@itwin/core-backend 3.4.0 → 3.4.1

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 (239) hide show
  1. package/CHANGELOG.md +8 -1
  2. package/lib/cjs/AliCloudStorageService.d.ts +23 -23
  3. package/lib/cjs/AliCloudStorageService.js +71 -71
  4. package/lib/cjs/AliCloudStorageService.js.map +1 -1
  5. package/lib/cjs/BackendHubAccess.d.ts +224 -224
  6. package/lib/cjs/BackendHubAccess.js +41 -41
  7. package/lib/cjs/BackendHubAccess.js.map +1 -1
  8. package/lib/cjs/BackendLoggerCategory.d.ts +91 -91
  9. package/lib/cjs/BackendLoggerCategory.js +99 -99
  10. package/lib/cjs/BackendLoggerCategory.js.map +1 -1
  11. package/lib/cjs/BisCoreSchema.d.ts +21 -21
  12. package/lib/cjs/BisCoreSchema.js +60 -60
  13. package/lib/cjs/BisCoreSchema.js.map +1 -1
  14. package/lib/cjs/BriefcaseManager.d.ts +165 -165
  15. package/lib/cjs/BriefcaseManager.js +405 -405
  16. package/lib/cjs/BriefcaseManager.js.map +1 -1
  17. package/lib/cjs/Category.d.ts +153 -153
  18. package/lib/cjs/Category.js +243 -243
  19. package/lib/cjs/Category.js.map +1 -1
  20. package/lib/cjs/ChangeSummaryManager.d.ts +187 -187
  21. package/lib/cjs/ChangeSummaryManager.js +445 -445
  22. package/lib/cjs/ChangeSummaryManager.js.map +1 -1
  23. package/lib/cjs/ChangedElementsDb.d.ts +99 -99
  24. package/lib/cjs/ChangedElementsDb.js +165 -165
  25. package/lib/cjs/ChangedElementsDb.js.map +1 -1
  26. package/lib/cjs/ChangedElementsManager.d.ts +39 -39
  27. package/lib/cjs/ChangedElementsManager.js +88 -88
  28. package/lib/cjs/ChangedElementsManager.js.map +1 -1
  29. package/lib/cjs/CheckpointManager.d.ts +120 -120
  30. package/lib/cjs/CheckpointManager.js +343 -343
  31. package/lib/cjs/CheckpointManager.js.map +1 -1
  32. package/lib/cjs/ClassRegistry.d.ts +72 -71
  33. package/lib/cjs/ClassRegistry.d.ts.map +1 -1
  34. package/lib/cjs/ClassRegistry.js +243 -215
  35. package/lib/cjs/ClassRegistry.js.map +1 -1
  36. package/lib/cjs/CloudSqlite.d.ts +349 -349
  37. package/lib/cjs/CloudSqlite.js +151 -151
  38. package/lib/cjs/CloudSqlite.js.map +1 -1
  39. package/lib/cjs/CloudStorageBackend.d.ts +58 -58
  40. package/lib/cjs/CloudStorageBackend.js +173 -173
  41. package/lib/cjs/CloudStorageBackend.js.map +1 -1
  42. package/lib/cjs/CodeService.d.ts +396 -396
  43. package/lib/cjs/CodeService.js +63 -63
  44. package/lib/cjs/CodeService.js.map +1 -1
  45. package/lib/cjs/CodeSpecs.d.ts +50 -50
  46. package/lib/cjs/CodeSpecs.js +112 -112
  47. package/lib/cjs/CodeSpecs.js.map +1 -1
  48. package/lib/cjs/ConcurrentQuery.d.ts +11 -11
  49. package/lib/cjs/ConcurrentQuery.js +30 -30
  50. package/lib/cjs/ConcurrentQuery.js.map +1 -1
  51. package/lib/cjs/CustomViewState3dCreator.d.ts +32 -32
  52. package/lib/cjs/CustomViewState3dCreator.js +113 -113
  53. package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
  54. package/lib/cjs/DevTools.d.ts +71 -71
  55. package/lib/cjs/DevTools.js +154 -154
  56. package/lib/cjs/DevTools.js.map +1 -1
  57. package/lib/cjs/DisplayStyle.d.ts +106 -106
  58. package/lib/cjs/DisplayStyle.d.ts.map +1 -1
  59. package/lib/cjs/DisplayStyle.js +256 -256
  60. package/lib/cjs/DisplayStyle.js.map +1 -1
  61. package/lib/cjs/ECDb.d.ts +191 -191
  62. package/lib/cjs/ECDb.js +350 -350
  63. package/lib/cjs/ECDb.js.map +1 -1
  64. package/lib/cjs/ECSchemaXmlContext.d.ts +18 -18
  65. package/lib/cjs/ECSchemaXmlContext.js +41 -41
  66. package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
  67. package/lib/cjs/ECSqlStatement.d.ts +466 -466
  68. package/lib/cjs/ECSqlStatement.js +791 -791
  69. package/lib/cjs/ECSqlStatement.js.map +1 -1
  70. package/lib/cjs/Element.d.ts +1120 -1109
  71. package/lib/cjs/Element.d.ts.map +1 -1
  72. package/lib/cjs/Element.js +1438 -1420
  73. package/lib/cjs/Element.js.map +1 -1
  74. package/lib/cjs/ElementAspect.d.ts +158 -156
  75. package/lib/cjs/ElementAspect.d.ts.map +1 -1
  76. package/lib/cjs/ElementAspect.js +186 -178
  77. package/lib/cjs/ElementAspect.js.map +1 -1
  78. package/lib/cjs/ElementGraphics.d.ts +9 -9
  79. package/lib/cjs/ElementGraphics.js +41 -41
  80. package/lib/cjs/ElementGraphics.js.map +1 -1
  81. package/lib/cjs/ElementTreeWalker.d.ts +162 -162
  82. package/lib/cjs/ElementTreeWalker.js +409 -409
  83. package/lib/cjs/ElementTreeWalker.js.map +1 -1
  84. package/lib/cjs/Entity.d.ts +106 -76
  85. package/lib/cjs/Entity.d.ts.map +1 -1
  86. package/lib/cjs/Entity.js +134 -82
  87. package/lib/cjs/Entity.js.map +1 -1
  88. package/lib/cjs/EntityReferences.d.ts +46 -0
  89. package/lib/cjs/EntityReferences.d.ts.map +1 -0
  90. package/lib/cjs/EntityReferences.js +92 -0
  91. package/lib/cjs/EntityReferences.js.map +1 -0
  92. package/lib/cjs/ExportGraphics.d.ts +317 -317
  93. package/lib/cjs/ExportGraphics.js +208 -208
  94. package/lib/cjs/ExportGraphics.js.map +1 -1
  95. package/lib/cjs/ExternalSource.d.ts +96 -94
  96. package/lib/cjs/ExternalSource.d.ts.map +1 -1
  97. package/lib/cjs/ExternalSource.js +131 -125
  98. package/lib/cjs/ExternalSource.js.map +1 -1
  99. package/lib/cjs/GeoCoordConfig.d.ts +19 -19
  100. package/lib/cjs/GeoCoordConfig.js +82 -82
  101. package/lib/cjs/GeoCoordConfig.js.map +1 -1
  102. package/lib/cjs/GeometrySummary.d.ts +4 -4
  103. package/lib/cjs/GeometrySummary.js +380 -380
  104. package/lib/cjs/GeometrySummary.js.map +1 -1
  105. package/lib/cjs/HubMock.d.ts +93 -93
  106. package/lib/cjs/HubMock.js +190 -190
  107. package/lib/cjs/HubMock.js.map +1 -1
  108. package/lib/cjs/IModelCloneContext.d.ts +89 -85
  109. package/lib/cjs/IModelCloneContext.d.ts.map +1 -1
  110. package/lib/cjs/IModelCloneContext.js +159 -150
  111. package/lib/cjs/IModelCloneContext.js.map +1 -1
  112. package/lib/cjs/IModelDb.d.ts +1164 -1164
  113. package/lib/cjs/IModelDb.d.ts.map +1 -1
  114. package/lib/cjs/IModelDb.js +2324 -2324
  115. package/lib/cjs/IModelDb.js.map +1 -1
  116. package/lib/cjs/IModelHost.d.ts +361 -361
  117. package/lib/cjs/IModelHost.js +489 -489
  118. package/lib/cjs/IModelHost.js.map +1 -1
  119. package/lib/cjs/IModelJsFs.d.ts +62 -62
  120. package/lib/cjs/IModelJsFs.js +140 -140
  121. package/lib/cjs/IModelJsFs.js.map +1 -1
  122. package/lib/cjs/IpcHost.d.ts +98 -98
  123. package/lib/cjs/IpcHost.js +234 -234
  124. package/lib/cjs/IpcHost.js.map +1 -1
  125. package/lib/cjs/LineStyle.d.ts +311 -311
  126. package/lib/cjs/LineStyle.js +295 -295
  127. package/lib/cjs/LineStyle.js.map +1 -1
  128. package/lib/cjs/LocalHub.d.ts +162 -162
  129. package/lib/cjs/LocalHub.js +587 -587
  130. package/lib/cjs/LocalHub.js.map +1 -1
  131. package/lib/cjs/LocalhostIpcHost.d.ts +20 -20
  132. package/lib/cjs/LocalhostIpcHost.js +81 -81
  133. package/lib/cjs/LocalhostIpcHost.js.map +1 -1
  134. package/lib/cjs/Material.d.ts +103 -103
  135. package/lib/cjs/Material.js +147 -147
  136. package/lib/cjs/Material.js.map +1 -1
  137. package/lib/cjs/Model.d.ts +388 -386
  138. package/lib/cjs/Model.d.ts.map +1 -1
  139. package/lib/cjs/Model.js +479 -471
  140. package/lib/cjs/Model.js.map +1 -1
  141. package/lib/cjs/NativeAppStorage.d.ts +51 -51
  142. package/lib/cjs/NativeAppStorage.js +202 -202
  143. package/lib/cjs/NativeAppStorage.js.map +1 -1
  144. package/lib/cjs/NativeHost.d.ts +52 -52
  145. package/lib/cjs/NativeHost.js +168 -168
  146. package/lib/cjs/NativeHost.js.map +1 -1
  147. package/lib/cjs/NavigationRelationship.d.ts +156 -156
  148. package/lib/cjs/NavigationRelationship.js +225 -225
  149. package/lib/cjs/NavigationRelationship.js.map +1 -1
  150. package/lib/cjs/PromiseMemoizer.d.ts +51 -51
  151. package/lib/cjs/PromiseMemoizer.js +101 -101
  152. package/lib/cjs/PromiseMemoizer.js.map +1 -1
  153. package/lib/cjs/PropertyStore.d.ts +132 -132
  154. package/lib/cjs/PropertyStore.js +11 -11
  155. package/lib/cjs/PropertyStore.js.map +1 -1
  156. package/lib/cjs/Relationship.d.ts +416 -400
  157. package/lib/cjs/Relationship.d.ts.map +1 -1
  158. package/lib/cjs/Relationship.js +494 -465
  159. package/lib/cjs/Relationship.js.map +1 -1
  160. package/lib/cjs/RpcBackend.d.ts +28 -28
  161. package/lib/cjs/RpcBackend.js +126 -126
  162. package/lib/cjs/RpcBackend.js.map +1 -1
  163. package/lib/cjs/SQLiteDb.d.ts +219 -219
  164. package/lib/cjs/SQLiteDb.js +214 -214
  165. package/lib/cjs/SQLiteDb.js.map +1 -1
  166. package/lib/cjs/Schema.d.ts +55 -55
  167. package/lib/cjs/Schema.js +83 -83
  168. package/lib/cjs/Schema.js.map +1 -1
  169. package/lib/cjs/ServerBasedLocks.d.ts +57 -57
  170. package/lib/cjs/ServerBasedLocks.js +168 -168
  171. package/lib/cjs/ServerBasedLocks.js.map +1 -1
  172. package/lib/cjs/SqliteStatement.d.ts +283 -283
  173. package/lib/cjs/SqliteStatement.js +448 -448
  174. package/lib/cjs/SqliteStatement.js.map +1 -1
  175. package/lib/cjs/Texture.d.ts +58 -58
  176. package/lib/cjs/Texture.js +82 -82
  177. package/lib/cjs/Texture.js.map +1 -1
  178. package/lib/cjs/TileStorage.d.ts +18 -18
  179. package/lib/cjs/TileStorage.js +90 -90
  180. package/lib/cjs/TileStorage.js.map +1 -1
  181. package/lib/cjs/TxnManager.d.ts +202 -202
  182. package/lib/cjs/TxnManager.js +356 -356
  183. package/lib/cjs/TxnManager.js.map +1 -1
  184. package/lib/cjs/ViewDefinition.d.ts +439 -435
  185. package/lib/cjs/ViewDefinition.d.ts.map +1 -1
  186. package/lib/cjs/ViewDefinition.js +646 -635
  187. package/lib/cjs/ViewDefinition.js.map +1 -1
  188. package/lib/cjs/ViewStateHydrator.d.ts +13 -13
  189. package/lib/cjs/ViewStateHydrator.js +103 -103
  190. package/lib/cjs/ViewStateHydrator.js.map +1 -1
  191. package/lib/cjs/assets/IModelChange.02.00.00.ecschema.xml +90 -90
  192. package/lib/cjs/assets/Settings/Schemas/Cloud.Schema.json +67 -67
  193. package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +31 -31
  194. package/lib/cjs/assets/Settings/Schemas/Workspace.Schema.json +52 -52
  195. package/lib/cjs/assets/Settings/backend.setting.json5 +138 -138
  196. package/lib/cjs/core-backend.d.ts +183 -182
  197. package/lib/cjs/core-backend.d.ts.map +1 -1
  198. package/lib/cjs/core-backend.js +203 -202
  199. package/lib/cjs/core-backend.js.map +1 -1
  200. package/lib/cjs/domains/FunctionalElements.d.ts +101 -101
  201. package/lib/cjs/domains/FunctionalElements.js +145 -145
  202. package/lib/cjs/domains/FunctionalElements.js.map +1 -1
  203. package/lib/cjs/domains/FunctionalSchema.d.ts +13 -13
  204. package/lib/cjs/domains/FunctionalSchema.js +40 -40
  205. package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
  206. package/lib/cjs/domains/GenericElements.d.ts +177 -177
  207. package/lib/cjs/domains/GenericElements.js +263 -263
  208. package/lib/cjs/domains/GenericElements.js.map +1 -1
  209. package/lib/cjs/domains/GenericSchema.d.ts +10 -10
  210. package/lib/cjs/domains/GenericSchema.js +28 -28
  211. package/lib/cjs/domains/GenericSchema.js.map +1 -1
  212. package/lib/cjs/rpc-impl/DevToolsRpcImpl.d.ts +15 -15
  213. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js +32 -32
  214. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js.map +1 -1
  215. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +45 -45
  216. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +262 -262
  217. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  218. package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts +22 -22
  219. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +204 -204
  220. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
  221. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts +36 -36
  222. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +168 -168
  223. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  224. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.d.ts +16 -16
  225. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js +43 -43
  226. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
  227. package/lib/cjs/rpc-impl/WipRpcImpl.d.ts +15 -15
  228. package/lib/cjs/rpc-impl/WipRpcImpl.js +37 -37
  229. package/lib/cjs/rpc-impl/WipRpcImpl.js.map +1 -1
  230. package/lib/cjs/workspace/Settings.d.ts +186 -186
  231. package/lib/cjs/workspace/Settings.js +155 -155
  232. package/lib/cjs/workspace/Settings.js.map +1 -1
  233. package/lib/cjs/workspace/SettingsSchemas.d.ts +75 -75
  234. package/lib/cjs/workspace/SettingsSchemas.js +191 -191
  235. package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
  236. package/lib/cjs/workspace/Workspace.d.ts +414 -414
  237. package/lib/cjs/workspace/Workspace.js +543 -543
  238. package/lib/cjs/workspace/Workspace.js.map +1 -1
  239. package/package.json +14 -13
