@itwin/core-backend 4.0.0-dev.10 → 4.0.0-dev.101
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +68 -1
- package/lib/cjs/BackendHubAccess.d.ts +226 -224
- package/lib/cjs/BackendHubAccess.d.ts.map +1 -1
- package/lib/cjs/BackendHubAccess.js +41 -41
- package/lib/cjs/BackendHubAccess.js.map +1 -1
- package/lib/cjs/BackendLoggerCategory.d.ts +90 -91
- package/lib/cjs/BackendLoggerCategory.d.ts.map +1 -1
- package/lib/cjs/BackendLoggerCategory.js +98 -99
- package/lib/cjs/BackendLoggerCategory.js.map +1 -1
- package/lib/cjs/BisCoreSchema.d.ts +21 -21
- package/lib/cjs/BisCoreSchema.js +60 -60
- package/lib/cjs/BisCoreSchema.js.map +1 -1
- package/lib/cjs/BlobContainerService.d.ts +120 -0
- package/lib/cjs/BlobContainerService.d.ts.map +1 -0
- package/lib/cjs/BlobContainerService.js +18 -0
- package/lib/cjs/BlobContainerService.js.map +1 -0
- package/lib/cjs/BriefcaseManager.d.ts +184 -170
- package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
- package/lib/cjs/BriefcaseManager.js +421 -414
- package/lib/cjs/BriefcaseManager.js.map +1 -1
- package/lib/cjs/Category.d.ts +153 -153
- package/lib/cjs/Category.js +243 -243
- package/lib/cjs/Category.js.map +1 -1
- package/lib/cjs/ChangeSummaryManager.d.ts +187 -187
- package/lib/cjs/ChangeSummaryManager.js +446 -447
- package/lib/cjs/ChangeSummaryManager.js.map +1 -1
- package/lib/cjs/ChangedElementsDb.d.ts +99 -99
- package/lib/cjs/ChangedElementsDb.js +165 -165
- package/lib/cjs/ChangedElementsDb.js.map +1 -1
- package/lib/cjs/ChangedElementsManager.d.ts +39 -39
- package/lib/cjs/ChangedElementsManager.js +88 -88
- package/lib/cjs/ChangedElementsManager.js.map +1 -1
- package/lib/cjs/ChannelControl.d.ts +70 -0
- package/lib/cjs/ChannelControl.d.ts.map +1 -0
- package/lib/cjs/ChannelControl.js +89 -0
- package/lib/cjs/ChannelControl.js.map +1 -0
- package/lib/cjs/CheckpointManager.d.ts +121 -121
- package/lib/cjs/CheckpointManager.d.ts.map +1 -1
- package/lib/cjs/CheckpointManager.js +351 -349
- package/lib/cjs/CheckpointManager.js.map +1 -1
- package/lib/cjs/ClassRegistry.d.ts +79 -79
- package/lib/cjs/ClassRegistry.js +254 -250
- package/lib/cjs/ClassRegistry.js.map +1 -1
- package/lib/cjs/CloudSqlite.d.ts +572 -350
- package/lib/cjs/CloudSqlite.d.ts.map +1 -1
- package/lib/cjs/CloudSqlite.js +374 -153
- package/lib/cjs/CloudSqlite.js.map +1 -1
- package/lib/cjs/CodeService.d.ts +399 -396
- package/lib/cjs/CodeService.d.ts.map +1 -1
- package/lib/cjs/CodeService.js +63 -63
- package/lib/cjs/CodeService.js.map +1 -1
- package/lib/cjs/CodeSpecs.d.ts +58 -55
- package/lib/cjs/CodeSpecs.d.ts.map +1 -1
- package/lib/cjs/CodeSpecs.js +154 -124
- package/lib/cjs/CodeSpecs.js.map +1 -1
- package/lib/cjs/ConcurrentQuery.d.ts +13 -13
- package/lib/cjs/ConcurrentQuery.d.ts.map +1 -1
- package/lib/cjs/ConcurrentQuery.js +36 -36
- package/lib/cjs/ConcurrentQuery.js.map +1 -1
- package/lib/cjs/CustomViewState3dCreator.d.ts +21 -21
- package/lib/cjs/CustomViewState3dCreator.d.ts.map +1 -1
- package/lib/cjs/CustomViewState3dCreator.js +80 -81
- package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
- package/lib/cjs/DevTools.d.ts +74 -71
- package/lib/cjs/DevTools.d.ts.map +1 -1
- package/lib/cjs/DevTools.js +156 -154
- package/lib/cjs/DevTools.js.map +1 -1
- package/lib/cjs/DisplayStyle.d.ts +104 -106
- package/lib/cjs/DisplayStyle.d.ts.map +1 -1
- package/lib/cjs/DisplayStyle.js +251 -256
- package/lib/cjs/DisplayStyle.js.map +1 -1
- package/lib/cjs/ECDb.d.ts +194 -191
- package/lib/cjs/ECDb.d.ts.map +1 -1
- package/lib/cjs/ECDb.js +351 -350
- package/lib/cjs/ECDb.js.map +1 -1
- package/lib/cjs/ECSchemaXmlContext.d.ts +18 -18
- package/lib/cjs/ECSchemaXmlContext.d.ts.map +1 -1
- package/lib/cjs/ECSchemaXmlContext.js +41 -41
- package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
- package/lib/cjs/ECSqlStatement.d.ts +473 -473
- package/lib/cjs/ECSqlStatement.js +791 -791
- package/lib/cjs/ECSqlStatement.js.map +1 -1
- package/lib/cjs/Element.d.ts +1105 -1109
- package/lib/cjs/Element.d.ts.map +1 -1
- package/lib/cjs/Element.js +1416 -1427
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/ElementAspect.d.ts +175 -179
- package/lib/cjs/ElementAspect.d.ts.map +1 -1
- package/lib/cjs/ElementAspect.js +202 -211
- package/lib/cjs/ElementAspect.js.map +1 -1
- package/lib/cjs/ElementGraphics.d.ts +9 -9
- package/lib/cjs/ElementGraphics.js +41 -41
- package/lib/cjs/ElementGraphics.js.map +1 -1
- package/lib/cjs/ElementTreeWalker.d.ts +162 -162
- package/lib/cjs/ElementTreeWalker.d.ts.map +1 -1
- package/lib/cjs/ElementTreeWalker.js +409 -409
- package/lib/cjs/ElementTreeWalker.js.map +1 -1
- package/lib/cjs/Entity.d.ts +102 -106
- package/lib/cjs/Entity.d.ts.map +1 -1
- package/lib/cjs/Entity.js +118 -134
- package/lib/cjs/Entity.js.map +1 -1
- package/lib/cjs/EntityReferences.d.ts +49 -49
- package/lib/cjs/EntityReferences.d.ts.map +1 -1
- package/lib/cjs/EntityReferences.js +95 -95
- package/lib/cjs/EntityReferences.js.map +1 -1
- package/lib/cjs/ExportGraphics.d.ts +317 -317
- package/lib/cjs/ExportGraphics.d.ts.map +1 -1
- package/lib/cjs/ExportGraphics.js +208 -208
- package/lib/cjs/ExportGraphics.js.map +1 -1
- package/lib/cjs/ExternalSource.d.ts +95 -96
- package/lib/cjs/ExternalSource.d.ts.map +1 -1
- package/lib/cjs/ExternalSource.js +130 -131
- package/lib/cjs/ExternalSource.js.map +1 -1
- package/lib/cjs/GeoCoordConfig.d.ts +19 -19
- package/lib/cjs/GeoCoordConfig.js +85 -85
- package/lib/cjs/GeoCoordConfig.js.map +1 -1
- package/lib/cjs/GeometrySummary.d.ts +4 -4
- package/lib/cjs/GeometrySummary.js +380 -380
- package/lib/cjs/GeometrySummary.js.map +1 -1
- package/lib/cjs/HubMock.d.ts +94 -94
- package/lib/cjs/HubMock.js +220 -222
- package/lib/cjs/HubMock.js.map +1 -1
- package/lib/cjs/IModelCloneContext.d.ts +8 -8
- package/lib/cjs/IModelCloneContext.d.ts.map +1 -1
- package/lib/cjs/IModelCloneContext.js +15 -15
- package/lib/cjs/IModelCloneContext.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +1222 -1196
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +2389 -2392
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/IModelElementCloneContext.d.ts +89 -89
- package/lib/cjs/IModelElementCloneContext.js +159 -159
- package/lib/cjs/IModelElementCloneContext.js.map +1 -1
- package/lib/cjs/IModelHost.d.ts +370 -369
- package/lib/cjs/IModelHost.d.ts.map +1 -1
- package/lib/cjs/IModelHost.js +476 -496
- package/lib/cjs/IModelHost.js.map +1 -1
- package/lib/cjs/IModelJsFs.d.ts +62 -62
- package/lib/cjs/IModelJsFs.js +139 -140
- package/lib/cjs/IModelJsFs.js.map +1 -1
- package/lib/cjs/IpcHost.d.ts +104 -104
- package/lib/cjs/IpcHost.js +276 -278
- package/lib/cjs/IpcHost.js.map +1 -1
- package/lib/cjs/LineStyle.d.ts +311 -311
- package/lib/cjs/LineStyle.js +295 -295
- package/lib/cjs/LineStyle.js.map +1 -1
- package/lib/cjs/LocalHub.d.ts +162 -162
- package/lib/cjs/LocalHub.d.ts.map +1 -1
- package/lib/cjs/LocalHub.js +580 -585
- package/lib/cjs/LocalHub.js.map +1 -1
- package/lib/cjs/LocalhostIpcHost.d.ts +21 -20
- package/lib/cjs/LocalhostIpcHost.d.ts.map +1 -1
- package/lib/cjs/LocalhostIpcHost.js +79 -81
- package/lib/cjs/LocalhostIpcHost.js.map +1 -1
- package/lib/cjs/Material.d.ts +131 -131
- package/lib/cjs/Material.d.ts.map +1 -1
- package/lib/cjs/Material.js +185 -181
- package/lib/cjs/Material.js.map +1 -1
- package/lib/cjs/Model.d.ts +391 -392
- package/lib/cjs/Model.d.ts.map +1 -1
- package/lib/cjs/Model.js +487 -485
- package/lib/cjs/Model.js.map +1 -1
- package/lib/cjs/NativeAppStorage.d.ts +51 -51
- package/lib/cjs/NativeAppStorage.js +202 -202
- package/lib/cjs/NativeAppStorage.js.map +1 -1
- package/lib/cjs/NativeHost.d.ts +52 -52
- package/lib/cjs/NativeHost.d.ts.map +1 -1
- package/lib/cjs/NativeHost.js +158 -163
- package/lib/cjs/NativeHost.js.map +1 -1
- package/lib/cjs/NavigationRelationship.d.ts +156 -156
- package/lib/cjs/NavigationRelationship.js +225 -225
- package/lib/cjs/NavigationRelationship.js.map +1 -1
- package/lib/cjs/PromiseMemoizer.d.ts +51 -51
- package/lib/cjs/PromiseMemoizer.d.ts.map +1 -1
- package/lib/cjs/PromiseMemoizer.js +101 -101
- package/lib/cjs/PromiseMemoizer.js.map +1 -1
- package/lib/cjs/PropertyStore.d.ts +123 -132
- package/lib/cjs/PropertyStore.d.ts.map +1 -1
- package/lib/cjs/PropertyStore.js +179 -11
- package/lib/cjs/PropertyStore.js.map +1 -1
- package/lib/cjs/Relationship.d.ts +413 -416
- package/lib/cjs/Relationship.d.ts.map +1 -1
- package/lib/cjs/Relationship.js +491 -494
- package/lib/cjs/Relationship.js.map +1 -1
- package/lib/cjs/RpcBackend.d.ts +5 -5
- package/lib/cjs/RpcBackend.js +32 -32
- package/lib/cjs/RpcBackend.js.map +1 -1
- package/lib/cjs/SQLiteDb.d.ts +317 -219
- package/lib/cjs/SQLiteDb.d.ts.map +1 -1
- package/lib/cjs/SQLiteDb.js +318 -214
- package/lib/cjs/SQLiteDb.js.map +1 -1
- package/lib/cjs/Schema.d.ts +55 -55
- package/lib/cjs/Schema.js +83 -83
- package/lib/cjs/Schema.js.map +1 -1
- package/lib/cjs/ServerBasedLocks.d.ts +57 -57
- package/lib/cjs/ServerBasedLocks.js +168 -168
- package/lib/cjs/ServerBasedLocks.js.map +1 -1
- package/lib/cjs/SqliteStatement.d.ts +360 -360
- package/lib/cjs/SqliteStatement.d.ts.map +1 -1
- package/lib/cjs/SqliteStatement.js +586 -586
- package/lib/cjs/SqliteStatement.js.map +1 -1
- package/lib/cjs/Texture.d.ts +58 -58
- package/lib/cjs/Texture.js +82 -82
- package/lib/cjs/Texture.js.map +1 -1
- package/lib/cjs/TileStorage.d.ts +44 -18
- package/lib/cjs/TileStorage.d.ts.map +1 -1
- package/lib/cjs/TileStorage.js +109 -90
- package/lib/cjs/TileStorage.js.map +1 -1
- package/lib/cjs/TxnManager.d.ts +202 -202
- package/lib/cjs/TxnManager.d.ts.map +1 -1
- package/lib/cjs/TxnManager.js +356 -356
- package/lib/cjs/TxnManager.js.map +1 -1
- package/lib/cjs/ViewDefinition.d.ts +429 -439
- package/lib/cjs/ViewDefinition.d.ts.map +1 -1
- package/lib/cjs/ViewDefinition.js +640 -646
- package/lib/cjs/ViewDefinition.js.map +1 -1
- package/lib/cjs/ViewStateHydrator.d.ts +13 -13
- package/lib/cjs/ViewStateHydrator.js +103 -103
- package/lib/cjs/ViewStateHydrator.js.map +1 -1
- package/lib/cjs/assets/IModelChange.02.00.00.ecschema.xml +90 -90
- package/lib/cjs/assets/Settings/Schemas/Cloud.Schema.json +67 -67
- package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +31 -31
- package/lib/cjs/assets/Settings/Schemas/Workspace.Schema.json +52 -52
- package/lib/cjs/assets/Settings/backend.setting.json5 +138 -138
- package/lib/cjs/core-backend.d.ts +181 -184
- package/lib/cjs/core-backend.d.ts.map +1 -1
- package/lib/cjs/core-backend.js +205 -204
- package/lib/cjs/core-backend.js.map +1 -1
- package/lib/cjs/domains/FunctionalElements.d.ts +101 -101
- package/lib/cjs/domains/FunctionalElements.js +145 -145
- package/lib/cjs/domains/FunctionalElements.js.map +1 -1
- package/lib/cjs/domains/FunctionalSchema.d.ts +13 -13
- package/lib/cjs/domains/FunctionalSchema.d.ts.map +1 -1
- package/lib/cjs/domains/FunctionalSchema.js +39 -40
- package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
- package/lib/cjs/domains/GenericElements.d.ts +177 -177
- package/lib/cjs/domains/GenericElements.js +263 -263
- package/lib/cjs/domains/GenericElements.js.map +1 -1
- package/lib/cjs/domains/GenericSchema.d.ts +10 -10
- package/lib/cjs/domains/GenericSchema.js +28 -28
- package/lib/cjs/domains/GenericSchema.js.map +1 -1
- package/lib/cjs/rpc/multipart.d.ts +11 -11
- package/lib/cjs/rpc/multipart.js +71 -71
- package/lib/cjs/rpc/multipart.js.map +1 -1
- package/lib/cjs/rpc/tracing.d.ts +28 -28
- package/lib/cjs/rpc/tracing.js +73 -74
- package/lib/cjs/rpc/tracing.js.map +1 -1
- package/lib/cjs/rpc/web/logging.d.ts +9 -9
- package/lib/cjs/rpc/web/logging.js +43 -43
- package/lib/cjs/rpc/web/logging.js.map +1 -1
- package/lib/cjs/rpc/web/request.d.ts +6 -6
- package/lib/cjs/rpc/web/request.js +73 -74
- package/lib/cjs/rpc/web/request.js.map +1 -1
- package/lib/cjs/rpc/web/response.d.ts +6 -6
- package/lib/cjs/rpc/web/response.js +105 -106
- package/lib/cjs/rpc/web/response.js.map +1 -1
- package/lib/cjs/rpc-impl/DevToolsRpcImpl.d.ts +15 -15
- package/lib/cjs/rpc-impl/DevToolsRpcImpl.js +32 -32
- package/lib/cjs/rpc-impl/DevToolsRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +47 -47
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +293 -294
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts +20 -22
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +193 -205
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts +36 -36
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +166 -168
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
- package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.d.ts +16 -16
- package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js +42 -43
- package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/WipRpcImpl.d.ts +15 -15
- package/lib/cjs/rpc-impl/WipRpcImpl.js +37 -37
- package/lib/cjs/rpc-impl/WipRpcImpl.js.map +1 -1
- package/lib/cjs/workspace/Settings.d.ts +186 -186
- package/lib/cjs/workspace/Settings.d.ts.map +1 -1
- package/lib/cjs/workspace/Settings.js +155 -155
- package/lib/cjs/workspace/Settings.js.map +1 -1
- package/lib/cjs/workspace/SettingsSchemas.d.ts +75 -75
- package/lib/cjs/workspace/SettingsSchemas.js +190 -191
- package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
- package/lib/cjs/workspace/Workspace.d.ts +411 -414
- package/lib/cjs/workspace/Workspace.d.ts.map +1 -1
- package/lib/cjs/workspace/Workspace.js +521 -543
- package/lib/cjs/workspace/Workspace.js.map +1 -1
- package/package.json +25 -28
- package/lib/cjs/AliCloudStorageService.d.ts +0 -24
- package/lib/cjs/AliCloudStorageService.d.ts.map +0 -1
- package/lib/cjs/AliCloudStorageService.js +0 -72
- package/lib/cjs/AliCloudStorageService.js.map +0 -1
- package/lib/cjs/CloudStorageBackend.d.ts +0 -59
- package/lib/cjs/CloudStorageBackend.d.ts.map +0 -1
- package/lib/cjs/CloudStorageBackend.js +0 -174
- 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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
this.promise
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
this.
|
|
26
|
-
this.
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
|
|
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;
|
|
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,sDAA0D;AAC1D,mEAAgE;AAEhE;;GAEG;AACH,MAAa,gBAAgB;
|
|
1
|
+
{"version":3,"file":"PromiseMemoizer.js","sourceRoot":"","sources":["../../src/PromiseMemoizer.ts"],"names":[],"mappings":";AAAA;;;+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,MAAM,GAAG,GAAW,IAAI,CAAC,cAAc,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":["/*---------------------------------------------------------------------------------------------\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,124 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { SettingObject } from "./workspace/Settings";
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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 { CloudSqlite } from "./CloudSqlite";
|
|
2
|
+
import { VersionedSqliteDb } from "./SQLiteDb";
|
|
3
|
+
import { SettingObject } from "./workspace/Settings";
|
|
4
|
+
/** @beta */
|
|
5
|
+
export declare namespace PropertyStore {
|
|
6
|
+
/** The set of valid types for properties in a PropertyStore. */
|
|
7
|
+
type PropertyType = string | number | boolean | Uint8Array | SettingObject;
|
|
8
|
+
/** The case-sensitive name of a Property. May not have leading or trailing spaces, and must be between 3 and 2048 characters long. */
|
|
9
|
+
type PropertyName = string;
|
|
10
|
+
/** An array of PropertyName/PropertyType pairs to be stored in a PropertyStore. */
|
|
11
|
+
type PropertyArray = {
|
|
12
|
+
name: PropertyName;
|
|
13
|
+
value: PropertyType;
|
|
14
|
+
}[];
|
|
15
|
+
/** The return status of an iteration function. The value "stop" causes the iteration to terminate. */
|
|
16
|
+
type IterationReturn = void | "stop";
|
|
17
|
+
/** An iteration function over Properties in a PropertyStore. It is called with the name of a each Property. */
|
|
18
|
+
type PropertyIteration = (name: string) => IterationReturn;
|
|
19
|
+
/** A filter used to limit and/or sort the values returned by an iteration. */
|
|
20
|
+
interface PropertyFilter {
|
|
21
|
+
/** A value filter. May include wild cards when used with `GLOB` or `LIKE` */
|
|
22
|
+
readonly value?: string;
|
|
23
|
+
/** The comparison operator for `value`. Default is `=` */
|
|
24
|
+
readonly valueCompare?: "GLOB" | "LIKE" | "NOT GLOB" | "NOT LIKE" | "=" | "!=" | "<" | ">";
|
|
25
|
+
/** Order results ascending or descending. If not supplied, the results are unordered (random). */
|
|
26
|
+
readonly orderBy?: "ASC" | "DESC";
|
|
27
|
+
/** 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) */
|
|
28
|
+
readonly sqlExpression?: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A SQLite database for storing PropertyName/PropertyValue pairs.
|
|
32
|
+
*/
|
|
33
|
+
class PropertyDb extends VersionedSqliteDb {
|
|
34
|
+
readonly myVersion = "3.0.0";
|
|
35
|
+
protected createDDL(): void;
|
|
36
|
+
/** get the value of a Property by name.
|
|
37
|
+
* @returns the property's value if it exists, `undefined` otherwise.
|
|
38
|
+
*/
|
|
39
|
+
getProperty(name: PropertyName): PropertyType | undefined;
|
|
40
|
+
/** Get the value of a string property by name.
|
|
41
|
+
* @returns the property's value if it exists and is a string, `undefined` otherwise.
|
|
42
|
+
*/
|
|
43
|
+
getString(name: PropertyName, defaultValue: string): string;
|
|
44
|
+
/** Get the value of a string property by name.
|
|
45
|
+
* @returns the property's value if it exists and is a string, otherwise the supplied default value.
|
|
46
|
+
*/
|
|
47
|
+
getString(name: PropertyName): string | undefined;
|
|
48
|
+
/** Get the value of a boolean property by name.
|
|
49
|
+
* @returns the property's value if it exists and is a boolean, `undefined` otherwise.
|
|
50
|
+
*/
|
|
51
|
+
getBoolean(name: PropertyName): boolean | undefined;
|
|
52
|
+
/** Get the value of a boolean property by name.
|
|
53
|
+
* @returns the property's value if it exists and is a boolean, otherwise the supplied default value.
|
|
54
|
+
*/
|
|
55
|
+
getBoolean(name: PropertyName, defaultValue: boolean): boolean;
|
|
56
|
+
/** Get the value of a number property by name.
|
|
57
|
+
* @returns the property's value if it exists and is a number, `undefined` otherwise.
|
|
58
|
+
*/
|
|
59
|
+
getNumber(name: PropertyName): number | undefined;
|
|
60
|
+
/** Get the value of a number property by name.
|
|
61
|
+
* @returns the property's value if it exists and is a number, otherwise the supplied default value.
|
|
62
|
+
*/
|
|
63
|
+
getNumber(name: PropertyName, defaultValue: number): number;
|
|
64
|
+
/** Get the value of a blob property by name.
|
|
65
|
+
* @returns the property's value if it exists and is a blob, `undefined` otherwise.
|
|
66
|
+
*/
|
|
67
|
+
getBlob(name: PropertyName): Uint8Array | undefined;
|
|
68
|
+
/** Get the value of a blob property by name.
|
|
69
|
+
* @returns the property's value if it exists and is a blob, otherwise the supplied default value.
|
|
70
|
+
*/
|
|
71
|
+
getBlob(name: PropertyName, defaultValue: Uint8Array): Uint8Array;
|
|
72
|
+
/** Get the value of an object property by name.
|
|
73
|
+
* @returns the property's value if it exists and is an object, `undefined` otherwise.
|
|
74
|
+
*/
|
|
75
|
+
getObject(name: PropertyName): SettingObject | undefined;
|
|
76
|
+
/** Get the value of an object property by name.
|
|
77
|
+
* @returns the property's value if it exists and is an object, otherwise the supplied default value.
|
|
78
|
+
*/
|
|
79
|
+
getObject(name: PropertyName, defaultValue: SettingObject): SettingObject;
|
|
80
|
+
/** call an iteration function for each property, optionally applying a filter */
|
|
81
|
+
forAllProperties(iter: PropertyIteration, filter?: PropertyFilter): void;
|
|
82
|
+
/** Delete a single property from this PropertyDb. If the value does not exist, this method does nothing.
|
|
83
|
+
* @note the database must be opened for write
|
|
84
|
+
*/
|
|
85
|
+
deleteProperty(propName: PropertyName): Promise<void>;
|
|
86
|
+
/** Delete an array of properties from this PropertyDb. Any value that does not exist is ignored.
|
|
87
|
+
* @note the database must be opened for write
|
|
88
|
+
*/
|
|
89
|
+
deleteProperties(propNames: PropertyName[]): Promise<void>;
|
|
90
|
+
private validateName;
|
|
91
|
+
/** Save a single property in this PropertyDb. If the property already exists, its value is overwritten.
|
|
92
|
+
* @note the database must be opened for write
|
|
93
|
+
*/
|
|
94
|
+
saveProperty(name: PropertyName, value: PropertyType): Promise<void>;
|
|
95
|
+
/** Save an array of properties in this PropertyDb. If a property already exists, its value is overwritten.
|
|
96
|
+
* @note the database must be opened for write
|
|
97
|
+
*/
|
|
98
|
+
saveProperties(props: PropertyArray): Promise<void>;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Provides access to a cloud-based `PropertyDb` to hold a set of values of type `PropertyType`, each with a unique `PropertyName`.
|
|
102
|
+
* `PropertyStore.PropertyDb`s that are stored in cloud containers require an access token that grants permission to read and/or write them.
|
|
103
|
+
* All write operations will fail without an access token that grants write permission.
|
|
104
|
+
*
|
|
105
|
+
* The database is cached on a local drive so reads are fast and inexpensive, and may even be done offline after a prefetch.
|
|
106
|
+
* However, that means that callers are responsible for synchronizing the local cache to ensure it includes changes
|
|
107
|
+
* made by others, as appropriate (see [[synchronizeWithCloud]]).
|
|
108
|
+
*/
|
|
109
|
+
class CloudAccess extends CloudSqlite.DbAccess<PropertyDb> {
|
|
110
|
+
constructor(props: CloudSqlite.ContainerAccessProps);
|
|
111
|
+
/**
|
|
112
|
+
* Initialize a cloud container for use as a PropertyStore. The container must first be created via its storage supplier api (e.g. Azure, or AWS).
|
|
113
|
+
* A valid sasToken that grants write access must be supplied. This function creates and uploads an empty PropertyDb into the container.
|
|
114
|
+
* @note this deletes any existing content in the container.
|
|
115
|
+
*/
|
|
116
|
+
static initializeDb(args: {
|
|
117
|
+
props: CloudSqlite.ContainerAccessProps;
|
|
118
|
+
initContainer?: {
|
|
119
|
+
blockSize?: number;
|
|
120
|
+
};
|
|
121
|
+
}): Promise<void>;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
133
124
|
//# sourceMappingURL=PropertyStore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyStore.d.ts","sourceRoot":"","sources":["../../src/PropertyStore.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PropertyStore.d.ts","sourceRoot":"","sources":["../../src/PropertyStore.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,YAAY;AACZ,yBAAiB,aAAa,CAAC;IAE7B,gEAAgE;IAChE,KAAY,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,aAAa,CAAC;IAClF,sIAAsI;IACtI,KAAY,YAAY,GAAG,MAAM,CAAC;IAClC,mFAAmF;IACnF,KAAY,aAAa,GAAG;QAAE,IAAI,EAAE,YAAY,CAAC;QAAC,KAAK,EAAE,YAAY,CAAA;KAAE,EAAE,CAAC;IAC1E,sGAAsG;IACtG,KAAY,eAAe,GAAG,IAAI,GAAG,MAAM,CAAC;IAC5C,+GAA+G;IAC/G,KAAY,iBAAiB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,eAAe,CAAC;IAElE,8EAA8E;IAC9E,UAAiB,cAAc;QAC7B,6EAA6E;QAC7E,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QACxB,0DAA0D;QAC1D,QAAQ,CAAC,YAAY,CA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