@itwin/imodel-transformer 2.0.0-dev.48 → 2.0.0-dev.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/IModelExporter.d.ts +24 -3
- package/lib/cjs/IModelExporter.d.ts.map +1 -1
- package/lib/cjs/IModelExporter.js +145 -29
- package/lib/cjs/IModelExporter.js.map +1 -1
- package/lib/cjs/IModelTransformer.d.ts +2 -2
- package/lib/cjs/IModelTransformer.d.ts.map +1 -1
- package/lib/cjs/IModelTransformer.js +5 -4
- package/lib/cjs/IModelTransformer.js.map +1 -1
- package/lib/cjs/IModelTransformerError.d.ts +2 -0
- package/lib/cjs/IModelTransformerError.d.ts.map +1 -1
- package/lib/cjs/IModelTransformerError.js +2 -0
- package/lib/cjs/IModelTransformerError.js.map +1 -1
- package/lib/cjs/ProvenanceManager.d.ts +13 -1
- package/lib/cjs/ProvenanceManager.d.ts.map +1 -1
- package/lib/cjs/ProvenanceManager.js +22 -14
- package/lib/cjs/ProvenanceManager.js.map +1 -1
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @module iModels
|
|
3
3
|
*/
|
|
4
4
|
import { BriefcaseDb, ChangeInstance, Element, ElementAspect, ElementMultiAspect, ElementUniqueAspect, IModelDb, IModelJsNative, Model, Relationship, SqliteChangeOp } from "@itwin/core-backend";
|
|
5
|
-
import { Id64Arg, Id64String } from "@itwin/core-bentley";
|
|
5
|
+
import { GuidString, Id64Arg, Id64String } from "@itwin/core-bentley";
|
|
6
6
|
import { ChangesetFileProps, CodeSpec, FontFamilyDescriptor, FontProps } from "@itwin/core-common";
|
|
7
7
|
import { Schema, SchemaKey } from "@itwin/ecschema-metadata";
|
|
8
8
|
import { ElementAspectExportCoordinator } from "./ElementAspectExportCoordinator";
|
|
@@ -135,9 +135,11 @@ export declare abstract class IModelExportHandler {
|
|
|
135
135
|
/** Called when a Relationship should be exported.
|
|
136
136
|
* @param relationship The Relationship to export
|
|
137
137
|
* @param isUpdate If defined, then `true` indicates an UPDATE operation while `false` indicates an INSERT operation. If not defined, then INSERT vs. UPDATE is not known.
|
|
138
|
+
* @param sourceFedGuid The FederationGuid of the relationship's source endpoint, if available.
|
|
139
|
+
* @param targetFedGuid The FederationGuid of the relationship's target endpoint, if available.
|
|
138
140
|
* @note This should be overridden to actually do the export.
|
|
139
141
|
*/
|
|
140
|
-
onExportRelationship(_relationship: Relationship, _isUpdate: boolean | undefined): Promise<void>;
|
|
142
|
+
onExportRelationship(_relationship: Relationship, _isUpdate: boolean | undefined, _sourceFedGuid?: GuidString, _targetFedGuid?: GuidString): Promise<void>;
|
|
141
143
|
/** Called when a relationship should be deleted. */
|
|
142
144
|
onDeleteRelationship(_relInstanceId: Id64String): Promise<void>;
|
|
143
145
|
/** If `true` is returned, then the schema will be exported.
|
|
@@ -367,10 +369,29 @@ export declare class IModelExporter {
|
|
|
367
369
|
private getAspectOwnerIdBatches;
|
|
368
370
|
/** Exports all relationships that subclass from the specified base class.
|
|
369
371
|
* @note This method is called from [[exportChanges]] and [[exportAll]], so it only needs to be called directly when exporting a subset of an iModel.
|
|
372
|
+
* @note This is the bulk traversal path. It hydrates relationships with one streaming query and calls [[exportRelationshipInstance]] directly; it does not call [[exportRelationship]] once per row.
|
|
370
373
|
*/
|
|
371
374
|
exportRelationships(baseRelClassFullName: string): Promise<void>;
|
|
372
|
-
/**
|
|
375
|
+
/** Builds the raw relationship query used by the bulk and targeted export paths. */
|
|
376
|
+
private getRelationshipQuery;
|
|
377
|
+
/** Applies the changeset filter (when exporting changes) to a relationship instance id.
|
|
378
|
+
* @returns whether to skip the relationship, and whether the export is an update.
|
|
379
|
+
*/
|
|
380
|
+
private checkRelationshipChangesetFilter;
|
|
381
|
+
/** Converts a raw `$` instance-access row into [RelationshipProps]($common). */
|
|
382
|
+
private getRelationshipProps;
|
|
383
|
+
/** Export one specified relationship from the source iModel.
|
|
384
|
+
* @note This targeted path is separate from [[exportRelationships]], which traverses a class hierarchy. It uses the same raw instance query and passes endpoint FederationGuids to the handler.
|
|
385
|
+
*/
|
|
373
386
|
exportRelationship(relClassFullName: string, relInstanceId: Id64String): Promise<void>;
|
|
387
|
+
/** Hydrates a relationship query row and runs the common export pipeline. */
|
|
388
|
+
private exportHydratedRelationship;
|
|
389
|
+
/** Applies exclusion rules and handler callbacks to an already-hydrated relationship instance.
|
|
390
|
+
* @param sourceFedGuid The FederationGuid of the relationship's source endpoint, if available.
|
|
391
|
+
* @param targetFedGuid The FederationGuid of the relationship's target endpoint, if available.
|
|
392
|
+
* @note This is the common protected hook used by both [[exportRelationship]] and [[exportRelationships]]. Most consumers should customize [[IModelExportHandler]] instead.
|
|
393
|
+
*/
|
|
394
|
+
protected exportRelationshipInstance(relationship: Relationship, isUpdate: boolean | undefined, sourceFedGuid?: GuidString, targetFedGuid?: GuidString): Promise<void>;
|
|
374
395
|
/** Tracks incremental progress */
|
|
375
396
|
private trackProgress;
|
|
376
397
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelExporter.d.ts","sourceRoot":"","sources":["../../src/IModelExporter.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EACL,WAAW,EAEX,cAAc,EAGd,OAAO,EACP,aAAa,EACb,kBAAkB,EAElB,mBAAmB,EAEnB,QAAQ,EACR,cAAc,EACd,KAAK,EAEL,YAAY,EACZ,cAAc,EACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,
|
|
1
|
+
{"version":3,"file":"IModelExporter.d.ts","sourceRoot":"","sources":["../../src/IModelExporter.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EACL,WAAW,EAEX,cAAc,EAGd,OAAO,EACP,aAAa,EACb,kBAAkB,EAElB,mBAAmB,EAEnB,QAAQ,EACR,cAAc,EACd,KAAK,EAEL,YAAY,EACZ,cAAc,EACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAEL,UAAU,EAEV,OAAO,EAEP,UA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,EAC1B,GAAG,EAAE,OAAO,GACX,OAAO,CAAC,IAAI,CAAC,CAgCf;IAED;;;;;;;;;;OAUG;IACU,oBAAoB,CAC/B,UAAU,EAAE,cAAc,EAC1B,GAAG,EAAE,OAAO,GACX,OAAO,CAAC,IAAI,CAAC,CAMf;IAED;;;;;;;;;;OAUG;IACI,qBAAqB,CAC1B,UAAU,EAAE,cAAc,EAC1B,GAAG,EAAE,OAAO,EACZ,UAAU,CAAC,EAAE,OAAO,GACnB,IAAI,CAkCN;IAED,OAAO,CAAC,wBAAwB;IAShC;;;OAGG;YACW,yBAAyB;YAiCzB,kCAAkC;YAyBlC,4BAA4B;IAoB1C,OAAO,CAAC,YAAY;IAyBpB;;;OAGG;IACH,OAAoB,UAAU,CAC5B,IAAI,EAAE,6BAA6B,GAClC,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAsDzC;CACF"}
|
|
@@ -102,9 +102,11 @@ class IModelExportHandler {
|
|
|
102
102
|
/** Called when a Relationship should be exported.
|
|
103
103
|
* @param relationship The Relationship to export
|
|
104
104
|
* @param isUpdate If defined, then `true` indicates an UPDATE operation while `false` indicates an INSERT operation. If not defined, then INSERT vs. UPDATE is not known.
|
|
105
|
+
* @param sourceFedGuid The FederationGuid of the relationship's source endpoint, if available.
|
|
106
|
+
* @param targetFedGuid The FederationGuid of the relationship's target endpoint, if available.
|
|
105
107
|
* @note This should be overridden to actually do the export.
|
|
106
108
|
*/
|
|
107
|
-
async onExportRelationship(_relationship, _isUpdate) { }
|
|
109
|
+
async onExportRelationship(_relationship, _isUpdate, _sourceFedGuid, _targetFedGuid) { }
|
|
108
110
|
/** Called when a relationship should be deleted. */
|
|
109
111
|
async onDeleteRelationship(_relInstanceId) { }
|
|
110
112
|
/** If `true` is returned, then the schema will be exported.
|
|
@@ -978,6 +980,7 @@ class IModelExporter {
|
|
|
978
980
|
}
|
|
979
981
|
/** Exports all relationships that subclass from the specified base class.
|
|
980
982
|
* @note This method is called from [[exportChanges]] and [[exportAll]], so it only needs to be called directly when exporting a subset of an iModel.
|
|
983
|
+
* @note This is the bulk traversal path. It hydrates relationships with one streaming query and calls [[exportRelationshipInstance]] directly; it does not call [[exportRelationship]] once per row.
|
|
981
984
|
*/
|
|
982
985
|
async exportRelationships(baseRelClassFullName) {
|
|
983
986
|
if (!this.visitRelationships) {
|
|
@@ -985,41 +988,154 @@ class IModelExporter {
|
|
|
985
988
|
return;
|
|
986
989
|
}
|
|
987
990
|
core_bentley_1.Logger.logTrace(loggerCategory, `exportRelationships(${baseRelClassFullName})`);
|
|
988
|
-
const
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
991
|
+
const changedRelationshipIds = this._sourceDbChanges === undefined
|
|
992
|
+
? undefined
|
|
993
|
+
: new Set([
|
|
994
|
+
...this._sourceDbChanges.relationship.insertIds,
|
|
995
|
+
...this._sourceDbChanges.relationship.updateIds,
|
|
996
|
+
]);
|
|
997
|
+
if (changedRelationshipIds?.size === 0) {
|
|
998
|
+
// Deleted relationships are handled by exportChanges after this traversal; they are no
|
|
999
|
+
// longer present in the source iModel and must not cause a full relationship scan here.
|
|
1000
|
+
core_bentley_1.Logger.logTrace(loggerCategory, "No inserted or updated relationships, skipping exportRelationships()");
|
|
1001
|
+
return;
|
|
999
1002
|
}
|
|
1000
|
-
|
|
1001
|
-
|
|
1003
|
+
const changedRelationshipJoin = changedRelationshipIds === undefined
|
|
1004
|
+
? undefined
|
|
1005
|
+
: "INNER JOIN IdSet(:changedRelationshipIds) changed ON changed.id = r.ECInstanceId";
|
|
1006
|
+
const relationshipWhereClause = "s.ECInstanceId IS NOT NULL AND t.ECInstanceId IS NOT NULL";
|
|
1007
|
+
// Bound the async reader's retained raw rows while preserving batched query throughput.
|
|
1008
|
+
// Keyset pagination avoids rescanning rows returned by earlier batches.
|
|
1009
|
+
const relationshipQueryBatchSize = 1000;
|
|
1010
|
+
let lastRelationshipId;
|
|
1011
|
+
while (true) {
|
|
1012
|
+
let rowsRead = 0;
|
|
1013
|
+
const whereClause = lastRelationshipId === undefined
|
|
1014
|
+
? relationshipWhereClause
|
|
1015
|
+
: `${relationshipWhereClause} AND r.ECInstanceId > :lastRelationshipId`;
|
|
1016
|
+
// QueryBinder parameters are immutable after binding a name. Recreate the binder for each
|
|
1017
|
+
// keyset page so the changing boundary can be bound without redefining a property.
|
|
1018
|
+
const queryParams = changedRelationshipIds === undefined && lastRelationshipId === undefined
|
|
1019
|
+
? undefined
|
|
1020
|
+
: new core_common_1.QueryBinder();
|
|
1021
|
+
if (queryParams !== undefined) {
|
|
1022
|
+
if (changedRelationshipIds !== undefined) {
|
|
1023
|
+
queryParams.bindIdSet("changedRelationshipIds", changedRelationshipIds);
|
|
1024
|
+
}
|
|
1025
|
+
if (lastRelationshipId !== undefined) {
|
|
1026
|
+
queryParams.bindId("lastRelationshipId", lastRelationshipId);
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
const reader = this.sourceDb.createQueryReader(this.getRelationshipQuery(baseRelClassFullName, "JOIN", whereClause, changedRelationshipJoin), queryParams, {
|
|
1030
|
+
usePrimaryConn: true,
|
|
1031
|
+
limit: { count: relationshipQueryBatchSize },
|
|
1032
|
+
});
|
|
1033
|
+
for await (const row of reader) {
|
|
1034
|
+
rowsRead++;
|
|
1035
|
+
const relInstanceId = row.relInstanceId;
|
|
1036
|
+
lastRelationshipId = relInstanceId;
|
|
1037
|
+
const changesetFilter = this.checkRelationshipChangesetFilter(relInstanceId);
|
|
1038
|
+
if (changesetFilter.skip) {
|
|
1039
|
+
await this._yieldManager.allowYield();
|
|
1040
|
+
continue;
|
|
1041
|
+
}
|
|
1042
|
+
await this.exportHydratedRelationship(row.rawInstance, row.sourceFedGuid, row.targetFedGuid, changesetFilter.isUpdate);
|
|
1043
|
+
await this._yieldManager.allowYield();
|
|
1044
|
+
}
|
|
1045
|
+
if (rowsRead < relationshipQueryBatchSize)
|
|
1046
|
+
break;
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
/** Builds the raw relationship query used by the bulk and targeted export paths. */
|
|
1050
|
+
getRelationshipQuery(relClassFullName, endpointJoin, whereClause, relationshipJoin) {
|
|
1051
|
+
return `SELECT r.$ AS rawInstance, r.ECInstanceId AS relInstanceId, s.FederationGuid AS sourceFedGuid, t.FederationGuid AS targetFedGuid FROM ${relClassFullName} r
|
|
1052
|
+
${relationshipJoin ?? ""}
|
|
1053
|
+
${endpointJoin} bis.Element s ON s.ECInstanceId = r.SourceECInstanceId
|
|
1054
|
+
${endpointJoin} bis.Element t ON t.ECInstanceId = r.TargetECInstanceId
|
|
1055
|
+
WHERE ${whereClause}
|
|
1056
|
+
ORDER BY r.ECInstanceId
|
|
1057
|
+
OPTIONS USE_JS_PROP_NAMES DO_NOT_TRUNCATE_BLOB`;
|
|
1058
|
+
}
|
|
1059
|
+
/** Applies the changeset filter (when exporting changes) to a relationship instance id.
|
|
1060
|
+
* @returns whether to skip the relationship, and whether the export is an update.
|
|
1061
|
+
*/
|
|
1062
|
+
checkRelationshipChangesetFilter(relInstanceId) {
|
|
1063
|
+
if (undefined === this._sourceDbChanges)
|
|
1064
|
+
return { skip: false, isUpdate: undefined };
|
|
1065
|
+
if (this._sourceDbChanges.relationship.insertIds.has(relInstanceId))
|
|
1066
|
+
return { skip: false, isUpdate: false };
|
|
1067
|
+
if (this._sourceDbChanges.relationship.updateIds.has(relInstanceId))
|
|
1068
|
+
return { skip: false, isUpdate: true };
|
|
1069
|
+
return { skip: true, isUpdate: undefined }; // not in changeset, don't export
|
|
1070
|
+
}
|
|
1071
|
+
/** Converts a raw `$` instance-access row into [RelationshipProps]($common). */
|
|
1072
|
+
getRelationshipProps(rawInstance) {
|
|
1073
|
+
const parsedRow = typeof rawInstance === "string"
|
|
1074
|
+
? JSON.parse(rawInstance, core_common_1.Base64EncodedString.reviver)
|
|
1075
|
+
: rawInstance;
|
|
1076
|
+
if (!core_bentley_1.JsonUtils.isObject(parsedRow))
|
|
1077
|
+
core_bentley_1.ITwinError.throwError({
|
|
1078
|
+
iTwinErrorId: {
|
|
1079
|
+
scope: IModelTransformerError_1.IModelTransformerErrorScope,
|
|
1080
|
+
key: IModelTransformerError_1.IModelTransformerError.InvalidRelationshipData,
|
|
1081
|
+
},
|
|
1082
|
+
message: "Expected a Relationship instance query to return an object",
|
|
1083
|
+
});
|
|
1084
|
+
const row = {};
|
|
1085
|
+
for (const [key, value] of Object.entries(parsedRow)) {
|
|
1086
|
+
const ecPropertyName = key.length === 0 ? key : key[0].toUpperCase() + key.substring(1);
|
|
1087
|
+
row[core_common_1.ECJsNames.toJsName(ecPropertyName)] = value;
|
|
1088
|
+
}
|
|
1089
|
+
const className = row.className;
|
|
1090
|
+
if (typeof className !== "string")
|
|
1091
|
+
core_bentley_1.ITwinError.throwError({
|
|
1092
|
+
iTwinErrorId: {
|
|
1093
|
+
scope: IModelTransformerError_1.IModelTransformerErrorScope,
|
|
1094
|
+
key: IModelTransformerError_1.IModelTransformerError.InvalidRelationshipData,
|
|
1095
|
+
},
|
|
1096
|
+
message: "Expected a Relationship instance query to return a className",
|
|
1097
|
+
});
|
|
1098
|
+
row.classFullName = className.replace(".", ":");
|
|
1099
|
+
delete row.className;
|
|
1100
|
+
delete row.sourceClassName;
|
|
1101
|
+
delete row.targetClassName;
|
|
1102
|
+
return row;
|
|
1103
|
+
}
|
|
1104
|
+
/** Export one specified relationship from the source iModel.
|
|
1105
|
+
* @note This targeted path is separate from [[exportRelationships]], which traverses a class hierarchy. It uses the same raw instance query and passes endpoint FederationGuids to the handler.
|
|
1106
|
+
*/
|
|
1002
1107
|
async exportRelationship(relClassFullName, relInstanceId) {
|
|
1003
1108
|
if (!this.visitRelationships) {
|
|
1004
1109
|
core_bentley_1.Logger.logTrace(loggerCategory, `visitRelationships=false, skipping exportRelationship(${relClassFullName}, ${relInstanceId})`);
|
|
1005
1110
|
return;
|
|
1006
1111
|
}
|
|
1007
|
-
|
|
1008
|
-
if (
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
else {
|
|
1017
|
-
return; // not in changeset, don't export
|
|
1018
|
-
}
|
|
1112
|
+
const changesetFilter = this.checkRelationshipChangesetFilter(relInstanceId);
|
|
1113
|
+
if (changesetFilter.skip)
|
|
1114
|
+
return;
|
|
1115
|
+
const queryParams = new core_common_1.QueryBinder().bindId("relInstanceId", relInstanceId);
|
|
1116
|
+
const reader = this.sourceDb.createQueryReader(this.getRelationshipQuery(relClassFullName, "LEFT JOIN", "r.ECInstanceId = :relInstanceId"), queryParams, { usePrimaryConn: true });
|
|
1117
|
+
if (await reader.step()) {
|
|
1118
|
+
const row = reader.current;
|
|
1119
|
+
await this.exportHydratedRelationship(row.rawInstance, row.sourceFedGuid, row.targetFedGuid, changesetFilter.isUpdate);
|
|
1120
|
+
return;
|
|
1019
1121
|
}
|
|
1020
|
-
//
|
|
1021
|
-
core_bentley_1.Logger.logTrace(loggerCategory, `exportRelationship(${relClassFullName}, ${relInstanceId})`);
|
|
1122
|
+
// Preserve the previous not-found behavior if the targeted query returned no row.
|
|
1022
1123
|
const relationship = this.sourceDb.relationships.getInstance(relClassFullName, relInstanceId);
|
|
1124
|
+
await this.exportRelationshipInstance(relationship, changesetFilter.isUpdate, this.sourceDb.elements.getFederationGuidFromId(relationship.sourceId), this.sourceDb.elements.getFederationGuidFromId(relationship.targetId));
|
|
1125
|
+
}
|
|
1126
|
+
/** Hydrates a relationship query row and runs the common export pipeline. */
|
|
1127
|
+
async exportHydratedRelationship(rawInstance, sourceFedGuid, targetFedGuid, isUpdate) {
|
|
1128
|
+
const relationship = this.sourceDb.constructEntity(this.getRelationshipProps(rawInstance));
|
|
1129
|
+
await this.exportRelationshipInstance(relationship, isUpdate, sourceFedGuid ?? undefined, targetFedGuid ?? undefined);
|
|
1130
|
+
}
|
|
1131
|
+
/** Applies exclusion rules and handler callbacks to an already-hydrated relationship instance.
|
|
1132
|
+
* @param sourceFedGuid The FederationGuid of the relationship's source endpoint, if available.
|
|
1133
|
+
* @param targetFedGuid The FederationGuid of the relationship's target endpoint, if available.
|
|
1134
|
+
* @note This is the common protected hook used by both [[exportRelationship]] and [[exportRelationships]]. Most consumers should customize [[IModelExportHandler]] instead.
|
|
1135
|
+
*/
|
|
1136
|
+
async exportRelationshipInstance(relationship, isUpdate, sourceFedGuid, targetFedGuid) {
|
|
1137
|
+
// passed changeset test, now apply standard exclusion rules
|
|
1138
|
+
core_bentley_1.Logger.logTrace(loggerCategory, `exportRelationship(${relationship.classFullName}, ${relationship.id})`);
|
|
1023
1139
|
for (const excludedRelationshipClass of this._excludedRelationshipClasses) {
|
|
1024
1140
|
if (relationship instanceof excludedRelationshipClass) {
|
|
1025
1141
|
core_bentley_1.Logger.logInfo(loggerCategory, `Excluded relationship by class: ${excludedRelationshipClass.classFullName}`);
|
|
@@ -1028,7 +1144,7 @@ class IModelExporter {
|
|
|
1028
1144
|
}
|
|
1029
1145
|
// relationship has passed standard exclusion rules, now give handler a chance to accept/reject export
|
|
1030
1146
|
if (await this.handler.shouldExportRelationship(relationship)) {
|
|
1031
|
-
await this.handler.onExportRelationship(relationship, isUpdate);
|
|
1147
|
+
await this.handler.onExportRelationship(relationship, isUpdate, sourceFedGuid, targetFedGuid);
|
|
1032
1148
|
await this.trackProgress();
|
|
1033
1149
|
}
|
|
1034
1150
|
}
|