@@ -1,86 +1,90 @@
1
- /** @packageDocumentation
2
- * @module iModels
3
- */
4
- import { Id64String } from "@itwin/core-bentley";
5
- import { ElementProps } from "@itwin/core-common";
6
- import { IModelJsNative } from "@bentley/imodeljs-native";
7
- import { Element } from "./Element";
8
- import { IModelDb } from "./IModelDb";
9
- import { SQLiteDb } from "./SQLiteDb";
10
- /** The context for transforming a *source* Element to a *target* Element and remapping internal identifiers to the target iModel.
11
- * @beta
12
- */
13
- export declare class IModelCloneContext {
14
- /** The source IModelDb. */
15
- readonly sourceDb: IModelDb;
16
- /** The target IModelDb. */
17
- readonly targetDb: IModelDb;
18
- /** The native import context */
19
- private _nativeContext;
20
- /** Construct a new IModelCloneContext.
21
- * @param sourceDb The source IModelDb.
22
- * @param targetDb If provided the target IModelDb. If not provided, the source and target are the same IModelDb.
23
- */
24
- constructor(sourceDb: IModelDb, targetDb?: IModelDb);
25
- /** Returns `true` if this context is for transforming between 2 iModels and `false` if it for transforming within the same iModel. */
26
- get isBetweenIModels(): boolean;
27
- /** Dispose any native resources associated with this IModelCloneContext. */
28
- dispose(): void;
29
- /** Debugging aid that dumps the Id remapping details and other information to the specified output file.
30
- * @internal
31
- */
32
- dump(outputFileName: string): void;
33
- /** Add a rule that remaps the specified source [CodeSpec]($common) to the specified target [CodeSpec]($common).
34
- * @param sourceCodeSpecName The name of the CodeSpec from the source iModel.
35
- * @param targetCodeSpecName The name of the CodeSpec from the target iModel.
36
- * @throws [[IModelError]] if either CodeSpec could not be found.
37
- */
38
- remapCodeSpec(sourceCodeSpecName: string, targetCodeSpecName: string): void;
39
- /** Add a rule that remaps the specified source class to the specified target class. */
40
- remapElementClass(sourceClassFullName: string, targetClassFullName: string): void;
41
- /** Add a rule that remaps the specified source Element to the specified target Element. */
42
- remapElement(sourceId: Id64String, targetId: Id64String): void;
43
- /** Remove a rule that remaps the specified source Element. */
44
- removeElement(sourceId: Id64String): void;
45
- /** Look up a target CodeSpecId from the source CodeSpecId.
46
- * @returns the target CodeSpecId or [Id64.invalid]($bentley) if a mapping not found.
47
- */
48
- findTargetCodeSpecId(sourceId: Id64String): Id64String;
49
- /** Look up a target ElementId from the source ElementId.
50
- * @returns the target ElementId or [Id64.invalid]($bentley) if a mapping not found.
51
- */
52
- findTargetElementId(sourceElementId: Id64String): Id64String;
53
- /** Filter out geometry entries in the specified SubCategory from GeometryStreams in the target iModel.
54
- * @note It is not possible to filter out a *default* SubCategory. A request to do so will be ignored.
55
- * @see [SubCategory.isDefaultSubCategory]($backend)
56
- */
57
- filterSubCategory(sourceSubCategoryId: Id64String): void;
58
- /** Returns `true` if there are any SubCategories being filtered. */
59
- get hasSubCategoryFilter(): boolean;
60
- /** Returns `true` if this SubCategory is being filtered. */
61
- isSubCategoryFiltered(subCategoryId: Id64String): boolean;
62
- /** Import the specified font from the source iModel into the target iModel.
63
- * @internal
64
- */
65
- importFont(sourceFontNumber: number): void;
66
- /** Import a single CodeSpec from the source iModel into the target iModel.
67
- * @internal
68
- */
69
- importCodeSpec(sourceCodeSpecId: Id64String): void;
70
- /** Clone the specified source Element into ElementProps for the target iModel.
71
- * @internal
72
- */
73
- cloneElement(sourceElement: Element, cloneOptions?: IModelJsNative.CloneElementOptions): ElementProps;
74
- /**
75
- * serialize state to a sqlite database at a given path
76
- * assumes the database has not already had any context state serialized to it
77
- * @internal
78
- */
79
- saveStateToDb(db: SQLiteDb): void;
80
- /**
81
- * load state from a sqlite database at a given path
82
- * @internal
83
- */
84
- loadStateFromDb(db: SQLiteDb): void;
85
- }
1
+ /** @packageDocumentation
2
+ * @module iModels
3
+ */
4
+ import { Id64String } from "@itwin/core-bentley";
5
+ import { ElementProps } from "@itwin/core-common";
6
+ import { IModelJsNative } from "@bentley/imodeljs-native";
7
+ import { Element } from "./Element";
8
+ import { IModelDb } from "./IModelDb";
9
+ import { SQLiteDb } from "./SQLiteDb";
10
+ /** The context for transforming a *source* Element to a *target* Element and remapping internal identifiers to the target iModel.
11
+ * @beta
12
+ */
13
+ export declare class IModelCloneContext {
14
+ /** The source IModelDb. */
15
+ readonly sourceDb: IModelDb;
16
+ /** The target IModelDb. */
17
+ readonly targetDb: IModelDb;
18
+ /** The native import context */
19
+ private _nativeContext;
20
+ /** Construct a new IModelCloneContext. It must be initialized with `initialize`, consider using [[IModelCloneContext.create]] instead
21
+ * @param sourceDb The source IModelDb.
22
+ * @param targetDb If provided the target IModelDb. If not provided, the source and target are the same IModelDb.
23
+ */
24
+ constructor(sourceDb: IModelDb, targetDb?: IModelDb);
25
+ /** @internal perform necessary initialization to use a clone context, namely caching the reference types in the source's schemas */
26
+ initialize(): Promise<void>;
27
+ /** @internal construct and initialize an IModelCloneContext at once, for where you construct in an async context */
28
+ static create(...args: ConstructorParameters<typeof IModelCloneContext>): Promise<IModelCloneContext>;
29
+ /** Returns `true` if this context is for transforming between 2 iModels and `false` if it for transforming within the same iModel. */
30
+ get isBetweenIModels(): boolean;
31
+ /** Dispose any native resources associated with this IModelCloneContext. */
32
+ dispose(): void;
33
+ /** Debugging aid that dumps the Id remapping details and other information to the specified output file.
34
+ * @internal
35
+ */
36
+ dump(outputFileName: string): void;
37
+ /** Add a rule that remaps the specified source [CodeSpec]($common) to the specified target [CodeSpec]($common).
38
+ * @param sourceCodeSpecName The name of the CodeSpec from the source iModel.
39
+ * @param targetCodeSpecName The name of the CodeSpec from the target iModel.
40
+ * @throws [[IModelError]] if either CodeSpec could not be found.
41
+ */
42
+ remapCodeSpec(sourceCodeSpecName: string, targetCodeSpecName: string): void;
43
+ /** Add a rule that remaps the specified source class to the specified target class. */
44
+ remapElementClass(sourceClassFullName: string, targetClassFullName: string): void;
45
+ /** Add a rule that remaps the specified source Element to the specified target Element. */
46
+ remapElement(sourceId: Id64String, targetId: Id64String): void;
47
+ /** Remove a rule that remaps the specified source Element. */
48
+ removeElement(sourceId: Id64String): void;
49
+ /** Look up a target CodeSpecId from the source CodeSpecId.
50
+ * @returns the target CodeSpecId or [Id64.invalid]($bentley) if a mapping not found.
51
+ */
52
+ findTargetCodeSpecId(sourceId: Id64String): Id64String;
53
+ /** Look up a target ElementId from the source ElementId.
54
+ * @returns the target ElementId or [Id64.invalid]($bentley) if a mapping not found.
55
+ */
56
+ findTargetElementId(sourceElementId: Id64String): Id64String;
57
+ /** Filter out geometry entries in the specified SubCategory from GeometryStreams in the target iModel.
58
+ * @note It is not possible to filter out a *default* SubCategory. A request to do so will be ignored.
59
+ * @see [SubCategory.isDefaultSubCategory]($backend)
60
+ */
61
+ filterSubCategory(sourceSubCategoryId: Id64String): void;
62
+ /** Returns `true` if there are any SubCategories being filtered. */
63
+ get hasSubCategoryFilter(): boolean;
64
+ /** Returns `true` if this SubCategory is being filtered. */
65
+ isSubCategoryFiltered(subCategoryId: Id64String): boolean;
66
+ /** Import the specified font from the source iModel into the target iModel.
67
+ * @internal
68
+ */
69
+ importFont(sourceFontNumber: number): void;
70
+ /** Import a single CodeSpec from the source iModel into the target iModel.
71
+ * @internal
72
+ */
73
+ importCodeSpec(sourceCodeSpecId: Id64String): void;
74
+ /** Clone the specified source Element into ElementProps for the target iModel.
75
+ * @internal
76
+ */
77
+ cloneElement(sourceElement: Element, cloneOptions?: IModelJsNative.CloneElementOptions): ElementProps;
78
+ /**
79
+ * serialize state to a sqlite database at a given path
80
+ * assumes the database has not already had any context state serialized to it
81
+ * @internal
82
+ */
83
+ saveStateToDb(db: SQLiteDb): void;
84
+ /**
85
+ * load state from a sqlite database at a given path
86
+ * @internal
87
+ */
88
+ loadStateFromDb(db: SQLiteDb): void;
89
+ }
86
90
  //# sourceMappingURL=IModelCloneContext.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"IModelCloneContext.d.ts","sourceRoot":"","sources":["../../src/IModelCloneContext.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,EAAQ,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAiC,YAAY,EAA4C,MAAM,oBAAoB,CAAC;AAC3H,OAAO,EAAE,cAAc,EAAE,MAAM,0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= void 0;
