@itwin/core-backend 4.0.0-dev.6 → 4.0.0-dev.60

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 (253) hide show
  1. package/CHANGELOG.md +89 -67
  2. package/lib/cjs/BackendHubAccess.d.ts +224 -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/BriefcaseManager.d.ts +170 -170
  13. package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
  14. package/lib/cjs/BriefcaseManager.js +408 -414
  15. package/lib/cjs/BriefcaseManager.js.map +1 -1
  16. package/lib/cjs/Category.d.ts +153 -153
  17. package/lib/cjs/Category.js +243 -243
  18. package/lib/cjs/Category.js.map +1 -1
  19. package/lib/cjs/ChangeSummaryManager.d.ts +187 -187
  20. package/lib/cjs/ChangeSummaryManager.js +444 -445
  21. package/lib/cjs/ChangeSummaryManager.js.map +1 -1
  22. package/lib/cjs/ChangedElementsDb.d.ts +99 -99
  23. package/lib/cjs/ChangedElementsDb.js +165 -165
  24. package/lib/cjs/ChangedElementsManager.d.ts +39 -39
  25. package/lib/cjs/ChangedElementsManager.js +88 -88
  26. package/lib/cjs/ChannelControl.d.ts +70 -0
  27. package/lib/cjs/ChannelControl.d.ts.map +1 -0
  28. package/lib/cjs/ChannelControl.js +89 -0
  29. package/lib/cjs/ChannelControl.js.map +1 -0
  30. package/lib/cjs/CheckpointManager.d.ts +121 -121
  31. package/lib/cjs/CheckpointManager.d.ts.map +1 -1
  32. package/lib/cjs/CheckpointManager.js +351 -349
  33. package/lib/cjs/CheckpointManager.js.map +1 -1
  34. package/lib/cjs/ClassRegistry.d.ts +79 -79
  35. package/lib/cjs/ClassRegistry.js +249 -245
  36. package/lib/cjs/ClassRegistry.js.map +1 -1
  37. package/lib/cjs/CloudSqlite.d.ts +355 -350
  38. package/lib/cjs/CloudSqlite.d.ts.map +1 -1
  39. package/lib/cjs/CloudSqlite.js +154 -153
  40. package/lib/cjs/CloudSqlite.js.map +1 -1
  41. package/lib/cjs/CodeService.d.ts +396 -396
  42. package/lib/cjs/CodeService.d.ts.map +1 -1
  43. package/lib/cjs/CodeService.js +63 -63
  44. package/lib/cjs/CodeService.js.map +1 -1
  45. package/lib/cjs/CodeSpecs.d.ts +55 -55
  46. package/lib/cjs/CodeSpecs.js +124 -124
  47. package/lib/cjs/ConcurrentQuery.d.ts +13 -13
  48. package/lib/cjs/ConcurrentQuery.d.ts.map +1 -1
  49. package/lib/cjs/ConcurrentQuery.js +36 -36
  50. package/lib/cjs/CustomViewState3dCreator.d.ts +21 -21
  51. package/lib/cjs/CustomViewState3dCreator.d.ts.map +1 -1
  52. package/lib/cjs/CustomViewState3dCreator.js +82 -81
  53. package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
  54. package/lib/cjs/DevTools.d.ts +74 -71
  55. package/lib/cjs/DevTools.d.ts.map +1 -1
  56. package/lib/cjs/DevTools.js +156 -154
  57. package/lib/cjs/DevTools.js.map +1 -1
  58. package/lib/cjs/DisplayStyle.d.ts +106 -106
  59. package/lib/cjs/DisplayStyle.js +253 -256
  60. package/lib/cjs/DisplayStyle.js.map +1 -1
  61. package/lib/cjs/ECDb.d.ts +194 -191
  62. package/lib/cjs/ECDb.d.ts.map +1 -1
  63. package/lib/cjs/ECDb.js +353 -350
  64. package/lib/cjs/ECDb.js.map +1 -1
  65. package/lib/cjs/ECSchemaXmlContext.d.ts +18 -18
  66. package/lib/cjs/ECSchemaXmlContext.d.ts.map +1 -1
  67. package/lib/cjs/ECSchemaXmlContext.js +41 -41
  68. package/lib/cjs/ECSqlStatement.d.ts +473 -473
  69. package/lib/cjs/ECSqlStatement.js +791 -791
  70. package/lib/cjs/Element.d.ts +1113 -1109
  71. package/lib/cjs/Element.d.ts.map +1 -1
  72. package/lib/cjs/Element.js +1424 -1427
  73. package/lib/cjs/Element.js.map +1 -1
  74. package/lib/cjs/ElementAspect.d.ts +176 -179
  75. package/lib/cjs/ElementAspect.d.ts.map +1 -1
  76. package/lib/cjs/ElementAspect.js +203 -211
  77. package/lib/cjs/ElementAspect.js.map +1 -1
  78. package/lib/cjs/ElementGraphics.d.ts +9 -9
  79. package/lib/cjs/ElementGraphics.js +41 -41
  80. package/lib/cjs/ElementGraphics.js.map +1 -1
  81. package/lib/cjs/ElementTreeWalker.d.ts +162 -162
  82. package/lib/cjs/ElementTreeWalker.d.ts.map +1 -1
  83. package/lib/cjs/ElementTreeWalker.js +409 -409
  84. package/lib/cjs/ElementTreeWalker.js.map +1 -1
  85. package/lib/cjs/Entity.d.ts +106 -106
  86. package/lib/cjs/Entity.d.ts.map +1 -1
  87. package/lib/cjs/Entity.js +134 -134
  88. package/lib/cjs/Entity.js.map +1 -1
  89. package/lib/cjs/EntityReferences.d.ts +49 -49
  90. package/lib/cjs/EntityReferences.d.ts.map +1 -1
  91. package/lib/cjs/EntityReferences.js +95 -95
  92. package/lib/cjs/ExportGraphics.d.ts +317 -317
  93. package/lib/cjs/ExportGraphics.d.ts.map +1 -1
  94. package/lib/cjs/ExportGraphics.js +208 -208
  95. package/lib/cjs/ExternalSource.d.ts +96 -96
  96. package/lib/cjs/ExternalSource.js +131 -131
  97. package/lib/cjs/ExternalSource.js.map +1 -1
  98. package/lib/cjs/GeoCoordConfig.d.ts +19 -19
  99. package/lib/cjs/GeoCoordConfig.js +85 -85
  100. package/lib/cjs/GeoCoordConfig.js.map +1 -1
  101. package/lib/cjs/GeometrySummary.d.ts +4 -4
  102. package/lib/cjs/GeometrySummary.js +333 -333
  103. package/lib/cjs/GeometrySummary.js.map +1 -1
  104. package/lib/cjs/HubMock.d.ts +94 -94
  105. package/lib/cjs/HubMock.js +220 -222
  106. package/lib/cjs/HubMock.js.map +1 -1
  107. package/lib/cjs/IModelCloneContext.d.ts +8 -8
  108. package/lib/cjs/IModelCloneContext.d.ts.map +1 -1
  109. package/lib/cjs/IModelCloneContext.js +15 -15
  110. package/lib/cjs/IModelDb.d.ts +1216 -1196
  111. package/lib/cjs/IModelDb.d.ts.map +1 -1
  112. package/lib/cjs/IModelDb.js +2387 -2392
  113. package/lib/cjs/IModelDb.js.map +1 -1
  114. package/lib/cjs/IModelElementCloneContext.d.ts +89 -89
  115. package/lib/cjs/IModelElementCloneContext.js +159 -159
  116. package/lib/cjs/IModelHost.d.ts +356 -369
  117. package/lib/cjs/IModelHost.d.ts.map +1 -1
  118. package/lib/cjs/IModelHost.js +472 -496
  119. package/lib/cjs/IModelHost.js.map +1 -1
  120. package/lib/cjs/IModelJsFs.d.ts +62 -62
  121. package/lib/cjs/IModelJsFs.js +139 -140
  122. package/lib/cjs/IModelJsFs.js.map +1 -1
  123. package/lib/cjs/IpcHost.d.ts +104 -104
  124. package/lib/cjs/IpcHost.js +276 -278
  125. package/lib/cjs/IpcHost.js.map +1 -1
  126. package/lib/cjs/LineStyle.d.ts +311 -311
  127. package/lib/cjs/LineStyle.js +295 -295
  128. package/lib/cjs/LocalHub.d.ts +162 -162
  129. package/lib/cjs/LocalHub.d.ts.map +1 -1
  130. package/lib/cjs/LocalHub.js +579 -584
  131. package/lib/cjs/LocalHub.js.map +1 -1
  132. package/lib/cjs/LocalhostIpcHost.d.ts +20 -20
  133. package/lib/cjs/LocalhostIpcHost.js +79 -81
  134. package/lib/cjs/LocalhostIpcHost.js.map +1 -1
  135. package/lib/cjs/Material.d.ts +131 -131
  136. package/lib/cjs/Material.js +180 -181
  137. package/lib/cjs/Material.js.map +1 -1
  138. package/lib/cjs/Model.d.ts +392 -392
  139. package/lib/cjs/Model.d.ts.map +1 -1
  140. package/lib/cjs/Model.js +489 -485
  141. package/lib/cjs/Model.js.map +1 -1
  142. package/lib/cjs/NativeAppStorage.d.ts +51 -51
  143. package/lib/cjs/NativeAppStorage.js +202 -202
  144. package/lib/cjs/NativeAppStorage.js.map +1 -1
  145. package/lib/cjs/NativeHost.d.ts +52 -52
  146. package/lib/cjs/NativeHost.js +160 -163
  147. package/lib/cjs/NativeHost.js.map +1 -1
  148. package/lib/cjs/NavigationRelationship.d.ts +156 -156
  149. package/lib/cjs/NavigationRelationship.js +225 -225
  150. package/lib/cjs/NavigationRelationship.js.map +1 -1
  151. package/lib/cjs/PromiseMemoizer.d.ts +51 -51
  152. package/lib/cjs/PromiseMemoizer.d.ts.map +1 -1
  153. package/lib/cjs/PromiseMemoizer.js +101 -101
  154. package/lib/cjs/PromiseMemoizer.js.map +1 -1
  155. package/lib/cjs/PropertyStore.d.ts +132 -132
  156. package/lib/cjs/PropertyStore.js +11 -11
  157. package/lib/cjs/Relationship.d.ts +416 -416
  158. package/lib/cjs/Relationship.js +494 -494
  159. package/lib/cjs/Relationship.js.map +1 -1
  160. package/lib/cjs/RpcBackend.d.ts +5 -5
  161. package/lib/cjs/RpcBackend.js +32 -32
  162. package/lib/cjs/SQLiteDb.d.ts +219 -219
  163. package/lib/cjs/SQLiteDb.js +212 -214
  164. package/lib/cjs/SQLiteDb.js.map +1 -1
  165. package/lib/cjs/Schema.d.ts +55 -55
  166. package/lib/cjs/Schema.js +83 -83
  167. package/lib/cjs/Schema.js.map +1 -1
  168. package/lib/cjs/ServerBasedLocks.d.ts +57 -57
  169. package/lib/cjs/ServerBasedLocks.js +168 -168
  170. package/lib/cjs/ServerBasedLocks.js.map +1 -1
  171. package/lib/cjs/SqliteStatement.d.ts +360 -360
  172. package/lib/cjs/SqliteStatement.d.ts.map +1 -1
  173. package/lib/cjs/SqliteStatement.js +586 -586
  174. package/lib/cjs/Texture.d.ts +58 -58
  175. package/lib/cjs/Texture.js +82 -82
  176. package/lib/cjs/Texture.js.map +1 -1
  177. package/lib/cjs/TileStorage.d.ts +18 -18
  178. package/lib/cjs/TileStorage.js +87 -90
  179. package/lib/cjs/TileStorage.js.map +1 -1
  180. package/lib/cjs/TxnManager.d.ts +202 -202
  181. package/lib/cjs/TxnManager.d.ts.map +1 -1
  182. package/lib/cjs/TxnManager.js +356 -356
  183. package/lib/cjs/TxnManager.js.map +1 -1
  184. package/lib/cjs/ViewDefinition.d.ts +435 -439
  185. package/lib/cjs/ViewDefinition.d.ts.map +1 -1
  186. package/lib/cjs/ViewDefinition.js +646 -646
  187. package/lib/cjs/ViewDefinition.js.map +1 -1
  188. package/lib/cjs/ViewStateHydrator.d.ts +13 -13
  189. package/lib/cjs/ViewStateHydrator.js +103 -103
  190. package/lib/cjs/core-backend.d.ts +183 -184
  191. package/lib/cjs/core-backend.d.ts.map +1 -1
  192. package/lib/cjs/core-backend.js +207 -204
  193. package/lib/cjs/core-backend.js.map +1 -1
  194. package/lib/cjs/domains/FunctionalElements.d.ts +101 -101
  195. package/lib/cjs/domains/FunctionalElements.js +145 -145
  196. package/lib/cjs/domains/FunctionalElements.js.map +1 -1
  197. package/lib/cjs/domains/FunctionalSchema.d.ts +13 -13
  198. package/lib/cjs/domains/FunctionalSchema.d.ts.map +1 -1
  199. package/lib/cjs/domains/FunctionalSchema.js +39 -40
  200. package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
  201. package/lib/cjs/domains/GenericElements.d.ts +177 -177
  202. package/lib/cjs/domains/GenericElements.js +263 -263
  203. package/lib/cjs/domains/GenericSchema.d.ts +10 -10
  204. package/lib/cjs/domains/GenericSchema.js +28 -28
  205. package/lib/cjs/rpc/multipart.d.ts +11 -11
  206. package/lib/cjs/rpc/multipart.js +71 -71
  207. package/lib/cjs/rpc/tracing.d.ts +28 -28
  208. package/lib/cjs/rpc/tracing.js +73 -74
  209. package/lib/cjs/rpc/tracing.js.map +1 -1
  210. package/lib/cjs/rpc/web/logging.d.ts +9 -9
  211. package/lib/cjs/rpc/web/logging.js +43 -43
  212. package/lib/cjs/rpc/web/request.d.ts +6 -6
  213. package/lib/cjs/rpc/web/request.js +73 -74
  214. package/lib/cjs/rpc/web/request.js.map +1 -1
  215. package/lib/cjs/rpc/web/response.d.ts +6 -6
  216. package/lib/cjs/rpc/web/response.js +105 -106
  217. package/lib/cjs/rpc/web/response.js.map +1 -1
  218. package/lib/cjs/rpc-impl/DevToolsRpcImpl.d.ts +15 -15
  219. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js +32 -32
  220. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +47 -47
  221. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +293 -294
  222. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  223. package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts +20 -22
  224. package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts.map +1 -1
  225. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +187 -205
  226. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
  227. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts +36 -36
  228. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +166 -168
  229. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  230. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.d.ts +16 -16
  231. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js +42 -43
  232. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
  233. package/lib/cjs/rpc-impl/WipRpcImpl.d.ts +15 -15
  234. package/lib/cjs/rpc-impl/WipRpcImpl.js +37 -37
  235. package/lib/cjs/workspace/Settings.d.ts +186 -186
  236. package/lib/cjs/workspace/Settings.d.ts.map +1 -1
  237. package/lib/cjs/workspace/Settings.js +154 -155
  238. package/lib/cjs/workspace/Settings.js.map +1 -1
  239. package/lib/cjs/workspace/SettingsSchemas.d.ts +75 -75
  240. package/lib/cjs/workspace/SettingsSchemas.js +190 -191
  241. package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
  242. package/lib/cjs/workspace/Workspace.d.ts +414 -414
  243. package/lib/cjs/workspace/Workspace.js +537 -543
  244. package/lib/cjs/workspace/Workspace.js.map +1 -1
  245. package/package.json +19 -19
  246. package/lib/cjs/AliCloudStorageService.d.ts +0 -24
  247. package/lib/cjs/AliCloudStorageService.d.ts.map +0 -1
  248. package/lib/cjs/AliCloudStorageService.js +0 -72
  249. package/lib/cjs/AliCloudStorageService.js.map +0 -1
  250. package/lib/cjs/CloudStorageBackend.d.ts +0 -59
  251. package/lib/cjs/CloudStorageBackend.d.ts.map +0 -1
  252. package/lib/cjs/CloudStorageBackend.js +0 -174
  253. package/lib/cjs/CloudStorageBackend.js.map +0 -1
