@itwin/imodel-transformer 0.3.2 → 0.3.3-dev.0

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/CHANGELOG.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # Change Log - @itwin/imodel-transformer
2
2
 
3
- This log was last generated on Fri, 18 Aug 2023 23:12:20 GMT and should not be manually modified.
3
+ This log was last generated on Fri, 18 Aug 2023 23:12:28 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
7
  ## 0.3.2
8
8
 
9
- Fri, 18 Aug 2023 23:12:20 GMT
9
+ Fri, 18 Aug 2023 23:12:28 GMT
10
10
 
11
11
  ### Patches
12
12
 
@@ -0,0 +1,16 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DetachedExportElementAspectsStrategy.d.ts","sourceRoot":"","sources":["../../src/DetachedExportElementAspectsStrategy.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAI9E;;;;;;;GAOG;AACH,qBAAa,oCAAqC,SAAQ,4BAA4B;IAC9D,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC;YAoChD,iBAAiB;YAUhB,YAAY;IAsCL,8BAA8B,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGxF"}
@@ -0,0 +1,98 @@
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
+ 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
+ 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
+ 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 (!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: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));
69
+ const aspectClassesAsyncQueryReader = (0, ECSqlReaderAsyncIterableIteratorAdapter_1.ensureECSqlReaderIsAsyncIterableIterator)(aspectClassesQueryReader);
70
+ for await (const rowProxy of aspectClassesAsyncQueryReader) {
71
+ const row = rowProxy.toRow();
72
+ aspectClassNameIdMap.set(row.className, row.classId);
73
+ }
74
+ for (const [className, classId] of aspectClassNameIdMap) {
75
+ if (this.excludedElementAspectClassFullNames.has(className))
76
+ continue;
77
+ const getAspectPropsSql = `SELECT * FROM ${className} WHERE ECClassId = :classId ORDER BY Element.Id`;
78
+ const aspectQueryReader = this.sourceDb.createQueryReader(getAspectPropsSql, new core_common_1.QueryBinder().bindId("classId", classId), { rowFormat: core_common_1.QueryRowFormat.UseJsPropertyNames });
79
+ const aspectAsyncQueryReader = (0, ECSqlReaderAsyncIterableIteratorAdapter_1.ensureECSqlReaderIsAsyncIterableIterator)(aspectQueryReader);
80
+ let firstDone = false;
81
+ for await (const rowProxy of aspectAsyncQueryReader) {
82
+ const row = rowProxy.toRow();
83
+ const aspectProps = { ...row, classFullName: className, className: undefined }; // add in property required by EntityProps
84
+ if (!firstDone) {
85
+ firstDone = true;
86
+ }
87
+ delete aspectProps.className; // clear property from SELECT * that we don't want in the final instance
88
+ const aspectEntity = this.sourceDb.constructEntity(aspectProps);
89
+ yield aspectEntity;
90
+ }
91
+ }
92
+ }
93
+ async exportElementAspectsForElement(_elementId) {
94
+ // All aspects are exported separately from their elements and don't need to be exported when element is exported.
95
+ }
96
+ }
97
+ exports.DetachedExportElementAspectsStrategy = DetachedExportElementAspectsStrategy;
98
+ //# sourceMappingURL=DetachedExportElementAspectsStrategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DetachedExportElementAspectsStrategy.js","sourceRoot":"","sources":["../../src/DetachedExportElementAspectsStrategy.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sDAA6F;AAE7F,iFAA8E;AAC9E,uGAAqG;AACrG,oDAAqF;AAErF;;;;;;;GAOG;AACH,MAAa,oCAAqC,SAAQ,2DAA4B;IACpE,KAAK,CAAC,uBAAuB;QAC3C,MAAM,IAAI,CAAC,iBAAiB,CAAsB,kCAAmB,CAAC,aAAa,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE;YAC1G,MAAM,cAAc,GAAG,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC,IAAI,KAAK,CAAC;YACnF,MAAM,cAAc,GAAG,IAAI,CAAC,aAAa,EAAE,S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AAE,4BAAc,CAAC,kBAAkB,EAAE,CAAC,CAAC;YAC7K,MAAM,sBAAsB,GAAG,IAAA,kFAAwC,EAAC,iBAAiB,CAAC,CAAC;YAC3F,IAAI,SAAS,GAAG,KAAK,CAAC;YACtB,IAAI,KAAK,EAAE,MAAM,QAAQ,IAAI,sBAAsB,EAAE;gBACnD,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAC;gBAC7B,MAAM,WAAW,GAAuB,EAAE,GAAG,GAAG,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC,0CAA0C;gBAC9I,IAAI,CAAC,SAAS,EAAE;oBACd,SAAS,GAAG,IAAI,CAAC;iBAClB;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;aACpB;SACF;IACH,CAAC;IAEe,KAAK,CAAC,8BAA8B,CAAC,UAAkB;QACrE,kHAAkH;IACpH,CAAC;CACF;AAxFD,oFAwFC","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 { ElementAspect, ElementMultiAspect, ElementUniqueAspect } from \"@itwin/core-backend\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { ExportElementAspectsStrategy } from \"./ExportElementAspectsStrategy\";\nimport { ensureECSqlReaderIsAsyncIterableIterator } from \"./ECSqlReaderAsyncIterableIteratorAdapter\";\nimport { ElementAspectProps, QueryBinder, QueryRowFormat } 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>(ElementUniqueAspect.classFullName, async (uniqueAspect) => {\n const isInsertChange = this.aspectChanges?.insertIds.has(uniqueAspect.id) ?? false;\n const isUpdateChange = this.aspectChanges?.updateIds.has(uniqueAspect.id) ?? false;\n const doExport = this.aspectChanges === undefined || isInsertChange || isUpdateChange;\n if (doExport) {\n const isKnownUpdate = this.aspectChanges ? isUpdateChange : undefined;\n this.handler.onExportElementUniqueAspect(uniqueAspect, isKnownUpdate);\n await this.handler.trackProgress();\n }\n });\n\n let batchedElementMultiAspects: ElementMultiAspect[] = [];\n await this.exportAspectsLoop<ElementMultiAspect>(ElementMultiAspect.classFullName, 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 (batchedElementMultiAspects[0].element.id !== multiAspect.element.id) {\n this.handler.onExportElementMultiAspects(batchedElementMultiAspects);\n await this.handler.trackProgress();\n batchedElementMultiAspects = [];\n }\n\n batchedElementMultiAspects.push(multiAspect);\n });\n\n if (batchedElementMultiAspects.length > 0) {\n // aspects that are left in the array have not been exported\n this.handler.onExportElementMultiAspects(batchedElementMultiAspects);\n await this.handler.trackProgress();\n }\n }\n\n private async exportAspectsLoop<T extends ElementAspect>(baseAspectClass: string, exportAspect: (aspect: T) => Promise<void>) {\n for await (const aspect of this.queryAspects<T>(baseAspectClass)) {\n if (!this.shouldExportElementAspect(aspect)) {\n continue;\n }\n\n await exportAspect(aspect);\n }\n }\n\n private async *queryAspects<T extends ElementAspect>(baseElementAspectClassFullName: string) {\n const aspectClassNameIdMap = new Map<string, Id64String>();\n\n const optimizesAspectClassesSql = `\n SELECT c.ECInstanceId as classId, (ec_className(c.ECInstanceId, 's: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(optimizesAspectClassesSql, new QueryBinder().bindString(\"baseClassName\", baseElementAspectClassFullName));\n const aspectClassesAsyncQueryReader = ensureECSqlReaderIsAsyncIterableIterator(aspectClassesQueryReader);\n for await (const rowProxy of aspectClassesAsyncQueryReader) {\n const row = rowProxy.toRow();\n aspectClassNameIdMap.set(row.className, row.classId);\n }\n\n for (const [className, classId] of aspectClassNameIdMap) {\n if(this.excludedElementAspectClassFullNames.has(className))\n continue;\n\n const getAspectPropsSql = `SELECT * FROM ${className} WHERE ECClassId = :classId ORDER BY Element.Id`;\n const aspectQueryReader = this.sourceDb.createQueryReader(getAspectPropsSql, new QueryBinder().bindId(\"classId\", classId), { rowFormat: QueryRowFormat.UseJsPropertyNames });\n const aspectAsyncQueryReader = ensureECSqlReaderIsAsyncIterableIterator(aspectQueryReader);\n let firstDone = false;\n for await (const rowProxy of aspectAsyncQueryReader) {\n const row = rowProxy.toRow();\n const aspectProps: ElementAspectProps = { ...row, classFullName: className, className: undefined }; // 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(_elementId: string): 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"]}
@@ -0,0 +1,19 @@
1
+ import { ECSqlReader, QueryRowProxy } from "@itwin/core-common";
2
+ /**
3
+ * Adapter class for ECSqlReader for AsyncIterableIterator interface.
4
+ * It allows to iterate through query results in itwin 3.x using for await() syntax like using itwin 4.x version.
5
+ * @internal
6
+ */
7
+ export declare class ECSqlReaderAsyncIterableIteratorAdapter implements AsyncIterableIterator<QueryRowProxy> {
8
+ private _ecSqlReader;
9
+ constructor(_ecSqlReader: ECSqlReader);
10
+ [Symbol.asyncIterator](): AsyncIterableIterator<QueryRowProxy>;
11
+ next(): Promise<IteratorResult<QueryRowProxy, any>>;
12
+ }
13
+ /**
14
+ * Wraps ECSqlReader with ECSqlReaderAsyncIterableIteratorAdapter if it's needed.
15
+ * @param ecSqlReader ECSqlReader isntance from itwin 3.x or 4.x version
16
+ * @internal
17
+ */
18
+ export declare function ensureECSqlReaderIsAsyncIterableIterator(ecSqlReader: ECSqlReader & AsyncIterableIterator<QueryRowProxy> | Omit<ECSqlReader, keyof AsyncIterableIterator<QueryRowProxy>>): AsyncIterableIterator<QueryRowProxy>;
19
+ //# sourceMappingURL=ECSqlReaderAsyncIterableIteratorAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ECSqlReaderAsyncIterableIteratorAdapter.d.ts","sourceRoot":"","sources":["../../src/ECSqlReaderAsyncIterableIteratorAdapter.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEhE;;;;GAIG;AACH,qBAAa,uCAAwC,YAAW,qBAAqB,CAAC,aAAa,CAAC;IAE/E,OAAO,CAAC,YAAY;gBAAZ,YAAY,EAAE,WAAW;IAE7C,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,qBAAqB,CAAC,aAAa,CAAC;IAIxD,IAAI,IAAI,OAAO,CAAC,cAAc,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;CAOjE;AAED;;;;GAIG;AACH,wBAAgB,wCAAwC,CAAC,WAAW,EAAE,WAAW,GAAG,qBAAqB,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,qBAAqB,CAAC,aAAa,CAAC,CAAC,GAAG,qBAAqB,CAAC,aAAa,CAAC,CAM9N"}
@@ -0,0 +1,43 @@
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.ensureECSqlReaderIsAsyncIterableIterator = exports.ECSqlReaderAsyncIterableIteratorAdapter = void 0;
8
+ /**
9
+ * Adapter class for ECSqlReader for AsyncIterableIterator interface.
10
+ * It allows to iterate through query results in itwin 3.x using for await() syntax like using itwin 4.x version.
11
+ * @internal
12
+ */
13
+ class ECSqlReaderAsyncIterableIteratorAdapter {
14
+ constructor(_ecSqlReader) {
15
+ this._ecSqlReader = _ecSqlReader;
16
+ }
17
+ [Symbol.asyncIterator]() {
18
+ return this;
19
+ }
20
+ async next() {
21
+ const done = !(await this._ecSqlReader.step());
22
+ return {
23
+ done,
24
+ value: this._ecSqlReader.current,
25
+ };
26
+ }
27
+ }
28
+ exports.ECSqlReaderAsyncIterableIteratorAdapter = ECSqlReaderAsyncIterableIteratorAdapter;
29
+ /**
30
+ * Wraps ECSqlReader with ECSqlReaderAsyncIterableIteratorAdapter if it's needed.
31
+ * @param ecSqlReader ECSqlReader isntance from itwin 3.x or 4.x version
32
+ * @internal
33
+ */
34
+ function ensureECSqlReaderIsAsyncIterableIterator(ecSqlReader) {
35
+ if (Symbol.asyncIterator in ecSqlReader) { // using itwin 4.x
36
+ return ecSqlReader;
37
+ }
38
+ else { // using itwin 3.x
39
+ return new ECSqlReaderAsyncIterableIteratorAdapter(ecSqlReader);
40
+ }
41
+ }
42
+ exports.ensureECSqlReaderIsAsyncIterableIterator = ensureECSqlReaderIsAsyncIterableIterator;
43
+ //# sourceMappingURL=ECSqlReaderAsyncIterableIteratorAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ECSqlReaderAsyncIterableIteratorAdapter.js","sourceRoot":"","sources":["../../src/ECSqlReaderAsyncIterableIteratorAdapter.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAI/F;;;;GAIG;AACH,MAAa,uCAAuC;IAElD,YAA2B,YAAyB;QAAzB,iBAAY,GAAZ,YAAY,CAAa;IAAI,CAAC;IAElD,CAAC,MAAM,CAAC,aAAa,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,IAAI;QACf,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC;QAC/C,OAAO;YACL,IAAI;YACJ,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,OAAO;SACjC,CAAC;IACJ,CAAC;CACF;AAfD,0FAeC;AAED;;;;GAIG;AACH,SAAgB,wCAAwC,CAAC,WAA+H;IACtL,IAAI,MAAM,CAAC,aAAa,IAAI,WAAW,EAAE,EAAE,kBAAkB;QAC3D,OAAO,WAAW,CAAC;KACpB;SAAM,EAAE,kBAAkB;QACzB,OAAO,IAAI,uCAAuC,CAAC,WAA0B,CAAC,CAAC;KAChF;AACH,CAAC;AAND,4FAMC","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 { ECSqlReader, QueryRowProxy } from \"@itwin/core-common\";\n\n/**\n * Adapter class for ECSqlReader for AsyncIterableIterator interface.\n * It allows to iterate through query results in itwin 3.x using for await() syntax like using itwin 4.x version.\n * @internal\n */\nexport class ECSqlReaderAsyncIterableIteratorAdapter implements AsyncIterableIterator<QueryRowProxy> {\n\n public constructor(private _ecSqlReader: ECSqlReader) { }\n\n public [Symbol.asyncIterator](): AsyncIterableIterator<QueryRowProxy> {\n return this;\n }\n\n public async next(): Promise<IteratorResult<QueryRowProxy, any>> {\n const done = !(await this._ecSqlReader.step());\n return {\n done,\n value: this._ecSqlReader.current,\n };\n }\n}\n\n/**\n * Wraps ECSqlReader with ECSqlReaderAsyncIterableIteratorAdapter if it's needed.\n * @param ecSqlReader ECSqlReader isntance from itwin 3.x or 4.x version\n * @internal\n */\nexport function ensureECSqlReaderIsAsyncIterableIterator(ecSqlReader: ECSqlReader & AsyncIterableIterator<QueryRowProxy> | Omit<ECSqlReader, keyof AsyncIterableIterator<QueryRowProxy>>): AsyncIterableIterator<QueryRowProxy> {\n if (Symbol.asyncIterator in ecSqlReader) { // using itwin 4.x\n return ecSqlReader;\n } else { // using itwin 3.x\n return new ECSqlReaderAsyncIterableIteratorAdapter(ecSqlReader as ECSqlReader);\n }\n}\n"]}
@@ -0,0 +1,35 @@
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): boolean;
10
+ onExportElementUniqueAspect(uniqueAspect: ElementUniqueAspect, isUpdate?: boolean | undefined): void;
11
+ onExportElementMultiAspects(multiAspects: ElementMultiAspect[]): 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): boolean;
31
+ setAspectChanges(aspectChanges?: ChangedInstanceOps): void;
32
+ loadExcludedElementAspectClasses(excludedElementAspectClassFullNames: string[]): void;
33
+ excludeElementAspectClass(classFullName: string): void;
34
+ }
35
+ //# sourceMappingURL=ExportElementAspectsStrategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExportElementAspectsStrategy.d.ts","sourceRoot":"","sources":["../../src/ExportElementAspectsStrategy.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACvG,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;IAC1D,2BAA2B,CAAC,YAAY,EAAE,mBAAmB,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,CAAC;IACrG,2BAA2B,CAAC,YAAY,EAAE,kBAAkB,EAAE,GAAG,IAAI,CAAC;IACtE,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,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;aACrE,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC;IAExD,SAAS,CAAC,yBAAyB,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO;IAW5D,gBAAgB,CAAC,aAAa,CAAC,EAAE,kBAAkB;IAInD,gCAAgC,CAAC,mCAAmC,EAAE,MAAM,EAAE,GAAG,IAAI;IAKrF,yBAAyB,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI;CAI9D"}
@@ -0,0 +1,48 @@
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
+ constructor(sourceDb, handler) {
18
+ /** The set of classes of ElementAspects that will be excluded (polymorphically) from transformation to the target iModel. */
19
+ this._excludedElementAspectClasses = new Set();
20
+ /** The set of classFullNames for ElementAspects that will be excluded from transformation to the target iModel. */
21
+ this.excludedElementAspectClassFullNames = new Set();
22
+ this.sourceDb = sourceDb;
23
+ this.handler = handler;
24
+ }
25
+ shouldExportElementAspect(aspect) {
26
+ for (const excludedElementAspectClass of this._excludedElementAspectClasses) {
27
+ if (aspect instanceof excludedElementAspectClass) {
28
+ core_bentley_1.Logger.logInfo(loggerCategory, `Excluded ElementAspect by class: ${aspect.classFullName}`);
29
+ return false;
30
+ }
31
+ }
32
+ // ElementAspect has passed standard exclusion rules, now give handler a chance to accept/reject
33
+ return this.handler.shouldExportElementAspect(aspect);
34
+ }
35
+ setAspectChanges(aspectChanges) {
36
+ this.aspectChanges = aspectChanges;
37
+ }
38
+ loadExcludedElementAspectClasses(excludedElementAspectClassFullNames) {
39
+ this.excludedElementAspectClassFullNames = new Set(excludedElementAspectClassFullNames);
40
+ this._excludedElementAspectClasses = new Set(excludedElementAspectClassFullNames.map((c) => this.sourceDb.getJsClass(c)));
41
+ }
42
+ excludeElementAspectClass(classFullName) {
43
+ this.excludedElementAspectClassFullNames.add(classFullName); // allows non-polymorphic exclusion before query
44
+ this._excludedElementAspectClasses.add(this.sourceDb.getJsClass(classFullName)); // allows polymorphic exclusion after query/load
45
+ }
46
+ }
47
+ exports.ExportElementAspectsStrategy = ExportElementAspectsStrategy;
48
+ //# sourceMappingURL=ExportElementAspectsStrategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExportElementAspectsStrategy.js","sourceRoot":"","sources":["../../src/ExportElementAspectsStrategy.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAG/F,sDAAyD;AACzD,2EAAwE;AAGxE,MAAM,cAAc,GAAG,qDAAyB,CAAC,cAAc,CAAC;AAahE;;;;GAIG;AACH,MAAsB,4BAA4B;IAYhD,YAAmB,QAAkB,EAAE,OAA8B;QAXrE,6HAA6H;QACnH,kCAA6B,GAAG,IAAI,GAAG,EAAwB,CAAC;QAC1E,mHAAmH;QACnG,wCAAmC,GAAG,IAAI,GAAG,EAAU,CAAC;QAStE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAKS,yBAAyB,CAAC,MAAqB;QACvD,KAAK,MAAM,0BAA0B,IAAI,IAAI,CAAC,6BAA6B,EAAE;YAC3E,IAAI,MAAM,YAAY,0BAA0B,EAAE;gBAChD,qBAAM,CAAC,OAAO,CAAC,cAAc,EAAE,oCAAoC,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC;gBAC3F,OAAO,KAAK,CAAC;aACd;SACF;QACD,gGAAgG;QAChG,OAAO,IAAI,CAAC,OAAO,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC;IACxD,CAAC;IAEM,gBAAgB,CAAC,aAAkC;QACxD,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IAEM,gCAAgC,CAAC,mCAA6C;QAClF,IAAI,CAAC,mCAA2C,GAAG,IAAI,GAAG,CAAC,mCAAmC,CAAC,CAAC;QACjG,IAAI,CAAC,6BAA6B,GAAG,IAAI,GAAG,CAAC,mCAAmC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5H,CAAC;IAEM,yBAAyB,CAAC,aAAqB;QACpD,IAAI,CAAC,mCAAmC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,gDAAgD;QAC7G,IAAI,CAAC,6BAA6B,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAuB,aAAa,CAAC,CAAC,CAAC,CAAC,gDAAgD;IACzJ,CAAC;CACF;AA5CD,oEA4CC","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 { ElementAspect, ElementMultiAspect, ElementUniqueAspect, IModelDb } 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): boolean;\n onExportElementUniqueAspect(uniqueAspect: ElementUniqueAspect, isUpdate?: boolean | undefined): void;\n onExportElementMultiAspects(multiAspects: ElementMultiAspect[]): 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(_elementId: Id64String): Promise<void>;\n public abstract exportAllElementAspects(): Promise<void>;\n\n protected shouldExportElementAspect(aspect: ElementAspect): boolean {\n for (const excludedElementAspectClass of this._excludedElementAspectClasses) {\n if (aspect instanceof excludedElementAspectClass) {\n Logger.logInfo(loggerCategory, `Excluded ElementAspect by class: ${aspect.classFullName}`);\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(excludedElementAspectClassFullNames: string[]): void {\n (this.excludedElementAspectClassFullNames as any) = new Set(excludedElementAspectClassFullNames);\n this._excludedElementAspectClasses = new Set(excludedElementAspectClassFullNames.map((c) => this.sourceDb.getJsClass(c)));\n }\n\n public excludeElementAspectClass(classFullName: string): void {\n this.excludedElementAspectClassFullNames.add(classFullName); // allows non-polymorphic exclusion before query\n this._excludedElementAspectClasses.add(this.sourceDb.getJsClass<typeof ElementAspect>(classFullName)); // allows polymorphic exclusion after query/load\n }\n}\n"]}
@@ -0,0 +1,12 @@
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
@@ -0,0 +1 @@
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,CAAC,SAAS,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAyBpE,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC;CAG/D"}
@@ -0,0 +1,43 @@
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 _uniqueAspects = await Promise.all(this.sourceDb.elements
18
+ ._queryAspects(elementId, core_backend_1.ElementUniqueAspect.classFullName, this.excludedElementAspectClassFullNames)
19
+ .filter((a) => this.shouldExportElementAspect(a))
20
+ .map(async (uniqueAspect) => {
21
+ const isInsertChange = this.aspectChanges?.insertIds.has(uniqueAspect.id) ?? false;
22
+ const isUpdateChange = this.aspectChanges?.updateIds.has(uniqueAspect.id) ?? false;
23
+ const doExport = this.aspectChanges === undefined || isInsertChange || isUpdateChange;
24
+ if (doExport) {
25
+ const isKnownUpdate = this.aspectChanges ? isUpdateChange : undefined;
26
+ this.handler.onExportElementUniqueAspect(uniqueAspect, isKnownUpdate);
27
+ await this.handler.trackProgress();
28
+ }
29
+ }));
30
+ const multiAspects = this.sourceDb.elements
31
+ ._queryAspects(elementId, core_backend_1.ElementMultiAspect.classFullName, this.excludedElementAspectClassFullNames)
32
+ .filter((a) => this.shouldExportElementAspect(a));
33
+ if (multiAspects.length > 0) {
34
+ this.handler.onExportElementMultiAspects(multiAspects);
35
+ return this.handler.trackProgress();
36
+ }
37
+ }
38
+ async exportAllElementAspects() {
39
+ // All aspects are exported with their owning elements and don't need to be exported separately.
40
+ }
41
+ }
42
+ exports.ExportElementAspectsWithElementsStrategy = ExportElementAspectsWithElementsStrategy;
43
+ //# sourceMappingURL=ExportElementAspectsWithElementsStrategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExportElementAspectsWithElementsStrategy.js","sourceRoot":"","sources":["../../src/ExportElementAspectsWithElementsStrategy.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sDAA8E;AAE9E,iFAA8E;AAE9E;;;;GAIG;AACH,MAAa,wCAAyC,SAAQ,2DAA4B;IACxE,KAAK,CAAC,8BAA8B,CAAC,SAAqB;QACxE,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ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CAAC;SACrC;IACH,CAAC;IAEe,KAAK,CAAC,uBAAuB;QAC3C,gGAAgG;IAClG,CAAC;CACF;AA7BD,4FA6BC","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(elementId: Id64String): Promise<void> {\n const _uniqueAspects = await Promise.all(this.sourceDb.elements\n ._queryAspects(elementId, ElementUniqueAspect.classFullName, this.excludedElementAspectClassFullNames)\n .filter((a) => this.shouldExportElementAspect(a))\n .map(async (uniqueAspect: ElementUniqueAspect) => {\n const isInsertChange = this.aspectChanges?.insertIds.has(uniqueAspect.id) ?? false;\n const isUpdateChange = this.aspectChanges?.updateIds.has(uniqueAspect.id) ?? false;\n const doExport = this.aspectChanges === undefined || isInsertChange || isUpdateChange;\n if (doExport) {\n const isKnownUpdate = this.aspectChanges ? isUpdateChange : undefined;\n this.handler.onExportElementUniqueAspect(uniqueAspect, isKnownUpdate);\n await this.handler.trackProgress();\n }\n }));\n\n const multiAspects = this.sourceDb.elements\n ._queryAspects(elementId, ElementMultiAspect.classFullName, this.excludedElementAspectClassFullNames)\n .filter((a) => this.shouldExportElementAspect(a));\n\n if (multiAspects.length > 0) {\n 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"]}
@@ -6,6 +6,7 @@ import { AccessToken, CompressedId64Set, Id64String } from "@itwin/core-bentley"
6
6
  import { ChangesetIndexOrId, CodeSpec, FontProps } from "@itwin/core-common";
