@itwin/core-backend 4.0.0-dev.10 → 4.0.0-dev.101

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 (295) hide show
  1. package/CHANGELOG.md +68 -1
  2. package/lib/cjs/BackendHubAccess.d.ts +226 -224
  3. package/lib/cjs/BackendHubAccess.d.ts.map +1 -1
  4. package/lib/cjs/BackendHubAccess.js +41 -41
  5. package/lib/cjs/BackendHubAccess.js.map +1 -1
  6. package/lib/cjs/BackendLoggerCategory.d.ts +90 -91
  7. package/lib/cjs/BackendLoggerCategory.d.ts.map +1 -1
  8. package/lib/cjs/BackendLoggerCategory.js +98 -99
  9. package/lib/cjs/BackendLoggerCategory.js.map +1 -1
  10. package/lib/cjs/BisCoreSchema.d.ts +21 -21
  11. package/lib/cjs/BisCoreSchema.js +60 -60
  12. package/lib/cjs/BisCoreSchema.js.map +1 -1
  13. package/lib/cjs/BlobContainerService.d.ts +120 -0
  14. package/lib/cjs/BlobContainerService.d.ts.map +1 -0
  15. package/lib/cjs/BlobContainerService.js +18 -0
  16. package/lib/cjs/BlobContainerService.js.map +1 -0
  17. package/lib/cjs/BriefcaseManager.d.ts +184 -170
  18. package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
  19. package/lib/cjs/BriefcaseManager.js +421 -414
  20. package/lib/cjs/BriefcaseManager.js.map +1 -1
  21. package/lib/cjs/Category.d.ts +153 -153
  22. package/lib/cjs/Category.js +243 -243
  23. package/lib/cjs/Category.js.map +1 -1
  24. package/lib/cjs/ChangeSummaryManager.d.ts +187 -187
  25. package/lib/cjs/ChangeSummaryManager.js +446 -447
  26. package/lib/cjs/ChangeSummaryManager.js.map +1 -1
  27. package/lib/cjs/ChangedElementsDb.d.ts +99 -99
  28. package/lib/cjs/ChangedElementsDb.js +165 -165
  29. package/lib/cjs/ChangedElementsDb.js.map +1 -1
  30. package/lib/cjs/ChangedElementsManager.d.ts +39 -39
  31. package/lib/cjs/ChangedElementsManager.js +88 -88
  32. package/lib/cjs/ChangedElementsManager.js.map +1 -1
  33. package/lib/cjs/ChannelControl.d.ts +70 -0
  34. package/lib/cjs/ChannelControl.d.ts.map +1 -0
  35. package/lib/cjs/ChannelControl.js +89 -0
  36. package/lib/cjs/ChannelControl.js.map +1 -0
  37. package/lib/cjs/CheckpointManager.d.ts +121 -121
  38. package/lib/cjs/CheckpointManager.d.ts.map +1 -1
  39. package/lib/cjs/CheckpointManager.js +351 -349
  40. package/lib/cjs/CheckpointManager.js.map +1 -1
  41. package/lib/cjs/ClassRegistry.d.ts +79 -79
  42. package/lib/cjs/ClassRegistry.js +254 -250
  43. package/lib/cjs/ClassRegistry.js.map +1 -1
  44. package/lib/cjs/CloudSqlite.d.ts +572 -350
  45. package/lib/cjs/CloudSqlite.d.ts.map +1 -1
  46. package/lib/cjs/CloudSqlite.js +374 -153
  47. package/lib/cjs/CloudSqlite.js.map +1 -1
  48. package/lib/cjs/CodeService.d.ts +399 -396
  49. package/lib/cjs/CodeService.d.ts.map +1 -1
  50. package/lib/cjs/CodeService.js +63 -63
  51. package/lib/cjs/CodeService.js.map +1 -1
  52. package/lib/cjs/CodeSpecs.d.ts +58 -55
  53. package/lib/cjs/CodeSpecs.d.ts.map +1 -1
  54. package/lib/cjs/CodeSpecs.js +154 -124
  55. package/lib/cjs/CodeSpecs.js.map +1 -1
  56. package/lib/cjs/ConcurrentQuery.d.ts +13 -13
  57. package/lib/cjs/ConcurrentQuery.d.ts.map +1 -1
  58. package/lib/cjs/ConcurrentQuery.js +36 -36
  59. package/lib/cjs/ConcurrentQuery.js.map +1 -1
  60. package/lib/cjs/CustomViewState3dCreator.d.ts +21 -21
  61. package/lib/cjs/CustomViewState3dCreator.d.ts.map +1 -1
  62. package/lib/cjs/CustomViewState3dCreator.js +80 -81
  63. package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
  64. package/lib/cjs/DevTools.d.ts +74 -71
  65. package/lib/cjs/DevTools.d.ts.map +1 -1
  66. package/lib/cjs/DevTools.js +156 -154
  67. package/lib/cjs/DevTools.js.map +1 -1
  68. package/lib/cjs/DisplayStyle.d.ts +104 -106
  69. package/lib/cjs/DisplayStyle.d.ts.map +1 -1
  70. package/lib/cjs/DisplayStyle.js +251 -256
  71. package/lib/cjs/DisplayStyle.js.map +1 -1
  72. package/lib/cjs/ECDb.d.ts +194 -191
  73. package/lib/cjs/ECDb.d.ts.map +1 -1
  74. package/lib/cjs/ECDb.js +351 -350
  75. package/lib/cjs/ECDb.js.map +1 -1
  76. package/lib/cjs/ECSchemaXmlContext.d.ts +18 -18
  77. package/lib/cjs/ECSchemaXmlContext.d.ts.map +1 -1
  78. package/lib/cjs/ECSchemaXmlContext.js +41 -41
  79. package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
  80. package/lib/cjs/ECSqlStatement.d.ts +473 -473
  81. package/lib/cjs/ECSqlStatement.js +791 -791
  82. package/lib/cjs/ECSqlStatement.js.map +1 -1
  83. package/lib/cjs/Element.d.ts +1105 -1109
  84. package/lib/cjs/Element.d.ts.map +1 -1
  85. package/lib/cjs/Element.js +1416 -1427
  86. package/lib/cjs/Element.js.map +1 -1
  87. package/lib/cjs/ElementAspect.d.ts +175 -179
  88. package/lib/cjs/ElementAspect.d.ts.map +1 -1
  89. package/lib/cjs/ElementAspect.js +202 -211
  90. package/lib/cjs/ElementAspect.js.map +1 -1
  91. package/lib/cjs/ElementGraphics.d.ts +9 -9
  92. package/lib/cjs/ElementGraphics.js +41 -41
  93. package/lib/cjs/ElementGraphics.js.map +1 -1
  94. package/lib/cjs/ElementTreeWalker.d.ts +162 -162
  95. package/lib/cjs/ElementTreeWalker.d.ts.map +1 -1
  96. package/lib/cjs/ElementTreeWalker.js +409 -409
  97. package/lib/cjs/ElementTreeWalker.js.map +1 -1
  98. package/lib/cjs/Entity.d.ts +102 -106
  99. package/lib/cjs/Entity.d.ts.map +1 -1
  100. package/lib/cjs/Entity.js +118 -134
  101. package/lib/cjs/Entity.js.map +1 -1
  102. package/lib/cjs/EntityReferences.d.ts +49 -49
  103. package/lib/cjs/EntityReferences.d.ts.map +1 -1
  104. package/lib/cjs/EntityReferences.js +95 -95
  105. package/lib/cjs/EntityReferences.js.map +1 -1
  106. package/lib/cjs/ExportGraphics.d.ts +317 -317
  107. package/lib/cjs/ExportGraphics.d.ts.map +1 -1
  108. package/lib/cjs/ExportGraphics.js +208 -208
  109. package/lib/cjs/ExportGraphics.js.map +1 -1
  110. package/lib/cjs/ExternalSource.d.ts +95 -96
  111. package/lib/cjs/ExternalSource.d.ts.map +1 -1
  112. package/lib/cjs/ExternalSource.js +130 -131
  113. package/lib/cjs/ExternalSource.js.map +1 -1
  114. package/lib/cjs/GeoCoordConfig.d.ts +19 -19
  115. package/lib/cjs/GeoCoordConfig.js +85 -85
  116. package/lib/cjs/GeoCoordConfig.js.map +1 -1
  117. package/lib/cjs/GeometrySummary.d.ts +4 -4
  118. package/lib/cjs/GeometrySummary.js +380 -380
  119. package/lib/cjs/GeometrySummary.js.map +1 -1
  120. package/lib/cjs/HubMock.d.ts +94 -94
  121. package/lib/cjs/HubMock.js +220 -222
  122. package/lib/cjs/HubMock.js.map +1 -1
  123. package/lib/cjs/IModelCloneContext.d.ts +8 -8
  124. package/lib/cjs/IModelCloneContext.d.ts.map +1 -1
  125. package/lib/cjs/IModelCloneContext.js +15 -15
  126. package/lib/cjs/IModelCloneContext.js.map +1 -1
  127. package/lib/cjs/IModelDb.d.ts +1222 -1196
  128. package/lib/cjs/IModelDb.d.ts.map +1 -1
  129. package/lib/cjs/IModelDb.js +2389 -2392
  130. package/lib/cjs/IModelDb.js.map +1 -1
  131. package/lib/cjs/IModelElementCloneContext.d.ts +89 -89
  132. package/lib/cjs/IModelElementCloneContext.js +159 -159
  133. package/lib/cjs/IModelElementCloneContext.js.map +1 -1
  134. package/lib/cjs/IModelHost.d.ts +370 -369
  135. package/lib/cjs/IModelHost.d.ts.map +1 -1
  136. package/lib/cjs/IModelHost.js +476 -496
  137. package/lib/cjs/IModelHost.js.map +1 -1
  138. package/lib/cjs/IModelJsFs.d.ts +62 -62
  139. package/lib/cjs/IModelJsFs.js +139 -140
  140. package/lib/cjs/IModelJsFs.js.map +1 -1
  141. package/lib/cjs/IpcHost.d.ts +104 -104
  142. package/lib/cjs/IpcHost.js +276 -278
  143. package/lib/cjs/IpcHost.js.map +1 -1
  144. package/lib/cjs/LineStyle.d.ts +311 -311
  145. package/lib/cjs/LineStyle.js +295 -295
  146. package/lib/cjs/LineStyle.js.map +1 -1
  147. package/lib/cjs/LocalHub.d.ts +162 -162
  148. package/lib/cjs/LocalHub.d.ts.map +1 -1
  149. package/lib/cjs/LocalHub.js +580 -585
  150. package/lib/cjs/LocalHub.js.map +1 -1
  151. package/lib/cjs/LocalhostIpcHost.d.ts +21 -20
  152. package/lib/cjs/LocalhostIpcHost.d.ts.map +1 -1
  153. package/lib/cjs/LocalhostIpcHost.js +79 -81
  154. package/lib/cjs/LocalhostIpcHost.js.map +1 -1
  155. package/lib/cjs/Material.d.ts +131 -131
  156. package/lib/cjs/Material.d.ts.map +1 -1
  157. package/lib/cjs/Material.js +185 -181
  158. package/lib/cjs/Material.js.map +1 -1
  159. package/lib/cjs/Model.d.ts +391 -392
  160. package/lib/cjs/Model.d.ts.map +1 -1
  161. package/lib/cjs/Model.js +487 -485
  162. package/lib/cjs/Model.js.map +1 -1
  163. package/lib/cjs/NativeAppStorage.d.ts +51 -51
  164. package/lib/cjs/NativeAppStorage.js +202 -202
  165. package/lib/cjs/NativeAppStorage.js.map +1 -1
  166. package/lib/cjs/NativeHost.d.ts +52 -52
  167. package/lib/cjs/NativeHost.d.ts.map +1 -1
  168. package/lib/cjs/NativeHost.js +158 -163
  169. package/lib/cjs/NativeHost.js.map +1 -1
  170. package/lib/cjs/NavigationRelationship.d.ts +156 -156
  171. package/lib/cjs/NavigationRelationship.js +225 -225
  172. package/lib/cjs/NavigationRelationship.js.map +1 -1
  173. package/lib/cjs/PromiseMemoizer.d.ts +51 -51
  174. package/lib/cjs/PromiseMemoizer.d.ts.map +1 -1
  175. package/lib/cjs/PromiseMemoizer.js +101 -101
  176. package/lib/cjs/PromiseMemoizer.js.map +1 -1
  177. package/lib/cjs/PropertyStore.d.ts +123 -132
  178. package/lib/cjs/PropertyStore.d.ts.map +1 -1
  179. package/lib/cjs/PropertyStore.js +179 -11
  180. package/lib/cjs/PropertyStore.js.map +1 -1
  181. package/lib/cjs/Relationship.d.ts +413 -416
  182. package/lib/cjs/Relationship.d.ts.map +1 -1
  183. package/lib/cjs/Relationship.js +491 -494
  184. package/lib/cjs/Relationship.js.map +1 -1
  185. package/lib/cjs/RpcBackend.d.ts +5 -5
  186. package/lib/cjs/RpcBackend.js +32 -32
  187. package/lib/cjs/RpcBackend.js.map +1 -1
  188. package/lib/cjs/SQLiteDb.d.ts +317 -219
  189. package/lib/cjs/SQLiteDb.d.ts.map +1 -1
  190. package/lib/cjs/SQLiteDb.js +318 -214
  191. package/lib/cjs/SQLiteDb.js.map +1 -1
  192. package/lib/cjs/Schema.d.ts +55 -55
  193. package/lib/cjs/Schema.js +83 -83
  194. package/lib/cjs/Schema.js.map +1 -1
  195. package/lib/cjs/ServerBasedLocks.d.ts +57 -57
  196. package/lib/cjs/ServerBasedLocks.js +168 -168
  197. package/lib/cjs/ServerBasedLocks.js.map +1 -1
  198. package/lib/cjs/SqliteStatement.d.ts +360 -360
  199. package/lib/cjs/SqliteStatement.d.ts.map +1 -1
  200. package/lib/cjs/SqliteStatement.js +586 -586
  201. package/lib/cjs/SqliteStatement.js.map +1 -1
  202. package/lib/cjs/Texture.d.ts +58 -58
  203. package/lib/cjs/Texture.js +82 -82
  204. package/lib/cjs/Texture.js.map +1 -1
  205. package/lib/cjs/TileStorage.d.ts +44 -18
  206. package/lib/cjs/TileStorage.d.ts.map +1 -1
  207. package/lib/cjs/TileStorage.js +109 -90
  208. package/lib/cjs/TileStorage.js.map +1 -1
  209. package/lib/cjs/TxnManager.d.ts +202 -202
  210. package/lib/cjs/TxnManager.d.ts.map +1 -1
  211. package/lib/cjs/TxnManager.js +356 -356
  212. package/lib/cjs/TxnManager.js.map +1 -1
  213. package/lib/cjs/ViewDefinition.d.ts +429 -439
  214. package/lib/cjs/ViewDefinition.d.ts.map +1 -1
  215. package/lib/cjs/ViewDefinition.js +640 -646
  216. package/lib/cjs/ViewDefinition.js.map +1 -1
  217. package/lib/cjs/ViewStateHydrator.d.ts +13 -13
  218. package/lib/cjs/ViewStateHydrator.js +103 -103
  219. package/lib/cjs/ViewStateHydrator.js.map +1 -1
  220. package/lib/cjs/assets/IModelChange.02.00.00.ecschema.xml +90 -90
  221. package/lib/cjs/assets/Settings/Schemas/Cloud.Schema.json +67 -67
  222. package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +31 -31
  223. package/lib/cjs/assets/Settings/Schemas/Workspace.Schema.json +52 -52
  224. package/lib/cjs/assets/Settings/backend.setting.json5 +138 -138
  225. package/lib/cjs/core-backend.d.ts +181 -184
  226. package/lib/cjs/core-backend.d.ts.map +1 -1
  227. package/lib/cjs/core-backend.js +205 -204
  228. package/lib/cjs/core-backend.js.map +1 -1
  229. package/lib/cjs/domains/FunctionalElements.d.ts +101 -101
  230. package/lib/cjs/domains/FunctionalElements.js +145 -145
  231. package/lib/cjs/domains/FunctionalElements.js.map +1 -1
  232. package/lib/cjs/domains/FunctionalSchema.d.ts +13 -13
  233. package/lib/cjs/domains/FunctionalSchema.d.ts.map +1 -1
  234. package/lib/cjs/domains/FunctionalSchema.js +39 -40
  235. package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
  236. package/lib/cjs/domains/GenericElements.d.ts +177 -177
  237. package/lib/cjs/domains/GenericElements.js +263 -263
  238. package/lib/cjs/domains/GenericElements.js.map +1 -1
  239. package/lib/cjs/domains/GenericSchema.d.ts +10 -10
  240. package/lib/cjs/domains/GenericSchema.js +28 -28
  241. package/lib/cjs/domains/GenericSchema.js.map +1 -1
  242. package/lib/cjs/rpc/multipart.d.ts +11 -11
  243. package/lib/cjs/rpc/multipart.js +71 -71
  244. package/lib/cjs/rpc/multipart.js.map +1 -1
  245. package/lib/cjs/rpc/tracing.d.ts +28 -28
  246. package/lib/cjs/rpc/tracing.js +73 -74
  247. package/lib/cjs/rpc/tracing.js.map +1 -1
  248. package/lib/cjs/rpc/web/logging.d.ts +9 -9
  249. package/lib/cjs/rpc/web/logging.js +43 -43
  250. package/lib/cjs/rpc/web/logging.js.map +1 -1
  251. package/lib/cjs/rpc/web/request.d.ts +6 -6
  252. package/lib/cjs/rpc/web/request.js +73 -74
  253. package/lib/cjs/rpc/web/request.js.map +1 -1
  254. package/lib/cjs/rpc/web/response.d.ts +6 -6
  255. package/lib/cjs/rpc/web/response.js +105 -106
  256. package/lib/cjs/rpc/web/response.js.map +1 -1
  257. package/lib/cjs/rpc-impl/DevToolsRpcImpl.d.ts +15 -15
  258. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js +32 -32
  259. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js.map +1 -1
  260. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +47 -47
  261. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +293 -294
  262. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  263. package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts +20 -22
  264. package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts.map +1 -1
  265. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +193 -205
  266. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
  267. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts +36 -36
  268. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +166 -168
  269. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  270. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.d.ts +16 -16
  271. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js +42 -43
  272. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
  273. package/lib/cjs/rpc-impl/WipRpcImpl.d.ts +15 -15
  274. package/lib/cjs/rpc-impl/WipRpcImpl.js +37 -37
  275. package/lib/cjs/rpc-impl/WipRpcImpl.js.map +1 -1
  276. package/lib/cjs/workspace/Settings.d.ts +186 -186
  277. package/lib/cjs/workspace/Settings.d.ts.map +1 -1
  278. package/lib/cjs/workspace/Settings.js +155 -155
  279. package/lib/cjs/workspace/Settings.js.map +1 -1
  280. package/lib/cjs/workspace/SettingsSchemas.d.ts +75 -75
  281. package/lib/cjs/workspace/SettingsSchemas.js +190 -191
  282. package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
  283. package/lib/cjs/workspace/Workspace.d.ts +411 -414
  284. package/lib/cjs/workspace/Workspace.d.ts.map +1 -1
  285. package/lib/cjs/workspace/Workspace.js +521 -543
  286. package/lib/cjs/workspace/Workspace.js.map +1 -1
  287. package/package.json +25 -28
  288. package/lib/cjs/AliCloudStorageService.d.ts +0 -24
  289. package/lib/cjs/AliCloudStorageService.d.ts.map +0 -1
  290. package/lib/cjs/AliCloudStorageService.js +0 -72
  291. package/lib/cjs/AliCloudStorageService.js.map +0 -1
  292. package/lib/cjs/CloudStorageBackend.d.ts +0 -59
  293. package/lib/cjs/CloudStorageBackend.d.ts.map +0 -1
  294. package/lib/cjs/CloudStorageBackend.js +0 -174
  295. package/lib/cjs/CloudStorageBackend.js.map +0 -1
