@itwin/imodel-transformer 2.0.0-dev.34 → 2.0.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.
- package/README.md +10 -0
- package/lib/cjs/ElementAspectCleanup.d.ts +16 -0
- package/lib/cjs/ElementAspectCleanup.d.ts.map +1 -0
- package/lib/cjs/ElementAspectCleanup.js +83 -0
- package/lib/cjs/ElementAspectCleanup.js.map +1 -0
- package/lib/cjs/ElementAspectExportCoordinator.d.ts +44 -0
- package/lib/cjs/ElementAspectExportCoordinator.d.ts.map +1 -0
- package/lib/cjs/ElementAspectExportCoordinator.js +148 -0
- package/lib/cjs/ElementAspectExportCoordinator.js.map +1 -0
- package/lib/cjs/ElementAspectExportProcessor.d.ts +55 -0
- package/lib/cjs/ElementAspectExportProcessor.d.ts.map +1 -0
- package/lib/cjs/ElementAspectExportProcessor.js +186 -0
- package/lib/cjs/ElementAspectExportProcessor.js.map +1 -0
- package/lib/cjs/IModelCloneContext.d.ts +3 -2
- package/lib/cjs/IModelCloneContext.d.ts.map +1 -1
- package/lib/cjs/IModelCloneContext.js +3 -2
- package/lib/cjs/IModelCloneContext.js.map +1 -1
- package/lib/cjs/IModelExporter.d.ts +48 -10
- package/lib/cjs/IModelExporter.d.ts.map +1 -1
- package/lib/cjs/IModelExporter.js +368 -41
- package/lib/cjs/IModelExporter.js.map +1 -1
- package/lib/cjs/IModelImporter.d.ts +6 -0
- package/lib/cjs/IModelImporter.d.ts.map +1 -1
- package/lib/cjs/IModelImporter.js +9 -0
- package/lib/cjs/IModelImporter.js.map +1 -1
- package/lib/cjs/IModelTransformContext.d.ts +54 -0
- package/lib/cjs/IModelTransformContext.d.ts.map +1 -0
- package/lib/cjs/IModelTransformContext.js +3 -0
- package/lib/cjs/IModelTransformContext.js.map +1 -0
- package/lib/cjs/IModelTransformer.d.ts +7 -3
- package/lib/cjs/IModelTransformer.d.ts.map +1 -1
- package/lib/cjs/IModelTransformer.js +57 -30
- package/lib/cjs/IModelTransformer.js.map +1 -1
- package/lib/cjs/IModelTransformerError.d.ts +2 -0
- package/lib/cjs/IModelTransformerError.d.ts.map +1 -1
- package/lib/cjs/IModelTransformerError.js +2 -0
- package/lib/cjs/IModelTransformerError.js.map +1 -1
- package/lib/cjs/ProvenanceManager.d.ts +8 -3
- package/lib/cjs/ProvenanceManager.d.ts.map +1 -1
- package/lib/cjs/ProvenanceManager.js +23 -23
- package/lib/cjs/ProvenanceManager.js.map +1 -1
- package/lib/cjs/SyncTypeResolver.d.ts +3 -3
- package/lib/cjs/SyncTypeResolver.d.ts.map +1 -1
- package/lib/cjs/SyncTypeResolver.js +6 -4
- package/lib/cjs/SyncTypeResolver.js.map +1 -1
- package/lib/cjs/TransformerLoggerCategory.d.ts +1 -1
- package/lib/cjs/TransformerLoggerCategory.js +1 -1
- package/lib/cjs/TransformerLoggerCategory.js.map +1 -1
- package/lib/cjs/imodel-transformer.d.ts +10 -1
- package/lib/cjs/imodel-transformer.d.ts.map +1 -1
- package/lib/cjs/imodel-transformer.js +10 -1
- package/lib/cjs/imodel-transformer.js.map +1 -1
- package/package.json +1 -1
- package/lib/cjs/DetachedExportElementAspectsStrategy.d.ts +0 -16
- package/lib/cjs/DetachedExportElementAspectsStrategy.d.ts.map +0 -1
- package/lib/cjs/DetachedExportElementAspectsStrategy.js +0 -108
- package/lib/cjs/DetachedExportElementAspectsStrategy.js.map +0 -1
- package/lib/cjs/ExportElementAspectsStrategy.d.ts +0 -35
- package/lib/cjs/ExportElementAspectsStrategy.d.ts.map +0 -1
- package/lib/cjs/ExportElementAspectsStrategy.js +0 -52
- package/lib/cjs/ExportElementAspectsStrategy.js.map +0 -1
- package/lib/cjs/ExportElementAspectsWithElementsStrategy.d.ts +0 -12
- package/lib/cjs/ExportElementAspectsWithElementsStrategy.d.ts.map +0 -1
- package/lib/cjs/ExportElementAspectsWithElementsStrategy.js +0 -48
- package/lib/cjs/ExportElementAspectsWithElementsStrategy.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SyncTypeResolver.js","sourceRoot":"","sources":["../../src/SyncTypeResolver.ts"],"names":[],"mappings":";;;AAAA;;;gGAGgG;AAChG,sDAA6D;AAC7D,sDAI6B;AAC7B,oDAA4C;
|
|
1
|
+
{"version":3,"file":"SyncTypeResolver.js","sourceRoot":"","sources":["../../src/SyncTypeResolver.ts"],"names":[],"mappings":";;;AAAA;;;gGAGgG;AAChG,sDAA6D;AAC7D,sDAI6B;AAC7B,oDAA4C;AAE5C,2DAAwD;AACxD,qEAGkC;AAKlC;;;;;GAKG;AACH,MAAa,gBAAgB;IACpB,MAAM,CAAC,8BAA8B,GAC1C,uOAAuO,CAAC;IAElO,SAAS,CAAY;IACZ,SAAS,CAAW;IACpB,SAAS,CAAW;IACpB,qBAAqB,CAAa;IAClC,0BAA0B,CAAU;IACpC,gBAAgB,CAAU;IAE3C,YACE,QAAkB,EAClB,QAAkB,EAClB,oBAAgC,EAChC,4BAAqC,KAAK,EAC1C,kBAA2B,KAAK;QAEhC,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,qBAAqB,GAAG,oBAAoB,CAAC;QAClD,IAAI,CAAC,0BAA0B,GAAG,yBAAyB,CAAC;QAC5D,IAAI,CAAC,gBAAgB,GAAG,eAAe,CAAC;IAC1C,CAAC;IAED;;;;;;;OAOG;IACI,MAAM,CAAC,KAAK,CAAC,iBAAiB,CACnC,QAAkB,EAClB,QAAkB,EAClB,oBAAgC;QAEhC,MAAM,WAAW,GAAG;YAClB,EAAE,EAAE,SAA+B;YACnC,OAAO,EAAE,SAA+B;YACxC,aAAa,EAAE,mCAAoB,CAAC,aAAa;YACjD,OAAO,EAAE;gBACP,EAAE,EAAE,oBAAoB;gBACxB,YAAY,EAAE,+CAAgC,CAAC,aAAa;aAC7D;YACD,KAAK,EAAE,EAAE,EAAE,EAAE,oBA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YACJ,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAEO,KAAK,CAAC,2BAA2B;QACvC,OAAO,CAAC,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,SAAS,CAAC;IAClD,CAAC;IAEO,KAAK,CAAC,2BAA2B;QACvC,OAAO,CAAC,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,SAAS,CAAC;IAClD,CAAC;;AAzGH,4CA0GC","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 *--------------------------------------------------------------------------------------------*/\nimport { Id64String, ITwinError } from \"@itwin/core-bentley\";\nimport {\n ElementOwnsExternalSourceAspects,\n ExternalSourceAspect,\n IModelDb,\n} from \"@itwin/core-backend\";\nimport { IModel } from \"@itwin/core-common\";\nimport type { TargetScopeProvenanceJsonProps } from \"./IModelTransformer\";\nimport { ProvenanceManager } from \"./ProvenanceManager\";\nimport {\n IModelTransformerError,\n IModelTransformerErrorScope,\n} from \"./IModelTransformerError\";\n\n/** @internal */\nexport type SyncType = \"not-sync\" | \"forward\" | \"reverse\";\n\n/**\n * Encapsulates sync direction determination logic.\n * Given a source and target iModel, resolves whether the transformation is\n * a forward sync, reverse sync, or not a sync at all.\n * @internal\n */\nexport class SyncTypeResolver {\n public static noEsaSyncDirectionErrorMessage =\n \"Couldn't find an external source aspect to determine sync direction. This often means that the master->branch relationship has not been established. Consider running the transformer with wasSourceIModelCopiedToTarget set to true.\";\n\n private _syncType?: SyncType;\n private readonly _sourceDb: IModelDb;\n private readonly _targetDb: IModelDb;\n private readonly _targetScopeElementId: Id64String;\n private readonly _isProvenanceInitTransform: boolean;\n private readonly _isSyncTransform: boolean;\n\n public constructor(\n sourceDb: IModelDb,\n targetDb: IModelDb,\n targetScopeElementId: Id64String,\n isProvenanceInitTransform: boolean = false,\n isSyncTransform: boolean = false\n ) {\n this._sourceDb = sourceDb;\n this._targetDb = targetDb;\n this._targetScopeElementId = targetScopeElementId;\n this._isProvenanceInitTransform = isProvenanceInitTransform;\n this._isSyncTransform = isSyncTransform;\n }\n\n /**\n * Determines the sync direction \"forward\" or \"reverse\" of a given sourceDb and targetDb by looking for the scoping ESA.\n * If the sourceDb's iModelId is found as the identifier of the expected scoping ESA in the targetDb, then it is a forward synchronization.\n * If the targetDb's iModelId is found as the identifier of the expected scoping ESA in the sourceDb, then it is a reverse synchronization.\n * @note This is a standalone utility that does not depend on instance state.\n * @throws if no scoping ESA can be found in either the sourceDb or targetDb which describes a master branch relationship between the two databases.\n * @returns \"forward\" or \"reverse\"\n */\n public static async determineSyncType(\n sourceDb: IModelDb,\n targetDb: IModelDb,\n targetScopeElementId: Id64String\n ): Promise<\"forward\" | \"reverse\"> {\n const aspectProps = {\n id: undefined as string | undefined,\n version: undefined as string | undefined,\n classFullName: ExternalSourceAspect.classFullName,\n element: {\n id: targetScopeElementId,\n relClassName: ElementOwnsExternalSourceAspects.classFullName,\n },\n scope: { id: IModel.rootSubjectId },\n identifier: sourceDb.iModelId,\n kind: ExternalSourceAspect.Kind.Scope,\n jsonProperties: undefined as TargetScopeProvenanceJsonProps | undefined,\n };\n // First check if the targetDb is the branch (branch is the provenanceDb)\n const esaPropsFromTargetDb =\n await ProvenanceManager.queryScopeExternalSourceAspect(\n targetDb,\n aspectProps\n );\n if (esaPropsFromTargetDb !== undefined) {\n return \"forward\";\n }\n\n // Now check if the sourceDb is the branch\n aspectProps.identifier = targetDb.iModelId;\n const esaPropsFromSourceDb =\n await ProvenanceManager.queryScopeExternalSourceAspect(\n sourceDb,\n aspectProps\n );\n\n if (esaPropsFromSourceDb !== undefined) {\n return \"reverse\";\n }\n ITwinError.throwError({\n iTwinErrorId: {\n scope: IModelTransformerErrorScope,\n key: IModelTransformerError.SynchronizationTypeNotDetermined,\n },\n message: SyncTypeResolver.noEsaSyncDirectionErrorMessage,\n });\n }\n\n /** Returns the sync type, lazily resolving it on first call. */\n public async getSyncType(): Promise<SyncType> {\n if (this._syncType === undefined) {\n if (this._isProvenanceInitTransform) {\n this._syncType = \"forward\";\n } else if (!this._isSyncTransform) {\n this._syncType = \"not-sync\";\n } else {\n this._syncType = await SyncTypeResolver.determineSyncType(\n this._sourceDb,\n this._targetDb,\n this._targetScopeElementId\n );\n }\n }\n return this._syncType;\n }\n\n private async getIsReverseSynchronization(): Promise<boolean> {\n return (await this.getSyncType()) === \"reverse\";\n }\n\n private async getIsForwardSynchronization(): Promise<boolean> {\n return (await this.getSyncType()) === \"forward\";\n }\n}\n"]}
|
|
@@ -19,7 +19,7 @@ export declare enum TransformerLoggerCategory {
|
|
|
19
19
|
* @beta
|
|
20
20
|
*/
|
|
21
21
|
IModelTransformer = "imodel-transformer.IModelTransformer",
|
|
22
|
-
/** The logger category used
|
|
22
|
+
/** The logger category used while cloning entities and remapping their references.
|
|
23
23
|
* @beta
|
|
24
24
|
*/
|
|
25
25
|
IModelCloneContext = "imodel-transformer.IModelCloneContext",
|
|
@@ -27,7 +27,7 @@ var TransformerLoggerCategory;
|
|
|
27
27
|
* @beta
|
|
28
28
|
*/
|
|
29
29
|
TransformerLoggerCategory["IModelTransformer"] = "imodel-transformer.IModelTransformer";
|
|
30
|
-
/** The logger category used
|
|
30
|
+
/** The logger category used while cloning entities and remapping their references.
|
|
31
31
|
* @beta
|
|
32
32
|
*/
|
|
33
33
|
TransformerLoggerCategory["IModelCloneContext"] = "imodel-transformer.IModelCloneContext";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransformerLoggerCategory.js","sourceRoot":"","sources":["../../src/TransformerLoggerCategory.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH;;;;GAIG;AACH,IAAY,yBAsBX;AAtBD,WAAY,yBAAyB;IACnC;;OAEG;IACH,iFAAoD,CAAA;IAEpD;;OAEG;IACH,iFAAoD,CAAA;IAEpD;;OAEG;IACH,uFAA0D,CAAA;IAE1D;;OAEG;IACH,yFAA4D,CAAA;IAE5D,+FAAkE,CAAA;AACpE,CAAC,EAtBW,yBAAyB,yCAAzB,yBAAyB,QAsBpC","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/** @packageDocumentation\n * @module Logging\n */\n\n/** Logger categories used by this package\n * @note All logger categories in this package start with the `imodel-transformer` prefix.\n * @see [Logger]($bentley)\n * @public\n */\nexport enum TransformerLoggerCategory {\n /** The logger category used by the [IModelExporter]($transformer) class.\n * @beta\n */\n IModelExporter = \"imodel-transformer.IModelExporter\",\n\n /** The logger category used by the [IModelImporter]($transformer) class.\n * @beta\n */\n IModelImporter = \"imodel-transformer.IModelImporter\",\n\n /** The logger category used by the [IModelTransformer]($transformer) class.\n * @beta\n */\n IModelTransformer = \"imodel-transformer.IModelTransformer\",\n\n /** The logger category used
|
|
1
|
+
{"version":3,"file":"TransformerLoggerCategory.js","sourceRoot":"","sources":["../../src/TransformerLoggerCategory.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH;;;;GAIG;AACH,IAAY,yBAsBX;AAtBD,WAAY,yBAAyB;IACnC;;OAEG;IACH,iFAAoD,CAAA;IAEpD;;OAEG;IACH,iFAAoD,CAAA;IAEpD;;OAEG;IACH,uFAA0D,CAAA;IAE1D;;OAEG;IACH,yFAA4D,CAAA;IAE5D,+FAAkE,CAAA;AACpE,CAAC,EAtBW,yBAAyB,yCAAzB,yBAAyB,QAsBpC","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/** @packageDocumentation\n * @module Logging\n */\n\n/** Logger categories used by this package\n * @note All logger categories in this package start with the `imodel-transformer` prefix.\n * @see [Logger]($bentley)\n * @public\n */\nexport enum TransformerLoggerCategory {\n /** The logger category used by the [IModelExporter]($transformer) class.\n * @beta\n */\n IModelExporter = \"imodel-transformer.IModelExporter\",\n\n /** The logger category used by the [IModelImporter]($transformer) class.\n * @beta\n */\n IModelImporter = \"imodel-transformer.IModelImporter\",\n\n /** The logger category used by the [IModelTransformer]($transformer) class.\n * @beta\n */\n IModelTransformer = \"imodel-transformer.IModelTransformer\",\n\n /** The logger category used while cloning entities and remapping their references.\n * @beta\n */\n IModelCloneContext = \"imodel-transformer.IModelCloneContext\",\n\n ECReferenceTypesCache = \"imodel-transformer.ECReferenceTypesCache\",\n}\n"]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export * from "./TransformerLoggerCategory";
|
|
2
|
-
export * from "./IModelTransformerError";
|
|
3
2
|
export * from "./IModelExporter";
|
|
4
3
|
export * from "./IModelImporter";
|
|
5
4
|
export * from "./IModelTransformer";
|
|
5
|
+
export * from "./IModelTransformContext";
|
|
6
|
+
export * from "./IModelTransformerError";
|
|
6
7
|
export * from "./BranchProvenanceInitializer";
|
|
7
8
|
/** @docs-package-description
|
|
8
9
|
* The @itwin/imodel-transformer package contains classes that [backend code]($docs/learning/backend/index.md) can use to
|
|
@@ -24,6 +25,14 @@ export * from "./BranchProvenanceInitializer";
|
|
|
24
25
|
* @docs-group-description Logging
|
|
25
26
|
* Logger categories used by this package.
|
|
26
27
|
*/
|
|
28
|
+
/**
|
|
29
|
+
* @docs-group-description ElementAspectExportCoordinator
|
|
30
|
+
* Internal coordination for scoped, owner-batched ElementAspect export.
|
|
31
|
+
*/
|
|
32
|
+
/**
|
|
33
|
+
* @docs-group-description ElementAspectExportProcessor
|
|
34
|
+
* Internal source queries, filtering, and export callbacks for ElementAspects owned by accepted elements.
|
|
35
|
+
*/
|
|
27
36
|
/**
|
|
28
37
|
* @docs-group-description IModelTransformerError
|
|
29
38
|
* Stable identifiers for errors originating from this package.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imodel-transformer.d.ts","sourceRoot":"","sources":["../../src/imodel-transformer.ts"],"names":[],"mappings":"AAIA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,
|
|
1
|
+
{"version":3,"file":"imodel-transformer.d.ts","sourceRoot":"","sources":["../../src/imodel-transformer.ts"],"names":[],"mappings":"AAIA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAyG9C;;;;;;GAMG;AACH;;;;GAIG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG"}
|
|
@@ -19,10 +19,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
19
19
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
20
20
|
*--------------------------------------------------------------------------------------------*/
|
|
21
21
|
__exportStar(require("./TransformerLoggerCategory"), exports);
|
|
22
|
-
__exportStar(require("./IModelTransformerError"), exports);
|
|
23
22
|
__exportStar(require("./IModelExporter"), exports);
|
|
24
23
|
__exportStar(require("./IModelImporter"), exports);
|
|
25
24
|
__exportStar(require("./IModelTransformer"), exports);
|
|
25
|
+
__exportStar(require("./IModelTransformContext"), exports);
|
|
26
|
+
__exportStar(require("./IModelTransformerError"), exports);
|
|
26
27
|
__exportStar(require("./BranchProvenanceInitializer"), exports);
|
|
27
28
|
const semver = require("semver");
|
|
28
29
|
const core_bentley_1 = require("@itwin/core-bentley");
|
|
@@ -108,6 +109,14 @@ if (process.env[noStrictDepCheckEnvVar] !== "1" &&
|
|
|
108
109
|
* @docs-group-description Logging
|
|
109
110
|
* Logger categories used by this package.
|
|
110
111
|
*/
|
|
112
|
+
/**
|
|
113
|
+
* @docs-group-description ElementAspectExportCoordinator
|
|
114
|
+
* Internal coordination for scoped, owner-batched ElementAspect export.
|
|
115
|
+
*/
|
|
116
|
+
/**
|
|
117
|
+
* @docs-group-description ElementAspectExportProcessor
|
|
118
|
+
* Internal source queries, filtering, and export callbacks for ElementAspects owned by accepted elements.
|
|
119
|
+
*/
|
|
111
120
|
/**
|
|
112
121
|
* @docs-group-description IModelTransformerError
|
|
113
122
|
* Stable identifiers for errors originating from this package.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imodel-transformer.js","sourceRoot":"","sources":["../../src/imodel-transformer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;gGAGgG;AAChG,8DAA4C;AAC5C,
|
|
1
|
+
{"version":3,"file":"imodel-transformer.js","sourceRoot":"","sources":["../../src/imodel-transformer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;gGAGgG;AAChG,8DAA4C;AAC5C,mDAAiC;AACjC,mDAAiC;AACjC,sDAAoC;AACpC,2DAAyC;AACzC,2DAAyC;AACzC,gEAA8C;AAE9C,iCAAiC;AACjC,sDAAiD;AACjD,mEAAsF;AACtF,qEAGkC;AAClC,6EAA0E;AAE1E,MAAM,EACJ,OAAO,EAAE,UAAU,EACnB,IAAI,EAAE,OAAO,EACb,gBAAgB,GACjB,GAAG,uDAA0B,CAAC;AAE/B,MAAM,2BAA2B,GAAG,gBAAgB,CAAC,qBAAqB,CAAC,CAAC;AAE5E,MAAM,sBAAsB,GAAG,iCAAiC,CAAC;AACjE,MAAM,iBAAiB,GAAG,8BAA8B,CAAC;AAEzD,4CAA4C;AAC5C,IAAI,MAAM,CAAC,UAAU,CAAC,sBAAuB,CAAC,EAAE,CAAC;IAC/C,sCAAsC;IACtC,OAAO,CAAC,IAAI,CACV,kCAAkC,sBAAuB,KAAK;QAC5D,uFAAuF;QACvF,+FAA+F,CAClG,CAAC;AACJ,CAAC;AAED,IACE,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,KAAK,GAAG;IAC3C,CAAC,MAAM,CAAC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AC,IAAI,EAAE,CAClD,CACF;iBACA,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;iBACf,MAAM,CAAC,gBAAgB,CAAC;iBACxB,OAAO,EAAE,CAAC;YAEb,yBAAU,CAAC,UAAU,CAAC;gBACpB,YAAY,EAAE;oBACZ,KAAK,EAAE,oDAA2B;oBAClC,GAAG,EAAE,+CAAsB,CAAC,yBAAyB;iBACtD;gBACD,OAAO,EAAE;oBACP,SAAS;oBACT,YAAY,iBAAiB,yEAAyE;oBACtG,wDAAwD;oBACxD,GAAG,6BAA6B;iBACjC,CAAC,IAAI,CAAC,IAAI,CAAC;aACb,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,yBAAU,CAAC,UAAU,CAAC;YACpB,YAAY,EAAE;gBACZ,KAAK,EAAE,oDAA2B;gBAClC,GAAG,EAAE,+CAAsB,CAAC,yBAAyB;aACtD;YACD,OAAO,EAAE,GAAG,SAAS,+CAA+C,iBAAiB,yCAAyC;SAC/H,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH;;;;GAIG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;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 *--------------------------------------------------------------------------------------------*/\nexport * from \"./TransformerLoggerCategory\";\nexport * from \"./IModelExporter\";\nexport * from \"./IModelImporter\";\nexport * from \"./IModelTransformer\";\nexport * from \"./IModelTransformContext\";\nexport * from \"./IModelTransformerError\";\nexport * from \"./BranchProvenanceInitializer\";\n\nimport * as semver from \"semver\";\nimport { ITwinError } from \"@itwin/core-bentley\";\nimport { version as iTwinCoreBackendVersion } from \"@itwin/core-backend/package.json\";\nimport {\n IModelTransformerError,\n IModelTransformerErrorScope,\n} from \"./IModelTransformerError\";\nimport { transformerPackageMetadata } from \"./TransformerPackageMetadata\";\n\nconst {\n version: ourVersion,\n name: ourName,\n peerDependencies,\n} = transformerPackageMetadata;\n\nconst ourITwinCoreBackendDepRange = peerDependencies[\"@itwin/core-backend\"];\n\nconst noStrictDepCheckEnvVar = \"TRANSFORMER_NO_STRICT_DEP_CHECK\";\nconst suggestEnvVarName = \"SUGGEST_TRANSFORMER_VERSIONS\";\n\n// warn if using a prerelease or dev version\nif (semver.prerelease(iTwinCoreBackendVersion)) {\n // eslint-disable-next-line no-console\n console.warn(\n `Warning: dev version detected (${iTwinCoreBackendVersion}). ` +\n \"This version is most likely fine, but it may introduce new behavior that could cause \" +\n \"unexpected issues or changes in the transformer's functionality. Please proceed with caution.\"\n );\n}\n\nif (\n process.env[noStrictDepCheckEnvVar] !== \"1\" &&\n !semver.satisfies(iTwinCoreBackendVersion, ourITwinCoreBackendDepRange, {\n includePrerelease: true,\n })\n) {\n const errHeader =\n `${ourName}@${ourVersion} only supports @itwin/core-backend@${ourITwinCoreBackendDepRange}, ` +\n `but @itwin/core-backend${iTwinCoreBackendVersion} was resolved when looking for the peer dependency.\\n` +\n `If you know exactly what you are doing, you can disable this check by setting ${noStrictDepCheckEnvVar}=1 in the environment\\n`;\n\n if (process.env[suggestEnvVarName]) {\n // let's not import https except in this case\n // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports\n const https = require(\"node:https\") as typeof import(\"node:https\");\n https.get(`https://registry.npmjs.org/${ourName}`, async (resp) => {\n const chunks: string[] = [];\n const packumentSrc = await new Promise<string>((r) =>\n resp\n .setEncoding(\"utf8\")\n .on(\"data\", (d) => chunks.push(d))\n .on(\"end\", () => r(chunks.join(\"\")))\n );\n interface PackumentSubset {\n versions: Record<\n string,\n {\n peerDependencies?: {\n \"@itwin/core-backend\": string; // eslint-disable-line @typescript-eslint/naming-convention\n };\n }\n >;\n }\n\n const packumentJson = JSON.parse(packumentSrc) as PackumentSubset;\n const isTaglessVersion = (version: string) => version.includes(\"-\");\n const latestFirstApplicableVersions = Object.entries(\n packumentJson.versions\n )\n .filter(([, v]) =>\n semver.satisfies(\n iTwinCoreBackendVersion,\n v.peerDependencies?.[\"@itwin/core-backend\"] ?? \"\"\n )\n )\n .map(([k]) => k)\n .filter(isTaglessVersion)\n .reverse();\n\n ITwinError.throwError({\n iTwinErrorId: {\n scope: IModelTransformerErrorScope,\n key: IModelTransformerError.DependencyVersionMismatch,\n },\n message: [\n errHeader,\n `You have ${suggestEnvVarName}=1 set in the environment, so we suggest one of the following versions.`,\n \"Be aware that older versions may be missing bug fixes.\",\n ...latestFirstApplicableVersions,\n ].join(\"\\n\"),\n });\n });\n } else {\n ITwinError.throwError({\n iTwinErrorId: {\n scope: IModelTransformerErrorScope,\n key: IModelTransformerError.DependencyVersionMismatch,\n },\n message: `${errHeader}You can rerun with the environment variable ${suggestEnvVarName}=1 to have this error suggest a version`,\n });\n }\n}\n\n/** @docs-package-description\n * The @itwin/imodel-transformer package contains classes that [backend code]($docs/learning/backend/index.md) can use to\n * traverse iModels, as well as *transform* an iModel into another existing or empty one, by exporting elements from one during\n * traversal and importing them into another.\n *\n * You can read further in [iModelTransformation and Data Exchange]($docs/learning/transformer/index.md) here.\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 * @docs-group-description Utils\n * Miscellaneous utility classes.\n */\n/**\n * @docs-group-description Logging\n * Logger categories used by this package.\n */\n/**\n * @docs-group-description ElementAspectExportCoordinator\n * Internal coordination for scoped, owner-batched ElementAspect export.\n */\n/**\n * @docs-group-description ElementAspectExportProcessor\n * Internal source queries, filtering, and export callbacks for ElementAspects owned by accepted elements.\n */\n/**\n * @docs-group-description IModelTransformerError\n * Stable identifiers for errors originating from this package.\n */\n/**\n * @docs-group-description TransformerPackageMetadata\n * Internal metadata describing this package and its peer dependencies.\n */\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/imodel-transformer",
|
|
3
|
-
"version": "2.0.0-dev.
|
|
3
|
+
"version": "2.0.0-dev.36",
|
|
4
4
|
"description": "API for exporting an iModel's parts and also importing them into another iModel",
|
|
5
5
|
"main": "lib/cjs/imodel-transformer.js",
|
|
6
6
|
"typings": "lib/cjs/imodel-transformer",
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ExportElementAspectsStrategy } from "./ExportElementAspectsStrategy";
|
|
2
|
-
/**
|
|
3
|
-
* Detached ElementAspect export strategy for [[IModelExporter]].
|
|
4
|
-
* This strategy exports all ElementAspects separately from the Elements that own them.
|
|
5
|
-
*
|
|
6
|
-
* @note Since aspects are exported separately from elements that own them, this strategy will export aspects of filtered out elements by default and
|
|
7
|
-
* this needs to be handled by ElementAspectHandler
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
export declare class DetachedExportElementAspectsStrategy extends ExportElementAspectsStrategy {
|
|
11
|
-
exportAllElementAspects(): Promise<void>;
|
|
12
|
-
private exportAspectsLoop;
|
|
13
|
-
private queryAspects;
|
|
14
|
-
exportElementAspectsForElement(_elementId: string): Promise<void>;
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=DetachedExportElementAspectsStrategy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DetachedExportElementAspectsStrategy.d.ts","sourceRoot":"","sources":["../../src/DetachedExportElementAspectsStrategy.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAQ9E;;;;;;;GAOG;AACH,qBAAa,oCAAqC,SAAQ,4BAA4B;IAC9D,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC;YAsDhD,iBAAiB;YAahB,YAAY;IAgEL,8BAA8B,CAClD,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC;CAGjB"}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.DetachedExportElementAspectsStrategy = void 0;
|
|
8
|
-
const core_backend_1 = require("@itwin/core-backend");
|
|
9
|
-
const ExportElementAspectsStrategy_1 = require("./ExportElementAspectsStrategy");
|
|
10
|
-
const ECSqlReaderAsyncIterableIteratorAdapter_1 = require("./ECSqlReaderAsyncIterableIteratorAdapter");
|
|
11
|
-
const core_common_1 = require("@itwin/core-common");
|
|
12
|
-
/**
|
|
13
|
-
* Detached ElementAspect export strategy for [[IModelExporter]].
|
|
14
|
-
* This strategy exports all ElementAspects separately from the Elements that own them.
|
|
15
|
-
*
|
|
16
|
-
* @note Since aspects are exported separately from elements that own them, this strategy will export aspects of filtered out elements by default and
|
|
17
|
-
* this needs to be handled by ElementAspectHandler
|
|
18
|
-
* @internal
|
|
19
|
-
*/
|
|
20
|
-
class DetachedExportElementAspectsStrategy extends ExportElementAspectsStrategy_1.ExportElementAspectsStrategy {
|
|
21
|
-
async exportAllElementAspects() {
|
|
22
|
-
await this.exportAspectsLoop(core_backend_1.ElementUniqueAspect.classFullName, async (uniqueAspect) => {
|
|
23
|
-
const isInsertChange = this.aspectChanges?.insertIds.has(uniqueAspect.id) ?? false;
|
|
24
|
-
const isUpdateChange = this.aspectChanges?.updateIds.has(uniqueAspect.id) ?? false;
|
|
25
|
-
const doExport = this.aspectChanges === undefined || isInsertChange || isUpdateChange;
|
|
26
|
-
if (doExport) {
|
|
27
|
-
const isKnownUpdate = this.aspectChanges ? isUpdateChange : undefined;
|
|
28
|
-
await this.handler.onExportElementUniqueAspect(uniqueAspect, isKnownUpdate);
|
|
29
|
-
await this.handler.trackProgress();
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
let batchedElementMultiAspects = [];
|
|
33
|
-
await this.exportAspectsLoop(core_backend_1.ElementMultiAspect.classFullName, async (multiAspect) => {
|
|
34
|
-
if (batchedElementMultiAspects.length === 0) {
|
|
35
|
-
batchedElementMultiAspects.push(multiAspect);
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
// element id changed so all element's aspects are in the array and can be exported
|
|
39
|
-
if (batchedElementMultiAspects[0].element.id !== multiAspect.element.id) {
|
|
40
|
-
await this.handler.onExportElementMultiAspects(batchedElementMultiAspects);
|
|
41
|
-
await this.handler.trackProgress();
|
|
42
|
-
batchedElementMultiAspects = [];
|
|
43
|
-
}
|
|
44
|
-
batchedElementMultiAspects.push(multiAspect);
|
|
45
|
-
});
|
|
46
|
-
if (batchedElementMultiAspects.length > 0) {
|
|
47
|
-
// aspects that are left in the array have not been exported
|
|
48
|
-
await this.handler.onExportElementMultiAspects(batchedElementMultiAspects);
|
|
49
|
-
await this.handler.trackProgress();
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
async exportAspectsLoop(baseAspectClass, exportAspect) {
|
|
53
|
-
for await (const aspect of this.queryAspects(baseAspectClass)) {
|
|
54
|
-
if (!(await this.shouldExportElementAspect(aspect))) {
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
await exportAspect(aspect);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
async *queryAspects(baseElementAspectClassFullName) {
|
|
61
|
-
const aspectClassNameIdMap = new Map();
|
|
62
|
-
const optimizesAspectClassesSql = `
|
|
63
|
-
SELECT c.ECInstanceId as classId, (ec_className(c.ECInstanceId, 's')) as schemaName, (ec_className(c.ECInstanceId, 'c')) as className
|
|
64
|
-
FROM ECDbMeta.ClassHasAllBaseClasses r
|
|
65
|
-
JOIN ECDbMeta.ECClassDef c ON c.ECInstanceId = r.SourceECInstanceId
|
|
66
|
-
WHERE r.TargetECInstanceId = ec_classId(:baseClassName)
|
|
67
|
-
`;
|
|
68
|
-
const aspectClassesQueryReader = this.sourceDb.createQueryReader(optimizesAspectClassesSql, new core_common_1.QueryBinder().bindString("baseClassName", baseElementAspectClassFullName), { usePrimaryConn: true });
|
|
69
|
-
const aspectClassesAsyncQueryReader = (0, ECSqlReaderAsyncIterableIteratorAdapter_1.ensureECSqlReaderIsAsyncIterableIterator)(aspectClassesQueryReader);
|
|
70
|
-
for await (const rowProxy of aspectClassesAsyncQueryReader) {
|
|
71
|
-
const row = rowProxy.toRow();
|
|
72
|
-
aspectClassNameIdMap.set(row.classId, {
|
|
73
|
-
schemaName: row.schemaName,
|
|
74
|
-
className: row.className,
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
for (const [classId, { schemaName, className }] of aspectClassNameIdMap) {
|
|
78
|
-
const classFullName = `${schemaName}:${className}`;
|
|
79
|
-
if (this.excludedElementAspectClassFullNames.has(classFullName))
|
|
80
|
-
continue;
|
|
81
|
-
const getAspectPropsSql = `SELECT * FROM [${schemaName}]:[${className}] WHERE ECClassId = :classId ORDER BY Element.Id`;
|
|
82
|
-
const aspectQueryReader = this.sourceDb.createQueryReader(getAspectPropsSql, new core_common_1.QueryBinder().bindId("classId", classId),
|
|
83
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
84
|
-
{ rowFormat: core_common_1.QueryRowFormat.UseJsPropertyNames, usePrimaryConn: true });
|
|
85
|
-
const aspectAsyncQueryReader = (0, ECSqlReaderAsyncIterableIteratorAdapter_1.ensureECSqlReaderIsAsyncIterableIterator)(aspectQueryReader);
|
|
86
|
-
let firstDone = false;
|
|
87
|
-
for await (const rowProxy of aspectAsyncQueryReader) {
|
|
88
|
-
const row = rowProxy.toRow();
|
|
89
|
-
const aspectProps = {
|
|
90
|
-
...row,
|
|
91
|
-
classFullName,
|
|
92
|
-
className: undefined,
|
|
93
|
-
}; // add in property required by EntityProps
|
|
94
|
-
if (!firstDone) {
|
|
95
|
-
firstDone = true;
|
|
96
|
-
}
|
|
97
|
-
delete aspectProps.className; // clear property from SELECT * that we don't want in the final instance
|
|
98
|
-
const aspectEntity = this.sourceDb.constructEntity(aspectProps);
|
|
99
|
-
yield aspectEntity;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
async exportElementAspectsForElement(_elementId) {
|
|
104
|
-
// All aspects are exported separately from their elements and don't need to be exported when element is exported.
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
exports.DetachedExportElementAspectsStrategy = DetachedExportElementAspectsStrategy;
|
|
108
|
-
//# sourceMappingURL=DetachedExportElementAspectsStrategy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DetachedExportElementAspectsStrategy.js","sourceRoot":"","sources":["../../src/DetachedExportElementAspectsStrategy.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,sDAI6B;AAE7B,iFAA8E;AAC9E,uGAAqG;AACrG,oDAI4B;AAE5B;;;;;;;GAOG;AACH,MAAa,oCAAqC,SAAQ,2DAA4B;IACpE,KAAK,CAAC,uBAAuB;QAC3C,MAAM,IAAI,CAAC,iBAAiB,CAC1B,kCAAmB,CAAC,aAAa,EACjC,KAAK,EAAE,YAAY,EAAE,EAAE;YACrB,MAAM,cAAc,GAClB,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC,IAAI,KAAK,CAAC;YAC9D,MAAM,cAAc,GAClB,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC,IAAI,KAAK,CAAC;YAC9D,MAAM,QAAQ,GACZ,IAAI,CAAC,aAAa,KAAK,SAAS,IAAI,cAAc,IAAI,cAAc,CAAC;YACvE,IAAI,QAAQ,EAAE,CAAC;gBACb,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,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,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC;YAC5C,4DAA4D;YAC5D,EAAE,SAAS,EAAE,4BAAc,CAAC,kBAAkB,EAAE,cAAc,EAAE,IAAI,EAAE,CACvE,CAAC;YACF,MAAM,sBAAsB,GAC1B,IAAA,kFAAwC,EAAC,iBAAiB,CAAC,CAAC;YAC9D,IAAI,SAAS,GAAG,KAAK,CAAC;YACtB,IAAI,KAAK,EAAE,MAAM,QAAQ,IAAI,sBAAsB,EAAE,CAAC;gBACpD,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAC;gBAC7B,MAAM,WAAW,GAAuB;oBACtC,GAAG,GAAG;oBACN,aAAa;oBACb,SAAS,EAAE,SAAS;iBACrB,CAAC,CAAC,0CAA0C;gBAC7C,IAAI,CAAC,SAAS,EAAE,CAAC;oBACf,SAAS,GAAG,IAAI,CAAC;gBACnB,CAAC;gBACD,OAAQ,WAAmB,CAAC,SAAS,CAAC,CAAC,wEAAwE;gBAC/G,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAI,WAAW,CAAC,CAAC;gBAEnE,MAAM,YAAY,CAAC;YACrB,CAAC;QACH,CAAC;IACH,CAAC;IAEe,KAAK,CAAC,8BAA8B,CAClD,UAAkB;QAElB,kHAAkH;IACpH,CAAC;CACF;AAzID,oFAyIC","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\nimport {\n ElementAspect,\n ElementMultiAspect,\n ElementUniqueAspect,\n} from \"@itwin/core-backend\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { ExportElementAspectsStrategy } from \"./ExportElementAspectsStrategy\";\nimport { ensureECSqlReaderIsAsyncIterableIterator } from \"./ECSqlReaderAsyncIterableIteratorAdapter\";\nimport {\n ElementAspectProps,\n QueryBinder,\n QueryRowFormat,\n} from \"@itwin/core-common\";\n\n/**\n * Detached ElementAspect export strategy for [[IModelExporter]].\n * This strategy exports all ElementAspects separately from the Elements that own them.\n *\n * @note Since aspects are exported separately from elements that own them, this strategy will export aspects of filtered out elements by default and\n * this needs to be handled by ElementAspectHandler\n * @internal\n */\nexport class DetachedExportElementAspectsStrategy extends ExportElementAspectsStrategy {\n public override async exportAllElementAspects(): Promise<void> {\n await this.exportAspectsLoop<ElementUniqueAspect>(\n ElementUniqueAspect.classFullName,\n async (uniqueAspect) => {\n const isInsertChange =\n this.aspectChanges?.insertIds.has(uniqueAspect.id) ?? false;\n const isUpdateChange =\n this.aspectChanges?.updateIds.has(uniqueAspect.id) ?? false;\n const doExport =\n this.aspectChanges === undefined || isInsertChange || isUpdateChange;\n if (doExport) {\n const isKnownUpdate = this.aspectChanges ? isUpdateChange : undefined;\n await this.handler.onExportElementUniqueAspect(\n uniqueAspect,\n isKnownUpdate\n );\n await this.handler.trackProgress();\n }\n }\n );\n\n let batchedElementMultiAspects: ElementMultiAspect[] = [];\n await this.exportAspectsLoop<ElementMultiAspect>(\n ElementMultiAspect.classFullName,\n async (multiAspect) => {\n if (batchedElementMultiAspects.length === 0) {\n batchedElementMultiAspects.push(multiAspect);\n return;\n }\n\n // element id changed so all element's aspects are in the array and can be exported\n if (\n batchedElementMultiAspects[0].element.id !== multiAspect.element.id\n ) {\n await this.handler.onExportElementMultiAspects(\n batchedElementMultiAspects\n );\n await this.handler.trackProgress();\n batchedElementMultiAspects = [];\n }\n\n batchedElementMultiAspects.push(multiAspect);\n }\n );\n\n if (batchedElementMultiAspects.length > 0) {\n // aspects that are left in the array have not been exported\n await this.handler.onExportElementMultiAspects(\n batchedElementMultiAspects\n );\n await this.handler.trackProgress();\n }\n }\n\n private async exportAspectsLoop<T extends ElementAspect>(\n baseAspectClass: string,\n exportAspect: (aspect: T) => Promise<void>\n ) {\n for await (const aspect of this.queryAspects<T>(baseAspectClass)) {\n if (!(await this.shouldExportElementAspect(aspect))) {\n continue;\n }\n\n await exportAspect(aspect);\n }\n }\n\n private async *queryAspects<T extends ElementAspect>(\n baseElementAspectClassFullName: string\n ) {\n const aspectClassNameIdMap = new Map<\n Id64String,\n { schemaName: string; className: string }\n >();\n\n const optimizesAspectClassesSql = `\n SELECT c.ECInstanceId as classId, (ec_className(c.ECInstanceId, 's')) as schemaName, (ec_className(c.ECInstanceId, 'c')) as className\n FROM ECDbMeta.ClassHasAllBaseClasses r\n JOIN ECDbMeta.ECClassDef c ON c.ECInstanceId = r.SourceECInstanceId\n WHERE r.TargetECInstanceId = ec_classId(:baseClassName)\n `;\n const aspectClassesQueryReader = this.sourceDb.createQueryReader(\n optimizesAspectClassesSql,\n new QueryBinder().bindString(\n \"baseClassName\",\n baseElementAspectClassFullName\n ),\n { usePrimaryConn: true }\n );\n const aspectClassesAsyncQueryReader =\n ensureECSqlReaderIsAsyncIterableIterator(aspectClassesQueryReader);\n for await (const rowProxy of aspectClassesAsyncQueryReader) {\n const row = rowProxy.toRow();\n aspectClassNameIdMap.set(row.classId, {\n schemaName: row.schemaName,\n className: row.className,\n });\n }\n\n for (const [classId, { schemaName, className }] of aspectClassNameIdMap) {\n const classFullName = `${schemaName}:${className}`;\n if (this.excludedElementAspectClassFullNames.has(classFullName)) continue;\n\n const getAspectPropsSql = `SELECT * FROM [${schemaName}]:[${className}] WHERE ECClassId = :classId ORDER BY Element.Id`;\n const aspectQueryReader = this.sourceDb.createQueryReader(\n getAspectPropsSql,\n new QueryBinder().bindId(\"classId\", classId),\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n { rowFormat: QueryRowFormat.UseJsPropertyNames, usePrimaryConn: true }\n );\n const aspectAsyncQueryReader =\n ensureECSqlReaderIsAsyncIterableIterator(aspectQueryReader);\n let firstDone = false;\n for await (const rowProxy of aspectAsyncQueryReader) {\n const row = rowProxy.toRow();\n const aspectProps: ElementAspectProps = {\n ...row,\n classFullName,\n className: undefined,\n }; // add in property required by EntityProps\n if (!firstDone) {\n firstDone = true;\n }\n delete (aspectProps as any).className; // clear property from SELECT * that we don't want in the final instance\n const aspectEntity = this.sourceDb.constructEntity<T>(aspectProps);\n\n yield aspectEntity;\n }\n }\n }\n\n public override async exportElementAspectsForElement(\n _elementId: string\n ): Promise<void> {\n // All aspects are exported separately from their elements and don't need to be exported when element is exported.\n }\n}\n"]}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { ElementAspect, ElementMultiAspect, ElementUniqueAspect, IModelDb } from "@itwin/core-backend";
|
|
2
|
-
import { Id64String } from "@itwin/core-bentley";
|
|
3
|
-
import { ChangedInstanceOps } from "./IModelExporter";
|
|
4
|
-
/**
|
|
5
|
-
* Handler for [[ExportElementAspectsStrategy]]
|
|
6
|
-
* @internal
|
|
7
|
-
*/
|
|
8
|
-
export interface ElementAspectsHandler {
|
|
9
|
-
shouldExportElementAspect(aspect: ElementAspect): Promise<boolean>;
|
|
10
|
-
onExportElementUniqueAspect(uniqueAspect: ElementUniqueAspect, isUpdate?: boolean | undefined): Promise<void>;
|
|
11
|
-
onExportElementMultiAspects(multiAspects: ElementMultiAspect[]): Promise<void>;
|
|
12
|
-
trackProgress: () => Promise<void>;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Base ElementAspect export strategy. Base export strategy includes state saving and loading and
|
|
16
|
-
* ElementAspect filtering.
|
|
17
|
-
* @internal
|
|
18
|
-
*/
|
|
19
|
-
export declare abstract class ExportElementAspectsStrategy {
|
|
20
|
-
/** The set of classes of ElementAspects that will be excluded (polymorphically) from transformation to the target iModel. */
|
|
21
|
-
protected _excludedElementAspectClasses: Set<typeof ElementAspect>;
|
|
22
|
-
/** The set of classFullNames for ElementAspects that will be excluded from transformation to the target iModel. */
|
|
23
|
-
readonly excludedElementAspectClassFullNames: Set<string>;
|
|
24
|
-
protected sourceDb: IModelDb;
|
|
25
|
-
protected aspectChanges: ChangedInstanceOps | undefined;
|
|
26
|
-
protected handler: ElementAspectsHandler;
|
|
27
|
-
constructor(sourceDb: IModelDb, handler: ElementAspectsHandler);
|
|
28
|
-
abstract exportElementAspectsForElement(_elementId: Id64String): Promise<void>;
|
|
29
|
-
abstract exportAllElementAspects(): Promise<void>;
|
|
30
|
-
protected shouldExportElementAspect(aspect: ElementAspect): Promise<boolean>;
|
|
31
|
-
setAspectChanges(aspectChanges?: ChangedInstanceOps): void;
|
|
32
|
-
loadExcludedElementAspectClasses(excludedElementAspectClassFullNames: string[]): void;
|
|
33
|
-
excludeElementAspectClass(classFullName: string): void;
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=ExportElementAspectsStrategy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExportElementAspectsStrategy.d.ts","sourceRoot":"","sources":["../../src/ExportElementAspectsStrategy.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EACnB,QAAQ,EACT,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAU,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAItD;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,yBAAyB,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACnE,2BAA2B,CACzB,YAAY,EAAE,mBAAmB,EACjC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,GAC7B,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,2BAA2B,CACzB,YAAY,EAAE,kBAAkB,EAAE,GACjC,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,aAAa,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC;AAED;;;;GAIG;AACH,8BAAsB,4BAA4B;IAChD,6HAA6H;IAC7H,SAAS,CAAC,6BAA6B,4BAAmC;IAC1E,mHAAmH;IACnH,SAAgB,mCAAmC,cAAqB;IAExE,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAE7B,SAAS,CAAC,aAAa,EAAE,kBAAkB,GAAG,SAAS,CAAC;IAExD,SAAS,CAAC,OAAO,EAAE,qBAAqB,CAAC;gBAEtB,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,qBAAqB;aAKrD,8BAA8B,CAC5C,UAAU,EAAE,UAAU,GACrB,OAAO,CAAC,IAAI,CAAC;aACA,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC;cAExC,yBAAyB,CACvC,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,OAAO,CAAC;IAeZ,gBAAgB,CAAC,aAAa,CAAC,EAAE,kBAAkB;IAInD,gCAAgC,CACrC,mCAAmC,EAAE,MAAM,EAAE,GAC5C,IAAI;IAWA,yBAAyB,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI;CAM9D"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.ExportElementAspectsStrategy = void 0;
|
|
8
|
-
const core_bentley_1 = require("@itwin/core-bentley");
|
|
9
|
-
const TransformerLoggerCategory_1 = require("./TransformerLoggerCategory");
|
|
10
|
-
const loggerCategory = TransformerLoggerCategory_1.TransformerLoggerCategory.IModelExporter;
|
|
11
|
-
/**
|
|
12
|
-
* Base ElementAspect export strategy. Base export strategy includes state saving and loading and
|
|
13
|
-
* ElementAspect filtering.
|
|
14
|
-
* @internal
|
|
15
|
-
*/
|
|
16
|
-
class ExportElementAspectsStrategy {
|
|
17
|
-
/** The set of classes of ElementAspects that will be excluded (polymorphically) from transformation to the target iModel. */
|
|
18
|
-
_excludedElementAspectClasses = new Set();
|
|
19
|
-
/** The set of classFullNames for ElementAspects that will be excluded from transformation to the target iModel. */
|
|
20
|
-
excludedElementAspectClassFullNames = new Set();
|
|
21
|
-
sourceDb;
|
|
22
|
-
aspectChanges;
|
|
23
|
-
handler;
|
|
24
|
-
constructor(sourceDb, handler) {
|
|
25
|
-
this.sourceDb = sourceDb;
|
|
26
|
-
this.handler = handler;
|
|
27
|
-
}
|
|
28
|
-
async shouldExportElementAspect(aspect) {
|
|
29
|
-
for (const excludedElementAspectClass of this
|
|
30
|
-
._excludedElementAspectClasses) {
|
|
31
|
-
if (aspect instanceof excludedElementAspectClass) {
|
|
32
|
-
core_bentley_1.Logger.logInfo(loggerCategory, `Excluded ElementAspect by class: ${aspect.classFullName}`);
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
// ElementAspect has passed standard exclusion rules, now give handler a chance to accept/reject
|
|
37
|
-
return this.handler.shouldExportElementAspect(aspect);
|
|
38
|
-
}
|
|
39
|
-
setAspectChanges(aspectChanges) {
|
|
40
|
-
this.aspectChanges = aspectChanges;
|
|
41
|
-
}
|
|
42
|
-
loadExcludedElementAspectClasses(excludedElementAspectClassFullNames) {
|
|
43
|
-
this.excludedElementAspectClassFullNames = new Set(excludedElementAspectClassFullNames);
|
|
44
|
-
this._excludedElementAspectClasses = new Set(excludedElementAspectClassFullNames.map((c) => this.sourceDb.getJsClass(c)));
|
|
45
|
-
}
|
|
46
|
-
excludeElementAspectClass(classFullName) {
|
|
47
|
-
this.excludedElementAspectClassFullNames.add(classFullName); // allows non-polymorphic exclusion before query
|
|
48
|
-
this._excludedElementAspectClasses.add(this.sourceDb.getJsClass(classFullName)); // allows polymorphic exclusion after query/load
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
exports.ExportElementAspectsStrategy = ExportElementAspectsStrategy;
|
|
52
|
-
//# sourceMappingURL=ExportElementAspectsStrategy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExportElementAspectsStrategy.js","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C5B,CACF,CAAC;IACJ,CAAC;IAEM,yBAAyB,CAAC,aAAqB;QACpD,IAAI,CAAC,mCAAmC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,gDAAgD;QAC7G,IAAI,CAAC,6BAA6B,CAAC,GAAG,CACpC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAuB,aAAa,CAAC,CAC9D,CAAC,CAAC,gDAAgD;IACrD,CAAC;CACF;AA9DD,oEA8DC","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\nimport {\n ElementAspect,\n ElementMultiAspect,\n ElementUniqueAspect,\n IModelDb,\n} from \"@itwin/core-backend\";\nimport { Id64String, Logger } from \"@itwin/core-bentley\";\nimport { TransformerLoggerCategory } from \"./TransformerLoggerCategory\";\nimport { ChangedInstanceOps } from \"./IModelExporter\";\n\nconst loggerCategory = TransformerLoggerCategory.IModelExporter;\n\n/**\n * Handler for [[ExportElementAspectsStrategy]]\n * @internal\n */\nexport interface ElementAspectsHandler {\n shouldExportElementAspect(aspect: ElementAspect): Promise<boolean>;\n onExportElementUniqueAspect(\n uniqueAspect: ElementUniqueAspect,\n isUpdate?: boolean | undefined\n ): Promise<void>;\n onExportElementMultiAspects(\n multiAspects: ElementMultiAspect[]\n ): Promise<void>;\n trackProgress: () => Promise<void>;\n}\n\n/**\n * Base ElementAspect export strategy. Base export strategy includes state saving and loading and\n * ElementAspect filtering.\n * @internal\n */\nexport abstract class ExportElementAspectsStrategy {\n /** The set of classes of ElementAspects that will be excluded (polymorphically) from transformation to the target iModel. */\n protected _excludedElementAspectClasses = new Set<typeof ElementAspect>();\n /** The set of classFullNames for ElementAspects that will be excluded from transformation to the target iModel. */\n public readonly excludedElementAspectClassFullNames = new Set<string>();\n\n protected sourceDb: IModelDb;\n\n protected aspectChanges: ChangedInstanceOps | undefined;\n\n protected handler: ElementAspectsHandler;\n\n public constructor(sourceDb: IModelDb, handler: ElementAspectsHandler) {\n this.sourceDb = sourceDb;\n this.handler = handler;\n }\n\n public abstract exportElementAspectsForElement(\n _elementId: Id64String\n ): Promise<void>;\n public abstract exportAllElementAspects(): Promise<void>;\n\n protected async shouldExportElementAspect(\n aspect: ElementAspect\n ): Promise<boolean> {\n for (const excludedElementAspectClass of this\n ._excludedElementAspectClasses) {\n if (aspect instanceof excludedElementAspectClass) {\n Logger.logInfo(\n loggerCategory,\n `Excluded ElementAspect by class: ${aspect.classFullName}`\n );\n return false;\n }\n }\n // ElementAspect has passed standard exclusion rules, now give handler a chance to accept/reject\n return this.handler.shouldExportElementAspect(aspect);\n }\n\n public setAspectChanges(aspectChanges?: ChangedInstanceOps) {\n this.aspectChanges = aspectChanges;\n }\n\n public loadExcludedElementAspectClasses(\n excludedElementAspectClassFullNames: string[]\n ): void {\n (this.excludedElementAspectClassFullNames as any) = new Set(\n excludedElementAspectClassFullNames\n );\n this._excludedElementAspectClasses = new Set(\n excludedElementAspectClassFullNames.map((c) =>\n this.sourceDb.getJsClass(c)\n )\n );\n }\n\n public excludeElementAspectClass(classFullName: string): void {\n this.excludedElementAspectClassFullNames.add(classFullName); // allows non-polymorphic exclusion before query\n this._excludedElementAspectClasses.add(\n this.sourceDb.getJsClass<typeof ElementAspect>(classFullName)\n ); // allows polymorphic exclusion after query/load\n }\n}\n"]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Id64String } from "@itwin/core-bentley";
|
|
2
|
-
import { ExportElementAspectsStrategy } from "./ExportElementAspectsStrategy";
|
|
3
|
-
/**
|
|
4
|
-
* ElementAspect export strategy for [[IModelExporter]].
|
|
5
|
-
* This strategy exports ElementAspects together with their Elements.
|
|
6
|
-
* @internal
|
|
7
|
-
*/
|
|
8
|
-
export declare class ExportElementAspectsWithElementsStrategy extends ExportElementAspectsStrategy {
|
|
9
|
-
exportElementAspectsForElement(elementId: Id64String): Promise<void>;
|
|
10
|
-
exportAllElementAspects(): Promise<void>;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=ExportElementAspectsWithElementsStrategy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExportElementAspectsWithElementsStrategy.d.ts","sourceRoot":"","sources":["../../src/ExportElementAspectsWithElementsStrategy.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAE9E;;;;GAIG;AACH,qBAAa,wCAAyC,SAAQ,4BAA4B;IAClE,8BAA8B,CAClD,SAAS,EAAE,UAAU,GACpB,OAAO,CAAC,IAAI,CAAC;IA4CM,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC;CAG/D"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.ExportElementAspectsWithElementsStrategy = void 0;
|
|
8
|
-
const core_backend_1 = require("@itwin/core-backend");
|
|
9
|
-
const ExportElementAspectsStrategy_1 = require("./ExportElementAspectsStrategy");
|
|
10
|
-
/**
|
|
11
|
-
* ElementAspect export strategy for [[IModelExporter]].
|
|
12
|
-
* This strategy exports ElementAspects together with their Elements.
|
|
13
|
-
* @internal
|
|
14
|
-
*/
|
|
15
|
-
class ExportElementAspectsWithElementsStrategy extends ExportElementAspectsStrategy_1.ExportElementAspectsStrategy {
|
|
16
|
-
async exportElementAspectsForElement(elementId) {
|
|
17
|
-
const allUniqueAspects = this.sourceDb.elements._queryAspects(elementId, core_backend_1.ElementUniqueAspect.classFullName, this.excludedElementAspectClassFullNames);
|
|
18
|
-
for (const uniqueAspect of allUniqueAspects) {
|
|
19
|
-
if (!(await this.shouldExportElementAspect(uniqueAspect))) {
|
|
20
|
-
continue;
|
|
21
|
-
}
|
|
22
|
-
const isInsertChange = this.aspectChanges?.insertIds.has(uniqueAspect.id) ?? false;
|
|
23
|
-
const isUpdateChange = this.aspectChanges?.updateIds.has(uniqueAspect.id) ?? false;
|
|
24
|
-
const doExport = this.aspectChanges === undefined || isInsertChange || isUpdateChange;
|
|
25
|
-
if (doExport) {
|
|
26
|
-
const isKnownUpdate = this.aspectChanges ? isUpdateChange : undefined;
|
|
27
|
-
await this.handler.onExportElementUniqueAspect(uniqueAspect, isKnownUpdate);
|
|
28
|
-
await this.handler.trackProgress();
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
const allMultiAspects = this.sourceDb.elements._queryAspects(elementId, core_backend_1.ElementMultiAspect.classFullName, this.excludedElementAspectClassFullNames);
|
|
32
|
-
const multiAspects = [];
|
|
33
|
-
for (const aspect of allMultiAspects) {
|
|
34
|
-
if (await this.shouldExportElementAspect(aspect)) {
|
|
35
|
-
multiAspects.push(aspect);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
if (multiAspects.length > 0) {
|
|
39
|
-
await this.handler.onExportElementMultiAspects(multiAspects);
|
|
40
|
-
return this.handler.trackProgress();
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
async exportAllElementAspects() {
|
|
44
|
-
// All aspects are exported with their owning elements and don't need to be exported separately.
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
exports.ExportElementAspectsWithElementsStrategy = ExportElementAspectsWithElementsStrategy;
|
|
48
|
-
//# sourceMappingURL=ExportElementAspectsWithElementsStrategy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExportElementAspectsWithElementsStrategy.js","sourceRoot":"","sources":["../../src/ExportElementAspectsWithElementsStrategy.ts"],"names":[],"mappings":";AAAA;;;gGAGgG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MAAM,MAAM,IAAI,eAAe,EAAE,CAAC;YACrC,IAAI,MAAM,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,CAAC;gBACjD,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC;QAED,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC5B,MAAM,IAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,YAAY,CAAC,CAAC;YAC7D,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;QACtC,CAAC;IACH,CAAC;IAEe,KAAK,CAAC,uBAAuB;QAC3C,gGAAgG;IAClG,CAAC;CACF;AAlDD,4FAkDC","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\nimport { ElementMultiAspect, ElementUniqueAspect } from \"@itwin/core-backend\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { ExportElementAspectsStrategy } from \"./ExportElementAspectsStrategy\";\n\n/**\n * ElementAspect export strategy for [[IModelExporter]].\n * This strategy exports ElementAspects together with their Elements.\n * @internal\n */\nexport class ExportElementAspectsWithElementsStrategy extends ExportElementAspectsStrategy {\n public override async exportElementAspectsForElement(\n elementId: Id64String\n ): Promise<void> {\n const allUniqueAspects = this.sourceDb.elements._queryAspects(\n elementId,\n ElementUniqueAspect.classFullName,\n this.excludedElementAspectClassFullNames\n );\n for (const uniqueAspect of allUniqueAspects) {\n if (!(await this.shouldExportElementAspect(uniqueAspect))) {\n continue;\n }\n const isInsertChange =\n this.aspectChanges?.insertIds.has(uniqueAspect.id) ?? false;\n const isUpdateChange =\n this.aspectChanges?.updateIds.has(uniqueAspect.id) ?? false;\n const doExport =\n this.aspectChanges === undefined || isInsertChange || isUpdateChange;\n if (doExport) {\n const isKnownUpdate = this.aspectChanges ? isUpdateChange : undefined;\n await this.handler.onExportElementUniqueAspect(\n uniqueAspect,\n isKnownUpdate\n );\n await this.handler.trackProgress();\n }\n }\n\n const allMultiAspects = this.sourceDb.elements._queryAspects(\n elementId,\n ElementMultiAspect.classFullName,\n this.excludedElementAspectClassFullNames\n );\n const multiAspects: ElementMultiAspect[] = [];\n for (const aspect of allMultiAspects) {\n if (await this.shouldExportElementAspect(aspect)) {\n multiAspects.push(aspect);\n }\n }\n\n if (multiAspects.length > 0) {\n await this.handler.onExportElementMultiAspects(multiAspects);\n return this.handler.trackProgress();\n }\n }\n\n public override async exportAllElementAspects(): Promise<void> {\n // All aspects are exported with their owning elements and don't need to be exported separately.\n }\n}\n"]}
|