@itwin/imodel-transformer 2.0.0-dev.7 → 2.0.0-dev.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -27
- package/lib/cjs/Algo.d.ts +0 -4
- package/lib/cjs/Algo.d.ts.map +1 -1
- package/lib/cjs/Algo.js +0 -11
- package/lib/cjs/Algo.js.map +1 -1
- package/lib/cjs/BigMap.d.ts.map +1 -1
- package/lib/cjs/BigMap.js.map +1 -1
- package/lib/cjs/BranchProvenanceInitializer.d.ts.map +1 -1
- package/lib/cjs/BranchProvenanceInitializer.js +26 -26
- package/lib/cjs/BranchProvenanceInitializer.js.map +1 -1
- package/lib/cjs/ChangedElementForest.d.ts +14 -0
- package/lib/cjs/ChangedElementForest.d.ts.map +1 -0
- package/lib/cjs/ChangedElementForest.js +86 -0
- package/lib/cjs/ChangedElementForest.js.map +1 -0
- package/lib/cjs/ChangesetScanner.d.ts +141 -0
- package/lib/cjs/ChangesetScanner.d.ts.map +1 -0
- package/lib/cjs/ChangesetScanner.js +187 -0
- package/lib/cjs/ChangesetScanner.js.map +1 -0
- package/lib/cjs/ECReferenceTypesCache.d.ts +0 -4
- package/lib/cjs/ECReferenceTypesCache.d.ts.map +1 -1
- package/lib/cjs/ECReferenceTypesCache.js +61 -111
- package/lib/cjs/ECReferenceTypesCache.js.map +1 -1
- package/lib/cjs/ECSqlReaderAsyncIterableIteratorAdapter.d.ts.map +1 -1
- package/lib/cjs/ECSqlReaderAsyncIterableIteratorAdapter.js.map +1 -1
- package/lib/cjs/ElementAspectCleanup.d.ts +16 -0
- package/lib/cjs/ElementAspectCleanup.d.ts.map +1 -0
- package/lib/cjs/ElementAspectCleanup.js +87 -0
- package/lib/cjs/ElementAspectCleanup.js.map +1 -0
- package/lib/cjs/ElementAspectExportCoordinator.d.ts +44 -0
- package/lib/cjs/ElementAspectExportCoordinator.d.ts.map +1 -0
- package/lib/cjs/ElementAspectExportCoordinator.js +148 -0
- package/lib/cjs/ElementAspectExportCoordinator.js.map +1 -0
- package/lib/cjs/ElementAspectExportProcessor.d.ts +44 -0
- package/lib/cjs/ElementAspectExportProcessor.d.ts.map +1 -0
- package/lib/cjs/ElementAspectExportProcessor.js +152 -0
- package/lib/cjs/ElementAspectExportProcessor.js.map +1 -0
- package/lib/cjs/ElementBulkDelete.d.ts +30 -0
- package/lib/cjs/ElementBulkDelete.d.ts.map +1 -0
- package/lib/cjs/ElementBulkDelete.js +358 -0
- package/lib/cjs/ElementBulkDelete.js.map +1 -0
- package/lib/cjs/EntityExistenceCache.d.ts +43 -0
- package/lib/cjs/EntityExistenceCache.d.ts.map +1 -0
- package/lib/cjs/EntityExistenceCache.js +91 -0
- package/lib/cjs/EntityExistenceCache.js.map +1 -0
- package/lib/cjs/EntityUnifier.d.ts +7 -7
- package/lib/cjs/EntityUnifier.d.ts.map +1 -1
- package/lib/cjs/EntityUnifier.js +55 -24
- package/lib/cjs/EntityUnifier.js.map +1 -1
- package/lib/cjs/IModelCloneContext.d.ts +9 -3
- package/lib/cjs/IModelCloneContext.d.ts.map +1 -1
- package/lib/cjs/IModelCloneContext.js +56 -22
- package/lib/cjs/IModelCloneContext.js.map +1 -1
- package/lib/cjs/IModelExporter.d.ts +180 -43
- package/lib/cjs/IModelExporter.d.ts.map +1 -1
- package/lib/cjs/IModelExporter.js +946 -247
- package/lib/cjs/IModelExporter.js.map +1 -1
- package/lib/cjs/IModelImporter.d.ts +75 -30
- package/lib/cjs/IModelImporter.d.ts.map +1 -1
- package/lib/cjs/IModelImporter.js +292 -132
- package/lib/cjs/IModelImporter.js.map +1 -1
- package/lib/cjs/IModelTransformContext.d.ts +54 -0
- package/lib/cjs/IModelTransformContext.d.ts.map +1 -0
- package/lib/cjs/IModelTransformContext.js +3 -0
- package/lib/cjs/IModelTransformContext.js.map +1 -0
- package/lib/cjs/IModelTransformer.d.ts +184 -206
- package/lib/cjs/IModelTransformer.d.ts.map +1 -1
- package/lib/cjs/IModelTransformer.js +819 -1278
- package/lib/cjs/IModelTransformer.js.map +1 -1
- package/lib/cjs/IModelTransformerError.d.ts +84 -0
- package/lib/cjs/IModelTransformerError.d.ts.map +1 -0
- package/lib/cjs/IModelTransformerError.js +93 -0
- package/lib/cjs/IModelTransformerError.js.map +1 -0
- package/lib/cjs/ProvenanceManager.d.ts +177 -0
- package/lib/cjs/ProvenanceManager.d.ts.map +1 -0
- package/lib/cjs/ProvenanceManager.js +719 -0
- package/lib/cjs/ProvenanceManager.js.map +1 -0
- package/lib/cjs/SourceClassKinds.d.ts +22 -0
- package/lib/cjs/SourceClassKinds.d.ts.map +1 -0
- package/lib/cjs/SourceClassKinds.js +60 -0
- package/lib/cjs/SourceClassKinds.js.map +1 -0
- package/lib/cjs/SyncTypeResolver.d.ts +32 -0
- package/lib/cjs/SyncTypeResolver.d.ts.map +1 -0
- package/lib/cjs/SyncTypeResolver.js +92 -0
- package/lib/cjs/SyncTypeResolver.js.map +1 -0
- package/lib/cjs/TransformerLoggerCategory.d.ts +1 -1
- package/lib/cjs/TransformerLoggerCategory.js +1 -1
- package/lib/cjs/TransformerLoggerCategory.js.map +1 -1
- package/lib/cjs/TransformerPackageMetadata.d.ts +8 -0
- package/lib/cjs/TransformerPackageMetadata.d.ts.map +1 -0
- package/lib/cjs/TransformerPackageMetadata.js +47 -0
- package/lib/cjs/TransformerPackageMetadata.js.map +1 -0
- package/lib/cjs/imodel-transformer.d.ts +28 -0
- package/lib/cjs/imodel-transformer.d.ts.map +1 -1
- package/lib/cjs/imodel-transformer.js +61 -34
- package/lib/cjs/imodel-transformer.js.map +1 -1
- package/lib/cjs/schema-processing/DynamicSchemaUnionStrategy.d.ts +29 -0
- package/lib/cjs/schema-processing/DynamicSchemaUnionStrategy.d.ts.map +1 -0
- package/lib/cjs/schema-processing/DynamicSchemaUnionStrategy.js +212 -0
- package/lib/cjs/schema-processing/DynamicSchemaUnionStrategy.js.map +1 -0
- package/lib/cjs/schema-processing/SchemaProcessingCoordinator.d.ts +25 -0
- package/lib/cjs/schema-processing/SchemaProcessingCoordinator.d.ts.map +1 -0
- package/lib/cjs/schema-processing/SchemaProcessingCoordinator.js +196 -0
- package/lib/cjs/schema-processing/SchemaProcessingCoordinator.js.map +1 -0
- package/lib/cjs/schema-processing/SchemaProcessingStrategy.d.ts +59 -0
- package/lib/cjs/schema-processing/SchemaProcessingStrategy.d.ts.map +1 -0
- package/lib/cjs/schema-processing/SchemaProcessingStrategy.js +28 -0
- package/lib/cjs/schema-processing/SchemaProcessingStrategy.js.map +1 -0
- package/lib/cjs/schema-processing.d.ts +7 -0
- package/lib/cjs/schema-processing.d.ts.map +1 -0
- package/lib/cjs/schema-processing.js +27 -0
- package/lib/cjs/schema-processing.js.map +1 -0
- package/package.json +70 -57
- package/lib/cjs/DetachedExportElementAspectsStrategy.d.ts +0 -16
- package/lib/cjs/DetachedExportElementAspectsStrategy.d.ts.map +0 -1
- package/lib/cjs/DetachedExportElementAspectsStrategy.js +0 -106
- package/lib/cjs/DetachedExportElementAspectsStrategy.js.map +0 -1
- package/lib/cjs/ElementCascadingDeleter.d.ts +0 -22
- package/lib/cjs/ElementCascadingDeleter.d.ts.map +0 -1
- package/lib/cjs/ElementCascadingDeleter.js +0 -57
- package/lib/cjs/ElementCascadingDeleter.js.map +0 -1
- package/lib/cjs/EntityMap.d.ts +0 -26
- package/lib/cjs/EntityMap.d.ts.map +0 -1
- package/lib/cjs/EntityMap.js +0 -54
- package/lib/cjs/EntityMap.js.map +0 -1
- package/lib/cjs/ExportElementAspectsStrategy.d.ts +0 -35
- package/lib/cjs/ExportElementAspectsStrategy.d.ts.map +0 -1
- package/lib/cjs/ExportElementAspectsStrategy.js +0 -52
- package/lib/cjs/ExportElementAspectsStrategy.js.map +0 -1
- package/lib/cjs/ExportElementAspectsWithElementsStrategy.d.ts +0 -12
- package/lib/cjs/ExportElementAspectsWithElementsStrategy.d.ts.map +0 -1
- package/lib/cjs/ExportElementAspectsWithElementsStrategy.js +0 -47
- package/lib/cjs/ExportElementAspectsWithElementsStrategy.js.map +0 -1
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
import { Id64Array, Id64Set, Id64String } from "@itwin/core-bentley";
|
|
2
2
|
import * as ECSchemaMetaData from "@itwin/ecschema-metadata";
|
|
3
3
|
import { Transform } from "@itwin/core-geometry";
|
|
4
|
-
import { Element, ElementAspect, ElementMultiAspect, ElementUniqueAspect, Entity, ExternalSourceAspect, IModelDb, Model, Relationship, RelationshipProps } from "@itwin/core-backend";
|
|
4
|
+
import { EditTxn, Element, ElementAspect, ElementMultiAspect, ElementUniqueAspect, Entity, ExternalSourceAspect, IModelDb, Model, Relationship, RelationshipProps } from "@itwin/core-backend";
|
|
5
5
|
import { ChangesetIndexAndId, CodeSpec, ElementAspectProps, ElementProps, ExternalSourceAspectProps, FontProps, Helmert2DWithZOffset, ModelProps, Placement2d, Placement3d } from "@itwin/core-common";
|
|
6
|
-
import { ChangedInstanceIds, ExportChangesOptions, ExportSchemaResult, IModelExporter, IModelExportHandler } from "./IModelExporter";
|
|
6
|
+
import { ChangedInstanceIds, ExportChangesOptions, ExportSchemaResult, IModelExporter, IModelExportHandler, RelationshipEndpointFederationGuids } from "./IModelExporter";
|
|
7
7
|
import { IModelImporter, OptimizeGeometryOptions } from "./IModelImporter";
|
|
8
|
-
import {
|
|
8
|
+
import type { IModelTransformContext } from "./IModelTransformContext";
|
|
9
|
+
import { ProvenanceManager } from "./ProvenanceManager";
|
|
10
|
+
import { ProcessSchemasOptions } from "./schema-processing/SchemaProcessingStrategy";
|
|
11
|
+
import { CollectedChanges } from "./ChangesetScanner";
|
|
12
|
+
/** Required arguments for the [[IModelTransformer]] constructor.
|
|
13
|
+
* @beta
|
|
14
|
+
*/
|
|
15
|
+
export interface IModelTransformArgs {
|
|
16
|
+
/** The source iModel or exporter to read elements from. */
|
|
17
|
+
source: IModelDb | IModelExporter;
|
|
18
|
+
/** The target for the transformation. Pass an [[EditTxn]] to have the transformer create a default [[IModelImporter]], or pass a pre-configured [[IModelImporter]]. */
|
|
19
|
+
target: EditTxn | IModelImporter;
|
|
20
|
+
}
|
|
9
21
|
/** Options provided to the [[IModelTransformer]] constructor.
|
|
10
22
|
* @beta
|
|
11
23
|
* @note if adding an option, you must explicitly add its serialization to [[IModelTransformer.saveStateToFile]]!
|
|
@@ -122,6 +134,13 @@ export interface IModelTransformOptions {
|
|
|
122
134
|
* @default false
|
|
123
135
|
*/
|
|
124
136
|
tryAlignGeolocation?: boolean;
|
|
137
|
+
/** An optional [[EditTxn]] for write operations on the **source** iModel.
|
|
138
|
+
* Only needed for reverse synchronization workflows where provenance must be written back to the source.
|
|
139
|
+
* If not provided, the source iModel is treated as read-only.
|
|
140
|
+
* Must be started before calling [[IModelTransformer.process]].
|
|
141
|
+
* @beta
|
|
142
|
+
*/
|
|
143
|
+
sourceEditTxn?: EditTxn;
|
|
125
144
|
}
|
|
126
145
|
/**
|
|
127
146
|
* Data type for persisting change version information within provenance Scope ExternalSourceAspect.
|
|
@@ -164,7 +183,7 @@ export interface InitOptions {
|
|
|
164
183
|
* @beta
|
|
165
184
|
*/
|
|
166
185
|
export type ProcessChangesOptions = ExportChangesOptions & {
|
|
167
|
-
/** how to
|
|
186
|
+
/** how to save changes on the target. Must call `editTxn.saveChanges()` on the target EditTxn, should not edit the iModel */
|
|
168
187
|
saveTargetChanges?: (transformer: IModelTransformer) => Promise<void>;
|
|
169
188
|
/**
|
|
170
189
|
* The forward sync 'version' to set on the scoping ESA @see ExternalSourceAspectProps upon startup, if the version property on the scoping ESA is undefined or empty string.
|
|
@@ -202,6 +221,7 @@ export interface RelationshipPropsForDelete {
|
|
|
202
221
|
export declare class IModelTransformer extends IModelExportHandler {
|
|
203
222
|
/** The IModelExporter that will export from the source iModel. */
|
|
204
223
|
readonly exporter: IModelExporter;
|
|
224
|
+
private readonly _schemaProcessingCoordinator;
|
|
205
225
|
/** The IModelImporter that will import into the target iModel. */
|
|
206
226
|
readonly importer: IModelImporter;
|
|
207
227
|
/** The normally read-only source iModel.
|
|
@@ -210,8 +230,10 @@ export declare class IModelTransformer extends IModelExportHandler {
|
|
|
210
230
|
readonly sourceDb: IModelDb;
|
|
211
231
|
/** The read/write target iModel. */
|
|
212
232
|
readonly targetDb: IModelDb;
|
|
213
|
-
/** The
|
|
214
|
-
|
|
233
|
+
/** The supported transformation context for this transformer. */
|
|
234
|
+
get context(): IModelTransformContext;
|
|
235
|
+
/** The clone context used by the transformer implementation. */
|
|
236
|
+
private readonly _cloneContext;
|
|
215
237
|
/** The transform to be applied to the placement of spatial elements
|
|
216
238
|
* This transform should be applied when:
|
|
217
239
|
* - source and target db have different ECEF locations
|
|
@@ -221,47 +243,38 @@ export declare class IModelTransformer extends IModelExportHandler {
|
|
|
221
243
|
* @beta
|
|
222
244
|
*/
|
|
223
245
|
private _linearSpatialTransform?;
|
|
224
|
-
|
|
246
|
+
/** The [[EditTxn]] used for write operations on the target iModel.
|
|
247
|
+
* The caller is responsible for starting, committing or abandoning this transaction.
|
|
248
|
+
* @beta
|
|
249
|
+
*/
|
|
250
|
+
protected readonly _targetEditTxn: EditTxn;
|
|
251
|
+
/** The optional [[EditTxn]] used for write operations on the source iModel during reverse synchronization.
|
|
252
|
+
* @beta
|
|
253
|
+
*/
|
|
254
|
+
protected readonly _sourceEditTxn?: EditTxn;
|
|
255
|
+
private _syncTypeResolver;
|
|
256
|
+
protected _provenanceManager: ProvenanceManager;
|
|
225
257
|
/** The Id of the Element in the **target** iModel that represents the **source** repository as a whole and scopes its [ExternalSourceAspect]($backend) instances. */
|
|
226
258
|
get targetScopeElementId(): Id64String;
|
|
227
259
|
/** a set of elements for which source provenance will be explicitly tracked by ExternalSourceAspects */
|
|
228
260
|
protected _elementsWithExplicitlyTrackedProvenance: Set<string>;
|
|
229
261
|
protected _partiallyCommittedElementIds: Id64Set;
|
|
230
262
|
protected _partiallyCommittedAspectIds: Id64Set;
|
|
231
|
-
/** the options that were used to initialize this transformer */
|
|
232
|
-
private readonly _options;
|
|
233
263
|
/**
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
264
|
+
* Tracks target element IDs that were remapped by Code during the current
|
|
265
|
+
* transformation pass. Used to prevent deletion of target elements that have been remapped
|
|
266
|
+
* to a new source element in the same pass (e.g., when a source element is deleted and a
|
|
267
|
+
* new one with the same properties is added, causing a remap to the same target).
|
|
238
268
|
*/
|
|
239
|
-
private
|
|
240
|
-
static noEsaSyncDirectionErrorMessage: string;
|
|
241
|
-
/**
|
|
242
|
-
* Queries for an esa which matches the props in the provided aspectProps.
|
|
243
|
-
* @param dbToQuery db to run the query on for scope external source
|
|
244
|
-
* @param aspectProps aspectProps to search for @see ExternalSourceAspectProps
|
|
245
|
-
*/
|
|
246
|
-
static queryScopeExternalSourceAspect(dbToQuery: IModelDb, aspectProps: ExternalSourceAspectProps): Promise<{
|
|
247
|
-
aspectId: Id64String;
|
|
248
|
-
version?: string;
|
|
249
|
-
/** stringified json */
|
|
250
|
-
jsonProperties?: string;
|
|
251
|
-
} | undefined>;
|
|
269
|
+
private _targetElementIdsRemappedByCode;
|
|
252
270
|
/**
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
/** @see [[IModelTransformOptions.targetScopeElementId]] */
|
|
261
|
-
targetScopeElementId: Id64String): Promise<"forward" | "reverse">;
|
|
262
|
-
private determineSyncType;
|
|
263
|
-
getIsReverseSynchronization(): Promise<boolean>;
|
|
264
|
-
getIsForwardSynchronization(): Promise<boolean>;
|
|
271
|
+
* Tracks target model IDs that were imported (inserted or updated) during the current
|
|
272
|
+
* transformation pass. Used to prevent deletion of target models that have been recreated
|
|
273
|
+
* in the same pass (e.g. when a partition element is recreated with a new model).
|
|
274
|
+
*/
|
|
275
|
+
private _targetModelsImportedInCurrentTransform;
|
|
276
|
+
/** the options that were used to initialize this transformer */
|
|
277
|
+
private readonly _options;
|
|
265
278
|
private _changesetRanges;
|
|
266
279
|
/**
|
|
267
280
|
* Set if the transformer is being used to perform the provenance initialization step of a fork initialization.
|
|
@@ -273,11 +286,10 @@ export declare class IModelTransformer extends IModelExportHandler {
|
|
|
273
286
|
/** The element aspect classes that are considered to define provenance in the iModel */
|
|
274
287
|
static get provenanceElementAspectClasses(): (typeof Entity)[];
|
|
275
288
|
/** Construct a new IModelTransformer
|
|
276
|
-
* @param
|
|
277
|
-
* @param target Specifies the target IModelImporter or the target IModelDb that will be used to construct the target IModelImporter.
|
|
289
|
+
* @param args The required arguments including source and target.
|
|
278
290
|
* @param options The options that specify how the transformation should be done.
|
|
279
291
|
*/
|
|
280
|
-
constructor(
|
|
292
|
+
constructor(args: IModelTransformArgs, options?: IModelTransformOptions);
|
|
281
293
|
/** validates that the importer set on the transformer has the same values for its shared options as the transformer.
|
|
282
294
|
* @note This expects that the importer is already set on the transformer.
|
|
283
295
|
*/
|
|
@@ -286,28 +298,6 @@ export declare class IModelTransformer extends IModelExportHandler {
|
|
|
286
298
|
dispose(): void;
|
|
287
299
|
/** Log current settings that affect IModelTransformer's behavior. */
|
|
288
300
|
private logSettings;
|
|
289
|
-
/** Return the IModelDb where IModelTransformer will store its provenance.
|
|
290
|
-
* @note This will be [[targetDb]] except when it is a reverse synchronization. In that case it be [[sourceDb]].
|
|
291
|
-
*/
|
|
292
|
-
provenanceDb(): Promise<IModelDb>;
|
|
293
|
-
/** Return the IModelDb where IModelTransformer looks for entities referred to by stored provenance.
|
|
294
|
-
* @note This will be [[sourceDb]] except when it is a reverse synchronization. In that case it be [[targetDb]].
|
|
295
|
-
*/
|
|
296
|
-
provenanceSourceDb(): Promise<IModelDb>;
|
|
297
|
-
/** Create an ExternalSourceAspectProps in a standard way for an Element in an iModel --> iModel transformation. */
|
|
298
|
-
static initElementProvenanceOptions(sourceElementId: Id64String, targetElementId: Id64String, args: {
|
|
299
|
-
sourceDb: IModelDb;
|
|
300
|
-
targetDb: IModelDb;
|
|
301
|
-
isReverseSynchronization: boolean;
|
|
302
|
-
targetScopeElementId: Id64String;
|
|
303
|
-
}): ExternalSourceAspectProps;
|
|
304
|
-
static initRelationshipProvenanceOptions(sourceRelInstanceId: Id64String, targetRelInstanceId: Id64String, args: {
|
|
305
|
-
sourceDb: IModelDb;
|
|
306
|
-
targetDb: IModelDb;
|
|
307
|
-
isReverseSynchronization: boolean;
|
|
308
|
-
targetScopeElementId: Id64String;
|
|
309
|
-
forceOldRelationshipProvenanceMethod: boolean;
|
|
310
|
-
}): Promise<ExternalSourceAspectProps>;
|
|
311
301
|
/**
|
|
312
302
|
* Previously the transformer would insert provenance always pointing to the "target" relationship.
|
|
313
303
|
* It should (and now by default does) instead insert provenance pointing to the provenanceSource
|
|
@@ -317,26 +307,6 @@ export declare class IModelTransformer extends IModelExportHandler {
|
|
|
317
307
|
private _forceOldRelationshipProvenanceMethod;
|
|
318
308
|
/** Create an ExternalSourceAspectProps in a standard way for an Element in an iModel --> iModel transformation. */
|
|
319
309
|
initElementProvenance(sourceElementId: Id64String, targetElementId: Id64String): Promise<ExternalSourceAspectProps>;
|
|
320
|
-
/** Create an ExternalSourceAspectProps in a standard way for a Relationship in an iModel --> iModel transformations.
|
|
321
|
-
* The ExternalSourceAspect is meant to be owned by the Element in the target iModel that is the `sourceId` of transformed relationship.
|
|
322
|
-
* The `identifier` property of the ExternalSourceAspect will be the ECInstanceId of the relationship in the master iModel.
|
|
323
|
-
* The ECInstanceId of the relationship in the branch iModel will be stored in the JsonProperties of the ExternalSourceAspect.
|
|
324
|
-
*/
|
|
325
|
-
private initRelationshipProvenance;
|
|
326
|
-
/** NOTE: the json properties must be converted to string before insertion */
|
|
327
|
-
private _targetScopeProvenanceProps;
|
|
328
|
-
/**
|
|
329
|
-
* Index of the changeset that the transformer was at when the transformation begins (was constructed).
|
|
330
|
-
* Used to determine at the end which changesets were part of a synchronization.
|
|
331
|
-
*/
|
|
332
|
-
private _startingChangesetIndices;
|
|
333
|
-
private _cachedSynchronizationVersion;
|
|
334
|
-
/**
|
|
335
|
-
* We cache the synchronization version to avoid querying the target scoping ESA multiple times.
|
|
336
|
-
* If the target scoping ESA is ever updated we need to clear any potentially cached sync version otherwise we will get stale values.
|
|
337
|
-
* Sets this._cachedSynchronizationVersion to undefined.
|
|
338
|
-
*/
|
|
339
|
-
private clearCachedSynchronizationVersion;
|
|
340
310
|
/** the changeset in the scoping element's source version found for this transformation
|
|
341
311
|
* @note the version depends on whether this is a reverse synchronization or not, as
|
|
342
312
|
* it is stored separately for both synchronization directions.
|
|
@@ -344,7 +314,7 @@ export declare class IModelTransformer extends IModelExportHandler {
|
|
|
344
314
|
* @note empty string and -1 for changeset and index if it was transformed before federation guid update (pre 1.x) and @see [[IModelTransformOptions.branchRelationshipDataBehavior]] === "unsafe-migrate".
|
|
345
315
|
* @throws if the version is not found in a preexisting scope aspect and @see [[IModelTransformOptions.branchRelationshipDataBehavior]] !== "unsafe-migrate"
|
|
346
316
|
*/
|
|
347
|
-
protected
|
|
317
|
+
protected getSynchronizationVersion(): Promise<ChangesetIndexAndId>;
|
|
348
318
|
/**
|
|
349
319
|
* @returns provenance scope aspect if it exists in the provenanceDb.
|
|
350
320
|
* Provenance scope aspect is created and inserted into provenanceDb when [[initScopeProvenance]] is invoked.
|
|
@@ -353,63 +323,32 @@ export declare class IModelTransformer extends IModelExportHandler {
|
|
|
353
323
|
/**
|
|
354
324
|
* Make sure there are no conflicting other scope-type external source aspects on the *target scope element*,
|
|
355
325
|
* If there are none at all, insert one, then this must be a first synchronization.
|
|
356
|
-
* @returns the last synced version (changesetId) on the target scope's external source aspect,
|
|
357
|
-
* if this was a [BriefcaseDb]($backend)
|
|
358
326
|
*/
|
|
359
327
|
protected initScopeProvenance(): Promise<void>;
|
|
360
|
-
/** Returns true if a change was made to the aspectProps. */
|
|
361
|
-
private handleUnsafeMigrate;
|
|
362
328
|
/**
|
|
363
|
-
*
|
|
364
|
-
*
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
*/
|
|
368
|
-
static forEachTrackedElement(args: {
|
|
369
|
-
provenanceSourceDb: IModelDb;
|
|
370
|
-
provenanceDb: IModelDb;
|
|
371
|
-
targetScopeElementId: Id64String;
|
|
372
|
-
isReverseSynchronization: boolean;
|
|
373
|
-
fn: (sourceElementId: Id64String, targetElementId: Id64String) => void;
|
|
374
|
-
skipPropagateChangesToRootElements: boolean;
|
|
375
|
-
}): Promise<void>;
|
|
376
|
-
private forEachTrackedElement;
|
|
329
|
+
* Get the IModelDb where provenance (ExternalSourceAspects) is stored.
|
|
330
|
+
* This will be targetDb except when it is a reverse synchronization, in which case it will be sourceDb.
|
|
331
|
+
*/
|
|
332
|
+
getProvenanceDb(): Promise<IModelDb>;
|
|
377
333
|
/**
|
|
378
|
-
*
|
|
379
|
-
* The identifier on the ESA is the id of the element in the [[IModelTransformer.provenanceSourceDb]]
|
|
380
|
-
* Therefore it only makes sense to call this function when you have an id in the provenanceSourceDb.
|
|
381
|
-
* @param entityInProvenanceSourceId
|
|
382
|
-
* @returns the elementId that the ESA is stored on, esa.Element.Id
|
|
334
|
+
* Get whether this is a reverse synchronization.
|
|
383
335
|
*/
|
|
384
|
-
|
|
336
|
+
getIsReverseSynchronization(): Promise<boolean>;
|
|
337
|
+
/**
|
|
338
|
+
* Get whether this is a forward synchronization.
|
|
339
|
+
*/
|
|
340
|
+
getIsForwardSynchronization(): Promise<boolean>;
|
|
385
341
|
/**
|
|
386
|
-
*
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
*/
|
|
392
|
-
private _queryProvenanceForRelationship;
|
|
393
|
-
private _queryTargetRelId;
|
|
394
|
-
private _targetClassNameToClassIdCache;
|
|
395
|
-
private _targetClassNameToClassId;
|
|
396
|
-
private _getRelClassId;
|
|
397
|
-
private _queryElemIdByFedGuid;
|
|
342
|
+
* Updates the synchronization version on the scope ESA.
|
|
343
|
+
*/
|
|
344
|
+
updateSynchronizationVersion({ initializeReverseSyncVersion, }?: {
|
|
345
|
+
initializeReverseSyncVersion?: boolean | undefined;
|
|
346
|
+
}): Promise<void>;
|
|
398
347
|
/** Returns `true` if *brute force* delete detections should be run.
|
|
399
348
|
* @note This is only called if [[IModelTransformOptions.forceExternalSourceAspectProvenance]] option is true
|
|
400
349
|
* @note Not relevant for [[process]] when [[IModelTransformOptions.argsForProcessChanges]] are provided and change history is known.
|
|
401
350
|
*/
|
|
402
|
-
protected shouldDetectDeletes(): boolean
|
|
403
|
-
/**
|
|
404
|
-
* Detect Element deletes using ExternalSourceAspects in the target iModel and a *brute force* comparison against Elements
|
|
405
|
-
* in the source iModel.
|
|
406
|
-
* deprecated in 1.x. Do not use this. // FIXME<MIKE>: how to better explain this?
|
|
407
|
-
* This method is only called during [[process]] when [[IModelTransformOptions.argsForProcessChanges]] is undefined and the option
|
|
408
|
-
* [[IModelTransformOptions.forceExternalSourceAspectProvenance]] is enabled. It is not
|
|
409
|
-
* necessary when calling [[process]] with [[IModelTransformOptions.argsForProcessChanges]] defined, since changeset information is sufficient.
|
|
410
|
-
* @note you do not need to call this directly unless processing a subset of an iModel.
|
|
411
|
-
* @throws [[IModelError]] If the required provenance information is not available to detect deletes.
|
|
412
|
-
*/
|
|
351
|
+
protected shouldDetectDeletes(): Promise<boolean>;
|
|
413
352
|
/** Transform the specified sourceElement into ElementProps for the target iModel.
|
|
414
353
|
* @param sourceElement The Element from the source iModel to transform.
|
|
415
354
|
* @returns ElementProps for the target iModel.
|
|
@@ -428,47 +367,75 @@ export declare class IModelTransformer extends IModelExportHandler {
|
|
|
428
367
|
static convertHelmertToTransform(helmert: Helmert2DWithZOffset | undefined): Transform;
|
|
429
368
|
calculateTransformFromHelmertTransforms(): Transform | undefined;
|
|
430
369
|
private _deletedSourceRelationshipData?;
|
|
370
|
+
/** Target relationship ids and target endpoint keys of [[_deletedSourceRelationshipData]] entries, for fast matching in [[onExportRelationship]]. */
|
|
371
|
+
private _pendingRelationshipDeleteTargets;
|
|
372
|
+
/** Target relationships that this run imported from a source relationship and that a pending relationship delete also resolves to.
|
|
373
|
+
* A source relationship deleted and recreated with the same endpoints maps to the same target relationship, which must not be deleted.
|
|
374
|
+
*/
|
|
375
|
+
private _reimportedTargetRelationshipIds;
|
|
431
376
|
/** Returns true if a change within sourceElement is detected.
|
|
432
377
|
* @param sourceElement The Element from the source iModel
|
|
433
378
|
* @note A subclass can override this method to provide custom change detection behavior.
|
|
379
|
+
* @note During change processing, elements not present in the changeset are short-circuited
|
|
380
|
+
* in the exporter before reaching this method. To add elements to the changeset programmatically,
|
|
381
|
+
* use [[addCustomChanges]] rather than overriding this method to expand processing.
|
|
434
382
|
*/
|
|
435
383
|
protected hasElementChanged(sourceElement: Element): boolean;
|
|
436
384
|
protected completePartiallyCommittedElements(): Promise<void>;
|
|
437
385
|
protected completePartiallyCommittedAspects(): Promise<void>;
|
|
386
|
+
/** An exported source element or model exists, so later references to it need no source query.
|
|
387
|
+
* Aspects are not recorded: they are rarely referenced, and they are usually the largest group.
|
|
388
|
+
*/
|
|
389
|
+
private markSourceEntityExists;
|
|
438
390
|
private doAllReferencesExistInTarget;
|
|
439
|
-
|
|
391
|
+
/** Assert that all `referenceIds` exist in the source iModel, batching the existence
|
|
392
|
+
* queries by entity type and caching positive results for the rest of the run.
|
|
393
|
+
*/
|
|
394
|
+
private assertReferencesExistInSource;
|
|
440
395
|
/** Cause the specified Element and its child Elements (if applicable) to be exported from the source iModel and imported into the target iModel.
|
|
441
396
|
* @param sourceElementId Identifies the Element from the source iModel to import.
|
|
442
397
|
* @note This method is called from [[process]], so it only needs to be called directly when processing a subset of an iModel.
|
|
398
|
+
* @note After composing subset processing calls, call [[IModelImporter.finalize]] before saving target changes.
|
|
443
399
|
*/
|
|
444
400
|
processElement(sourceElementId: Id64String): Promise<void>;
|
|
445
401
|
/** Import child elements into the target IModelDb
|
|
446
402
|
* @param sourceElementId Import the child elements of this element in the source IModelDb.
|
|
447
403
|
* @note This method is called from [[process]], so it only needs to be called directly when processing a subset of an iModel.
|
|
404
|
+
* @note After composing subset processing calls, call [[IModelImporter.finalize]] before saving target changes.
|
|
448
405
|
*/
|
|
449
406
|
processChildElements(sourceElementId: Id64String): Promise<void>;
|
|
407
|
+
private processScopedElementExport;
|
|
450
408
|
/** Override of [IModelExportHandler.shouldExportElement]($transformer) that is called to determine if an element should be exported from the source iModel.
|
|
451
409
|
* @note Reaching this point means that the element has passed the standard exclusion checks in IModelExporter.
|
|
452
410
|
*/
|
|
453
|
-
shouldExportElement(_sourceElement: Element): boolean
|
|
411
|
+
shouldExportElement(_sourceElement: Element): Promise<boolean>;
|
|
454
412
|
/**
|
|
455
413
|
* If they haven't been already, import all of the required references
|
|
456
414
|
* @internal do not call, override or implement this, it will be removed
|
|
457
415
|
*/
|
|
458
416
|
preExportElement(sourceElement: Element): Promise<void>;
|
|
417
|
+
/** Makes sure an element that a changed element requires is mapped in the target before the changed element is imported.
|
|
418
|
+
* A changed required element is exported. An unchanged one is only looked up in the target: change processing does not insert it, and exporting it would visit its children, which can include the element that requires it.
|
|
419
|
+
* @throws [[IModelTransformerError.DependencyMappingMissing]] if the required element is still not mapped.
|
|
420
|
+
*/
|
|
421
|
+
private resolveRequiredElement;
|
|
422
|
+
/** Finds the existing target element for a source element by FederationGuid, then by Code, and records the mapping.
|
|
423
|
+
* @note Updates `targetElementProps.code` as the Code lookup requires.
|
|
424
|
+
* @returns the target element's id, or `Id64.invalid` if none is found.
|
|
425
|
+
*/
|
|
426
|
+
private findExistingTargetElement;
|
|
459
427
|
private getElemTransformState;
|
|
428
|
+
private queryElementIdByCode;
|
|
460
429
|
/** Override of [IModelExportHandler.onExportElement]($transformer) that imports an element into the target iModel when it is exported from the source iModel.
|
|
461
430
|
* This override calls [[onTransformElement]] and then [IModelImporter.importElement]($transformer) to update the target iModel.
|
|
462
431
|
*/
|
|
463
432
|
onExportElement(sourceElement: Element): Promise<void>;
|
|
464
|
-
/**
|
|
465
|
-
|
|
466
|
-
*/
|
|
467
|
-
onDeleteElement(sourceElementId: Id64String): void;
|
|
433
|
+
/** Maps the deleted source element IDs and passes the target IDs to the importer as one set. */
|
|
434
|
+
onDeleteElements(sourceElementIds: ReadonlySet<Id64String>): Promise<void>;
|
|
468
435
|
/** Override of [IModelExportHandler.onExportModel]($transformer) that is called when a Model should be exported from the source iModel.
|
|
469
436
|
* This override calls [[onTransformModel]] and then [IModelImporter.importModel]($transformer) to update the target iModel.
|
|
470
437
|
*/
|
|
471
|
-
onExportModel(sourceModel: Model): void
|
|
438
|
+
onExportModel(sourceModel: Model): Promise<void>;
|
|
472
439
|
/** Override of [IModelExportHandler.onDeleteModel]($transformer) that is called when [IModelExporter]($transformer) detects that a [Model]($backend) has been deleted from the source iModel. */
|
|
473
440
|
onDeleteModel(sourceModelId: Id64String): Promise<void>;
|
|
474
441
|
/** Schedule modeled partition deletion */
|
|
@@ -476,6 +443,7 @@ export declare class IModelTransformer extends IModelExportHandler {
|
|
|
476
443
|
/** Cause the model container, contents, and sub-models to be exported from the source iModel and imported into the target iModel.
|
|
477
444
|
* @param sourceModeledElementId Import this [Model]($backend) from the source IModelDb.
|
|
478
445
|
* @note This method is called from [[process]], so it only needs to be called directly when processing a subset of an iModel.
|
|
446
|
+
* @note After composing subset processing calls, call [[IModelImporter.finalize]] before saving target changes.
|
|
479
447
|
*/
|
|
480
448
|
processModel(sourceModeledElementId: Id64String): Promise<void>;
|
|
481
449
|
/** Cause the model contents to be exported from the source iModel and imported into the target iModel.
|
|
@@ -483,6 +451,7 @@ export declare class IModelTransformer extends IModelExportHandler {
|
|
|
483
451
|
* @param targetModelId Import into this model in the target IModelDb. The target model must exist prior to this call.
|
|
484
452
|
* @param elementClassFullName Optional classFullName of an element subclass to limit import query against the source model.
|
|
485
453
|
* @note This method is called from [[process]], so it only needs to be called directly when processing a subset of an iModel.
|
|
454
|
+
* @note After composing subset processing calls, call [[IModelImporter.finalize]] before saving target changes.
|
|
486
455
|
*/
|
|
487
456
|
processModelContents(sourceModelId: Id64String, targetModelId: Id64String, elementClassFullName?: string): Promise<void>;
|
|
488
457
|
/** Cause all sub-models that recursively descend from the specified Subject to be exported from the source iModel and imported into the target iModel. */
|
|
@@ -494,59 +463,39 @@ export declare class IModelTransformer extends IModelExportHandler {
|
|
|
494
463
|
* @note A subclass can override this method to provide custom transform behavior.
|
|
495
464
|
*/
|
|
496
465
|
onTransformModel(sourceModel: Model, targetModeledElementId: Id64String): ModelProps;
|
|
497
|
-
/**
|
|
498
|
-
* Called at the end of a transformation,
|
|
499
|
-
* updates the target scope element to say that transformation up through the
|
|
500
|
-
* source's changeset has been performed. Also stores all changesets that occurred
|
|
501
|
-
* during the transformation as "pending synchronization changeset indices" @see TargetScopeProvenanceJsonProps
|
|
502
|
-
*
|
|
503
|
-
* You generally should not call this function yourself and use [[process]] with [[IModelTransformOptions.argsForProcessChanges]] provided instead.
|
|
504
|
-
* It is public for unsupported use cases of custom synchronization transforms.
|
|
505
|
-
* @note If [[IModelTransformOptions.argsForProcessChanges]] is not defined in this transformation, this function will return early without updating the sync version,
|
|
506
|
-
* unless the `initializeReverseSyncVersion` option is set to `true`
|
|
507
|
-
*
|
|
508
|
-
* The `initializeReverseSyncVersion` is added to set the reverse synchronization version during a forward synchronization.
|
|
509
|
-
* When set to `true`, it saves the reverse sync version as the current changeset of the targetDb. This is typically used for the first transformation between a master and branch iModel.
|
|
510
|
-
* Setting `initializeReverseSyncVersion` to `true` has the effect of making it so any changesets in the branch iModel at the time of the first transformation will be ignored during any future reverse synchronizations from the branch to the master iModel.
|
|
511
|
-
*
|
|
512
|
-
* Note that typically, the reverseSyncVersion is saved as the last changeset merged from the branch into master.
|
|
513
|
-
* Setting initializeReverseSyncVersion to true during a forward transformation could overwrite this correct reverseSyncVersion and should only be done during the first transformation between a master and branch iModel.
|
|
514
|
-
*/
|
|
515
|
-
updateSynchronizationVersion({ initializeReverseSyncVersion, }?: {
|
|
516
|
-
initializeReverseSyncVersion?: boolean | undefined;
|
|
517
|
-
}): Promise<void>;
|
|
466
|
+
/** Complete a high-level transformation after all export operations finish. */
|
|
518
467
|
private finalizeTransformation;
|
|
468
|
+
private setCodeValueBehavior;
|
|
519
469
|
/** Imports all relationships that subclass from the specified base class.
|
|
520
470
|
* @param baseRelClassFullName The specified base relationship class.
|
|
521
471
|
* @note This method is called from [[process]], so it only needs to be called directly when processing a subset of an iModel.
|
|
472
|
+
* @note After composing subset processing calls, call [[IModelImporter.finalize]] before saving target changes.
|
|
522
473
|
*/
|
|
523
474
|
processRelationships(baseRelClassFullName: string): Promise<void>;
|
|
524
475
|
/** Override of [IModelExportHandler.shouldExportRelationship]($transformer) that is called to determine if a [Relationship]($backend) should be exported.
|
|
525
476
|
* @note Reaching this point means that the relationship has passed the standard exclusion checks in [IModelExporter]($transformer).
|
|
526
477
|
*/
|
|
527
|
-
shouldExportRelationship(_sourceRelationship: Relationship): boolean
|
|
478
|
+
shouldExportRelationship(_sourceRelationship: Relationship): Promise<boolean>;
|
|
528
479
|
/** Override of [IModelExportHandler.onExportRelationship]($transformer) that imports a relationship into the target iModel when it is exported from the source iModel.
|
|
529
480
|
* This override calls [[onTransformRelationship]] and then [IModelImporter.importRelationship]($transformer) to update the target iModel.
|
|
481
|
+
* @param endpointFedGuids The FederationGuids of the relationship's source and target elements, as supplied by [[IModelExporter]]. If `undefined`, both are looked up in the source iModel when provenance needs them.
|
|
482
|
+
* @note Overrides should pass `endpointFedGuids` to `super`. If it is omitted, the transformer looks up both endpoint FederationGuids for every relationship, which is slower.
|
|
530
483
|
*/
|
|
531
|
-
onExportRelationship(sourceRelationship: Relationship): Promise<void>;
|
|
484
|
+
onExportRelationship(sourceRelationship: Relationship, _isUpdate?: boolean, endpointFedGuids?: RelationshipEndpointFederationGuids): Promise<void>;
|
|
485
|
+
/** Returns whether both relationship endpoints have a FederationGuid, looking them up only when the caller did not supply them. */
|
|
486
|
+
private relationshipEndpointsHaveFedGuids;
|
|
532
487
|
/** Override of [IModelExportHandler.onDeleteRelationship]($transformer) that is called when [IModelExporter]($transformer) detects that a [Relationship]($backend) has been deleted from the source iModel.
|
|
533
488
|
* This override propagates the delete to the target iModel via [IModelImporter.deleteRelationship]($transformer).
|
|
534
489
|
*/
|
|
535
490
|
onDeleteRelationship(sourceRelInstanceId: Id64String): Promise<void>;
|
|
536
|
-
private _yieldManager;
|
|
537
|
-
/** Detect Relationship deletes using ExternalSourceAspects in the target iModel and a *brute force* comparison against relationships in the source iModel.
|
|
538
|
-
* @deprecated in 1.x. Don't use this anymore
|
|
539
|
-
* @see [[process]] with [[IModelTransformOptions.argsForProcessChanges]] provided.
|
|
540
|
-
* @note This method is called from [[process]] when [[IModelTransformOptions.argsForProcessChanges]] are undefined, so it only needs to be called directly when processing a subset of an iModel.
|
|
541
|
-
* @throws [[IModelError]] If the required provenance information is not available to detect deletes.
|
|
542
|
-
*/
|
|
543
491
|
/** Transform the specified sourceRelationship into RelationshipProps for the target iModel.
|
|
544
492
|
* @param sourceRelationship The Relationship from the source iModel to be transformed.
|
|
545
493
|
* @returns RelationshipProps for the target iModel.
|
|
546
494
|
* @note A subclass can override this method to provide custom transform behavior.
|
|
547
495
|
*/
|
|
548
496
|
protected onTransformRelationship(sourceRelationship: Relationship): RelationshipProps;
|
|
549
|
-
shouldExportElementAspect(aspect: ElementAspect): boolean
|
|
497
|
+
shouldExportElementAspect(aspect: ElementAspect): Promise<boolean>;
|
|
498
|
+
private prepareElementAspects;
|
|
550
499
|
/** Override of [IModelExportHandler.onExportElementUniqueAspect]($transformer) that imports an ElementUniqueAspect into the target iModel when it is exported from the source iModel.
|
|
551
500
|
* This override calls [[onTransformElementAspect]] and then [IModelImporter.importElementUniqueAspect]($transformer) to update the target iModel.
|
|
552
501
|
*/
|
|
@@ -567,29 +516,25 @@ export declare class IModelTransformer extends IModelExportHandler {
|
|
|
567
516
|
/** Override of [IModelExportHandler.shouldExportSchema]($transformer) that is called to determine if a schema should be exported
|
|
568
517
|
* @note the default behavior doesn't import schemas older than those already in the target
|
|
569
518
|
*/
|
|
570
|
-
shouldExportSchema(schemaKey: ECSchemaMetaData.SchemaKey): boolean
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
*
|
|
574
|
-
* @returns {Promise<ExportSchemaResult>} Although the type is possibly void for backwards compatibility of subclasses,
|
|
575
|
-
* `IModelTransformer.onExportSchema` always returns an[[IModelExportHandler.ExportSchemaResult]]
|
|
576
|
-
* with a defined `schemaPath` property, for subclasses to know where the schema was written.
|
|
577
|
-
* Schemas are *not* guaranteed to be written to [[IModelTransformer._schemaExportDir]] by a
|
|
578
|
-
* known pattern derivable from the schema's name, so you must use this to find it.
|
|
519
|
+
shouldExportSchema(schemaKey: ECSchemaMetaData.SchemaKey): Promise<boolean>;
|
|
520
|
+
/** Serialize a source schema to the temporary directory used by [[processSchemas]].
|
|
521
|
+
* @returns A path to the serialized schema file.
|
|
522
|
+
* @note The file name is not derived reliably from the schema name. Use the returned path when a subclass calls `super`.
|
|
579
523
|
*/
|
|
580
524
|
onExportSchema(schema: ECSchemaMetaData.Schema): Promise<void | ExportSchemaResult>;
|
|
581
|
-
|
|
582
|
-
|
|
525
|
+
/** Process source schemas and import selected or generated definitions into the target iModel.
|
|
526
|
+
* @param options Selects the schema processing strategy.
|
|
527
|
+
* @note When no strategy is supplied, [[NewerVersionSchemaImportStrategy]] is used.
|
|
583
528
|
* @note For performance reasons, it is recommended that [IModelDb.saveChanges]($backend) be called after `processSchemas` is complete.
|
|
584
529
|
* It is more efficient to process *data* changes after the schema changes have been saved.
|
|
585
530
|
*/
|
|
586
|
-
processSchemas(): Promise<void>;
|
|
531
|
+
processSchemas(options?: ProcessSchemasOptions): Promise<void>;
|
|
587
532
|
/** Cause all fonts to be exported from the source iModel and imported into the target iModel.
|
|
588
533
|
* @note This method is called from [[process]], so it only needs to be called directly when processing a subset of an iModel.
|
|
589
534
|
*/
|
|
590
535
|
processFonts(): Promise<void>;
|
|
591
536
|
/** Override of [IModelExportHandler.onExportFont]($transformer) that imports a font into the target iModel when it is exported from the source iModel. */
|
|
592
|
-
onExportFont(font: FontProps, _isUpdate: boolean | undefined): void
|
|
537
|
+
onExportFont(font: FontProps, _isUpdate: boolean | undefined): Promise<void>;
|
|
593
538
|
/** Cause all CodeSpecs to be exported from the source iModel and imported into the target iModel.
|
|
594
539
|
* @note This method is called from [[process]], so it only needs to be called directly when processing a subset of an iModel.
|
|
595
540
|
*/
|
|
@@ -601,16 +546,17 @@ export declare class IModelTransformer extends IModelExportHandler {
|
|
|
601
546
|
/** Override of [IModelExportHandler.shouldExportCodeSpec]($transformer) that is called to determine if a CodeSpec should be exported from the source iModel.
|
|
602
547
|
* @note Reaching this point means that the CodeSpec has passed the standard exclusion checks in [IModelExporter]($transformer).
|
|
603
548
|
*/
|
|
604
|
-
shouldExportCodeSpec(_sourceCodeSpec: CodeSpec): boolean
|
|
549
|
+
shouldExportCodeSpec(_sourceCodeSpec: CodeSpec): Promise<boolean>;
|
|
605
550
|
/** Override of [IModelExportHandler.onExportCodeSpec]($transformer) that imports a CodeSpec into the target iModel when it is exported from the source iModel. */
|
|
606
|
-
onExportCodeSpec(sourceCodeSpec: CodeSpec): void
|
|
607
|
-
/** Recursively import all Elements and sub-Models that descend from the specified Subject
|
|
551
|
+
onExportCodeSpec(sourceCodeSpec: CodeSpec): Promise<void>;
|
|
552
|
+
/** Recursively import all Elements and sub-Models that descend from the specified Subject.
|
|
553
|
+
* @note After composing subset processing calls, call [[IModelImporter.finalize]] before saving target changes.
|
|
554
|
+
*/
|
|
608
555
|
processSubject(sourceSubjectId: Id64String, targetSubjectId: Id64String): Promise<void>;
|
|
609
556
|
/** state to prevent reinitialization, @see [[initialize]] */
|
|
610
557
|
private _initialized;
|
|
611
558
|
private _sourceChangeDataState;
|
|
612
|
-
|
|
613
|
-
private _csFileProps?;
|
|
559
|
+
private _deletionBatches?;
|
|
614
560
|
/**
|
|
615
561
|
* Initialize prerequisites of processing, you must initialize with an [[InitOptions]] if you
|
|
616
562
|
* are intending to process changes. Callers may wish to explicitly call initialize if they need to execute code after initialize but before [[process]] is called.
|
|
@@ -618,13 +564,34 @@ export declare class IModelTransformer extends IModelExportHandler {
|
|
|
618
564
|
* Overriders must call `super.initialize()` first
|
|
619
565
|
*/
|
|
620
566
|
initialize(): Promise<void>;
|
|
567
|
+
private initializeChangesetScanAndExporter;
|
|
621
568
|
/**
|
|
622
|
-
* Reads
|
|
623
|
-
*
|
|
624
|
-
*
|
|
625
|
-
*
|
|
569
|
+
* Reads the source changes for the changeset ranges being processed. Override to supply changes from another
|
|
570
|
+
* source, such as a precomputed cache, instead of downloading and reading changesets.
|
|
571
|
+
*
|
|
572
|
+
* An override can supply some ranges itself and pass the rest to `super.collectChanges()`. Pass the same
|
|
573
|
+
* `changedInstanceIds` to every call and handle the ranges in order, so that changes to the same instance in
|
|
574
|
+
* different ranges combine correctly. Use [[ChangedInstanceIds.addChangeRecord]] to add each supplied change.
|
|
575
|
+
* See [Supplying source changes]($docs/learning/transformer/change-scanning.md) for the full contract and an example.
|
|
576
|
+
* @param ranges Ordered, inclusive `[first, last]` changeset index ranges. They already exclude changesets
|
|
577
|
+
* that must be skipped, such as those pushed by a previous synchronization in the other direction, so an
|
|
578
|
+
* override must cover exactly these ranges.
|
|
579
|
+
* @param changedInstanceIds Receives the changes read from the ranges. Defaults to a new, empty instance.
|
|
580
|
+
* @returns The changed instance IDs to export and the records used to find the targets of deleted instances.
|
|
581
|
+
* See [[CollectedChanges]] for what the result must include.
|
|
582
|
+
* @note The default implementation downloads the changesets, reads them with `ChangesetReader`, and returns one
|
|
583
|
+
* deletion batch per range.
|
|
584
|
+
* @note Not called when the exporter already has changed instance IDs, for example when `changedInstanceIds`
|
|
585
|
+
* is passed in [[IModelTransformOptions.argsForProcessChanges]]. The transformer then still downloads and reads
|
|
586
|
+
* the changesets to find deletion records.
|
|
587
|
+
* @beta
|
|
588
|
+
*/
|
|
589
|
+
protected collectChanges(ranges: readonly (readonly [number, number])[], changedInstanceIds?: ChangedInstanceIds): Promise<CollectedChanges>;
|
|
590
|
+
/**
|
|
591
|
+
* Remaps tracked elements, adds custom changes, and remaps deleted source entities to their targets using the
|
|
592
|
+
* deletion batches read for the changeset ranges being processed.
|
|
626
593
|
*/
|
|
627
|
-
private
|
|
594
|
+
private prepareSourceChanges;
|
|
628
595
|
/**
|
|
629
596
|
* This will be called when transformer is called with [[IModelTransformOptions.argsForProcessChanges]] to process changes.
|
|
630
597
|
* It will be executed after changes in changesets are populated into `sourceDbChanges` and before data processing begins.
|
|
@@ -635,17 +602,33 @@ export declare class IModelTransformer extends IModelExportHandler {
|
|
|
635
602
|
*/
|
|
636
603
|
protected addCustomChanges(_sourceDbChanges: ChangedInstanceIds): Promise<void>;
|
|
637
604
|
/**
|
|
638
|
-
*
|
|
639
|
-
*
|
|
640
|
-
*
|
|
641
|
-
*
|
|
642
|
-
* @param
|
|
605
|
+
* Finds the target ID of a source element while processing deletions, first through the transformation's
|
|
606
|
+
* ExternalSourceAspects when the source holds the provenance, then through the federation GUID. The element may be
|
|
607
|
+
* deleted itself, or be a surviving endpoint of a deleted relationship.
|
|
608
|
+
* @param sourceId the source element ID.
|
|
609
|
+
* @param federationGuid the source element's federation GUID, if known.
|
|
610
|
+
* @param deletedScopeEsaByElementId this transformation scope's deleted ESAs in the same batch, keyed by the ID of the element that owned each one.
|
|
611
|
+
*/
|
|
612
|
+
private findTargetElementIdForDeletion;
|
|
613
|
+
/**
|
|
614
|
+
* Helper function for [[prepareSourceChanges]]. Records how to find the target relationship of a deleted source relationship.
|
|
615
|
+
* @param deletion the deleted source relationship.
|
|
616
|
+
* @param deletedScopeEsaByElementId this transformation scope's deleted ESAs in the same batch, keyed by the ID of the element that owned each one.
|
|
617
|
+
* @param deletedFederationGuidByElementId federation GUIDs of the elements deleted in the same batch, for endpoints that no longer exist in the source.
|
|
618
|
+
*/
|
|
619
|
+
private processDeletedRelationship;
|
|
620
|
+
/**
|
|
621
|
+
* Helper function for [[prepareSourceChanges]]. Remaps a deleted source element or model to its target.
|
|
622
|
+
* @param sourceId the deleted source element or model.
|
|
623
|
+
* @param federationGuid the deleted source element's federation GUID, if it had one. Undefined for models.
|
|
624
|
+
* @param deletedScopeEsaByElementId this transformation scope's deleted ESAs in the same batch, keyed by the ID of the element that owned each one.
|
|
643
625
|
* @param alreadyImportedElementInserts used to handle entity recreation and not delete already handled element inserts.
|
|
644
626
|
* @param alreadyImportedModelInserts used to handle entity recreation and not delete already handled model inserts.
|
|
645
|
-
* @returns void
|
|
646
627
|
*/
|
|
647
|
-
private
|
|
628
|
+
private processDeletedElement;
|
|
648
629
|
private _tryInitChangesetData;
|
|
630
|
+
/** Asserts that the EditTxn is active before any write operations. */
|
|
631
|
+
private assertEditTxnActive;
|
|
649
632
|
/**
|
|
650
633
|
* The behavior of process is influenced by [[IModelTransformOptions.argsForProcessChanges]] being defined or not defined during construction passed of the IModelTransformer.
|
|
651
634
|
* @section When argsForProcessChanges are defined:
|
|
@@ -674,9 +657,6 @@ export declare class IModelTransformer extends IModelExportHandler {
|
|
|
674
657
|
* @note [[processSchemas]] is not called automatically since the target iModel may want a different collection of schemas.
|
|
675
658
|
*/
|
|
676
659
|
private processAll;
|
|
677
|
-
/** previous provenance, either a federation guid, a `${sourceFedGuid}/${targetFedGuid}` pair, or required aspect props */
|
|
678
|
-
private _lastProvenanceEntityInfo;
|
|
679
|
-
private markLastProvenance;
|
|
680
660
|
/** Export changes from the source iModel and import the transformed entities into the target iModel.
|
|
681
661
|
* Inserts, updates, and deletes are determined by inspecting the changeset(s).
|
|
682
662
|
* @note the transformer assumes that you saveChanges after processing changes. You should not
|
|
@@ -707,12 +687,10 @@ export declare class TemplateModelCloner extends IModelTransformer {
|
|
|
707
687
|
/** Accumulates the mapping of sourceElementIds to targetElementIds from the elements in the template model that were cloned. */
|
|
708
688
|
private _sourceIdToTargetIdMap?;
|
|
709
689
|
/** Construct a new TemplateModelCloner
|
|
710
|
-
* @param
|
|
711
|
-
* @param targetDb Optionally specify the target IModelDb where the cloned template will be inserted.
|
|
712
|
-
* Typically this is left unspecified, and the default is to use the sourceDb as the target
|
|
690
|
+
* @param editTxn The [[EditTxn]] to use for all read and write operations. The source and target db are both derived from `editTxn.iModel`. Must be started before constructing.
|
|
713
691
|
* @note The expectation is that the template definitions are within the same iModel where instances will be placed.
|
|
714
692
|
*/
|
|
715
|
-
constructor(
|
|
693
|
+
constructor(editTxn: EditTxn);
|
|
716
694
|
/** Place a template from the sourceDb at the specified placement in the target model within the targetDb.
|
|
717
695
|
* @param sourceTemplateModelId The Id of the template model in the sourceDb
|
|
718
696
|
* @param targetModelId The Id of the target model (must be a subclass of GeometricModel3d) where the cloned component will be inserted.
|