@itwin/core-backend 3.5.0-dev.8 → 3.5.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 (279) hide show
  1. package/CHANGELOG.md +112 -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 +170 -165
  15. package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
  16. package/lib/cjs/BriefcaseManager.js +413 -405
  17. package/lib/cjs/BriefcaseManager.js.map +1 -1
  18. package/lib/cjs/Category.d.ts +153 -153
  19. package/lib/cjs/Category.js +243 -243
  20. package/lib/cjs/Category.js.map +1 -1
  21. package/lib/cjs/ChangeSummaryManager.d.ts +187 -187
  22. package/lib/cjs/ChangeSummaryManager.d.ts.map +1 -1
  23. package/lib/cjs/ChangeSummaryManager.js +447 -445
  24. package/lib/cjs/ChangeSummaryManager.js.map +1 -1
  25. package/lib/cjs/ChangedElementsDb.d.ts +99 -99
  26. package/lib/cjs/ChangedElementsDb.js +165 -165
  27. package/lib/cjs/ChangedElementsDb.js.map +1 -1
  28. package/lib/cjs/ChangedElementsManager.d.ts +39 -39
  29. package/lib/cjs/ChangedElementsManager.js +88 -88
  30. package/lib/cjs/ChangedElementsManager.js.map +1 -1
  31. package/lib/cjs/CheckpointManager.d.ts +120 -120
  32. package/lib/cjs/CheckpointManager.js +343 -343
  33. package/lib/cjs/CheckpointManager.js.map +1 -1
  34. package/lib/cjs/ClassRegistry.d.ts +79 -71
  35. package/lib/cjs/ClassRegistry.d.ts.map +1 -1
  36. package/lib/cjs/ClassRegistry.js +249 -215
  37. package/lib/cjs/ClassRegistry.js.map +1 -1
  38. package/lib/cjs/CloudSqlite.d.ts +350 -349
  39. package/lib/cjs/CloudSqlite.d.ts.map +1 -1
  40. package/lib/cjs/CloudSqlite.js +152 -151
  41. package/lib/cjs/CloudSqlite.js.map +1 -1
  42. package/lib/cjs/CloudStorageBackend.d.ts +58 -58
  43. package/lib/cjs/CloudStorageBackend.js +173 -173
  44. package/lib/cjs/CloudStorageBackend.js.map +1 -1
  45. package/lib/cjs/CodeService.d.ts +396 -396
  46. package/lib/cjs/CodeService.js +63 -63
  47. package/lib/cjs/CodeService.js.map +1 -1
  48. package/lib/cjs/CodeSpecs.d.ts +50 -50
  49. package/lib/cjs/CodeSpecs.js +112 -112
  50. package/lib/cjs/CodeSpecs.js.map +1 -1
  51. package/lib/cjs/ConcurrentQuery.d.ts +13 -11
  52. package/lib/cjs/ConcurrentQuery.d.ts.map +1 -1
  53. package/lib/cjs/ConcurrentQuery.js +36 -30
  54. package/lib/cjs/ConcurrentQuery.js.map +1 -1
  55. package/lib/cjs/CustomViewState3dCreator.d.ts +21 -32
  56. package/lib/cjs/CustomViewState3dCreator.d.ts.map +1 -1
  57. package/lib/cjs/CustomViewState3dCreator.js +81 -113
  58. package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
  59. package/lib/cjs/DevTools.d.ts +71 -71
  60. package/lib/cjs/DevTools.js +154 -154
  61. package/lib/cjs/DevTools.js.map +1 -1
  62. package/lib/cjs/DisplayStyle.d.ts +106 -106
  63. package/lib/cjs/DisplayStyle.d.ts.map +1 -1
  64. package/lib/cjs/DisplayStyle.js +256 -256
  65. package/lib/cjs/DisplayStyle.js.map +1 -1
  66. package/lib/cjs/ECDb.d.ts +191 -191
  67. package/lib/cjs/ECDb.js +350 -350
  68. package/lib/cjs/ECDb.js.map +1 -1
  69. package/lib/cjs/ECSchemaXmlContext.d.ts +18 -18
  70. package/lib/cjs/ECSchemaXmlContext.js +41 -41
  71. package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
  72. package/lib/cjs/ECSqlStatement.d.ts +466 -466
  73. package/lib/cjs/ECSqlStatement.js +791 -791
  74. package/lib/cjs/ECSqlStatement.js.map +1 -1
  75. package/lib/cjs/Element.d.ts +1102 -1109
  76. package/lib/cjs/Element.d.ts.map +1 -1
  77. package/lib/cjs/Element.js +1416 -1420
  78. package/lib/cjs/Element.js.map +1 -1
  79. package/lib/cjs/ElementAspect.d.ts +176 -156
  80. package/lib/cjs/ElementAspect.d.ts.map +1 -1
  81. package/lib/cjs/ElementAspect.js +211 -178
  82. package/lib/cjs/ElementAspect.js.map +1 -1
  83. package/lib/cjs/ElementGraphics.d.ts +9 -9
  84. package/lib/cjs/ElementGraphics.js +41 -41
  85. package/lib/cjs/ElementGraphics.js.map +1 -1
  86. package/lib/cjs/ElementTreeWalker.d.ts +162 -162
  87. package/lib/cjs/ElementTreeWalker.js +409 -409
  88. package/lib/cjs/ElementTreeWalker.js.map +1 -1
  89. package/lib/cjs/Entity.d.ts +106 -76
  90. package/lib/cjs/Entity.d.ts.map +1 -1
  91. package/lib/cjs/Entity.js +134 -82
  92. package/lib/cjs/Entity.js.map +1 -1
  93. package/lib/cjs/EntityReferences.d.ts +50 -0
  94. package/lib/cjs/EntityReferences.d.ts.map +1 -0
  95. package/lib/cjs/EntityReferences.js +96 -0
  96. package/lib/cjs/EntityReferences.js.map +1 -0
  97. package/lib/cjs/ExportGraphics.d.ts +317 -317
  98. package/lib/cjs/ExportGraphics.js +208 -208
  99. package/lib/cjs/ExportGraphics.js.map +1 -1
  100. package/lib/cjs/ExternalSource.d.ts +96 -94
  101. package/lib/cjs/ExternalSource.d.ts.map +1 -1
  102. package/lib/cjs/ExternalSource.js +131 -125
  103. package/lib/cjs/ExternalSource.js.map +1 -1
  104. package/lib/cjs/GeoCoordConfig.d.ts +19 -19
  105. package/lib/cjs/GeoCoordConfig.d.ts.map +1 -1
  106. package/lib/cjs/GeoCoordConfig.js +85 -82
  107. package/lib/cjs/GeoCoordConfig.js.map +1 -1
  108. package/lib/cjs/GeometrySummary.d.ts +4 -4
  109. package/lib/cjs/GeometrySummary.js +380 -380
  110. package/lib/cjs/GeometrySummary.js.map +1 -1
  111. package/lib/cjs/HubMock.d.ts +94 -93
  112. package/lib/cjs/HubMock.d.ts.map +1 -1
  113. package/lib/cjs/HubMock.js +222 -190
  114. package/lib/cjs/HubMock.js.map +1 -1
  115. package/lib/cjs/IModelCloneContext.d.ts +8 -85
  116. package/lib/cjs/IModelCloneContext.d.ts.map +1 -1
  117. package/lib/cjs/IModelCloneContext.js +15 -150
  118. package/lib/cjs/IModelCloneContext.js.map +1 -1
  119. package/lib/cjs/IModelDb.d.ts +1183 -1164
  120. package/lib/cjs/IModelDb.d.ts.map +1 -1
  121. package/lib/cjs/IModelDb.js +2374 -2324
  122. package/lib/cjs/IModelDb.js.map +1 -1
  123. package/lib/cjs/IModelElementCloneContext.d.ts +90 -0
  124. package/lib/cjs/IModelElementCloneContext.d.ts.map +1 -0
  125. package/lib/cjs/IModelElementCloneContext.js +160 -0
  126. package/lib/cjs/IModelElementCloneContext.js.map +1 -0
  127. package/lib/cjs/IModelHost.d.ts +370 -361
  128. package/lib/cjs/IModelHost.d.ts.map +1 -1
  129. package/lib/cjs/IModelHost.js +496 -489
  130. package/lib/cjs/IModelHost.js.map +1 -1
  131. package/lib/cjs/IModelJsFs.d.ts +62 -62
  132. package/lib/cjs/IModelJsFs.js +140 -140
  133. package/lib/cjs/IModelJsFs.js.map +1 -1
  134. package/lib/cjs/IpcHost.d.ts +104 -98
  135. package/lib/cjs/IpcHost.d.ts.map +1 -1
  136. package/lib/cjs/IpcHost.js +278 -234
  137. package/lib/cjs/IpcHost.js.map +1 -1
  138. package/lib/cjs/LineStyle.d.ts +311 -311
  139. package/lib/cjs/LineStyle.js +295 -295
  140. package/lib/cjs/LineStyle.js.map +1 -1
  141. package/lib/cjs/LocalHub.d.ts +162 -162
  142. package/lib/cjs/LocalHub.js +587 -587
  143. package/lib/cjs/LocalHub.js.map +1 -1
  144. package/lib/cjs/LocalhostIpcHost.d.ts +20 -20
  145. package/lib/cjs/LocalhostIpcHost.js +81 -81
  146. package/lib/cjs/LocalhostIpcHost.js.map +1 -1
  147. package/lib/cjs/Material.d.ts +103 -103
  148. package/lib/cjs/Material.js +147 -147
  149. package/lib/cjs/Material.js.map +1 -1
  150. package/lib/cjs/Model.d.ts +392 -386
  151. package/lib/cjs/Model.d.ts.map +1 -1
  152. package/lib/cjs/Model.js +485 -471
  153. package/lib/cjs/Model.js.map +1 -1
  154. package/lib/cjs/NativeAppStorage.d.ts +51 -51
  155. package/lib/cjs/NativeAppStorage.js +202 -202
  156. package/lib/cjs/NativeAppStorage.js.map +1 -1
  157. package/lib/cjs/NativeHost.d.ts +52 -52
  158. package/lib/cjs/NativeHost.d.ts.map +1 -1
  159. package/lib/cjs/NativeHost.js +163 -168
  160. package/lib/cjs/NativeHost.js.map +1 -1
  161. package/lib/cjs/NavigationRelationship.d.ts +156 -156
  162. package/lib/cjs/NavigationRelationship.js +225 -225
  163. package/lib/cjs/NavigationRelationship.js.map +1 -1
  164. package/lib/cjs/PromiseMemoizer.d.ts +51 -51
  165. package/lib/cjs/PromiseMemoizer.d.ts.map +1 -1
  166. package/lib/cjs/PromiseMemoizer.js +101 -101
  167. package/lib/cjs/PromiseMemoizer.js.map +1 -1
  168. package/lib/cjs/PropertyStore.d.ts +132 -132
  169. package/lib/cjs/PropertyStore.js +11 -11
  170. package/lib/cjs/PropertyStore.js.map +1 -1
  171. package/lib/cjs/Relationship.d.ts +416 -400
  172. package/lib/cjs/Relationship.d.ts.map +1 -1
  173. package/lib/cjs/Relationship.js +494 -465
  174. package/lib/cjs/Relationship.js.map +1 -1
  175. package/lib/cjs/RpcBackend.d.ts +5 -28
  176. package/lib/cjs/RpcBackend.d.ts.map +1 -1
  177. package/lib/cjs/RpcBackend.js +31 -126
  178. package/lib/cjs/RpcBackend.js.map +1 -1
  179. package/lib/cjs/SQLiteDb.d.ts +219 -219
  180. package/lib/cjs/SQLiteDb.js +214 -214
  181. package/lib/cjs/SQLiteDb.js.map +1 -1
  182. package/lib/cjs/Schema.d.ts +55 -55
  183. package/lib/cjs/Schema.js +83 -83
  184. package/lib/cjs/Schema.js.map +1 -1
  185. package/lib/cjs/ServerBasedLocks.d.ts +57 -57
  186. package/lib/cjs/ServerBasedLocks.js +168 -168
  187. package/lib/cjs/ServerBasedLocks.js.map +1 -1
  188. package/lib/cjs/SqliteStatement.d.ts +360 -283
  189. package/lib/cjs/SqliteStatement.d.ts.map +1 -1
  190. package/lib/cjs/SqliteStatement.js +586 -448
  191. package/lib/cjs/SqliteStatement.js.map +1 -1
  192. package/lib/cjs/Texture.d.ts +58 -58
  193. package/lib/cjs/Texture.js +82 -82
  194. package/lib/cjs/Texture.js.map +1 -1
  195. package/lib/cjs/TileStorage.d.ts +18 -18
  196. package/lib/cjs/TileStorage.js +90 -90
  197. package/lib/cjs/TileStorage.js.map +1 -1
  198. package/lib/cjs/TxnManager.d.ts +202 -202
  199. package/lib/cjs/TxnManager.js +356 -356
  200. package/lib/cjs/TxnManager.js.map +1 -1
  201. package/lib/cjs/ViewDefinition.d.ts +439 -435
  202. package/lib/cjs/ViewDefinition.d.ts.map +1 -1
  203. package/lib/cjs/ViewDefinition.js +646 -635
  204. package/lib/cjs/ViewDefinition.js.map +1 -1
  205. package/lib/cjs/ViewStateHydrator.d.ts +13 -13
  206. package/lib/cjs/ViewStateHydrator.js +103 -103
  207. package/lib/cjs/ViewStateHydrator.js.map +1 -1
  208. package/lib/cjs/assets/IModelChange.02.00.00.ecschema.xml +90 -90
  209. package/lib/cjs/assets/Settings/Schemas/Cloud.Schema.json +67 -67
  210. package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +31 -31
  211. package/lib/cjs/assets/Settings/Schemas/Workspace.Schema.json +52 -52
  212. package/lib/cjs/assets/Settings/backend.setting.json5 +138 -138
  213. package/lib/cjs/core-backend.d.ts +184 -182
  214. package/lib/cjs/core-backend.d.ts.map +1 -1
  215. package/lib/cjs/core-backend.js +204 -202
  216. package/lib/cjs/core-backend.js.map +1 -1
  217. package/lib/cjs/domains/FunctionalElements.d.ts +101 -101
  218. package/lib/cjs/domains/FunctionalElements.js +145 -145
  219. package/lib/cjs/domains/FunctionalElements.js.map +1 -1
  220. package/lib/cjs/domains/FunctionalSchema.d.ts +13 -13
  221. package/lib/cjs/domains/FunctionalSchema.js +40 -40
  222. package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
  223. package/lib/cjs/domains/GenericElements.d.ts +177 -177
  224. package/lib/cjs/domains/GenericElements.js +263 -263
  225. package/lib/cjs/domains/GenericElements.js.map +1 -1
  226. package/lib/cjs/domains/GenericSchema.d.ts +10 -10
  227. package/lib/cjs/domains/GenericSchema.js +28 -28
  228. package/lib/cjs/domains/GenericSchema.js.map +1 -1
  229. package/lib/cjs/rpc/multipart.d.ts +12 -0
  230. package/lib/cjs/rpc/multipart.d.ts.map +1 -0
  231. package/lib/cjs/rpc/multipart.js +71 -0
  232. package/lib/cjs/rpc/multipart.js.map +1 -0
  233. package/lib/cjs/rpc/tracing.d.ts +29 -0
  234. package/lib/cjs/rpc/tracing.d.ts.map +1 -0
  235. package/lib/cjs/rpc/tracing.js +74 -0
  236. package/lib/cjs/rpc/tracing.js.map +1 -0
  237. package/lib/cjs/rpc/web/logging.d.ts +10 -0
  238. package/lib/cjs/rpc/web/logging.d.ts.map +1 -0
  239. package/lib/cjs/rpc/web/logging.js +43 -0
  240. package/lib/cjs/rpc/web/logging.js.map +1 -0
  241. package/lib/cjs/rpc/web/request.d.ts +7 -0
  242. package/lib/cjs/rpc/web/request.d.ts.map +1 -0
  243. package/lib/cjs/rpc/web/request.js +74 -0
  244. package/lib/cjs/rpc/web/request.js.map +1 -0
  245. package/lib/cjs/rpc/web/response.d.ts +7 -0
  246. package/lib/cjs/rpc/web/response.d.ts.map +1 -0
  247. package/lib/cjs/rpc/web/response.js +106 -0
  248. package/lib/cjs/rpc/web/response.js.map +1 -0
  249. package/lib/cjs/rpc-impl/DevToolsRpcImpl.d.ts +15 -15
  250. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js +32 -32
  251. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js.map +1 -1
  252. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +47 -45
  253. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -1
  254. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +291 -262
  255. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  256. package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts +22 -22
  257. package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts.map +1 -1
  258. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +202 -204
  259. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
  260. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts +36 -36
  261. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +168 -168
  262. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  263. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.d.ts +16 -16
  264. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js +43 -43
  265. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
  266. package/lib/cjs/rpc-impl/WipRpcImpl.d.ts +15 -15
  267. package/lib/cjs/rpc-impl/WipRpcImpl.js +37 -37
  268. package/lib/cjs/rpc-impl/WipRpcImpl.js.map +1 -1
  269. package/lib/cjs/workspace/Settings.d.ts +186 -186
  270. package/lib/cjs/workspace/Settings.js +155 -155
  271. package/lib/cjs/workspace/Settings.js.map +1 -1
  272. package/lib/cjs/workspace/SettingsSchemas.d.ts +75 -75
  273. package/lib/cjs/workspace/SettingsSchemas.js +191 -191
  274. package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
  275. package/lib/cjs/workspace/Workspace.d.ts +414 -414
  276. package/lib/cjs/workspace/Workspace.d.ts.map +1 -1
  277. package/lib/cjs/workspace/Workspace.js +543 -543
  278. package/lib/cjs/workspace/Workspace.js.map +1 -1
  279. package/package.json +14 -14
