Skip to content

Core Backend : ES Modules #7917

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
33 changes: 15 additions & 18 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
41 changes: 28 additions & 13 deletions core/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,51 @@
"name": "@itwin/core-backend",
"version": "5.0.0-dev.99",
"description": "iTwin.js backend components",
"type": "module",
"main": "lib/cjs/core-backend.js",
"module": "lib/esm/core-backend.js",
"typings": "lib/cjs/core-backend",
"exports": {
".": {
"require": {
"types": "./lib/cjs/core-backend",
"default": "./lib/cjs/core-backend.js"
},
"import": {
"types": "./lib/esm/core-backend",
"default": "./lib/esm/core-backend.js"
}
},
"./test": {
"import": {
"default": "./lib/esm/test/index.js"
}
},
"./internal": {
"import": "./lib/esm/internal/cross-package.js",
"require": "./lib/cjs/internal/cross-package.js"
}
},
"license": "MIT",
"engines": {
"node": "^20.0.0 || ^22.0.0"
},
"scripts": {
"build": "npm run -s build:cjs && npm run -s build:esm && npm run -s copy:assets && npm run -s copy:test-assets && npm run -s copy:ecsqltestmdfiles",
"build:cjs": "tsc 1>&2 --outDir lib/cjs",
"build:esm": "tsc 1>&2 --module ES2022 --outDir lib/esm",
"build:cjs": "internal-tools build-cjs",
"build:esm": "tsc 1>&2 --outDir lib/esm",
"clean": "rimraf -g lib .rush/temp/package-deps*.json ../../tools/internal/ios/core-test-runner/build ../../tools/internal/lib",
"docs": "betools docs --json=../../generated-docs/core/core-backend/file.json --tsIndexFile=./core-backend.ts --onlyJson --excludeGlob=**/*.d.ts",
"copy:assets": " npm run -s copy:assets:cjs && npm run -s copy:assets:esm",
"copy:assets:cjs": "cpx \"./src/assets/**/*\" ./lib/cjs/assets",
"copy:assets:esm": "cpx \"./src/assets/**/*\" ./lib/esm/assets",
"copy:ecsqltestmdfiles": "cpx \"./src/test/ecsql/queries/*\" ./lib/cjs/test/ecsql/queries",
"copy:ecsqltestmdfiles": "cpx \"./src/test/ecsql/queries/*\" ./lib/esm/test/ecsql/queries",
"copy:config": "internal-tools copy-config",
"copy:test-assets": "cpx \"./src/test/assets/**/*\" ./lib/cjs/test/assets",
"copy:test-assets": "cpx \"./src/test/assets/**/*\" ./lib/esm/test/assets",
"cover": "nyc npm -s test",
"extract-api": "betools extract-api --entry=core-backend",
"lint": "eslint \"./src/**/*.ts\" 1>&2",
"lint-fix": "eslint --fix -f visualstudio \"./src/**/*.ts\" 1>&2",
"test": "mocha",
"test:debug": "mocha --inspect-brk",
"test": "vitest --run",
"ios:webpack:tests": "TESTS_GLOB=./lib/esm/**/*.test.js webpack --config ../../tools/internal/ios/ios.webpack.config.js",
"ios:copy:assets": "cpx \"./src/test/assets/**/*\" ../../tools/internal/lib/ios/assets/assets && cpx \"./src/assets/**/*\" ../../tools/internal/lib/ios/assets/assets",
"ios:build:tests": "npm run -s build && npm run -s ios:webpack:tests && npm run -s ios:copy:assets",
Expand Down Expand Up @@ -75,25 +95,19 @@
"@itwin/ecsql-common": "workspace:*",
"@itwin/eslint-plugin": "5.0.0-dev.1",
"@opentelemetry/api": "1.0.4",
"@types/chai": "4.3.1",
"@types/chai-as-promised": "^7",
"@types/fs-extra": "^4.0.7",
"@types/mocha": "^10.0.6",
"@types/multiparty": "^0.0.31",
"@types/node": "~20.17.0",
"@types/semver": "7.3.10",
"@types/sinon": "^17.0.2",
"@types/touch": "^3.1.2",
"@types/ws": "^7.0.0",
"chai": "^4.3.10",
"chai-as-promised": "^7.1.1",
"cpx2": "^8.0.0",
"dotenv": "^16.4.5",
"dotenv-expand": "^5.1.0",
"eslint": "^9.13.0",
"fs-extra": "^8.1.0",
"internal-tools": "workspace:*",
"mocha": "^11.1.0",
"node-simctl": "~7.6.1",
"null-loader": "^4.0.1",
"nyc": "^17.1.0",
Expand All @@ -103,6 +117,7 @@
"typescript": "~5.6.2",
"marked": "^14.1.3",
"sql-formatter": "^15.4.6",
"vitest": "^3.0.6",
"webpack": "^5.97.1"
},
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions core/backend/src/BackendHubAccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import {
LockState as CommonLockState, IModelError, IModelVersion,
LocalDirName, LocalFileName,
} from "@itwin/core-common";
import { CheckpointProps, ProgressFunction } from "./CheckpointManager";
import type { TokenArg } from "./IModelDb";
import { CheckpointProps, ProgressFunction } from "./CheckpointManager.js";
import type { TokenArg } from "./IModelDb.js";

