@itwin/core-backend 4.2.0-dev.13 → 4.2.0-dev.16
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 +13 -1
- package/lib/cjs/BlobContainerService.d.ts +6 -2
- package/lib/cjs/BlobContainerService.d.ts.map +1 -1
- package/lib/cjs/BlobContainerService.js.map +1 -1
- package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
- package/lib/cjs/BriefcaseManager.js +5 -1
- package/lib/cjs/BriefcaseManager.js.map +1 -1
- package/lib/cjs/CheckpointManager.d.ts.map +1 -1
- package/lib/cjs/CheckpointManager.js +4 -1
- package/lib/cjs/CheckpointManager.js.map +1 -1
- package/lib/cjs/CloudSqlite.d.ts +72 -33
- package/lib/cjs/CloudSqlite.d.ts.map +1 -1
- package/lib/cjs/CloudSqlite.js +6 -8
- package/lib/cjs/CloudSqlite.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +3 -1
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +3 -1
- package/lib/cjs/IModelDb.js.map +1 -1
- package/package.json +12 -12
package/lib/cjs/CloudSqlite.d.ts
CHANGED
|
@@ -14,19 +14,19 @@ export declare namespace CloudSqlite {
|
|
|
14
14
|
* Request a new AccessToken for a cloud container using the [[BlobContainer]] service.
|
|
15
15
|
* If the service is unavailable or returns an error, an empty token is returned.
|
|
16
16
|
*/
|
|
17
|
-
function requestToken(args: Optional<BlobContainer.RequestTokenProps, "userToken">): Promise<AccessToken>;
|
|
17
|
+
export function requestToken(args: Optional<BlobContainer.RequestTokenProps, "userToken">): Promise<AccessToken>;
|
|
18
18
|
/**
|
|
19
19
|
* Create a new CloudContainer from a ContainerAccessProps. For non-public containers, a valid accessToken must be provided before the container
|
|
20
20
|
* can be used (e.g. via [[CloudSqlite.requestToken]]).
|
|
21
21
|
* @note After the container is successfully connected to a CloudCache, it will begin auto-refreshing its accessToken every `tokenRefreshSeconds` seconds (default is 1 hour)
|
|
22
22
|
* until it is disconnected. However, if the container is public, or if `tokenRefreshSeconds` is <=0, auto-refresh is not enabled.
|
|
23
23
|
*/
|
|
24
|
-
function createCloudContainer(args: ContainerAccessProps & {
|
|
24
|
+
export function createCloudContainer(args: ContainerAccessProps & {
|
|
25
25
|
accessLevel?: BlobContainer.RequestAccessLevel;
|
|
26
26
|
}): CloudContainer;
|
|
27
27
|
/** Begin prefetching all blocks for a database in a CloudContainer in the background. */
|
|
28
|
-
function startCloudPrefetch(container: CloudContainer, dbName: string, args?: PrefetchProps): CloudPrefetch;
|
|
29
|
-
interface ContainerProps {
|
|
28
|
+
export function startCloudPrefetch(container: CloudContainer, dbName: string, args?: PrefetchProps): CloudPrefetch;
|
|
29
|
+
export interface ContainerProps {
|
|
30
30
|
/** The type of storage provider. */
|
|
31
31
|
storageType: "azure" | "google";
|
|
32
32
|
/** The base URI for the container. */
|
|
@@ -37,7 +37,7 @@ export declare namespace CloudSqlite {
|
|
|
37
37
|
isPublic?: boolean;
|
|
38
38
|
}
|
|
39
39
|
/** Properties to access a CloudContainer. */
|
|
40
|
-
interface ContainerAccessProps extends ContainerProps {
|
|
40
|
+
export interface ContainerAccessProps extends ContainerProps {
|
|
41
41
|
/** an alias for the container. Defaults to `containerId` */
|
|
42
42
|
alias?: string;
|
|
43
43
|
/** SAS token that grants access to the container. */
|
|
@@ -54,7 +54,7 @@ export declare namespace CloudSqlite {
|
|
|
54
54
|
tokenRefreshSeconds?: number;
|
|
55
55
|
}
|
|
56
56
|
/** Returned from `CloudContainer.queryDatabase` describing one database in the container */
|
|
57
|
-
interface CachedDbProps {
|
|
57
|
+
export interface CachedDbProps {
|
|
58
58
|
/** The total number of blocks in the database. */
|
|
59
59
|
readonly totalBlocks: number;
|
|
60
60
|
/** the number of blocks of the database that have been downloaded into the CloudCache */
|
|
@@ -73,7 +73,7 @@ export declare namespace CloudSqlite {
|
|
|
73
73
|
/** Filter options passed to CloudContainer.queryHttpLog
|
|
74
74
|
* @internal
|
|
75
75
|
*/
|
|
76
|
-
interface BcvHttpLogFilterOptions {
|
|
76
|
+
export interface BcvHttpLogFilterOptions {
|
|
77
77
|
/** only return rows whose ID is >= the provided id */
|
|
78
78
|
startFromId?: number;
|
|
79
79
|
/** only return rows whose endTime is null OR >= the provided endTime. */
|
|
@@ -84,7 +84,7 @@ export declare namespace CloudSqlite {
|
|
|
84
84
|
/** Returned from 'CloudContainer.queryHttpLog' describing a row in the bcv_http_log table.
|
|
85
85
|
* @internal
|
|
86
86
|
*/
|
|
87
|
-
interface BcvHttpLog {
|
|
87
|
+
export interface BcvHttpLog {
|
|
88
88
|
/** Unique, monotonically increasing id value */
|
|
89
89
|
readonly id: number;
|
|
90
90
|
/** Time request was made, as iso-8601 */
|
|
@@ -102,35 +102,64 @@ export declare namespace CloudSqlite {
|
|
|
102
102
|
/** HTTP response code (e.g. 200) */
|
|
103
103
|
readonly httpcode: number;
|
|
104
104
|
}
|
|
105
|
+
/** Filter options passed to 'CloudContainer.queryBcvStats'
|
|
106
|
+
* @internal
|
|
107
|
+
*/
|
|
108
|
+
interface BcvStatsFilterOptions {
|
|
109
|
+
/** if true, adds activeClients, totalClients, ongoingPrefetches, and attachedContainers to the result. */
|
|
110
|
+
addClientInformation?: boolean;
|
|
111
|
+
}
|
|
112
|
+
/** Returned from 'CloudContainer.queryBcvStats' describing the rows in the bcv_stat table.
|
|
113
|
+
* Also gathers additional statistics using the other virtual tables bcv_container, bcv_database such as totalClients, ongoingPrefetches, activeClients and attachedContainers.
|
|
114
|
+
* @internal
|
|
115
|
+
*/
|
|
116
|
+
export interface BcvStats {
|
|
117
|
+
/** The total number of cache slots that are currently in use or 'locked' by ongoing client read transactions. In daemonless mode, this value is always 0.
|
|
118
|
+
* A locked cache slot implies that it is not eligible for eviction in the event of a full cachefile.
|
|
119
|
+
*/
|
|
120
|
+
readonly lockedCacheslots: number;
|
|
121
|
+
/** The current number of slots with data in them in the cache. */
|
|
122
|
+
readonly populatedCacheslots: number;
|
|
123
|
+
/** The configured size of the cache, in number of slots. */
|
|
124
|
+
readonly totalCacheslots: number;
|
|
125
|
+
/** The total number of clients opened on this cache */
|
|
126
|
+
readonly totalClients?: number;
|
|
127
|
+
/** The total number of ongoing prefetches on this cache */
|
|
128
|
+
readonly ongoingPrefetches?: number;
|
|
129
|
+
/** The total number of active clients on this cache. An active client is one which has an open read txn. */
|
|
130
|
+
readonly activeClients?: number;
|
|
131
|
+
/** The total number of attached containers on this cache. */
|
|
132
|
+
readonly attachedContainers?: number;
|
|
133
|
+
}
|
|
105
134
|
/** The name of a CloudSqlite database within a CloudContainer. */
|
|
106
|
-
interface DbNameProp {
|
|
135
|
+
export interface DbNameProp {
|
|
107
136
|
/** the name of the database within the CloudContainer.
|
|
108
137
|
* @note names of databases within a CloudContainer are always **case sensitive** on all platforms.*/
|
|
109
138
|
dbName: string;
|
|
110
139
|
}
|
|
111
140
|
/** Properties for accessing a database within a CloudContainer */
|
|
112
|
-
interface DbProps extends DbNameProp {
|
|
141
|
+
export interface DbProps extends DbNameProp {
|
|
113
142
|
/** the name of the local file to access the database. */
|
|
114
143
|
localFileName: LocalFileName;
|
|
115
144
|
}
|
|
116
|
-
type TransferDirection = "upload" | "download";
|
|
117
|
-
interface TransferProgress {
|
|
145
|
+
export type TransferDirection = "upload" | "download";
|
|
146
|
+
export interface TransferProgress {
|
|
118
147
|
/** a user-supplied progress function called during the transfer operation. Return a non-0 value to abort the transfer. */
|
|
119
148
|
onProgress?: (loaded: number, total: number) => number;
|
|
120
149
|
}
|
|
121
|
-
interface CloudHttpProps {
|
|
150
|
+
export interface CloudHttpProps {
|
|
122
151
|
/** The number of simultaneous HTTP requests. Default is 6. */
|
|
123
152
|
nRequests?: number;
|
|
124
153
|
}
|
|
125
|
-
interface PrefetchProps extends CloudHttpProps {
|
|
154
|
+
export interface PrefetchProps extends CloudHttpProps {
|
|
126
155
|
/** timeout between requests, in milliseconds. Default is 100. */
|
|
127
156
|
timeout?: number;
|
|
128
157
|
/** The number of prefetch requests to issue while there is foreground activity. Default is 3. */
|
|
129
158
|
minRequests?: number;
|
|
130
159
|
}
|
|
131
|
-
type TransferDbProps = DbProps & TransferProgress & CloudHttpProps;
|
|
160
|
+
export type TransferDbProps = DbProps & TransferProgress & CloudHttpProps;
|
|
132
161
|
/** Properties for creating a CloudCache. */
|
|
133
|
-
interface CacheProps extends CloudHttpProps {
|
|
162
|
+
export interface CacheProps extends CloudHttpProps {
|
|
134
163
|
/** full path of directory for cache to store its files. Must be on a (preferably fast) local drive, and must be empty when the cache is first created. */
|
|
135
164
|
rootDir: string;
|
|
136
165
|
/** name of this cache. It is possible to have more than one CloudCache in the same session, but each must have a unique name. */
|
|
@@ -141,7 +170,7 @@ export declare namespace CloudSqlite {
|
|
|
141
170
|
curlDiagnostics?: boolean;
|
|
142
171
|
}
|
|
143
172
|
/** Parameters used to obtain the write lock on a cloud container */
|
|
144
|
-
interface ObtainLockParams {
|
|
173
|
+
export interface ObtainLockParams {
|
|
145
174
|
/** a string that identifies me to others if I hold the lock while they attempt to acquire it. */
|
|
146
175
|
user?: string;
|
|
147
176
|
/** number of times to retry in the event the lock currently held by someone else.
|
|
@@ -157,7 +186,7 @@ export declare namespace CloudSqlite {
|
|
|
157
186
|
onFailure?: WriteLockBusyHandler;
|
|
158
187
|
}
|
|
159
188
|
/** @internal */
|
|
160
|
-
interface LockAndOpenArgs extends SQLiteDb.WithOpenDbArgs {
|
|
189
|
+
export interface LockAndOpenArgs extends SQLiteDb.WithOpenDbArgs {
|
|
161
190
|
/** a string that identifies me to others if I hold the lock while they attempt to acquire it. */
|
|
162
191
|
user: string;
|
|
163
192
|
/** the name of the database within the container */
|
|
@@ -170,7 +199,7 @@ export declare namespace CloudSqlite {
|
|
|
170
199
|
openMode?: OpenMode;
|
|
171
200
|
}
|
|
172
201
|
/** Logging categories for `CloudCache.setLogMask` */
|
|
173
|
-
enum LoggingMask {
|
|
202
|
+
export enum LoggingMask {
|
|
174
203
|
/** log all HTTP requests and responses */
|
|
175
204
|
HTTP = 1,
|
|
176
205
|
/** log as blocks become dirty and must be uploaded */
|
|
@@ -203,7 +232,7 @@ export declare namespace CloudSqlite {
|
|
|
203
232
|
* - The contents of the cache directory are entirely controlled by CloudSqlite and should be empty when the cache is
|
|
204
233
|
* first created and never modified directly thereafter.
|
|
205
234
|
*/
|
|
206
|
-
interface CloudCache {
|
|
235
|
+
export interface CloudCache {
|
|
207
236
|
/** `true` if this CloudCache is connected to a daemon process */
|
|
208
237
|
get isDaemon(): boolean;
|
|
209
238
|
/** The name for this CloudCache. */
|
|
@@ -241,7 +270,7 @@ export declare namespace CloudSqlite {
|
|
|
241
270
|
* - when a CloudContainer is created, it may either be readonly or writeable. If a container is never meant to be used for writes,
|
|
242
271
|
* it is slightly more efficient to indicate that by passing `writeable: false`
|
|
243
272
|
*/
|
|
244
|
-
interface CloudContainer {
|
|
273
|
+
export interface CloudContainer {
|
|
245
274
|
onConnect?: (container: CloudContainer, cache: CloudCache) => void;
|
|
246
275
|
onConnected?: (container: CloudContainer) => void;
|
|
247
276
|
onDisconnect?: (container: CloudContainer, detach: boolean) => void;
|
|
@@ -257,6 +286,10 @@ export declare namespace CloudSqlite {
|
|
|
257
286
|
get alias(): string;
|
|
258
287
|
/** The logId. */
|
|
259
288
|
get logId(): string;
|
|
289
|
+
/** The time that the write lock expires. Of the form 'YYYY-MM-DDTHH:MM:SS.000Z' in UTC.
|
|
290
|
+
* Returns empty string if write lock is not held.
|
|
291
|
+
*/
|
|
292
|
+
get writeLockExpires(): string;
|
|
260
293
|
/** true if this CloudContainer is currently connected to a CloudCache via the `connect` method. */
|
|
261
294
|
get isConnected(): boolean;
|
|
262
295
|
/** true if this CloudContainer was created with the `writeable` flag (and its `accessToken` supplies write access). */
|
|
@@ -386,6 +419,11 @@ export declare namespace CloudSqlite {
|
|
|
386
419
|
* @internal
|
|
387
420
|
*/
|
|
388
421
|
queryHttpLog(filterOptions?: BcvHttpLogFilterOptions): CloudSqlite.BcvHttpLog[];
|
|
422
|
+
/**
|
|
423
|
+
* query the bcv_stat table.
|
|
424
|
+
* @internal
|
|
425
|
+
*/
|
|
426
|
+
queryBcvStats(filterOptions?: BcvStatsFilterOptions): CloudSqlite.BcvStats;
|
|
389
427
|
/**
|
|
390
428
|
* Get the SHA1 hash of the content of a database.
|
|
391
429
|
* @param dbName the name of the database of interest
|
|
@@ -397,7 +435,7 @@ export declare namespace CloudSqlite {
|
|
|
397
435
|
* Object returned by [[CloudSqlite.startCloudPrefetch]].
|
|
398
436
|
* It holds a promise that is fulfilled when a Prefetch is completed. May also be used to cancel an in-progress prefetch.
|
|
399
437
|
*/
|
|
400
|
-
interface CloudPrefetch {
|
|
438
|
+
export interface CloudPrefetch {
|
|
401
439
|
readonly cloudContainer: CloudContainer;
|
|
402
440
|
readonly dbName: string;
|
|
403
441
|
/** Cancel a currently pending prefetch. The promise will be resolved immediately after this call. */
|
|
@@ -414,13 +452,13 @@ export declare namespace CloudSqlite {
|
|
|
414
452
|
promise: Promise<boolean>;
|
|
415
453
|
}
|
|
416
454
|
/** @internal */
|
|
417
|
-
function transferDb(direction: TransferDirection, container: CloudContainer, props: TransferDbProps): Promise<void>;
|
|
455
|
+
export function transferDb(direction: TransferDirection, container: CloudContainer, props: TransferDbProps): Promise<void>;
|
|
418
456
|
/** Upload a local SQLite database file into a CloudContainer.
|
|
419
457
|
* @param container the CloudContainer holding the database. Must be connected.
|
|
420
458
|
* @param props the properties that describe the database to be downloaded, plus optionally an `onProgress` function.
|
|
421
459
|
* @note this function requires that the write lock be held on the container
|
|
422
460
|
*/
|
|
423
|
-
function uploadDb(container: CloudContainer, props: TransferDbProps): Promise<void>;
|
|
461
|
+
export function uploadDb(container: CloudContainer, props: TransferDbProps): Promise<void>;
|
|
424
462
|
/** Download a database from a CloudContainer.
|
|
425
463
|
* @param container the CloudContainer holding the database. Must be connected.
|
|
426
464
|
* @param props the properties that describe the database to be downloaded, plus optionally an `onProgress` function.
|
|
@@ -428,30 +466,30 @@ export declare namespace CloudSqlite {
|
|
|
428
466
|
* @note the download is "restartable." If the transfer is aborted and then re-requested, it will continue from where
|
|
429
467
|
* it left off rather than re-downloading the entire file.
|
|
430
468
|
*/
|
|
431
|
-
function downloadDb(container: CloudContainer, props: TransferDbProps): Promise<void>;
|
|
469
|
+
export function downloadDb(container: CloudContainer, props: TransferDbProps): Promise<void>;
|
|
432
470
|
/** Optional method to be called when an attempt to acquire the write lock fails because another user currently holds it.
|
|
433
471
|
* @param lockedBy The identifier supplied by the application/user that currently holds the lock.
|
|
434
472
|
* @param expires a stringified Date (in local time) indicating when the lock will expire.
|
|
435
473
|
* @return "stop" to give up and stop retrying. Generally, it's a good idea to wait for some time before returning.
|
|
436
474
|
*/
|
|
437
|
-
type WriteLockBusyHandler = (lockedBy: string, expires: string) => Promise<void | "stop">;
|
|
475
|
+
export type WriteLockBusyHandler = (lockedBy: string, expires: string) => Promise<void | "stop">;
|
|
438
476
|
/**
|
|
439
477
|
* Attempt to acquire the write lock for a container, with retries.
|
|
440
478
|
* If write lock is held by another user, call busyHandler if supplied. If no busyHandler, or handler returns "stop", throw. Otherwise try again.
|
|
441
|
-
* @note if write lock is already held, this function
|
|
479
|
+
* @note if write lock is already held by the same user, this function will refresh the write lock's expiry time.
|
|
442
480
|
* @param user the name to be displayed to other users in the event they attempt to obtain the lock while it is held by us
|
|
443
481
|
* @param container the CloudContainer for which the lock is to be acquired
|
|
444
482
|
* @param busyHandler if present, function called when the write lock is currently held by another user.
|
|
445
483
|
* @throws if [[container]] is not connected to a CloudCache.
|
|
446
484
|
*/
|
|
447
|
-
function acquireWriteLock(args: {
|
|
485
|
+
export function acquireWriteLock(args: {
|
|
448
486
|
user: string;
|
|
449
487
|
container: CloudContainer;
|
|
450
488
|
busyHandler?: WriteLockBusyHandler;
|
|
451
489
|
}): Promise<void>;
|
|
452
490
|
/**
|
|
453
491
|
* Perform an asynchronous write operation on a CloudContainer with the write lock held.
|
|
454
|
-
* 1. if write lock is already held by the current user, call operation and return.
|
|
492
|
+
* 1. if write lock is already held by the current user, refresh write lock's expiry time, call operation and return.
|
|
455
493
|
* 2. attempt to acquire the write lock, with retries. Throw if unable to obtain write lock.
|
|
456
494
|
* 3. perform the operation
|
|
457
495
|
* 3.a if the operation throws, abandon all changes and re-throw
|
|
@@ -463,13 +501,13 @@ export declare namespace CloudSqlite {
|
|
|
463
501
|
* @param busyHandler if present, function called when the write lock is currently held by another user.
|
|
464
502
|
* @returns a Promise with the result of `operation`
|
|
465
503
|
*/
|
|
466
|
-
function withWriteLock<T>(args: {
|
|
504
|
+
export function withWriteLock<T>(args: {
|
|
467
505
|
user: string;
|
|
468
506
|
container: CloudContainer;
|
|
469
507
|
busyHandler?: WriteLockBusyHandler;
|
|
470
508
|
}, operation: () => Promise<T>): Promise<T>;
|
|
471
509
|
/** Arguments to create or find a CloudCache */
|
|
472
|
-
interface CreateCloudCacheArg {
|
|
510
|
+
export interface CreateCloudCacheArg {
|
|
473
511
|
/** The name of the CloudCache. CloudCache names must be unique. */
|
|
474
512
|
cacheName: string;
|
|
475
513
|
/** A string that specifies the maximum size of the CloudCache. It should be a number followed by "K",
|
|
@@ -481,7 +519,7 @@ export declare namespace CloudSqlite {
|
|
|
481
519
|
cacheDir?: string;
|
|
482
520
|
}
|
|
483
521
|
/** The collection of currently extant `CloudCache`s, by name. */
|
|
484
|
-
class CloudCaches {
|
|
522
|
+
export class CloudCaches {
|
|
485
523
|
private static readonly cloudCaches;
|
|
486
524
|
/** create a new CloudCache */
|
|
487
525
|
private static makeCache;
|
|
@@ -497,7 +535,7 @@ export declare namespace CloudSqlite {
|
|
|
497
535
|
static getCache(args: CreateCloudCacheArg): CloudCache;
|
|
498
536
|
}
|
|
499
537
|
/** Class that provides convenient local access to a SQLite database in a CloudContainer. */
|
|
500
|
-
class DbAccess<DbType extends VersionedSqliteDb, ReadMethods = DbType, WriteMethods = DbType> {
|
|
538
|
+
export class DbAccess<DbType extends VersionedSqliteDb, ReadMethods = DbType, WriteMethods = DbType> {
|
|
501
539
|
/** The name of the database within the cloud container. */
|
|
502
540
|
readonly dbName: string;
|
|
503
541
|
/** Parameters for obtaining the write lock for this container. */
|
|
@@ -603,5 +641,6 @@ export declare namespace CloudSqlite {
|
|
|
603
641
|
*/
|
|
604
642
|
get reader(): PickMethods<ReadMethods>;
|
|
605
643
|
}
|
|
644
|
+
export {};
|
|
606
645
|
}
|
|
607
646
|
//# sourceMappingURL=CloudSqlite.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CloudSqlite.d.ts","sourceRoot":"","sources":["../../src/CloudSqlite.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EACL,WAAW,EAA+B,WAAW,EAAE,UAAU,EAAU,QAAQ,EAAE,QAAQ,EAAE,gBAAgB,EAAE,WAAW,EAC7H,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAKvD,OAAO,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAI9D;;;GAGG;AACH,yBAAiB,WAAW,CAAC;IAK3B;;;OAGG;IACH,
|
|
1
|
+
{"version":3,"file":"CloudSqlite.d.ts","sourceRoot":"","sources":["../../src/CloudSqlite.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EACL,WAAW,EAA+B,WAAW,EAAE,UAAU,EAAU,QAAQ,EAAE,QAAQ,EAAE,gBAAgB,EAAE,WAAW,EAC7H,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAKvD,OAAO,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAI9D;;;GAGG;AACH,yBA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;;;WAGG;QACH,IAAW,MAAM,6BAOhB;KACF;;CACF"}
|
package/lib/cjs/CloudSqlite.js
CHANGED
|
@@ -48,7 +48,7 @@ var CloudSqlite;
|
|
|
48
48
|
container.lockExpireSeconds = args.lockExpireSeconds ?? 60 * 60; // default is 1 hour
|
|
49
49
|
// don't refresh tokens for public containers or if refreshSeconds<=0
|
|
50
50
|
if (!args.isPublic && refreshSeconds > 0) {
|
|
51
|
-
const tokenProps = { baseUri: args.baseUri, containerId: args.containerId,
|
|
51
|
+
const tokenProps = { baseUri: args.baseUri, containerId: args.containerId, accessLevel: args.accessLevel };
|
|
52
52
|
const doRefresh = async () => {
|
|
53
53
|
let newToken;
|
|
54
54
|
const url = `[${tokenProps.baseUri}/${tokenProps.containerId}]`;
|
|
@@ -156,7 +156,7 @@ var CloudSqlite;
|
|
|
156
156
|
/**
|
|
157
157
|
* Attempt to acquire the write lock for a container, with retries.
|
|
158
158
|
* If write lock is held by another user, call busyHandler if supplied. If no busyHandler, or handler returns "stop", throw. Otherwise try again.
|
|
159
|
-
* @note if write lock is already held, this function
|
|
159
|
+
* @note if write lock is already held by the same user, this function will refresh the write lock's expiry time.
|
|
160
160
|
* @param user the name to be displayed to other users in the event they attempt to obtain the lock while it is held by us
|
|
161
161
|
* @param container the CloudContainer for which the lock is to be acquired
|
|
162
162
|
* @param busyHandler if present, function called when the write lock is currently held by another user.
|
|
@@ -167,8 +167,9 @@ var CloudSqlite;
|
|
|
167
167
|
while (true) {
|
|
168
168
|
try {
|
|
169
169
|
if (container.hasWriteLock) {
|
|
170
|
-
if (container.writeLockHeldBy === args.user)
|
|
171
|
-
return; //
|
|
170
|
+
if (container.writeLockHeldBy === args.user) {
|
|
171
|
+
return container.acquireWriteLock(args.user); // refresh the write lock's expiry time.
|
|
172
|
+
}
|
|
172
173
|
const err = new Error(); // lock held by another user within this process
|
|
173
174
|
err.errorNumber = 5;
|
|
174
175
|
err.lockedBy = container.writeLockHeldBy;
|
|
@@ -187,7 +188,7 @@ var CloudSqlite;
|
|
|
187
188
|
CloudSqlite.acquireWriteLock = acquireWriteLock;
|
|
188
189
|
/**
|
|
189
190
|
* Perform an asynchronous write operation on a CloudContainer with the write lock held.
|
|
190
|
-
* 1. if write lock is already held by the current user, call operation and return.
|
|
191
|
+
* 1. if write lock is already held by the current user, refresh write lock's expiry time, call operation and return.
|
|
191
192
|
* 2. attempt to acquire the write lock, with retries. Throw if unable to obtain write lock.
|
|
192
193
|
* 3. perform the operation
|
|
193
194
|
* 3.a if the operation throws, abandon all changes and re-throw
|
|
@@ -206,18 +207,15 @@ var CloudSqlite;
|
|
|
206
207
|
if (containerInternal.writeLockHeldBy === args.user) // If the user already had the write lock, then don't release it.
|
|
207
208
|
return await operation();
|
|
208
209
|
containerInternal.writeLockHeldBy = args.user;
|
|
209
|
-
containerInternal.writeLockExpires = new Date(Date.now() + 1000 * containerInternal.lockExpireSeconds).toLocaleString();
|
|
210
210
|
// eslint-disable-next-line @typescript-eslint/await-thenable
|
|
211
211
|
const val = await operation(); // wait for work to finish or fail
|
|
212
212
|
containerInternal.releaseWriteLock();
|
|
213
213
|
containerInternal.writeLockHeldBy = undefined;
|
|
214
|
-
containerInternal.writeLockExpires = undefined;
|
|
215
214
|
return val;
|
|
216
215
|
}
|
|
217
216
|
catch (e) {
|
|
218
217
|
args.container.abandonChanges(); // if operation threw, abandon all changes
|
|
219
218
|
containerInternal.writeLockHeldBy = undefined;
|
|
220
|
-
containerInternal.writeLockExpires = undefined;
|
|
221
219
|
throw e;
|
|
222
220
|
}
|
|
223
221
|
}
|