@@ -1,125 +1,155 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- /** @packageDocumentation
7
- * @module Codes
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.CodeSpecs = void 0;
11
- const core_bentley_1 = require("@itwin/core-bentley");
12
- const core_common_1 = require("@itwin/core-common");
13
- /** Manages [CodeSpecs]($docs/BIS/guide/fundamentals/element-fundamentals.md#codespec) within an [[IModelDb]]
14
- * @public
15
- */
16
- class CodeSpecs {
17
- constructor(imodel) {
18
- this._loadedCodeSpecs = [];
19
- this._imodel = imodel;
20
- if (imodel.isBriefcaseDb()) {
21
- imodel.onChangesetApplied.addListener(() => this._loadedCodeSpecs.length = 0);
22
- }
23
- }
24
- /** Look up the Id of the CodeSpec with the specified name. */
25
- queryId(name) {
26
- return this._imodel.withPreparedStatement("SELECT ECInstanceId FROM BisCore.CodeSpec WHERE Name=:name", (stmt) => {
27
- stmt.bindString("name", name);
28
- if (core_bentley_1.DbResult.BE_SQLITE_ROW !== stmt.step())
29
- throw new core_common_1.IModelError(core_bentley_1.IModelStatus.NotFound, "CodeSpec not found", () => ({ name }));
30
- return stmt.getValue(0).getId();
31
- });
32
- }
33
- /** Look up a CodeSpec by Id. The CodeSpec will be loaded from the database if necessary.
34
- * @param codeSpecId The Id of the CodeSpec to load
35
- * @returns The CodeSpec with the specified Id
36
- * @throws [[IModelError]] if the Id is invalid or if no CodeSpec with that Id could be found.
37
- */
38
- getById(codeSpecId) {
39
- if (core_bentley_1.Id64.isInvalid(codeSpecId))
40
- throw new core_common_1.IModelError(core_bentley_1.IModelStatus.InvalidId, "Invalid codeSpecId");
41
- // good chance it is already loaded - check there before running a query
42
- const found = this._loadedCodeSpecs.find((codeSpec) => codeSpec.id === codeSpecId);
43
- if (found !== undefined)
44
- return found;
45
- // must load this codespec
46
- const loadedCodeSpec = this.load(codeSpecId);
47
- this._loadedCodeSpecs.push(loadedCodeSpec);
48
- return loadedCodeSpec;
49
- }
50
- /** Returns true if the IModelDb has a CodeSpec of the specified Id. */
51
- hasId(codeSpecId) {
52
- try {
53
- return undefined !== this.getById(codeSpecId);
54
- }
55
- catch (error) {
56
- return false;
57
- }
58
- }
59
- /** Look up a CodeSpec by name. The CodeSpec will be loaded from the database if necessary.
60
- * @param name The name of the CodeSpec to load
61
- * @returns The CodeSpec with the specified name
62
- * @throws [[IModelError]] if no CodeSpec with the specified name could be found.
63
- */
64
- getByName(name) {
65
- // good chance it is already loaded - check there before running a query
66
- const found = this._loadedCodeSpecs.find((codeSpec) => codeSpec.name === name);
67
- if (found !== undefined)
68
- return found;
69
- const codeSpecId = this.queryId(name);
70
- if (codeSpecId === undefined)
71
- throw new core_common_1.IModelError(core_bentley_1.IModelStatus.NotFound, "CodeSpec not found", () => ({ name }));
72
- return this.getById(codeSpecId);
73
- }
74
- /** Returns true if the IModelDb has a CodeSpec of the specified name. */
75
- hasName(name) {
76
- try {
77
- return undefined !== this.getByName(name);
78
- }
79
- catch (error) {
80
- return false;
81
- }
82
- }
83
- insert(codeSpecOrName, scopeType) {
84
- if (codeSpecOrName instanceof core_common_1.CodeSpec) {
85
- const codeSpec = codeSpecOrName;
86
- const id = this._imodel.insertCodeSpec(codeSpec);
87
- codeSpec.id = id;
88
- return id;
89
- }
90
- if (typeof codeSpecOrName === "string") {
91
- const name = codeSpecOrName;
92
- if (scopeType)
93
- return this._imodel.insertCodeSpec(core_common_1.CodeSpec.create(this._imodel, name, scopeType));
94
- }
95
- throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadArg, "Invalid argument");
96
- }
97
- /** Update the Json properties of an existing CodeSpec.
98
- * @param codeSpec The codeSpec holding Json properties values to update
99
- * @throws if unable to update the codeSpec.
100
- */
101
- updateProperties(codeSpec) {
102
- this._imodel.withPreparedSqliteStatement("UPDATE bis_CodeSpec SET JsonProperties=? WHERE Id=?", (stmt) => {
103
- stmt.bindString(1, JSON.stringify(codeSpec.properties));
104
- stmt.bindId(2, codeSpec.id);
105
- if (core_bentley_1.DbResult.BE_SQLITE_DONE !== stmt.step())
106
- throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadArg, "error updating CodeSpec properties");
107
- });
108
- }
109
- /** Load a CodeSpec from the iModel
110
- * @param id The persistent Id of the CodeSpec to load
111
- */
112
- load(id) {
113
- if (core_bentley_1.Id64.isInvalid(id))
114
- throw new core_common_1.IModelError(core_bentley_1.IModelStatus.InvalidId, "Invalid codeSpecId");
115
- return this._imodel.withPreparedStatement("SELECT name,jsonProperties FROM BisCore.CodeSpec WHERE ECInstanceId=?", (stmt) => {
116
- stmt.bindId(1, id);
117
- if (core_bentley_1.DbResult.BE_SQLITE_ROW !== stmt.step())
118
- throw new core_common_1.IModelError(core_bentley_1.IModelStatus.InvalidId, "Invalid codeSpecId");
119
- const row = stmt.getRow();
120
- return core_common_1.CodeSpec.createFromJson(this._imodel, id, row.name, JSON.parse(row.jsonProperties));
121
- });
122
- }
123
- }
124
- exports.CodeSpecs = CodeSpecs;
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module Codes
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.CodeSpecs = void 0;
11
+ const core_bentley_1 = require("@itwin/core-bentley");
12
+ const core_common_1 = require("@itwin/core-common");
13
+ /** Manages [CodeSpecs]($docs/BIS/guide/fundamentals/element-fundamentals.md#codespec) within an [[IModelDb]]
14
+ * @public
15
+ */
16
+ class CodeSpecs {
17
+ constructor(imodel) {
18
+ this._loadedCodeSpecs = [];
19
+ this._imodel = imodel;
20
+ if (imodel.isBriefcaseDb()) {
21
+ imodel.onChangesetApplied.addListener(() => this._loadedCodeSpecs.length = 0);
22
+ }
23
+ }
24
+ findByName(name) {
25
+ return this._imodel.withSqliteStatement(`SELECT Id FROM ${CodeSpecs.tableName} WHERE Name=?`, (stmt) => {
26
+ stmt.bindString(1, name);
27
+ return stmt.nextRow() ? stmt.getValueId(0) : undefined;
28
+ });
29
+ }
30
+ /** Look up the Id of the CodeSpec with the specified name. */
31
+ queryId(name) {
32
+ const id = this.findByName(name);
33
+ if (!id)
34
+ throw new core_common_1.IModelError(core_bentley_1.IModelStatus.NotFound, "CodeSpec not found");
35
+ return id;
36
+ }
37
+ /** Look up a CodeSpec by Id. The CodeSpec will be loaded from the database if necessary.
38
+ * @param codeSpecId The Id of the CodeSpec to load
39
+ * @returns The CodeSpec with the specified Id
40
+ * @throws [[IModelError]] if the Id is invalid or if no CodeSpec with that Id could be found.
41
+ */
42
+ getById(codeSpecId) {
43
+ // good chance it is already loaded - check there before running a query
44
+ const found = this._loadedCodeSpecs.find((codeSpec) => codeSpec.id === codeSpecId);
45
+ if (found !== undefined)
46
+ return found;
47
+ // must load this codespec
48
+ const loadedCodeSpec = this.load(codeSpecId);
49
+ this._loadedCodeSpecs.push(loadedCodeSpec);
50
+ return loadedCodeSpec;
51
+ }
52
+ /** Returns true if the IModelDb has a CodeSpec of the specified Id. */
53
+ hasId(codeSpecId) {
54
+ try {
55
+ return undefined !== this.getById(codeSpecId);
56
+ }
57
+ catch (error) {
58
+ return false;
59
+ }
60
+ }
61
+ /** Look up a CodeSpec by name. The CodeSpec will be loaded from the database if necessary.
62
+ * @param name The name of the CodeSpec to load
63
+ * @returns The CodeSpec with the specified name
64
+ * @throws [[IModelError]] if no CodeSpec with the specified name could be found.
65
+ */
66
+ getByName(name) {
67
+ // good chance it is already loaded - check there before running a query
68
+ const found = this._loadedCodeSpecs.find((codeSpec) => codeSpec.name === name);
69
+ if (found !== undefined)
70
+ return found;
71
+ const codeSpecId = this.queryId(name);
72
+ if (codeSpecId === undefined)
73
+ throw new core_common_1.IModelError(core_bentley_1.IModelStatus.NotFound, "CodeSpec not found");
74
+ return this.getById(codeSpecId);
75
+ }
76
+ /** Returns true if the IModelDb has a CodeSpec of the specified name. */
77
+ hasName(name) {
78
+ try {
79
+ return undefined !== this.getByName(name);
80
+ }
81
+ catch (error) {
82
+ return false;
83
+ }
84
+ }
85
+ insertCodeSpec(specName, properties) {
86
+ const iModel = this._imodel;
87
+ const spec = { name: specName.trim(), props: JSON.stringify(properties) };
88
+ if (this.findByName(spec.name))
89
+ throw new core_common_1.IModelError(core_bentley_1.IModelStatus.DuplicateName, "CodeSpec already exists");
90
+ const internalCodes = iModel.codeService?.internalCodes;
91
+ if (internalCodes) {
92
+ // Since there is no lock on the codespec table, to add a codespec to an iModel it must first be reserved in the
93
+ // internal code index via `internalCodes.reserveBisCodeSpecs` prior to calling this function.
94
+ // This ensures that the Ids will be unique, and the property values consistent, even if more than one user
95
+ // adds them without pushing their changes. The call to `verifyBisCodeSpec` will throw otherwise.
96
+ internalCodes.reader.verifyBisCodeSpec(spec);
97
+ }
98
+ else {
99
+ // If this iModel doesn't have an internal code index, we have no way of coordinating the Ids for CodeSpecs across multiple users.
100
+ // Just look in this briefcase to find the currently highest used Id and hope for the best.
101
+ spec.id = iModel.withSqliteStatement(`SELECT MAX(Id) FROM ${CodeSpecs.tableName}`, (stmt) => stmt.nextRow() ? stmt.getValueInteger(0) + 1 : 1);
102
+ }
103
+ const id = spec.id; // eslint-disable-line @typescript-eslint/no-non-null-assertion
104
+ iModel.withSqliteStatement(`INSERT INTO ${CodeSpecs.tableName}(Id,Name,JsonProperties) VALUES(?,?,?)`, (stmt) => {
105
+ stmt.bindInteger(1, id);
106
+ stmt.bindString(2, spec.name);
107
+ stmt.bindString(3, spec.props);
108
+ const rc = stmt.step();
109
+ if (rc !== core_bentley_1.DbResult.BE_SQLITE_DONE)
110
+ throw new core_bentley_1.BentleyError(rc, "Error inserting codeSpec");
111
+ });
112
+ return core_bentley_1.Id64.fromLocalAndBriefcaseIds(id, 0);
113
+ }
114
+ insert(codeSpecOrName, props) {
115
+ if (codeSpecOrName instanceof core_common_1.CodeSpec) {
116
+ const id = this.insertCodeSpec(codeSpecOrName.name, codeSpecOrName.properties);
117
+ codeSpecOrName.id = id;
118
+ return id;
119
+ }
120
+ if (props === undefined)
121
+ throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadArg, "Invalid argument");
122
+ if (typeof props === "object")
123
+ return this.insertCodeSpec(codeSpecOrName, props);
124
+ const spec = core_common_1.CodeSpec.create(this._imodel, codeSpecOrName, props);
125
+ return this.insertCodeSpec(spec.name, spec.properties);
126
+ }
127
+ /** Update the Json properties of an existing CodeSpec.
128
+ * @param codeSpec The codeSpec holding Json properties values to update
129
+ * @throws if unable to update the codeSpec.
130
+ */
131
+ updateProperties(codeSpec) {
132
+ this._imodel.withSqliteStatement(`UPDATE ${CodeSpecs.tableName} SET JsonProperties=? WHERE Id=?`, (stmt) => {
133
+ stmt.bindString(1, JSON.stringify(codeSpec.properties));
134
+ stmt.bindId(2, codeSpec.id);
135
+ if (core_bentley_1.DbResult.BE_SQLITE_DONE !== stmt.step())
136
+ throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadArg, "error updating CodeSpec properties");
137
+ });
138
+ }
139
+ /** Load a CodeSpec from the iModel
140
+ * @param id The persistent Id of the CodeSpec to load
141
+ */
142
+ load(id) {
143
+ if (core_bentley_1.Id64.isInvalid(id))
144
+ throw new core_common_1.IModelError(core_bentley_1.IModelStatus.InvalidId, "Invalid codeSpecId");
145
+ return this._imodel.withSqliteStatement(`SELECT Name,JsonProperties FROM ${CodeSpecs.tableName} WHERE Id=?`, (stmt) => {
146
+ stmt.bindId(1, id);
147
+ if (!stmt.nextRow())
148
+ throw new core_common_1.IModelError(core_bentley_1.IModelStatus.InvalidId, "CodeSpec not found");
149
+ return core_common_1.CodeSpec.createFromJson(this._imodel, id, stmt.getValueString(0), JSON.parse(stmt.getValueString(1)));
150
+ });
151
+ }
152
+ }
153
+ CodeSpecs.tableName = "bis_CodeSpec";
154
+ exports.CodeSpecs = CodeSpecs;
125
155
  //# sourceMappingURL=CodeSpecs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CodeSpecs.js","sourceRoot":"","sources":["../../src/CodeSpecs.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA+E;AAC/E,oDAA0E;AAI1E;;GAEG;AACH,MAAa,SAAS;IAIpB,YAAY,MAAgB;QAFpB,qBAAgB,GAAe,EAAE,CAAC;QAGxC,IAAI,CAAC,OAAO,GAAG,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G,GAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;YAC/B,OAAO,sBAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC;QAC7F,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AArID,8BAqIC","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 Codes\r\n */\r\n\r\nimport { DbResult, Id64, Id64String, IModelStatus } from \"@itwin/core-bentley\";\r\nimport { CodeScopeSpec, CodeSpec, IModelError } from \"@itwin/core-common\";\r\nimport { ECSqlStatement } from \"./ECSqlStatement\";\r\nimport { IModelDb } from \"./IModelDb\";\r\n\r\n/** Manages [CodeSpecs]($docs/BIS/guide/fundamentals/element-fundamentals.md#codespec) within an [[IModelDb]]\r\n * @public\r\n */\r\nexport class CodeSpecs {\r\n private _imodel: IModelDb;\r\n private _loadedCodeSpecs: CodeSpec[] = [];\r\n\r\n constructor(imodel: IModelDb) {\r\n this._imodel = imodel;\r\n if (imodel.isBriefcaseDb()) {\r\n imodel.onChangesetApplied.addListener(() => this._loadedCodeSpecs.length = 0);\r\n }\r\n }\r\n\r\n /** Look up the Id of the CodeSpec with the specified name. */\r\n public queryId(name: string): Id64String {\r\n return this._imodel.withPreparedStatement(\"SELECT ECInstanceId FROM BisCore.CodeSpec WHERE Name=:name\", (stmt: ECSqlStatement) => {\r\n stmt.bindString(\"name\", name);\r\n if (DbResult.BE_SQLITE_ROW !== stmt.step())\r\n throw new IModelError(IModelStatus.NotFound, \"CodeSpec not found\", () => ({ name }));\r\n return stmt.getValue(0).getId();\r\n });\r\n }\r\n\r\n /** Look up a CodeSpec by Id. The CodeSpec will be loaded from the database if necessary.\r\n * @param codeSpecId The Id of the CodeSpec to load\r\n * @returns The CodeSpec with the specified Id\r\n * @throws [[IModelError]] if the Id is invalid or if no CodeSpec with that Id could be found.\r\n */\r\n public getById(codeSpecId: Id64String): CodeSpec {\r\n if (Id64.isInvalid(codeSpecId))\r\n throw new IModelError(IModelStatus.InvalidId, \"Invalid codeSpecId\");\r\n\r\n // good chance it is already loaded - check there before running a query\r\n const found = this._loadedCodeSpecs.find((codeSpec) => codeSpec.id === codeSpecId);\r\n if (found !== undefined)\r\n return found;\r\n\r\n // must load this codespec\r\n const loadedCodeSpec = this.load(codeSpecId);\r\n this._loadedCodeSpecs.push(loadedCodeSpec);\r\n return loadedCodeSpec;\r\n }\r\n\r\n /** Returns true if the IModelDb has a CodeSpec of the specified Id. */\r\n public hasId(codeSpecId: Id64String): boolean {\r\n try {\r\n return undefined !== this.getById(codeSpecId);\r\n } catch (error) {\r\n return false;\r\n }\r\n }\r\n\r\n /** Look up a CodeSpec by name. The CodeSpec will be loaded from the database if necessary.\r\n * @param name The name of the CodeSpec to load\r\n * @returns The CodeSpec with the specified name\r\n * @throws [[IModelError]] if no CodeSpec with the specified name could be found.\r\n */\r\n public getByName(name: string): CodeSpec {\r\n // good chance it is already loaded - check there before running a query\r\n const found: CodeSpec | undefined = this._loadedCodeSpecs.find((codeSpec) => codeSpec.name === name);\r\n if (found !== undefined)\r\n return found;\r\n const codeSpecId = this.queryId(name);\r\n if (codeSpecId === undefined)\r\n throw new IModelError(IModelStatus.NotFound, \"CodeSpec not found\", () => ({ name }));\r\n return this.getById(codeSpecId);\r\n }\r\n\r\n /** Returns true if the IModelDb has a CodeSpec of the specified name. */\r\n public hasName(name: string): boolean {\r\n try {\r\n return undefined !== this.getByName(name);\r\n } catch (error) {\r\n return false;\r\n }\r\n }\r\n\r\n /** Add a new CodeSpec to the iModel.\r\n * @param codeSpec The CodeSpec to insert\r\n * @returns The Id of the persistent CodeSpec.\r\n * @note If successful, this method will assign a valid CodeSpecId to the supplied CodeSpec\r\n * @throws IModelError if the insertion fails\r\n */\r\n public insert(codeSpec: CodeSpec): Id64String;\r\n /** Add a new CodeSpec to the IModelDb.\r\n * @param name The name for the new CodeSpec.\r\n * @param scopeType The scope type\r\n * @returns The Id of the persistent CodeSpec.\r\n * @throws IModelError if the insertion fails\r\n */\r\n public insert(name: string, scopeType: CodeScopeSpec.Type): Id64String;\r\n public insert(codeSpecOrName: CodeSpec | string, scopeType?: CodeScopeSpec.Type): Id64String {\r\n if (codeSpecOrName instanceof CodeSpec) {\r\n const codeSpec = codeSpecOrName;\r\n const id: Id64String = this._imodel.insertCodeSpec(codeSpec);\r\n codeSpec.id = id;\r\n return id;\r\n }\r\n if (typeof codeSpecOrName === \"string\") {\r\n const name = codeSpecOrName;\r\n if (scopeType)\r\n return this._imodel.insertCodeSpec(CodeSpec.create(this._imodel, name, scopeType));\r\n }\r\n throw new IModelError(IModelStatus.BadArg, \"Invalid argument\");\r\n }\r\n\r\n /** Update the Json properties of an existing CodeSpec.\r\n * @param codeSpec The codeSpec holding Json properties values to update\r\n * @throws if unable to update the codeSpec.\r\n */\r\n public updateProperties(codeSpec: CodeSpec): void {\r\n this._imodel.withPreparedSqliteStatement(\"UPDATE bis_CodeSpec SET JsonProperties=? WHERE Id=?\", (stmt) => {\r\n stmt.bindString(1, JSON.stringify(codeSpec.properties));\r\n stmt.bindId(2, codeSpec.id);\r\n if (DbResult.BE_SQLITE_DONE !== stmt.step())\r\n throw new IModelError(IModelStatus.BadArg, \"error updating CodeSpec properties\");\r\n });\r\n }\r\n\r\n /** Load a CodeSpec from the iModel\r\n * @param id The persistent Id of the CodeSpec to load\r\n */\r\n public load(id: Id64String): CodeSpec {\r\n if (Id64.isInvalid(id))\r\n throw new IModelError(IModelStatus.InvalidId, \"Invalid codeSpecId\");\r\n\r\n return this._imodel.withPreparedStatement(\"SELECT name,jsonProperties FROM BisCore.CodeSpec WHERE ECInstanceId=?\", (stmt: ECSqlStatement) => {\r\n stmt.bindId(1, id);\r\n if (DbResult.BE_SQLITE_ROW !== stmt.step())\r\n throw new IModelError(IModelStatus.InvalidId, \"Invalid codeSpecId\");\r\n\r\n const row: any = stmt.getRow();\r\n return CodeSpec.createFromJson(this._imodel, id, row.name, JSON.parse(row.jsonProperties));\r\n });\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"CodeSpecs.js","sourceRoot":"","sources":["../../src/CodeSpecs.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6F;AAC7F,oDAA8F;AAI9F;;GAEG;AACH,MAAa,SAAS;IAKpB,YAAY,MAAgB;QAFpB,qBAAgB,GAAe,EAAE,CAAC;QAGxC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,MAAM,CAAC,aAAa,EAAE,EAAE;YAC1B,MAAM,CAAC,kBAAkB,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;SAC/E;IACH,CAAC;IAEO,UAAU,CAAC,IAAY;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,kBAAkB,SAAS,CAAC,SAAS,eAAe,EAAE,CAAC,IAAI,EAAE,EAAE;YACrG,IAAI,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;YACzB,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACzD,CAAC,CAAC,CAAC;IACL,CAAC;IAED,8DAA8D;IACvD,OAAO,CAAC,IAAY;QACzB,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,CAAC,EAAE;YACL,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;QACrE,OAAO,EAAE,CAAC;IACZ,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UAAU,CAAC,CAAC,CAAC;YACxD,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC;YAC5B,IAAI,uBAAQ,CAAC,cAAc,KAAK,IAAI,CAAC,IAAI,EAAE;gBACzC,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,MAAM,EAAE,oCAAoC,CAAC,CAAC;QACrF,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACI,IAAI,CAAC,EAAc;QACxB,IAAI,mBAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YACpB,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;QAEtE,OAAO,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,mCAAmC,SAAS,CAAC,SAAS,aAAa,EAAE,CAAC,IAAI,EAAE,EAAE;YACpH,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACnB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;gBACjB,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;YAEtE,OAAO,sBAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/G,CAAC,CAAC,CAAC;IACL,CAAC;;AAvKc,mBAAS,GAAG,cAAc,AAAjB,CAAkB;AAD/B,8BAAS","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 Codes\n */\n\nimport { BentleyError, DbResult, Id64, Id64String, IModelStatus } from \"@itwin/core-bentley\";\nimport { CodeScopeSpec, CodeSpec, CodeSpecProperties, IModelError } from \"@itwin/core-common\";\nimport { IModelDb } from \"./IModelDb\";\nimport { CodeService } from \"./CodeService\";\n\n/** Manages [CodeSpecs]($docs/BIS/guide/fundamentals/element-fundamentals.md#codespec) within an [[IModelDb]]\n * @public\n */\nexport class CodeSpecs {\n private static tableName = \"bis_CodeSpec\";\n private _imodel: IModelDb;\n private _loadedCodeSpecs: CodeSpec[] = [];\n\n constructor(imodel: IModelDb) {\n this._imodel = imodel;\n if (imodel.isBriefcaseDb()) {\n imodel.onChangesetApplied.addListener(() => this._loadedCodeSpecs.length = 0);\n }\n }\n\n private findByName(name: string): Id64String | undefined {\n return this._imodel.withSqliteStatement(`SELECT Id FROM ${CodeSpecs.tableName} WHERE Name=?`, (stmt) => {\n stmt.bindString(1, name);\n return stmt.nextRow() ? stmt.getValueId(0) : undefined;\n });\n }\n\n /** Look up the Id of the CodeSpec with the specified name. */\n public queryId(name: string): Id64String {\n const id = this.findByName(name);\n if (!id)\n throw new IModelError(IModelStatus.NotFound, \"CodeSpec not found\");\n return id;\n }\n\n /** Look up a CodeSpec by Id. The CodeSpec will be loaded from the database if necessary.\n * @param codeSpecId The Id of the CodeSpec to load\n * @returns The CodeSpec with the specified Id\n * @throws [[IModelError]] if the Id is invalid or if no CodeSpec with that Id could be found.\n */\n public getById(codeSpecId: Id64String): CodeSpec {\n // good chance it is already loaded - check there before running a query\n const found = this._loadedCodeSpecs.find((codeSpec) => codeSpec.id === codeSpecId);\n if (found !== undefined)\n return found;\n\n // must load this codespec\n const loadedCodeSpec = this.load(codeSpecId);\n this._loadedCodeSpecs.push(loadedCodeSpec);\n return loadedCodeSpec;\n }\n\n /** Returns true if the IModelDb has a CodeSpec of the specified Id. */\n public hasId(codeSpecId: Id64String): boolean {\n try {\n return undefined !== this.getById(codeSpecId);\n } catch (error) {\n return false;\n }\n }\n\n /** Look up a CodeSpec by name. The CodeSpec will be loaded from the database if necessary.\n * @param name The name of the CodeSpec to load\n * @returns The CodeSpec with the specified name\n * @throws [[IModelError]] if no CodeSpec with the specified name could be found.\n */\n public getByName(name: string): CodeSpec {\n // good chance it is already loaded - check there before running a query\n const found = this._loadedCodeSpecs.find((codeSpec) => codeSpec.name === name);\n if (found !== undefined)\n return found;\n const codeSpecId = this.queryId(name);\n if (codeSpecId === undefined)\n throw new IModelError(IModelStatus.NotFound, \"CodeSpec not found\");\n return this.getById(codeSpecId);\n }\n\n /** Returns true if the IModelDb has a CodeSpec of the specified name. */\n public hasName(name: string): boolean {\n try {\n return undefined !== this.getByName(name);\n } catch (error) {\n return false;\n }\n }\n\n private insertCodeSpec(specName: string, properties: CodeSpecProperties): Id64String {\n const iModel = this._imodel;\n const spec: CodeService.BisCodeSpecIndexProps = { name: specName.trim(), props: JSON.stringify(properties) };\n if (this.findByName(spec.name))\n throw new IModelError(IModelStatus.DuplicateName, \"CodeSpec already exists\");\n\n const internalCodes = iModel.codeService?.internalCodes;\n if (internalCodes) {\n // Since there is no lock on the codespec table, to add a codespec to an iModel it must first be reserved in the\n // internal code index via `internalCodes.reserveBisCodeSpecs` prior to calling this function.\n // This ensures that the Ids will be unique, and the property values consistent, even if more than one user\n // adds them without pushing their changes. The call to `verifyBisCodeSpec` will throw otherwise.\n internalCodes.reader.verifyBisCodeSpec(spec);\n } else {\n // If this iModel doesn't have an internal code index, we have no way of coordinating the Ids for CodeSpecs across multiple users.\n // Just look in this briefcase to find the currently highest used Id and hope for the best.\n spec.id = iModel.withSqliteStatement(`SELECT MAX(Id) FROM ${CodeSpecs.tableName}`, (stmt) => stmt.nextRow() ? stmt.getValueInteger(0) + 1 : 1);\n }\n\n const id = spec.id!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n iModel.withSqliteStatement(`INSERT INTO ${CodeSpecs.tableName}(Id,Name,JsonProperties) VALUES(?,?,?)`, (stmt) => {\n stmt.bindInteger(1, id);\n stmt.bindString(2, spec.name);\n stmt.bindString(3, spec.props);\n const rc = stmt.step();\n if (rc !== DbResult.BE_SQLITE_DONE)\n throw new BentleyError(rc, \"Error inserting codeSpec\");\n });\n\n return Id64.fromLocalAndBriefcaseIds(id, 0);\n }\n\n /** Add a new CodeSpec to the iModel.\n * @param codeSpec The CodeSpec to insert\n * @returns The Id of the persistent CodeSpec.\n * @note If successful, this method will assign a valid CodeSpecId to the supplied CodeSpec\n * @throws IModelError if the insertion fails\n */\n public insert(codeSpec: CodeSpec): Id64String;\n\n /** Add a new CodeSpec to the IModelDb.\n * @param name The name for the new CodeSpec.\n * @param properties The properties or the CodeSpec. For backwards compatibility this may also be a `CodeScopeSpec.Type`.\n * @returns The Id of the persistent CodeSpec.\n * @throws IModelError if the insertion fails\n */\n public insert(name: string, properties: CodeSpecProperties | CodeScopeSpec.Type): Id64String;\n public insert(codeSpecOrName: CodeSpec | string, props?: CodeSpecProperties | CodeScopeSpec.Type): Id64String {\n if (codeSpecOrName instanceof CodeSpec) {\n const id = this.insertCodeSpec(codeSpecOrName.name, codeSpecOrName.properties);\n codeSpecOrName.id = id;\n return id;\n }\n if (props === undefined)\n throw new IModelError(IModelStatus.BadArg, \"Invalid argument\");\n\n if (typeof props === \"object\")\n return this.insertCodeSpec(codeSpecOrName, props);\n\n const spec = CodeSpec.create(this._imodel, codeSpecOrName, props);\n return this.insertCodeSpec(spec.name, spec.properties);\n }\n\n /** Update the Json properties of an existing CodeSpec.\n * @param codeSpec The codeSpec holding Json properties values to update\n * @throws if unable to update the codeSpec.\n */\n public updateProperties(codeSpec: CodeSpec): void {\n this._imodel.withSqliteStatement(`UPDATE ${CodeSpecs.tableName} SET JsonProperties=? WHERE Id=?`, (stmt) => {\n stmt.bindString(1, JSON.stringify(codeSpec.properties));\n stmt.bindId(2, codeSpec.id);\n if (DbResult.BE_SQLITE_DONE !== stmt.step())\n throw new IModelError(IModelStatus.BadArg, \"error updating CodeSpec properties\");\n });\n }\n\n /** Load a CodeSpec from the iModel\n * @param id The persistent Id of the CodeSpec to load\n */\n public load(id: Id64String): CodeSpec {\n if (Id64.isInvalid(id))\n throw new IModelError(IModelStatus.InvalidId, \"Invalid codeSpecId\");\n\n return this._imodel.withSqliteStatement(`SELECT Name,JsonProperties FROM ${CodeSpecs.tableName} WHERE Id=?`, (stmt) => {\n stmt.bindId(1, id);\n if (!stmt.nextRow())\n throw new IModelError(IModelStatus.InvalidId, \"CodeSpec not found\");\n\n return CodeSpec.createFromJson(this._imodel, id, stmt.getValueString(0), JSON.parse(stmt.getValueString(1)));\n });\n }\n}\n"]}
