@itwin/core-backend 3.7.11 → 3.7.12

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 (244) hide show
  1. package/CHANGELOG.md +6 -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 -170
  15. package/lib/cjs/BriefcaseManager.js +414 -414
  16. package/lib/cjs/BriefcaseManager.js.map +1 -1
  17. package/lib/cjs/Category.d.ts +153 -153
  18. package/lib/cjs/Category.js +243 -243
  19. package/lib/cjs/Category.js.map +1 -1
  20. package/lib/cjs/ChangeSummaryManager.d.ts +187 -187
  21. package/lib/cjs/ChangeSummaryManager.js +447 -447
  22. package/lib/cjs/ChangeSummaryManager.js.map +1 -1
  23. package/lib/cjs/ChangedElementsDb.d.ts +99 -99
  24. package/lib/cjs/ChangedElementsDb.js +165 -165
  25. package/lib/cjs/ChangedElementsDb.js.map +1 -1
  26. package/lib/cjs/ChangedElementsManager.d.ts +39 -39
  27. package/lib/cjs/ChangedElementsManager.js +88 -88
  28. package/lib/cjs/ChangedElementsManager.js.map +1 -1
  29. package/lib/cjs/CheckpointManager.d.ts +121 -121
  30. package/lib/cjs/CheckpointManager.js +363 -363
  31. package/lib/cjs/CheckpointManager.js.map +1 -1
  32. package/lib/cjs/ClassRegistry.d.ts +79 -79
  33. package/lib/cjs/ClassRegistry.js +250 -250
  34. package/lib/cjs/ClassRegistry.js.map +1 -1
  35. package/lib/cjs/CloudSqlite.d.ts +350 -350
  36. package/lib/cjs/CloudSqlite.js +153 -153
  37. package/lib/cjs/CloudSqlite.js.map +1 -1
  38. package/lib/cjs/CloudStorageBackend.d.ts +58 -58
  39. package/lib/cjs/CloudStorageBackend.js +173 -173
  40. package/lib/cjs/CloudStorageBackend.js.map +1 -1
  41. package/lib/cjs/CodeService.d.ts +396 -396
  42. package/lib/cjs/CodeService.js +63 -63
  43. package/lib/cjs/CodeService.js.map +1 -1
  44. package/lib/cjs/CodeSpecs.d.ts +55 -55
  45. package/lib/cjs/CodeSpecs.js +124 -124
  46. package/lib/cjs/CodeSpecs.js.map +1 -1
  47. package/lib/cjs/ConcurrentQuery.d.ts +13 -13
  48. package/lib/cjs/ConcurrentQuery.js +36 -36
  49. package/lib/cjs/ConcurrentQuery.js.map +1 -1
  50. package/lib/cjs/CustomViewState3dCreator.d.ts +21 -21
  51. package/lib/cjs/CustomViewState3dCreator.js +82 -82
  52. package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
  53. package/lib/cjs/DevTools.d.ts +71 -71
  54. package/lib/cjs/DevTools.js +154 -154
  55. package/lib/cjs/DevTools.js.map +1 -1
  56. package/lib/cjs/DisplayStyle.d.ts +106 -106
  57. package/lib/cjs/DisplayStyle.js +256 -256
  58. package/lib/cjs/DisplayStyle.js.map +1 -1
  59. package/lib/cjs/ECDb.d.ts +194 -194
  60. package/lib/cjs/ECDb.js +355 -355
  61. package/lib/cjs/ECDb.js.map +1 -1
  62. package/lib/cjs/ECSchemaXmlContext.d.ts +18 -18
  63. package/lib/cjs/ECSchemaXmlContext.js +41 -41
  64. package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
  65. package/lib/cjs/ECSqlStatement.d.ts +473 -473
  66. package/lib/cjs/ECSqlStatement.js +791 -791
  67. package/lib/cjs/ECSqlStatement.js.map +1 -1
  68. package/lib/cjs/Element.d.ts +1109 -1109
  69. package/lib/cjs/Element.js +1427 -1427
  70. package/lib/cjs/Element.js.map +1 -1
  71. package/lib/cjs/ElementAspect.d.ts +179 -179
  72. package/lib/cjs/ElementAspect.js +211 -211
  73. package/lib/cjs/ElementAspect.js.map +1 -1
  74. package/lib/cjs/ElementGraphics.d.ts +9 -9
  75. package/lib/cjs/ElementGraphics.js +41 -41
  76. package/lib/cjs/ElementGraphics.js.map +1 -1
  77. package/lib/cjs/ElementTreeWalker.d.ts +162 -162
  78. package/lib/cjs/ElementTreeWalker.js +409 -409
  79. package/lib/cjs/ElementTreeWalker.js.map +1 -1
  80. package/lib/cjs/Entity.d.ts +106 -106
  81. package/lib/cjs/Entity.js +134 -134
  82. package/lib/cjs/Entity.js.map +1 -1
  83. package/lib/cjs/EntityReferences.d.ts +49 -49
  84. package/lib/cjs/EntityReferences.js +95 -95
  85. package/lib/cjs/EntityReferences.js.map +1 -1
  86. package/lib/cjs/ExportGraphics.d.ts +317 -317
  87. package/lib/cjs/ExportGraphics.js +208 -208
  88. package/lib/cjs/ExportGraphics.js.map +1 -1
  89. package/lib/cjs/ExternalSource.d.ts +96 -96
  90. package/lib/cjs/ExternalSource.js +131 -131
  91. package/lib/cjs/ExternalSource.js.map +1 -1
  92. package/lib/cjs/GeoCoordConfig.d.ts +19 -19
  93. package/lib/cjs/GeoCoordConfig.js +85 -85
  94. package/lib/cjs/GeoCoordConfig.js.map +1 -1
  95. package/lib/cjs/GeometrySummary.d.ts +4 -4
  96. package/lib/cjs/GeometrySummary.js +380 -380
  97. package/lib/cjs/GeometrySummary.js.map +1 -1
  98. package/lib/cjs/HubMock.d.ts +94 -94
  99. package/lib/cjs/HubMock.js +222 -222
  100. package/lib/cjs/HubMock.js.map +1 -1
  101. package/lib/cjs/IModelCloneContext.d.ts +8 -8
  102. package/lib/cjs/IModelCloneContext.js +15 -15
  103. package/lib/cjs/IModelCloneContext.js.map +1 -1
  104. package/lib/cjs/IModelDb.d.ts +1213 -1213
  105. package/lib/cjs/IModelDb.js +2392 -2392
  106. package/lib/cjs/IModelDb.js.map +1 -1
  107. package/lib/cjs/IModelElementCloneContext.d.ts +89 -89
  108. package/lib/cjs/IModelElementCloneContext.js +159 -159
  109. package/lib/cjs/IModelElementCloneContext.js.map +1 -1
  110. package/lib/cjs/IModelHost.d.ts +370 -370
  111. package/lib/cjs/IModelHost.js +497 -497
  112. package/lib/cjs/IModelHost.js.map +1 -1
  113. package/lib/cjs/IModelJsFs.d.ts +62 -62
  114. package/lib/cjs/IModelJsFs.js +140 -140
  115. package/lib/cjs/IModelJsFs.js.map +1 -1
  116. package/lib/cjs/IpcHost.d.ts +104 -104
  117. package/lib/cjs/IpcHost.js +278 -278
  118. package/lib/cjs/IpcHost.js.map +1 -1
  119. package/lib/cjs/LineStyle.d.ts +311 -311
  120. package/lib/cjs/LineStyle.js +295 -295
  121. package/lib/cjs/LineStyle.js.map +1 -1
  122. package/lib/cjs/LocalHub.d.ts +162 -162
  123. package/lib/cjs/LocalHub.js +585 -585
  124. package/lib/cjs/LocalHub.js.map +1 -1
  125. package/lib/cjs/LocalhostIpcHost.d.ts +21 -21
  126. package/lib/cjs/LocalhostIpcHost.js +81 -81
  127. package/lib/cjs/LocalhostIpcHost.js.map +1 -1
  128. package/lib/cjs/Material.d.ts +131 -131
  129. package/lib/cjs/Material.js +181 -181
  130. package/lib/cjs/Material.js.map +1 -1
  131. package/lib/cjs/Model.d.ts +392 -392
  132. package/lib/cjs/Model.js +485 -485
  133. package/lib/cjs/Model.js.map +1 -1
  134. package/lib/cjs/NativeAppStorage.d.ts +51 -51
  135. package/lib/cjs/NativeAppStorage.js +202 -202
  136. package/lib/cjs/NativeAppStorage.js.map +1 -1
  137. package/lib/cjs/NativeHost.d.ts +52 -52
  138. package/lib/cjs/NativeHost.js +163 -163
  139. package/lib/cjs/NativeHost.js.map +1 -1
  140. package/lib/cjs/NavigationRelationship.d.ts +156 -156
  141. package/lib/cjs/NavigationRelationship.js +225 -225
  142. package/lib/cjs/NavigationRelationship.js.map +1 -1
  143. package/lib/cjs/PromiseMemoizer.d.ts +51 -51
  144. package/lib/cjs/PromiseMemoizer.js +101 -101
  145. package/lib/cjs/PromiseMemoizer.js.map +1 -1
  146. package/lib/cjs/PropertyStore.d.ts +132 -132
  147. package/lib/cjs/PropertyStore.js +11 -11
  148. package/lib/cjs/PropertyStore.js.map +1 -1
  149. package/lib/cjs/Relationship.d.ts +416 -416
  150. package/lib/cjs/Relationship.js +494 -494
  151. package/lib/cjs/Relationship.js.map +1 -1
  152. package/lib/cjs/RpcBackend.d.ts +5 -5
  153. package/lib/cjs/RpcBackend.js +32 -32
  154. package/lib/cjs/RpcBackend.js.map +1 -1
  155. package/lib/cjs/SQLiteDb.d.ts +219 -219
  156. package/lib/cjs/SQLiteDb.js +214 -214
  157. package/lib/cjs/SQLiteDb.js.map +1 -1
  158. package/lib/cjs/Schema.d.ts +55 -55
  159. package/lib/cjs/Schema.js +83 -83
  160. package/lib/cjs/Schema.js.map +1 -1
  161. package/lib/cjs/ServerBasedLocks.d.ts +57 -57
  162. package/lib/cjs/ServerBasedLocks.js +168 -168
  163. package/lib/cjs/ServerBasedLocks.js.map +1 -1
  164. package/lib/cjs/SqliteStatement.d.ts +360 -360
  165. package/lib/cjs/SqliteStatement.js +586 -586
  166. package/lib/cjs/SqliteStatement.js.map +1 -1
  167. package/lib/cjs/Texture.d.ts +58 -58
  168. package/lib/cjs/Texture.js +82 -82
  169. package/lib/cjs/Texture.js.map +1 -1
  170. package/lib/cjs/TileStorage.d.ts +25 -25
  171. package/lib/cjs/TileStorage.js +102 -102
  172. package/lib/cjs/TileStorage.js.map +1 -1
  173. package/lib/cjs/TxnManager.d.ts +202 -202
  174. package/lib/cjs/TxnManager.js +356 -356
  175. package/lib/cjs/TxnManager.js.map +1 -1
  176. package/lib/cjs/ViewDefinition.d.ts +439 -439
  177. package/lib/cjs/ViewDefinition.js +646 -646
  178. package/lib/cjs/ViewDefinition.js.map +1 -1
  179. package/lib/cjs/ViewStateHydrator.d.ts +13 -13
  180. package/lib/cjs/ViewStateHydrator.js +103 -103
  181. package/lib/cjs/ViewStateHydrator.js.map +1 -1
  182. package/lib/cjs/assets/IModelChange.02.00.00.ecschema.xml +90 -90
  183. package/lib/cjs/assets/Settings/Schemas/Cloud.Schema.json +67 -67
  184. package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +31 -31
  185. package/lib/cjs/assets/Settings/Schemas/Workspace.Schema.json +52 -52
  186. package/lib/cjs/assets/Settings/backend.setting.json5 +138 -138
  187. package/lib/cjs/core-backend.d.ts +184 -184
  188. package/lib/cjs/core-backend.js +204 -204
  189. package/lib/cjs/core-backend.js.map +1 -1
  190. package/lib/cjs/domains/FunctionalElements.d.ts +101 -101
  191. package/lib/cjs/domains/FunctionalElements.js +145 -145
  192. package/lib/cjs/domains/FunctionalElements.js.map +1 -1
  193. package/lib/cjs/domains/FunctionalSchema.d.ts +13 -13
  194. package/lib/cjs/domains/FunctionalSchema.js +40 -40
  195. package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
  196. package/lib/cjs/domains/GenericElements.d.ts +177 -177
  197. package/lib/cjs/domains/GenericElements.js +263 -263
  198. package/lib/cjs/domains/GenericElements.js.map +1 -1
  199. package/lib/cjs/domains/GenericSchema.d.ts +10 -10
  200. package/lib/cjs/domains/GenericSchema.js +28 -28
  201. package/lib/cjs/domains/GenericSchema.js.map +1 -1
  202. package/lib/cjs/rpc/multipart.d.ts +11 -11
  203. package/lib/cjs/rpc/multipart.js +71 -71
  204. package/lib/cjs/rpc/multipart.js.map +1 -1
  205. package/lib/cjs/rpc/tracing.d.ts +28 -28
  206. package/lib/cjs/rpc/tracing.js +74 -74
  207. package/lib/cjs/rpc/tracing.js.map +1 -1
  208. package/lib/cjs/rpc/web/logging.d.ts +9 -9
  209. package/lib/cjs/rpc/web/logging.js +43 -43
  210. package/lib/cjs/rpc/web/logging.js.map +1 -1
  211. package/lib/cjs/rpc/web/request.d.ts +6 -6
  212. package/lib/cjs/rpc/web/request.js +74 -74
  213. package/lib/cjs/rpc/web/request.js.map +1 -1
  214. package/lib/cjs/rpc/web/response.d.ts +6 -6
  215. package/lib/cjs/rpc/web/response.js +106 -106
  216. package/lib/cjs/rpc/web/response.js.map +1 -1
  217. package/lib/cjs/rpc-impl/DevToolsRpcImpl.d.ts +15 -15
  218. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js +32 -32
  219. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js.map +1 -1
  220. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +47 -47
  221. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +294 -294
  222. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  223. package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts +22 -22
  224. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +211 -211
  225. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
  226. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts +36 -36
  227. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +168 -168
  228. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  229. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.d.ts +16 -16
  230. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js +43 -43
  231. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
  232. package/lib/cjs/rpc-impl/WipRpcImpl.d.ts +15 -15
  233. package/lib/cjs/rpc-impl/WipRpcImpl.js +37 -37
  234. package/lib/cjs/rpc-impl/WipRpcImpl.js.map +1 -1
  235. package/lib/cjs/workspace/Settings.d.ts +186 -186
  236. package/lib/cjs/workspace/Settings.js +155 -155
  237. package/lib/cjs/workspace/Settings.js.map +1 -1
  238. package/lib/cjs/workspace/SettingsSchemas.d.ts +75 -75
  239. package/lib/cjs/workspace/SettingsSchemas.js +191 -191
  240. package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
  241. package/lib/cjs/workspace/Workspace.d.ts +414 -414
  242. package/lib/cjs/workspace/Workspace.js +543 -543
  243. package/lib/cjs/workspace/Workspace.js.map +1 -1
  244. package/package.json +11 -11
