@itwin/core-backend 5.1.0-dev.34 → 5.1.0-dev.36

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.
@@ -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,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,QAAQ,CAAC;AACvB,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,C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;GAEG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;GAGG"}
@@ -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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;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.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AG,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;AACzE,IAAK,UAAkB,CAAC,uBAAuB,CAAC,EAAE,CAAC;IACjD,4DAA4D;IAC5D,MAAM,cAAc,GAAI,UAAkB,CAAC,uBAAuB,CAAC,CAAC,KAAK,CAAC;IAE1E,MAAM,KAAK,GAAG,IAAI,KAAK,CACrB,sEAAsE;QACpE,yDAAyD;QACzD,8CAA8C;QAC9C,wDAAwD,CAC3D,CAAC;IAEF,+BAA+B;IAC/B,OAAO,CAAC,KAAK,CAAC,uCAAuC,EAAE,KAAK,CAAC,CAAC;IAC9D,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,cAAc,CAAC,CAAC;IAC3D,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IAC1D,8BAA8B;IAE9B,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,83 @@ 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
+ export declare namespace ECChangeUnifierCache {
63
+ function createInMemory(): ECChangeUnifierCache;
64
+ function createSqliteBacked(db: AnyDb, bufferedReadInstanceSizeInBytes?: number): ECChangeUnifierCache;
65
+ }
34
66
  /**
35
67
  * Combine partial changed instance into single instance.
36
68
  * Partial changes is per table and a single instance can
37
69
  * span multiple tables.
38
70
  * @beta
39
71
  */
