@itwin/core-backend 5.1.0-dev.34 → 5.1.0-dev.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/ChangesetECAdaptor.d.ts +67 -8
- package/lib/cjs/ChangesetECAdaptor.d.ts.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.js +248 -33
- package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +1 -0
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/core-backend.d.ts.map +1 -1
- package/lib/cjs/core-backend.js +20 -0
- package/lib/cjs/core-backend.js.map +1 -1
- package/lib/esm/ChangesetECAdaptor.d.ts +67 -8
- package/lib/esm/ChangesetECAdaptor.d.ts.map +1 -1
- package/lib/esm/ChangesetECAdaptor.js +248 -33
- package/lib/esm/ChangesetECAdaptor.js.map +1 -1
- package/lib/esm/IModelDb.d.ts.map +1 -1
- package/lib/esm/IModelDb.js +1 -0
- package/lib/esm/IModelDb.js.map +1 -1
- package/lib/esm/core-backend.d.ts.map +1 -1
- package/lib/esm/core-backend.js +20 -0
- package/lib/esm/core-backend.js.map +1 -1
- package/lib/esm/test/imodel/IModel.test.js +27 -0
- package/lib/esm/test/imodel/IModel.test.js.map +1 -1
- package/lib/esm/test/standalone/ChangesetReader.test.js +294 -136
- package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -1
- package/package.json +13 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-backend.d.ts","sourceRoot":"","sources":["../../src/core-backend.ts"],"names":[],"mappings":"AAKA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qCAAqC,CAAC;AACpD,cAAc,sCAAsC,CAAC;AACrD,cAAc,iCAAiC,CAAC;AAChD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,c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ACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AAErC,cAAc,0BAA0B,CAAC;AA2BzC;;;;GAIG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;IAGI;AAEJ;;;GAGG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;;GAIG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;GAGG;AAEH;;GAEG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;GAGG"}
|
package/lib/cjs/core-backend.js
CHANGED
|
@@ -95,6 +95,26 @@ __exportStar(require("./workspace/WorkspaceEditor"), exports);
|
|
|
95
95
|
__exportStar(require("./SqliteChangesetReader"), exports);
|
|
96
96
|
__exportStar(require("./ChangesetECAdaptor"), exports);
|
|
97
97
|
__exportStar(require("./internal/cross-package"), exports);
|
|
98
|
+
const globalSymbolCoreBackend = Symbol.for("itwin.core.backend.globals");
|
|
99
|
+
if (globalThis[globalSymbolCoreBackend]) {
|
|
100
|
+
// Get the stack trace from when the module was first loaded
|
|
101
|
+
const firstLoadStack = globalThis[globalSymbolCoreBackend].stack;
|
|
102
|
+
const error = new Error("Multiple @itwin/core-backend imports detected! This may happen if:\n" +
|
|
103
|
+
"- You have multiple versions of the package installed\n" +
|
|
104
|
+
"- Your bundling configuration is incorrect\n" +
|
|
105
|
+
"- You're importing from both ESM and CommonJS versions");
|
|
106
|
+
/* eslint-disable no-console */
|
|
107
|
+
console.error("Duplicate @itwin/core-backend import:", error);
|
|
108
|
+
console.error("First import occurred at:", firstLoadStack);
|
|
109
|
+
console.error("Current import occurred at:", error.stack);
|
|
110
|
+
/* eslint-enable no-console */
|
|
111
|
+
throw error;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
globalThis[globalSymbolCoreBackend] = {
|
|
115
|
+
stack: new Error().stack,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
98
118
|
/** @docs-package-description
|
|
99
119
|
* The core-backend package always runs on the computer with a local Briefcase.
|
|
100
120
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-backend.js","sourceRoot":"","sources":["../../src/core-backend.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;;;;;;;;;;;;;AAE/F,8DAA4C;AAC5C,sEAAoD;AACpD,uEAAqD;AACrD,kEAAgD;AAChD,gEAA8C;AAC9C,qDAAmC;AACnC,0DAAwC;AACxC,kDAAgC;AAChC,yDAAuC;AACvC,qDAAmC;AACnC,8CAA4B;AAC5B,6CAA2B;AAC3B,sDAAoC;AACpC,yDAAuC;AACvC,mDAAiC;AACjC,sDAAoC;AACpC,kDAAgC;AAChC,gDAA8B;AAC9B,gDAA8B;AAC9B,8CAA4B;AAC5B,6CAA2B;AAC3B,iDAA+B;AAC/B,+DAA6C;AAC7C,6DAA2C;AAC3C,4DAA0C;AAC1C,0DAAwC;AACxC,yCAAuB;AACvB,uDAAqC;AACrC,mDAAiC;AACjC,4CAA0B;AAC1B,kDAAgC;AAChC,oDAAkC;AAClC,sDAAoC;AACpC,2CAAyB;AACzB,qDAAmC;AACnC,mDAAiC;AACjC,mDAAiC;AACjC,6CAA2B;AAC3B,mDAAiC;AACjC,0DAAwC;AACxC,0DAAwC;AACxC,6CAA2B;AAC3B,kDAAgC;AAChC,8DAA4C;AAC5C,+CAA6B;AAC7B,+CAA6B;AAC7B,+CAA6B;AAC7B,4CAA0B;AAC1B,8CAA4B;AAC5B,qDAAmC;AACnC,6CAA2B;AAC3B,gDAA8B;AAC9B,6CAA2B;AAC3B,0CAAwB;AACxB,qDAAmC;AACnC,+CAA6B;AAC7B,2DAAyC;AACzC,kDAAgC;AAChC,iDAA+B;AAC/B,gDAA8B;AAC9B,2CAAyB;AACzB,gDAA8B;AAC9B,+CAA6B;AAC7B,6CAA2B;AAC3B,oDAAkC;AAClC,4CAA0B;AAC1B,gDAA8B;AAC9B,+CAA6B;AAC7B,mDAAiC;AACjC,8CAA4B;AAC5B,uDAAqC;AACrC,8DAA4C;AAC5C,wDAAsC;AACtC,8DAA4C;AAC5C,0DAAwC;AACxC,uDAAqC;AAErC,2DAAyC;AAEzC;;;;GAIG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;IAGI;AAEJ;;;GAGG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;;GAIG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;GAGG;AAEH;;GAEG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;GAGG","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nexport * from \"./annotations/FrameGeometry\";\nexport * from \"./annotations/TextAnnotationElement\";\nexport * from \"./annotations/TextAnnotationGeometry\";\nexport * from \"./annotations/TextBlockGeometry\";\nexport * from \"./annotations/TextBlockLayout\";\nexport * from \"./BackendHubAccess\";\nexport * from \"./BackendLoggerCategory\";\nexport * from \"./BisCoreSchema\";\nexport * from \"./BlobContainerService\";\nexport * from \"./BriefcaseManager\";\nexport * from \"./CatalogDb\";\nexport * from \"./Category\";\nexport * from \"./ChangedElementsDb\";\nexport * from \"./ChangeSummaryManager\";\nexport * from \"./ChannelControl\";\nexport * from \"./CheckpointManager\";\nexport * from \"./ClassRegistry\";\nexport * from \"./CloudSqlite\";\nexport * from \"./CodeService\";\nexport * from \"./CodeSpecs\";\nexport * from \"./DevTools\";\nexport * from \"./DisplayStyle\";\nexport * from \"./domains/FunctionalElements\";\nexport * from \"./domains/FunctionalSchema\";\nexport * from \"./domains/GenericElements\";\nexport * from \"./domains/GenericSchema\";\nexport * from \"./ECDb\";\nexport * from \"./ECSchemaXmlContext\";\nexport * from \"./ECSqlStatement\";\nexport * from \"./Element\";\nexport * from \"./ElementAspect\";\nexport * from \"./ElementGraphics\";\nexport * from \"./ElementTreeWalker\";\nexport * from \"./Entity\";\nexport * from \"./EntityReferences\";\nexport * from \"./ExportGraphics\";\nexport * from \"./ExternalSource\";\nexport * from \"./FontFile\";\nexport * from \"./GeoCoordConfig\";\nexport * from \"./GeographicCRSServices\";\nexport * from \"./ImageSourceConversion\";\nexport * from \"./IModelDb\";\nexport * from \"./IModelDbFonts\";\nexport * from \"./IModelElementCloneContext\";\nexport * from \"./IModelHost\";\nexport * from \"./IModelJsFs\";\nexport * from \"./SchemaSync\";\nexport * from \"./IpcHost\";\nexport * from \"./LineStyle\";\nexport * from \"./LocalhostIpcHost\";\nexport * from \"./LocalHub\";\nexport * from \"./LockControl\";\nexport * from \"./Material\";\nexport * from \"./Model\";\nexport * from \"./NativeAppStorage\";\nexport * from \"./NativeHost\";\nexport * from \"./NavigationRelationship\";\nexport * from \"./PropertyStore\";\nexport * from \"./Relationship\";\nexport * from \"./rpc/tracing\";\nexport * from \"./Schema\";\nexport * from \"./SchemaUtils\";\nexport * from \"./SheetIndex\";\nexport * from \"./SQLiteDb\";\nexport * from \"./SqliteStatement\";\nexport * from \"./Texture\";\nexport * from \"./TileStorage\";\nexport * from \"./TxnManager\";\nexport * from \"./ViewDefinition\";\nexport * from \"./ViewStore\";\nexport * from \"./workspace/Settings\";\nexport * from \"./workspace/SettingsSchemas\";\nexport * from \"./workspace/Workspace\";\nexport * from \"./workspace/WorkspaceEditor\";\nexport * from \"./SqliteChangesetReader\";\nexport * from \"./ChangesetECAdaptor\";\n\nexport * from \"./internal/cross-package\";\n\n/** @docs-package-description\n * The core-backend package always runs on the computer with a local Briefcase.\n *\n * It contains classes that [backend code]($docs/learning/backend/index.md) can use to work with directly with iModels.\n */\n\n/**\n * @docs-group-description BlobContainers\n * Classes for working with cloud-based blob containers.\n */\n\n/**\n * @docs-group-description Codes\n * Classes for working with [Codes]($docs/BIS/guide/fundamentals/codes.md).\n * See [the learning articles]($docs/learning/backend/index.md).\n */\n\n/**\n * @docs-group-description ECDb\n * Classes for working with ECDb.\n */\n\n/**\n * @docs-group-description ECSQL\n * Classes for working with [ECSQL]($docs/learning/ECSQL.md)\n */\n\n/**\n * @docs-group-description ElementAspects\n * Subclasses of [ElementAspects]($docs/bis/guide/fundamentals/elementaspect-fundamentals.md).\n * See [the learning articles]($docs/learning/backend/index.md).\n */\n\n/**\n * @docs-group-description ElementGeometry\n * Classes for defining the symbology and geometry of geometric elements\n */\n\n/**\n * @docs-group-description Elements\n * Subclasses of [Elements]($docs/BIS/guide/fundamentals/element-fundamentals.md).\n * See [the learning articles]($docs/learning/backend/index.md).\n */\n\n/**\n * @docs-group-description ExportGraphics\n * APIs for producing low-level graphics primitives from element geometry.\n */\n\n/**\n * @docs-group-description HubAccess\n * APIs for working with IModelHub\n */\n\n/**\n * @docs-group-description Images\n * APIs for encoding and decoding images\n */\n\n/**\n * @docs-group-description IModelHost\n * Classes for configuring and administering the backend [host]($docs/learning/backend/IModelHost.md).\n * See [the learning article]($docs/learning/backend/IModelHost.md).\n */\n\n/**\n * @docs-group-description iModels\n * Classes for working with [iModels]($docs/learning/iModels.md).\n * See [the learning article]($docs/learning/backend/index.md).\n */\n\n/**\n * @docs-group-description Logging\n * Logger categories used by this package.\n */\n\n/**\n * @docs-group-description Models\n * Subclasses of [Models]($docs/BIS/guide/fundamentals/model-fundamentals.md).\n * See [the learning articles]($docs/learning/backend/index.md).\n */\n\n/**\n * @docs-group-description NativeApp\n * Classes for working with Mobile/Desktop Application.\n */\n\n/**\n * @docs-group-description Portability\n */\n\n/**\n * @docs-group-description Relationships\n * Classes that describe the [relationships]($docs/bis/guide/fundamentals/relationship-fundamentals.md) between elements.\n */\n\n/**\n * @docs-group-description RpcInterface\n * Classes for working with [RpcInterfaces]($docs/learning/RpcInterface.md).\n */\n\n/**\n * @docs-group-description Schema\n * Classes for working with [ECSchemas]($docs/learning/backend/SchemasAndElementsInTypeScript.md)\n */\n\n/**\n * @docs-group-description SQLite\n * Classes for working directly with SQLite\n */\n\n/**\n * @docs-group-description SQLiteDb\n * Classes for working with SQLiteDb.\n */\n\n/**\n * @docs-group-description TileStorage\n * Class for working with cloud storage using iTwin/object-storage cloud providers\n */\n\n/**\n * @docs-group-description ViewDefinitions\n * Classes for working with Elements that define what appears in [Views]($docs/learning/frontend/views.md).\n * See [the learning articles]($docs/learning/backend/createelements/#orthographicviewdefinition).\n */\n\n/**\n * @docs-group-description Workspace\n * APIs for loading and using Settings and Workspace resources\n */\n"]}
|
|
1
|
+
{"version":3,"file":"core-backend.js","sourceRoot":"","sources":["../../src/core-backend.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;;;;;;;;;;;;;AAE/F,8DAA4C;AAC5C,sEAAoD;AACpD,uEAAqD;AACrD,kEAAgD;AAChD,gEAA8C;AAC9C,qDAAmC;AACnC,0DAAwC;AACxC,kDAAgC;AAChC,yDAAuC;AACvC,qDAAmC;AACnC,8CAA4B;AAC5B,6CAA2B;AAC3B,sDAAoC;AACpC,yDAAuC;AACvC,mDAAiC;AACjC,sDAAoC;AACpC,kDAAgC;AAChC,gDAA8B;AAC9B,gDAA8B;AAC9B,8CAA4B;AAC5B,6CAA2B;AAC3B,iDAA+B;AAC/B,+DAA6C;AAC7C,6DAA2C;AAC3C,4DAA0C;AAC1C,0DAAwC;AACxC,yCAAuB;AACvB,uDAAqC;AACrC,mDAAiC;AACjC,4CAA0B;AAC1B,kDAAgC;AAChC,oDAAkC;AACl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,MAAM,KAAK,CAAC;AACd,CAAC;KAAM,CAAC;IACL,UAAkB,CAAC,uBAAuB,CAAC,GAAG;QAC7C,KAAK,EAAE,IAAI,KAAK,EAAE,CAAC,KAAK;KACzB,CAAC;AACJ,CAAC;AAED;;;;GAIG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;IAGI;AAEJ;;;GAGG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;;GAIG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;GAGG;AAEH;;GAEG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;GAGG","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nexport * from \"./annotations/FrameGeometry\";\nexport * from \"./annotations/TextAnnotationElement\";\nexport * from \"./annotations/TextAnnotationGeometry\";\nexport * from \"./annotations/TextBlockGeometry\";\nexport * from \"./annotations/TextBlockLayout\";\nexport * from \"./BackendHubAccess\";\nexport * from \"./BackendLoggerCategory\";\nexport * from \"./BisCoreSchema\";\nexport * from \"./BlobContainerService\";\nexport * from \"./BriefcaseManager\";\nexport * from \"./CatalogDb\";\nexport * from \"./Category\";\nexport * from \"./ChangedElementsDb\";\nexport * from \"./ChangeSummaryManager\";\nexport * from \"./ChannelControl\";\nexport * from \"./CheckpointManager\";\nexport * from \"./ClassRegistry\";\nexport * from \"./CloudSqlite\";\nexport * from \"./CodeService\";\nexport * from \"./CodeSpecs\";\nexport * from \"./DevTools\";\nexport * from \"./DisplayStyle\";\nexport * from \"./domains/FunctionalElements\";\nexport * from \"./domains/FunctionalSchema\";\nexport * from \"./domains/GenericElements\";\nexport * from \"./domains/GenericSchema\";\nexport * from \"./ECDb\";\nexport * from \"./ECSchemaXmlContext\";\nexport * from \"./ECSqlStatement\";\nexport * from \"./Element\";\nexport * from \"./ElementAspect\";\nexport * from \"./ElementGraphics\";\nexport * from \"./ElementTreeWalker\";\nexport * from \"./Entity\";\nexport * from \"./EntityReferences\";\nexport * from \"./ExportGraphics\";\nexport * from \"./ExternalSource\";\nexport * from \"./FontFile\";\nexport * from \"./GeoCoordConfig\";\nexport * from \"./GeographicCRSServices\";\nexport * from \"./ImageSourceConversion\";\nexport * from \"./IModelDb\";\nexport * from \"./IModelDbFonts\";\nexport * from \"./IModelElementCloneContext\";\nexport * from \"./IModelHost\";\nexport * from \"./IModelJsFs\";\nexport * from \"./SchemaSync\";\nexport * from \"./IpcHost\";\nexport * from \"./LineStyle\";\nexport * from \"./LocalhostIpcHost\";\nexport * from \"./LocalHub\";\nexport * from \"./LockControl\";\nexport * from \"./Material\";\nexport * from \"./Model\";\nexport * from \"./NativeAppStorage\";\nexport * from \"./NativeHost\";\nexport * from \"./NavigationRelationship\";\nexport * from \"./PropertyStore\";\nexport * from \"./Relationship\";\nexport * from \"./rpc/tracing\";\nexport * from \"./Schema\";\nexport * from \"./SchemaUtils\";\nexport * from \"./SheetIndex\";\nexport * from \"./SQLiteDb\";\nexport * from \"./SqliteStatement\";\nexport * from \"./Texture\";\nexport * from \"./TileStorage\";\nexport * from \"./TxnManager\";\nexport * from \"./ViewDefinition\";\nexport * from \"./ViewStore\";\nexport * from \"./workspace/Settings\";\nexport * from \"./workspace/SettingsSchemas\";\nexport * from \"./workspace/Workspace\";\nexport * from \"./workspace/WorkspaceEditor\";\nexport * from \"./SqliteChangesetReader\";\nexport * from \"./ChangesetECAdaptor\";\n\nexport * from \"./internal/cross-package\";\n\nconst globalSymbolCoreBackend = Symbol.for(\"itwin.core.backend.globals\");\nif ((globalThis as any)[globalSymbolCoreBackend]) {\n // Get the stack trace from when the module was first loaded\n const firstLoadStack = (globalThis as any)[globalSymbolCoreBackend].stack;\n\n const error = new Error(\n \"Multiple @itwin/core-backend imports detected! This may happen if:\\n\" +\n \"- You have multiple versions of the package installed\\n\" +\n \"- Your bundling configuration is incorrect\\n\" +\n \"- You're importing from both ESM and CommonJS versions\"\n );\n\n /* eslint-disable no-console */\n console.error(\"Duplicate @itwin/core-backend import:\", error);\n console.error(\"First import occurred at:\", firstLoadStack);\n console.error(\"Current import occurred at:\", error.stack);\n /* eslint-enable no-console */\n\n throw error;\n} else {\n (globalThis as any)[globalSymbolCoreBackend] = {\n stack: new Error().stack,\n };\n}\n\n/** @docs-package-description\n * The core-backend package always runs on the computer with a local Briefcase.\n *\n * It contains classes that [backend code]($docs/learning/backend/index.md) can use to work with directly with iModels.\n */\n\n/**\n * @docs-group-description BlobContainers\n * Classes for working with cloud-based blob containers.\n */\n\n/**\n * @docs-group-description Codes\n * Classes for working with [Codes]($docs/BIS/guide/fundamentals/codes.md).\n * See [the learning articles]($docs/learning/backend/index.md).\n */\n\n/**\n * @docs-group-description ECDb\n * Classes for working with ECDb.\n */\n\n/**\n * @docs-group-description ECSQL\n * Classes for working with [ECSQL]($docs/learning/ECSQL.md)\n */\n\n/**\n * @docs-group-description ElementAspects\n * Subclasses of [ElementAspects]($docs/bis/guide/fundamentals/elementaspect-fundamentals.md).\n * See [the learning articles]($docs/learning/backend/index.md).\n */\n\n/**\n * @docs-group-description ElementGeometry\n * Classes for defining the symbology and geometry of geometric elements\n */\n\n/**\n * @docs-group-description Elements\n * Subclasses of [Elements]($docs/BIS/guide/fundamentals/element-fundamentals.md).\n * See [the learning articles]($docs/learning/backend/index.md).\n */\n\n/**\n * @docs-group-description ExportGraphics\n * APIs for producing low-level graphics primitives from element geometry.\n */\n\n/**\n * @docs-group-description HubAccess\n * APIs for working with IModelHub\n */\n\n/**\n * @docs-group-description Images\n * APIs for encoding and decoding images\n */\n\n/**\n * @docs-group-description IModelHost\n * Classes for configuring and administering the backend [host]($docs/learning/backend/IModelHost.md).\n * See [the learning article]($docs/learning/backend/IModelHost.md).\n */\n\n/**\n * @docs-group-description iModels\n * Classes for working with [iModels]($docs/learning/iModels.md).\n * See [the learning article]($docs/learning/backend/index.md).\n */\n\n/**\n * @docs-group-description Logging\n * Logger categories used by this package.\n */\n\n/**\n * @docs-group-description Models\n * Subclasses of [Models]($docs/BIS/guide/fundamentals/model-fundamentals.md).\n * See [the learning articles]($docs/learning/backend/index.md).\n */\n\n/**\n * @docs-group-description NativeApp\n * Classes for working with Mobile/Desktop Application.\n */\n\n/**\n * @docs-group-description Portability\n */\n\n/**\n * @docs-group-description Relationships\n * Classes that describe the [relationships]($docs/bis/guide/fundamentals/relationship-fundamentals.md) between elements.\n */\n\n/**\n * @docs-group-description RpcInterface\n * Classes for working with [RpcInterfaces]($docs/learning/RpcInterface.md).\n */\n\n/**\n * @docs-group-description Schema\n * Classes for working with [ECSchemas]($docs/learning/backend/SchemasAndElementsInTypeScript.md)\n */\n\n/**\n * @docs-group-description SQLite\n * Classes for working directly with SQLite\n */\n\n/**\n * @docs-group-description SQLiteDb\n * Classes for working with SQLiteDb.\n */\n\n/**\n * @docs-group-description TileStorage\n * Class for working with cloud storage using iTwin/object-storage cloud providers\n */\n\n/**\n * @docs-group-description ViewDefinitions\n * Classes for working with Elements that define what appears in [Views]($docs/learning/frontend/views.md).\n * See [the learning articles]($docs/learning/backend/createelements/#orthographicviewdefinition).\n */\n\n/**\n * @docs-group-description Workspace\n * APIs for loading and using Settings and Workspace resources\n */\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @module ECDb
|
|
3
3
|
*/
|
|
4
4
|
import { Id64String } from "@itwin/core-bentley";
|
|
5
|
-
import { SqliteChangeOp, SqliteChangesetReader, SqliteValueStage } from "./SqliteChangesetReader";
|
|
5
|
+
import { AnyDb, SqliteChangeOp, SqliteChangesetReader, SqliteValueStage } from "./SqliteChangesetReader";
|
|
6
6
|
/**
|
|
7
7
|
* Record meta data for the change.
|
|
8
8
|
* @beta
|
|
@@ -31,33 +31,96 @@ export interface ChangedECInstance {
|
|
|
31
31
|
$meta?: ChangeMetaData;
|
|
32
32
|
[key: string]: any;
|
|
33
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Represents a cache for unifying EC changes.
|
|
36
|
+
* @beta
|
|
37
|
+
*/
|
|
38
|
+
export interface ECChangeUnifierCache extends Disposable {
|
|
39
|
+
/**
|
|
40
|
+
* Retrieves the value associated with the specified key from the cache.
|
|
41
|
+
* @param key - The key to retrieve the value for.
|
|
42
|
+
* @returns The value associated with the key, or undefined if the key is not found.
|
|
43
|
+
*/
|
|
44
|
+
get(key: string): ChangedECInstance | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Sets the value associated with the specified key in the cache.
|
|
47
|
+
* @param key - The key to set the value for.
|
|
48
|
+
* @param value - The value to be associated with the key.
|
|
49
|
+
*/
|
|
50
|
+
set(key: string, value: ChangedECInstance): void;
|
|
51
|
+
/**
|
|
52
|
+
* Returns an iterator for all the values in the cache.
|
|
53
|
+
* @returns An iterator for all the values in the cache.
|
|
54
|
+
*/
|
|
55
|
+
all(): IterableIterator<ChangedECInstance>;
|
|
56
|
+
/**
|
|
57
|
+
* Returns the number of entries in the cache.
|
|
58
|
+
* @returns The number of entries in the cache.
|
|
59
|
+
*/
|
|
60
|
+
count(): number;
|
|
61
|
+
}
|
|
62
|
+
/** @beta */
|
|
63
|
+
export declare namespace ECChangeUnifierCache {
|
|
64
|
+
/**
|
|
65
|
+
* Creates and returns a new in-memory cache for EC change unification.
|
|
66
|
+
* @note This cache is fast but recommended for small to medium size changesets. As it store changes in memory using a hash map, it may run out of memory for larger changesets.
|
|
67
|
+
* @returns {ECChangeUnifierCache} An instance of cache that store changes in memory using a hash map.
|
|
68
|
+
*/
|
|
69
|
+
function createInMemoryCache(): ECChangeUnifierCache;
|
|
70
|
+
/**
|
|
71
|
+
* Creates an ECChangeUnifierCache that is backed by a database.
|
|
72
|
+
* @note This cache is suitable for larger changesets and uses SQLite to store changes. It is slower than the in-memory cache but can handle larger datasets without running out of memory.
|
|
73
|
+
* @param db - The database instance to use for caching.
|
|
74
|
+
* @param bufferedReadInstanceSizeInBytes - The size in bytes for buffered read instances. Defaults to 10 MB.
|
|
75
|
+
* @returns An instance of ECChangeUnifierCache backed by SQLite temp db.
|
|
76
|
+
*/
|
|
77
|
+
function createSqliteBackedCache(db: AnyDb, bufferedReadInstanceSizeInBytes?: number): ECChangeUnifierCache;
|
|
78
|
+
}
|
|
34
79
|
/**
|
|
35
80
|
* Combine partial changed instance into single instance.
|
|
36
81
|
* Partial changes is per table and a single instance can
|
|
37
82
|
* span multiple tables.
|
|
38
83
|
* @beta
|
|
39
84
|
*/
|
|
40
|
-
export declare class PartialECChangeUnifier {
|
|
85
|
+
export declare class PartialECChangeUnifier implements Disposable {
|
|
86
|
+
private _db;
|
|
41
87
|
private _cache;
|
|
42
88
|
private _readonly;
|
|
89
|
+
constructor(_db: AnyDb, _cache?: ECChangeUnifierCache);
|
|
90
|
+
/**
|
|
91
|
+
* Dispose the instance.
|
|
92
|
+
*/
|
|
93
|
+
[Symbol.dispose](): void;
|
|
43
94
|
/**
|
|
44
95
|
* Get root class id for a given class
|
|
45
96
|
* @param classId given class id
|
|
46
97
|
* @param db use to find root class
|
|
47
98
|
* @returns return root class id
|
|
48
99
|
*/
|
|
49
|
-
private
|
|
100
|
+
private getRootClassId;
|
|
101
|
+
/**
|
|
102
|
+
* Checks if the given `rhsClassId` is an instance of the `lhsClassId`.
|
|
103
|
+
* @param rhsClassId The ID of the right-hand side class.
|
|
104
|
+
* @param lhsClassId The ID of the left-hand side class.
|
|
105
|
+
* @returns `true` if `rhsClassId` is an instance of `lhsClassId`, `false` otherwise.
|
|
106
|
+
*/
|
|
107
|
+
private instanceOf;
|
|
50
108
|
/**
|
|
51
109
|
* Combine partial instance with instance with same key if already exists.
|
|
52
110
|
* @param rhs partial instance
|
|
53
111
|
*/
|
|
54
112
|
private combine;
|
|
113
|
+
/**
|
|
114
|
+
* Returns the number of instances in the cache.
|
|
115
|
+
* @returns The number of instances in the cache.
|
|
116
|
+
*/
|
|
117
|
+
getInstanceCount(): number;
|
|
55
118
|
/**
|
|
56
119
|
* Build key from EC change.
|
|
57
120
|
* @param change EC change
|
|
58
121
|
* @returns key created from EC change.
|
|
59
122
|
*/
|
|
60
|
-
private
|
|
123
|
+
private buildKey;
|
|
61
124
|
/**
|
|
62
125
|
* Append partial changes which will be combine using there instance key.
|
|
63
126
|
* @note $meta property must be present on partial change as information
|
|
@@ -66,10 +129,6 @@ export declare class PartialECChangeUnifier {
|
|
|
66
129
|
* @beta
|
|
67
130
|
*/
|
|
68
131
|
appendFrom(adaptor: ChangesetECAdaptor): void;
|
|
69
|
-
/**
|
|
70
|
-
* Delete $meta from all the instances.
|
|
71
|
-
*/
|
|
72
|
-
stripMetaData(): void;
|
|
73
132
|
/**
|
|
74
133
|
* Returns complete EC change instances.
|
|
75
134
|
* @beta
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChangesetECAdaptor.d.ts","sourceRoot":"","sources":["../../src/ChangesetECAdaptor.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,
|
|
1
|
+
{"version":3,"file":"ChangesetECAdaptor.d.ts","sourceRoot":"","sources":["../../src/ChangesetECAdaptor.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,EAA8B,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAE,KAAK,EAAgB,cAAc,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAuVvH;;;KAGK;AACL,MAAM,WAAW,cAAc;IAC7B,8CAA8C;IAC9C,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,+CAA+C;IAC/C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,8CAA8C;IAC9C,EAAE,EAAE,cAAc,CAAC;IACnB,mDAAmD;IACnD,KAAK,EAAE,gBAAgB,CAAC;IACxB,sFAAsF;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G;IACH,OAAO,CAAC,gBAAgB;IAWxB,qCAAqC;IACrC,IAAW,EAAE,mBAA6B;IAC1C,0DAA0D;IAC1D,IAAW,UAAU,YAAqC;IAC1D,yDAAyD;IACzD,IAAW,SAAS,YAAoC;IACxD,yDAAyD;IACzD,IAAW,SAAS,YAAoC;IAExD;;;OAGG;IACI,IAAI,IAAI,OAAO;IA4GtB;;;;;OAKG;IACH,OAAO,CAAC,2BAA2B;IAwBnC;;;;;;OAMG;IACH,OAAO,CAAC,SAAS;CA6ClB"}
|
|
@@ -5,7 +5,10 @@
|
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module ECDb
|
|
7
7
|
*/
|
|
8
|
-
import { DbResult } from "@itwin/core-bentley";
|
|
8
|
+
import { DbResult, Guid } from "@itwin/core-bentley";
|
|
9
|
+
import { Base64EncodedString } from "@itwin/core-common";
|
|
10
|
+
import { ECDb } from "./ECDb";
|
|
11
|
+
import { _nativeDb } from "./internal/Symbols";
|
|
9
12
|
class ECDbMap {
|
|
10
13
|
db;
|
|
11
14
|
_cachedClassMaps = new Map();
|
|
@@ -318,6 +321,199 @@ var DateTime;
|
|
|
318
321
|
}
|
|
319
322
|
DateTime.fromJulianDay = fromJulianDay;
|
|
320
323
|
})(DateTime || (DateTime = {}));
|
|
324
|
+
/** @beta */
|
|
325
|
+
export var ECChangeUnifierCache;
|
|
326
|
+
(function (ECChangeUnifierCache) {
|
|
327
|
+
/**
|
|
328
|
+
* Creates and returns a new in-memory cache for EC change unification.
|
|
329
|
+
* @note This cache is fast but recommended for small to medium size changesets. As it store changes in memory using a hash map, it may run out of memory for larger changesets.
|
|
330
|
+
* @returns {ECChangeUnifierCache} An instance of cache that store changes in memory using a hash map.
|
|
331
|
+
*/
|
|
332
|
+
function createInMemoryCache() {
|
|
333
|
+
return new InMemoryInstanceCache();
|
|
334
|
+
}
|
|
335
|
+
ECChangeUnifierCache.createInMemoryCache = createInMemoryCache;
|
|
336
|
+
/**
|
|
337
|
+
* Creates an ECChangeUnifierCache that is backed by a database.
|
|
338
|
+
* @note This cache is suitable for larger changesets and uses SQLite to store changes. It is slower than the in-memory cache but can handle larger datasets without running out of memory.
|
|
339
|
+
* @param db - The database instance to use for caching.
|
|
340
|
+
* @param bufferedReadInstanceSizeInBytes - The size in bytes for buffered read instances. Defaults to 10 MB.
|
|
341
|
+
* @returns An instance of ECChangeUnifierCache backed by SQLite temp db.
|
|
342
|
+
*/
|
|
343
|
+
function createSqliteBackedCache(db, bufferedReadInstanceSizeInBytes = 1024 * 1024 * 10) {
|
|
344
|
+
return new SqliteBackedInstanceCache(db, bufferedReadInstanceSizeInBytes);
|
|
345
|
+
}
|
|
346
|
+
ECChangeUnifierCache.createSqliteBackedCache = createSqliteBackedCache;
|
|
347
|
+
})(ECChangeUnifierCache || (ECChangeUnifierCache = {}));
|
|
348
|
+
/**
|
|
349
|
+
* In-memory cache for storing changed EC instances.
|
|
350
|
+
*/
|
|
351
|
+
class InMemoryInstanceCache {
|
|
352
|
+
_cache = new Map();
|
|
353
|
+
/**
|
|
354
|
+
* Retrieves the changed EC instance associated with the specified key.
|
|
355
|
+
* @param key - The key used to retrieve the instance.
|
|
356
|
+
* @returns The changed EC instance, or undefined if not found.
|
|
357
|
+
*/
|
|
358
|
+
get(key) {
|
|
359
|
+
return this._cache.get(key);
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Sets the changed EC instance associated with the specified key.
|
|
363
|
+
* @param key - The key used to store the instance.
|
|
364
|
+
* @param value - The changed EC instance to be stored.
|
|
365
|
+
*/
|
|
366
|
+
set(key, value) {
|
|
367
|
+
const meta = value.$meta;
|
|
368
|
+
// Remove undefined keys
|
|
369
|
+
if (meta) {
|
|
370
|
+
Object.keys(meta).forEach((k) => meta[k] === undefined && delete meta[k]);
|
|
371
|
+
}
|
|
372
|
+
this._cache.set(key, value);
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Returns an iterator over all the changed EC instances in the cache.
|
|
376
|
+
* @returns An iterator over all the changed EC instances.
|
|
377
|
+
*/
|
|
378
|
+
*all() {
|
|
379
|
+
for (const key of Array.from(this._cache.keys()).sort()) {
|
|
380
|
+
const instance = this._cache.get(key);
|
|
381
|
+
if (instance) {
|
|
382
|
+
yield instance;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Returns the number of changed EC instances in the cache.
|
|
388
|
+
* @returns The number of changed EC instances.
|
|
389
|
+
*/
|
|
390
|
+
count() {
|
|
391
|
+
return this._cache.size;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Disposes the cache.
|
|
395
|
+
*/
|
|
396
|
+
[Symbol.dispose]() {
|
|
397
|
+
// Implementation details
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Represents a cache for unifying EC changes in a SQLite-backed instance cache.
|
|
402
|
+
*/
|
|
403
|
+
class SqliteBackedInstanceCache {
|
|
404
|
+
_db;
|
|
405
|
+
bufferedReadInstanceSizeInBytes;
|
|
406
|
+
_cacheTable = `[temp].[${Guid.createValue()}]`;
|
|
407
|
+
static defaultBufferSize = 1024 * 1024 * 10; // 10MB
|
|
408
|
+
/**
|
|
409
|
+
* Creates an instance of SqliteBackedInstanceCache.
|
|
410
|
+
* @param _db The underlying database connection.
|
|
411
|
+
* @param bufferedReadInstanceSizeInBytes The size of read instance buffer defaults to 10Mb.
|
|
412
|
+
* @throws Error if bufferedReadInstanceSizeInBytes is less than or equal to 0.
|
|
413
|
+
*/
|
|
414
|
+
constructor(_db, bufferedReadInstanceSizeInBytes = SqliteBackedInstanceCache.defaultBufferSize) {
|
|
415
|
+
this._db = _db;
|
|
416
|
+
this.bufferedReadInstanceSizeInBytes = bufferedReadInstanceSizeInBytes;
|
|
417
|
+
if (bufferedReadInstanceSizeInBytes <= 0)
|
|
418
|
+
throw new Error("bufferedReadInstanceCount must be greater than 0");
|
|
419
|
+
this.createTempTable();
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Creates a temporary table in the database for caching instances.
|
|
423
|
+
* @throws Error if unable to create the temporary table.
|
|
424
|
+
*/
|
|
425
|
+
createTempTable() {
|
|
426
|
+
this._db.withSqliteStatement(`CREATE TABLE ${this._cacheTable} ([key] text primary key, [value] text)`, (stmt) => {
|
|
427
|
+
if (DbResult.BE_SQLITE_DONE !== stmt.step())
|
|
428
|
+
throw new Error("unable to create temp table");
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Drops the temporary table from the database.
|
|
433
|
+
* @throws Error if unable to drop the temporary table.
|
|
434
|
+
*/
|
|
435
|
+
dropTempTable() {
|
|
436
|
+
this._db.saveChanges();
|
|
437
|
+
if (this._db instanceof ECDb)
|
|
438
|
+
this._db.clearStatementCache();
|
|
439
|
+
else {
|
|
440
|
+
this._db.clearCaches();
|
|
441
|
+
this._db[_nativeDb].clearECDbCache();
|
|
442
|
+
}
|
|
443
|
+
this._db.withSqliteStatement(`DROP TABLE IF EXISTS ${this._cacheTable}`, (stmt) => {
|
|
444
|
+
if (DbResult.BE_SQLITE_DONE !== stmt.step())
|
|
445
|
+
throw new Error("unable to drop temp table");
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* Retrieves the changed EC instance from the cache based on the specified key.
|
|
450
|
+
* @param key The key of the instance.
|
|
451
|
+
* @returns The changed EC instance if found, otherwise undefined.
|
|
452
|
+
*/
|
|
453
|
+
get(key) {
|
|
454
|
+
return this._db.withPreparedSqliteStatement(`SELECT [value] FROM ${this._cacheTable} WHERE [key]=?`, (stmt) => {
|
|
455
|
+
stmt.bindString(1, key);
|
|
456
|
+
if (stmt.step() === DbResult.BE_SQLITE_ROW) {
|
|
457
|
+
const out = JSON.parse(stmt.getValueString(0), Base64EncodedString.reviver);
|
|
458
|
+
return out;
|
|
459
|
+
}
|
|
460
|
+
return undefined;
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Sets the changed EC instance in the cache with the specified key.
|
|
465
|
+
* @param key The key of the instance.
|
|
466
|
+
* @param value The changed EC instance to be set.
|
|
467
|
+
*/
|
|
468
|
+
set(key, value) {
|
|
469
|
+
const shallowCopy = Object.assign({}, value);
|
|
470
|
+
this._db.withPreparedSqliteStatement(`INSERT INTO ${this._cacheTable} ([key], [value]) VALUES (?, ?) ON CONFLICT ([key]) DO UPDATE SET [value] = [excluded].[value]`, (stmt) => {
|
|
471
|
+
stmt.bindString(1, key);
|
|
472
|
+
stmt.bindString(2, JSON.stringify(shallowCopy, Base64EncodedString.replacer));
|
|
473
|
+
stmt.step();
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Returns an iterator for all the changed EC instances in the cache.
|
|
478
|
+
* @returns An iterator for all the changed EC instances.
|
|
479
|
+
*/
|
|
480
|
+
*all() {
|
|
481
|
+
const sql = `
|
|
482
|
+
SELECT JSON_GROUP_ARRAY (JSON([value]))
|
|
483
|
+
FROM (SELECT
|
|
484
|
+
[value],
|
|
485
|
+
SUM (LENGTH ([value])) OVER (ORDER BY [key] ROWS UNBOUNDED PRECEDING) / ${this.bufferedReadInstanceSizeInBytes} AS [bucket]
|
|
486
|
+
FROM ${this._cacheTable})
|
|
487
|
+
GROUP BY [bucket]`;
|
|
488
|
+
const stmt = this._db.prepareSqliteStatement(sql);
|
|
489
|
+
while (stmt.step() === DbResult.BE_SQLITE_ROW) {
|
|
490
|
+
const instanceBucket = JSON.parse(stmt.getValueString(0), Base64EncodedString.reviver);
|
|
491
|
+
for (const value of instanceBucket) {
|
|
492
|
+
yield value;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
stmt[Symbol.dispose]();
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Returns the number of instances in the cache.
|
|
499
|
+
* @returns The number of instances in the cache.
|
|
500
|
+
*/
|
|
501
|
+
count() {
|
|
502
|
+
return this._db.withPreparedSqliteStatement(`SELECT COUNT(*) FROM ${this._cacheTable}`, (stmt) => {
|
|
503
|
+
if (stmt.step() === DbResult.BE_SQLITE_ROW)
|
|
504
|
+
return stmt.getValue(0).getInteger();
|
|
505
|
+
return 0;
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Disposes the cache by dropping the temporary table.
|
|
510
|
+
*/
|
|
511
|
+
[Symbol.dispose]() {
|
|
512
|
+
if (this._db.isOpen) {
|
|
513
|
+
this.dropTempTable();
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
}
|
|
321
517
|
/**
|
|
322
518
|
* Combine partial changed instance into single instance.
|
|
323
519
|
* Partial changes is per table and a single instance can
|
|
@@ -325,15 +521,26 @@ var DateTime;
|
|
|
325
521
|
* @beta
|
|
326
522
|
*/
|
|
327
523
|
export class PartialECChangeUnifier {
|
|
328
|
-
|
|
524
|
+
_db;
|
|
525
|
+
_cache;
|
|
329
526
|
_readonly = false;
|
|
527
|
+
constructor(_db, _cache = new InMemoryInstanceCache()) {
|
|
528
|
+
this._db = _db;
|
|
529
|
+
this._cache = _cache;
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Dispose the instance.
|
|
533
|
+
*/
|
|
534
|
+
[Symbol.dispose]() {
|
|
535
|
+
this._cache[Symbol.dispose]();
|
|
536
|
+
}
|
|
330
537
|
/**
|
|
331
538
|
* Get root class id for a given class
|
|
332
539
|
* @param classId given class id
|
|
333
540
|
* @param db use to find root class
|
|
334
541
|
* @returns return root class id
|
|
335
542
|
*/
|
|
336
|
-
|
|
543
|
+
getRootClassId(classId) {
|
|
337
544
|
const sql = `
|
|
338
545
|
WITH
|
|
339
546
|
[base_class]([classId], [baseClassId], [Level]) AS(
|
|
@@ -356,7 +563,7 @@ export class PartialECChangeUnifier {
|
|
|
356
563
|
WHERE [cc].[Name] = 'IsMixIn'
|
|
357
564
|
AND [ss].[Name] = 'CoreCustomAttributes'))
|
|
358
565
|
ORDER BY [Level] DESC`;
|
|
359
|
-
return
|
|
566
|
+
return this._db.withSqliteStatement(sql, (stmt) => {
|
|
360
567
|
stmt.bindId(1, classId);
|
|
361
568
|
if (stmt.step() === DbResult.BE_SQLITE_ROW && !stmt.isValueNull(0)) {
|
|
362
569
|
return stmt.getValueString(0);
|
|
@@ -364,15 +571,30 @@ export class PartialECChangeUnifier {
|
|
|
364
571
|
return classId;
|
|
365
572
|
});
|
|
366
573
|
}
|
|
574
|
+
/**
|
|
575
|
+
* Checks if the given `rhsClassId` is an instance of the `lhsClassId`.
|
|
576
|
+
* @param rhsClassId The ID of the right-hand side class.
|
|
577
|
+
* @param lhsClassId The ID of the left-hand side class.
|
|
578
|
+
* @returns `true` if `rhsClassId` is an instance of `lhsClassId`, `false` otherwise.
|
|
579
|
+
*/
|
|
580
|
+
instanceOf(rhsClassId, lhsClassId) {
|
|
581
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
582
|
+
return this._db.withPreparedStatement("SELECT ec_instanceof(?,?)", (stmt) => {
|
|
583
|
+
stmt.bindId(1, rhsClassId);
|
|
584
|
+
stmt.bindId(2, lhsClassId);
|
|
585
|
+
stmt.step();
|
|
586
|
+
return stmt.getValue(0).getInteger() === 1;
|
|
587
|
+
});
|
|
588
|
+
}
|
|
367
589
|
/**
|
|
368
590
|
* Combine partial instance with instance with same key if already exists.
|
|
369
591
|
* @param rhs partial instance
|
|
370
592
|
*/
|
|
371
|
-
combine(rhs
|
|
593
|
+
combine(rhs) {
|
|
372
594
|
if (!rhs.$meta) {
|
|
373
595
|
throw new Error("PartialECChange being combine must have '$meta' property");
|
|
374
596
|
}
|
|
375
|
-
const key =
|
|
597
|
+
const key = this.buildKey(rhs);
|
|
376
598
|
const lhs = this._cache.get(key);
|
|
377
599
|
if (lhs) {
|
|
378
600
|
const { $meta: _, ...restOfRhs } = rhs;
|
|
@@ -381,37 +603,39 @@ export class PartialECChangeUnifier {
|
|
|
381
603
|
lhs.$meta.tables = [...rhs.$meta?.tables, ...lhs.$meta?.tables];
|
|
382
604
|
lhs.$meta.changeIndexes = [...rhs.$meta?.changeIndexes, ...lhs.$meta?.changeIndexes];
|
|
383
605
|
// we preserve child class name & id when merging instance.
|
|
384
|
-
if (rhs.$meta.fallbackClassId && lhs.$meta.fallbackClassId &&
|
|
606
|
+
if (rhs.$meta.fallbackClassId && lhs.$meta.fallbackClassId && rhs.$meta.fallbackClassId !== lhs.$meta.fallbackClassId) {
|
|
385
607
|
const lhsClassId = lhs.$meta.fallbackClassId;
|
|
386
608
|
const rhsClassId = rhs.$meta.fallbackClassId;
|
|
387
|
-
|
|
388
|
-
const isRhsIsSubClassOfLhs = db.withPreparedStatement("SELECT ec_instanceof(?,?)", (stmt) => {
|
|
389
|
-
stmt.bindId(1, rhsClassId);
|
|
390
|
-
stmt.bindId(2, lhsClassId);
|
|
391
|
-
stmt.step();
|
|
392
|
-
return stmt.getValue(0).getInteger() === 1;
|
|
393
|
-
});
|
|
609
|
+
const isRhsIsSubClassOfLhs = this.instanceOf(rhsClassId, lhsClassId);
|
|
394
610
|
if (isRhsIsSubClassOfLhs) {
|
|
395
611
|
lhs.$meta.fallbackClassId = rhs.$meta.fallbackClassId;
|
|
396
612
|
lhs.$meta.classFullName = rhs.$meta.classFullName;
|
|
397
613
|
}
|
|
398
614
|
}
|
|
399
615
|
}
|
|
616
|
+
this._cache.set(key, lhs);
|
|
400
617
|
}
|
|
401
618
|
else {
|
|
402
619
|
this._cache.set(key, rhs);
|
|
403
620
|
}
|
|
404
621
|
}
|
|
622
|
+
/**
|
|
623
|
+
* Returns the number of instances in the cache.
|
|
624
|
+
* @returns The number of instances in the cache.
|
|
625
|
+
*/
|
|
626
|
+
getInstanceCount() {
|
|
627
|
+
return this._cache.count();
|
|
628
|
+
}
|
|
405
629
|
/**
|
|
406
630
|
* Build key from EC change.
|
|
407
631
|
* @param change EC change
|
|
408
632
|
* @returns key created from EC change.
|
|
409
633
|
*/
|
|
410
|
-
|
|
634
|
+
buildKey(change) {
|
|
411
635
|
let classId = change.ECClassId;
|
|
412
636
|
if (typeof classId === "undefined") {
|
|
413
|
-
if (
|
|
414
|
-
classId = this.getRootClassId(change.$meta.fallbackClassId
|
|
637
|
+
if (change.$meta?.fallbackClassId) {
|
|
638
|
+
classId = this.getRootClassId(change.$meta.fallbackClassId);
|
|
415
639
|
}
|
|
416
640
|
if (typeof classId === "undefined") {
|
|
417
641
|
throw new Error(`unable to resolve ECClassId to root class id.`);
|
|
@@ -434,32 +658,23 @@ export class PartialECChangeUnifier {
|
|
|
434
658
|
throw new Error("this instance is marked as readonly.");
|
|
435
659
|
}
|
|
436
660
|
if (adaptor.op === "Updated" && adaptor.inserted && adaptor.deleted) {
|
|
437
|
-
this.combine(adaptor.inserted
|
|
438
|
-
this.combine(adaptor.deleted
|
|
661
|
+
this.combine(adaptor.inserted);
|
|
662
|
+
this.combine(adaptor.deleted);
|
|
439
663
|
}
|
|
440
664
|
else if (adaptor.op === "Inserted" && adaptor.inserted) {
|
|
441
|
-
this.combine(adaptor.inserted
|
|
665
|
+
this.combine(adaptor.inserted);
|
|
442
666
|
}
|
|
443
667
|
else if (adaptor.op === "Deleted" && adaptor.deleted) {
|
|
444
|
-
this.combine(adaptor.deleted
|
|
668
|
+
this.combine(adaptor.deleted);
|
|
445
669
|
}
|
|
446
670
|
}
|
|
447
|
-
/**
|
|
448
|
-
* Delete $meta from all the instances.
|
|
449
|
-
*/
|
|
450
|
-
stripMetaData() {
|
|
451
|
-
for (const inst of this._cache.values()) {
|
|
452
|
-
if ("$meta" in inst) {
|
|
453
|
-
delete inst.$meta;
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
this._readonly = true;
|
|
457
|
-
}
|
|
458
671
|
/**
|
|
459
672
|
* Returns complete EC change instances.
|
|
460
673
|
* @beta
|
|
461
674
|
*/
|
|
462
|
-
get instances() {
|
|
675
|
+
get instances() {
|
|
676
|
+
return this._cache.all();
|
|
677
|
+
}
|
|
463
678
|
}
|
|
464
679
|
/**
|
|
465
680
|
* Transform sqlite change to ec change. EC change is partial change as
|