@itwin/imodel-transformer 0.3.18-fedguidopt.7 → 0.4.1-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.
Files changed (37) hide show
  1. package/CHANGELOG.md +26 -1
  2. package/lib/cjs/BranchProvenanceInitializer.d.ts +3 -10
  3. package/lib/cjs/BranchProvenanceInitializer.d.ts.map +1 -1
  4. package/lib/cjs/BranchProvenanceInitializer.js +13 -84
  5. package/lib/cjs/BranchProvenanceInitializer.js.map +1 -1
  6. package/lib/cjs/DetachedExportElementAspectsStrategy.d.ts +16 -0
  7. package/lib/cjs/DetachedExportElementAspectsStrategy.d.ts.map +1 -0
  8. package/lib/cjs/DetachedExportElementAspectsStrategy.js +98 -0
  9. package/lib/cjs/DetachedExportElementAspectsStrategy.js.map +1 -0
  10. package/lib/cjs/ECSqlReaderAsyncIterableIteratorAdapter.d.ts +19 -0
  11. package/lib/cjs/ECSqlReaderAsyncIterableIteratorAdapter.d.ts.map +1 -0
  12. package/lib/cjs/ECSqlReaderAsyncIterableIteratorAdapter.js +43 -0
  13. package/lib/cjs/ECSqlReaderAsyncIterableIteratorAdapter.js.map +1 -0
  14. package/lib/cjs/ExportElementAspectsStrategy.d.ts +35 -0
  15. package/lib/cjs/ExportElementAspectsStrategy.d.ts.map +1 -0
  16. package/lib/cjs/ExportElementAspectsStrategy.js +48 -0
  17. package/lib/cjs/ExportElementAspectsStrategy.js.map +1 -0
  18. package/lib/cjs/ExportElementAspectsWithElementsStrategy.d.ts +12 -0
  19. package/lib/cjs/ExportElementAspectsWithElementsStrategy.d.ts.map +1 -0
  20. package/lib/cjs/ExportElementAspectsWithElementsStrategy.js +43 -0
  21. package/lib/cjs/ExportElementAspectsWithElementsStrategy.js.map +1 -0
  22. package/lib/cjs/IModelCloneContext.d.ts.map +1 -1
  23. package/lib/cjs/IModelCloneContext.js +2 -0
  24. package/lib/cjs/IModelCloneContext.js.map +1 -1
  25. package/lib/cjs/IModelExporter.d.ts +15 -40
  26. package/lib/cjs/IModelExporter.d.ts.map +1 -1
  27. package/lib/cjs/IModelExporter.js +52 -125
  28. package/lib/cjs/IModelExporter.js.map +1 -1
  29. package/lib/cjs/IModelTransformer.d.ts +29 -161
  30. package/lib/cjs/IModelTransformer.d.ts.map +1 -1
  31. package/lib/cjs/IModelTransformer.js +286 -934
  32. package/lib/cjs/IModelTransformer.js.map +1 -1
  33. package/package.json +14 -14
  34. package/lib/cjs/Algo.d.ts +0 -7
  35. package/lib/cjs/Algo.d.ts.map +0 -1
  36. package/lib/cjs/Algo.js +0 -50
  37. package/lib/cjs/Algo.js.map +0 -1