@@ -1,397 +1,397 @@
1
- import { AccessToken, BentleyError, GuidString, MarkRequired, Mutable } from "@itwin/core-bentley";
2
- import { CodeProps } from "@itwin/core-common";
3
- import { CloudSqlite } from "./CloudSqlite";
4
- import { IModelDb } from "./IModelDb";
5
- import { SettingObject } from "./workspace/Settings";
6
- /**
7
- * A readonly index of all known Codes for an iTwin. The CodeIndex may be slightly out-of-date
8
- * with the master copy in the cloud, but it should be periodically synchronized. Whenever codes are reserved/updated/deleted
9
- * locally, this copy is always up-to-date as of those changes.
10
- * @alpha
11
- */
12
- export interface CodeIndex {
13
- /**
14
- * Find the next available value for the supplied `SequenceScope`.
15
- * If the sequence is full (there are no available values), this will throw an exception with `errorId="SequenceFull"`
16
- * @param from the sequence and scope to search
17
- * @returns the next available CodeValue in the sequence.
18
- */
19
- findNextAvailable(from: CodeService.SequenceScope): CodeService.CodeValue;
20
- /**
21
- * Find the highest currently used value for the supplied `SequenceScope`
22
- * @param from the sequence and scope to search
23
- * @returns the highest used value, or undefined if no values have been used.
24
- */
25
- findHighestUsed(from: CodeService.SequenceScope): CodeService.CodeValue | undefined;
26
- /** Determine whether a code is present in this CodeIndex by its Guid. */
27
- isCodePresent(guid: CodeService.CodeGuid): boolean;
28
- /** Get the data for a code in this CodeIndex by its Guid.
29
- * @returns the data for the code or undefined if no code is present for the supplied Guid.
30
- */
31
- getCode(guid: CodeService.CodeGuid): CodeService.CodeEntry | undefined;
32
- /** Look up a code by its Scope, Spec, and Value.
33
- * @returns the Guid of the code, or undefined if not present.
34
- */
35
- findCode(code: CodeService.ScopeSpecAndValue): CodeService.CodeGuid | undefined;
36
- /** Look up a code spec by its name
37
- * @throws if the spec is not present.
38
- */
39
- getCodeSpec(props: CodeService.CodeSpecName): CodeService.NameAndJson;
40
- /** Call a `CodeIteration` function for all codes in this index, optionally filtered by a `CodeFilter ` */
41
- forAllCodes(iter: CodeService.CodeIteration, filter?: CodeService.CodeFilter): void;
42
- /** Call an iteration function for all code specs in this index, optionally filtered by a `ValueFilter ` */
43
- forAllCodeSpecs(iter: CodeService.NameAndJsonIteration, filter?: CodeService.ValueFilter): void;
44
- }
45
- /**
46
- * The services for querying, reserving, updating, and deleting codes for a BriefcaseDb (available via `BriefcaseDb.codeService`) whenever it is opened for write access.
47
- * @alpha
48
- */
49
- export interface CodeService {
50
- /** @internal */
51
- close: () => void;
52
- /** @internal */
53
- addAllCodeSpecs(iModel: IModelDb): Promise<void>;
54
- /** the code index for this CodeService */
55
- readonly codeIndex: CodeIndex;
56
- /**
57
- * Application-supplied parameters for obtaining the write lock on the container.
58
- * Applications should set these parameters by adding a listener for `BriefcaseDb.onCodeServiceCreated`
59
- * that is called every time a BriefcaseDb that uses code services is opened for write access.
60
- */
61
- readonly lockParams: CloudSqlite.ObtainLockParams;
62
- /**
63
- * Application-supplied parameters for reserving new codes.
64
- * @see lockParams
65
- */
66
- readonly appParams: CodeService.AuthorAndOrigin;
67
- /**
68
- * The token that grants access to the cloud container for this CodeService.
69
- * It should be established in a listener for `BriefcaseDb.onCodeServiceCreated`, and should be refreshed (via a
70
- * timer) before it expires.
71
- */
72
- sasToken: AccessToken;
73
- /**
74
- * Synchronize the local index with any changes by made by others.
75
- * @note This is called automatically whenever any write operation is performed on the code index. It is only necessary to
76
- * call this directly if you have not changed the code index recently, but wish to perform a readonly operation and want to
77
- * ensure it is up-to-date as of now.
78
- * @note There is no guarantee that a readonly index is up-to-date even immediately after calling this method, since others
79
- * may be modifying it at any time.
80
- */
81
- synchronizeWithCloud(): void;
82
- /**
83
- * Verify that the Code of a to-be-inserted or to-be-updated Element:
84
- * 1. has already been reserved,
85
- * 2. if the element has a `federationGuid`, it must match the reserved value. If the federationGuid is undefined,
86
- * the value from the code index is returned.
87
- *
88
- * If not, throw an exception. Elements with no CodeValue are ignored.
89
- * @note this method is automatically called whenever elements are added or updated by a BriefcaseDb with a CodeService.
90
- */
91
- verifyCode(props: CodeService.ElementCodeProps): void;
92
- /** Add a new code spec to this code service.
93
- * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.
94
- */
95
- addCodeSpec(val: CodeService.NameAndJson): Promise<void>;
96
- /**
97
- * Add all of the codes and code specs from this CodeService's BriefcaseDb into the code index.
98
- * @returns the number of codes actually added.
99
- * @note It is not necessary to call this method unless the BriefcaseDb somehow becomes out of sync with its CodeService,
100
- * for example when migrating iModels to a new code service. It is safe (but relatively expensive) to call this method multiple times, since
101
- * any codes or code specs that are already in the index are ignored.
102
- * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.
103
- */
104
- addAllCodes(iModel: IModelDb): Promise<number>;
105
- /**
106
- * Attempt to reserve a single proposed code.
107
- * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.
108
- * @throws `CodeService.Error` if the proposed code cannot be reserved.
109
- */
110
- reserveCode(code: CodeService.ProposedCode): Promise<void>;
111
- /**
112
- * Attempt to reserve an array of proposed codes.
113
- * @returns number of codes actually reserved.
114
- * @see the `problems` member of the `CodeService.Error` exception
115
- * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.
116
- * @note If you have a set of codes to reserve, it is considerably more efficient to do them as an array rather than one at a time.
117
- * @throws `CodeService.Error` if any of the proposed code cannot be reserved. The details for each failed code are in the `problems` member.
118
- */
119
- reserveCodes(arg: CodeService.ReserveCodesArgs): Promise<number>;
120
- /**
121
- * Attempt to reserve the next available code for a code sequence and scope.
122
- * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.
123
- */
124
- reserveNextAvailableCode(arg: CodeService.ReserveNextArgs): Promise<void>;
125
- /**
126
- * Attempt to reserve an array of the next available codes for a code sequence and scope.
127
- * The length of the array determines the number of codes requested. The values for the new codes are returned
128
- * in the array, so they can be associated with the supplied GUIDs.
129
- * @returns number of codes actually reserved.
130
- * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.
131
- */
132
- reserveNextAvailableCodes(arg: CodeService.ReserveNextArrayArgs): Promise<number>;
133
- /**
134
- * Update the properties of a single code.
135
- * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.
136
- */
137
- updateCode(props: CodeService.UpdatedCode): Promise<void>;
138
- /**
139
- * Update the properties of an array codes.
140
- * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.
141
- * @note If you have a set of codes to update, it is considerably more efficient to do them as an array rather than one at a time.
142
- * @returns number of codes actually updated.
143
- */
144
- updateCodes(arg: CodeService.UpdateCodesArgs): Promise<number>;
145
- /** Delete an array of codes by their guids.
146
- * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.
147
- */
148
- deleteCodes(guid: CodeService.CodeGuid[]): Promise<void>;
149
- }
150
- /** @alpha */
151
- export declare namespace CodeService {
152
- /** @internal */
153
- let createForIModel: ((db: IModelDb) => CodeService) | undefined;
154
- /** Register an instance of a`CodeSequence` so it can be looked up by name. */
155
- function registerSequence(seq: CodeSequence): void;
156
- /** Get a previously registered `CodeSequence` by its name.
157
- * @throws if no sequence by that name was registered.
158
- */
159
- function getSequence(name: string): CodeSequence;
160
- /**
161
- * Turn a `CodePops` for the briefcase of this CodeService into a `ScopeAndSpec` object for use with a CodeService.
162
- * This is necessary because the `spec` member of `CodeProps` refers to the id of a code spec in the iModel, and
163
- * the `scope` member refers to the element Id of the scope element in the iModel. This helper function
164
- * converts the spec Id to the spec name and looks up the `FederationGuid` of the scope element.
165
- */
166
- function makeScopeAndSpec(iModel: IModelDb, code: CodeProps): CodeService.ScopeAndSpec;
167
- /** Turn a `CodeProps` and `ProposedCodeProps` into a `ProposedCode` for use with a CodeService.
168
- * @see [[makeScopeAndSpec]] for explanation of why this is necessary.
169
- */
170
- function makeProposedCode(arg: CodeService.MakeProposedCodeArgs): CodeService.ProposedCode;
171
- /** The name of a code spec */
172
- type CodeSpecName = string;
173
- /** The name that identifies the "originator" of a code. Usually this is the Guid of the iModel from which a code was added,
174
- * but can also be used to identify a system or type from an external code service. */
175
- type CodeOriginName = string;
176
- /** The name that identifies the "author" of a code. Generally, this is intended to be the name of a person or group that helps identify the purpose of the code. */
177
- type AuthorName = string;
178
- /** The value for a code. */
179
- type CodeValue = string;
180
- /** The guid for a code. This identifies the real-world entity associated with the code. */
181
- type CodeGuid = GuidString;
182
- /** The guid of the scope for a code. This identifies the real-world entity that provides the uniqueness scope for code values. */
183
- type ScopeGuid = GuidString;
184
- /** An optional number associated with a code that may be used for "status" information. Values must be defined by applications. */
185
- type CodeState = number;
186
- /** The return status of an iteration function. The value "stop" causes the iteration to terminate. */
187
- type IterationReturn = void | "stop";
188
- /** An iteration function over codes in a code index. It is called with the Guid of a each code. */
189
- type CodeIteration = (guid: GuidString) => IterationReturn;
190
- /** An iteration function over code specs in a code index. It is called with the name and json of a each code spec. */
191
- type NameAndJsonIteration = (nameAndJson: NameAndJson) => IterationReturn;
192
- /** Argument for reserving an array of new codes. */
193
- interface ReserveCodesArgs {
194
- /** an array of proposed codes to reserve.
195
- * @note the guid of each proposed code must be supplied by the caller.
196
- */
197
- readonly codes: CodeService.ProposedCode[];
198
- /** If true, unless all codes are available, don't reserve any codes. Otherwise reserve all available codes. */
199
- readonly allOrNothing?: true;
200
- }
201
- /** Argument for reserving a code from a code sequence. */
202
- interface ReserveNextArgs {
203
- /** the properties of the new code */
204
- readonly code: CodeService.ProposedCodeProps;
205
- /** The code sequence and scope for the new code. */
206
- readonly from: SequenceScope;
207
- }
208
- /** Argument for reserving an array of codes from a code sequence. */
209
- interface ReserveNextArrayArgs {
210
- /** an array of proposed codes to reserve. */
211
- readonly codes: CodeService.ProposedCodeProps[];
212
- /** The code sequence and scope for the new codes. */
213
- readonly from: CodeService.SequenceScope;
214
- /** If true, and in the event that the code sequence does not have enough available codes to fulfill all the entries in `codes`,
215
- * return as many as possible. Otherwise no codes are reserved. The `problems` member of the exception can be used to determine how many codes were available.
216
- * @note if `asManyAsPossible` is true, no error is thrown if the sequence becomes full. You must check the return value to see how many
217
- * were actually available. The `value` member will be undefined for any proposed codes that were not reserved.
218
- */
219
- readonly asManyAsPossible?: true;
220
- }
221
- /** Argument for updating an array of codes. */
222
- interface UpdateCodesArgs {
223
- /** Properties of the codes to update */
224
- readonly props: CodeService.UpdatedCode[];
225
- /** If true, unless all codes are updated, don't update any codes. Otherwise update all possible codes. */
226
- readonly allOrNothing?: true;
227
- }
228
- /** Arguments for CodeService.makeProposedCode */
229
- interface MakeProposedCodeArgs {
230
- readonly iModel: IModelDb;
231
- readonly code: Required<CodeProps>;
232
- readonly props: CodeService.CodeGuidStateJson;
233
- }
234
- /** The properties of an Element to be checked against the code index.
235
- * @see CodeService.verifyCode
236
- */
237
- interface ElementCodeProps {
238
- /** iModel from which the code is being inserted/updated. */
239
- readonly iModel: IModelDb;
240
- /** Properties of the code */
241
- readonly props: {
242
- /** The imodel-specific code properties. */
243
- readonly code: CodeProps;
244
- /**
245
- * The federationGuid of the element being inserted or updated.
246
- * If federationGuid is defined, it is must match the value in the code index or an error is thrown.
247
- * If it is undefined, the value from the code index is returned here.
248
- */
249
- federationGuid?: GuidString;
250
- };
251
- }
252
- /** a name and a json object. Used for code specs, authors and origins. */
253
- interface NameAndJson {
254
- readonly name: string;
255
- readonly json?: SettingObject;
256
- }
257
- /** A code Scope guid, and code spec name. */
258
- interface ScopeAndSpec {
259
- readonly spec: CodeSpecName;
260
- readonly scope: ScopeGuid;
261
- }
262
- /** A code Scope guid, code spec, and code value. */
263
- interface ScopeSpecAndValue extends ScopeAndSpec {
264
- readonly value: CodeValue;
265
- }
266
- /** The data held in a code index for a single code. */
267
- interface CodeEntry {
268
- /** The name of the code spec for this code. */
269
- readonly spec: CodeSpecName;
270
- /** The guid of the entity that provides the scope for this code. */
271
- readonly scope: ScopeGuid;
272
- /** The value of this code. */
273
- readonly value: CodeValue;
274
- /** The guid of the entity this code identifies. */
275
- readonly guid: CodeGuid;
276
- /** the state of the code. May be undefined. */
277
- readonly state?: CodeState;
278
- /** The name of the originating source of this code (usually an iModel Guid). May be undefined. */
279
- readonly origin: CodeOriginName;
280
- /** The name of the author of this code. May be undefined. */
281
- readonly author?: AuthorName;
282
- /** Option json properties associated with this code. May be undefined. */
283
- readonly json?: SettingObject;
284
- }
285
- /** A filter used to limit and/or sort the values returned by an iteration. */
286
- interface ValueFilter {
287
- /** A value filter. May include wild cards when used with `GLOB` or `LIKE` */
288
- readonly value?: string;
289
- /** The comparison operator for `value`. Default is `=` */
290
- readonly valueCompare?: "GLOB" | "LIKE" | "NOT GLOB" | "NOT LIKE" | "=" | "<" | ">";
291
- /** Order results ascending or descending. If not supplied, the results are unordered (random). */
292
- readonly orderBy?: "ASC" | "DESC";
293
- /** An SQL expression to further filter results. This string is appended to the `WHERE` clause with an `AND` (that should not be part of the sqlExpression) */
294
- readonly sqlExpression?: string;
295
- }
296
- /** A filter to limit and/or sort the values for the [[CodeIndex.forAllCodes]] iteration. */
297
- interface CodeFilter extends ValueFilter {
298
- /** If supplied, limit results to only those with this spec */
299
- readonly spec?: CodeSpecName;
300
- /** If supplied, limit results to only those with this scope Guid */
301
- readonly scope?: ScopeGuid;
302
- /** If supplied, limit results to only those with this origin */
303
- readonly origin?: CodeOriginName;
304
- }
305
- /** Author and origin information supplied when codes are reserved. */
306
- interface AuthorAndOrigin {
307
- /** The name of the individual or group for whom the code was reserved. */
308
- readonly author: Mutable<NameAndJson>;
309
- /** The identity of the "originator" of the code. This is usually a guid of an iModel, but can be any unique string. */
310
- readonly origin: Mutable<NameAndJson>;
311
- }
312
- /** The Guid, state, and json properties of a code. */
313
- interface CodeGuidStateJson {
314
- /** The Guid of the new code. This must be always be supplied by the application. */
315
- readonly guid: CodeGuid;
316
- /** An optional value for the state of the code. */
317
- readonly state?: CodeState;
318
- /** An optional json object to be stored with the code. */
319
- readonly json?: SettingObject;
320
- }
321
- /** Properties of a "proposed" new code to be reserved.
322
- * @note the Guid of the entity identified by this code *must* be supplied, but `value` is optional, since
323
- * this may be used to reserve codes from a sequence where the value is generated.
324
- */
325
- interface ProposedCodeProps extends CodeGuidStateJson {
326
- /** The value for the proposed code.
327
- * @note For code sequence operations, this value is ignored on input and is set with a new value from the sequence on successful return.
328
- */
329
- value?: CodeValue;
330
- }
331
- /** Properties of a proposed new code that is not from a code sequence (its `value` is required). */
332
- type ProposedCode = ProposedCodeProps & ScopeSpecAndValue;
333
- /** Properties that describe a code sequence and a scope and spec for a proposed code or array of codes from a sequence. */
334
- interface SequenceScope extends ScopeAndSpec {
335
- /** The code sequence. */
336
- readonly seq: CodeSequence;
337
- /** A valid current value. If supplied, the returned value will always be later in the sequence than this. */
338
- readonly start?: CodeValue;
339
- }
340
- /** Properties of a code to be updated.
341
- * @note The `guid` member identifies the code to be updated and is required.
342
- * All other properties are optional - if `undefined`, its value is not changed.
343
- */
344
- type UpdatedCode = MarkRequired<Partial<ProposedCode>, "guid">;
345
- /** A proposed code that could not be reserved due to some error. */
346
- interface ReserveProblem {
347
- /** the proposed code that failed. */
348
- readonly code: ProposedCode;
349
- /** the reason for the failure */
350
- readonly errorId: ErrorId;
351
- /** the error message from the exception for this proposed code. */
352
- readonly message: string;
353
- }
354
- /** A update to a code that failed for some error. */
355
- interface UpdateProblem {
356
- /** The properties of the code that was to be updated */
357
- readonly prop: UpdatedCode;
358
- /** the reason for the failure */
359
- readonly errorId: ErrorId;
360
- /** the error message from the exception for the update request. */
361
- readonly message: string;
362
- }
363
- /**
364
- * A sequence of code values following a increasing pattern. Valid code sequences must have a first value, a last value, and
365
- * a way to get the next valid value from an existing valid value.
366
- * Code sequences have a `sequenceName` so they can be registered using `CodeService.registerSequence`.
367
- */
368
- interface CodeSequence {
369
- /** the name of this CodeSequence. */
370
- get sequenceName(): string;
371
- /** Get the first valid value for this CodeSequence */
372
- getFirstValue(): CodeValue;
373
- /** Get the last valid value for this CodeSequence */
374
- getLastValue(): CodeValue;
375
- /** Get the next valid value for this CodeSequence from the supplied value.
376
- * If the sequence is full (that is, the next value is greater than the last value, this method should throw with errorId="SequenceFull".
377
- * @return the next valid value according to the rules of this CodeSequence.
378
- */
379
- getNextValue(code: CodeValue): CodeValue;
380
- /** Determine whether this supplied value is valid for this sequence. */
381
- isValidCode(code: CodeValue): boolean;
382
- }
383
- /** Exception class thrown by `CodeService` methods. */
384
- class Error extends BentleyError {
385
- /** A string that indicates the type of problem that caused the exception. */
386
- readonly errorId: ErrorId;
387
- /** For [[CodeService.reserveCodes]] and [[CodeService.updateCodes]], a list of the problem details. */
388
- readonly problems?: ReserveProblem[] | UpdateProblem[];
389
- /** @internal */
390
- constructor(errorId: ErrorId, errNum: number, message: string, problems?: ReserveProblem[] | UpdateProblem[]);
391
- }
392
- /** Identifiers for exceptions thrown by `CodeService` methods.
393
- * @see [[CodeService.Error.errorId]]
394
- */
395
- type ErrorId = "BadIndexProps" | "CorruptIModel" | "CorruptIndex" | "DuplicateValue" | "GuidIsInUse" | "GuidMismatch" | "IllegalValue" | "IndexReadonly" | "InvalidCodeScope" | "InvalidGuid" | "InvalidSequence" | "MissingCode" | "MissingGuid" | "MissingInput" | "MissingSpec" | "NoCodeIndex" | "SequenceFull" | "ReserveErrors" | "SequenceNotFound" | "SqlLogicError" | "UpdateErrors" | "ValueIsInUse" | "WrongVersion";
396
- }
1
+ import { AccessToken, BentleyError, GuidString, MarkRequired, Mutable } from "@itwin/core-bentley";
2
+ import { CodeProps } from "@itwin/core-common";
3
+ import { CloudSqlite } from "./CloudSqlite";
4
+ import { IModelDb } from "./IModelDb";
5
+ import { SettingObject } from "./workspace/Settings";
6
+ /**
7
+ * A readonly index of all known Codes for an iTwin. The CodeIndex may be slightly out-of-date
8
+ * with the master copy in the cloud, but it should be periodically synchronized. Whenever codes are reserved/updated/deleted
9
+ * locally, this copy is always up-to-date as of those changes.
10
+ * @alpha
11
+ */
12
+ export interface CodeIndex {
13
+ /**
14
+ * Find the next available value for the supplied `SequenceScope`.
15
+ * If the sequence is full (there are no available values), this will throw an exception with `errorId="SequenceFull"`
16
+ * @param from the sequence and scope to search
17
+ * @returns the next available CodeValue in the sequence.
18
+ */
19
+ findNextAvailable(from: CodeService.SequenceScope): CodeService.CodeValue;
20
+ /**
21
+ * Find the highest currently used value for the supplied `SequenceScope`
22
+ * @param from the sequence and scope to search
23
+ * @returns the highest used value, or undefined if no values have been used.
24
+ */
25
+ findHighestUsed(from: CodeService.SequenceScope): CodeService.CodeValue | undefined;
26
+ /** Determine whether a code is present in this CodeIndex by its Guid. */
27
+ isCodePresent(guid: CodeService.CodeGuid): boolean;
28
+ /** Get the data for a code in this CodeIndex by its Guid.
29
+ * @returns the data for the code or undefined if no code is present for the supplied Guid.
30
+ */
31
+ getCode(guid: CodeService.CodeGuid): CodeService.CodeEntry | undefined;
32
+ /** Look up a code by its Scope, Spec, and Value.
33
+ * @returns the Guid of the code, or undefined if not present.
34
+ */
35
+ findCode(code: CodeService.ScopeSpecAndValue): CodeService.CodeGuid | undefined;
36
+ /** Look up a code spec by its name
37
+ * @throws if the spec is not present.
38
+ */
39
+ getCodeSpec(props: CodeService.CodeSpecName): CodeService.NameAndJson;
40
+ /** Call a `CodeIteration` function for all codes in this index, optionally filtered by a `CodeFilter ` */
41
+ forAllCodes(iter: CodeService.CodeIteration, filter?: CodeService.CodeFilter): void;
42
+ /** Call an iteration function for all code specs in this index, optionally filtered by a `ValueFilter ` */
43
+ forAllCodeSpecs(iter: CodeService.NameAndJsonIteration, filter?: CodeService.ValueFilter): void;
44
+ }
45
+ /**
46
+ * The services for querying, reserving, updating, and deleting codes for a BriefcaseDb (available via `BriefcaseDb.codeService`) whenever it is opened for write access.
47
+ * @alpha
48
+ */
49
+ export interface CodeService {
50
+ /** @internal */
51
+ close: () => void;
52
+ /** @internal */
53
+ addAllCodeSpecs(iModel: IModelDb): Promise<void>;
54
+ /** the code index for this CodeService */
55
+ readonly codeIndex: CodeIndex;
56
+ /**
57
+ * Application-supplied parameters for obtaining the write lock on the container.
58
+ * Applications should set these parameters by adding a listener for `BriefcaseDb.onCodeServiceCreated`
59
+ * that is called every time a BriefcaseDb that uses code services is opened for write access.
60
+ */
61
+ readonly lockParams: CloudSqlite.ObtainLockParams;
62
+ /**
63
+ * Application-supplied parameters for reserving new codes.
64
+ * @see lockParams
65
+ */
66
+ readonly appParams: CodeService.AuthorAndOrigin;
67
+ /**
68
+ * The token that grants access to the cloud container for this CodeService.
69
+ * It should be established in a listener for `BriefcaseDb.onCodeServiceCreated`, and should be refreshed (via a
70
+ * timer) before it expires.
71
+ */
72
+ sasToken: AccessToken;
73
+ /**
74
+ * Synchronize the local index with any changes by made by others.
75
+ * @note This is called automatically whenever any write operation is performed on the code index. It is only necessary to
76
+ * call this directly if you have not changed the code index recently, but wish to perform a readonly operation and want to
77
+ * ensure it is up-to-date as of now.
78
+ * @note There is no guarantee that a readonly index is up-to-date even immediately after calling this method, since others
79
+ * may be modifying it at any time.
80
+ */
81
+ synchronizeWithCloud(): void;
82
+ /**
83
+ * Verify that the Code of a to-be-inserted or to-be-updated Element:
84
+ * 1. has already been reserved,
85
+ * 2. if the element has a `federationGuid`, it must match the reserved value. If the federationGuid is undefined,
86
+ * the value from the code index is returned.
87
+ *
88
+ * If not, throw an exception. Elements with no CodeValue are ignored.
89
+ * @note this method is automatically called whenever elements are added or updated by a BriefcaseDb with a CodeService.
90
+ */
91
+ verifyCode(props: CodeService.ElementCodeProps): void;
92
+ /** Add a new code spec to this code service.
93
+ * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.
94
+ */
95
+ addCodeSpec(val: CodeService.NameAndJson): Promise<void>;
96
+ /**
97
+ * Add all of the codes and code specs from this CodeService's BriefcaseDb into the code index.
98
+ * @returns the number of codes actually added.
99
+ * @note It is not necessary to call this method unless the BriefcaseDb somehow becomes out of sync with its CodeService,
100
+ * for example when migrating iModels to a new code service. It is safe (but relatively expensive) to call this method multiple times, since
101
+ * any codes or code specs that are already in the index are ignored.
102
+ * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.
103
+ */
104
+ addAllCodes(iModel: IModelDb): Promise<number>;
105
+ /**
106
+ * Attempt to reserve a single proposed code.
107
+ * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.
108
+ * @throws `CodeService.Error` if the proposed code cannot be reserved.
109
+ */
110
+ reserveCode(code: CodeService.ProposedCode): Promise<void>;
111
+ /**
112
+ * Attempt to reserve an array of proposed codes.
113
+ * @returns number of codes actually reserved.
114
+ * @see the `problems` member of the `CodeService.Error` exception
115
+ * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.
116
+ * @note If you have a set of codes to reserve, it is considerably more efficient to do them as an array rather than one at a time.
117
+ * @throws `CodeService.Error` if any of the proposed code cannot be reserved. The details for each failed code are in the `problems` member.
118
+ */
119
+ reserveCodes(arg: CodeService.ReserveCodesArgs): Promise<number>;
120
+ /**
121
+ * Attempt to reserve the next available code for a code sequence and scope.
122
+ * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.
123
+ */
124
+ reserveNextAvailableCode(arg: CodeService.ReserveNextArgs): Promise<void>;
125
+ /**
126
+ * Attempt to reserve an array of the next available codes for a code sequence and scope.
127
+ * The length of the array determines the number of codes requested. The values for the new codes are returned
128
+ * in the array, so they can be associated with the supplied GUIDs.
129
+ * @returns number of codes actually reserved.
130
+ * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.
131
+ */
132
+ reserveNextAvailableCodes(arg: CodeService.ReserveNextArrayArgs): Promise<number>;
133
+ /**
134
+ * Update the properties of a single code.
135
+ * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.
136
+ */
137
+ updateCode(props: CodeService.UpdatedCode): Promise<void>;
138
+ /**
139
+ * Update the properties of an array codes.
140
+ * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.
141
+ * @note If you have a set of codes to update, it is considerably more efficient to do them as an array rather than one at a time.
142
+ * @returns number of codes actually updated.
143
+ */
144
+ updateCodes(arg: CodeService.UpdateCodesArgs): Promise<number>;
145
+ /** Delete an array of codes by their guids.
146
+ * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.
147
+ */
148
+ deleteCodes(guid: CodeService.CodeGuid[]): Promise<void>;
149
+ }
150
+ /** @alpha */
151
+ export declare namespace CodeService {
152
+ /** @internal */
153
+ let createForIModel: ((db: IModelDb) => CodeService) | undefined;
154
+ /** Register an instance of a`CodeSequence` so it can be looked up by name. */
155
+ function registerSequence(seq: CodeSequence): void;
156
+ /** Get a previously registered `CodeSequence` by its name.
157
+ * @throws if no sequence by that name was registered.
158
+ */
159
+ function getSequence(name: string): CodeSequence;
160
+ /**
161
+ * Turn a `CodePops` for the briefcase of this CodeService into a `ScopeAndSpec` object for use with a CodeService.
162
+ * This is necessary because the `spec` member of `CodeProps` refers to the id of a code spec in the iModel, and
163
+ * the `scope` member refers to the element Id of the scope element in the iModel. This helper function
164
+ * converts the spec Id to the spec name and looks up the `FederationGuid` of the scope element.
165
+ */
166
+ function makeScopeAndSpec(iModel: IModelDb, code: CodeProps): CodeService.ScopeAndSpec;
167
+ /** Turn a `CodeProps` and `ProposedCodeProps` into a `ProposedCode` for use with a CodeService.
168
+ * @see [[makeScopeAndSpec]] for explanation of why this is necessary.
169
+ */
170
+ function makeProposedCode(arg: CodeService.MakeProposedCodeArgs): CodeService.ProposedCode;
171
+ /** The name of a code spec */
172
+ type CodeSpecName = string;
173
+ /** The name that identifies the "originator" of a code. Usually this is the Guid of the iModel from which a code was added,
174
+ * but can also be used to identify a system or type from an external code service. */
175
+ type CodeOriginName = string;
176
+ /** The name that identifies the "author" of a code. Generally, this is intended to be the name of a person or group that helps identify the purpose of the code. */
177
+ type AuthorName = string;
178
+ /** The value for a code. */
179
+ type CodeValue = string;
180
+ /** The guid for a code. This identifies the real-world entity associated with the code. */
181
+ type CodeGuid = GuidString;
182
+ /** The guid of the scope for a code. This identifies the real-world entity that provides the uniqueness scope for code values. */
183
+ type ScopeGuid = GuidString;
184
+ /** An optional number associated with a code that may be used for "status" information. Values must be defined by applications. */
185
+ type CodeState = number;
186
+ /** The return status of an iteration function. The value "stop" causes the iteration to terminate. */
187
+ type IterationReturn = void | "stop";
188
+ /** An iteration function over codes in a code index. It is called with the Guid of a each code. */
189
+ type CodeIteration = (guid: GuidString) => IterationReturn;
190
+ /** An iteration function over code specs in a code index. It is called with the name and json of a each code spec. */
191
+ type NameAndJsonIteration = (nameAndJson: NameAndJson) => IterationReturn;
192
+ /** Argument for reserving an array of new codes. */
193
+ interface ReserveCodesArgs {
194
+ /** an array of proposed codes to reserve.
195
+ * @note the guid of each proposed code must be supplied by the caller.
196
+ */
197
+ readonly codes: CodeService.ProposedCode[];
198
+ /** If true, unless all codes are available, don't reserve any codes. Otherwise reserve all available codes. */
199
+ readonly allOrNothing?: true;
200
+ }
201
+ /** Argument for reserving a code from a code sequence. */
202
+ interface ReserveNextArgs {
203
+ /** the properties of the new code */
204
+ readonly code: CodeService.ProposedCodeProps;
205
+ /** The code sequence and scope for the new code. */
206
+ readonly from: SequenceScope;
207
+ }
208
+ /** Argument for reserving an array of codes from a code sequence. */
209
+ interface ReserveNextArrayArgs {
210
+ /** an array of proposed codes to reserve. */
211
+ readonly codes: CodeService.ProposedCodeProps[];
212
+ /** The code sequence and scope for the new codes. */
213
+ readonly from: CodeService.SequenceScope;
214
+ /** If true, and in the event that the code sequence does not have enough available codes to fulfill all the entries in `codes`,
215
+ * return as many as possible. Otherwise no codes are reserved. The `problems` member of the exception can be used to determine how many codes were available.
216
+ * @note if `asManyAsPossible` is true, no error is thrown if the sequence becomes full. You must check the return value to see how many
217
+ * were actually available. The `value` member will be undefined for any proposed codes that were not reserved.
218
+ */
219
+ readonly asManyAsPossible?: true;
220
+ }
221
+ /** Argument for updating an array of codes. */
222
+ interface UpdateCodesArgs {
223
+ /** Properties of the codes to update */
224
+ readonly props: CodeService.UpdatedCode[];
225
+ /** If true, unless all codes are updated, don't update any codes. Otherwise update all possible codes. */
226
+ readonly allOrNothing?: true;
227
+ }
228
+ /** Arguments for CodeService.makeProposedCode */
229
+ interface MakeProposedCodeArgs {
230
+ readonly iModel: IModelDb;
231
+ readonly code: Required<CodeProps>;
232
+ readonly props: CodeService.CodeGuidStateJson;
233
+ }
234
+ /** The properties of an Element to be checked against the code index.
235
+ * @see CodeService.verifyCode
236
+ */
237
+ interface ElementCodeProps {
238
+ /** iModel from which the code is being inserted/updated. */
239
+ readonly iModel: IModelDb;
240
+ /** Properties of the code */
241
+ readonly props: {
242
+ /** The imodel-specific code properties. */
243
+ readonly code: CodeProps;
244
+ /**
245
+ * The federationGuid of the element being inserted or updated.
246
+ * If federationGuid is defined, it is must match the value in the code index or an error is thrown.
247
+ * If it is undefined, the value from the code index is returned here.
248
+ */
249
+ federationGuid?: GuidString;
250
+ };
251
+ }
252
+ /** a name and a json object. Used for code specs, authors and origins. */
253
+ interface NameAndJson {
254
+ readonly name: string;
255
+ readonly json?: SettingObject;
256
+ }
257
+ /** A code Scope guid, and code spec name. */
258
+ interface ScopeAndSpec {
259
+ readonly spec: CodeSpecName;
260
+ readonly scope: ScopeGuid;
261
+ }
262
+ /** A code Scope guid, code spec, and code value. */
263
+ interface ScopeSpecAndValue extends ScopeAndSpec {
264
+ readonly value: CodeValue;
265
+ }
266
+ /** The data held in a code index for a single code. */
267
+ interface CodeEntry {
268
+ /** The name of the code spec for this code. */
269
+ readonly spec: CodeSpecName;
270
+ /** The guid of the entity that provides the scope for this code. */
271
+ readonly scope: ScopeGuid;
272
+ /** The value of this code. */
273
+ readonly value: CodeValue;
274
+ /** The guid of the entity this code identifies. */
275
+ readonly guid: CodeGuid;
276
+ /** the state of the code. May be undefined. */
277
+ readonly state?: CodeState;
278
+ /** The name of the originating source of this code (usually an iModel Guid). May be undefined. */
279
+ readonly origin: CodeOriginName;
280
+ /** The name of the author of this code. May be undefined. */
281
+ readonly author?: AuthorName;
282
+ /** Option json properties associated with this code. May be undefined. */
283
+ readonly json?: SettingObject;
284
+ }
285
+ /** A filter used to limit and/or sort the values returned by an iteration. */
286
+ interface ValueFilter {
287
+ /** A value filter. May include wild cards when used with `GLOB` or `LIKE` */
288
+ readonly value?: string;
289
+ /** The comparison operator for `value`. Default is `=` */
290
+ readonly valueCompare?: "GLOB" | "LIKE" | "NOT GLOB" | "NOT LIKE" | "=" | "<" | ">";
291
+ /** Order results ascending or descending. If not supplied, the results are unordered (random). */
292
+ readonly orderBy?: "ASC" | "DESC";
293
+ /** An SQL expression to further filter results. This string is appended to the `WHERE` clause with an `AND` (that should not be part of the sqlExpression) */
294
+ readonly sqlExpression?: string;
295
+ }
296
+ /** A filter to limit and/or sort the values for the [[CodeIndex.forAllCodes]] iteration. */
297
+ interface CodeFilter extends ValueFilter {
298
+ /** If supplied, limit results to only those with this spec */
299
+ readonly spec?: CodeSpecName;
300
+ /** If supplied, limit results to only those with this scope Guid */
301
+ readonly scope?: ScopeGuid;
302
+ /** If supplied, limit results to only those with this origin */
303
+ readonly origin?: CodeOriginName;
304
+ }
305
+ /** Author and origin information supplied when codes are reserved. */
306
+ interface AuthorAndOrigin {
307
+ /** The name of the individual or group for whom the code was reserved. */
308
+ readonly author: Mutable<NameAndJson>;
309
+ /** The identity of the "originator" of the code. This is usually a guid of an iModel, but can be any unique string. */
310
+ readonly origin: Mutable<NameAndJson>;
311
+ }
312
+ /** The Guid, state, and json properties of a code. */
313
+ interface CodeGuidStateJson {
314
+ /** The Guid of the new code. This must be always be supplied by the application. */
315
+ readonly guid: CodeGuid;
316
+ /** An optional value for the state of the code. */
317
+ readonly state?: CodeState;
318
+ /** An optional json object to be stored with the code. */
319
+ readonly json?: SettingObject;
320
+ }
321
+ /** Properties of a "proposed" new code to be reserved.
322
+ * @note the Guid of the entity identified by this code *must* be supplied, but `value` is optional, since
323
+ * this may be used to reserve codes from a sequence where the value is generated.
324
+ */
325
+ interface ProposedCodeProps extends CodeGuidStateJson {
326
+ /** The value for the proposed code.
327
+ * @note For code sequence operations, this value is ignored on input and is set with a new value from the sequence on successful return.
328
+ */
329
+ value?: CodeValue;
330
+ }
331
+ /** Properties of a proposed new code that is not from a code sequence (its `value` is required). */
332
+ type ProposedCode = ProposedCodeProps & ScopeSpecAndValue;
333
+ /** Properties that describe a code sequence and a scope and spec for a proposed code or array of codes from a sequence. */
334
+ interface SequenceScope extends ScopeAndSpec {
335
+ /** The code sequence. */
336
+ readonly seq: CodeSequence;
337
+ /** A valid current value. If supplied, the returned value will always be later in the sequence than this. */
338
+ readonly start?: CodeValue;
339
+ }
340
+ /** Properties of a code to be updated.
341
+ * @note The `guid` member identifies the code to be updated and is required.
342
+ * All other properties are optional - if `undefined`, its value is not changed.
343
+ */
344
+ type UpdatedCode = MarkRequired<Partial<ProposedCode>, "guid">;
345
+ /** A proposed code that could not be reserved due to some error. */
346
+ interface ReserveProblem {
347
+ /** the proposed code that failed. */
348
+ readonly code: ProposedCode;
349
+ /** the reason for the failure */
350
+ readonly errorId: ErrorId;
351
+ /** the error message from the exception for this proposed code. */
352
+ readonly message: string;
353
+ }
354
+ /** A update to a code that failed for some error. */
355
+ interface UpdateProblem {
356
+ /** The properties of the code that was to be updated */
357
+ readonly prop: UpdatedCode;
358
+ /** the reason for the failure */
359
+ readonly errorId: ErrorId;
360
+ /** the error message from the exception for the update request. */
361
+ readonly message: string;
362
+ }
363
+ /**
364
+ * A sequence of code values following a increasing pattern. Valid code sequences must have a first value, a last value, and
365
+ * a way to get the next valid value from an existing valid value.
366
+ * Code sequences have a `sequenceName` so they can be registered using `CodeService.registerSequence`.
367
+ */
368
+ interface CodeSequence {
369
+ /** the name of this CodeSequence. */
370
+ get sequenceName(): string;
371
+ /** Get the first valid value for this CodeSequence */
372
+ getFirstValue(): CodeValue;
373
+ /** Get the last valid value for this CodeSequence */
374
+ getLastValue(): CodeValue;
375
+ /** Get the next valid value for this CodeSequence from the supplied value.
376
+ * If the sequence is full (that is, the next value is greater than the last value, this method should throw with errorId="SequenceFull".
377
+ * @return the next valid value according to the rules of this CodeSequence.
378
+ */
379
+ getNextValue(code: CodeValue): CodeValue;
380
+ /** Determine whether this supplied value is valid for this sequence. */
381
+ isValidCode(code: CodeValue): boolean;
382
+ }
383
+ /** Exception class thrown by `CodeService` methods. */
384
+ class Error extends BentleyError {
385
+ /** A string that indicates the type of problem that caused the exception. */
386
+ readonly errorId: ErrorId;
387
+ /** For [[CodeService.reserveCodes]] and [[CodeService.updateCodes]], a list of the problem details. */
388
+ readonly problems?: ReserveProblem[] | UpdateProblem[];
389
+ /** @internal */
390
+ constructor(errorId: ErrorId, errNum: number, message: string, problems?: ReserveProblem[] | UpdateProblem[]);
391
+ }
392
+ /** Identifiers for exceptions thrown by `CodeService` methods.
393
+ * @see [[CodeService.Error.errorId]]
394
+ */
395
+ type ErrorId = "BadIndexProps" | "CorruptIModel" | "CorruptIndex" | "DuplicateValue" | "GuidIsInUse" | "GuidMismatch" | "IllegalValue" | "IndexReadonly" | "InvalidCodeScope" | "InvalidGuid" | "InvalidSequence" | "MissingCode" | "MissingGuid" | "MissingInput" | "MissingSpec" | "NoCodeIndex" | "SequenceFull" | "ReserveErrors" | "SequenceNotFound" | "SqlLogicError" | "UpdateErrors" | "ValueIsInUse" | "WrongVersion";
396
+ }
397
397
  //# sourceMappingURL=CodeService.d.ts.map