@itwin/core-backend 4.0.0-dev.94 → 4.0.0-dev.96
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/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/Category.d.ts +1 -1
- package/lib/cjs/Category.js +1 -1
- package/lib/cjs/Category.js.map +1 -1
- package/lib/cjs/ClassRegistry.js +3 -3
- package/lib/cjs/ClassRegistry.js.map +1 -1
- package/lib/cjs/CloudSqlite.d.ts +116 -14
- package/lib/cjs/CloudSqlite.d.ts.map +1 -1
- package/lib/cjs/CloudSqlite.js +189 -4
- package/lib/cjs/CloudSqlite.js.map +1 -1
- package/lib/cjs/CodeService.d.ts +110 -148
- package/lib/cjs/CodeService.d.ts.map +1 -1
- package/lib/cjs/CodeService.js.map +1 -1
- package/lib/cjs/CodeSpecs.js +1 -1
- package/lib/cjs/CodeSpecs.js.map +1 -1
- package/lib/cjs/DisplayStyle.d.ts +2 -4
- package/lib/cjs/DisplayStyle.d.ts.map +1 -1
- package/lib/cjs/DisplayStyle.js +4 -6
- package/lib/cjs/DisplayStyle.js.map +1 -1
- package/lib/cjs/Element.d.ts +9 -17
- package/lib/cjs/Element.d.ts.map +1 -1
- package/lib/cjs/Element.js +16 -24
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/ElementAspect.d.ts +1 -2
- package/lib/cjs/ElementAspect.d.ts.map +1 -1
- package/lib/cjs/ElementAspect.js +2 -3
- package/lib/cjs/ElementAspect.js.map +1 -1
- package/lib/cjs/Entity.d.ts +12 -16
- package/lib/cjs/Entity.d.ts.map +1 -1
- package/lib/cjs/Entity.js +18 -35
- package/lib/cjs/Entity.js.map +1 -1
- package/lib/cjs/ExternalSource.d.ts +1 -2
- package/lib/cjs/ExternalSource.d.ts.map +1 -1
- package/lib/cjs/ExternalSource.js +2 -3
- package/lib/cjs/ExternalSource.js.map +1 -1
- package/lib/cjs/IModelHost.d.ts +2 -0
- package/lib/cjs/IModelHost.d.ts.map +1 -1
- package/lib/cjs/IModelHost.js +2 -0
- package/lib/cjs/IModelHost.js.map +1 -1
- package/lib/cjs/Model.d.ts +1 -2
- package/lib/cjs/Model.d.ts.map +1 -1
- package/lib/cjs/Model.js +2 -4
- package/lib/cjs/Model.js.map +1 -1
- package/lib/cjs/PropertyStore.d.ts +52 -61
- package/lib/cjs/PropertyStore.d.ts.map +1 -1
- package/lib/cjs/PropertyStore.js +169 -1
- package/lib/cjs/PropertyStore.js.map +1 -1
- package/lib/cjs/Relationship.d.ts +4 -7
- package/lib/cjs/Relationship.d.ts.map +1 -1
- package/lib/cjs/Relationship.js +7 -10
- package/lib/cjs/Relationship.js.map +1 -1
- package/lib/cjs/SQLiteDb.d.ts +106 -8
- package/lib/cjs/SQLiteDb.d.ts.map +1 -1
- package/lib/cjs/SQLiteDb.js +116 -10
- package/lib/cjs/SQLiteDb.js.map +1 -1
- package/lib/cjs/ViewDefinition.d.ts +6 -12
- package/lib/cjs/ViewDefinition.d.ts.map +1 -1
- package/lib/cjs/ViewDefinition.js +12 -18
- package/lib/cjs/ViewDefinition.js.map +1 -1
- package/lib/cjs/core-backend.d.ts +4 -6
- package/lib/cjs/core-backend.d.ts.map +1 -1
- package/lib/cjs/core-backend.js +4 -6
- package/lib/cjs/core-backend.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +5 -2
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
- package/lib/cjs/workspace/Settings.d.ts.map +1 -1
- package/lib/cjs/workspace/Settings.js +2 -1
- package/lib/cjs/workspace/Settings.js.map +1 -1
- package/package.json +10 -10
package/lib/cjs/SQLiteDb.d.ts
CHANGED
|
@@ -2,20 +2,23 @@
|
|
|
2
2
|
* @module SQLiteDb
|
|
3
3
|
*/
|
|
4
4
|
import { IModelJsNative } from "@bentley/imodeljs-native";
|
|
5
|
-
import { DbResult,
|
|
5
|
+
import { DbResult, OpenMode } from "@itwin/core-bentley";
|
|
6
6
|
import { LocalFileName } from "@itwin/core-common";
|
|
7
7
|
import { CloudSqlite } from "./CloudSqlite";
|
|
8
8
|
import { SqliteStatement } from "./SqliteStatement";
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* A "generic" SQLiteDb. This class may be used to access local files or databases in a cloud container.
|
|
10
11
|
* @public
|
|
11
12
|
*/
|
|
12
|
-
export declare class SQLiteDb
|
|
13
|
+
export declare class SQLiteDb {
|
|
13
14
|
/** @internal */
|
|
14
15
|
readonly nativeDb: IModelJsNative.SQLiteDb;
|
|
15
16
|
private _sqliteStatementCache;
|
|
16
17
|
/** @internal */
|
|
17
18
|
static createBlobIO(): SQLiteDb.BlobIO;
|
|
18
|
-
/** alias for closeDb.
|
|
19
|
+
/** alias for closeDb.
|
|
20
|
+
* @deprecated in 4.0, use [[closeDb]]
|
|
21
|
+
*/
|
|
19
22
|
dispose(): void;
|
|
20
23
|
/** Create a SQLiteDb
|
|
21
24
|
* @param dbName The path to the SQLiteDb file to create.
|
|
@@ -40,6 +43,22 @@ export declare class SQLiteDb implements IDisposable {
|
|
|
40
43
|
get isOpen(): boolean;
|
|
41
44
|
/** Returns true if this SQLiteDb is open readonly */
|
|
42
45
|
get isReadonly(): boolean;
|
|
46
|
+
/** Create a new table in this database. */
|
|
47
|
+
protected createTable(args: {
|
|
48
|
+
/** The name of the table to create. */
|
|
49
|
+
tableName: string;
|
|
50
|
+
/** all of the columns in the table. */
|
|
51
|
+
columns: string;
|
|
52
|
+
/** any unique or foreign key constraints */
|
|
53
|
+
constraints?: string;
|
|
54
|
+
/** if true, add a "lastMod" timestamp column and triggers to automatically update it. */
|
|
55
|
+
addTimestamp?: boolean;
|
|
56
|
+
}): void;
|
|
57
|
+
/**
|
|
58
|
+
* Get the last modified date for a row in a table of this database.
|
|
59
|
+
* @note the table must have been created with `addTimestamp: true`
|
|
60
|
+
*/
|
|
61
|
+
readLastModTime(tableName: string, rowId: number): Date;
|
|
43
62
|
/**
|
|
44
63
|
* Open a database, perform an operation, then close the database.
|
|
45
64
|
*
|
|
@@ -66,14 +85,14 @@ export declare class SQLiteDb implements IDisposable {
|
|
|
66
85
|
* @return value from operation
|
|
67
86
|
* @internal
|
|
68
87
|
*/
|
|
69
|
-
withLockedContainer<T>(args: CloudSqlite.LockAndOpenArgs, operation: () => T): Promise<T>;
|
|
88
|
+
withLockedContainer<T>(args: CloudSqlite.LockAndOpenArgs, operation: () => Promise<T>): Promise<T>;
|
|
70
89
|
/** vacuum this database
|
|
71
90
|
* @see https://www.sqlite.org/lang_vacuum.html
|
|
72
91
|
*/
|
|
73
92
|
vacuum(args?: SQLiteDb.VacuumDbArgs): void;
|
|
74
|
-
/** Commit the outermost transaction, writing changes to the file. Then, restart the transaction. */
|
|
93
|
+
/** Commit the outermost transaction, writing changes to the file. Then, restart the default transaction. */
|
|
75
94
|
saveChanges(): void;
|
|
76
|
-
/** Abandon (cancel) the outermost transaction, discarding all changes since last save. Then, restart the transaction. */
|
|
95
|
+
/** Abandon (cancel) the outermost transaction, discarding all changes since last save. Then, restart the default transaction. */
|
|
77
96
|
abandonChanges(): void;
|
|
78
97
|
/**
|
|
79
98
|
* Use a prepared SQL statement, potentially from the statement cache. If the requested statement doesn't exist
|
|
@@ -87,7 +106,7 @@ export declare class SQLiteDb implements IDisposable {
|
|
|
87
106
|
*/
|
|
88
107
|
withPreparedSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T): T;
|
|
89
108
|
/**
|
|
90
|
-
*
|
|
109
|
+
* Prepare and execute a callback on a SQL statement. After the callback completes the statement is disposed.
|
|
91
110
|
* Use this method for SQL statements are either not expected to be reused, or are not expensive to prepare.
|
|
92
111
|
* For statements that will be reused often, instead use [[withPreparedSqliteStatement]].
|
|
93
112
|
* @param sql The SQLite SQL statement to execute
|
|
@@ -110,8 +129,87 @@ export declare class SQLiteDb implements IDisposable {
|
|
|
110
129
|
/** execute an SQL statement */
|
|
111
130
|
executeSQL(sql: string): DbResult;
|
|
112
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* Abstract base class for a SQLite database that has [[SQLiteDb.RequiredVersionRanges]] stored in it.
|
|
134
|
+
* This class provides version checking when the database is opened, to guarantee that a valid version of software is
|
|
135
|
+
* always used for access.
|
|
136
|
+
*
|
|
137
|
+
* Notes:
|
|
138
|
+
* - This class may be used either to access a local file, or one stored in a cloud container.
|
|
139
|
+
* - Subclasses must provide a `myVersion` member indicating the version of its software, and implement the `createDDL` member to create its
|
|
140
|
+
* tables.
|
|
141
|
+
* @beta
|
|
142
|
+
*/
|
|
143
|
+
export declare abstract class VersionedSqliteDb extends SQLiteDb {
|
|
144
|
+
protected static _versionProps: {
|
|
145
|
+
readonly namespace: "SQLiteDb";
|
|
146
|
+
readonly name: "versions";
|
|
147
|
+
};
|
|
148
|
+
/** The current semver "persistence version" of this class.
|
|
149
|
+
* @note This value should only be changed when logic in its code is modified in a way that affects the operation of extant copies.
|
|
150
|
+
* If this value is outside of the range of accepted versions of a to-be-opened VersionedSqliteDb, the operation will fail. In this manner, if
|
|
151
|
+
* changes are made to the format of a VersionedSqliteDb, or if bug fixes are necessary, the `requiredVersions` property in a VersionedSqliteDb may be updated
|
|
152
|
+
* and immediately old versions of the package will refuse to open the VersionedSqliteDb, with a message to the user that they need to upgrade their
|
|
153
|
+
* software. Likewise, if a new version of the package is asked to open an older VersionedSqliteDb that has not been upgraded to the lowest version
|
|
154
|
+
* supported by it, the user will be informed that they need to upgrade their software.
|
|
155
|
+
* @note this identifier is independent of versions in `package.json` files.
|
|
156
|
+
*/
|
|
157
|
+
abstract myVersion: string;
|
|
158
|
+
/**
|
|
159
|
+
* Change the "versions required to open this database" property stored in this database. After this call,
|
|
160
|
+
* versions of software that don't meet the supplied ranges will fail.
|
|
161
|
+
* @param versions the new versions required for reading and writing this database.
|
|
162
|
+
* @note the database must be opened for write access.
|
|
163
|
+
*/
|
|
164
|
+
setRequiredVersions(versions: SQLiteDb.RequiredVersionRanges): void;
|
|
165
|
+
/** Get the required version ranges necessary to open this VersionedSqliteDb. */
|
|
166
|
+
getRequiredVersions(): SQLiteDb.RequiredVersionRanges;
|
|
167
|
+
/**
|
|
168
|
+
* Implement this method to create all tables for this subclass of `VersionedSqliteDb` when a new database file is created. Called from [[createNewDb]].
|
|
169
|
+
*/
|
|
170
|
+
protected abstract createDDL(): void;
|
|
171
|
+
/**
|
|
172
|
+
* Create a new database file for the subclass of VersionedSqliteDb.
|
|
173
|
+
* @param fileName the name of a local
|
|
174
|
+
* @note The required versions are saved as [[myVersion]] or newer for both read and write.
|
|
175
|
+
*/
|
|
176
|
+
static createNewDb(fileName: LocalFileName): void;
|
|
177
|
+
/**
|
|
178
|
+
* Verify that this version of the software meets the required version range (as appropriate, read or write) stored in the database.
|
|
179
|
+
* Throws otherwise.
|
|
180
|
+
*/
|
|
181
|
+
protected verifyVersions(): void;
|
|
182
|
+
/**
|
|
183
|
+
* Open this database and verify that this version of the software meets the required version range (as appropriate, read or write) stored in the database.
|
|
184
|
+
* Throws otherwise.
|
|
185
|
+
* @see [[SqliteDb.openDb]] for argument types
|
|
186
|
+
*/
|
|
187
|
+
openDb(dbName: string, openMode: OpenMode | SQLiteDb.OpenParams, container?: CloudSqlite.CloudContainer): void;
|
|
188
|
+
upgradeSchema(arg: {
|
|
189
|
+
dbName: string;
|
|
190
|
+
lockContainer?: {
|
|
191
|
+
container: CloudSqlite.CloudContainer;
|
|
192
|
+
moniker: string;
|
|
193
|
+
};
|
|
194
|
+
upgradeFn: () => void;
|
|
195
|
+
}): Promise<void | (() => void)>;
|
|
196
|
+
}
|
|
113
197
|
/** @public */
|
|
114
198
|
export declare namespace SQLiteDb {
|
|
199
|
+
/** A semver version range.
|
|
200
|
+
* @see https://docs.npmjs.com/cli/v6/using-npm/semver
|
|
201
|
+
*/
|
|
202
|
+
type VersionRange = string;
|
|
203
|
+
/**
|
|
204
|
+
* A pair of semver [[SQLiteDb.VersionRange]]s, one for read and one for write, required to access a [[VersionedSqliteDb]].
|
|
205
|
+
* If the version of the software attempting to read or write the database does not satisfy the range, access is denied.
|
|
206
|
+
*/
|
|
207
|
+
interface RequiredVersionRanges {
|
|
208
|
+
/** a range of acceptable persistence versions for reading from a VersionedSqliteDb. */
|
|
209
|
+
readonly readVersion: VersionRange;
|
|
210
|
+
/** a range of acceptable persistence versions for writing to a VersionedSqliteDb. */
|
|
211
|
+
readonly writeVersion: VersionRange;
|
|
212
|
+
}
|
|
115
213
|
/** interface for reading and writing to a blob in a SQLiteDb
|
|
116
214
|
* @internal
|
|
117
215
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SQLiteDb.d.ts","sourceRoot":"","sources":["../../src/SQLiteDb.ts"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"SQLiteDb.d.ts","sourceRoot":"","sources":["../../src/SQLiteDb.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,OAAO,EAAE,eAAe,EAAkB,MAAM,mBAAmB,CAAC;AAMpE;;;GAGG;AACH,qBAAa,QAAQ;IACnB,gBAAgB;IAChB,SAAgB,QAAQ,0BAAsC;IAC9D,OAAO,CAAC,qBAAqB,CAAyC;IAEtE,gBAAgB;WACF,YAAY,IAAI,QAAQ,CAAC,MAAM;IAI7C;;OAEG;IACI,OAAO,IAAI,IAAI;IAItB;;OAEG;IACI,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,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AC;KACtB;CACF"}
|
package/lib/cjs/SQLiteDb.js
CHANGED
|
@@ -7,14 +7,19 @@
|
|
|
7
7
|
* @module SQLiteDb
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.SQLiteDb = void 0;
|
|
10
|
+
exports.VersionedSqliteDb = exports.SQLiteDb = void 0;
|
|
11
|
+
const fs = require("fs");
|
|
12
|
+
const path_1 = require("path");
|
|
13
|
+
const semver = require("semver");
|
|
11
14
|
const core_bentley_1 = require("@itwin/core-bentley");
|
|
12
15
|
const CloudSqlite_1 = require("./CloudSqlite");
|
|
13
16
|
const IModelHost_1 = require("./IModelHost");
|
|
17
|
+
const IModelJsFs_1 = require("./IModelJsFs");
|
|
14
18
|
const SqliteStatement_1 = require("./SqliteStatement");
|
|
15
|
-
// cspell:ignore savepoint
|
|
19
|
+
// cspell:ignore savepoint julianday rowid
|
|
16
20
|
/* eslint-disable @typescript-eslint/unified-signatures */
|
|
17
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* A "generic" SQLiteDb. This class may be used to access local files or databases in a cloud container.
|
|
18
23
|
* @public
|
|
19
24
|
*/
|
|
20
25
|
class SQLiteDb {
|
|
@@ -27,15 +32,15 @@ class SQLiteDb {
|
|
|
27
32
|
static createBlobIO() {
|
|
28
33
|
return new IModelHost_1.IModelHost.platform.BlobIO();
|
|
29
34
|
}
|
|
30
|
-
/** alias for closeDb.
|
|
35
|
+
/** alias for closeDb.
|
|
36
|
+
* @deprecated in 4.0, use [[closeDb]]
|
|
37
|
+
*/
|
|
31
38
|
dispose() {
|
|
32
39
|
this.closeDb();
|
|
33
40
|
}
|
|
34
|
-
/** @internal */
|
|
35
41
|
createDb(dbName, container, params) {
|
|
36
42
|
this.nativeDb.createDb(dbName, container, params);
|
|
37
43
|
}
|
|
38
|
-
/** @internal */
|
|
39
44
|
openDb(dbName, openMode, container) {
|
|
40
45
|
this.nativeDb.openDb(dbName, openMode, container);
|
|
41
46
|
}
|
|
@@ -52,6 +57,24 @@ class SQLiteDb {
|
|
|
52
57
|
get isOpen() { return this.nativeDb.isOpen(); }
|
|
53
58
|
/** Returns true if this SQLiteDb is open readonly */
|
|
54
59
|
get isReadonly() { return this.nativeDb.isReadonly(); }
|
|
60
|
+
/** Create a new table in this database. */
|
|
61
|
+
createTable(args) {
|
|
62
|
+
const timestampCol = args.addTimestamp ? ",lastMod TIMESTAMP NOT NULL DEFAULT(julianday('now'))" : "";
|
|
63
|
+
const constraints = args.constraints ? `,${args.constraints}` : "";
|
|
64
|
+
this.executeSQL(`CREATE TABLE ${args.tableName}(${args.columns}${timestampCol}${constraints})`);
|
|
65
|
+
if (args.addTimestamp)
|
|
66
|
+
this.executeSQL(`CREATE TRIGGER ${args.tableName}_timestamp AFTER UPDATE ON ${args.tableName} WHEN old.lastMod=new.lastMod AND old.lastMod != julianday('now') BEGIN UPDATE ${args.tableName} SET lastMod=julianday('now') WHERE rowid=new.rowid; END`);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get the last modified date for a row in a table of this database.
|
|
70
|
+
* @note the table must have been created with `addTimestamp: true`
|
|
71
|
+
*/
|
|
72
|
+
readLastModTime(tableName, rowId) {
|
|
73
|
+
return this.withSqliteStatement(`SELECT lastMod from ${tableName} WHERE rowid=?`, (stmt) => {
|
|
74
|
+
stmt.bindInteger(1, rowId);
|
|
75
|
+
return stmt.getValueDate(0);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
55
78
|
/**
|
|
56
79
|
* Open a database, perform an operation, then close the database.
|
|
57
80
|
*
|
|
@@ -93,7 +116,7 @@ class SQLiteDb {
|
|
|
93
116
|
* @internal
|
|
94
117
|
*/
|
|
95
118
|
async withLockedContainer(args, operation) {
|
|
96
|
-
return CloudSqlite_1.CloudSqlite.withWriteLock(args.
|
|
119
|
+
return CloudSqlite_1.CloudSqlite.withWriteLock(args.moniker, args.container, async () => this.withOpenDb({ ...args, openMode: core_bentley_1.OpenMode.ReadWrite }, operation), args.busyHandler);
|
|
97
120
|
}
|
|
98
121
|
/** vacuum this database
|
|
99
122
|
* @see https://www.sqlite.org/lang_vacuum.html
|
|
@@ -101,11 +124,11 @@ class SQLiteDb {
|
|
|
101
124
|
vacuum(args) {
|
|
102
125
|
this.nativeDb.vacuum(args);
|
|
103
126
|
}
|
|
104
|
-
/** Commit the outermost transaction, writing changes to the file. Then, restart the transaction. */
|
|
127
|
+
/** Commit the outermost transaction, writing changes to the file. Then, restart the default transaction. */
|
|
105
128
|
saveChanges() {
|
|
106
129
|
this.nativeDb.saveChanges();
|
|
107
130
|
}
|
|
108
|
-
/** Abandon (cancel) the outermost transaction, discarding all changes since last save. Then, restart the transaction. */
|
|
131
|
+
/** Abandon (cancel) the outermost transaction, discarding all changes since last save. Then, restart the default transaction. */
|
|
109
132
|
abandonChanges() {
|
|
110
133
|
this.nativeDb.abandonChanges();
|
|
111
134
|
}
|
|
@@ -133,7 +156,7 @@ class SQLiteDb {
|
|
|
133
156
|
}
|
|
134
157
|
}
|
|
135
158
|
/**
|
|
136
|
-
*
|
|
159
|
+
* Prepare and execute a callback on a SQL statement. After the callback completes the statement is disposed.
|
|
137
160
|
* Use this method for SQL statements are either not expected to be reused, or are not expensive to prepare.
|
|
138
161
|
* For statements that will be reused often, instead use [[withPreparedSqliteStatement]].
|
|
139
162
|
* @param sql The SQLite SQL statement to execute
|
|
@@ -193,6 +216,89 @@ class SQLiteDb {
|
|
|
193
216
|
}
|
|
194
217
|
}
|
|
195
218
|
exports.SQLiteDb = SQLiteDb;
|
|
219
|
+
/**
|
|
220
|
+
* Abstract base class for a SQLite database that has [[SQLiteDb.RequiredVersionRanges]] stored in it.
|
|
221
|
+
* This class provides version checking when the database is opened, to guarantee that a valid version of software is
|
|
222
|
+
* always used for access.
|
|
223
|
+
*
|
|
224
|
+
* Notes:
|
|
225
|
+
* - This class may be used either to access a local file, or one stored in a cloud container.
|
|
226
|
+
* - Subclasses must provide a `myVersion` member indicating the version of its software, and implement the `createDDL` member to create its
|
|
227
|
+
* tables.
|
|
228
|
+
* @beta
|
|
229
|
+
*/
|
|
230
|
+
class VersionedSqliteDb extends SQLiteDb {
|
|
231
|
+
/**
|
|
232
|
+
* Change the "versions required to open this database" property stored in this database. After this call,
|
|
233
|
+
* versions of software that don't meet the supplied ranges will fail.
|
|
234
|
+
* @param versions the new versions required for reading and writing this database.
|
|
235
|
+
* @note the database must be opened for write access.
|
|
236
|
+
*/
|
|
237
|
+
setRequiredVersions(versions) {
|
|
238
|
+
// NOTE: It might look tempting to just stringify the supplied `versions` object, but we only include required members - there may be others.
|
|
239
|
+
this.nativeDb.saveFileProperty(VersionedSqliteDb._versionProps, JSON.stringify({ readVersion: versions.readVersion, writeVersion: versions.writeVersion }));
|
|
240
|
+
}
|
|
241
|
+
/** Get the required version ranges necessary to open this VersionedSqliteDb. */
|
|
242
|
+
getRequiredVersions() {
|
|
243
|
+
const checkIsString = (value) => {
|
|
244
|
+
if (typeof value !== "string")
|
|
245
|
+
throw new Error(`CloudDb ${this.nativeDb.getFilePath()} has invalid "versions" property`);
|
|
246
|
+
return value;
|
|
247
|
+
};
|
|
248
|
+
const versionJson = checkIsString(this.nativeDb.queryFileProperty(VersionedSqliteDb._versionProps, true));
|
|
249
|
+
const versionRanges = JSON.parse(versionJson);
|
|
250
|
+
checkIsString(versionRanges.readVersion);
|
|
251
|
+
checkIsString(versionRanges.writeVersion);
|
|
252
|
+
return versionRanges;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Create a new database file for the subclass of VersionedSqliteDb.
|
|
256
|
+
* @param fileName the name of a local
|
|
257
|
+
* @note The required versions are saved as [[myVersion]] or newer for both read and write.
|
|
258
|
+
*/
|
|
259
|
+
static createNewDb(fileName) {
|
|
260
|
+
const db = new this(); // "as any" necessary because VersionedSqliteDb is abstract
|
|
261
|
+
IModelJsFs_1.IModelJsFs.recursiveMkDirSync((0, path_1.dirname)(fileName));
|
|
262
|
+
if (fs.existsSync(fileName))
|
|
263
|
+
fs.unlinkSync(fileName);
|
|
264
|
+
db.createDb(fileName);
|
|
265
|
+
db.createDDL();
|
|
266
|
+
const minVer = `^${db.myVersion}`;
|
|
267
|
+
db.setRequiredVersions({ readVersion: minVer, writeVersion: minVer });
|
|
268
|
+
db.closeDb(true);
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Verify that this version of the software meets the required version range (as appropriate, read or write) stored in the database.
|
|
272
|
+
* Throws otherwise.
|
|
273
|
+
*/
|
|
274
|
+
verifyVersions() {
|
|
275
|
+
const versions = this.getRequiredVersions();
|
|
276
|
+
const isReadonly = this.isReadonly; // so we can tell read/write after the file is closed.
|
|
277
|
+
const range = isReadonly ? versions.readVersion : versions.writeVersion;
|
|
278
|
+
if (semver.satisfies(this.myVersion, range))
|
|
279
|
+
return;
|
|
280
|
+
this.closeDb();
|
|
281
|
+
const tooNew = semver.gtr(this.myVersion, range);
|
|
282
|
+
throw new Error(`${this.nativeDb.getFilePath()} requires ${tooNew ? "older" : "newer"} version of ${this.constructor.name} for ${isReadonly ? "read" : "write"}`);
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Open this database and verify that this version of the software meets the required version range (as appropriate, read or write) stored in the database.
|
|
286
|
+
* Throws otherwise.
|
|
287
|
+
* @see [[SqliteDb.openDb]] for argument types
|
|
288
|
+
*/
|
|
289
|
+
openDb(dbName, openMode, container) {
|
|
290
|
+
super.openDb(dbName, openMode, container);
|
|
291
|
+
this.verifyVersions();
|
|
292
|
+
}
|
|
293
|
+
async upgradeSchema(arg) {
|
|
294
|
+
// can't use "this" because it checks for version, which we don't want here
|
|
295
|
+
return (arg.lockContainer) ?
|
|
296
|
+
super.withLockedContainer({ dbName: arg.dbName, ...arg.lockContainer }, async () => arg.upgradeFn) :
|
|
297
|
+
super.withOpenDb({ ...arg, openMode: core_bentley_1.OpenMode.ReadWrite }, arg.upgradeFn);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
VersionedSqliteDb._versionProps = { namespace: "SQLiteDb", name: "versions" };
|
|
301
|
+
exports.VersionedSqliteDb = VersionedSqliteDb;
|
|
196
302
|
/** @public */
|
|
197
303
|
(function (SQLiteDb) {
|
|
198
304
|
/** Default transaction mode for SQLiteDbs.
|
package/lib/cjs/SQLiteDb.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SQLiteDb.js","sourceRoot":"","sources":["../../src/SQLiteDb.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,sDAAsE;AAEtE,+CAA4C;AAC5C,6CAA0C;AAC1C,uDAAoE;AAEpE,0BAA0B;AAC1B,0DAA0D;AAE1D;;GAEG;AACH,MAAa,QAAQ;IAArB;QACE,gBAAgB;QACA,aAAQ,GAAG,IAAI,uBAAU,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;QACtD,0BAAqB,GAAG,IAAI,gCAAc,EAAmB,CAAC;IAuMxE,CAAC;IArMC,gBAAgB;IACT,MAAM,CAAC,YAAY;QACxB,OAAO,IAAI,uBAAU,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC1C,CAAC;IAED,yBAAyB;IAClB,OAAO;QACZ,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC;IAQD,gBAAgB;IACT,QAAQ,CAAC,MAAc,EAAE,SAAsC,EAAE,MAA8B;QACpG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IACpD,CAAC;IAYD,gBAAgB;IACT,MAAM,CAAC,MAAc,EAAE,QAAwC,EAAE,SAAsC;QAC5G,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;IACpD,CAAC;IAED;;OAEG;IACI,OAAO,CAAC,WAAqB;QAClC,IAAI,WAAW,IAAI,IAAI,CAAC,MAAM;YAC5B,IAAI,CAAC,WAAW,EAAE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WAAiB,QAAQ;IAqDvB;;OAEG;IACH,IAAY,cASX;IATD,WAAY,cAAc;QACxB,4GAA4G;QAC5G,mDAAQ,CAAA;QACR,4FAA4F;QAC5F,2DAAY,CAAA;QACZ,yEAAyE;QACzE,6DAAa,CAAA;QACb,yEAAyE;QACzE,6DAAa,CAAA;IACf,CAAC,EATW,cAAc,GAAd,uBAAc,KAAd,uBAAc,QASzB;AAgDH,CAAC,EAjHgB,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAiHxB","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 SQLiteDb\r\n */\r\n\r\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\nimport { DbResult, IDisposable, OpenMode } from \"@itwin/core-bentley\";\r\nimport { LocalFileName } from \"@itwin/core-common\";\r\nimport { CloudSqlite } from \"./CloudSqlite\";\r\nimport { IModelHost } from \"./IModelHost\";\r\nimport { SqliteStatement, StatementCache } from \"./SqliteStatement\";\r\n\r\n// cspell:ignore savepoint\r\n/* eslint-disable @typescript-eslint/unified-signatures */\r\n\r\n/** A SQLiteDb file\r\n * @public\r\n */\r\nexport class SQLiteDb implements IDisposable {\r\n /** @internal */\r\n public readonly nativeDb = new IModelHost.platform.SQLiteDb();\r\n private _sqliteStatementCache = new StatementCache<SqliteStatement>();\r\n\r\n /** @internal */\r\n public static createBlobIO(): SQLiteDb.BlobIO {\r\n return new IModelHost.platform.BlobIO();\r\n }\r\n\r\n /** alias for closeDb. */\r\n public dispose(): void {\r\n this.closeDb();\r\n }\r\n\r\n /** Create a SQLiteDb\r\n * @param dbName The path to the SQLiteDb file to create.\r\n */\r\n public createDb(dbName: string): void;\r\n /** @beta */\r\n public createDb(dbName: string, container?: CloudSqlite.CloudContainer, params?: SQLiteDb.CreateParams): void;\r\n /** @internal */\r\n public createDb(dbName: string, container?: CloudSqlite.CloudContainer, params?: SQLiteDb.CreateParams): void {\r\n this.nativeDb.createDb(dbName, container, params);\r\n }\r\n\r\n /** Open a SQLiteDb.\r\n * @param dbName The path to the SQLiteDb file to open\r\n */\r\n public openDb(dbName: string, openMode: OpenMode | SQLiteDb.OpenParams): void;\r\n /**\r\n * @param container optional CloudContainer holding database\r\n * @beta\r\n */\r\n public openDb(dbName: string, openMode: OpenMode | SQLiteDb.OpenParams, container?: CloudSqlite.CloudContainer): void;\r\n\r\n /** @internal */\r\n public openDb(dbName: string, openMode: OpenMode | SQLiteDb.OpenParams, container?: CloudSqlite.CloudContainer): void {\r\n this.nativeDb.openDb(dbName, openMode, container);\r\n }\r\n\r\n /** Close SQLiteDb.\r\n * @param saveChanges if true, call `saveChanges` before closing db. Otherwise unsaved changes are abandoned.\r\n */\r\n public closeDb(saveChanges?: boolean): void {\r\n if (saveChanges && this.isOpen)\r\n this.saveChanges();\r\n this._sqliteStatementCache.clear();\r\n this.nativeDb.closeDb();\r\n }\r\n\r\n /** Returns true if this SQLiteDb is open */\r\n public get isOpen(): boolean { return this.nativeDb.isOpen(); }\r\n\r\n /** Returns true if this SQLiteDb is open readonly */\r\n public get isReadonly(): boolean { return this.nativeDb.isReadonly(); }\r\n\r\n /**\r\n * Open a database, perform an operation, then close the database.\r\n *\r\n * Details:\r\n * - if database is open, throw an error\r\n * - open a database\r\n * - call a function with the database opened. If it is async, await its return.\r\n * - if function throws, abandon all changes, close database, and rethrow\r\n * - save all changes\r\n * - close the database\r\n * @return value from operation\r\n */\r\n public withOpenDb<T>(args: SQLiteDb.WithOpenDbArgs, operation: () => T): T {\r\n if (this.isOpen)\r\n throw new Error(\"database is already open\");\r\n\r\n const save = () => this.closeDb(true), abandon = () => this.closeDb(false);\r\n this.openDb(args.dbName, args.openMode ?? OpenMode.Readonly, args.container);\r\n try {\r\n const result = operation();\r\n result instanceof Promise ? result.then(save, abandon) : save();\r\n return result;\r\n } catch (e) {\r\n abandon();\r\n throw e;\r\n }\r\n }\r\n\r\n /**\r\n * Perform an operation on a database in a CloudContainer with the write lock held.\r\n *\r\n * Details:\r\n * - acquire the write lock on a CloudContainer\r\n * - call `withOpenDb` with openMode `ReadWrite`\r\n * - upload changes\r\n * - release the write lock\r\n * @param args arguments to lock the container and open the database\r\n * @param operation an operation performed on the database with the write lock held.\r\n * @return value from operation\r\n * @internal\r\n */\r\n public async withLockedContainer<T>(args: CloudSqlite.LockAndOpenArgs, operation: () => T) {\r\n return CloudSqlite.withWriteLock(args.user, args.container, () => this.withOpenDb({ ...args, openMode: OpenMode.ReadWrite }, operation), args.busyHandler);\r\n }\r\n\r\n /** vacuum this database\r\n * @see https://www.sqlite.org/lang_vacuum.html\r\n */\r\n public vacuum(args?: SQLiteDb.VacuumDbArgs) {\r\n this.nativeDb.vacuum(args);\r\n }\r\n\r\n /** Commit the outermost transaction, writing changes to the file. Then, restart the transaction. */\r\n public saveChanges(): void {\r\n this.nativeDb.saveChanges();\r\n }\r\n\r\n /** Abandon (cancel) the outermost transaction, discarding all changes since last save. Then, restart the transaction. */\r\n public abandonChanges(): void {\r\n this.nativeDb.abandonChanges();\r\n }\r\n\r\n /**\r\n * Use a prepared SQL statement, potentially from the statement cache. If the requested statement doesn't exist\r\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\r\n * in the statement cache so it can be reused in the future. Use this method for SQL statements that will be\r\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\r\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withSqliteStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @returns the value returned by `callback`.\r\n */\r\n public withPreparedSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T): T {\r\n const stmt = this._sqliteStatementCache.findAndRemove(sql) ?? this.prepareSqliteStatement(sql);\r\n const release = () => this._sqliteStatementCache.addOrDispose(stmt);\r\n try {\r\n const val = callback(stmt);\r\n val instanceof Promise ? val.then(release, release) : release();\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Prepared and execute a callback on a SQL statement. After the callback completes the statement is disposed.\r\n * Use this method for SQL statements are either not expected to be reused, or are not expensive to prepare.\r\n * For statements that will be reused often, instead use [[withPreparedSqliteStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @returns the value returned by `callback`.\r\n */\r\n public withSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T): T {\r\n const stmt = this.prepareSqliteStatement(sql);\r\n const release = () => stmt.dispose();\r\n try {\r\n const val = callback(stmt);\r\n val instanceof Promise ? val.then(release, release) : release();\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Perform an operation on this database within a [savepoint](https://www.sqlite.org/lang_savepoint.html). If the operation completes successfully, the\r\n * changes remain in the current transaction. If the operation throws an exception, the savepoint is rolled back\r\n * and all changes to the database from this method are reversed, leaving the transaction exactly as it was before this method.\r\n */\r\n public withSavePoint(savePointName: string, operation: () => void) {\r\n if (this.isReadonly)\r\n throw new Error(\"database is readonly\");\r\n\r\n this.executeSQL(`SAVEPOINT ${savePointName}`);\r\n try {\r\n operation();\r\n this.executeSQL(`RELEASE ${savePointName}`);\r\n } catch (e) {\r\n this.executeSQL(`ROLLBACK TO ${savePointName}`);\r\n throw e;\r\n }\r\n }\r\n\r\n /** Prepare an SQL statement.\r\n * @param sql The SQLite SQL statement to prepare\r\n * @param logErrors Determine if errors are logged or not\r\n * @internal\r\n */\r\n public prepareSqliteStatement(sql: string, logErrors = true): SqliteStatement {\r\n const stmt = new SqliteStatement(sql);\r\n stmt.prepare(this.nativeDb, logErrors);\r\n return stmt;\r\n }\r\n\r\n /** execute an SQL statement */\r\n public executeSQL(sql: string): DbResult {\r\n const stmt = this.prepareSqliteStatement(sql);\r\n try {\r\n return stmt.step();\r\n } finally {\r\n stmt.dispose();\r\n }\r\n }\r\n}\r\n\r\n/** @public */\r\nexport namespace SQLiteDb {\r\n /** interface for reading and writing to a blob in a SQLiteDb\r\n * @internal\r\n */\r\n export interface BlobIO {\r\n /** Close this BlobIO if it is opened.\r\n * @note this BlobIO *may* be reused after this call by calling `open` again.\r\n */\r\n close(): void;\r\n /** get the total number of bytes in the blob */\r\n getNumBytes(): number;\r\n /** @return true if this BlobIO was successfully opened and may be use to read or write the blob */\r\n isValid(): boolean;\r\n /** Open this BlobIO against a table/row/column in a Db */\r\n open(\r\n /** The database for the blob */\r\n db: IModelJsNative.AnyDb,\r\n args: {\r\n /** the name of the table for the blob*/\r\n tableName: string;\r\n /** the name of the column for the blob */\r\n columnName: string;\r\n /** The rowId of the blob */\r\n row: number;\r\n /** If true, open this BlobIO for write access */\r\n writeable?: boolean;\r\n }): void;\r\n /** Read from a blob\r\n * @returns the contents of the requested byte range\r\n */\r\n read(args: {\r\n /** The number of bytes to read */\r\n numBytes: number;\r\n /** starting offset within the blob to read */\r\n offset: number;\r\n /** If present and of sufficient size, use this ArrayBuffer for the value. */\r\n blob?: ArrayBuffer;\r\n }): Uint8Array;\r\n /** Reposition this BlobIO to a new rowId\r\n * @note this BlobIO must be valid when this methods is called.\r\n */\r\n changeRow(row: number): void;\r\n /** Write to a blob */\r\n write(args: {\r\n /** The number of bytes to write */\r\n numBytes: number;\r\n /** starting offset within the blob to write */\r\n offset: number;\r\n /** the value to write */\r\n blob: ArrayBuffer;\r\n }): void;\r\n }\r\n\r\n /** Default transaction mode for SQLiteDbs.\r\n * @see https://www.sqlite.org/lang_transaction.html\r\n */\r\n export enum DefaultTxnMode {\r\n /** no default transaction is started. You must use BEGIN/COMMIT or SQLite will use implicit transactions */\r\n None = 0,\r\n /** A deferred transaction is started when the file is first opened. This is the default. */\r\n Deferred = 1,\r\n /** An immediate transaction is started when the file is first opened. */\r\n Immediate = 2,\r\n /** An exclusive transaction is started when the file is first opened. */\r\n Exclusive = 3\r\n }\r\n\r\n /** parameters common to opening or creating a new SQLiteDb */\r\n export interface OpenOrCreateParams {\r\n /** If true, do not require that the `be_Prop` table exist */\r\n rawSQLite?: boolean;\r\n /** @see immutable option at https://www.sqlite.org/c3ref/open.html */\r\n immutable?: boolean;\r\n /** Do not attempt to verify that the file is a valid sQLite file before opening. */\r\n skipFileCheck?: boolean;\r\n /** the default transaction mode\r\n * @see [[SQLiteDb.DefaultTxnMode]]\r\n */\r\n defaultTxn?: 0 | 1 | 2 | 3;\r\n /** see query parameters from 'URI Filenames' in https://www.sqlite.org/c3ref/open.html */\r\n queryParam?: string;\r\n }\r\n\r\n /** Parameters for opening an existing SQLiteDb */\r\n export interface OpenParams extends OpenOrCreateParams {\r\n /** use OpenMode.ReadWrite to open the file with write access */\r\n openMode: OpenMode;\r\n }\r\n\r\n /** Size of a SQLiteDb page in bytes */\r\n export interface PageSize {\r\n /** see https://www.sqlite.org/pragma.html#pragma_page_size */\r\n pageSize?: number;\r\n }\r\n\r\n /** Parameters for creating a new SQLiteDb */\r\n export type CreateParams = OpenOrCreateParams & PageSize;\r\n\r\n /** Arguments for `SqliteDb.withOpenDb` */\r\n export interface WithOpenDbArgs {\r\n /** The name of the database to open */\r\n dbName: string;\r\n /** either an object with the open parameters or just OpenMode value. */\r\n openMode?: OpenMode | SQLiteDb.OpenParams;\r\n /** @internal */\r\n container?: CloudSqlite.CloudContainer;\r\n }\r\n\r\n /** Arguments for `SQLiteDb.vacuum` */\r\n export interface VacuumDbArgs extends PageSize {\r\n /** if present, name of new file to [vacuum into](https://www.sqlite.org/lang_vacuum.html) */\r\n into?: LocalFileName;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"SQLiteDb.js","sourceRoot":"","sources":["../../src/SQLiteDb.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,yBAAyB;AACzB,+BAA+B;AAC/B,iCAAiC;AAEjC,sDAAyD;AAEzD,+CAA4C;AAC5C,6C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,KAAR,gBAAQ,QAiIxB","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 SQLiteDb\r\n */\r\n\r\nimport * as fs from \"fs\";\r\nimport { dirname } from \"path\";\r\nimport * as semver from \"semver\";\r\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\nimport { DbResult, OpenMode } from \"@itwin/core-bentley\";\r\nimport { LocalFileName } from \"@itwin/core-common\";\r\nimport { CloudSqlite } from \"./CloudSqlite\";\r\nimport { IModelHost } from \"./IModelHost\";\r\nimport { IModelJsFs } from \"./IModelJsFs\";\r\nimport { SqliteStatement, StatementCache } from \"./SqliteStatement\";\r\n\r\n// cspell:ignore savepoint julianday rowid\r\n\r\n/* eslint-disable @typescript-eslint/unified-signatures */\r\n\r\n/**\r\n * A \"generic\" SQLiteDb. This class may be used to access local files or databases in a cloud container.\r\n * @public\r\n */\r\nexport class SQLiteDb {\r\n /** @internal */\r\n public readonly nativeDb = new IModelHost.platform.SQLiteDb();\r\n private _sqliteStatementCache = new StatementCache<SqliteStatement>();\r\n\r\n /** @internal */\r\n public static createBlobIO(): SQLiteDb.BlobIO {\r\n return new IModelHost.platform.BlobIO();\r\n }\r\n\r\n /** alias for closeDb.\r\n * @deprecated in 4.0, use [[closeDb]]\r\n */\r\n public dispose(): void {\r\n this.closeDb();\r\n }\r\n\r\n /** Create a SQLiteDb\r\n * @param dbName The path to the SQLiteDb file to create.\r\n */\r\n public createDb(dbName: string): void;\r\n /** @beta */\r\n public createDb(dbName: string, container?: CloudSqlite.CloudContainer, params?: SQLiteDb.CreateParams): void;\r\n public createDb(dbName: string, container?: CloudSqlite.CloudContainer, params?: SQLiteDb.CreateParams): void {\r\n this.nativeDb.createDb(dbName, container, params);\r\n }\r\n\r\n /** Open a SQLiteDb.\r\n * @param dbName The path to the SQLiteDb file to open\r\n */\r\n public openDb(dbName: string, openMode: OpenMode | SQLiteDb.OpenParams): void;\r\n /**\r\n * @param container optional CloudContainer holding database\r\n * @beta\r\n */\r\n public openDb(dbName: string, openMode: OpenMode | SQLiteDb.OpenParams, container?: CloudSqlite.CloudContainer): void;\r\n public openDb(dbName: string, openMode: OpenMode | SQLiteDb.OpenParams, container?: CloudSqlite.CloudContainer): void {\r\n this.nativeDb.openDb(dbName, openMode, container);\r\n }\r\n\r\n /** Close SQLiteDb.\r\n * @param saveChanges if true, call `saveChanges` before closing db. Otherwise unsaved changes are abandoned.\r\n */\r\n public closeDb(saveChanges?: boolean): void {\r\n if (saveChanges && this.isOpen)\r\n this.saveChanges();\r\n this._sqliteStatementCache.clear();\r\n this.nativeDb.closeDb();\r\n }\r\n\r\n /** Returns true if this SQLiteDb is open */\r\n public get isOpen(): boolean { return this.nativeDb.isOpen(); }\r\n\r\n /** Returns true if this SQLiteDb is open readonly */\r\n public get isReadonly(): boolean { return this.nativeDb.isReadonly(); }\r\n\r\n /** Create a new table in this database. */\r\n protected createTable(args: {\r\n /** The name of the table to create. */\r\n tableName: string;\r\n /** all of the columns in the table. */\r\n columns: string;\r\n /** any unique or foreign key constraints */\r\n constraints?: string;\r\n /** if true, add a \"lastMod\" timestamp column and triggers to automatically update it. */\r\n addTimestamp?: boolean;\r\n }) {\r\n const timestampCol = args.addTimestamp ? \",lastMod TIMESTAMP NOT NULL DEFAULT(julianday('now'))\" : \"\";\r\n const constraints = args.constraints ? `,${args.constraints}` : \"\";\r\n this.executeSQL(`CREATE TABLE ${args.tableName}(${args.columns}${timestampCol}${constraints})`);\r\n if (args.addTimestamp)\r\n this.executeSQL(`CREATE TRIGGER ${args.tableName}_timestamp AFTER UPDATE ON ${args.tableName} WHEN old.lastMod=new.lastMod AND old.lastMod != julianday('now') BEGIN UPDATE ${args.tableName} SET lastMod=julianday('now') WHERE rowid=new.rowid; END`);\r\n }\r\n\r\n /**\r\n * Get the last modified date for a row in a table of this database.\r\n * @note the table must have been created with `addTimestamp: true`\r\n */\r\n public readLastModTime(tableName: string, rowId: number): Date {\r\n return this.withSqliteStatement(`SELECT lastMod from ${tableName} WHERE rowid=?`, (stmt) => {\r\n stmt.bindInteger(1, rowId);\r\n return stmt.getValueDate(0);\r\n });\r\n }\r\n\r\n /**\r\n * Open a database, perform an operation, then close the database.\r\n *\r\n * Details:\r\n * - if database is open, throw an error\r\n * - open a database\r\n * - call a function with the database opened. If it is async, await its return.\r\n * - if function throws, abandon all changes, close database, and rethrow\r\n * - save all changes\r\n * - close the database\r\n * @return value from operation\r\n */\r\n public withOpenDb<T>(args: SQLiteDb.WithOpenDbArgs, operation: () => T): T {\r\n if (this.isOpen)\r\n throw new Error(\"database is already open\");\r\n\r\n const save = () => this.closeDb(true), abandon = () => this.closeDb(false);\r\n this.openDb(args.dbName, args.openMode ?? OpenMode.Readonly, args.container);\r\n try {\r\n const result = operation();\r\n result instanceof Promise ? result.then(save, abandon) : save();\r\n return result;\r\n } catch (e) {\r\n abandon();\r\n throw e;\r\n }\r\n }\r\n\r\n /**\r\n * Perform an operation on a database in a CloudContainer with the write lock held.\r\n *\r\n * Details:\r\n * - acquire the write lock on a CloudContainer\r\n * - call `withOpenDb` with openMode `ReadWrite`\r\n * - upload changes\r\n * - release the write lock\r\n * @param args arguments to lock the container and open the database\r\n * @param operation an operation performed on the database with the write lock held.\r\n * @return value from operation\r\n * @internal\r\n */\r\n public async withLockedContainer<T>(args: CloudSqlite.LockAndOpenArgs, operation: () => Promise<T>) {\r\n return CloudSqlite.withWriteLock(args.moniker, args.container, async () => this.withOpenDb({ ...args, openMode: OpenMode.ReadWrite }, operation), args.busyHandler);\r\n }\r\n\r\n /** vacuum this database\r\n * @see https://www.sqlite.org/lang_vacuum.html\r\n */\r\n public vacuum(args?: SQLiteDb.VacuumDbArgs) {\r\n this.nativeDb.vacuum(args);\r\n }\r\n\r\n /** Commit the outermost transaction, writing changes to the file. Then, restart the default transaction. */\r\n public saveChanges(): void {\r\n this.nativeDb.saveChanges();\r\n }\r\n\r\n /** Abandon (cancel) the outermost transaction, discarding all changes since last save. Then, restart the default transaction. */\r\n public abandonChanges(): void {\r\n this.nativeDb.abandonChanges();\r\n }\r\n\r\n /**\r\n * Use a prepared SQL statement, potentially from the statement cache. If the requested statement doesn't exist\r\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\r\n * in the statement cache so it can be reused in the future. Use this method for SQL statements that will be\r\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\r\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withSqliteStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @returns the value returned by `callback`.\r\n */\r\n public withPreparedSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T): T {\r\n const stmt = this._sqliteStatementCache.findAndRemove(sql) ?? this.prepareSqliteStatement(sql);\r\n const release = () => this._sqliteStatementCache.addOrDispose(stmt);\r\n try {\r\n const val = callback(stmt);\r\n val instanceof Promise ? val.then(release, release) : release();\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Prepare and execute a callback on a SQL statement. After the callback completes the statement is disposed.\r\n * Use this method for SQL statements are either not expected to be reused, or are not expensive to prepare.\r\n * For statements that will be reused often, instead use [[withPreparedSqliteStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @returns the value returned by `callback`.\r\n */\r\n public withSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T): T {\r\n const stmt = this.prepareSqliteStatement(sql);\r\n const release = () => stmt.dispose();\r\n try {\r\n const val = callback(stmt);\r\n val instanceof Promise ? val.then(release, release) : release();\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Perform an operation on this database within a [savepoint](https://www.sqlite.org/lang_savepoint.html). If the operation completes successfully, the\r\n * changes remain in the current transaction. If the operation throws an exception, the savepoint is rolled back\r\n * and all changes to the database from this method are reversed, leaving the transaction exactly as it was before this method.\r\n */\r\n public withSavePoint(savePointName: string, operation: () => void) {\r\n if (this.isReadonly)\r\n throw new Error(\"database is readonly\");\r\n\r\n this.executeSQL(`SAVEPOINT ${savePointName}`);\r\n try {\r\n operation();\r\n this.executeSQL(`RELEASE ${savePointName}`);\r\n } catch (e) {\r\n this.executeSQL(`ROLLBACK TO ${savePointName}`);\r\n throw e;\r\n }\r\n }\r\n\r\n /** Prepare an SQL statement.\r\n * @param sql The SQLite SQL statement to prepare\r\n * @param logErrors Determine if errors are logged or not\r\n * @internal\r\n */\r\n public prepareSqliteStatement(sql: string, logErrors = true): SqliteStatement {\r\n const stmt = new SqliteStatement(sql);\r\n stmt.prepare(this.nativeDb, logErrors);\r\n return stmt;\r\n }\r\n\r\n /** execute an SQL statement */\r\n public executeSQL(sql: string): DbResult {\r\n const stmt = this.prepareSqliteStatement(sql);\r\n try {\r\n return stmt.step();\r\n } finally {\r\n stmt.dispose();\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Abstract base class for a SQLite database that has [[SQLiteDb.RequiredVersionRanges]] stored in it.\r\n * This class provides version checking when the database is opened, to guarantee that a valid version of software is\r\n * always used for access.\r\n *\r\n * Notes:\r\n * - This class may be used either to access a local file, or one stored in a cloud container.\r\n * - Subclasses must provide a `myVersion` member indicating the version of its software, and implement the `createDDL` member to create its\r\n * tables.\r\n * @beta\r\n */\r\nexport abstract class VersionedSqliteDb extends SQLiteDb {\r\n protected static _versionProps = { namespace: \"SQLiteDb\", name: \"versions\" } as const;\r\n\r\n /** The current semver \"persistence version\" of this class.\r\n * @note This value should only be changed when logic in its code is modified in a way that affects the operation of extant copies.\r\n * If this value is outside of the range of accepted versions of a to-be-opened VersionedSqliteDb, the operation will fail. In this manner, if\r\n * changes are made to the format of a VersionedSqliteDb, or if bug fixes are necessary, the `requiredVersions` property in a VersionedSqliteDb may be updated\r\n * and immediately old versions of the package will refuse to open the VersionedSqliteDb, with a message to the user that they need to upgrade their\r\n * software. Likewise, if a new version of the package is asked to open an older VersionedSqliteDb that has not been upgraded to the lowest version\r\n * supported by it, the user will be informed that they need to upgrade their software.\r\n * @note this identifier is independent of versions in `package.json` files.\r\n */\r\n public abstract myVersion: string;\r\n\r\n /**\r\n * Change the \"versions required to open this database\" property stored in this database. After this call,\r\n * versions of software that don't meet the supplied ranges will fail.\r\n * @param versions the new versions required for reading and writing this database.\r\n * @note the database must be opened for write access.\r\n */\r\n public setRequiredVersions(versions: SQLiteDb.RequiredVersionRanges) {\r\n // NOTE: It might look tempting to just stringify the supplied `versions` object, but we only include required members - there may be others.\r\n this.nativeDb.saveFileProperty(VersionedSqliteDb._versionProps, JSON.stringify({ readVersion: versions.readVersion, writeVersion: versions.writeVersion }));\r\n }\r\n\r\n /** Get the required version ranges necessary to open this VersionedSqliteDb. */\r\n public getRequiredVersions() {\r\n const checkIsString = (value: any) => {\r\n if (typeof value !== \"string\")\r\n throw new Error(`CloudDb ${this.nativeDb.getFilePath()} has invalid \"versions\" property`);\r\n return value;\r\n };\r\n const versionJson = checkIsString(this.nativeDb.queryFileProperty(VersionedSqliteDb._versionProps, true));\r\n const versionRanges = JSON.parse(versionJson) as SQLiteDb.RequiredVersionRanges;\r\n checkIsString(versionRanges.readVersion);\r\n checkIsString(versionRanges.writeVersion);\r\n return versionRanges;\r\n }\r\n\r\n /**\r\n * Implement this method to create all tables for this subclass of `VersionedSqliteDb` when a new database file is created. Called from [[createNewDb]].\r\n */\r\n protected abstract createDDL(): void;\r\n\r\n /**\r\n * Create a new database file for the subclass of VersionedSqliteDb.\r\n * @param fileName the name of a local\r\n * @note The required versions are saved as [[myVersion]] or newer for both read and write.\r\n */\r\n public static createNewDb(fileName: LocalFileName) {\r\n const db = new (this as any)() as VersionedSqliteDb; // \"as any\" necessary because VersionedSqliteDb is abstract\r\n IModelJsFs.recursiveMkDirSync(dirname(fileName));\r\n if (fs.existsSync(fileName))\r\n fs.unlinkSync(fileName);\r\n\r\n db.createDb(fileName);\r\n db.createDDL();\r\n const minVer = `^${db.myVersion}`;\r\n db.setRequiredVersions({ readVersion: minVer, writeVersion: minVer });\r\n db.closeDb(true);\r\n }\r\n\r\n /**\r\n * Verify that this version of the software meets the required version range (as appropriate, read or write) stored in the database.\r\n * Throws otherwise.\r\n */\r\n protected verifyVersions() {\r\n const versions = this.getRequiredVersions();\r\n const isReadonly = this.isReadonly; // so we can tell read/write after the file is closed.\r\n const range = isReadonly ? versions.readVersion : versions.writeVersion;\r\n if (semver.satisfies(this.myVersion, range))\r\n return;\r\n\r\n this.closeDb();\r\n const tooNew = semver.gtr(this.myVersion, range);\r\n throw new Error(`${this.nativeDb.getFilePath()} requires ${tooNew ? \"older\" : \"newer\"} version of ${this.constructor.name} for ${isReadonly ? \"read\" : \"write\"}`);\r\n\r\n }\r\n\r\n /**\r\n * Open this database and verify that this version of the software meets the required version range (as appropriate, read or write) stored in the database.\r\n * Throws otherwise.\r\n * @see [[SqliteDb.openDb]] for argument types\r\n */\r\n public override openDb(dbName: string, openMode: OpenMode | SQLiteDb.OpenParams, container?: CloudSqlite.CloudContainer) {\r\n super.openDb(dbName, openMode, container);\r\n this.verifyVersions();\r\n }\r\n\r\n public async upgradeSchema(arg: { dbName: string, lockContainer?: { container: CloudSqlite.CloudContainer, moniker: string }, upgradeFn: () => void }) {\r\n // can't use \"this\" because it checks for version, which we don't want here\r\n return (arg.lockContainer) ?\r\n super.withLockedContainer({ dbName: arg.dbName, ...arg.lockContainer }, async () => arg.upgradeFn) :\r\n super.withOpenDb({ ...arg, openMode: OpenMode.ReadWrite }, arg.upgradeFn);\r\n }\r\n}\r\n\r\n/** @public */\r\nexport namespace SQLiteDb {\r\n /** A semver version range.\r\n * @see https://docs.npmjs.com/cli/v6/using-npm/semver\r\n */\r\n export type VersionRange = string;\r\n\r\n /**\r\n * A pair of semver [[SQLiteDb.VersionRange]]s, one for read and one for write, required to access a [[VersionedSqliteDb]].\r\n * If the version of the software attempting to read or write the database does not satisfy the range, access is denied.\r\n */\r\n export interface RequiredVersionRanges {\r\n /** a range of acceptable persistence versions for reading from a VersionedSqliteDb. */\r\n readonly readVersion: VersionRange;\r\n /** a range of acceptable persistence versions for writing to a VersionedSqliteDb. */\r\n readonly writeVersion: VersionRange;\r\n }\r\n\r\n /** interface for reading and writing to a blob in a SQLiteDb\r\n * @internal\r\n */\r\n export interface BlobIO {\r\n /** Close this BlobIO if it is opened.\r\n * @note this BlobIO *may* be reused after this call by calling `open` again.\r\n */\r\n close(): void;\r\n /** get the total number of bytes in the blob */\r\n getNumBytes(): number;\r\n /** @return true if this BlobIO was successfully opened and may be use to read or write the blob */\r\n isValid(): boolean;\r\n /** Open this BlobIO against a table/row/column in a Db */\r\n open(\r\n /** The database for the blob */\r\n db: IModelJsNative.AnyDb,\r\n args: {\r\n /** the name of the table for the blob*/\r\n tableName: string;\r\n /** the name of the column for the blob */\r\n columnName: string;\r\n /** The rowId of the blob */\r\n row: number;\r\n /** If true, open this BlobIO for write access */\r\n writeable?: boolean;\r\n }): void;\r\n /** Read from a blob\r\n * @returns the contents of the requested byte range\r\n */\r\n read(args: {\r\n /** The number of bytes to read */\r\n numBytes: number;\r\n /** starting offset within the blob to read */\r\n offset: number;\r\n /** If present and of sufficient size, use this ArrayBuffer for the value. */\r\n blob?: ArrayBuffer;\r\n }): Uint8Array;\r\n /** Reposition this BlobIO to a new rowId\r\n * @note this BlobIO must be valid when this methods is called.\r\n */\r\n changeRow(row: number): void;\r\n /** Write to a blob */\r\n write(args: {\r\n /** The number of bytes to write */\r\n numBytes: number;\r\n /** starting offset within the blob to write */\r\n offset: number;\r\n /** the value to write */\r\n blob: ArrayBuffer;\r\n }): void;\r\n }\r\n\r\n /** Default transaction mode for SQLiteDbs.\r\n * @see https://www.sqlite.org/lang_transaction.html\r\n */\r\n export enum DefaultTxnMode {\r\n /** no default transaction is started. You must use BEGIN/COMMIT or SQLite will use implicit transactions */\r\n None = 0,\r\n /** A deferred transaction is started when the file is first opened. This is the default. */\r\n Deferred = 1,\r\n /** An immediate transaction is started when the file is first opened. */\r\n Immediate = 2,\r\n /** An exclusive transaction is started when the file is first opened. */\r\n Exclusive = 3\r\n }\r\n\r\n /** parameters common to opening or creating a new SQLiteDb */\r\n export interface OpenOrCreateParams {\r\n /** If true, do not require that the `be_Prop` table exist */\r\n rawSQLite?: boolean;\r\n /** @see immutable option at https://www.sqlite.org/c3ref/open.html */\r\n immutable?: boolean;\r\n /** Do not attempt to verify that the file is a valid sQLite file before opening. */\r\n skipFileCheck?: boolean;\r\n /** the default transaction mode\r\n * @see [[SQLiteDb.DefaultTxnMode]]\r\n */\r\n defaultTxn?: 0 | 1 | 2 | 3;\r\n /** see query parameters from 'URI Filenames' in https://www.sqlite.org/c3ref/open.html */\r\n queryParam?: string;\r\n }\r\n\r\n /** Parameters for opening an existing SQLiteDb */\r\n export interface OpenParams extends OpenOrCreateParams {\r\n /** use OpenMode.ReadWrite to open the file with write access */\r\n openMode: OpenMode;\r\n }\r\n\r\n /** Size of a SQLiteDb page in bytes */\r\n export interface PageSize {\r\n /** see https://www.sqlite.org/pragma.html#pragma_page_size */\r\n pageSize?: number;\r\n }\r\n\r\n /** Parameters for creating a new SQLiteDb */\r\n export type CreateParams = OpenOrCreateParams & PageSize;\r\n\r\n /** Arguments for `SqliteDb.withOpenDb` */\r\n export interface WithOpenDbArgs {\r\n /** The name of the database to open */\r\n dbName: string;\r\n /** either an object with the open parameters or just OpenMode value. */\r\n openMode?: OpenMode | SQLiteDb.OpenParams;\r\n /** @internal */\r\n container?: CloudSqlite.CloudContainer;\r\n }\r\n\r\n /** Arguments for `SQLiteDb.vacuum` */\r\n export interface VacuumDbArgs extends PageSize {\r\n /** if present, name of new file to [vacuum into](https://www.sqlite.org/lang_vacuum.html) */\r\n into?: LocalFileName;\r\n }\r\n}\r\n"]}
|
|
@@ -22,8 +22,7 @@ export declare class ModelSelector extends DefinitionElement {
|
|
|
22
22
|
constructor(props: ModelSelectorProps, iModel: IModelDb);
|
|
23
23
|
/** @internal */
|
|
24
24
|
toJSON(): ModelSelectorProps;
|
|
25
|
-
|
|
26
|
-
protected collectReferenceConcreteIds(referenceIds: EntityReferenceSet): void;
|
|
25
|
+
protected collectReferenceIds(referenceIds: EntityReferenceSet): void;
|
|
27
26
|
/** Create a Code for a ModelSelector given a name that is meant to be unique within the scope of the specified DefinitionModel.
|
|
28
27
|
* @param iModel The IModelDb
|
|
29
28
|
* @param scopeModelId The Id of the DefinitionModel that contains the ModelSelector and provides the scope for its name.
|
|
@@ -65,8 +64,7 @@ export declare class CategorySelector extends DefinitionElement {
|
|
|
65
64
|
constructor(props: CategorySelectorProps, iModel: IModelDb);
|
|
66
65
|
/** @internal */
|
|
67
66
|
toJSON(): CategorySelectorProps;
|
|
68
|
-
|
|
69
|
-
protected collectReferenceConcreteIds(referenceIds: EntityReferenceSet): void;
|
|
67
|
+
protected collectReferenceIds(referenceIds: EntityReferenceSet): void;
|
|
70
68
|
/** Create a Code for a CategorySelector given a name that is meant to be unique within the scope of the specified DefinitionModel.
|
|
71
69
|
* @param iModel The IModelDb
|
|
72
70
|
* @param scopeModelId The Id of the DefinitionModel that contains the CategorySelector and provides the scope for its name.
|
|
@@ -119,8 +117,7 @@ export declare abstract class ViewDefinition extends DefinitionElement {
|
|
|
119
117
|
protected constructor(props: ViewDefinitionProps, iModel: IModelDb);
|
|
120
118
|
/** @internal */
|
|
121
119
|
toJSON(): ViewDefinitionProps;
|
|
122
|
-
|
|
123
|
-
protected collectReferenceConcreteIds(referenceIds: EntityReferenceSet): void;
|
|
120
|
+
protected collectReferenceIds(referenceIds: EntityReferenceSet): void;
|
|
124
121
|
/** @beta */
|
|
125
122
|
static readonly requiredReferenceKeys: ReadonlyArray<string>;
|
|
126
123
|
/** @alpha */
|
|
@@ -203,8 +200,7 @@ export declare class SpatialViewDefinition extends ViewDefinition3d {
|
|
|
203
200
|
static fromJSON(props: Omit<SpatialViewDefinitionProps, "classFullName">, iModel: IModelDb): SpatialViewDefinition;
|
|
204
201
|
/** Convert this view to its JSON representation. */
|
|
205
202
|
toJSON(): SpatialViewDefinitionProps;
|
|
206
|
-
|
|
207
|
-
protected collectReferenceConcreteIds(referenceIds: EntityReferenceSet): void;
|
|
203
|
+
protected collectReferenceIds(referenceIds: EntityReferenceSet): void;
|
|
208
204
|
/** @beta */
|
|
209
205
|
static readonly requiredReferenceKeys: ReadonlyArray<string>;
|
|
210
206
|
/** @alpha */
|
|
@@ -292,8 +288,7 @@ export declare class ViewDefinition2d extends ViewDefinition {
|
|
|
292
288
|
constructor(props: ViewDefinition2dProps, iModel: IModelDb);
|
|
293
289
|
/** @internal */
|
|
294
290
|
toJSON(): ViewDefinition2dProps;
|
|
295
|
-
|
|
296
|
-
protected collectReferenceConcreteIds(referenceIds: EntityReferenceSet): void;
|
|
291
|
+
protected collectReferenceIds(referenceIds: EntityReferenceSet): void;
|
|
297
292
|
/** Provides access to optional detail settings for this view. */
|
|
298
293
|
get details(): ViewDetails;
|
|
299
294
|
/** Load this view's DisplayStyle2d from the IModelDb. */
|
|
@@ -419,8 +414,7 @@ export declare class ViewAttachment extends GraphicalElement2d {
|
|
|
419
414
|
static get className(): string;
|
|
420
415
|
view: RelatedElement;
|
|
421
416
|
constructor(props: ViewAttachmentProps, iModel: IModelDb);
|
|
422
|
-
|
|
423
|
-
protected collectReferenceConcreteIds(referenceIds: EntityReferenceSet): void;
|
|
417
|
+
protected collectReferenceIds(referenceIds: EntityReferenceSet): void;
|
|
424
418
|
}
|
|
425
419
|
/** The position in space of a Light.
|
|
426
420
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewDefinition.d.ts","sourceRoot":"","sources":["../../src/ViewDefinition.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAQ,SAAS,EAAE,UAAU,EAA2B,MAAM,qBAAqB,CAAC;AAC3F,OAAO,EACL,KAAK,EAAY,OAAO,EAAE,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