/** Exception thrown if lock cannot be acquired.
* @beta
Expand Down
32 changes: 16 additions & 16 deletions core/backend/src/BisCoreSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
* @module Schema
*/

import * as path from "path";
import * as categoryMod from "./Category";
import { ClassRegistry } from "./ClassRegistry";
import * as elementMod from "./Element";
import * as aspectMod from "./ElementAspect";
import * as externalSourceMod from "./ExternalSource";
import { KnownLocations } from "./IModelHost";
import * as materialMod from "./Material";
import * as modelMod from "./Model";
import * as linkMod from "./Relationship";
import { Schema, Schemas } from "./Schema";
import * as textureMod from "./Texture";
import * as viewMod from "./ViewDefinition";
import * as displayStyleMod from "./DisplayStyle";
import * as annotationsMod from "./TextAnnotationElement";
import * as sheetIndex from "./SheetIndex";
import path from "node:path";
import * as categoryMod from "./Category.js";
import { ClassRegistry } from "./ClassRegistry.js";
import * as elementMod from "./Element.js";
import * as aspectMod from "./ElementAspect.js";
import * as externalSourceMod from "./ExternalSource.js";
import { KnownLocations } from "./IModelHost.js";
import * as materialMod from "./Material.js";
import * as modelMod from "./Model.js";
import * as linkMod from "./Relationship.js";
import { Schema, Schemas } from "./Schema.js";
import * as textureMod from "./Texture.js";
import * as viewMod from "./ViewDefinition.js";
import * as displayStyleMod from "./DisplayStyle.js";
import * as annotationsMod from "./TextAnnotationElement.js";
import * as sheetIndex from "./SheetIndex.js";