@@ -1,14 +1,14 @@
1
- import { IModelJsNative } from "@bentley/imodeljs-native";
2
- import { DbBlobRequest, DbBlobResponse, DbQueryConfig, DbQueryRequest, DbQueryResponse } from "@itwin/core-common";
3
- /** @internal */
4
- export declare type OnResponse = (response: Response) => void;
5
- /** @internal */
6
- export declare class ConcurrentQuery {
7
- /** @internal */
8
- static executeQueryRequest(conn: IModelJsNative.ECDb | IModelJsNative.DgnDb, request: DbQueryRequest): Promise<DbQueryResponse>;
9
- /** @internal */
10
- static executeBlobRequest(conn: IModelJsNative.ECDb | IModelJsNative.DgnDb, request: DbBlobRequest): Promise<DbBlobResponse>;
11
- static resetConfig(conn: IModelJsNative.ECDb | IModelJsNative.DgnDb, config?: DbQueryConfig): DbQueryConfig;
12
- static shutdown(conn: IModelJsNative.ECDb | IModelJsNative.DgnDb): void;
13
- }
1
+ import { IModelJsNative } from "@bentley/imodeljs-native";
2
+ import { DbBlobRequest, DbBlobResponse, DbQueryConfig, DbQueryRequest, DbQueryResponse } from "@itwin/core-common";
3
+ /** @internal */
4
+ export type OnResponse = (response: Response) => void;
5
+ /** @internal */
6
+ export declare class ConcurrentQuery {
7
+ /** @internal */
8
+ static executeQueryRequest(conn: IModelJsNative.ECDb | IModelJsNative.DgnDb, request: DbQueryRequest): Promise<DbQueryResponse>;
9
+ /** @internal */
10
+ static executeBlobRequest(conn: IModelJsNative.ECDb | IModelJsNative.DgnDb, request: DbBlobRequest): Promise<DbBlobResponse>;
11
+ static resetConfig(conn: IModelJsNative.ECDb | IModelJsNative.DgnDb, config?: DbQueryConfig): DbQueryConfig;
12
+ static shutdown(conn: IModelJsNative.ECDb | IModelJsNative.DgnDb): void;
13
+ }
14
14
  //# sourceMappingURL=ConcurrentQuery.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConcurrentQuery.d.ts","sourceRoot":"","sources":["../../src/ConcurrentQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAK1D,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAiB,MAAM,oBAAoB,CAAC;AAElI,gBAAgB;AAChB,oBAAY,UAAU,GAAG,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAC;AAEtD,gBAAgB;AAChB,qBAAa,eAAe;IAC1B,gBAAgB;WACI,mBAAmB,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,GAAG,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;IAQ5I,gBAAgB;WACI,kBAAkB,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,GAAG,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC;WAQ3H,WAAW,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,GAAG,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,aAAa,GAAG,aAAa;WAGpG,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,GAAG,cAAc,CAAC,KAAK;CAGxE"}