7
7
  import { Schema, SchemaKey } from "@itwin/ecschema-metadata";
8
8
  import type { InitFromExternalSourceAspectsArgs } from "./IModelTransformer";
9
+ import { ElementAspectsHandler, ExportElementAspectsStrategy } from "./ExportElementAspectsStrategy";
9
10
  /**
10
11
  * @beta
11
12
  * The (optional) result of [[IModelExportHandler.onExportSchema]]
@@ -177,17 +178,15 @@ export declare class IModelExporter {
177
178
  private _excludedElementCategoryIds;
178
179
  /** The set of classes of Elements that will be excluded (polymorphically) from transformation to the target iModel. */
179
180
  private _excludedElementClasses;
180
- /** The set of classes of ElementAspects that will be excluded (polymorphically) from transformation to the target iModel. */
181
- private _excludedElementAspectClasses;
182
- /** The set of classFullNames for ElementAspects that will be excluded from transformation to the target iModel. */
183
- private _excludedElementAspectClassFullNames;
184
181
  /** The set of classes of Relationships that will be excluded (polymorphically) from transformation to the target iModel. */
185
182
  private _excludedRelationshipClasses;
183
+ /** Strategy for how ElementAspects are exported */
184
+ private _exportElementAspectsStrategy;
186
185
  /** Construct a new IModelExporter
187
186
  * @param sourceDb The source IModelDb
188
187
  * @see registerHandler
189
188
  */