/**
* The [BisCore]($docs/bis/guide/fundamentals/schemas-domains.md) schema is the lowest level Schema in an iModel.
Expand Down
2 changes: 1 addition & 1 deletion core/backend/src/BlobContainerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// spell:ignore datacenter

import { AccessToken, GuidString, Id64String } from "@itwin/core-bentley";
import { SettingsContainer } from "./workspace/Settings";
import { SettingsContainer } from "./workspace/Settings.js";

/**
* Types and functions for creating, deleting and authorizing access to cloud-based blob containers for an iTwin.
Expand Down
20 changes: 10 additions & 10 deletions core/backend/src/BriefcaseManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@

// cspell:ignore cset csets ecchanges

import * as path from "path";
import path from "node:path";
import {
AccessToken, BeDuration, ChangeSetStatus, GuidString, IModelHubStatus, IModelStatus, Logger, OpenMode, Optional, StopWatch,
} from "@itwin/core-bentley";
import {
BriefcaseId, BriefcaseIdValue, BriefcaseProps, ChangesetFileProps, ChangesetIndex, ChangesetIndexOrId, ChangesetProps, ChangesetRange, ChangesetType, IModelError, IModelVersion, LocalBriefcaseProps,
LocalDirName, LocalFileName, RequestNewBriefcaseProps,
} from "@itwin/core-common";
import { AcquireNewBriefcaseIdArg, IModelNameArg } from "./BackendHubAccess";
import { BackendLoggerCategory } from "./BackendLoggerCategory";
import { CheckpointManager, CheckpointProps, ProgressFunction } from "./CheckpointManager";
import { BriefcaseDb, IModelDb, TokenArg } from "./IModelDb";
import { IModelHost } from "./IModelHost";
import { IModelJsFs } from "./IModelJsFs";
import { SchemaSync } from "./SchemaSync";
import { _hubAccess, _nativeDb, _releaseAllLocks } from "./internal/Symbols";
import { IModelNative } from "./internal/NativePlatform";
import { AcquireNewBriefcaseIdArg, IModelNameArg } from "./BackendHubAccess.js";
import { BackendLoggerCategory } from "./BackendLoggerCategory.js";
import { CheckpointManager, CheckpointProps, ProgressFunction } from "./CheckpointManager.js";
import { BriefcaseDb, IModelDb, TokenArg } from "./IModelDb.js";
import { IModelHost } from "./IModelHost.js";
import { IModelJsFs } from "./IModelJsFs.js";
import { SchemaSync } from "./SchemaSync.js";
import { _hubAccess, _nativeDb, _releaseAllLocks } from "./internal/Symbols.js";
import { IModelNative } from "./internal/NativePlatform.js";

const loggerCategory = BackendLoggerCategory.IModelDb;

Expand Down
6 changes: 3 additions & 3 deletions core/backend/src/Category.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import { Id64, Id64String, JsonUtils } from "@itwin/core-bentley";
import {
BisCodeSpec, CategoryProps, Code, CodeScopeProps, CodeSpec, ElementProps, Rank, SubCategoryAppearance, SubCategoryProps,
} from "@itwin/core-common";
import { DefinitionElement } from "./Element";
import { IModelDb } from "./IModelDb";
import { CategoryOwnsSubCategories } from "./NavigationRelationship";
import { DefinitionElement } from "./Element.js";
import { IModelDb } from "./IModelDb.js";
import { CategoryOwnsSubCategories } from "./NavigationRelationship.js";

/** Defines the appearance for graphics in Geometric elements
* @public
Expand Down
18 changes: 9 additions & 9 deletions core/backend/src/ChangeSummaryManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

import { AccessToken, assert, DbResult, GuidString, Id64String, IModelStatus, Logger } from "@itwin/core-bentley";
import { ChangedValueState, ChangeOpCode, ChangesetRange, IModelError, IModelVersion } from "@itwin/core-common";
import * as path from "path";
import { BackendLoggerCategory } from "./BackendLoggerCategory";
import { BriefcaseManager } from "./BriefcaseManager";
import { ECDb, ECDbOpenMode } from "./ECDb";
import { ECSqlInsertResult, ECSqlStatement, ECSqlWriteStatement } from "./ECSqlStatement";
import { BriefcaseDb, IModelDb, TokenArg } from "./IModelDb";
import { IModelHost, KnownLocations } from "./IModelHost";
import { IModelJsFs } from "./IModelJsFs";
import { _hubAccess, _nativeDb } from "./internal/Symbols";
import path from "node:path";
import { BackendLoggerCategory } from "./BackendLoggerCategory.js";
import { BriefcaseManager } from "./BriefcaseManager.js";
import { ECDb, ECDbOpenMode } from "./ECDb.js";
import { ECSqlInsertResult, ECSqlStatement, ECSqlWriteStatement } from "./ECSqlStatement.js";
import { BriefcaseDb, IModelDb, TokenArg } from "./IModelDb.js";
import { IModelHost, KnownLocations } from "./IModelHost.js";
import { IModelJsFs } from "./IModelJsFs.js";
import { _hubAccess, _nativeDb } from "./internal/Symbols.js";

const loggerCategory: string = BackendLoggerCategory.ECDb;

Expand Down
12 changes: 6 additions & 6 deletions core/backend/src/ChangedElementsDb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
import { AccessToken, DbResult, IModelStatus, OpenMode } from "@itwin/core-bentley";
import { ChangeData, ChangedElements, ChangedModels, IModelError } from "@itwin/core-common";
import { IModelJsNative } from "@bentley/imodeljs-native";
import { BriefcaseManager } from "./BriefcaseManager";
import { ECDbOpenMode } from "./ECDb";
import { IModelDb } from "./IModelDb";
import { IModelHost } from "./IModelHost";
import { IModelNative } from "./internal/NativePlatform";
import { _hubAccess, _nativeDb } from "./internal/Symbols";
import { BriefcaseManager } from "./BriefcaseManager.js";
import { ECDbOpenMode } from "./ECDb.js";
import { IModelDb } from "./IModelDb.js";
import { IModelHost } from "./IModelHost.js";
import { IModelNative } from "./internal/NativePlatform.js";
import { _hubAccess, _nativeDb } from "./internal/Symbols.js";

/**
* Options for processChangesets function
Expand Down
2 changes: 1 addition & 1 deletion core/backend/src/ChangesetECAdaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @module ECDb
*/
import { DbResult, GuidString, Id64String } from "@itwin/core-bentley";
import { AnyDb, SqliteChange, SqliteChangeOp, SqliteChangesetReader, SqliteValueStage } from "./SqliteChangesetReader";
import { AnyDb, SqliteChange, SqliteChangeOp, SqliteChangesetReader, SqliteValueStage } from "./SqliteChangesetReader.js";