@@ -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;aAC5D,aAAa,CAAC,SAAS,EAAE,kCAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,mCAAmC,CAAC;aACrG,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC;aAChD,GAAG,CAAC,KAAK,EAAE,YAAiC,EAAE,EAAE;YAC/C,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,SAAS,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC,IAAI,KAAK,CAAC;YACnF,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,KAAK,SAAS,IAAI,cAAc,IAAI,cAAc,CAAC;YACtF,IAAI,QAAQ,EAAE;gBACZ,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC;gBACtE,IAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;gBACtE,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;aACpC;QACH,CAAC,CAAC,CAAC,CAAC;QAEN,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ;aACxC,aAAa,CAAC,SAAS,EAAE,iCAAkB,CAAC,aAAa,EAAE,IAAI,CAAC,mCAAmC,CAAC;aACpG,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,CAAC;QAEpD,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;YAC3B,IAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,YAAY,CAAC,CAAC;YACvD,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"IModelCloneContext.d.ts","sourceRoot":"","sources":["../../src/IModelCloneContext.ts"],"names":[],"mappings":"AAQA,OAAO,EAAkB,UAAU,EAAU,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAGgB,kBAAkB,EAAE,YAAY,EAAE,eAAe,EAEvE,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,OAAO,EAAE,aAAa,EAAoB,yBAAyB,EAAE,cAAc,EAAE,QAAQ,EAC9F,MAAM,qBAAqB,CAAC;AAO7B;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,yBAAyB;IAE/D,OAAO,CAAC,cAAc,CAA+B;IACrD,OAAO,CAAC,iBAAiB,CAAqC;IAE9D,0HAA0H;IACpG,UAAU;IAIhC;;OAEG;IACa,YAAY,CAAC,aAAa,EAAE,OAA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I;IAIvF,mEAAmE;IAC5D,mBAAmB,CAAC,cAAc,EAAE,UAAU,GAAG,IAAI;IAI5D;;OAEG;IACI,kBAAkB,CAAC,cAAc,EAAE,UAAU,GAAG,UAAU;IAIjE;;OAEG;IACI,kBAAkB,CAAC,cAAc,EAAE,eAAe,GAAG,eAAe;IA+F3E;;OAEG;IACI,kBAAkB,CAAC,mBAAmB,EAAE,aAAa,GAAG,kBAAkB;IAyBjF,OAAO,CAAC,MAAM,CAAC,oBAAoB,CAAoB;IAEvC,aAAa,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI;IAoBjC,eAAe,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI;CAapD"}
@@ -33,6 +33,7 @@ class IModelCloneContext extends core_backend_1.IModelElementCloneContext {
33
33
  * @internal
34
34
  */
35
35
  cloneElement(sourceElement, cloneOptions) {
36
+ // eslint-disable-next-line @typescript-eslint/dot-notation
36
37
  const targetElementProps = this["_nativeContext"].cloneElement(sourceElement.id, cloneOptions);
37
38
  // Ensure that all NavigationProperties in targetElementProps have a defined value so "clearing" changes will be part of the JSON used for update
38
39
  sourceElement.forEachProperty((propertyName, meta) => {
@@ -54,6 +55,7 @@ class IModelCloneContext extends core_backend_1.IModelElementCloneContext {
54
55
  targetElementProps.code = core_common_1.Code.createEmpty();
55
56
  }
56
57
  const jsClass = this.sourceDb.getJsClass(sourceElement.classFullName);
58
+ // eslint-disable-next-line @typescript-eslint/dot-notation
57
59
  jsClass["onCloned"](this, sourceElement.toJSON(), targetElementProps);
58
60
  return targetElementProps;
59
61
  }
@@ -1 +1 @@
1
- {"version":3,"file":"IModelCloneContext.js","sourceRoot":"","sources":["../../src/IModelCloneContext.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,iCAAiC;AACjC,sDAAyE;AACzE,oDAK4B;AAC5B,sDAE6B;AAC7B,mEAAgE;AAChE,mDAAgD;AAChD,2EAAwE;AAExE,MAAM,cAAc,GAAW,qDAAyB,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,IAAI,uBAAQ,CAAC,cAAc,KAAK,IAAI,CAAC,IAAI,EAAE;oBACzC,MAAM,KAAK,CAAC,2DAA2D,CAAC,CAAC;aAC5E;QACH,CAAC,CAAC,CAAC;IACP,CAAC;IAEe,eAAe,CAAC,EAAY;QAC1C,KAAK,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;QAC1B,mBAAmB;QACnB,EAAE,CAAC,mBAAmB,CAAC,8BAA8B,kBAAkB,CAAC,oBAAoB,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE;YACvG,IAAI,MAAM,GAAG,uBAAQ,CAAC,eAAe,CAAC;YACtC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,uBAAQ,CAAC,aAAa,EAAE;gBACxD,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;gBACxC,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;gBACxC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;aAC5C;YACD,MAAM,CAAC,MAAM,KAAK,uBAAQ,CAAC,cAAc,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;IACL,CAAC;;AAxNH,gDAyNC;AAnCgB,uCAAoB,GAAG,gBAAgB,AAAnB,CAAoB","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 iModels\n */\nimport * as assert from \"assert\";\nimport { DbResult, Id64, Id64String, Logger } from \"@itwin/core-bentley\";\nimport {\n Code,\n CodeScopeSpec,\n ConcreteEntityTypes, ElementAspectProps, ElementProps, EntityReference, IModel, IModelError,\n PrimitiveTypeCode, PropertyMetaData, RelatedElement, RelatedElementProps,\n} from \"@itwin/core-common\";\nimport {\n Element, ElementAspect, EntityReferences, IModelElementCloneContext, IModelJsNative, SQLiteDb,\n} from \"@itwin/core-backend\";\nimport { ECReferenceTypesCache } from \"./ECReferenceTypesCache\";\nimport { EntityUnifier } from \"./EntityUnifier\";\nimport { TransformerLoggerCategory } from \"./TransformerLoggerCategory\";\n\nconst loggerCategory: string = TransformerLoggerCategory.IModelCloneContext;\n\n/** The context for transforming a *source* Element to a *target* Element and remapping internal identifiers to the target iModel.\n * @beta\n */\nexport class IModelCloneContext extends IModelElementCloneContext {\n\n private _refTypesCache = new ECReferenceTypesCache();\n private _aspectRemapTable = new Map<Id64String, Id64String>();\n\n /** perform necessary initialization to use a clone context, namely caching the reference types in the source's schemas */\n public override async initialize() {\n await this._refTypesCache.initAllSchemasInIModel(this.sourceDb);\n }\n\n /** Clone the specified source Element into ElementProps for the target iModel.\n * @internal\n */\n public override cloneElement(sourceElement: Element, cloneOptions?: IModelJsNative.CloneElementOptions): ElementProps {\n const targetElementProps: ElementProps = this[\"_nativeContext\"].cloneElement(sourceElement.id, cloneOptions);\n // Ensure that all NavigationProperties in targetElementProps have a defined value so \"clearing\" changes will be part of the JSON used for update\n sourceElement.forEachProperty((propertyName: string, meta: PropertyMetaData) => {\n if ((meta.isNavigation) && (undefined === (sourceElement as any)[propertyName])) {\n (targetElementProps as any)[propertyName] = RelatedElement.none;\n }\n }, false); // exclude custom because C++ has already handled them\n if (this.isBetweenIModels) {\n // The native C++ cloneElement strips off federationGuid, want to put it back if transformation is between iModels\n targetElementProps.federationGuid = sourceElement.federationGuid;\n const targetElementCodeScopeType = this.targetDb.codeSpecs.getById(targetElementProps.code.spec).scopeType;\n if (CodeScopeSpec.Type.Repository === targetElementCodeScopeType && targetElementProps.code.scope !== IModel.rootSubjectId) {\n Logger.logWarning(loggerCategory, `Incorrect CodeScope '${targetElementCodeScopeType}' is set for target element ${targetElementProps.id}`);\n }\n }\n // unlike other references, code cannot be null. If it is null, use an empty code instead\n // this will be updated back later as the transformer resolves references\n if (targetElementProps.code.scope === Id64.invalid || targetElementProps.code.spec === Id64.invalid) {\n targetElementProps.code = Code.createEmpty();\n }\n const jsClass = this.sourceDb.getJsClass<typeof Element>(sourceElement.classFullName);\n jsClass[\"onCloned\"](this, sourceElement.toJSON(), targetElementProps);\n return targetElementProps;\n }\n\n /** Add a rule that remaps the specified source ElementAspect to the specified target ElementAspect. */\n public remapElementAspect(aspectSourceId: Id64String, aspectTargetId: Id64String): void {\n this._aspectRemapTable.set(aspectSourceId, aspectTargetId);\n }\n\n /** Remove a rule that remaps the specified source ElementAspect */\n public removeElementAspect(aspectSourceId: Id64String): void {\n this._aspectRemapTable.delete(aspectSourceId);\n }\n\n /** Look up a target AspectId from the source AspectId.\n * @returns the target AspectId or [Id64.invalid]($bentley) if a mapping not found.\n */\n public findTargetAspectId(sourceAspectId: Id64String): Id64String {\n return this._aspectRemapTable.get(sourceAspectId) ?? Id64.invalid;\n }\n\n /** Look up a target [EntityReference]($bentley) from a source [EntityReference]($bentley)\n * @returns the target CodeSpecId or a [EntityReference]($bentley) containing [Id64.invalid]($bentley) if a mapping is not found.\n */\n public findTargetEntityId(sourceEntityId: EntityReference): EntityReference {\n const [type, rawId] = EntityReferences.split(sourceEntityId);\n if (Id64.isValid(rawId)) {\n switch (type) {\n case ConcreteEntityTypes.Model: {\n const targetId = `m${this.findTargetElementId(rawId)}` as const;\n // Check if the model exists, `findTargetElementId` may have worked because the element exists when the model doesn't.\n // That can occur in the transformer since a submodeled element is imported before its submodel.\n if (EntityUnifier.exists(this.targetDb, { entityReference: targetId }))\n return targetId;\n break;\n }\n case ConcreteEntityTypes.Element:\n return `e${this.findTargetElementId(rawId)}`;\n case ConcreteEntityTypes.ElementAspect:\n return `a${this.findTargetAspectId(rawId)}`;\n case ConcreteEntityTypes.Relationship: {\n const makeGetConcreteEntityTypeSql = (property: string) => `\n CASE\n WHEN [${property}] IS (BisCore.ElementUniqueAspect) OR [${property}] IS (BisCore.ElementMultiAspect)\n THEN 'a'\n WHEN [${property}] IS (BisCore.Element)\n THEN 'e'\n WHEN [${property}] IS (BisCore.Model)\n THEN 'm'\n WHEN [${property}] IS (BisCore.CodeSpec)\n THEN 'c'\n WHEN [${property}] IS (BisCore.ElementRefersToElements) -- TODO: ElementDrivesElement still not handled by the transformer\n THEN 'r'\n ELSE 'error'\n END\n `;\n const relInSource = this.sourceDb.withPreparedStatement(\n `\n SELECT\n SourceECInstanceId,\n TargetECInstanceId,\n (${makeGetConcreteEntityTypeSql(\"SourceECClassId\")}) AS SourceType,\n (${makeGetConcreteEntityTypeSql(\"TargetECClassId\")}) AS TargetType\n FROM BisCore:ElementRefersToElements\n WHERE ECInstanceId=?\n `, (stmt) => {\n stmt.bindId(1, rawId);\n let status: DbResult;\n while ((status = stmt.step()) === DbResult.BE_SQLITE_ROW) {\n const sourceId = stmt.getValue(0).getId();\n const targetId = stmt.getValue(1).getId();\n const sourceType = stmt.getValue(2).getString() as ConcreteEntityTypes | \"error\";\n const targetType = stmt.getValue(3).getString() as ConcreteEntityTypes | \"error\";\n if (sourceType === \"error\" || targetType === \"error\")\n throw Error(\"relationship end had unknown root class\");\n return {\n sourceId: `${sourceType}${sourceId}`,\n targetId: `${targetType}${targetId}`,\n } as const;\n }\n if (status !== DbResult.BE_SQLITE_DONE)\n throw new IModelError(status, \"unexpected query failure\");\n return undefined;\n });\n if (relInSource === undefined)\n break;\n // just in case prevent recursion\n if (relInSource.sourceId === sourceEntityId || relInSource.targetId === sourceEntityId)\n throw Error(\"link table relationship end was resolved to itself. This should be impossible\");\n const relInTarget = {\n sourceId: this.findTargetEntityId(relInSource.sourceId),\n targetId: this.findTargetEntityId(relInSource.targetId),\n };\n // return a null\n if (!EntityReferences.isValid(relInTarget.sourceId) || !EntityReferences.isValid(relInTarget.targetId))\n break;\n const relInTargetId = this.targetDb.withPreparedStatement(\n `\n SELECT ECInstanceId\n FROM BisCore:ElementRefersToElements\n WHERE SourceECInstanceId=?\n AND TargetECInstanceId=?\n `, (stmt) => {\n stmt.bindId(1, EntityReferences.toId64(relInTarget.sourceId));\n stmt.bindId(2, EntityReferences.toId64(relInTarget.targetId));\n const status: DbResult = stmt.step();\n if (status === DbResult.BE_SQLITE_ROW)\n return stmt.getValue(0).getId();\n if (status !== DbResult.BE_SQLITE_DONE)\n throw new IModelError(status, \"unexpected query failure\");\n return Id64.invalid;\n });\n return `r${relInTargetId}`;\n }\n }\n }\n return `${type}${Id64.invalid}`;\n }\n\n /** Clone the specified source Element into ElementProps for the target iModel.\n * @internal\n */\n public cloneElementAspect(sourceElementAspect: ElementAspect): ElementAspectProps {\n const targetElementAspectProps: ElementAspectProps = sourceElementAspect.toJSON();\n targetElementAspectProps.id = undefined;\n sourceElementAspect.forEachProperty((propertyName, propertyMetaData) => {\n if (propertyMetaData.isNavigation) {\n const sourceNavProp: RelatedElementProps | undefined = sourceElementAspect.asAny[propertyName];\n if (sourceNavProp?.id) {\n const navPropRefType = this._refTypesCache.getNavPropRefType(\n sourceElementAspect.schemaName,\n sourceElementAspect.className,\n propertyName\n );\n assert(navPropRefType !== undefined,`nav prop ref type for '${propertyName}' was not in the cache, this is a bug.`);\n const targetEntityReference = this.findTargetEntityId(EntityReferences.fromEntityType(sourceNavProp.id, navPropRefType));\n const targetEntityId = EntityReferences.toId64(targetEntityReference);\n // spread the property in case toJSON did not deep-clone\n (targetElementAspectProps as any)[propertyName] = { ...(targetElementAspectProps as any)[propertyName], id: targetEntityId };\n }\n } else if ((PrimitiveTypeCode.Long === propertyMetaData.primitiveType) && (\"Id\" === propertyMetaData.extendedType)) {\n (targetElementAspectProps as any)[propertyName] = this.findTargetElementId(sourceElementAspect.asAny[propertyName]);\n }\n });\n return targetElementAspectProps;\n }\n\n private static aspectRemapTableName = \"AspectIdRemaps\";\n\n public override saveStateToDb(db: SQLiteDb): void {\n super.saveStateToDb(db);\n if (DbResult.BE_SQLITE_DONE !== db.executeSQL(\n `CREATE TABLE ${IModelCloneContext.aspectRemapTableName} (Source INTEGER, Target INTEGER)`\n ))\n throw Error(\"Failed to create the aspect remap table in the state database\");\n db.saveChanges();\n db.withPreparedSqliteStatement(\n `INSERT INTO ${IModelCloneContext.aspectRemapTableName} (Source, Target) VALUES (?, ?)`,\n (stmt) => {\n for (const [source, target] of this._aspectRemapTable) {\n stmt.reset();\n stmt.bindId(1, source);\n stmt.bindId(2, target);\n if (DbResult.BE_SQLITE_DONE !== stmt.step())\n throw Error(\"Failed to insert aspect remapping into the state database\");\n }\n });\n }\n\n public override loadStateFromDb(db: SQLiteDb): void {\n super.loadStateFromDb(db);\n // FIXME: test this\n db.withSqliteStatement(`SELECT Source, Target FROM ${IModelCloneContext.aspectRemapTableName}`, (stmt) => {\n let status = DbResult.BE_SQLITE_ERROR;\n while ((status = stmt.step()) === DbResult.BE_SQLITE_ROW) {\n const source = stmt.getValue(0).getId();\n const target = stmt.getValue(1).getId();\n this._aspectRemapTable.set(source, target);\n }\n assert(status === DbResult.BE_SQLITE_DONE);\n });\n }\n}\n"]}
1
+ {"version":3,"file":"IModelCloneContext.js","sourceRoot":"","sources":["../../src/IModelCloneContext.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,iCAAiC;AACjC,sDAAyE;AACzE,oDAK4B;AAC5B,sDAE6B;AAC7B,mEAAgE;AAChE,mDAAgD;AAChD,2EAAwE;AAExE,MAAM,cAAc,GAAW,qDAAyB,CAAC,kBAAkB,CAAC;AAE5E;;GAEG;AACH,MAAa,kBAAmB,SAAQ,wCAAyB;IAAjE;;QAEU,mBAAc,GAAG,IAAI,6CAAqB,EAAE,CAAC;QAC7C,sBAAiB,GAAG,IAAI,GAAG,EAA0B,CAAC;IAwNhE,CAAC;IAtNC,0HAA0H;IAC1G,KAAK,CAAC,UAAU;QAC9B,MAAM,IAAI,CAAC,cAAc,CAAC,sBAAsB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAClE,CAAC;IAED;;OAEG;IACa,YAAY,CAAC,a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I,EAAE,EAAE;YACvG,IAAI,MAAM,GAAG,uBAAQ,CAAC,eAAe,CAAC;YACtC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,uBAAQ,CAAC,aAAa,EAAE;gBACxD,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;gBACxC,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;gBACxC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;aAC5C;YACD,MAAM,CAAC,MAAM,KAAK,uBAAQ,CAAC,cAAc,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;IACL,CAAC;;AA1NH,gDA2NC;AAnCgB,uCAAoB,GAAG,gBAAgB,AAAnB,CAAoB","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 iModels\n */\nimport * as assert from \"assert\";\nimport { DbResult, Id64, Id64String, Logger } from \"@itwin/core-bentley\";\nimport {\n Code,\n CodeScopeSpec,\n ConcreteEntityTypes, ElementAspectProps, ElementProps, EntityReference, IModel, IModelError,\n PrimitiveTypeCode, PropertyMetaData, RelatedElement, RelatedElementProps,\n} from \"@itwin/core-common\";\nimport {\n Element, ElementAspect, EntityReferences, IModelElementCloneContext, IModelJsNative, SQLiteDb,\n} from \"@itwin/core-backend\";\nimport { ECReferenceTypesCache } from \"./ECReferenceTypesCache\";\nimport { EntityUnifier } from \"./EntityUnifier\";\nimport { TransformerLoggerCategory } from \"./TransformerLoggerCategory\";\n\nconst loggerCategory: string = TransformerLoggerCategory.IModelCloneContext;\n\n/** The context for transforming a *source* Element to a *target* Element and remapping internal identifiers to the target iModel.\n * @beta\n */\nexport class IModelCloneContext extends IModelElementCloneContext {\n\n private _refTypesCache = new ECReferenceTypesCache();\n private _aspectRemapTable = new Map<Id64String, Id64String>();\n\n /** perform necessary initialization to use a clone context, namely caching the reference types in the source's schemas */\n public override async initialize() {\n await this._refTypesCache.initAllSchemasInIModel(this.sourceDb);\n }\n\n /** Clone the specified source Element into ElementProps for the target iModel.\n * @internal\n */\n public override cloneElement(sourceElement: Element, cloneOptions?: IModelJsNative.CloneElementOptions): ElementProps {\n // eslint-disable-next-line @typescript-eslint/dot-notation\n const targetElementProps: ElementProps = this[\"_nativeContext\"].cloneElement(sourceElement.id, cloneOptions);\n // Ensure that all NavigationProperties in targetElementProps have a defined value so \"clearing\" changes will be part of the JSON used for update\n sourceElement.forEachProperty((propertyName: string, meta: PropertyMetaData) => {\n if ((meta.isNavigation) && (undefined === (sourceElement as any)[propertyName])) {\n (targetElementProps as any)[propertyName] = RelatedElement.none;\n }\n }, false); // exclude custom because C++ has already handled them\n if (this.isBetweenIModels) {\n // The native C++ cloneElement strips off federationGuid, want to put it back if transformation is between iModels\n targetElementProps.federationGuid = sourceElement.federationGuid;\n const targetElementCodeScopeType = this.targetDb.codeSpecs.getById(targetElementProps.code.spec).scopeType;\n if (CodeScopeSpec.Type.Repository === targetElementCodeScopeType && targetElementProps.code.scope !== IModel.rootSubjectId) {\n Logger.logWarning(loggerCategory, `Incorrect CodeScope '${targetElementCodeScopeType}' is set for target element ${targetElementProps.id}`);\n }\n }\n // unlike other references, code cannot be null. If it is null, use an empty code instead\n // this will be updated back later as the transformer resolves references\n if (targetElementProps.code.scope === Id64.invalid || targetElementProps.code.spec === Id64.invalid) {\n targetElementProps.code = Code.createEmpty();\n }\n const jsClass = this.sourceDb.getJsClass<typeof Element>(sourceElement.classFullName);\n // eslint-disable-next-line @typescript-eslint/dot-notation\n jsClass[\"onCloned\"](this, sourceElement.toJSON(), targetElementProps);\n return targetElementProps;\n }\n\n /** Add a rule that remaps the specified source ElementAspect to the specified target ElementAspect. */\n public remapElementAspect(aspectSourceId: Id64String, aspectTargetId: Id64String): void {\n this._aspectRemapTable.set(aspectSourceId, aspectTargetId);\n }\n\n /** Remove a rule that remaps the specified source ElementAspect */\n public removeElementAspect(aspectSourceId: Id64String): void {\n this._aspectRemapTable.delete(aspectSourceId);\n }\n\n /** Look up a target AspectId from the source AspectId.\n * @returns the target AspectId or [Id64.invalid]($bentley) if a mapping not found.\n */\n public findTargetAspectId(sourceAspectId: Id64String): Id64String {\n return this._aspectRemapTable.get(sourceAspectId) ?? Id64.invalid;\n }\n\n /** Look up a target [EntityReference]($bentley) from a source [EntityReference]($bentley)\n * @returns the target CodeSpecId or a [EntityReference]($bentley) containing [Id64.invalid]($bentley) if a mapping is not found.\n */\n public findTargetEntityId(sourceEntityId: EntityReference): EntityReference {\n const [type, rawId] = EntityReferences.split(sourceEntityId);\n if (Id64.isValid(rawId)) {\n switch (type) {\n case ConcreteEntityTypes.Model: {\n const targetId = `m${this.findTargetElementId(rawId)}` as const;\n // Check if the model exists, `findTargetElementId` may have worked because the element exists when the model doesn't.\n // That can occur in the transformer since a submodeled element is imported before its submodel.\n if (EntityUnifier.exists(this.targetDb, { entityReference: targetId }))\n return targetId;\n break;\n }\n case ConcreteEntityTypes.Element:\n return `e${this.findTargetElementId(rawId)}`;\n case ConcreteEntityTypes.ElementAspect:\n return `a${this.findTargetAspectId(rawId)}`;\n case ConcreteEntityTypes.Relationship: {\n const makeGetConcreteEntityTypeSql = (property: string) => `\n CASE\n WHEN [${property}] IS (BisCore.ElementUniqueAspect) OR [${property}] IS (BisCore.ElementMultiAspect)\n THEN 'a'\n WHEN [${property}] IS (BisCore.Element)\n THEN 'e'\n WHEN [${property}] IS (BisCore.Model)\n THEN 'm'\n WHEN [${property}] IS (BisCore.CodeSpec)\n THEN 'c'\n WHEN [${property}] IS (BisCore.ElementRefersToElements) -- TODO: ElementDrivesElement still not handled by the transformer\n THEN 'r'\n ELSE 'error'\n END\n `;\n const relInSource = this.sourceDb.withPreparedStatement(\n `\n SELECT\n SourceECInstanceId,\n TargetECInstanceId,\n (${makeGetConcreteEntityTypeSql(\"SourceECClassId\")}) AS SourceType,\n (${makeGetConcreteEntityTypeSql(\"TargetECClassId\")}) AS TargetType\n FROM BisCore:ElementRefersToElements\n WHERE ECInstanceId=?\n `, (stmt) => {\n stmt.bindId(1, rawId);\n let status: DbResult;\n while ((status = stmt.step()) === DbResult.BE_SQLITE_ROW) {\n const sourceId = stmt.getValue(0).getId();\n const targetId = stmt.getValue(1).getId();\n const sourceType = stmt.getValue(2).getString() as ConcreteEntityTypes | \"error\";\n const targetType = stmt.getValue(3).getString() as ConcreteEntityTypes | \"error\";\n if (sourceType === \"error\" || targetType === \"error\")\n throw Error(\"relationship end had unknown root class\");\n return {\n sourceId: `${sourceType}${sourceId}`,\n targetId: `${targetType}${targetId}`,\n } as const;\n }\n if (status !== DbResult.BE_SQLITE_DONE)\n throw new IModelError(status, \"unexpected query failure\");\n return undefined;\n });\n if (relInSource === undefined)\n break;\n // just in case prevent recursion\n if (relInSource.sourceId === sourceEntityId || relInSource.targetId === sourceEntityId)\n throw Error(\"link table relationship end was resolved to itself. This should be impossible\");\n const relInTarget = {\n sourceId: this.findTargetEntityId(relInSource.sourceId),\n targetId: this.findTargetEntityId(relInSource.targetId),\n };\n // return a null\n if (!EntityReferences.isValid(relInTarget.sourceId) || !EntityReferences.isValid(relInTarget.targetId))\n break;\n const relInTargetId = this.targetDb.withPreparedStatement(\n `\n SELECT ECInstanceId\n FROM BisCore:ElementRefersToElements\n WHERE SourceECInstanceId=?\n AND TargetECInstanceId=?\n `, (stmt) => {\n stmt.bindId(1, EntityReferences.toId64(relInTarget.sourceId));\n stmt.bindId(2, EntityReferences.toId64(relInTarget.targetId));\n const status: DbResult = stmt.step();\n if (status === DbResult.BE_SQLITE_ROW)\n return stmt.getValue(0).getId();\n if (status !== DbResult.BE_SQLITE_DONE)\n throw new IModelError(status, \"unexpected query failure\");\n return Id64.invalid;\n });\n return `r${relInTargetId}`;\n }\n }\n }\n return `${type}${Id64.invalid}`;\n }\n\n /** Clone the specified source Element into ElementProps for the target iModel.\n * @internal\n */\n public cloneElementAspect(sourceElementAspect: ElementAspect): ElementAspectProps {\n const targetElementAspectProps: ElementAspectProps = sourceElementAspect.toJSON();\n targetElementAspectProps.id = undefined;\n sourceElementAspect.forEachProperty((propertyName, propertyMetaData) => {\n if (propertyMetaData.isNavigation) {\n const sourceNavProp: RelatedElementProps | undefined = sourceElementAspect.asAny[propertyName];\n if (sourceNavProp?.id) {\n const navPropRefType = this._refTypesCache.getNavPropRefType(\n sourceElementAspect.schemaName,\n sourceElementAspect.className,\n propertyName\n );\n assert(navPropRefType !== undefined,`nav prop ref type for '${propertyName}' was not in the cache, this is a bug.`);\n const targetEntityReference = this.findTargetEntityId(EntityReferences.fromEntityType(sourceNavProp.id, navPropRefType));\n const targetEntityId = EntityReferences.toId64(targetEntityReference);\n // spread the property in case toJSON did not deep-clone\n (targetElementAspectProps as any)[propertyName] = { ...(targetElementAspectProps as any)[propertyName], id: targetEntityId };\n }\n } else if ((PrimitiveTypeCode.Long === propertyMetaData.primitiveType) && (\"Id\" === propertyMetaData.extendedType)) {\n (targetElementAspectProps as any)[propertyName] = this.findTargetElementId(sourceElementAspect.asAny[propertyName]);\n }\n });\n return targetElementAspectProps;\n }\n\n private static aspectRemapTableName = \"AspectIdRemaps\";\n\n public override saveStateToDb(db: SQLiteDb): void {\n super.saveStateToDb(db);\n if (DbResult.BE_SQLITE_DONE !== db.executeSQL(\n `CREATE TABLE ${IModelCloneContext.aspectRemapTableName} (Source INTEGER, Target INTEGER)`\n ))\n throw Error(\"Failed to create the aspect remap table in the state database\");\n db.saveChanges();\n db.withPreparedSqliteStatement(\n `INSERT INTO ${IModelCloneContext.aspectRemapTableName} (Source, Target) VALUES (?, ?)`,\n (stmt) => {\n for (const [source, target] of this._aspectRemapTable) {\n stmt.reset();\n stmt.bindId(1, source);\n stmt.bindId(2, target);\n if (DbResult.BE_SQLITE_DONE !== stmt.step())\n throw Error(\"Failed to insert aspect remapping into the state database\");\n }\n });\n }\n\n public override loadStateFromDb(db: SQLiteDb): void {\n super.loadStateFromDb(db);\n // FIXME: test this\n db.withSqliteStatement(`SELECT Source, Target FROM ${IModelCloneContext.aspectRemapTableName}`, (stmt) => {\n let status = DbResult.BE_SQLITE_ERROR;\n while ((status = stmt.step()) === DbResult.BE_SQLITE_ROW) {\n const source = stmt.getValue(0).getId();\n const target = stmt.getValue(1).getId();\n this._aspectRemapTable.set(source, target);\n }\n assert(status === DbResult.BE_SQLITE_DONE);\n });\n }\n}\n"]}
@@ -3,9 +3,10 @@
3
3
  */
4
4
  import { BriefcaseDb, Element, ElementAspect, ElementMultiAspect, ElementUniqueAspect, IModelDb, IModelJsNative, Model, Relationship } from "@itwin/core-backend";
5
5
  import { AccessToken, CompressedId64Set, Id64String } from "@itwin/core-bentley";
6
- import { CodeSpec, FontProps } from "@itwin/core-common";
6
+ import { ChangesetIndexOrId, CodeSpec, FontProps } from "@itwin/core-common";
7
7
  import { Schema, SchemaKey } from "@itwin/ecschema-metadata";
8
- import type { InitOptions } from "./IModelTransformer";
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]]
@@ -18,26 +19,14 @@ export interface ExportSchemaResult {
18
19
  * Arguments for [[IModelExporter.exportChanges]]
19
20
  * @public
20
21
  */
21
- export interface ExportChangesOptions extends InitOptions {
22
+ export interface ExportChangesOptions extends InitFromExternalSourceAspectsArgs {
22
23
  /**
23
24
  * Class instance that contains modified elements between 2 versions of an iModel.
24
25
  * If this parameter is not provided, then [[ChangedInstanceIds.initialize]] in [[IModelExporter.exportChanges]]
25
26
  * will be called to discover changed elements.
26
- * @note mutually exclusive with @see changesetRanges and @see startChangeset, so define one of the three, never more
27
27
  */
28
28
  changedInstanceIds?: ChangedInstanceIds;
29
- /**
30
- * An ordered array of changeset index ranges, e.g. [[2,2], [4,5]] is [2,4,5]
31
- * @note mutually exclusive with @see changedInstanceIds and @see startChangeset, so define one of the three, never more
32
- */
33
- changesetRanges?: [number, number][];
34
29
  }
35
- /**
36
- * Arguments for [[IModelExporter.initialize]], usually in case you want to query changedata early
37
- * such as in the case of the IModelTransformer
38
- * @beta
39
- */
40
- export type ExporterInitOptions = ExportChangesOptions;
41
30
  /** Handles the events generated by IModelExporter.
42
31
  * @note Change information is available when `IModelExportHandler` methods are invoked via [IModelExporter.exportChanges]($transformer), but not available when invoked via [IModelExporter.exportAll]($transformer).
43
32
  * @note The handler is intended to be owned by (registered with) and called from the IModelExporter exclusively
@@ -189,25 +178,15 @@ export declare class IModelExporter {
189
178
  private _excludedElementCategoryIds;
190
179
  /** The set of classes of Elements that will be excluded (polymorphically) from transformation to the target iModel. */
191
180
  private _excludedElementClasses;
192
- /** The set of classes of ElementAspects that will be excluded (polymorphically) from transformation to the target iModel. */
193
- private _excludedElementAspectClasses;
194
- /** The set of classFullNames for ElementAspects that will be excluded from transformation to the target iModel. */
195
- private _excludedElementAspectClassFullNames;
196
181
  /** The set of classes of Relationships that will be excluded (polymorphically) from transformation to the target iModel. */
197
182
  private _excludedRelationshipClasses;
183
+ /** Strategy for how ElementAspects are exported */
184
+ private _exportElementAspectsStrategy;
198
185
  /** Construct a new IModelExporter
199
186
  * @param sourceDb The source IModelDb
200
187
  * @see registerHandler
201
188
  */
202
- constructor(sourceDb: IModelDb);
203
- /**
204
- * Initialize prerequisites of exporting. This is implicitly done by any `export*` calls that need initialization
205
- * which is currently just `exportChanges`.
206
- * Prefer to not call this explicitly (e.g. just call [[IModelExporter.exportChanges]])
207
- * @note that if you do call this explicitly, you must do so with the same options that
208
- * you pass to [[IModelExporter.exportChanges]]
209
- */
210
- initialize(options: ExporterInitOptions): Promise<void>;
189
+ constructor(sourceDb: IModelDb, elementAspectsStrategy?: new (source: IModelDb, handler: ElementAspectsHandler) => ExportElementAspectsStrategy);
211
190
  /** Register the handler that will be called by IModelExporter. */
212
191
  registerHandler(handler: IModelExportHandler): void;
213
192
  /** Add a rule to exclude a CodeSpec */
@@ -226,17 +205,12 @@ export declare class IModelExporter {
226
205
  * @note [[exportSchemas]] must be called separately.
227
206
  */
228
207
  exportAll(): Promise<void>;
229
- /** Export changes from the source iModel.
230
- * Inserts, updates, and deletes are determined by inspecting the changeset(s).
231
- * @note To form a range of versions to process, set `startChangesetId` for the start (inclusive) of the desired
232
- * range and open the source iModel as of the end (inclusive) of the desired range.
233
- * @note the changedInstanceIds are just for this call to exportChanges, so you must continue to pass it in
234
- * for consecutive calls
208
+ /**
209
+ * Export changes from the source iModel.
235
210
  */
236
211
  exportChanges(args?: ExportChangesOptions): Promise<void>;
237
- /** @deprecated in 0.1.x, use a single [[ExportChangesOptions]] object instead */
212
+ /** @deprecated in 0.1.x, use a single ExportChangesArgs object instead */
238
213
  exportChanges(accessToken?: AccessToken, startChangesetId?: string, args?: ExportChangesOptions): Promise<void>;
239
- private _resetChangeDataOnExport;
240
214
  /** Export schemas from the source iModel.
241
215
  * @note This must be called separately from [[exportAll]] or [[exportChanges]].
242
216
  */
@@ -298,10 +272,9 @@ export declare class IModelExporter {
298
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.
299
273
  */
300
274
  exportChildElements(elementId: Id64String): Promise<void>;
301
- /** Returns `true` if the specified ElementAspect should be exported or `false` if if should be excluded. */
302
- private shouldExportElementAspect;
303
- /** Export ElementAspects from the specified element from the source iModel. */
304
- private exportElementAspects;
275
+ /** Exports all aspects present in the iModel.
276
+ */
277
+ private exportAllAspects;
305
278
  /** Exports all relationships that subclass from the specified base class.
306
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.
307
280
  */
@@ -363,6 +336,8 @@ export interface IModelExporterState {
363
336
  * @beta
364
337
  */
365
338
  export interface ChangedInstanceIdsInitOptions extends ExportChangesOptions {
339
+ /** @inheritdoc */
340
+ startChangeset: ChangesetIndexOrId;
366
341
  iModel: BriefcaseDb;
367
342
  }
368
343
  /** Class for holding change information.
@@ -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,QAAQ,EAAE,SAAS,EAAuB,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAa,MAAM,EAAE,SAAS,EAAgB,MAAM,0BAA0B,CAAC;AAEtF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAKvD;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,uFAAuF;IACvF,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAqB,SAAQ,WAAW;IACvD;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC;;;OAGG;IACH,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;CACtC;AAED;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,oBAAoB,CAAC;AAEvD;;;;;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;;;;OA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G;AACH,MAAM,WAAW,6BAA8B,SAAQ,oBAAoB;IACzE,kBAAkB;IAClB,cAAc,EAAE,kBAAkB,CAAC;IACnC,MAAM,EAAE,WAAW,CAAC;CACrB;AAED;;EAEE;AACF,qBAAa,kBAAkB;IACtB,SAAS,cAAyB;IAClC,SAAS,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,7 +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 nodeAssert = require("assert");
16
+ const ExportElementAspectsWithElementsStrategy_1 = require("./ExportElementAspectsWithElementsStrategy");
17
17
  const loggerCategory = TransformerLoggerCategory_1.TransformerLoggerCategory.IModelExporter;
18
18
  /** Handles the events generated by IModelExporter.
19
19
  * @note Change information is available when `IModelExportHandler` methods are invoked via [IModelExporter.exportChanges]($transformer), but not available when invoked via [IModelExporter.exportAll]($transformer).
@@ -135,7 +135,7 @@ class IModelExporter {
135
135
  * @param sourceDb The source IModelDb
136
136
  * @see registerHandler
137
137
  */
138
- constructor(sourceDb) {
138
+ constructor(sourceDb, elementAspectsStrategy = ExportElementAspectsWithElementsStrategy_1.ExportElementAspectsWithElementsStrategy) {
139
139
  /** A flag that indicates whether element GeometryStreams are loaded or not.
140
140
  * @note As an optimization, exporters that don't need geometry can set this flag to `false`. The default is `true`.
141
141
  * @note The transformer by default sets this to `false` as an optimization.
@@ -173,29 +173,16 @@ class IModelExporter {
173
173
  this._excludedElementCategoryIds = new Set();
174
174
  /** The set of classes of Elements that will be excluded (polymorphically) from transformation to the target iModel. */
175
175
  this._excludedElementClasses = new Set();
176
- /** The set of classes of ElementAspects that will be excluded (polymorphically) from transformation to the target iModel. */
177
- this._excludedElementAspectClasses = new Set();
178
- /** The set of classFullNames for ElementAspects that will be excluded from transformation to the target iModel. */
179
- this._excludedElementAspectClassFullNames = new Set();
180
176
  /** The set of classes of Relationships that will be excluded (polymorphically) from transformation to the target iModel. */
181
177
  this._excludedRelationshipClasses = new Set();
182
- this._resetChangeDataOnExport = true;
183
178
  this._yieldManager = new core_bentley_1.YieldManager();
184
179
  this.sourceDb = sourceDb;
185
- }
186
- /**
187
- * Initialize prerequisites of exporting. This is implicitly done by any `export*` calls that need initialization
188
- * which is currently just `exportChanges`.
189
- * Prefer to not call this explicitly (e.g. just call [[IModelExporter.exportChanges]])
190
- * @note that if you do call this explicitly, you must do so with the same options that
191
- * you pass to [[IModelExporter.exportChanges]]
192
- */
193
- async initialize(options) {
194
- const hasChangeData = options.startChangeset || options.changesetRanges || options.changedInstanceIds;
195
- if (this._sourceDbChanges || !this.sourceDb.isBriefcaseDb() || !hasChangeData)
196
- return;
197
- this._sourceDbChanges = options.changedInstanceIds
198
- ?? await ChangedInstanceIds.initialize({ iModel: this.sourceDb, ...options });
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
+ });
199
186
  }
200
187
  /** Register the handler that will be called by IModelExporter. */
201
188
  registerHandler(handler) {
@@ -219,8 +206,7 @@ class IModelExporter {
219
206
  }
220
207
  /** Add a rule to exclude all ElementAspects of a specified class. */
221
208
  excludeElementAspectClass(classFullName) {
222
- this._excludedElementAspectClassFullNames.add(classFullName); // allows non-polymorphic exclusion before query
223
- this._excludedElementAspectClasses.add(this.sourceDb.getJsClass(classFullName)); // allows polymorphic exclusion after query/load
209
+ this._exportElementAspectsStrategy.excludeElementAspectClass(classFullName);
224
210
  }
225
211
  /** Add a rule to exclude all Relationships of a specified class. */
226
212
  excludeRelationshipClass(classFullName) {
@@ -230,28 +216,36 @@ class IModelExporter {
230
216
  * @note [[exportSchemas]] must be called separately.
231
217
  */
232
218
  async exportAll() {
233
- await this.initialize({});
234
219
  await this.exportCodeSpecs();
235
220
  await this.exportFonts();
236
221
  await this.exportModel(core_common_1.IModel.repositoryModelId);
237
222
  await this.exportRelationships(core_backend_1.ElementRefersToElements.classFullName);
238
223
  }
239
- async exportChanges(accessTokenOrOpts, startChangesetId) {
224
+ async exportChanges(accessTokenOrArgs, startChangesetId) {
240
225
  if (!this.sourceDb.isBriefcaseDb())
241
226
  throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadRequest, "Must be a briefcase to export changes");
242
227
  if ("" === this.sourceDb.changeset.id) {
243
228
  await this.exportAll(); // no changesets, so revert to exportAll
244
229
  return;
245
230
  }
246
- const initOpts = typeof accessTokenOrOpts === "object"
247
- ? accessTokenOrOpts
231
+ const { accessToken, startChangeset } = typeof accessTokenOrArgs === "object"
232
+ ? accessTokenOrArgs
248
233
  : {
249
- accessToken: accessTokenOrOpts,
234
+ accessToken: accessTokenOrArgs,
250
235
  startChangeset: { id: startChangesetId },
251
236
  };
252
- await this.initialize(initOpts);
253
- // _sourceDbChanges are initialized in this.initialize
254
- nodeAssert(this._sourceDbChanges !== undefined, "sourceDbChanges must be initialized.");
237
+ this._sourceDbChanges =
238
+ (typeof accessTokenOrArgs === "object"
239
+ ? accessTokenOrArgs.changedInstanceIds
240
+ : undefined)
241
+ ?? await ChangedInstanceIds.initialize({
242
+ accessToken,
243
+ startChangeset: startChangeset?.id !== undefined || startChangeset?.index !== undefined
244
+ ? startChangeset
245
+ : this.sourceDb.changeset,
246
+ iModel: this.sourceDb,
247
+ });
248
+ this._exportElementAspectsStrategy.setAspectChanges(this._sourceDbChanges?.aspect);
255
249
  await this.exportCodeSpecs();
256
250
  await this.exportFonts();
257
251
  await this.exportModelContents(core_common_1.IModel.repositoryModelId);
@@ -285,12 +279,6 @@ class IModelExporter {
285
279
  this.handler.onDeleteRelationship(relInstanceId);
286
280
  }
287
281
  }
288
- // Enable consecutive exportChanges runs without the need to re-instantiate the exporter.
289
- // You can counteract the obvious impact of losing this expensive data by always calling
290
- // exportChanges with the [[ExportChangesOptions.changedInstanceIds]] option set to
291
- // whatever you want
292
- if (this._resetChangeDataOnExport)
293
- this._sourceDbChanges = undefined;
294
282
  }
295
283
  /** Export schemas from the source iModel.
296
284
  * @note This must be called separately from [[exportAll]] or [[exportChanges]].
@@ -564,10 +552,20 @@ class IModelExporter {
564
552
  core_bentley_1.Logger.logTrace(loggerCategory, `visitElements=false, skipping exportElement(${elementId})`);
565
553
  return;
566
554
  }
567
- // are we processing changes?
568
- const isUpdate = this._sourceDbChanges?.element.insertIds.has(elementId) ? false
569
- : this._sourceDbChanges?.element.updateIds.has(elementId) ? true
570
- : undefined;
555
+ let isUpdate;
556
+ if (undefined !== this._sourceDbChanges) { // is changeset information available?
557
+ if (this._sourceDbChanges.element.insertIds.has(elementId)) {
558
+ isUpdate = false;
559
+ }
560
+ else if (this._sourceDbChanges.element.updateIds.has(elementId)) {
561
+ isUpdate = true;
562
+ }
563
+ else {
564
+ // NOTE: This optimization assumes that the Element will change (LastMod) if an owned ElementAspect changes
565
+ // NOTE: However, child elements may have changed without the parent changing
566
+ return this.exportChildElements(elementId);
567
+ }
568
+ }
571
569
  const element = this.sourceDb.elements.getElement({ id: elementId, wantGeometry: this.wantGeometry, wantBRepData: this.wantGeometry });
572
570
  core_bentley_1.Logger.logTrace(loggerCategory, `exportElement(${element.id}, "${element.getDisplayLabel()}")${this.getChangeOpSuffix(isUpdate)}`);
573
571
  // the order and `await`ing of calls beyond here is depended upon by the IModelTransformer for a current bug workaround
@@ -575,7 +573,7 @@ class IModelExporter {
575
573
  await this.handler.preExportElement(element);
576
574
  this.handler.onExportElement(element, isUpdate);
577
575
  await this.trackProgress();
578
- await this.exportElementAspects(elementId);
576
+ await this._exportElementAspectsStrategy.exportElementAspectsForElement(elementId);
579
577
  return this.exportChildElements(elementId);
580
578
  }
581
579
  else {
@@ -598,39 +596,10 @@ class IModelExporter {
598
596
  }
599
597
  }
600
598
  }
601
- /** Returns `true` if the specified ElementAspect should be exported or `false` if if should be excluded. */
602
- shouldExportElementAspect(aspect) {
603
- for (const excludedElementAspectClass of this._excludedElementAspectClasses) {
604
- if (aspect instanceof excludedElementAspectClass) {
605
- core_bentley_1.Logger.logInfo(loggerCategory, `Excluded ElementAspect by class: ${aspect.classFullName}`);
606
- return false;
607
- }
608
- }
609
- // ElementAspect has passed standard exclusion rules, now give handler a chance to accept/reject
610
- return this.handler.shouldExportElementAspect(aspect);
611
- }
612
- /** Export ElementAspects from the specified element from the source iModel. */
613
- async exportElementAspects(elementId) {
614
- const _uniqueAspects = await Promise.all(this.sourceDb.elements
615
- ._queryAspects(elementId, core_backend_1.ElementUniqueAspect.classFullName, this._excludedElementAspectClassFullNames)
616
- .filter((a) => this.shouldExportElementAspect(a))
617
- .map(async (uniqueAspect) => {
618
- const isInsertChange = this._sourceDbChanges?.aspect.insertIds.has(uniqueAspect.id) ?? false;
619
- const isUpdateChange = this._sourceDbChanges?.aspect.updateIds.has(uniqueAspect.id) ?? false;
620
- const doExport = this._sourceDbChanges === undefined || isInsertChange || isUpdateChange;
621
- if (doExport) {
622
- const isKnownUpdate = this._sourceDbChanges ? isUpdateChange : undefined;
623
- this.handler.onExportElementUniqueAspect(uniqueAspect, isKnownUpdate);
624
- await this.trackProgress();
625
- }
626
- }));
627
- const multiAspects = this.sourceDb.elements
628
- ._queryAspects(elementId, core_backend_1.ElementMultiAspect.classFullName, this._excludedElementAspectClassFullNames)
629
- .filter((a) => this.shouldExportElementAspect(a));
630
- if (multiAspects.length > 0) {
631
- this.handler.onExportElementMultiAspects(multiAspects);
632
- return this.trackProgress();
633
- }
599
+ /** Exports all aspects present in the iModel.
600
+ */
601
+ async exportAllAspects() {
602
+ return this._exportElementAspectsStrategy.exportAllElementAspects();
634
603
  }
635
604
  /** Exports all relationships that subclass from the specified base class.
636
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.
@@ -724,8 +693,7 @@ class IModelExporter {
724
693
  this._excludedElementIds = core_bentley_1.CompressedId64Set.decompressSet(state.excludedElementIds),
725
694
  this._excludedElementCategoryIds = core_bentley_1.CompressedId64Set.decompressSet(state.excludedElementCategoryIds),
726
695
  this._excludedElementClasses = new Set(state.excludedElementClassNames.map((c) => this.sourceDb.getJsClass(c)));
727
- this._excludedElementAspectClassFullNames = new Set(state.excludedElementAspectClassFullNames);
728
- this._excludedElementAspectClasses = new Set(state.excludedElementAspectClassFullNames.map((c) => this.sourceDb.getJsClass(c)));
696
+ this._exportElementAspectsStrategy.loadExcludedElementAspectClasses(state.excludedElementAspectClassFullNames);
729
697
  this._excludedRelationshipClasses = new Set(state.excludedRelationshipClassNames.map((c) => this.sourceDb.getJsClass(c)));
730
698
  this.loadAdditionalStateJson(state.additionalState);
731
699
  }
@@ -747,36 +715,13 @@ class IModelExporter {
747
715
  excludedElementIds: core_bentley_1.CompressedId64Set.compressSet(this._excludedElementIds),
748
716
  excludedElementCategoryIds: core_bentley_1.CompressedId64Set.compressSet(this._excludedElementCategoryIds),
749
717
  excludedElementClassNames: Array.from(this._excludedElementClasses, (cls) => cls.classFullName),
750
- excludedElementAspectClassFullNames: [...this._excludedElementAspectClassFullNames],
718
+ excludedElementAspectClassFullNames: [...this._exportElementAspectsStrategy.excludedElementAspectClassFullNames],
751
719
  excludedRelationshipClassNames: Array.from(this._excludedRelationshipClasses, (cls) => cls.classFullName),
752
720
  additionalState: this.getAdditionalStateJson(),
753
721
  };
754
722
  }
755
723
  }
756
724
  exports.IModelExporter = IModelExporter;
757
- /**
758
- * Asserts that the passed in options have exactly one of:
759
- * startChangeset xor changesetRanges xor changedInstanceIds
760
- * defined
761
- */
762
- function assertHasChangeDataOptions(opts) {
763
- const xor = (...args) => {
764
- let result = false;
765
- for (const a of args) {
766
- if (!result && a)
767
- result = true;
768
- else if (result && a)
769
- return false;
770
- }
771
- return result;
772
- };
773
- nodeAssert(xor(opts.startChangeset, opts.changesetRanges, opts.changedInstanceIds), "exactly one of startChangeset, XOR changesetRanges XOR opts.changedInstanceIds may be defined but "
774
- + `received ${JSON.stringify({
775
- startChangeset: !!opts.startChangeset,
776
- changesetRanges: !!opts.changesetRanges,
777
- ChangedInstanceIds: !!opts.changedInstanceIds,
778
- })}`);
779
- }
780
725
  /** Class for holding change information.
781
726
  * @beta
782
727
  */
@@ -828,31 +773,13 @@ class ChangedInstanceIds {
828
773
  iModel: iModel,
829
774
  startChangeset: { id: startChangesetId },
830
775
  };
831
- assertHasChangeDataOptions(opts);
832
- const iModelId = opts.iModel.iModelId;
833
776
  const accessToken = opts.accessToken;
834
- const changesetRanges = opts.changesetRanges
835
- ?? [[
836
- // we know startChangeset is defined because of the assert above
837
- opts.startChangeset.index
838
- ?? (await core_backend_1.IModelHost.hubAccess.queryChangeset({
839
- iModelId,
840
- changeset: { id: opts.startChangeset.id ?? opts.iModel.changeset.id },
841
- accessToken,
842
- })).index,
843
- opts.iModel.changeset.index
844
- ?? (await core_backend_1.IModelHost.hubAccess.queryChangeset({
845
- iModelId,
846
- changeset: { id: opts.iModel.changeset.id },
847
- accessToken,
848
- })).index,
849
- ]];
850
- core_bentley_1.Logger.logTrace(loggerCategory, `ChangedInstanceIds.initialize ranges: ${changesetRanges.join("|")}`);
851
- const changesets = (await Promise.all(changesetRanges.map(async ([first, end]) => core_backend_1.IModelHost.hubAccess.downloadChangesets({
852
- accessToken,
853
- iModelId, range: { first, end },
854
- targetDir: core_backend_1.BriefcaseManager.getChangeSetsPath(iModelId),
855
- })))).flat();
777
+ const iModelId = opts.iModel.iModelId;
778
+ const first = opts.startChangeset?.index
779
+ ?? (await core_backend_1.IModelHost.hubAccess.queryChangeset({ iModelId, changeset: { id: opts.startChangeset.id }, accessToken })).index;
780
+ const end = opts.iModel.changeset.index
781
+ ?? (await core_backend_1.IModelHost.hubAccess.queryChangeset({ iModelId, changeset: { id: opts.iModel.changeset.id }, accessToken })).index;
782
+ const changesets = await core_backend_1.IModelHost.hubAccess.downloadChangesets({ accessToken, iModelId, range: { first, end }, targetDir: core_backend_1.BriefcaseManager.getChangeSetsPath(iModelId) });
856
783
  const changedInstanceIds = new ChangedInstanceIds();
857
784
  const changesetFiles = changesets.map((c) => c.pathname);
858
785
  const statusOrResult = opts.iModel.nativeDb.extractChangedInstanceIdsFromChangeSets(changesetFiles);