190
- constructor(sourceDb: IModelDb);
189
+ constructor(sourceDb: IModelDb, elementAspectsStrategy?: new (source: IModelDb, handler: ElementAspectsHandler) => ExportElementAspectsStrategy);
191
190
  /** Register the handler that will be called by IModelExporter. */
192
191
  registerHandler(handler: IModelExportHandler): void;
193
192
  /** Add a rule to exclude a CodeSpec */
@@ -273,10 +272,9 @@ export declare class IModelExporter {
273
272
  * @note This method is called from [[exportChanges]] and [[exportAll]], so it only needs to be called directly when exporting a subset of an iModel.
274
273
  */
275
274
  exportChildElements(elementId: Id64String): Promise<void>;
276
- /** Returns `true` if the specified ElementAspect should be exported or `false` if if should be excluded. */
277
- private shouldExportElementAspect;
278
- /** Export ElementAspects from the specified element from the source iModel. */
279
- private exportElementAspects;
275
+ /** Exports all aspects present in the iModel.
276
+ */
277
+ private exportAllAspects;
280
278
  /** Exports all relationships that subclass from the specified base class.
281
279
  * @note This method is called from [[exportChanges]] and [[exportAll]], so it only needs to be called directly when exporting a subset of an iModel.
282
280
  */
@@ -1 +1 @@
1
- {"version":3,"file":"IModelExporter.d.ts","sourceRoot":"","sources":["../../src/IModelExporter.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EACL,WAAW,EAAqD,OAAO,EAAE,aAAa,EACtF,kBAAkB,EAA2B,mBAAmB,EAAoB,QAAQ,EAChF,cAAc,EAAE,KAAK,EAA2B,YAAY,EACzE,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAU,iBAAiB,EAAkB,UAAU,EAAsC,MAAM,qBAAqB,CAAC;AAC7I,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,SAAS,EAAuB,MAAM,oBAAoB,CAAC;AAClG,OAAO,EAAa,MAAM,EAAE,SAAS,EAAgB,MAAM,0BAA0B,CAAC;AAEtF,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,qBAAqB,CAAC;AAI7E;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,uFAAuF;IACvF,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAqB,SAAQ,iCAAiC;IAC7E;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC;AAED;;;;;GAKG;AACH,8BAAsB,mBAAmB;IACvC;;OAEG;IACI,oBAAoB,CAAC,SAAS,EAAE,QAAQ,GAAG,OAAO;IAEzD;;;;OAIG;IACI,gBAAgB,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI;IAElF;;;;OAIG;IACI,YAAY,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI;IAE3E;;;;OAIG;IACI,aAAa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cAAyB;IAClC,SAAS,cAAyB;IAEzC,0EAA0E;IACnE,WAAW,CAAC,GAAG,EAAE,cAAc,CAAC,uBAAuB,GAAG,SAAS,GAAG,IAAI;CAYlF;AAED;;;GAGG;AACH,qBAAa,kBAAkB;IACtB,QAAQ,qBAA4B;IACpC,KAAK,qBAA4B;IACjC,OAAO,qBAA4B;IACnC,MAAM,qBAA4B;IAClC,YAAY,qBAA4B;IACxC,IAAI,qBAA4B;IACvC,OAAO;IAEP;;OAEG;WACiB,UAAU,CAAC,IAAI,EAAE,6BAA6B,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAgDjG"}
@@ -13,6 +13,7 @@ const core_bentley_1 = require("@itwin/core-bentley");
13
13
  const core_common_1 = require("@itwin/core-common");
14
14
  const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
15
15
  const TransformerLoggerCategory_1 = require("./TransformerLoggerCategory");
16
+ const ExportElementAspectsWithElementsStrategy_1 = require("./ExportElementAspectsWithElementsStrategy");
16
17
  const loggerCategory = TransformerLoggerCategory_1.TransformerLoggerCategory.IModelExporter;
17
18
  /** Handles the events generated by IModelExporter.
18
19
  * @note Change information is available when `IModelExportHandler` methods are invoked via [IModelExporter.exportChanges]($transformer), but not available when invoked via [IModelExporter.exportAll]($transformer).
@@ -134,7 +135,7 @@ class IModelExporter {
134
135
  * @param sourceDb The source IModelDb
135
136
  * @see registerHandler
136
137
  */
137
- constructor(sourceDb) {
138
+ constructor(sourceDb, elementAspectsStrategy = ExportElementAspectsWithElementsStrategy_1.ExportElementAspectsWithElementsStrategy) {
138
139
  /** A flag that indicates whether element GeometryStreams are loaded or not.
139
140
  * @note As an optimization, exporters that don't need geometry can set this flag to `false`. The default is `true`.
140
141
  * @note The transformer by default sets this to `false` as an optimization.
@@ -172,14 +173,16 @@ class IModelExporter {
172
173
  this._excludedElementCategoryIds = new Set();
173
174
  /** The set of classes of Elements that will be excluded (polymorphically) from transformation to the target iModel. */
174
175
  this._excludedElementClasses = new Set();
175
- /** The set of classes of ElementAspects that will be excluded (polymorphically) from transformation to the target iModel. */
176
- this._excludedElementAspectClasses = new Set();
177
- /** The set of classFullNames for ElementAspects that will be excluded from transformation to the target iModel. */
178
- this._excludedElementAspectClassFullNames = new Set();
179
176
  /** The set of classes of Relationships that will be excluded (polymorphically) from transformation to the target iModel. */
180
177
  this._excludedRelationshipClasses = new Set();
181
178
  this._yieldManager = new core_bentley_1.YieldManager();
182
179
  this.sourceDb = sourceDb;
180
+ this._exportElementAspectsStrategy = new elementAspectsStrategy(this.sourceDb, {
181
+ onExportElementMultiAspects: (aspects) => this.handler.onExportElementMultiAspects(aspects),
182
+ onExportElementUniqueAspect: (aspect, isUpdate) => this.handler.onExportElementUniqueAspect(aspect, isUpdate),
183
+ shouldExportElementAspect: (aspect) => this.handler.shouldExportElementAspect(aspect),
184
+ trackProgress: async () => this.trackProgress(),
185
+ });
183
186
  }
184
187
  /** Register the handler that will be called by IModelExporter. */
185
188
  registerHandler(handler) {
@@ -203,8 +206,7 @@ class IModelExporter {
203
206
  }
204
207
  /** Add a rule to exclude all ElementAspects of a specified class. */
205
208
  excludeElementAspectClass(classFullName) {
206
- this._excludedElementAspectClassFullNames.add(classFullName); // allows non-polymorphic exclusion before query
207
- this._excludedElementAspectClasses.add(this.sourceDb.getJsClass(classFullName)); // allows polymorphic exclusion after query/load
209
+ this._exportElementAspectsStrategy.excludeElementAspectClass(classFullName);
208
210
  }
209
211
  /** Add a rule to exclude all Relationships of a specified class. */
210
212
  excludeRelationshipClass(classFullName) {
@@ -243,6 +245,7 @@ class IModelExporter {
243
245
  : this.sourceDb.changeset,
244
246
  iModel: this.sourceDb,
245
247
  });
248
+ this._exportElementAspectsStrategy.setAspectChanges(this._sourceDbChanges?.aspect);
246
249
  await this.exportCodeSpecs();
247
250
  await this.exportFonts();
248
251
  await this.exportModelContents(core_common_1.IModel.repositoryModelId);
@@ -570,7 +573,7 @@ class IModelExporter {
570
573
  await this.handler.preExportElement(element);
571
574
  this.handler.onExportElement(element, isUpdate);
572
575
  await this.trackProgress();
573
- await this.exportElementAspects(elementId);
576
+ await this._exportElementAspectsStrategy.exportElementAspectsForElement(elementId);
574
577
  return this.exportChildElements(elementId);
575
578
  }
576
579
  else {
@@ -593,39 +596,10 @@ class IModelExporter {
593
596
  }
594
597
  }
595
598
  }
596
- /** Returns `true` if the specified ElementAspect should be exported or `false` if if should be excluded. */
597
- shouldExportElementAspect(aspect) {
598
- for (const excludedElementAspectClass of this._excludedElementAspectClasses) {
599
- if (aspect instanceof excludedElementAspectClass) {
600
- core_bentley_1.Logger.logInfo(loggerCategory, `Excluded ElementAspect by class: ${aspect.classFullName}`);
601
- return false;
602
- }
603
- }
604
- // ElementAspect has passed standard exclusion rules, now give handler a chance to accept/reject
605
- return this.handler.shouldExportElementAspect(aspect);
606
- }
607
- /** Export ElementAspects from the specified element from the source iModel. */
608
- async exportElementAspects(elementId) {
609
- const _uniqueAspects = await Promise.all(this.sourceDb.elements
610
- ._queryAspects(elementId, core_backend_1.ElementUniqueAspect.classFullName, this._excludedElementAspectClassFullNames)
611
- .filter((a) => this.shouldExportElementAspect(a))
612
- .map(async (uniqueAspect) => {
613
- const isInsertChange = this._sourceDbChanges?.aspect.insertIds.has(uniqueAspect.id) ?? false;
614
- const isUpdateChange = this._sourceDbChanges?.aspect.updateIds.has(uniqueAspect.id) ?? false;
615
- const doExport = this._sourceDbChanges === undefined || isInsertChange || isUpdateChange;
616
- if (doExport) {
617
- const isKnownUpdate = this._sourceDbChanges ? isUpdateChange : undefined;
618
- this.handler.onExportElementUniqueAspect(uniqueAspect, isKnownUpdate);
619
- await this.trackProgress();
620
- }
621
- }));
622
- const multiAspects = this.sourceDb.elements
623
- ._queryAspects(elementId, core_backend_1.ElementMultiAspect.classFullName, this._excludedElementAspectClassFullNames)
624
- .filter((a) => this.shouldExportElementAspect(a));
625
- if (multiAspects.length > 0) {
626
- this.handler.onExportElementMultiAspects(multiAspects);
627
- return this.trackProgress();
628
- }
599
+ /** Exports all aspects present in the iModel.
600
+ */
601
+ async exportAllAspects() {
602
+ return this._exportElementAspectsStrategy.exportAllElementAspects();
629
603
  }
630
604
  /** Exports all relationships that subclass from the specified base class.
631
605
  * @note This method is called from [[exportChanges]] and [[exportAll]], so it only needs to be called directly when exporting a subset of an iModel.
@@ -719,8 +693,7 @@ class IModelExporter {
719
693
  this._excludedElementIds = core_bentley_1.CompressedId64Set.decompressSet(state.excludedElementIds),
720
694
  this._excludedElementCategoryIds = core_bentley_1.CompressedId64Set.decompressSet(state.excludedElementCategoryIds),
721
695
  this._excludedElementClasses = new Set(state.excludedElementClassNames.map((c) => this.sourceDb.getJsClass(c)));
722
- this._excludedElementAspectClassFullNames = new Set(state.excludedElementAspectClassFullNames);
723
- this._excludedElementAspectClasses = new Set(state.excludedElementAspectClassFullNames.map((c) => this.sourceDb.getJsClass(c)));
696
+ this._exportElementAspectsStrategy.loadExcludedElementAspectClasses(state.excludedElementAspectClassFullNames);
724
697
  this._excludedRelationshipClasses = new Set(state.excludedRelationshipClassNames.map((c) => this.sourceDb.getJsClass(c)));
725
698
  this.loadAdditionalStateJson(state.additionalState);
726
699
  }
@@ -742,7 +715,7 @@ class IModelExporter {
742
715
  excludedElementIds: core_bentley_1.CompressedId64Set.compressSet(this._excludedElementIds),
743
716
  excludedElementCategoryIds: core_bentley_1.CompressedId64Set.compressSet(this._excludedElementCategoryIds),
744
717
  excludedElementClassNames: Array.from(this._excludedElementClasses, (cls) => cls.classFullName),
745
- excludedElementAspectClassFullNames: [...this._excludedElementAspectClassFullNames],
718
+ excludedElementAspectClassFullNames: [...this._exportElementAspectsStrategy.excludedElementAspectClassFullNames],
746
719
  excludedRelationshipClassNames: Array.from(this._excludedRelationshipClasses, (cls) => cls.classFullName),
747
720
  additionalState: this.getAdditionalStateJson(),
748
721
  };