@itwin/core-backend 3.4.0-dev.9 → 3.5.0-dev.5
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 +41 -1
- package/lib/cjs/AliCloudStorageService.d.ts +8 -2
- package/lib/cjs/AliCloudStorageService.d.ts.map +1 -1
- package/lib/cjs/AliCloudStorageService.js +4 -1
- package/lib/cjs/AliCloudStorageService.js.map +1 -1
- package/lib/cjs/BackendHubAccess.d.ts.map +1 -1
- package/lib/cjs/BackendHubAccess.js.map +1 -1
- package/lib/cjs/BackendLoggerCategory.d.ts +9 -5
- package/lib/cjs/BackendLoggerCategory.d.ts.map +1 -1
- package/lib/cjs/BackendLoggerCategory.js +9 -5
- package/lib/cjs/BackendLoggerCategory.js.map +1 -1
- package/lib/cjs/ChangedElementsDb.d.ts +1 -0
- package/lib/cjs/ChangedElementsDb.d.ts.map +1 -1
- package/lib/cjs/ChangedElementsDb.js +2 -2
- package/lib/cjs/ChangedElementsDb.js.map +1 -1
- package/lib/cjs/CheckpointManager.d.ts +2 -4
- package/lib/cjs/CheckpointManager.d.ts.map +1 -1
- package/lib/cjs/CheckpointManager.js +8 -19
- package/lib/cjs/CheckpointManager.js.map +1 -1
- package/lib/cjs/ClassRegistry.d.ts.map +1 -1
- package/lib/cjs/ClassRegistry.js +3 -1
- package/lib/cjs/ClassRegistry.js.map +1 -1
- package/lib/cjs/CloudSqlite.d.ts +350 -0
- package/lib/cjs/CloudSqlite.d.ts.map +1 -0
- package/lib/cjs/CloudSqlite.js +152 -0
- package/lib/cjs/CloudSqlite.js.map +1 -0
- package/lib/cjs/CloudStorageBackend.d.ts +16 -4
- package/lib/cjs/CloudStorageBackend.d.ts.map +1 -1
- package/lib/cjs/CloudStorageBackend.js +12 -3
- package/lib/cjs/CloudStorageBackend.js.map +1 -1
- package/lib/cjs/CodeService.d.ts +397 -0
- package/lib/cjs/CodeService.d.ts.map +1 -0
- package/lib/cjs/CodeService.js +64 -0
- package/lib/cjs/CodeService.js.map +1 -0
- package/lib/cjs/CodeSpecs.js.map +1 -1
- package/lib/cjs/CustomViewState3dCreator.d.ts.map +1 -1
- package/lib/cjs/CustomViewState3dCreator.js +15 -0
- package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
- package/lib/cjs/DevTools.d.ts.map +1 -1
- package/lib/cjs/DevTools.js.map +1 -1
- package/lib/cjs/Element.d.ts.map +1 -1
- package/lib/cjs/Element.js +20 -17
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/ElementTreeWalker.d.ts.map +1 -1
- package/lib/cjs/ElementTreeWalker.js.map +1 -1
- package/lib/cjs/ExportGraphics.d.ts +9 -9
- package/lib/cjs/ExportGraphics.d.ts.map +1 -1
- package/lib/cjs/ExportGraphics.js.map +1 -1
- package/lib/cjs/ExternalSource.d.ts.map +1 -1
- package/lib/cjs/ExternalSource.js.map +1 -1
- package/lib/cjs/GeoCoordConfig.d.ts +7 -1
- package/lib/cjs/GeoCoordConfig.d.ts.map +1 -1
- package/lib/cjs/GeoCoordConfig.js +16 -7
- package/lib/cjs/GeoCoordConfig.js.map +1 -1
- package/lib/cjs/GeometrySummary.js +1 -1
- package/lib/cjs/GeometrySummary.js.map +1 -1
- package/lib/cjs/HubMock.d.ts.map +1 -1
- package/lib/cjs/HubMock.js +7 -7
- package/lib/cjs/HubMock.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +18 -5
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +63 -25
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/IModelHost.d.ts +20 -6
- package/lib/cjs/IModelHost.d.ts.map +1 -1
- package/lib/cjs/IModelHost.js +56 -22
- package/lib/cjs/IModelHost.js.map +1 -1
- package/lib/cjs/IModelJsFs.d.ts +1 -1
- package/lib/cjs/IModelJsFs.d.ts.map +1 -1
- package/lib/cjs/IModelJsFs.js +2 -2
- package/lib/cjs/IModelJsFs.js.map +1 -1
- package/lib/cjs/LocalHub.js +1 -1
- package/lib/cjs/LocalHub.js.map +1 -1
- package/lib/cjs/Material.d.ts +3 -1
- package/lib/cjs/Material.d.ts.map +1 -1
- package/lib/cjs/Material.js +3 -1
- package/lib/cjs/Material.js.map +1 -1
- package/lib/cjs/Model.d.ts.map +1 -1
- package/lib/cjs/Model.js +5 -2
- package/lib/cjs/Model.js.map +1 -1
- package/lib/cjs/PromiseMemoizer.d.ts.map +1 -1
- package/lib/cjs/PromiseMemoizer.js +10 -4
- package/lib/cjs/PromiseMemoizer.js.map +1 -1
- package/lib/cjs/PropertyStore.d.ts +133 -0
- package/lib/cjs/PropertyStore.d.ts.map +1 -0
- package/lib/cjs/PropertyStore.js +12 -0
- package/lib/cjs/PropertyStore.js.map +1 -0
- package/lib/cjs/SQLiteDb.d.ts +110 -64
- package/lib/cjs/SQLiteDb.d.ts.map +1 -1
- package/lib/cjs/SQLiteDb.js +61 -58
- package/lib/cjs/SQLiteDb.js.map +1 -1
- package/lib/cjs/SqliteStatement.d.ts +14 -2
- package/lib/cjs/SqliteStatement.d.ts.map +1 -1
- package/lib/cjs/SqliteStatement.js +50 -28
- package/lib/cjs/SqliteStatement.js.map +1 -1
- package/lib/cjs/TileStorage.d.ts +19 -0
- package/lib/cjs/TileStorage.d.ts.map +1 -0
- package/lib/cjs/TileStorage.js +91 -0
- package/lib/cjs/TileStorage.js.map +1 -0
- package/lib/cjs/TxnManager.d.ts.map +1 -1
- package/lib/cjs/TxnManager.js +5 -2
- package/lib/cjs/TxnManager.js.map +1 -1
- package/lib/cjs/ViewDefinition.d.ts.map +1 -1
- package/lib/cjs/ViewDefinition.js +8 -2
- package/lib/cjs/ViewDefinition.js.map +1 -1
- package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +10 -0
- package/lib/cjs/assets/Settings/backend.setting.json5 +1 -1
- package/lib/cjs/core-backend.d.ts +9 -2
- package/lib/cjs/core-backend.d.ts.map +1 -1
- package/lib/cjs/core-backend.js +10 -3
- package/lib/cjs/core-backend.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts +2 -0
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +11 -2
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +3 -0
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
- package/lib/cjs/workspace/Settings.d.ts.map +1 -1
- package/lib/cjs/workspace/Settings.js +4 -1
- package/lib/cjs/workspace/Settings.js.map +1 -1
- package/lib/cjs/workspace/Workspace.d.ts +31 -18
- package/lib/cjs/workspace/Workspace.d.ts.map +1 -1
- package/lib/cjs/workspace/Workspace.js +34 -25
- package/lib/cjs/workspace/Workspace.js.map +1 -1
- package/package.json +18 -19
- package/lib/cjs/IModelSchemaLoader.d.ts +0 -26
- package/lib/cjs/IModelSchemaLoader.d.ts.map +0 -1
- package/lib/cjs/IModelSchemaLoader.js +0 -122
- package/lib/cjs/IModelSchemaLoader.js.map +0 -1
|
@@ -18,9 +18,13 @@ class QueryablePromise {
|
|
|
18
18
|
this.promise = promise;
|
|
19
19
|
this._fulfilled = false;
|
|
20
20
|
this._rejected = false;
|
|
21
|
-
this.promise
|
|
22
|
-
|
|
23
|
-
|
|
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
|
+
});
|
|
24
28
|
}
|
|
25
29
|
get isPending() { return !this.isFulfilled && !this.isRejected; }
|
|
26
30
|
get isFulfilled() { return this._fulfilled; }
|
|
@@ -63,7 +67,9 @@ class PromiseMemoizer {
|
|
|
63
67
|
this._timers.set(key, setTimeout(cleanUp, this._cacheTimeout));
|
|
64
68
|
return v;
|
|
65
69
|
};
|
|
66
|
-
const p = this._memoizeFn(...args).then(removeCachedPromise, (e) => {
|
|
70
|
+
const p = this._memoizeFn(...args).then(removeCachedPromise, (e) => {
|
|
71
|
+
throw removeCachedPromise(e);
|
|
72
|
+
});
|
|
67
73
|
qp = new QueryablePromise(p);
|
|
68
74
|
this._cachedPromises.set(key, qp);
|
|
69
75
|
return qp;
|
|
@@ -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;IAU3B,YAAmC,OAAmB;QAAnB,YAAO,GAAP,OAAO,CAAY;QAN9C,eAAU,GAAY,KAAK,CAAC;QAC5B,cAAS,GAAY,KAAK,CAAC;QAMjC,IAAI,CAAC,OAAO
|
|
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;IAU3B,YAAmC,OAAmB;QAAnB,YAAO,GAAP,OAAO,CAAY;QAN9C,eAAU,GAAY,KAAK,CAAC;QAC5B,cAAS,GAAY,KAAK,CAAC;QAMjC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAM,EAAE,EAAE;YAC3B,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC;YAClB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACzB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAQ,EAAE,EAAE;YACpB,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC;YACjB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACxB,CAAC,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CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;QACpC,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAClC,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;IACpC,CAAC;CAqDF;AA3ED,0CA2EC","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 this._timers.clear();\r\n this.clearCache();\r\n };\r\n}\r\n"]}
|
|
@@ -0,0 +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
|
+
}
|
|
133
|
+
//#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AO,CAAC;QAC/D;;UAEE;QACF,SAAS,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,GAAG,SAAS,CAAC;QAClD;;UAEE;QACF,SAAS,CAAC,IAAI,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC;QAC5D;;UAEE;QACF,OAAO,CAAC,IAAI,EAAE,YAAY,GAAG,UAAU,GAAG,SAAS,CAAC;QACpD;;UAEE;QACF,OAAO,CAAC,IAAI,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,GAAG,UAAU,CAAC;QAClE;;UAEE;QACF,SAAS,CAAC,CAAC,SAAS,aAAa,EAAE,IAAI,EAAE,YAAY,GAAG,CAAC,GAAG,SAAS,CAAC;QACtE;;UAEE;QACF,SAAS,CAAC,CAAC,SAAS,aAAa,EAAE,IAAI,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC,GAAG,CAAC,CAAC;QAC3E,iFAAiF;QACjF,gBAAgB,CAAC,IAAI,EAAE,iBAAiB,EAAE,MAAM,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;KAC1E;CACF"}
|
|
@@ -0,0 +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 = {}));
|
|
12
|
+
//# sourceMappingURL=PropertyStore.js.map
|
|
@@ -0,0 +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"]}
|
package/lib/cjs/SQLiteDb.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module SQLiteDb
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { IModelJsNative } from "@bentley/imodeljs-native";
|
|
5
5
|
import { DbResult, IDisposable, OpenMode } from "@itwin/core-bentley";
|
|
6
6
|
import { LocalFileName } from "@itwin/core-common";
|
|
7
|
+
import { CloudSqlite } from "./CloudSqlite";
|
|
7
8
|
import { SqliteStatement } from "./SqliteStatement";
|
|
8
9
|
/** A SQLiteDb file
|
|
9
10
|
* @public
|
|
@@ -13,78 +14,63 @@ export declare class SQLiteDb implements IDisposable {
|
|
|
13
14
|
readonly nativeDb: IModelJsNative.SQLiteDb;
|
|
14
15
|
private _sqliteStatementCache;
|
|
15
16
|
/** @internal */
|
|
16
|
-
static createCloudContainer(args: CloudSqlite.ContainerAccessProps): SQLiteDb.CloudContainer;
|
|
17
|
-
/** @internal */
|
|
18
|
-
static createCloudCache(args: CloudSqlite.CacheProps): SQLiteDb.CloudCache;
|
|
19
|
-
/** @internal */
|
|
20
|
-
static startCloudPrefetch(container: SQLiteDb.CloudContainer, dbName: string, args?: CloudSqlite.PrefetchProps): SQLiteDb.CloudPrefetch;
|
|
21
|
-
/** @internal */
|
|
22
17
|
static createBlobIO(): SQLiteDb.BlobIO;
|
|
23
18
|
/** alias for closeDb. */
|
|
24
19
|
dispose(): void;
|
|
25
20
|
/** Create a SQLiteDb
|
|
26
21
|
* @param dbName The path to the SQLiteDb file to create.
|
|
27
22
|
*/
|
|
28
|
-
createDb(dbName: string
|
|
23
|
+
createDb(dbName: string): void;
|
|
24
|
+
/** @beta */
|
|
25
|
+
createDb(dbName: string, container?: CloudSqlite.CloudContainer, params?: SQLiteDb.CreateParams): void;
|
|
29
26
|
/** Open a SQLiteDb.
|
|
30
27
|
* @param dbName The path to the SQLiteDb file to open
|
|
31
28
|
*/
|
|
32
29
|
openDb(dbName: string, openMode: OpenMode | SQLiteDb.OpenParams): void;
|
|
33
30
|
/**
|
|
34
31
|
* @param container optional CloudContainer holding database
|
|
35
|
-
* @
|
|
32
|
+
* @beta
|
|
36
33
|
*/
|
|
37
|
-
openDb(dbName: string, openMode: OpenMode | SQLiteDb.OpenParams, container?:
|
|
34
|
+
openDb(dbName: string, openMode: OpenMode | SQLiteDb.OpenParams, container?: CloudSqlite.CloudContainer): void;
|
|
38
35
|
/** Close SQLiteDb.
|
|
39
|
-
* @param saveChanges if true, call `saveChanges` before closing db.
|
|
36
|
+
* @param saveChanges if true, call `saveChanges` before closing db. Otherwise unsaved changes are abandoned.
|
|
40
37
|
*/
|
|
41
38
|
closeDb(saveChanges?: boolean): void;
|
|
42
|
-
/** Returns true if
|
|
39
|
+
/** Returns true if this SQLiteDb is open */
|
|
43
40
|
get isOpen(): boolean;
|
|
41
|
+
/** Returns true if this SQLiteDb is open readonly */
|
|
42
|
+
get isReadonly(): boolean;
|
|
44
43
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
44
|
+
* Open a database, perform an operation, then close the database.
|
|
45
|
+
*
|
|
46
|
+
* Details:
|
|
47
|
+
* - if database is open, throw an error
|
|
48
|
+
* - open a database
|
|
49
|
+
* - call a function with the database opened. If it is async, await its return.
|
|
50
|
+
* - if function throws, abandon all changes, close database, and rethrow
|
|
51
|
+
* - save all changes
|
|
52
|
+
* - close the database
|
|
53
|
+
* @return value from operation
|
|
48
54
|
*/
|
|
49
|
-
|
|
50
|
-
/** The name of the database to open */
|
|
51
|
-
dbName: string;
|
|
52
|
-
/** either an object with the open parameters or just OpenMode value. */
|
|
53
|
-
openMode?: OpenMode | SQLiteDb.OpenParams;
|
|
54
|
-
/** @internal */
|
|
55
|
-
container?: SQLiteDb.CloudContainer;
|
|
56
|
-
}, operation: (db: SQLiteDb) => T): T;
|
|
55
|
+
withOpenDb<T>(args: SQLiteDb.WithOpenDbArgs, operation: () => T): T;
|
|
57
56
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
57
|
+
* Perform an operation on a database in a CloudContainer with the write lock held.
|
|
58
|
+
*
|
|
59
|
+
* Details:
|
|
60
|
+
* - acquire the write lock on a CloudContainer
|
|
61
|
+
* - call `withOpenDb` with openMode `ReadWrite`
|
|
62
|
+
* - upload changes
|
|
63
|
+
* - release the write lock
|
|
64
|
+
* @param args arguments to lock the container and open the database
|
|
65
|
+
* @param operation an operation performed on the database with the write lock held.
|
|
66
|
+
* @return value from operation
|
|
63
67
|
* @internal
|
|
64
68
|
*/
|
|
65
|
-
|
|
66
|
-
/** the name to be displayed in the event of lock collisions */
|
|
67
|
-
user: string;
|
|
68
|
-
/** the name of the database within the container */
|
|
69
|
-
dbName: string;
|
|
70
|
-
/** the CloudContainer on which the operation will be performed */
|
|
71
|
-
container: SQLiteDb.CloudContainer;
|
|
72
|
-
/** if present, function called when the write lock is currently held by another user. */
|
|
73
|
-
busyHandler?: CloudSqlite.WriteLockBusyHandler;
|
|
74
|
-
},
|
|
75
|
-
/** an asynchronous operation performed on the database with the write lock held. */
|
|
76
|
-
operation: (db: SQLiteDb) => Promise<void>): Promise<void>;
|
|
69
|
+
withLockedContainer<T>(args: CloudSqlite.LockAndOpenArgs, operation: () => T): Promise<T>;
|
|
77
70
|
/** vacuum this database
|
|
78
71
|
* @see https://www.sqlite.org/lang_vacuum.html
|
|
79
72
|
*/
|
|
80
|
-
vacuum(args?:
|
|
81
|
-
/** new page size
|
|
82
|
-
* @see https://www.sqlite.org/pragma.html#pragma_page_size
|
|
83
|
-
*/
|
|
84
|
-
pageSize?: number;
|
|
85
|
-
/** if present, name of new file to vacuum into */
|
|
86
|
-
into?: LocalFileName;
|
|
87
|
-
}): void;
|
|
73
|
+
vacuum(args?: SQLiteDb.VacuumDbArgs): void;
|
|
88
74
|
/** Commit the outermost transaction, writing changes to the file. Then, restart the transaction. */
|
|
89
75
|
saveChanges(): void;
|
|
90
76
|
/** Abandon (cancel) the outermost transaction, discarding all changes since last save. Then, restart the transaction. */
|
|
@@ -109,6 +95,12 @@ export declare class SQLiteDb implements IDisposable {
|
|
|
109
95
|
* @returns the value returned by `callback`.
|
|
110
96
|
*/
|
|
111
97
|
withSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T): T;
|
|
98
|
+
/**
|
|
99
|
+
* Perform an operation on this database within a [savepoint](https://www.sqlite.org/lang_savepoint.html). If the operation completes successfully, the
|
|
100
|
+
* changes remain in the current transaction. If the operation throws an exception, the savepoint is rolled back
|
|
101
|
+
* and all changes to the database from this method are reversed, leaving the transaction exactly as it was before this method.
|
|
102
|
+
*/
|
|
103
|
+
withSavePoint(savePointName: string, operation: () => void): void;
|
|
112
104
|
/** Prepare an SQL statement.
|
|
113
105
|
* @param sql The SQLite SQL statement to prepare
|
|
114
106
|
* @param logErrors Determine if errors are logged or not
|
|
@@ -120,21 +112,59 @@ export declare class SQLiteDb implements IDisposable {
|
|
|
120
112
|
}
|
|
121
113
|
/** @public */
|
|
122
114
|
export declare namespace SQLiteDb {
|
|
123
|
-
/**
|
|
124
|
-
* @internal
|
|
125
|
-
*/
|
|
126
|
-
type CloudContainer = IModelJsNative.CloudContainer;
|
|
127
|
-
/** @internal */
|
|
128
|
-
type CloudCache = IModelJsNative.CloudCache;
|
|
129
|
-
/** @internal */
|
|
130
|
-
type CloudPrefetch = IModelJsNative.CloudPrefetch;
|
|
131
|
-
/** Incremental IO for blobs
|
|
115
|
+
/** interface for reading and writing to a blob in a SQLiteDb
|
|
132
116
|
* @internal
|
|
133
117
|
*/
|
|
134
|
-
|
|
118
|
+
interface BlobIO {
|
|
119
|
+
/** Close this BlobIO if it is opened.
|
|
120
|
+
* @note this BlobIO *may* be reused after this call by calling `open` again.
|
|
121
|
+
*/
|
|
122
|
+
close(): void;
|
|
123
|
+
/** get the total number of bytes in the blob */
|
|
124
|
+
getNumBytes(): number;
|
|
125
|
+
/** @return true if this BlobIO was successfully opened and may be use to read or write the blob */
|
|
126
|
+
isValid(): boolean;
|
|
127
|
+
/** Open this BlobIO against a table/row/column in a Db */
|
|
128
|
+
open(
|
|
129
|
+
/** The database for the blob */
|
|
130
|
+
db: IModelJsNative.AnyDb, args: {
|
|
131
|
+
/** the name of the table for the blob*/
|
|
132
|
+
tableName: string;
|
|
133
|
+
/** the name of the column for the blob */
|
|
134
|
+
columnName: string;
|
|
135
|
+
/** The rowId of the blob */
|
|
136
|
+
row: number;
|
|
137
|
+
/** If true, open this BlobIO for write access */
|
|
138
|
+
writeable?: boolean;
|
|
139
|
+
}): void;
|
|
140
|
+
/** Read from a blob
|
|
141
|
+
* @returns the contents of the requested byte range
|
|
142
|
+
*/
|
|
143
|
+
read(args: {
|
|
144
|
+
/** The number of bytes to read */
|
|
145
|
+
numBytes: number;
|
|
146
|
+
/** starting offset within the blob to read */
|
|
147
|
+
offset: number;
|
|
148
|
+
/** If present and of sufficient size, use this ArrayBuffer for the value. */
|
|
149
|
+
blob?: ArrayBuffer;
|
|
150
|
+
}): Uint8Array;
|
|
151
|
+
/** Reposition this BlobIO to a new rowId
|
|
152
|
+
* @note this BlobIO must be valid when this methods is called.
|
|
153
|
+
*/
|
|
154
|
+
changeRow(row: number): void;
|
|
155
|
+
/** Write to a blob */
|
|
156
|
+
write(args: {
|
|
157
|
+
/** The number of bytes to write */
|
|
158
|
+
numBytes: number;
|
|
159
|
+
/** starting offset within the blob to write */
|
|
160
|
+
offset: number;
|
|
161
|
+
/** the value to write */
|
|
162
|
+
blob: ArrayBuffer;
|
|
163
|
+
}): void;
|
|
164
|
+
}
|
|
135
165
|
/** Default transaction mode for SQLiteDbs.
|
|
136
|
-
|
|
137
|
-
|
|
166
|
+
* @see https://www.sqlite.org/lang_transaction.html
|
|
167
|
+
*/
|
|
138
168
|
enum DefaultTxnMode {
|
|
139
169
|
/** no default transaction is started. You must use BEGIN/COMMIT or SQLite will use implicit transactions */
|
|
140
170
|
None = 0,
|
|
@@ -154,8 +184,8 @@ export declare namespace SQLiteDb {
|
|
|
154
184
|
/** Do not attempt to verify that the file is a valid sQLite file before opening. */
|
|
155
185
|
skipFileCheck?: boolean;
|
|
156
186
|
/** the default transaction mode
|
|
157
|
-
|
|
158
|
-
|
|
187
|
+
* @see [[SQLiteDb.DefaultTxnMode]]
|
|
188
|
+
*/
|
|
159
189
|
defaultTxn?: 0 | 1 | 2 | 3;
|
|
160
190
|
/** see query parameters from 'URI Filenames' in https://www.sqlite.org/c3ref/open.html */
|
|
161
191
|
queryParam?: string;
|
|
@@ -165,10 +195,26 @@ export declare namespace SQLiteDb {
|
|
|
165
195
|
/** use OpenMode.ReadWrite to open the file with write access */
|
|
166
196
|
openMode: OpenMode;
|
|
167
197
|
}
|
|
168
|
-
/**
|
|
169
|
-
interface
|
|
198
|
+
/** Size of a SQLiteDb page in bytes */
|
|
199
|
+
interface PageSize {
|
|
170
200
|
/** see https://www.sqlite.org/pragma.html#pragma_page_size */
|
|
171
201
|
pageSize?: number;
|
|
172
202
|
}
|
|
203
|
+
/** Parameters for creating a new SQLiteDb */
|
|
204
|
+
type CreateParams = OpenOrCreateParams & PageSize;
|
|
205
|
+
/** Arguments for `SqliteDb.withOpenDb` */
|
|
206
|
+
interface WithOpenDbArgs {
|
|
207
|
+
/** The name of the database to open */
|
|
208
|
+
dbName: string;
|
|
209
|
+
/** either an object with the open parameters or just OpenMode value. */
|
|
210
|
+
openMode?: OpenMode | SQLiteDb.OpenParams;
|
|
211
|
+
/** @internal */
|
|
212
|
+
container?: CloudSqlite.CloudContainer;
|
|
213
|
+
}
|
|
214
|
+
/** Arguments for `SQLiteDb.vacuum` */
|
|
215
|
+
interface VacuumDbArgs extends PageSize {
|
|
216
|
+
/** if present, name of new file to [vacuum into](https://www.sqlite.org/lang_vacuum.html) */
|
|
217
|
+
into?: LocalFileName;
|
|
218
|
+
}
|
|
173
219
|
}
|
|
174
220
|
//# sourceMappingURL=SQLiteDb.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SQLiteDb.d.ts","sourceRoot":"","sources":["../../src/SQLiteDb.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"SQLiteDb.d.ts","sourceRoot":"","sources":["../../src/SQLiteDb.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAkB,MAAM,mBAAmB,CAAC;AAKpE;;GAEG;AACH,qBAAa,QAAS,YAAW,WAAW;IAC1C,gBAAgB;IAChB,SAAgB,QAAQ,0BAAsC;IAC9D,OAAO,CAAC,qBAAqB,CAAyC;IAEtE,gBAAgB;WACF,YAAY,IAAI,QAAQ,CAAC,MAAM;IAI7C,yBAAyB;IAClB,OAAO,IAAI,IAAI;IAItB;;OAEG;IACI,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IACrC,YAAY;IACL,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,WAAW,CAAC,cAAc,EAAE,MAAM,CAAC,EAAE,QAAQ,CAAC,YAAY,GAAG,IAAI;IAM7G;;OAEG;IACI,MAAM,CAAC,MAAM,EAAE,MA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