interface IClassRef {
classId: Id64String;
Expand Down
2 changes: 1 addition & 1 deletion core/backend/src/ChannelControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { Id64String } from "@itwin/core-bentley";
import { _implementationProhibited, _verifyChannel } from "./internal/Symbols";
import { _implementationProhibited, _verifyChannel } from "./internal/Symbols.js";

/** The key for a channel. Used for "allowed channels" in [[ChannelControl]]
* @beta
Expand Down
20 changes: 10 additions & 10 deletions core/backend/src/CheckpointManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@

// cspell:ignore BLOCKCACHE

import * as path from "path";
import path from "node:path";
import { NativeLoggerCategory } from "@bentley/imodeljs-native";
import { AccessToken, BeEvent, ChangeSetStatus, Guid, GuidString, IModelStatus, Logger, LogLevel, Mutable, OpenMode, StopWatch } from "@itwin/core-bentley";
import {
BriefcaseIdValue, ChangesetId, ChangesetIdWithIndex, ChangesetIndexAndId, IModelError, IModelVersion, LocalDirName, LocalFileName, OpenCheckpointArgs,
} from "@itwin/core-common";
import { V2CheckpointAccessProps } from "./BackendHubAccess";
import { BackendLoggerCategory } from "./BackendLoggerCategory";
import { BriefcaseManager } from "./BriefcaseManager";
import { CloudSqlite } from "./CloudSqlite";
import { IModelHost } from "./IModelHost";
import { IModelJsFs } from "./IModelJsFs";
import { SnapshotDb, TokenArg } from "./IModelDb";
import { IModelNative } from "./internal/NativePlatform";
import { _getCheckpointDb, _hubAccess, _nativeDb, _openCheckpoint } from "./internal/Symbols";
import { V2CheckpointAccessProps } from "./BackendHubAccess.js";
import { BackendLoggerCategory } from "./BackendLoggerCategory.js";
import { BriefcaseManager } from "./BriefcaseManager.js";
import { CloudSqlite } from "./CloudSqlite.js";
import { IModelHost } from "./IModelHost.js";
import { IModelJsFs } from "./IModelJsFs.js";
import { SnapshotDb, TokenArg } from "./IModelDb.js";
import { IModelNative } from "./internal/NativePlatform.js";
import { _getCheckpointDb, _hubAccess, _nativeDb, _openCheckpoint } from "./internal/Symbols.js";

const loggerCategory = BackendLoggerCategory.IModelDb;

Expand Down
Loading