@itwin/imodel-transformer 2.0.0-dev.2 → 2.0.0-dev.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -1
- package/lib/cjs/BranchProvenanceInitializer.js +18 -15
- package/lib/cjs/BranchProvenanceInitializer.js.map +1 -1
- package/lib/cjs/DetachedExportElementAspectsStrategy.d.ts.map +1 -1
- package/lib/cjs/DetachedExportElementAspectsStrategy.js +8 -6
- package/lib/cjs/DetachedExportElementAspectsStrategy.js.map +1 -1
- package/lib/cjs/ECReferenceTypesCache.d.ts +3 -0
- package/lib/cjs/ECReferenceTypesCache.d.ts.map +1 -1
- package/lib/cjs/ECReferenceTypesCache.js +103 -40
- package/lib/cjs/ECReferenceTypesCache.js.map +1 -1
- package/lib/cjs/ElementCascadingDeleter.d.ts.map +1 -1
- package/lib/cjs/ElementCascadingDeleter.js +10 -9
- package/lib/cjs/ElementCascadingDeleter.js.map +1 -1
- package/lib/cjs/EntityUnifier.d.ts +1 -1
- package/lib/cjs/EntityUnifier.d.ts.map +1 -1
- package/lib/cjs/EntityUnifier.js +11 -12
- package/lib/cjs/EntityUnifier.js.map +1 -1
- package/lib/cjs/ExportElementAspectsStrategy.d.ts +4 -4
- package/lib/cjs/ExportElementAspectsStrategy.d.ts.map +1 -1
- package/lib/cjs/ExportElementAspectsStrategy.js +1 -1
- package/lib/cjs/ExportElementAspectsStrategy.js.map +1 -1
- package/lib/cjs/ExportElementAspectsWithElementsStrategy.d.ts.map +1 -1
- package/lib/cjs/ExportElementAspectsWithElementsStrategy.js +17 -16
- package/lib/cjs/ExportElementAspectsWithElementsStrategy.js.map +1 -1
- package/lib/cjs/IModelCloneContext.d.ts +3 -3
- package/lib/cjs/IModelCloneContext.d.ts.map +1 -1
- package/lib/cjs/IModelCloneContext.js +60 -52
- package/lib/cjs/IModelCloneContext.js.map +1 -1
- package/lib/cjs/IModelExporter.d.ts +28 -19
- package/lib/cjs/IModelExporter.d.ts.map +1 -1
- package/lib/cjs/IModelExporter.js +145 -119
- package/lib/cjs/IModelExporter.js.map +1 -1
- package/lib/cjs/IModelImporter.d.ts +21 -21
- package/lib/cjs/IModelImporter.d.ts.map +1 -1
- package/lib/cjs/IModelImporter.js +94 -74
- package/lib/cjs/IModelImporter.js.map +1 -1
- package/lib/cjs/IModelTransformer.d.ts +84 -178
- package/lib/cjs/IModelTransformer.d.ts.map +1 -1
- package/lib/cjs/IModelTransformer.js +371 -997
- package/lib/cjs/IModelTransformer.js.map +1 -1
- package/lib/cjs/ProvenanceManager.d.ts +159 -0
- package/lib/cjs/ProvenanceManager.d.ts.map +1 -0
- package/lib/cjs/ProvenanceManager.js +677 -0
- package/lib/cjs/ProvenanceManager.js.map +1 -0
- package/lib/cjs/SyncTypeResolver.d.ts +34 -0
- package/lib/cjs/SyncTypeResolver.d.ts.map +1 -0
- package/lib/cjs/SyncTypeResolver.js +84 -0
- package/lib/cjs/SyncTypeResolver.js.map +1 -0
- package/lib/cjs/TransformerLoggerCategory.d.ts +6 -5
- package/lib/cjs/TransformerLoggerCategory.d.ts.map +1 -1
- package/lib/cjs/TransformerLoggerCategory.js +6 -5
- package/lib/cjs/TransformerLoggerCategory.js.map +1 -1
- package/lib/cjs/imodel-transformer.js +2 -2
- package/lib/cjs/imodel-transformer.js.map +1 -1
- package/package.json +38 -33
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { Id64String } from "@itwin/core-bentley";
|
|
2
|
+
import { type Entity, ExternalSourceAspect, IModelDb } from "@itwin/core-backend";
|
|
3
|
+
import { ChangesetIndexAndId, ExternalSourceAspectProps } from "@itwin/core-common";
|
|
4
|
+
import type { IModelTransformOptions } from "./IModelTransformer";
|
|
5
|
+
import type { SyncTypeResolver } from "./SyncTypeResolver";
|
|
6
|
+
import type { IModelCloneContext } from "./IModelCloneContext";
|
|
7
|
+
/**
|
|
8
|
+
* Manages provenance scope aspects and synchronization versioning.
|
|
9
|
+
* Encapsulates all ESA scope management, sync version tracking, and
|
|
10
|
+
* provenance DB direction logic extracted from IModelTransformer.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export declare class ProvenanceManager {
|
|
14
|
+
readonly context: IModelCloneContext;
|
|
15
|
+
private readonly _targetScopeElementId;
|
|
16
|
+
private readonly _transformerOptions;
|
|
17
|
+
private readonly _syncTypeResolver;
|
|
18
|
+
private readonly _startingChangesetIndices?;
|
|
19
|
+
/** NOTE: the json properties must be converted to string before insertion */
|
|
20
|
+
private _targetScopeProvenanceProps;
|
|
21
|
+
private _cachedSynchronizationVersion;
|
|
22
|
+
private _targetClassNameToClassIdCache;
|
|
23
|
+
constructor(targetScopeElementId: Id64String, transformerOptions: IModelTransformOptions, syncTypeResolver: SyncTypeResolver);
|
|
24
|
+
private _isReverseSynchronization;
|
|
25
|
+
private _queryTargetRelId;
|
|
26
|
+
private _targetClassNameToClassId;
|
|
27
|
+
private _getRelClassId;
|
|
28
|
+
/** The element classes that are considered to define provenance in the iModel */
|
|
29
|
+
static get provenanceElementClasses(): (typeof Entity)[];
|
|
30
|
+
/** The element aspect classes that are considered to define provenance in the iModel */
|
|
31
|
+
static get provenanceElementAspectClasses(): (typeof Entity)[];
|
|
32
|
+
/**
|
|
33
|
+
* Iterate all matching federation guids and ExternalSourceAspects in the provenance iModel (target unless reverse sync)
|
|
34
|
+
* and call a function for each one.
|
|
35
|
+
* @note provenance is done by federation guids where possible
|
|
36
|
+
* @note this may execute on each element more than once! Only use in cases where that is handled
|
|
37
|
+
*/
|
|
38
|
+
static forEachTrackedElement(args: {
|
|
39
|
+
provenanceSourceDb: IModelDb;
|
|
40
|
+
provenanceDb: IModelDb;
|
|
41
|
+
targetScopeElementId: Id64String;
|
|
42
|
+
isReverseSynchronization: boolean;
|
|
43
|
+
fn: (sourceElementId: Id64String, targetElementId: Id64String) => void;
|
|
44
|
+
skipPropagateChangesToRootElements: boolean;
|
|
45
|
+
}): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Queries for an ESA which matches the props in the provided aspectProps.
|
|
48
|
+
* @param dbToQuery db to run the query on
|
|
49
|
+
* @param aspectProps aspectProps to search for
|
|
50
|
+
*/
|
|
51
|
+
static queryScopeExternalSourceAspect(dbToQuery: IModelDb, aspectProps: ExternalSourceAspectProps): Promise<{
|
|
52
|
+
aspectId: Id64String;
|
|
53
|
+
version?: string;
|
|
54
|
+
/** stringified json */
|
|
55
|
+
jsonProperties?: string;
|
|
56
|
+
} | undefined>;
|
|
57
|
+
/** Return the IModelDb where provenance is stored.
|
|
58
|
+
* This will be targetDb except when it is a reverse synchronization, in which case it will be sourceDb.
|
|
59
|
+
*/
|
|
60
|
+
private getProvenanceDb;
|
|
61
|
+
/** Return the IModelDb where entities referred to by stored provenance live.
|
|
62
|
+
* This will be sourceDb except when it is a reverse synchronization, in which case it will be targetDb.
|
|
63
|
+
*/
|
|
64
|
+
getProvenanceSourceDb(): Promise<IModelDb>;
|
|
65
|
+
/**
|
|
66
|
+
* @returns provenance scope aspect if it exists in the provenanceDb.
|
|
67
|
+
* Provenance scope aspect is created and inserted into provenanceDb when [[initScopeProvenance]] is invoked.
|
|
68
|
+
*/
|
|
69
|
+
tryGetProvenanceScopeAspect(): Promise<ExternalSourceAspect | undefined>;
|
|
70
|
+
/**
|
|
71
|
+
* Make sure there are no conflicting other scope-type external source aspects on the target scope element.
|
|
72
|
+
* If there are none at all, insert one (this must be a first synchronization).
|
|
73
|
+
*/
|
|
74
|
+
initScopeProvenance(): Promise<void>;
|
|
75
|
+
/** Returns true if a change was made to the aspectProps. */
|
|
76
|
+
private handleUnsafeMigrate;
|
|
77
|
+
/**
|
|
78
|
+
* We cache the synchronization version to avoid querying the target scoping ESA multiple times.
|
|
79
|
+
* Clears the cached value so the next call to getSynchronizationVersion re-queries.
|
|
80
|
+
*/
|
|
81
|
+
clearCachedSynchronizationVersion(): void;
|
|
82
|
+
/** The changeset version in the scoping element's source version found for this transformation.
|
|
83
|
+
* @note the version depends on whether this is a reverse synchronization or not.
|
|
84
|
+
* @note empty string and -1 for changeset and index if it has never been transformed.
|
|
85
|
+
*/
|
|
86
|
+
getSynchronizationVersion(): Promise<ChangesetIndexAndId>;
|
|
87
|
+
/**
|
|
88
|
+
* Returns the pending changeset indices to skip for the current synchronization direction.
|
|
89
|
+
* Used by changeset initialization to determine which changesets have already been processed.
|
|
90
|
+
*/
|
|
91
|
+
getChangesetsToSkip(): Promise<number[]>;
|
|
92
|
+
/**
|
|
93
|
+
* Updates the synchronization version on the scope ESA.
|
|
94
|
+
*
|
|
95
|
+
* Called at the end of a transformation, updates the target scope element to record
|
|
96
|
+
* that transformation up through the source's changeset has been performed. Also stores
|
|
97
|
+
* all changesets that occurred during the transformation as "pending synchronization
|
|
98
|
+
* changeset indices" @see TargetScopeProvenanceJsonProps
|
|
99
|
+
*
|
|
100
|
+
* @param initializeReverseSyncVersion When true, saves the reverse sync version as the
|
|
101
|
+
* current changeset of the targetDb. This is typically used for the first transformation
|
|
102
|
+
* between a master and branch iModel. Setting this to true has the effect of making it so
|
|
103
|
+
* any changesets in the branch iModel at the time of the first transformation will be
|
|
104
|
+
* ignored during any future reverse synchronizations from the branch to the master iModel.
|
|
105
|
+
*
|
|
106
|
+
* Note that typically, the reverseSyncVersion is saved as the last changeset merged from
|
|
107
|
+
* the branch into master. Setting initializeReverseSyncVersion to true during a forward
|
|
108
|
+
* transformation could overwrite this correct reverseSyncVersion and should only be done
|
|
109
|
+
* during the first transformation between a master and branch iModel.
|
|
110
|
+
*
|
|
111
|
+
* @param sourceChangeDataState The current state of change data — used to skip updates
|
|
112
|
+
* when there are no changes.
|
|
113
|
+
*/
|
|
114
|
+
updateSynchronizationVersion({ initializeReverseSyncVersion, sourceChangeDataState, }: {
|
|
115
|
+
initializeReverseSyncVersion?: boolean;
|
|
116
|
+
sourceChangeDataState: "uninited" | "has-changes" | "no-changes" | "unconnected";
|
|
117
|
+
}): Promise<void>;
|
|
118
|
+
/** Create ExternalSourceAspectProps for an element in an iModel → iModel transformation. */
|
|
119
|
+
static initElementProvenanceOptions(sourceElementId: Id64String, targetElementId: Id64String, args: {
|
|
120
|
+
sourceDb: IModelDb;
|
|
121
|
+
targetDb: IModelDb;
|
|
122
|
+
isReverseSynchronization: boolean;
|
|
123
|
+
targetScopeElementId: Id64String;
|
|
124
|
+
}): ExternalSourceAspectProps;
|
|
125
|
+
/** Create ExternalSourceAspectProps for a relationship in an iModel → iModel transformation. */
|
|
126
|
+
static initRelationshipProvenanceOptions(sourceRelInstanceId: Id64String, targetRelInstanceId: Id64String, args: {
|
|
127
|
+
sourceDb: IModelDb;
|
|
128
|
+
targetDb: IModelDb;
|
|
129
|
+
isReverseSynchronization: boolean;
|
|
130
|
+
targetScopeElementId: Id64String;
|
|
131
|
+
forceOldRelationshipProvenanceMethod: boolean;
|
|
132
|
+
}): Promise<ExternalSourceAspectProps>;
|
|
133
|
+
/** Create an ExternalSourceAspectProps for an element using this manager's context. */
|
|
134
|
+
initElementProvenance(sourceElementId: Id64String, targetElementId: Id64String): Promise<ExternalSourceAspectProps>;
|
|
135
|
+
/** Create an ExternalSourceAspectProps for a relationship using this manager's context. */
|
|
136
|
+
initRelationshipProvenance(sourceRelInstanceId: Id64String, targetRelInstanceId: Id64String, forceOldRelationshipProvenanceMethod: boolean): Promise<ExternalSourceAspectProps>;
|
|
137
|
+
/**
|
|
138
|
+
* Queries the provenanceDb for an ESA whose identifier matches the provided element ID.
|
|
139
|
+
* @param entityInProvenanceSourceId ID of the element in the provenanceSourceDb
|
|
140
|
+
*/
|
|
141
|
+
queryProvenanceForElement(entityInProvenanceSourceId: Id64String): Promise<Id64String | undefined>;
|
|
142
|
+
/**
|
|
143
|
+
* Queries the provenanceDb for an ESA whose identifier matches the provided relationship ID.
|
|
144
|
+
* @param entityInProvenanceSourceId ID of the relationship in the provenanceSourceDb
|
|
145
|
+
* @param sourceRelInfo Source relationship class and endpoint info (for legacy fallback)
|
|
146
|
+
*/
|
|
147
|
+
queryProvenanceForRelationship(entityInProvenanceSourceId: Id64String, sourceRelInfo: {
|
|
148
|
+
classFullName: string;
|
|
149
|
+
sourceId: Id64String;
|
|
150
|
+
targetId: Id64String;
|
|
151
|
+
}): Promise<{
|
|
152
|
+
aspectId: Id64String;
|
|
153
|
+
/** if undefined, the relationship could not be found, perhaps it was deleted */
|
|
154
|
+
relationshipId: Id64String | undefined;
|
|
155
|
+
} | undefined>;
|
|
156
|
+
/** Instance convenience that calls the static forEachTrackedElement with this manager's context. */
|
|
157
|
+
forEachTrackedElement(fn: (sourceElementId: Id64String, targetElementId: Id64String) => void): Promise<void>;
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=ProvenanceManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProvenanceManager.d.ts","sourceRoot":"","sources":["../../src/ProvenanceManager.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,UAAU,EAGX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAEL,KAAK,MAAM,EAEX,oBAAoB,EAGpB,QAAQ,EAET,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EAI1B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EACV,sBAAsB,EAEvB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAI/D;;;;;GAKG;AACH,qBAAa,iBAAiB;IAC5B,SAAgB,OAAO,EAAE,kBAAkB,CAAC;IAE5C,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAa;IACnD,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAyB;IAC7D,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAmB;IACrD,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAAC,CAGzC;IAEF,6EAA6E;IAC7E,OAAO,C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