4
- /*---------------------------------------------------------------------------------------------
5
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
6
- * See LICENSE.md in the project root for license terms and full copyright notice.
7
- *--------------------------------------------------------------------------------------------*/
8
- /** @packageDocumentation
9
- * @module iModels
10
- */
11
- const core_bentley_1 = require("@itwin/core-bentley");
12
- const core_common_1 = require("@itwin/core-common");
13
- const Category_1 = require("./Category");
14
- const IModelHost_1 = require("./IModelHost");
15
- /** The context for transforming a *source* Element to a *target* Element and remapping internal identifiers to the target iModel.
16
- * @beta
17
- */
18
- class IModelCloneContext {
19
- /** Construct a new IModelCloneContext.
20
- * @param sourceDb The source IModelDb.
21
- * @param targetDb If provided the target IModelDb. If not provided, the source and target are the same IModelDb.
22
- */
23
- constructor(sourceDb, targetDb) {
24
- this.sourceDb = sourceDb;
25
- this.targetDb = (undefined !== targetDb) ? targetDb : sourceDb;
26
- this._nativeContext = new IModelHost_1.IModelHost.platform.ImportContext(this.sourceDb.nativeDb, this.targetDb.nativeDb);
27
- }
28
- /** Returns `true` if this context is for transforming between 2 iModels and `false` if it for transforming within the same iModel. */
29
- get isBetweenIModels() { return this.sourceDb !== this.targetDb; }
30
- /** Dispose any native resources associated with this IModelCloneContext. */
31
- dispose() { this._nativeContext.dispose(); }
32
- /** Debugging aid that dumps the Id remapping details and other information to the specified output file.
33
- * @internal
34
- */
35
- dump(outputFileName) { this._nativeContext.dump(outputFileName); }
36
- /** Add a rule that remaps the specified source [CodeSpec]($common) to the specified target [CodeSpec]($common).
37
- * @param sourceCodeSpecName The name of the CodeSpec from the source iModel.
38
- * @param targetCodeSpecName The name of the CodeSpec from the target iModel.
39
- * @throws [[IModelError]] if either CodeSpec could not be found.
40
- */
41
- remapCodeSpec(sourceCodeSpecName, targetCodeSpecName) {
42
- const sourceCodeSpec = this.sourceDb.codeSpecs.getByName(sourceCodeSpecName);
43
- const targetCodeSpec = this.targetDb.codeSpecs.getByName(targetCodeSpecName);
44
- this._nativeContext.addCodeSpecId(sourceCodeSpec.id, targetCodeSpec.id);
45
- }
46
- /** Add a rule that remaps the specified source class to the specified target class. */
47
- remapElementClass(sourceClassFullName, targetClassFullName) {
48
- this._nativeContext.addClass(sourceClassFullName, targetClassFullName);
49
- }
50
- /** Add a rule that remaps the specified source Element to the specified target Element. */
51
- remapElement(sourceId, targetId) {
52
- this._nativeContext.addElementId(sourceId, targetId);
53
- }
54
- /** Remove a rule that remaps the specified source Element. */
55
- removeElement(sourceId) {
56
- this._nativeContext.removeElementId(sourceId);
57
- }
58
- /** Look up a target CodeSpecId from the source CodeSpecId.
59
- * @returns the target CodeSpecId or [Id64.invalid]($bentley) if a mapping not found.
60
- */
61
- findTargetCodeSpecId(sourceId) {
62
- if (core_bentley_1.Id64.invalid === sourceId) {
63
- return core_bentley_1.Id64.invalid;
64
- }
65
- return this._nativeContext.findCodeSpecId(sourceId);
66
- }
67
- /** Look up a target ElementId from the source ElementId.
68
- * @returns the target ElementId or [Id64.invalid]($bentley) if a mapping not found.
69
- */
70
- findTargetElementId(sourceElementId) {
71
- if (core_bentley_1.Id64.invalid === sourceElementId) {
72
- return core_bentley_1.Id64.invalid;
73
- }
74
- return this._nativeContext.findElementId(sourceElementId);
75
- }
76
- /** Filter out geometry entries in the specified SubCategory from GeometryStreams in the target iModel.
77
- * @note It is not possible to filter out a *default* SubCategory. A request to do so will be ignored.
78
- * @see [SubCategory.isDefaultSubCategory]($backend)
79
- */
80
- filterSubCategory(sourceSubCategoryId) {
81
- const sourceSubCategory = this.sourceDb.elements.tryGetElement(sourceSubCategoryId, Category_1.SubCategory);
82
- if (sourceSubCategory && !sourceSubCategory.isDefaultSubCategory) {
83
- this._nativeContext.filterSubCategoryId(sourceSubCategoryId);
84
- }
85
- }
86
- /** Returns `true` if there are any SubCategories being filtered. */
87
- get hasSubCategoryFilter() {
88
- return this._nativeContext.hasSubCategoryFilter();
89
- }
90
- /** Returns `true` if this SubCategory is being filtered. */
91
- isSubCategoryFiltered(subCategoryId) {
92
- return this._nativeContext.isSubCategoryFiltered(subCategoryId);
93
- }
94
- /** Import the specified font from the source iModel into the target iModel.
95
- * @internal
96
- */
97
- importFont(sourceFontNumber) {
98
- this.targetDb.clearFontMap(); // so it will be reloaded with new font info
99
- this._nativeContext.importFont(sourceFontNumber);
100
- }
101
- /** Import a single CodeSpec from the source iModel into the target iModel.
102
- * @internal
103
- */
104
- importCodeSpec(sourceCodeSpecId) {
105
- this._nativeContext.importCodeSpec(sourceCodeSpecId);
106
- }
107
- /** Clone the specified source Element into ElementProps for the target iModel.
108
- * @internal
109
- */
110
- cloneElement(sourceElement, cloneOptions) {
111
- const targetElementProps = this._nativeContext.cloneElement(sourceElement.id, cloneOptions);
112
- // Ensure that all NavigationProperties in targetElementProps have a defined value so "clearing" changes will be part of the JSON used for update
113
- sourceElement.forEachProperty((propertyName, meta) => {
114
- if ((meta.isNavigation) && (undefined === sourceElement[propertyName])) {
115
- targetElementProps[propertyName] = core_common_1.RelatedElement.none;
116
- }
117
- }, false); // exclude custom because C++ has already handled them
118
- if (this.isBetweenIModels) {
119
- // The native C++ cloneElement strips off federationGuid, want to put it back if transformation is between iModels
120
- targetElementProps.federationGuid = sourceElement.federationGuid;
121
- if (core_common_1.CodeScopeSpec.Type.Repository === this.targetDb.codeSpecs.getById(targetElementProps.code.spec).scopeType) {
122
- targetElementProps.code.scope = core_common_1.IModel.rootSubjectId;
123
- }
124
- }
125
- // unlike other references, code cannot be null. If it is null, use an empty code instead
126
- if (targetElementProps.code.scope === core_bentley_1.Id64.invalid || targetElementProps.code.spec === core_bentley_1.Id64.invalid) {
127
- targetElementProps.code = core_common_1.Code.createEmpty();
128
- }
129
- const jsClass = this.sourceDb.getJsClass(sourceElement.classFullName);
130
- // eslint-disable-next-line @typescript-eslint/dot-notation
131
- jsClass["onCloned"](this, sourceElement.toJSON(), targetElementProps);
132
- return targetElementProps;
133
- }
134
- /**
135
- * serialize state to a sqlite database at a given path
136
- * assumes the database has not already had any context state serialized to it
137
- * @internal
138
- */
139
- saveStateToDb(db) {
140
- this._nativeContext.saveStateToDb(db.nativeDb);
141
- }
142
- /**
143
- * load state from a sqlite database at a given path
144
- * @internal
145
- */
146
- loadStateFromDb(db) {
147
- this._nativeContext.loadStateFromDb(db.nativeDb);
148
- }
149
- }
150
- exports.IModelCloneContext = IModelCloneContext;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IModelCloneContext = void 0;
4
+ /*---------------------------------------------------------------------------------------------
5
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
6
+ * See LICENSE.md in the project root for license terms and full copyright notice.
7
+ *--------------------------------------------------------------------------------------------*/
8
+ /** @packageDocumentation
9
+ * @module iModels
10
+ */
11
+ const core_bentley_1 = require("@itwin/core-bentley");
12
+ const core_common_1 = require("@itwin/core-common");
13
+ const Category_1 = require("./Category");
14
+ const IModelHost_1 = require("./IModelHost");
15
+ /** The context for transforming a *source* Element to a *target* Element and remapping internal identifiers to the target iModel.
16
+ * @beta
17
+ */
18
+ class IModelCloneContext {
19
+ /** Construct a new IModelCloneContext. It must be initialized with `initialize`, consider using [[IModelCloneContext.create]] instead
20
+ * @param sourceDb The source IModelDb.
21
+ * @param targetDb If provided the target IModelDb. If not provided, the source and target are the same IModelDb.
22
+ */
23
+ constructor(sourceDb, targetDb) {
24
+ this.sourceDb = sourceDb;
25
+ this.targetDb = (undefined !== targetDb) ? targetDb : sourceDb;
26
+ this._nativeContext = new IModelHost_1.IModelHost.platform.ImportContext(this.sourceDb.nativeDb, this.targetDb.nativeDb);
27
+ }
28
+ /** @internal perform necessary initialization to use a clone context, namely caching the reference types in the source's schemas */
29
+ async initialize() {
30
+ }
31
+ /** @internal construct and initialize an IModelCloneContext at once, for where you construct in an async context */
32
+ static async create(...args) {
33
+ const instance = new this(...args);
34
+ await instance.initialize();
35
+ return instance;
36
+ }
37
+ /** Returns `true` if this context is for transforming between 2 iModels and `false` if it for transforming within the same iModel. */
38
+ get isBetweenIModels() { return this.sourceDb !== this.targetDb; }
39
+ /** Dispose any native resources associated with this IModelCloneContext. */
40
+ dispose() { this._nativeContext.dispose(); }
41
+ /** Debugging aid that dumps the Id remapping details and other information to the specified output file.
42
+ * @internal
43
+ */
44
+ dump(outputFileName) { this._nativeContext.dump(outputFileName); }
45
+ /** Add a rule that remaps the specified source [CodeSpec]($common) to the specified target [CodeSpec]($common).
46
+ * @param sourceCodeSpecName The name of the CodeSpec from the source iModel.
47
+ * @param targetCodeSpecName The name of the CodeSpec from the target iModel.
48
+ * @throws [[IModelError]] if either CodeSpec could not be found.
49
+ */
50
+ remapCodeSpec(sourceCodeSpecName, targetCodeSpecName) {
51
+ const sourceCodeSpec = this.sourceDb.codeSpecs.getByName(sourceCodeSpecName);
52
+ const targetCodeSpec = this.targetDb.codeSpecs.getByName(targetCodeSpecName);
53
+ this._nativeContext.addCodeSpecId(sourceCodeSpec.id, targetCodeSpec.id);
54
+ }
55
+ /** Add a rule that remaps the specified source class to the specified target class. */
56
+ remapElementClass(sourceClassFullName, targetClassFullName) {
57
+ this._nativeContext.addClass(sourceClassFullName, targetClassFullName);
58
+ }
59
+ /** Add a rule that remaps the specified source Element to the specified target Element. */
60
+ remapElement(sourceId, targetId) {
61
+ this._nativeContext.addElementId(sourceId, targetId);
62
+ }
63
+ /** Remove a rule that remaps the specified source Element. */
64
+ removeElement(sourceId) {
65
+ this._nativeContext.removeElementId(sourceId);
66
+ }
67
+ /** Look up a target CodeSpecId from the source CodeSpecId.
68
+ * @returns the target CodeSpecId or [Id64.invalid]($bentley) if a mapping not found.
69
+ */
70
+ findTargetCodeSpecId(sourceId) {
71
+ if (core_bentley_1.Id64.invalid === sourceId) {
72
+ return core_bentley_1.Id64.invalid;
73
+ }
74
+ return this._nativeContext.findCodeSpecId(sourceId);
75
+ }
76
+ /** Look up a target ElementId from the source ElementId.
77
+ * @returns the target ElementId or [Id64.invalid]($bentley) if a mapping not found.
78
+ */
79
+ findTargetElementId(sourceElementId) {
80
+ if (core_bentley_1.Id64.invalid === sourceElementId) {
81
+ return core_bentley_1.Id64.invalid;
82
+ }
83
+ return this._nativeContext.findElementId(sourceElementId);
84
+ }
85
+ /** Filter out geometry entries in the specified SubCategory from GeometryStreams in the target iModel.
86
+ * @note It is not possible to filter out a *default* SubCategory. A request to do so will be ignored.
87
+ * @see [SubCategory.isDefaultSubCategory]($backend)
88
+ */
89
+ filterSubCategory(sourceSubCategoryId) {
90
+ const sourceSubCategory = this.sourceDb.elements.tryGetElement(sourceSubCategoryId, Category_1.SubCategory);
91
+ if (sourceSubCategory && !sourceSubCategory.isDefaultSubCategory) {
92
+ this._nativeContext.filterSubCategoryId(sourceSubCategoryId);
93
+ }
94
+ }
95
+ /** Returns `true` if there are any SubCategories being filtered. */
96
+ get hasSubCategoryFilter() {
97
+ return this._nativeContext.hasSubCategoryFilter();
98
+ }
99
+ /** Returns `true` if this SubCategory is being filtered. */
100
+ isSubCategoryFiltered(subCategoryId) {
101
+ return this._nativeContext.isSubCategoryFiltered(subCategoryId);
102
+ }
103
+ /** Import the specified font from the source iModel into the target iModel.
104
+ * @internal
105
+ */
106
+ importFont(sourceFontNumber) {
107
+ this.targetDb.clearFontMap(); // so it will be reloaded with new font info
108
+ this._nativeContext.importFont(sourceFontNumber);
109
+ }
110
+ /** Import a single CodeSpec from the source iModel into the target iModel.
111
+ * @internal
112
+ */
113
+ importCodeSpec(sourceCodeSpecId) {
114
+ this._nativeContext.importCodeSpec(sourceCodeSpecId);
115
+ }
116
+ /** Clone the specified source Element into ElementProps for the target iModel.
117
+ * @internal
118
+ */
119
+ cloneElement(sourceElement, cloneOptions) {
120
+ const targetElementProps = this._nativeContext.cloneElement(sourceElement.id, cloneOptions);
121
+ // Ensure that all NavigationProperties in targetElementProps have a defined value so "clearing" changes will be part of the JSON used for update
122
+ sourceElement.forEachProperty((propertyName, meta) => {
123
+ if ((meta.isNavigation) && (undefined === sourceElement[propertyName])) {
124
+ targetElementProps[propertyName] = core_common_1.RelatedElement.none;
125
+ }
126
+ }, false); // exclude custom because C++ has already handled them
127
+ if (this.isBetweenIModels) {
128
+ // The native C++ cloneElement strips off federationGuid, want to put it back if transformation is between iModels
129
+ targetElementProps.federationGuid = sourceElement.federationGuid;
130
+ if (core_common_1.CodeScopeSpec.Type.Repository === this.targetDb.codeSpecs.getById(targetElementProps.code.spec).scopeType) {
131
+ targetElementProps.code.scope = core_common_1.IModel.rootSubjectId;
132
+ }
133
+ }
134
+ // unlike other references, code cannot be null. If it is null, use an empty code instead
135
+ if (targetElementProps.code.scope === core_bentley_1.Id64.invalid || targetElementProps.code.spec === core_bentley_1.Id64.invalid) {
136
+ targetElementProps.code = core_common_1.Code.createEmpty();
137
+ }
138
+ const jsClass = this.sourceDb.getJsClass(sourceElement.classFullName);
139
+ // eslint-disable-next-line @typescript-eslint/dot-notation
140
+ jsClass["onCloned"](this, sourceElement.toJSON(), targetElementProps);
141
+ return targetElementProps;
142
+ }
143
+ /**
144
+ * serialize state to a sqlite database at a given path
145
+ * assumes the database has not already had any context state serialized to it
146
+ * @internal
147
+ */
148
+ saveStateToDb(db) {
149
+ this._nativeContext.saveStateToDb(db.nativeDb);
150
+ }
151
+ /**
152
+ * load state from a sqlite database at a given path
153
+ * @internal
154
+ */
155
+ loadStateFromDb(db) {
156
+ this._nativeContext.loadStateFromDb(db.nativeDb);
157
+ }
158
+ }
159
+ exports.IModelCloneContext = IModelCloneContext;
151
160
  //# sourceMappingURL=IModelCloneContext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"IModelCloneContext.js","sourceRoot":"","sources":["../../src/IModelCloneContext.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,sDAAuD;AACvD,oDAA2H;AAE3H,yCAAyC;AAGzC,6CAA0C;AAG1C;;GAEG;AACH,MAAa,kBAAkB;IAQ7B;;;OAGG;IACH,YAAmB,QAAkB,EAAE,QAAmB;QACxD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GA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AA2D;QAC3D,OAAO,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,aAAa,CAAC,MAAM,EAAE,EAAE,kBAAkB,CAAC,CAAC;QACtE,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACI,aAAa,CAAC,EAAY;QAC/B,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;IACjD,CAAC;IAED;;;OAGG;IACI,eAAe,CAAC,EAAY;QACjC,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;IACnD,CAAC;CACF;AA3JD,gDA2JC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module iModels\r\n */\r\nimport { Id64, Id64String } from \"@itwin/core-bentley\";\r\nimport { Code, CodeScopeSpec, CodeSpec, ElementProps, IModel, PropertyMetaData, RelatedElement } from \"@itwin/core-common\";\r\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\nimport { SubCategory } from \"./Category\";\r\nimport { Element } from \"./Element\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { IModelHost } from \"./IModelHost\";\r\nimport { SQLiteDb } from \"./SQLiteDb\";\r\n\r\n/** The context for transforming a *source* Element to a *target* Element and remapping internal identifiers to the target iModel.\r\n * @beta\r\n */\r\nexport class IModelCloneContext {\r\n /** The source IModelDb. */\r\n public readonly sourceDb: IModelDb;\r\n /** The target IModelDb. */\r\n public readonly targetDb: IModelDb;\r\n /** The native import context */\r\n private _nativeContext: IModelJsNative.ImportContext;\r\n\r\n /** Construct a new IModelCloneContext.\r\n * @param sourceDb The source IModelDb.\r\n * @param targetDb If provided the target IModelDb. If not provided, the source and target are the same IModelDb.\r\n */\r\n public constructor(sourceDb: IModelDb, targetDb?: IModelDb) {\r\n this.sourceDb = sourceDb;\r\n this.targetDb = (undefined !== targetDb) ? targetDb : sourceDb;\r\n this._nativeContext = new IModelHost.platform.ImportContext(this.sourceDb.nativeDb, this.targetDb.nativeDb);\r\n }\r\n\r\n /** Returns `true` if this context is for transforming between 2 iModels and `false` if it for transforming within the same iModel. */\r\n public get isBetweenIModels(): boolean { return this.sourceDb !== this.targetDb; }\r\n\r\n /** Dispose any native resources associated with this IModelCloneContext. */\r\n public dispose(): void { this._nativeContext.dispose(); }\r\n\r\n /** Debugging aid that dumps the Id remapping details and other information to the specified output file.\r\n * @internal\r\n */\r\n public dump(outputFileName: string): void { this._nativeContext.dump(outputFileName); }\r\n\r\n /** Add a rule that remaps the specified source [CodeSpec]($common) to the specified target [CodeSpec]($common).\r\n * @param sourceCodeSpecName The name of the CodeSpec from the source iModel.\r\n * @param targetCodeSpecName The name of the CodeSpec from the target iModel.\r\n * @throws [[IModelError]] if either CodeSpec could not be found.\r\n */\r\n public remapCodeSpec(sourceCodeSpecName: string, targetCodeSpecName: string): void {\r\n const sourceCodeSpec: CodeSpec = this.sourceDb.codeSpecs.getByName(sourceCodeSpecName);\r\n const targetCodeSpec: CodeSpec = this.targetDb.codeSpecs.getByName(targetCodeSpecName);\r\n this._nativeContext.addCodeSpecId(sourceCodeSpec.id, targetCodeSpec.id);\r\n }\r\n\r\n /** Add a rule that remaps the specified source class to the specified target class. */\r\n public remapElementClass(sourceClassFullName: string, targetClassFullName: string): void {\r\n this._nativeContext.addClass(sourceClassFullName, targetClassFullName);\r\n }\r\n\r\n /** Add a rule that remaps the specified source Element to the specified target Element. */\r\n public remapElement(sourceId: Id64String, targetId: Id64String): void {\r\n this._nativeContext.addElementId(sourceId, targetId);\r\n }\r\n\r\n /** Remove a rule that remaps the specified source Element. */\r\n public removeElement(sourceId: Id64String): void {\r\n this._nativeContext.removeElementId(sourceId);\r\n }\r\n\r\n /** Look up a target CodeSpecId from the source CodeSpecId.\r\n * @returns the target CodeSpecId or [Id64.invalid]($bentley) if a mapping not found.\r\n */\r\n public findTargetCodeSpecId(sourceId: Id64String): Id64String {\r\n if (Id64.invalid === sourceId) {\r\n return Id64.invalid;\r\n }\r\n return this._nativeContext.findCodeSpecId(sourceId);\r\n }\r\n\r\n /** Look up a target ElementId from the source ElementId.\r\n * @returns the target ElementId or [Id64.invalid]($bentley) if a mapping not found.\r\n */\r\n public findTargetElementId(sourceElementId: Id64String): Id64String {\r\n if (Id64.invalid === sourceElementId) {\r\n return Id64.invalid;\r\n }\r\n return this._nativeContext.findElementId(sourceElementId);\r\n }\r\n\r\n /** Filter out geometry entries in the specified SubCategory from GeometryStreams in the target iModel.\r\n * @note It is not possible to filter out a *default* SubCategory. A request to do so will be ignored.\r\n * @see [SubCategory.isDefaultSubCategory]($backend)\r\n */\r\n public filterSubCategory(sourceSubCategoryId: Id64String): void {\r\n const sourceSubCategory = this.sourceDb.elements.tryGetElement<SubCategory>(sourceSubCategoryId, SubCategory);\r\n if (sourceSubCategory && !sourceSubCategory.isDefaultSubCategory) {\r\n this._nativeContext.filterSubCategoryId(sourceSubCategoryId);\r\n }\r\n }\r\n\r\n /** Returns `true` if there are any SubCategories being filtered. */\r\n public get hasSubCategoryFilter(): boolean {\r\n return this._nativeContext.hasSubCategoryFilter();\r\n }\r\n\r\n /** Returns `true` if this SubCategory is being filtered. */\r\n public isSubCategoryFiltered(subCategoryId: Id64String): boolean {\r\n return this._nativeContext.isSubCategoryFiltered(subCategoryId);\r\n }\r\n\r\n /** Import the specified font from the source iModel into the target iModel.\r\n * @internal\r\n */\r\n public importFont(sourceFontNumber: number): void {\r\n this.targetDb.clearFontMap(); // so it will be reloaded with new font info\r\n this._nativeContext.importFont(sourceFontNumber);\r\n }\r\n\r\n /** Import a single CodeSpec from the source iModel into the target iModel.\r\n * @internal\r\n */\r\n public importCodeSpec(sourceCodeSpecId: Id64String): void {\r\n this._nativeContext.importCodeSpec(sourceCodeSpecId);\r\n }\r\n\r\n /** Clone the specified source Element into ElementProps for the target iModel.\r\n * @internal\r\n */\r\n public cloneElement(sourceElement: Element, cloneOptions?: IModelJsNative.CloneElementOptions): ElementProps {\r\n const targetElementProps: ElementProps = this._nativeContext.cloneElement(sourceElement.id, cloneOptions);\r\n // Ensure that all NavigationProperties in targetElementProps have a defined value so \"clearing\" changes will be part of the JSON used for update\r\n sourceElement.forEachProperty((propertyName: string, meta: PropertyMetaData) => {\r\n if ((meta.isNavigation) && (undefined === (sourceElement as any)[propertyName])) {\r\n (targetElementProps as any)[propertyName] = RelatedElement.none;\r\n }\r\n }, false); // exclude custom because C++ has already handled them\r\n if (this.isBetweenIModels) {\r\n // The native C++ cloneElement strips off federationGuid, want to put it back if transformation is between iModels\r\n targetElementProps.federationGuid = sourceElement.federationGuid;\r\n if (CodeScopeSpec.Type.Repository === this.targetDb.codeSpecs.getById(targetElementProps.code.spec).scopeType) {\r\n targetElementProps.code.scope = IModel.rootSubjectId;\r\n }\r\n }\r\n // unlike other references, code cannot be null. If it is null, use an empty code instead\r\n if (targetElementProps.code.scope === Id64.invalid || targetElementProps.code.spec === Id64.invalid) {\r\n targetElementProps.code = Code.createEmpty();\r\n }\r\n const jsClass = this.sourceDb.getJsClass<typeof Element>(sourceElement.classFullName);\r\n // eslint-disable-next-line @typescript-eslint/dot-notation\r\n jsClass[\"onCloned\"](this, sourceElement.toJSON(), targetElementProps);\r\n return targetElementProps;\r\n }\r\n\r\n /**\r\n * serialize state to a sqlite database at a given path\r\n * assumes the database has not already had any context state serialized to it\r\n * @internal\r\n */\r\n public saveStateToDb(db: SQLiteDb): void {\r\n this._nativeContext.saveStateToDb(db.nativeDb);\r\n }\r\n\r\n /**\r\n * load state from a sqlite database at a given path\r\n * @internal\r\n */\r\n public loadStateFromDb(db: SQLiteDb): void {\r\n this._nativeContext.loadStateFromDb(db.nativeDb);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"IModelCloneContext.js","sourceRoot":"","sources":["../../src/IModelCloneContext.ts"],"names":[],"mappings":";;;AA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IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,OAAO,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE;gBAC7G,kBAAkB,CAAC,IAAI,CAAC,KAAK,GAAG,oBAAM,CAAC,aAAa,CAAC;aACtD;SACF;QACD,yFAAyF;QACzF,IAAI,kBAAkB,CAAC,IAAI,CAAC,KAAK,KAAK,mBAAI,CAAC,OAAO,IAAI,kBAAkB,CAAC,IAAI,CAAC,IAAI,KAAK,mBAAI,CAAC,OAAO,EAAE;YACnG,kBAAkB,CAAC,IAAI,GAAG,kBAAI,CAAC,WAAW,EAAE,CAAC;SAC9C;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAiB,aAAa,CAAC,aAAa,CAAC,CAAC;QACtF,2DAA2D;QAC3D,OAAO,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,aAAa,CAAC,MAAM,EAAE,EAAE,kBAAkB,CAAC,CAAC;QACtE,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACI,aAAa,CAAC,EAAY;QAC/B,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;IACjD,CAAC;IAED;;;OAGG;IACI,eAAe,CAAC,EAAY;QACjC,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;IACnD,CAAC;CACF;AAtKD,gDAsKC","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 { Id64, Id64String } from \"@itwin/core-bentley\";\nimport { Code, CodeScopeSpec, CodeSpec, ElementProps, IModel, PropertyMetaData, RelatedElement } from \"@itwin/core-common\";\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\nimport { SubCategory } from \"./Category\";\nimport { Element } from \"./Element\";\nimport { IModelDb } from \"./IModelDb\";\nimport { IModelHost } from \"./IModelHost\";\nimport { SQLiteDb } from \"./SQLiteDb\";\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 {\n /** The source IModelDb. */\n public readonly sourceDb: IModelDb;\n /** The target IModelDb. */\n public readonly targetDb: IModelDb;\n /** The native import context */\n private _nativeContext: IModelJsNative.ImportContext;\n\n /** Construct a new IModelCloneContext. It must be initialized with `initialize`, consider using [[IModelCloneContext.create]] instead\n * @param sourceDb The source IModelDb.\n * @param targetDb If provided the target IModelDb. If not provided, the source and target are the same IModelDb.\n */\n public constructor(sourceDb: IModelDb, targetDb?: IModelDb) {\n this.sourceDb = sourceDb;\n this.targetDb = (undefined !== targetDb) ? targetDb : sourceDb;\n this._nativeContext = new IModelHost.platform.ImportContext(this.sourceDb.nativeDb, this.targetDb.nativeDb);\n }\n\n /** @internal perform necessary initialization to use a clone context, namely caching the reference types in the source's schemas */\n public async initialize() {\n }\n\n /** @internal construct and initialize an IModelCloneContext at once, for where you construct in an async context */\n public static async create(...args: ConstructorParameters<typeof IModelCloneContext>): Promise<IModelCloneContext> {\n const instance = new this(...args);\n await instance.initialize();\n return instance;\n }\n\n /** Returns `true` if this context is for transforming between 2 iModels and `false` if it for transforming within the same iModel. */\n public get isBetweenIModels(): boolean { return this.sourceDb !== this.targetDb; }\n\n /** Dispose any native resources associated with this IModelCloneContext. */\n public dispose(): void { this._nativeContext.dispose(); }\n\n /** Debugging aid that dumps the Id remapping details and other information to the specified output file.\n * @internal\n */\n public dump(outputFileName: string): void { this._nativeContext.dump(outputFileName); }\n\n /** Add a rule that remaps the specified source [CodeSpec]($common) to the specified target [CodeSpec]($common).\n * @param sourceCodeSpecName The name of the CodeSpec from the source iModel.\n * @param targetCodeSpecName The name of the CodeSpec from the target iModel.\n * @throws [[IModelError]] if either CodeSpec could not be found.\n */\n public remapCodeSpec(sourceCodeSpecName: string, targetCodeSpecName: string): void {\n const sourceCodeSpec: CodeSpec = this.sourceDb.codeSpecs.getByName(sourceCodeSpecName);\n const targetCodeSpec: CodeSpec = this.targetDb.codeSpecs.getByName(targetCodeSpecName);\n this._nativeContext.addCodeSpecId(sourceCodeSpec.id, targetCodeSpec.id);\n }\n\n /** Add a rule that remaps the specified source class to the specified target class. */\n public remapElementClass(sourceClassFullName: string, targetClassFullName: string): void {\n this._nativeContext.addClass(sourceClassFullName, targetClassFullName);\n }\n\n /** Add a rule that remaps the specified source Element to the specified target Element. */\n public remapElement(sourceId: Id64String, targetId: Id64String): void {\n this._nativeContext.addElementId(sourceId, targetId);\n }\n\n /** Remove a rule that remaps the specified source Element. */\n public removeElement(sourceId: Id64String): void {\n this._nativeContext.removeElementId(sourceId);\n }\n\n /** Look up a target CodeSpecId from the source CodeSpecId.\n * @returns the target CodeSpecId or [Id64.invalid]($bentley) if a mapping not found.\n */\n public findTargetCodeSpecId(sourceId: Id64String): Id64String {\n if (Id64.invalid === sourceId) {\n return Id64.invalid;\n }\n return this._nativeContext.findCodeSpecId(sourceId);\n }\n\n /** Look up a target ElementId from the source ElementId.\n * @returns the target ElementId or [Id64.invalid]($bentley) if a mapping not found.\n */\n public findTargetElementId(sourceElementId: Id64String): Id64String {\n if (Id64.invalid === sourceElementId) {\n return Id64.invalid;\n }\n return this._nativeContext.findElementId(sourceElementId);\n }\n\n /** Filter out geometry entries in the specified SubCategory from GeometryStreams in the target iModel.\n * @note It is not possible to filter out a *default* SubCategory. A request to do so will be ignored.\n * @see [SubCategory.isDefaultSubCategory]($backend)\n */\n public filterSubCategory(sourceSubCategoryId: Id64String): void {\n const sourceSubCategory = this.sourceDb.elements.tryGetElement<SubCategory>(sourceSubCategoryId, SubCategory);\n if (sourceSubCategory && !sourceSubCategory.isDefaultSubCategory) {\n this._nativeContext.filterSubCategoryId(sourceSubCategoryId);\n }\n }\n\n /** Returns `true` if there are any SubCategories being filtered. */\n public get hasSubCategoryFilter(): boolean {\n return this._nativeContext.hasSubCategoryFilter();\n }\n\n /** Returns `true` if this SubCategory is being filtered. */\n public isSubCategoryFiltered(subCategoryId: Id64String): boolean {\n return this._nativeContext.isSubCategoryFiltered(subCategoryId);\n }\n\n /** Import the specified font from the source iModel into the target iModel.\n * @internal\n */\n public importFont(sourceFontNumber: number): void {\n this.targetDb.clearFontMap(); // so it will be reloaded with new font info\n this._nativeContext.importFont(sourceFontNumber);\n }\n\n /** Import a single CodeSpec from the source iModel into the target iModel.\n * @internal\n */\n public importCodeSpec(sourceCodeSpecId: Id64String): void {\n this._nativeContext.importCodeSpec(sourceCodeSpecId);\n }\n\n /** Clone the specified source Element into ElementProps for the target iModel.\n * @internal\n */\n public 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 if (CodeScopeSpec.Type.Repository === this.targetDb.codeSpecs.getById(targetElementProps.code.spec).scopeType) {\n targetElementProps.code.scope = IModel.rootSubjectId;\n }\n }\n // unlike other references, code cannot be null. If it is null, use an empty code instead\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 /**\n * serialize state to a sqlite database at a given path\n * assumes the database has not already had any context state serialized to it\n * @internal\n */\n public saveStateToDb(db: SQLiteDb): void {\n this._nativeContext.saveStateToDb(db.nativeDb);\n }\n\n /**\n * load state from a sqlite database at a given path\n * @internal\n */\n public loadStateFromDb(db: SQLiteDb): void {\n this._nativeContext.loadStateFromDb(db.nativeDb);\n }\n}\n"]}