@@ -1,102 +1,102 @@
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 Utils
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.PromiseMemoizer = exports.QueryablePromise = void 0;
11
- const core_bentley_1 = require("@itwin/core-bentley");
12
- const BackendLoggerCategory_1 = require("./BackendLoggerCategory");
13
- /** Wrapper around a promise that allows synchronous queries of it's state
14
- * @internal
15
- */
16
- class QueryablePromise {
17
- constructor(promise) {
18
- this.promise = promise;
19
- this._fulfilled = false;
20
- this._rejected = false;
21
- this.promise.then((res) => {
22
- this.result = res;
23
- this._fulfilled = true;
24
- }).catch((err) => {
25
- this.error = err;
26
- this._rejected = true;
27
- });
28
- }
29
- get isPending() { return !this.isFulfilled && !this.isRejected; }
30
- get isFulfilled() { return this._fulfilled; }
31
- get isRejected() { return this._rejected; }
32
- }
33
- exports.QueryablePromise = QueryablePromise;
34
- /** Utility to cache and retrieve results of long running asynchronous functions.
35
- * The cache is keyed on the input arguments passed to these functions
36
- * @internal
37
- */
38
- class PromiseMemoizer {
39
- /**
40
- * Constructor
41
- * @param memoizeFn Function to memoize
42
- * @param generateKeyFn Function to generate the key for the memoized function
43
- * @param maxCacheSize Maximum size of the memoizer cache.
44
- * If the maximum cache size is exceeded, fulfilled/rejected entries are first discarded - these
45
- * may have been unclaimed/orphaned promises. If the cache size is still above the maxCacheSize
46
- * threshold, the entire cache is then cleared.
47
- */
48
- constructor(memoizeFn, generateKeyFn, maxCacheSize = 500, cacheTimeout = 30000) {
49
- this._cachedPromises = new Map();
50
- this._timers = new Map();
51
- this._memoizeFn = memoizeFn;
52
- this._generateKeyFn = generateKeyFn;
53
- this._maxCacheSize = maxCacheSize;
54
- this._cacheTimeout = cacheTimeout;
55
- }
56
- /** Call the memoized function */
57
- memoize(...args) {
58
- const key = this._generateKeyFn(...args);
59
- let qp = this._cachedPromises.get(key);
60
- if (qp)
61
- return qp;
62
- if (this._cachedPromises.size >= this._maxCacheSize) {
63
- if (this._maxCacheSize > 1)
64
- core_bentley_1.Logger.logError(BackendLoggerCategory_1.BackendLoggerCategory.PromiseMemoizer, "Cleared too many unresolved entries in memoizer cache");
65
- this.clearCache();
66
- }
67
- const removeCachedPromise = (v) => {
68
- const cleanUp = () => {
69
- this._cachedPromises.delete(key);
70
- this._timers.delete(key);
71
- };
72
- this._timers.set(key, setTimeout(cleanUp, this._cacheTimeout));
73
- return v;
74
- };
75
- const p = this._memoizeFn(...args).then(removeCachedPromise, (e) => {
76
- throw removeCachedPromise(e);
77
- });
78
- qp = new QueryablePromise(p);
79
- this._cachedPromises.set(key, qp);
80
- return qp;
81
- }
82
- /** Delete the memoized function */
83
- deleteMemoized(...args) {
84
- const key = this._generateKeyFn(...args);
85
- this._cachedPromises.delete(key);
86
- const timer = this._timers.get(key);
87
- if (timer)
88
- clearTimeout(timer);
89
- }
90
- /** Clear all entries in the memoizer cache */
91
- clearCache() {
92
- this._cachedPromises.clear();
93
- }
94
- dispose() {
95
- for (const timer of this._timers.values())
96
- clearTimeout(timer);
97
- this._timers.clear();
98
- this.clearCache();
99
- }
100
- }
101
- exports.PromiseMemoizer = PromiseMemoizer;
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 Utils
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.PromiseMemoizer = exports.QueryablePromise = void 0;
11
+ const core_bentley_1 = require("@itwin/core-bentley");
12
+ const BackendLoggerCategory_1 = require("./BackendLoggerCategory");
13
+ /** Wrapper around a promise that allows synchronous queries of it's state
14
+ * @internal
15
+ */
16
+ class QueryablePromise {
17
+ get isPending() { return !this.isFulfilled && !this.isRejected; }
18
+ get isFulfilled() { return this._fulfilled; }
19
+ get isRejected() { return this._rejected; }
20
+ constructor(promise) {
21
+ this.promise = promise;
22
+ this._fulfilled = false;
23
+ this._rejected = false;
24
+ this.promise.then((res) => {
25
+ this.result = res;
26
+ this._fulfilled = true;
27
+ }).catch((err) => {
28
+ this.error = err;
29
+ this._rejected = true;
30
+ });
31
+ }
32
+ }
33
+ exports.QueryablePromise = QueryablePromise;
34
+ /** Utility to cache and retrieve results of long running asynchronous functions.
35
+ * The cache is keyed on the input arguments passed to these functions
36
+ * @internal
37
+ */
38
+ class PromiseMemoizer {
39
+ /**
40
+ * Constructor
41
+ * @param memoizeFn Function to memoize
42
+ * @param generateKeyFn Function to generate the key for the memoized function
43
+ * @param maxCacheSize Maximum size of the memoizer cache.
44
+ * If the maximum cache size is exceeded, fulfilled/rejected entries are first discarded - these
45
+ * may have been unclaimed/orphaned promises. If the cache size is still above the maxCacheSize
46
+ * threshold, the entire cache is then cleared.
47
+ */
48
+ constructor(memoizeFn, generateKeyFn, maxCacheSize = 500, cacheTimeout = 30000) {
49
+ this._cachedPromises = new Map();
50
+ this._timers = new Map();
51
+ this._memoizeFn = memoizeFn;
52
+ this._generateKeyFn = generateKeyFn;
53
+ this._maxCacheSize = maxCacheSize;
54
+ this._cacheTimeout = cacheTimeout;
55
+ }
56
+ /** Call the memoized function */
57
+ memoize(...args) {
58
+ const key = this._generateKeyFn(...args);
59
+ let qp = this._cachedPromises.get(key);
60
+ if (qp)
61
+ return qp;
62
+ if (this._cachedPromises.size >= this._maxCacheSize) {
63
+ if (this._maxCacheSize > 1)
64
+ core_bentley_1.Logger.logError(BackendLoggerCategory_1.BackendLoggerCategory.PromiseMemoizer, "Cleared too many unresolved entries in memoizer cache");
65
+ this.clearCache();
66
+ }
67
+ const removeCachedPromise = (v) => {
68
+ const cleanUp = () => {
69
+ this._cachedPromises.delete(key);
70
+ this._timers.delete(key);
71
+ };
72
+ this._timers.set(key, setTimeout(cleanUp, this._cacheTimeout));
73
+ return v;
74
+ };
75
+ const p = this._memoizeFn(...args).then(removeCachedPromise, (e) => {
76
+ throw removeCachedPromise(e);
77
+ });
78
+ qp = new QueryablePromise(p);
79
+ this._cachedPromises.set(key, qp);
80
+ return qp;
81
+ }
82
+ /** Delete the memoized function */
83
+ deleteMemoized(...args) {
84
+ const key = this._generateKeyFn(...args);
85
+ this._cachedPromises.delete(key);
86
+ const timer = this._timers.get(key);
87
+ if (timer)
88
+ clearTimeout(timer);
89
+ }
90
+ /** Clear all entries in the memoizer cache */
91
+ clearCache() {
92
+ this._cachedPromises.clear();
93
+ }
94
+ dispose() {
95
+ for (const timer of this._timers.values())
96
+ clearTimeout(timer);
97
+ this._timers.clear();
98
+ this.clearCache();
99
+ }
100
+ }
101
+ exports.PromiseMemoizer = PromiseMemoizer;
102
102
  //# sourceMappingURL=PromiseMemoizer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PromiseMemoizer.js","sourceRoot":"","sources":["../../src/PromiseMemoizer.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA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Ac,CAAC,GAAG,IAAI,CAAC,CAAC;QACjD,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjC,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACpC,IAAI,KAAK;YACP,YAAY,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;IAED,8CAA8C;IACvC,UAAU;QACf,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;IAC/B,CAAC;IAEM,OAAO;QACZ,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YACvC,YAAY,CAAC,KAAK,CAAC,CAAC;QAEtB,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACrB,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;CACF;AA5ED,0CA4EC","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 Utils\r\n */\r\n\r\nimport { IDisposable, Logger } from \"@itwin/core-bentley\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\n\r\n/** Wrapper around a promise that allows synchronous queries of it's state\r\n * @internal\r\n */\r\nexport class QueryablePromise<T> {\r\n public result?: T;\r\n public error?: any;\r\n\r\n private _fulfilled: boolean = false;\r\n private _rejected: boolean = false;\r\n\r\n public get isPending(): boolean { return !this.isFulfilled && !this.isRejected; }\r\n public get isFulfilled(): boolean { return this._fulfilled; }\r\n public get isRejected(): boolean { return this._rejected; }\r\n public constructor(public readonly promise: Promise<T>) {\r\n this.promise.then((res: T) => {\r\n this.result = res;\r\n this._fulfilled = true;\r\n }).catch((err: any) => {\r\n this.error = err;\r\n this._rejected = true;\r\n });\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport type MemoizeFnType<T> = (...args: any[]) => Promise<T>;\r\n/** @internal */\r\nexport type GenerateKeyFnType = (...args: any[]) => string;\r\n\r\n/** Utility to cache and retrieve results of long running asynchronous functions.\r\n * The cache is keyed on the input arguments passed to these functions\r\n * @internal\r\n */\r\nexport class PromiseMemoizer<T> implements IDisposable {\r\n private readonly _cachedPromises: Map<string, QueryablePromise<T>> = new Map<string, QueryablePromise<T>>();\r\n private readonly _timers: Map<string, NodeJS.Timer> = new Map<string, NodeJS.Timer>();\r\n private readonly _memoizeFn: MemoizeFnType<T>;\r\n private readonly _generateKeyFn: GenerateKeyFnType;\r\n private readonly _maxCacheSize: number;\r\n private readonly _cacheTimeout: number;\r\n\r\n /**\r\n * Constructor\r\n * @param memoizeFn Function to memoize\r\n * @param generateKeyFn Function to generate the key for the memoized function\r\n * @param maxCacheSize Maximum size of the memoizer cache.\r\n * If the maximum cache size is exceeded, fulfilled/rejected entries are first discarded - these\r\n * may have been unclaimed/orphaned promises. If the cache size is still above the maxCacheSize\r\n * threshold, the entire cache is then cleared.\r\n */\r\n public constructor(memoizeFn: MemoizeFnType<T>, generateKeyFn: GenerateKeyFnType, maxCacheSize: number = 500, cacheTimeout: number = 30000) {\r\n this._memoizeFn = memoizeFn;\r\n this._generateKeyFn = generateKeyFn;\r\n this._maxCacheSize = maxCacheSize;\r\n this._cacheTimeout = cacheTimeout;\r\n }\r\n\r\n /** Call the memoized function */\r\n public memoize(...args: any[]): QueryablePromise<T> {\r\n const key: string = this._generateKeyFn(...args);\r\n let qp: QueryablePromise<T> | undefined = this._cachedPromises.get(key);\r\n if (qp)\r\n return qp;\r\n\r\n if (this._cachedPromises.size >= this._maxCacheSize) {\r\n if (this._maxCacheSize > 1)\r\n Logger.logError(BackendLoggerCategory.PromiseMemoizer, \"Cleared too many unresolved entries in memoizer cache\");\r\n this.clearCache();\r\n }\r\n\r\n const removeCachedPromise = (v: T) => {\r\n const cleanUp = () => {\r\n this._cachedPromises.delete(key);\r\n this._timers.delete(key);\r\n };\r\n this._timers.set(key, setTimeout(cleanUp, this._cacheTimeout));\r\n return v;\r\n };\r\n\r\n const p = this._memoizeFn(...args).then(removeCachedPromise, (e) => {\r\n throw removeCachedPromise(e);\r\n });\r\n\r\n qp = new QueryablePromise<T>(p);\r\n this._cachedPromises.set(key, qp);\r\n return qp;\r\n }\r\n\r\n /** Delete the memoized function */\r\n public deleteMemoized(...args: any[]) {\r\n const key: string = this._generateKeyFn(...args);\r\n this._cachedPromises.delete(key);\r\n const timer = this._timers.get(key);\r\n if (timer)\r\n clearTimeout(timer);\r\n }\r\n\r\n /** Clear all entries in the memoizer cache */\r\n public clearCache() {\r\n this._cachedPromises.clear();\r\n }\r\n\r\n public dispose() {\r\n for (const timer of this._timers.values())\r\n clearTimeout(timer);\r\n\r\n this._timers.clear();\r\n this.clearCache();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"PromiseMemoizer.js","sourceRoot":"","sources":["../../src/PromiseMemoizer.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA0D;AAC1D,mEAAgE;AAEhE;;GAEG;AACH,MAAa,gBAAgB;IAO3B,IAAW,SAAS,KAAc,OAAO,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IACjF,IAAW,WAAW,KAAc,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IAC7D,IAAW,UAAU,KAAc,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAC3D,YAAmC,OAAmB;QAAnB,YAAO,GAAP,OAAO,CAAY;QAN9C,eAAU,GAAY,KAAK,CAAC;QAC5B,cAAS,GAAY,KAAK,CAAC;QAMjC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAM,EAAE,EAAE;YAC3B,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC;YAClB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACzB,CAAC,CAA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------------------------------------------------------\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 Utils\r\n */\r\n\r\nimport { IDisposable, Logger } from \"@itwin/core-bentley\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\n\r\n/** Wrapper around a promise that allows synchronous queries of it's state\r\n * @internal\r\n */\r\nexport class QueryablePromise<T> {\r\n public result?: T;\r\n public error?: any;\r\n\r\n private _fulfilled: boolean = false;\r\n private _rejected: boolean = false;\r\n\r\n public get isPending(): boolean { return !this.isFulfilled && !this.isRejected; }\r\n public get isFulfilled(): boolean { return this._fulfilled; }\r\n public get isRejected(): boolean { return this._rejected; }\r\n public constructor(public readonly promise: Promise<T>) {\r\n this.promise.then((res: T) => {\r\n this.result = res;\r\n this._fulfilled = true;\r\n }).catch((err: any) => {\r\n this.error = err;\r\n this._rejected = true;\r\n });\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport type MemoizeFnType<T> = (...args: any[]) => Promise<T>;\r\n/** @internal */\r\nexport type GenerateKeyFnType = (...args: any[]) => string;\r\n\r\n/** Utility to cache and retrieve results of long running asynchronous functions.\r\n * The cache is keyed on the input arguments passed to these functions\r\n * @internal\r\n */\r\nexport class PromiseMemoizer<T> implements IDisposable {\r\n private readonly _cachedPromises: Map<string, QueryablePromise<T>> = new Map<string, QueryablePromise<T>>();\r\n private readonly _timers: Map<string, NodeJS.Timer> = new Map<string, NodeJS.Timer>();\r\n private readonly _memoizeFn: MemoizeFnType<T>;\r\n private readonly _generateKeyFn: GenerateKeyFnType;\r\n private readonly _maxCacheSize: number;\r\n private readonly _cacheTimeout: number;\r\n\r\n /**\r\n * Constructor\r\n * @param memoizeFn Function to memoize\r\n * @param generateKeyFn Function to generate the key for the memoized function\r\n * @param maxCacheSize Maximum size of the memoizer cache.\r\n * If the maximum cache size is exceeded, fulfilled/rejected entries are first discarded - these\r\n * may have been unclaimed/orphaned promises. If the cache size is still above the maxCacheSize\r\n * threshold, the entire cache is then cleared.\r\n */\r\n public constructor(memoizeFn: MemoizeFnType<T>, generateKeyFn: GenerateKeyFnType, maxCacheSize: number = 500, cacheTimeout: number = 30000) {\r\n this._memoizeFn = memoizeFn;\r\n this._generateKeyFn = generateKeyFn;\r\n this._maxCacheSize = maxCacheSize;\r\n this._cacheTimeout = cacheTimeout;\r\n }\r\n\r\n /** Call the memoized function */\r\n public memoize(...args: any[]): QueryablePromise<T> {\r\n const key: string = this._generateKeyFn(...args);\r\n let qp: QueryablePromise<T> | undefined = this._cachedPromises.get(key);\r\n if (qp)\r\n return qp;\r\n\r\n if (this._cachedPromises.size >= this._maxCacheSize) {\r\n if (this._maxCacheSize > 1)\r\n Logger.logError(BackendLoggerCategory.PromiseMemoizer, \"Cleared too many unresolved entries in memoizer cache\");\r\n this.clearCache();\r\n }\r\n\r\n const removeCachedPromise = (v: T) => {\r\n const cleanUp = () => {\r\n this._cachedPromises.delete(key);\r\n this._timers.delete(key);\r\n };\r\n this._timers.set(key, setTimeout(cleanUp, this._cacheTimeout));\r\n return v;\r\n };\r\n\r\n const p = this._memoizeFn(...args).then(removeCachedPromise, (e) => {\r\n throw removeCachedPromise(e);\r\n });\r\n\r\n qp = new QueryablePromise<T>(p);\r\n this._cachedPromises.set(key, qp);\r\n return qp;\r\n }\r\n\r\n /** Delete the memoized function */\r\n public deleteMemoized(...args: any[]) {\r\n const key: string = this._generateKeyFn(...args);\r\n this._cachedPromises.delete(key);\r\n const timer = this._timers.get(key);\r\n if (timer)\r\n clearTimeout(timer);\r\n }\r\n\r\n /** Clear all entries in the memoizer cache */\r\n public clearCache() {\r\n this._cachedPromises.clear();\r\n }\r\n\r\n public dispose() {\r\n for (const timer of this._timers.values())\r\n clearTimeout(timer);\r\n\r\n this._timers.clear();\r\n this.clearCache();\r\n }\r\n}\r\n"]}