@@ -0,0 +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 IModelElementCloneContext {
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 IModelElementCloneContext. It must be initialized with `initialize`, consider using [[IModelElementCloneContext.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
+ /** perform necessary initialization to use a clone context, namely caching the reference types in the source's schemas */
26
+ initialize(): Promise<void>;
27
+ /** construct and initialize an IModelElementCloneContext at once, for where you construct in an async context */
28
+ static create(...args: ConstructorParameters<typeof IModelElementCloneContext>): Promise<IModelElementCloneContext>;
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 IModelElementCloneContext. */
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
+ }
90
+ //# sourceMappingURL=IModelElementCloneContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IModelElementCloneContext.d.ts","sourceRoot":"","sources":["../../src/IModelElementCloneContext.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,0BAA0B,CAAC;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC;;GAEG;AACH,qBAAa,yBAAyB;IACpC,2BAA2B;IAC3B,SAAgB,QAAQ,EAAE,QAAQ,CAAC;IACnC,2BAA2B;IAC3B,SAAgB,QAAQ,EAAE,QAAQ,CAAC;IACnC,gCAAgC;IAChC,OAAO,CAAC,cAAc,CAA+B;IAErD;;;OAGG;gBACgB,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,QAAQ;IAM1D,0HAA0H;IAC7G,UAAU;IAGvB,iHAAiH;WAC7F,MAAM,CAAC,GAAG,IAAI,EAAE,qBAAqB,CAAC,OAAO,yBAAyB,CAAC,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAMhI,sIAAsI;IACtI,IAA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exports.IModelElementCloneContext = 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 IModelElementCloneContext {
19
+ /** Construct a new IModelElementCloneContext. It must be initialized with `initialize`, consider using [[IModelElementCloneContext.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
+ /** perform necessary initialization to use a clone context, namely caching the reference types in the source's schemas */
29
+ async initialize() {
30
+ }
31
+ /** construct and initialize an IModelElementCloneContext 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 IModelElementCloneContext. */
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.IModelElementCloneContext = IModelElementCloneContext;
160
+ //# sourceMappingURL=IModelElementCloneContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IModelElementCloneContext.js","sourceRoot":"","sources":["../../src/IModelElementCloneContext.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,sDAAuD;AACvD,oDAA2H;AAE3H,yCAAyC;AAGzC,6CAA0C;AAG1C;;GAEG;AACH,MAAa,yBAAyB;IAQpC;;;OAGG;IACH,YAAmB,QAAkB,EAAE,QAAmB;QACxD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,CAAC,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC;QAC/D,IAAI,CAAC,cAAc,GAAG,IAAI,uBAAU,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CA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iB,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,8DAsKC","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 IModelElementCloneContext {\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 IModelElementCloneContext. It must be initialized with `initialize`, consider using [[IModelElementCloneContext.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 /** 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 /** construct and initialize an IModelElementCloneContext at once, for where you construct in an async context */\n public static async create(...args: ConstructorParameters<typeof IModelElementCloneContext>): Promise<IModelElementCloneContext> {\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 IModelElementCloneContext. */\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"]}