1
+ {"version":3,"file":"ConcurrentQuery.d.ts","sourceRoot":"","sources":["../../src/ConcurrentQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAK1D,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAiB,MAAM,oBAAoB,CAAC;AAElI,gBAAgB;AAChB,MAAM,MAAM,UAAU,GAAG,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAC;AAEtD,gBAAgB;AAChB,qBAAa,eAAe;IAC1B,gBAAgB;WACI,mBAAmB,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,GAAG,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;IAQ5I,gBAAgB;WACI,kBAAkB,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,GAAG,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC;WAQ3H,WAAW,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,GAAG,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,aAAa,GAAG,aAAa;WAGpG,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,GAAG,cAAc,CAAC,KAAK;CAGxE"}
@@ -1,37 +1,37 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ConcurrentQuery = 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
- const core_common_1 = require("@itwin/core-common");
9
- /** @internal */
10
- class ConcurrentQuery {
11
- /** @internal */
12
- static async executeQueryRequest(conn, request) {
13
- return new Promise((resolve) => {
14
- request.kind = core_common_1.DbRequestKind.ECSql;
15
- conn.concurrentQueryExecute(request, (response) => {
16
- resolve(response);
17
- });
18
- });
19
- }
20
- /** @internal */
21
- static async executeBlobRequest(conn, request) {
22
- return new Promise((resolve) => {
23
- request.kind = core_common_1.DbRequestKind.BlobIO;
24
- conn.concurrentQueryExecute(request, (response) => {
25
- resolve(response);
26
- });
27
- });
28
- }
29
- static resetConfig(conn, config) {
30
- return conn.concurrentQueryResetConfig(config);
31
- }
32
- static shutdown(conn) {
33
- conn.concurrentQueryShutdown();
34
- }
35
- }
36
- exports.ConcurrentQuery = ConcurrentQuery;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConcurrentQuery = 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
+ const core_common_1 = require("@itwin/core-common");
9
+ /** @internal */
10
+ class ConcurrentQuery {
11
+ /** @internal */
12
+ static async executeQueryRequest(conn, request) {
13
+ return new Promise((resolve) => {
14
+ request.kind = core_common_1.DbRequestKind.ECSql;
15
+ conn.concurrentQueryExecute(request, (response) => {
16
+ resolve(response);
17
+ });
18
+ });
19
+ }
20
+ /** @internal */
21
+ static async executeBlobRequest(conn, request) {
22
+ return new Promise((resolve) => {
23
+ request.kind = core_common_1.DbRequestKind.BlobIO;
24
+ conn.concurrentQueryExecute(request, (response) => {
25
+ resolve(response);
26
+ });
27
+ });
28
+ }
29
+ static resetConfig(conn, config) {
30
+ return conn.concurrentQueryResetConfig(config);
31
+ }
32
+ static shutdown(conn) {
33
+ conn.concurrentQueryShutdown();
34
+ }
35
+ }
36
+ exports.ConcurrentQuery = ConcurrentQuery;
37
37
  //# sourceMappingURL=ConcurrentQuery.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConcurrentQuery.js","sourceRoot":"","sources":["../../src/ConcurrentQuery.ts"],"names":[],"mappings":";;;AACA;;;+FAG+F;AAC/F,oDAAkI;AAKlI,gBAAgB;AAChB,MAAa,eAAe;IAC1B,gBAAgB;IACT,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,IAAgD,EAAE,OAAuB;QAC/G,OAAO,IAAI,OAAO,CAAkB,CAAC,OAAO,EAAE,EAAE;YAC9C,OAAO,CAAC,IAAI,GAAG,2BAAa,CAAC,KAAK,CAAC;YACnC,IAAI,CAAC,sBAAsB,CAAC,OAAc,EAAE,CAAC,QAAa,EAAE,EAAE;gBAC5D,OAAO,CAAC,QAA2B,CAAC,CAAC;YACvC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IACD,gBAAgB;IACT,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,IAAgD,EAAE,OAAsB;QAC7G,OAAO,IAAI,OAAO,CAAiB,CAAC,OAAO,EAAE,EAAE;YAC7C,OAAO,CAAC,IAAI,GAAG,2BAAa,CAAC,MAAM,CAAC;YACpC,IAAI,CAAC,sBAAsB,CAAC,OAAc,EAAE,CAAC,QAAa,EAAE,EAAE;gBAC5D,OAAO,CAAC,QAA0B,CAAC,CAAC;YACtC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IACM,MAAM,CAAC,WAAW,CAAC,IAAgD,EAAE,MAAsB;QAChG,OAAO,IAAI,CAAC,0BAA0B,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;IACM,MAAM,CAAC,QAAQ,CAAC,IAAgD;QACrE,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;CACF;AAzBD,0CAyBC","sourcesContent":["import { IModelJsNative } from \"@bentley/imodeljs-native\";\r\n/*---------------------------------------------------------------------------------------------\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\nimport { DbBlobRequest, DbBlobResponse, DbQueryConfig, DbQueryRequest, DbQueryResponse, DbRequestKind } from \"@itwin/core-common\";\r\n\r\n/** @internal */\r\nexport type OnResponse = (response: Response) => void;\r\n\r\n/** @internal */\r\nexport class ConcurrentQuery {\r\n /** @internal */\r\n public static async executeQueryRequest(conn: IModelJsNative.ECDb | IModelJsNative.DgnDb, request: DbQueryRequest): Promise<DbQueryResponse> {\r\n return new Promise<DbQueryResponse>((resolve) => {\r\n request.kind = DbRequestKind.ECSql;\r\n conn.concurrentQueryExecute(request as any, (response: any) => {\r\n resolve(response as DbQueryResponse);\r\n });\r\n });\r\n }\r\n /** @internal */\r\n public static async executeBlobRequest(conn: IModelJsNative.ECDb | IModelJsNative.DgnDb, request: DbBlobRequest): Promise<DbBlobResponse> {\r\n return new Promise<DbBlobResponse>((resolve) => {\r\n request.kind = DbRequestKind.BlobIO;\r\n conn.concurrentQueryExecute(request as any, (response: any) => {\r\n resolve(response as DbBlobResponse);\r\n });\r\n });\r\n }\r\n public static resetConfig(conn: IModelJsNative.ECDb | IModelJsNative.DgnDb, config?: DbQueryConfig): DbQueryConfig {\r\n return conn.concurrentQueryResetConfig(config);\r\n }\r\n public static shutdown(conn: IModelJsNative.ECDb | IModelJsNative.DgnDb) {\r\n conn.concurrentQueryShutdown();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ConcurrentQuery.js","sourceRoot":"","sources":["../../src/ConcurrentQuery.ts"],"names":[],"mappings":";;;AACA;;;+FAG+F;AAC/F,oDAAkI;AAKlI,gBAAgB;AAChB,MAAa,eAAe;IAC1B,gBAAgB;IACT,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,IAAgD,EAAE,OAAuB;QAC/G,OAAO,IAAI,OAAO,CAAkB,CAAC,OAAO,EAAE,EAAE;YAC9C,OAAO,CAAC,IAAI,GAAG,2BAAa,CAAC,KAAK,CAAC;YACnC,IAAI,CAAC,sBAAsB,CAAC,OAAc,EAAE,CAAC,QAAa,EAAE,EAAE;gBAC5D,OAAO,CAAC,QAA2B,CAAC,CAAC;YACvC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IACD,gBAAgB;IACT,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,IAAgD,EAAE,OAAsB;QAC7G,OAAO,IAAI,OAAO,CAAiB,CAAC,OAAO,EAAE,EAAE;YAC7C,OAAO,CAAC,IAAI,GAAG,2BAAa,CAAC,MAAM,CAAC;YACpC,IAAI,CAAC,sBAAsB,CAAC,OAAc,EAAE,CAAC,QAAa,EAAE,EAAE;gBAC5D,OAAO,CAAC,QAA0B,CAAC,CAAC;YACtC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IACM,MAAM,CAAC,WAAW,CAAC,IAAgD,EAAE,MAAsB;QAChG,OAAO,IAAI,CAAC,0BAA0B,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;IACM,MAAM,CAAC,QAAQ,CAAC,IAAgD;QACrE,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;CACF;AAzBD,0CAyBC","sourcesContent":["import { IModelJsNative } from \"@bentley/imodeljs-native\";\n/*---------------------------------------------------------------------------------------------\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*--------------------------------------------------------------------------------------------*/\nimport { DbBlobRequest, DbBlobResponse, DbQueryConfig, DbQueryRequest, DbQueryResponse, DbRequestKind } from \"@itwin/core-common\";\n\n/** @internal */\nexport type OnResponse = (response: Response) => void;\n\n/** @internal */\nexport class ConcurrentQuery {\n /** @internal */\n public static async executeQueryRequest(conn: IModelJsNative.ECDb | IModelJsNative.DgnDb, request: DbQueryRequest): Promise<DbQueryResponse> {\n return new Promise<DbQueryResponse>((resolve) => {\n request.kind = DbRequestKind.ECSql;\n conn.concurrentQueryExecute(request as any, (response: any) => {\n resolve(response as DbQueryResponse);\n });\n });\n }\n /** @internal */\n public static async executeBlobRequest(conn: IModelJsNative.ECDb | IModelJsNative.DgnDb, request: DbBlobRequest): Promise<DbBlobResponse> {\n return new Promise<DbBlobResponse>((resolve) => {\n request.kind = DbRequestKind.BlobIO;\n conn.concurrentQueryExecute(request as any, (response: any) => {\n resolve(response as DbBlobResponse);\n });\n });\n }\n public static resetConfig(conn: IModelJsNative.ECDb | IModelJsNative.DgnDb, config?: DbQueryConfig): DbQueryConfig {\n return conn.concurrentQueryResetConfig(config);\n }\n public static shutdown(conn: IModelJsNative.ECDb | IModelJsNative.DgnDb) {\n conn.concurrentQueryShutdown();\n }\n}\n"]}
@@ -1,22 +1,22 @@
1
- import { CustomViewState3dCreatorOptions, CustomViewState3dProps } from "@itwin/core-common";
2
- import { IModelDb } from "./IModelDb";
3
- /**
4
- * Class which helps to generate a custom ViewState3d.
5
- * @internal
6
- */
7
- export declare class CustomViewState3dCreator {
8
- private _imodel;
9
- constructor(iModel: IModelDb);
10
- /** Gets default view state data such as category Ids and modelextents. If no model ids are passed in, all 3D models in the iModel are used.
11
- * @param [modelIds] Ids of models to display in the view.
12
- * @throws [IModelError]($common) If no 3d models are found in the iModel.
13
- */
14
- getCustomViewState3dData(options: CustomViewState3dCreatorOptions): Promise<CustomViewState3dProps>;
15
- private _getAllCategories;
16
- /** Compute the union of the extents of all the specified models. */
17
- private _getModelExtents;
18
- /** Get the Ids of all spatially-located, non-template 3d models in the iModel. */
19
- private _getAllModels;
20
- private _executeQuery;
21
- }
1
+ import { CustomViewState3dCreatorOptions, CustomViewState3dProps } from "@itwin/core-common";
2
+ import { IModelDb } from "./IModelDb";
3
+ /**
4
+ * Class which helps to generate a custom ViewState3d.
5
+ * @internal
6
+ */
7
+ export declare class CustomViewState3dCreator {
8
+ private _imodel;
9
+ constructor(iModel: IModelDb);
10
+ /** Gets default view state data such as category Ids and modelextents. If no model ids are passed in, all 3D models in the iModel are used.
11
+ * @param [modelIds] Ids of models to display in the view.
12
+ * @throws [IModelError]($common) If no 3d models are found in the iModel.
13
+ */
14
+ getCustomViewState3dData(options: CustomViewState3dCreatorOptions): Promise<CustomViewState3dProps>;
15
+ private _getAllCategories;
16
+ /** Compute the union of the extents of all the specified models. */
17
+ private _getModelExtents;
18
+ /** Get the Ids of all spatially-located, non-template 3d models in the iModel. */
19
+ private _getAllModels;
20
+ private _executeQuery;
21
+ }
22
22
  //# sourceMappingURL=CustomViewState3dCreator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CustomViewState3dCreator.d.ts","sourceRoot":"","sources":["../../src/CustomViewState3dCreator.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,+BAA+B,EAAE,sBAAsB,EAAkB,MAAM,oBAAoB,CAAC;AAG7G,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAItC;;;GAGG;AACH,qBAAa,wBAAwB;IACnC,OAAO,CAAC,OAAO,CAAW;gBACP,MAAM,EAAE,QAAQ;IAGnC;;;OAGG;IACU,wBAAwB,CAAC,OAAO,EAAE,+BAA+B,GAAG,OAAO,CAAC,sBAAsB,CAAC;YAelG,iBAAiB;IAS/B,oEAAoE;YACtD,gBAAgB;IAa9B,kFAAkF;YACpE,aAAa;IAmB3B,OAAO,CAAC,aAAa,CAMnB;CACH"}
1
+ {"version":3,"file":"CustomViewState3dCreator.d.ts","sourceRoot":"","sources":["../../src/CustomViewState3dCreator.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,+BAA+B,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAG7F,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAItC;;;GAGG;AACH,qBAAa,wBAAwB;IACnC,OAAO,CAAC,OAAO,CAAW;gBACP,MAAM,EAAE,QAAQ;IAGnC;;;OAGG;IACU,wBAAwB,CAAC,OAAO,EAAE,+BAA+B,GAAG,OAAO,CAAC,sBAAsB,CAAC;YAelG,iBAAiB;IAS/B,oEAAoE;YACtD,gBAAgB;IAa9B,kFAAkF;YACpE,aAAa;IAmB3B,OAAO,CAAC,aAAa,CAMnB;CACH"}