@itwin/core-backend 4.0.0-dev.52 → 4.0.0-dev.54

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