@@ -1,133 +1,133 @@
1
- import { AccessToken } from "@itwin/core-bentley";
2
- import { CloudSqlite } from "./CloudSqlite";
3
- import { SettingObject } from "./workspace/Settings";
4
- /**
5
- * A persistent storage for a set of values of type `PropertyType`, each with a unique `PropertyName`.
6
- * `PropertyStore`s are stored in cloud containers, and require an access token that grants permission to read and/or write them.
7
- * All write operations will fail without an access token that grants write permission.
8
- * A `PropertyStore` is cached on a local drive so reads are fast and inexpensive, and may even be done offline after a prefetch.
9
- * However, that means that callers are responsible for synchronizing the local cache to ensure it includes changes
10
- * made by others, as appropriate (see [[synchronizeWithCloud]]).
11
- * @alpha */
12
- export interface PropertyStore {
13
- /** The collection of property values in the PropertyStore as of the last time it was synchronized. */
14
- readonly values: PropertyStore.Values;
15
- /** Parameters for obtaining the write lock on the container for a PropertyStore.*/
16
- readonly lockParams: CloudSqlite.ObtainLockParams;
17
- /**
18
- * The token that grants access to the cloud container for this PropertyStore. If it does not grant write permissions, all
19
- * write operations will fail. It should be refreshed (via a timer) before it expires.
20
- */
21
- sasToken: AccessToken;
22
- /**
23
- * Synchronize the local values in this PropertyStore with any changes by made by others.
24
- * @note This is called automatically whenever any write operation is performed on the PropertyStore. It is only necessary to
25
- * call this directly if you have not changed the PropertyStore recently, but wish to perform a readonly operation and want to
26
- * ensure it is up-to-date as of now.
27
- * @note There is no guarantee that the Values are up-to-date even immediately after calling this method, since others
28
- * may be modifying them at any time.
29
- */
30
- synchronizeWithCloud(): void;
31
- /** initiate a prefetch operation on this PropertyStore
32
- * @internal
33
- */
34
- startPrefetch(): CloudSqlite.CloudPrefetch;
35
- /** Save a single property in this PropertyStore. If the property already exists, its value is overwritten.
36
- * @note This will obtain the write lock, save the value, and then release the write lock.
37
- */
38
- saveProperty(name: PropertyStore.PropertyName, value: PropertyStore.PropertyType): Promise<void>;
39
- /** Save an array of properties in this PropertyStore. If a property already exists, its value is overwritten.
40
- * @note This will obtain the write lock, save the values, and then release the write lock.
41
- */
42
- saveProperties(props: PropertyStore.PropertyArray): Promise<void>;
43
- /** Delete a single property from this PropertyStore. If the value does not exist, this method does nothing.
44
- * @note This will obtain the write lock, delete the value, and then release the write lock.
45
- */
46
- deleteProperty(propName: PropertyStore.PropertyName): Promise<void>;
47
- /** Delete an array of properties from this PropertyStore. Any value that does not exist is ignored.
48
- * @note This will obtain the write lock, delete the values, and then release the write lock.
49
- */
50
- deleteProperties(propNames: PropertyStore.PropertyName[]): Promise<void>;
51
- }
52
- /** @alpha */
53
- export declare namespace PropertyStore {
54
- /** @internal */
55
- let openPropertyStore: ((props: CloudSqlite.ContainerAccessProps) => PropertyStore) | undefined;
56
- /** The set of valid types for properties in a PropertyStore. */
57
- type PropertyType = string | number | boolean | Uint8Array | SettingObject;
58
- /** The name of a Property. May not have leading or trailing spaces, and must be between 3 and 2048 characters long. */
59
- type PropertyName = string;
60
- /** An array of PropertyName/PropertyType pairs to be stored in a PropertyStore. */
61
- type PropertyArray = {
62
- name: PropertyName;
63
- value: PropertyType;
64
- }[];
65
- /** The return status of an iteration function. The value "stop" causes the iteration to terminate. */
66
- type IterationReturn = void | "stop";
67
- /** An iteration function over Properties in a PropertyStore. It is called with the name of a each Property. */
68
- type PropertyIteration = (name: string) => IterationReturn;
69
- /** A filter used to limit and/or sort the values returned by an iteration. */
70
- interface PropertyFilter {
71
- /** A value filter. May include wild cards when used with `GLOB` or `LIKE` */
72
- readonly value?: string;
73
- /** The comparison operator for `value`. Default is `=` */
74
- readonly valueCompare?: "GLOB" | "LIKE" | "NOT GLOB" | "NOT LIKE" | "=" | "<" | ">";
75
- /** Order results ascending or descending. If not supplied, the results are unordered (random). */
76
- readonly orderBy?: "ASC" | "DESC";
77
- /** 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) */
78
- readonly sqlExpression?: string;
79
- }
80
- /**
81
- * A readonly set of Property values in a PropertyStore.
82
- * @alpha
83
- */
84
- interface Values {
85
- /** get the value of a Property by name.
86
- * @returns the property's value if it exists, `undefined` otherwise.
87
- */
88
- getProperty(name: PropertyName): PropertyType | undefined;
89
- /** Get the value of a string property by name.
90
- * @returns the property's value if it exists and is a string, `undefined` otherwise.
91
- */
92
- getString(name: PropertyName): string | undefined;
93
- /** Get the value of a string property by name.
94
- * @returns the property's value if it exists and is a string, otherwise the supplied default value.
95
- */
96
- getString(name: PropertyName, defaultValue: string): string;
97
- /** Get the value of a boolean property by name.
98
- * @returns the property's value if it exists and is a boolean, `undefined` otherwise.
99
- */
100
- getBoolean(name: PropertyName): boolean | undefined;
101
- /** Get the value of a boolean property by name.
102
- * @returns the property's value if it exists and is a boolean, otherwise the supplied default value.
103
- */
104
- getBoolean(name: PropertyName, defaultValue: boolean): boolean;
105
- /** Get the value of a number property by name.
106
- * @returns the property's value if it exists and is a number, `undefined` otherwise.
107
- */
108
- getNumber(name: PropertyName): number | undefined;
109
- /** Get the value of a number property by name.
110
- * @returns the property's value if it exists and is a number, otherwise the supplied default value.
111
- */
112
- getNumber(name: PropertyName, defaultValue: number): number;
113
- /** Get the value of a blob property by name.
114
- * @returns the property's value if it exists and is a blob, `undefined` otherwise.
115
- */
116
- getBlob(name: PropertyName): Uint8Array | undefined;
117
- /** Get the value of a blob property by name.
118
- * @returns the property's value if it exists and is a blob, otherwise the supplied default value.
119
- */
120
- getBlob(name: PropertyName, defaultValue: Uint8Array): Uint8Array;
121
- /** Get the value of an object property by name.
122
- * @returns the property's value if it exists and is an object, `undefined` otherwise.
123
- */
124
- getObject<T extends SettingObject>(name: PropertyName): T | undefined;
125
- /** Get the value of an object property by name.
126
- * @returns the property's value if it exists and is an object, otherwise the supplied default value.
127
- */
128
- getObject<T extends SettingObject>(name: PropertyName, defaultValue: T): T;
129
- /** call an iteration function for each property, optionally applying a filter */
130
- forAllProperties(iter: PropertyIteration, filter?: PropertyFilter): void;
131
- }
132
- }
1
+ import { AccessToken } from "@itwin/core-bentley";
2
+ import { CloudSqlite } from "./CloudSqlite";
3
+ import { SettingObject } from "./workspace/Settings";
4
+ /**
5
+ * A persistent storage for a set of values of type `PropertyType`, each with a unique `PropertyName`.
6
+ * `PropertyStore`s are stored in cloud containers, and require an access token that grants permission to read and/or write them.
7
+ * All write operations will fail without an access token that grants write permission.
8
+ * A `PropertyStore` is cached on a local drive so reads are fast and inexpensive, and may even be done offline after a prefetch.
9
+ * However, that means that callers are responsible for synchronizing the local cache to ensure it includes changes
10
+ * made by others, as appropriate (see [[synchronizeWithCloud]]).
11
+ * @alpha */
12
+ export interface PropertyStore {
13
+ /** The collection of property values in the PropertyStore as of the last time it was synchronized. */
14
+ readonly values: PropertyStore.Values;
15
+ /** Parameters for obtaining the write lock on the container for a PropertyStore.*/
16
+ readonly lockParams: CloudSqlite.ObtainLockParams;
17
+ /**
18
+ * The token that grants access to the cloud container for this PropertyStore. If it does not grant write permissions, all
19
+ * write operations will fail. It should be refreshed (via a timer) before it expires.
20
+ */
21
+ sasToken: AccessToken;
22
+ /**
23
+ * Synchronize the local values in this PropertyStore with any changes by made by others.
24
+ * @note This is called automatically whenever any write operation is performed on the PropertyStore. It is only necessary to
25
+ * call this directly if you have not changed the PropertyStore recently, but wish to perform a readonly operation and want to
26
+ * ensure it is up-to-date as of now.
27
+ * @note There is no guarantee that the Values are up-to-date even immediately after calling this method, since others
28
+ * may be modifying them at any time.
29
+ */
30
+ synchronizeWithCloud(): void;
31
+ /** initiate a prefetch operation on this PropertyStore
32
+ * @internal
33
+ */
34
+ startPrefetch(): CloudSqlite.CloudPrefetch;
35
+ /** Save a single property in this PropertyStore. If the property already exists, its value is overwritten.
36
+ * @note This will obtain the write lock, save the value, and then release the write lock.
37
+ */
38
+ saveProperty(name: PropertyStore.PropertyName, value: PropertyStore.PropertyType): Promise<void>;
39
+ /** Save an array of properties in this PropertyStore. If a property already exists, its value is overwritten.
40
+ * @note This will obtain the write lock, save the values, and then release the write lock.
41
+ */
42
+ saveProperties(props: PropertyStore.PropertyArray): Promise<void>;
43
+ /** Delete a single property from this PropertyStore. If the value does not exist, this method does nothing.
44
+ * @note This will obtain the write lock, delete the value, and then release the write lock.
45
+ */
46
+ deleteProperty(propName: PropertyStore.PropertyName): Promise<void>;
47
+ /** Delete an array of properties from this PropertyStore. Any value that does not exist is ignored.
48
+ * @note This will obtain the write lock, delete the values, and then release the write lock.
49
+ */
50
+ deleteProperties(propNames: PropertyStore.PropertyName[]): Promise<void>;
51
+ }
52
+ /** @alpha */
53
+ export declare namespace PropertyStore {
54
+ /** @internal */
55
+ let openPropertyStore: ((props: CloudSqlite.ContainerAccessProps) => PropertyStore) | undefined;
56
+ /** The set of valid types for properties in a PropertyStore. */
57
+ type PropertyType = string | number | boolean | Uint8Array | SettingObject;
58
+ /** The name of a Property. May not have leading or trailing spaces, and must be between 3 and 2048 characters long. */
59
+ type PropertyName = string;
60
+ /** An array of PropertyName/PropertyType pairs to be stored in a PropertyStore. */
61
+ type PropertyArray = {
62
+ name: PropertyName;
63
+ value: PropertyType;
64
+ }[];
65
+ /** The return status of an iteration function. The value "stop" causes the iteration to terminate. */
66
+ type IterationReturn = void | "stop";
67
+ /** An iteration function over Properties in a PropertyStore. It is called with the name of a each Property. */
68
+ type PropertyIteration = (name: string) => IterationReturn;
69
+ /** A filter used to limit and/or sort the values returned by an iteration. */
70
+ interface PropertyFilter {
71
+ /** A value filter. May include wild cards when used with `GLOB` or `LIKE` */
72
+ readonly value?: string;
73
+ /** The comparison operator for `value`. Default is `=` */
74
+ readonly valueCompare?: "GLOB" | "LIKE" | "NOT GLOB" | "NOT LIKE" | "=" | "<" | ">";
75
+ /** Order results ascending or descending. If not supplied, the results are unordered (random). */
76
+ readonly orderBy?: "ASC" | "DESC";
77
+ /** 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) */
78
+ readonly sqlExpression?: string;
79
+ }
80
+ /**
81
+ * A readonly set of Property values in a PropertyStore.
82
+ * @alpha
83
+ */
84
+ interface Values {
85
+ /** get the value of a Property by name.
86
+ * @returns the property's value if it exists, `undefined` otherwise.
87
+ */
88
+ getProperty(name: PropertyName): PropertyType | undefined;
89
+ /** Get the value of a string property by name.
90
+ * @returns the property's value if it exists and is a string, `undefined` otherwise.
91
+ */
92
+ getString(name: PropertyName): string | undefined;
93
+ /** Get the value of a string property by name.
94
+ * @returns the property's value if it exists and is a string, otherwise the supplied default value.
95
+ */
96
+ getString(name: PropertyName, defaultValue: string): string;
97
+ /** Get the value of a boolean property by name.
98
+ * @returns the property's value if it exists and is a boolean, `undefined` otherwise.
99
+ */
100
+ getBoolean(name: PropertyName): boolean | undefined;
101
+ /** Get the value of a boolean property by name.
102
+ * @returns the property's value if it exists and is a boolean, otherwise the supplied default value.
103
+ */
104
+ getBoolean(name: PropertyName, defaultValue: boolean): boolean;
105
+ /** Get the value of a number property by name.
106
+ * @returns the property's value if it exists and is a number, `undefined` otherwise.
107
+ */
108
+ getNumber(name: PropertyName): number | undefined;
109
+ /** Get the value of a number property by name.
110
+ * @returns the property's value if it exists and is a number, otherwise the supplied default value.
111
+ */
112
+ getNumber(name: PropertyName, defaultValue: number): number;
113
+ /** Get the value of a blob property by name.
114
+ * @returns the property's value if it exists and is a blob, `undefined` otherwise.
115
+ */
116
+ getBlob(name: PropertyName): Uint8Array | undefined;
117
+ /** Get the value of a blob property by name.
118
+ * @returns the property's value if it exists and is a blob, otherwise the supplied default value.
119
+ */
120
+ getBlob(name: PropertyName, defaultValue: Uint8Array): Uint8Array;
121
+ /** Get the value of an object property by name.
122
+ * @returns the property's value if it exists and is an object, `undefined` otherwise.
123
+ */
124
+ getObject<T extends SettingObject>(name: PropertyName): T | undefined;
125
+ /** Get the value of an object property by name.
126
+ * @returns the property's value if it exists and is an object, otherwise the supplied default value.
127
+ */
128
+ getObject<T extends SettingObject>(name: PropertyName, defaultValue: T): T;
129
+ /** call an iteration function for each property, optionally applying a filter */
130
+ forAllProperties(iter: PropertyIteration, filter?: PropertyFilter): void;
131
+ }
132
+ }
133
133
  //# sourceMappingURL=PropertyStore.d.ts.map
@@ -1,12 +1,12 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.PropertyStore = void 0;
8
- /** @alpha */
9
- var PropertyStore;
10
- (function (PropertyStore) {
11
- })(PropertyStore = exports.PropertyStore || (exports.PropertyStore = {}));
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
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.PropertyStore = void 0;
8
+ /** @alpha */
9
+ var PropertyStore;
10
+ (function (PropertyStore) {
11
+ })(PropertyStore = exports.PropertyStore || (exports.PropertyStore = {}));
12
12
  //# sourceMappingURL=PropertyStore.js.map