40
- export declare class PartialECChangeUnifier {
72
+ export declare class PartialECChangeUnifier implements Disposable {
73
+ private _db;
41
74
  private _cache;
42
75
  private _readonly;
76
+ constructor(_db: AnyDb, _cache?: ECChangeUnifierCache);
77
+ /**
78
+ * Dispose the instance.
79
+ */
80
+ [Symbol.dispose](): void;
43
81
  /**
44
82
  * Get root class id for a given class
45
83
  * @param classId given class id
46
84
  * @param db use to find root class
47
85
  * @returns return root class id
48
86
  */
49
- private static getRootClassId;
87
+ private getRootClassId;
88
+ /**
89
+ * Checks if the given `rhsClassId` is an instance of the `lhsClassId`.
90
+ * @param rhsClassId The ID of the right-hand side class.
91
+ * @param lhsClassId The ID of the left-hand side class.
92
+ * @returns `true` if `rhsClassId` is an instance of `lhsClassId`, `false` otherwise.
93
+ */
94
+ private instanceOf;
50
95
  /**
51
96
  * Combine partial instance with instance with same key if already exists.
52
97
  * @param rhs partial instance
53
98
  */
54
99
  private combine;
100
+ /**
101
+ * Returns the number of instances in the cache.
102
+ * @returns The number of instances in the cache.
103
+ */
104
+ getInstanceCount(): number;
55
105
  /**
56
106
  * Build key from EC change.
57
107
  * @param change EC change
58
108
  * @returns key created from EC change.
59
109
  */
60
- private static buildKey;
110
+ private buildKey;
61
111
  /**
62
112
  * Append partial changes which will be combine using there instance key.
63
113
  * @note $meta property must be present on partial change as information
@@ -66,10 +116,6 @@ export declare class PartialECChangeUnifier {
66
116
  * @beta
67
117
  */
68
118
  appendFrom(adaptor: ChangesetECAdaptor): void;
69
- /**
70
- * Delete $meta from all the instances.
71
- */
72
- stripMetaData(): void;
73
119
  /**
74
120
  * Returns complete EC change instances.
75
121
  * @beta
@@ -1 +1 @@
1
- {"version":3,"file":"ChangesetECAdaptor.d.ts","sourceRoot":"","sources":["../../src/ChangesetECAdaptor.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,EAAwB,UAAU,EAAE,MA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AAW,CAAC,aAAa,EAAE,MAAM,GAAG,kBAAkB;IAQ7D,OAAO,CAAC,gBAAgB;IAWxB;;;;;OAKG;gBACgC,MAAM,EAAE,qBAAqB,EAAkB,eAAe,UAAQ;IAOzG;;OAEG;IACI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;IAI/B;;OAEG;IACI,KAAK,IAAI,IAAI;IAIpB;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAYlC;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ;IAoBvB;;;;OAIG;IACI,SAAS,CAAC,SAAS,EAAE,MAAM;IAIlC;;;;;OAKG;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,186 @@ var DateTime;
318
321
  }
319
322
  DateTime.fromJulianDay = fromJulianDay;
320
323
  })(DateTime || (DateTime = {}));
324
+ export var ECChangeUnifierCache;
325
+ (function (ECChangeUnifierCache) {
326
+ function createInMemory() {
327
+ return new InMemoryInstanceCache();
328
+ }
329
+ ECChangeUnifierCache.createInMemory = createInMemory;
330
+ function createSqliteBacked(db, bufferedReadInstanceSizeInBytes = 1024 * 1024 * 10) {
331
+ return new SqliteBackedInstanceCache(db, bufferedReadInstanceSizeInBytes);
332
+ }
333
+ ECChangeUnifierCache.createSqliteBacked = createSqliteBacked;
334
+ })(ECChangeUnifierCache || (ECChangeUnifierCache = {}));
335
+ /**
336
+ * In-memory cache for storing changed EC instances.
337
+ */
338
+ class InMemoryInstanceCache {
339
+ _cache = new Map();
340
+ /**
341
+ * Retrieves the changed EC instance associated with the specified key.
342
+ * @param key - The key used to retrieve the instance.
343
+ * @returns The changed EC instance, or undefined if not found.
344
+ */
345
+ get(key) {
346
+ return this._cache.get(key);
347
+ }
348
+ /**
349
+ * Sets the changed EC instance associated with the specified key.
350
+ * @param key - The key used to store the instance.
351
+ * @param value - The changed EC instance to be stored.
352
+ */
353
+ set(key, value) {
354
+ const meta = value.$meta;
355
+ // Remove undefined keys
356
+ if (meta) {
357
+ Object.keys(meta).forEach((k) => meta[k] === undefined && delete meta[k]);
358
+ }
359
+ this._cache.set(key, value);
360
+ }
361
+ /**
362
+ * Returns an iterator over all the changed EC instances in the cache.
363
+ * @returns An iterator over all the changed EC instances.
364
+ */
365
+ *all() {
366
+ for (const key of Array.from(this._cache.keys()).sort()) {
367
+ const instance = this._cache.get(key);
368
+ if (instance) {
369
+ yield instance;
370
+ }
371
+ }
372
+ }
373
+ /**
374
+ * Returns the number of changed EC instances in the cache.
375
+ * @returns The number of changed EC instances.
376
+ */
377
+ count() {
378
+ return this._cache.size;
379
+ }
380
+ /**
381
+ * Disposes the cache.
382
+ */
383
+ [Symbol.dispose]() {
384
+ // Implementation details
385
+ }
386
+ }
387
+ /**
388
+ * Represents a cache for unifying EC changes in a SQLite-backed instance cache.
389
+ */
390
+ class SqliteBackedInstanceCache {
391
+ _db;
392
+ bufferedReadInstanceSizeInBytes;
393
+ _cacheTable = `[temp].[${Guid.createValue()}]`;
394
+ static defaultBufferSize = 1024 * 1024 * 10; // 10MB
395
+ /**
396
+ * Creates an instance of SqliteBackedInstanceCache.
397
+ * @param _db The underlying database connection.
398
+ * @param bufferedReadInstanceSizeInBytes The size of read instance buffer defaults to 10Mb.
399
+ * @throws Error if bufferedReadInstanceSizeInBytes is less than or equal to 0.
400
+ */
401
+ constructor(_db, bufferedReadInstanceSizeInBytes = SqliteBackedInstanceCache.defaultBufferSize) {
402
+ this._db = _db;
403
+ this.bufferedReadInstanceSizeInBytes = bufferedReadInstanceSizeInBytes;
404
+ if (bufferedReadInstanceSizeInBytes <= 0)
405
+ throw new Error("bufferedReadInstanceCount must be greater than 0");
406
+ this.createTempTable();
407
+ }
408
+ /**
409
+ * Creates a temporary table in the database for caching instances.
410
+ * @throws Error if unable to create the temporary table.
411
+ */
412
+ createTempTable() {
413
+ this._db.withSqliteStatement(`CREATE TABLE ${this._cacheTable} ([key] text primary key, [value] text)`, (stmt) => {
414
+ if (DbResult.BE_SQLITE_DONE !== stmt.step())
415
+ throw new Error("unable to create temp table");
416
+ });
417
+ }
418
+ /**
419
+ * Drops the temporary table from the database.
420
+ * @throws Error if unable to drop the temporary table.
421
+ */
422
+ dropTempTable() {
423
+ this._db.saveChanges();
424
+ if (this._db instanceof ECDb)
425
+ this._db.clearStatementCache();
426
+ else {
427
+ this._db.clearCaches();
428
+ this._db[_nativeDb].clearECDbCache();
429
+ }
430
+ this._db.withSqliteStatement(`DROP TABLE IF EXISTS ${this._cacheTable}`, (stmt) => {
431
+ if (DbResult.BE_SQLITE_DONE !== stmt.step())
432
+ throw new Error("unable to drop temp table");
433
+ });
434
+ }
435
+ /**
436
+ * Retrieves the changed EC instance from the cache based on the specified key.
437
+ * @param key The key of the instance.
438
+ * @returns The changed EC instance if found, otherwise undefined.
439
+ */
440
+ get(key) {
441
+ return this._db.withPreparedSqliteStatement(`SELECT [value] FROM ${this._cacheTable} WHERE [key]=?`, (stmt) => {
442
+ stmt.bindString(1, key);
443
+ if (stmt.step() === DbResult.BE_SQLITE_ROW) {
444
+ const out = JSON.parse(stmt.getValueString(0), Base64EncodedString.reviver);
445
+ return out;
446
+ }
447
+ return undefined;
448
+ });
449
+ }
450
+ /**
451
+ * Sets the changed EC instance in the cache with the specified key.
452
+ * @param key The key of the instance.
453
+ * @param value The changed EC instance to be set.
454
+ */
455
+ set(key, value) {
456
+ const shallowCopy = Object.assign({}, value);
457
+ this._db.withPreparedSqliteStatement(`INSERT INTO ${this._cacheTable} ([key], [value]) VALUES (?, ?) ON CONFLICT ([key]) DO UPDATE SET [value] = [excluded].[value]`, (stmt) => {
458
+ stmt.bindString(1, key);
459
+ stmt.bindString(2, JSON.stringify(shallowCopy, Base64EncodedString.replacer));
460
+ stmt.step();
461
+ });
462
+ }
463
+ /**
464
+ * Returns an iterator for all the changed EC instances in the cache.
465
+ * @returns An iterator for all the changed EC instances.
466
+ */
467
+ *all() {
468
+ const sql = `
469
+ SELECT JSON_GROUP_ARRAY (JSON([value]))
470
+ FROM (SELECT
471
+ [value],
472
+ SUM (LENGTH ([value])) OVER (ORDER BY [key] ROWS UNBOUNDED PRECEDING) / ${this.bufferedReadInstanceSizeInBytes} AS [bucket]
473
+ FROM ${this._cacheTable})
474
+ GROUP BY [bucket]`;
475
+ const stmt = this._db.prepareSqliteStatement(sql);
476
+ while (stmt.step() === DbResult.BE_SQLITE_ROW) {
477
+ const instanceBucket = JSON.parse(stmt.getValueString(0), Base64EncodedString.reviver);
478
+ for (const value of instanceBucket) {
479
+ yield value;
480
+ }
481
+ }
482
+ stmt[Symbol.dispose]();
483
+ }
484
+ /**
485
+ * Returns the number of instances in the cache.
486
+ * @returns The number of instances in the cache.
487
+ */
488
+ count() {
489
+ return this._db.withPreparedSqliteStatement(`SELECT COUNT(*) FROM ${this._cacheTable}`, (stmt) => {
490
+ if (stmt.step() === DbResult.BE_SQLITE_ROW)
491
+ return stmt.getValue(0).getInteger();
492
+ return 0;
493
+ });
494
+ }
495
+ /**
496
+ * Disposes the cache by dropping the temporary table.
497
+ */
498
+ [Symbol.dispose]() {
499
+ if (this._db.isOpen) {
500
+ this.dropTempTable();
501
+ }
502
+ }
503
+ }
321
504
  /**
322
505
  * Combine partial changed instance into single instance.
323
506
  * Partial changes is per table and a single instance can
@@ -325,15 +508,26 @@ var DateTime;
325
508
  * @beta
326
509
  */
327
510
  export class PartialECChangeUnifier {
328
- _cache = new Map();
511
+ _db;
512
+ _cache;
329
513
  _readonly = false;
514
+ constructor(_db, _cache = new InMemoryInstanceCache()) {
515
+ this._db = _db;
516
+ this._cache = _cache;
517
+ }
518
+ /**
519
+ * Dispose the instance.
520
+ */
521
+ [Symbol.dispose]() {
522
+ this._cache[Symbol.dispose]();
523
+ }
330
524
  /**
331
525
  * Get root class id for a given class
332
526
  * @param classId given class id
333
527
  * @param db use to find root class
334
528
  * @returns return root class id
335
529
  */
336
- static getRootClassId(classId, db) {
530
+ getRootClassId(classId) {
337
531
  const sql = `
338
532
  WITH
339
533
  [base_class]([classId], [baseClassId], [Level]) AS(
@@ -356,7 +550,7 @@ export class PartialECChangeUnifier {
356
550
  WHERE [cc].[Name] = 'IsMixIn'
357
551
  AND [ss].[Name] = 'CoreCustomAttributes'))
358
552
  ORDER BY [Level] DESC`;
359
- return db.withSqliteStatement(sql, (stmt) => {
553
+ return this._db.withSqliteStatement(sql, (stmt) => {
360
554
  stmt.bindId(1, classId);
361
555
  if (stmt.step() === DbResult.BE_SQLITE_ROW && !stmt.isValueNull(0)) {
362
556
  return stmt.getValueString(0);
@@ -364,15 +558,30 @@ export class PartialECChangeUnifier {
364
558
  return classId;
365
559
  });
366
560
  }
561
+ /**
562
+ * Checks if the given `rhsClassId` is an instance of the `lhsClassId`.
563
+ * @param rhsClassId The ID of the right-hand side class.
564
+ * @param lhsClassId The ID of the left-hand side class.
565
+ * @returns `true` if `rhsClassId` is an instance of `lhsClassId`, `false` otherwise.
566
+ */
567
+ instanceOf(rhsClassId, lhsClassId) {
568
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
569
+ return this._db.withPreparedStatement("SELECT ec_instanceof(?,?)", (stmt) => {
570
+ stmt.bindId(1, rhsClassId);
571
+ stmt.bindId(2, lhsClassId);
572
+ stmt.step();
573
+ return stmt.getValue(0).getInteger() === 1;
574
+ });
575
+ }
367
576
  /**
368
577
  * Combine partial instance with instance with same key if already exists.
369
578
  * @param rhs partial instance
370
579
  */
371
- combine(rhs, db) {
580
+ combine(rhs) {
372
581
  if (!rhs.$meta) {
373
582
  throw new Error("PartialECChange being combine must have '$meta' property");
374
583
  }
375
- const key = PartialECChangeUnifier.buildKey(rhs, db);
584
+ const key = this.buildKey(rhs);
376
585
  const lhs = this._cache.get(key);
377
586
  if (lhs) {
378
587
  const { $meta: _, ...restOfRhs } = rhs;
@@ -381,37 +590,39 @@ export class PartialECChangeUnifier {
381
590
  lhs.$meta.tables = [...rhs.$meta?.tables, ...lhs.$meta?.tables];
382
591
  lhs.$meta.changeIndexes = [...rhs.$meta?.changeIndexes, ...lhs.$meta?.changeIndexes];
383
592
  // we preserve child class name & id when merging instance.
384
- if (rhs.$meta.fallbackClassId && lhs.$meta.fallbackClassId && db && rhs.$meta.fallbackClassId !== lhs.$meta.fallbackClassId) {
593
+ if (rhs.$meta.fallbackClassId && lhs.$meta.fallbackClassId && rhs.$meta.fallbackClassId !== lhs.$meta.fallbackClassId) {
385
594
  const lhsClassId = lhs.$meta.fallbackClassId;
386
595
  const rhsClassId = rhs.$meta.fallbackClassId;
387
- // eslint-disable-next-line @typescript-eslint/no-deprecated
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
- });
596
+ const isRhsIsSubClassOfLhs = this.instanceOf(rhsClassId, lhsClassId);
394
597
  if (isRhsIsSubClassOfLhs) {
395
598
  lhs.$meta.fallbackClassId = rhs.$meta.fallbackClassId;
396
599
  lhs.$meta.classFullName = rhs.$meta.classFullName;
397
600
  }
398
601
  }
399
602
  }
603
+ this._cache.set(key, lhs);
400
604
  }
401
605
  else {
402
606
  this._cache.set(key, rhs);
403
607
  }
404
608
  }
609
+ /**
610
+ * Returns the number of instances in the cache.
611
+ * @returns The number of instances in the cache.
612
+ */
613
+ getInstanceCount() {
614
+ return this._cache.count();
615
+ }
405
616
  /**
406
617
  * Build key from EC change.
407
618
  * @param change EC change
408
619
  * @returns key created from EC change.
409
620
  */
410
- static buildKey(change, db) {
621
+ buildKey(change) {
411
622
  let classId = change.ECClassId;
412
623
  if (typeof classId === "undefined") {
413
- if (db && change.$meta?.fallbackClassId) {
414
- classId = this.getRootClassId(change.$meta.fallbackClassId, db);
624
+ if (change.$meta?.fallbackClassId) {
625
+ classId = this.getRootClassId(change.$meta.fallbackClassId);
415
626
  }
416
627
  if (typeof classId === "undefined") {
417
628
  throw new Error(`unable to resolve ECClassId to root class id.`);
@@ -434,32 +645,23 @@ export class PartialECChangeUnifier {
434
645
  throw new Error("this instance is marked as readonly.");
435
646
  }
436
647
  if (adaptor.op === "Updated" && adaptor.inserted && adaptor.deleted) {
437
- this.combine(adaptor.inserted, adaptor.reader.db);
438
- this.combine(adaptor.deleted, adaptor.reader.db);
648
+ this.combine(adaptor.inserted);
649
+ this.combine(adaptor.deleted);
439
650
  }
440
651
  else if (adaptor.op === "Inserted" && adaptor.inserted) {
441
- this.combine(adaptor.inserted, adaptor.reader.db);
652
+ this.combine(adaptor.inserted);
442
653
  }
443
654
  else if (adaptor.op === "Deleted" && adaptor.deleted) {
444
- this.combine(adaptor.deleted, adaptor.reader.db);
445
- }
446
- }
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
- }
655
+ this.combine(adaptor.deleted);
455
656
  }
456
- this._readonly = true;
457
657
  }
458
658
  /**
459
659
  * Returns complete EC change instances.
460
660
  * @beta
461
661
  */
462
- get instances() { return this._cache.values(); }
662
+ get instances() {
663
+ return this._cache.all();
664
+ }
463
665
  }
464
666
  /**
465
667
  * Transform sqlite change to ec change. EC change is partial change as