@itwin/core-backend 3.3.0-dev.9 → 3.4.0-dev.10
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/BackendHubAccess.d.ts +32 -15
- package/lib/cjs/BackendHubAccess.d.ts.map +1 -1
- package/lib/cjs/BackendHubAccess.js.map +1 -1
- package/lib/cjs/BackendLoggerCategory.d.ts +2 -2
- package/lib/cjs/BackendLoggerCategory.js +2 -2
- package/lib/cjs/BackendLoggerCategory.js.map +1 -1
- package/lib/cjs/BisCoreSchema.d.ts +1 -1
- package/lib/cjs/BisCoreSchema.js +1 -1
- package/lib/cjs/BisCoreSchema.js.map +1 -1
- package/lib/cjs/BriefcaseManager.d.ts +10 -11
- package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
- package/lib/cjs/BriefcaseManager.js +10 -11
- package/lib/cjs/BriefcaseManager.js.map +1 -1
- package/lib/cjs/CheckpointManager.d.ts +28 -6
- package/lib/cjs/CheckpointManager.d.ts.map +1 -1
- package/lib/cjs/CheckpointManager.js +117 -22
- package/lib/cjs/CheckpointManager.js.map +1 -1
- package/lib/cjs/ClassRegistry.js +6 -6
- package/lib/cjs/ClassRegistry.js.map +1 -1
- package/lib/cjs/CodeSpecs.d.ts +1 -1
- package/lib/cjs/CodeSpecs.js +1 -1
- package/lib/cjs/CodeSpecs.js.map +1 -1
- package/lib/cjs/DisplayStyle.d.ts +2 -2
- package/lib/cjs/DisplayStyle.d.ts.map +1 -1
- package/lib/cjs/DisplayStyle.js +14 -17
- package/lib/cjs/DisplayStyle.js.map +1 -1
- package/lib/cjs/Element.d.ts +36 -25
- package/lib/cjs/Element.d.ts.map +1 -1
- package/lib/cjs/Element.js +54 -39
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/ElementTreeWalker.d.ts +163 -0
- package/lib/cjs/ElementTreeWalker.d.ts.map +1 -0
- package/lib/cjs/ElementTreeWalker.js +410 -0
- package/lib/cjs/ElementTreeWalker.js.map +1 -0
- package/lib/cjs/GeoCoordConfig.d.ts +14 -0
- package/lib/cjs/GeoCoordConfig.d.ts.map +1 -0
- package/lib/cjs/GeoCoordConfig.js +74 -0
- package/lib/cjs/GeoCoordConfig.js.map +1 -0
- package/lib/cjs/HubMock.d.ts +94 -0
- package/lib/cjs/HubMock.d.ts.map +1 -0
- package/lib/cjs/HubMock.js +191 -0
- package/lib/cjs/HubMock.js.map +1 -0
- package/lib/cjs/IModelDb.d.ts +39 -15
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +79 -35
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/IModelHost.d.ts +75 -33
- package/lib/cjs/IModelHost.d.ts.map +1 -1
- package/lib/cjs/IModelHost.js +66 -80
- package/lib/cjs/IModelHost.js.map +1 -1
- package/lib/cjs/IpcHost.d.ts +2 -2
- package/lib/cjs/IpcHost.d.ts.map +1 -1
- package/lib/cjs/IpcHost.js +1 -1
- package/lib/cjs/IpcHost.js.map +1 -1
- package/lib/cjs/LocalHub.d.ts +163 -0
- package/lib/cjs/LocalHub.d.ts.map +1 -0
- package/lib/cjs/LocalHub.js +588 -0
- package/lib/cjs/LocalHub.js.map +1 -0
- package/lib/cjs/LocalhostIpcHost.d.ts +2 -2
- package/lib/cjs/LocalhostIpcHost.d.ts.map +1 -1
- package/lib/cjs/LocalhostIpcHost.js +16 -0
- package/lib/cjs/LocalhostIpcHost.js.map +1 -1
- package/lib/cjs/RpcBackend.d.ts +3 -1
- package/lib/cjs/RpcBackend.d.ts.map +1 -1
- package/lib/cjs/RpcBackend.js +27 -3
- package/lib/cjs/RpcBackend.js.map +1 -1
- package/lib/cjs/SQLiteDb.d.ts +138 -30
- package/lib/cjs/SQLiteDb.d.ts.map +1 -1
- package/lib/cjs/SQLiteDb.js +110 -38
- package/lib/cjs/SQLiteDb.js.map +1 -1
- package/lib/cjs/SqliteStatement.d.ts +8 -0
- package/lib/cjs/SqliteStatement.d.ts.map +1 -1
- package/lib/cjs/SqliteStatement.js +10 -0
- package/lib/cjs/SqliteStatement.js.map +1 -1
- package/lib/cjs/ViewDefinition.d.ts +6 -6
- package/lib/cjs/ViewDefinition.d.ts.map +1 -1
- package/lib/cjs/ViewDefinition.js +20 -20
- package/lib/cjs/ViewDefinition.js.map +1 -1
- package/lib/cjs/{ViewStateHydrater.d.ts → ViewStateHydrator.d.ts} +3 -3
- package/lib/cjs/ViewStateHydrator.d.ts.map +1 -0
- package/lib/cjs/{ViewStateHydrater.js → ViewStateHydrator.js} +15 -29
- package/lib/cjs/ViewStateHydrator.js.map +1 -0
- package/lib/cjs/assets/Settings/Schemas/Cloud.Schema.json +68 -0
- package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +22 -0
- package/lib/cjs/assets/Settings/Schemas/Workspace.Schema.json +53 -0
- package/lib/cjs/assets/Settings/backend.setting.json5 +139 -0
- package/lib/cjs/core-backend.d.ts +11 -8
- package/lib/cjs/core-backend.d.ts.map +1 -1
- package/lib/cjs/core-backend.js +11 -8
- package/lib/cjs/core-backend.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +3 -2
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +7 -2
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +8 -12
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
- package/lib/cjs/workspace/Settings.d.ts +8 -3
- package/lib/cjs/workspace/Settings.d.ts.map +1 -1
- package/lib/cjs/workspace/Settings.js +9 -0
- package/lib/cjs/workspace/Settings.js.map +1 -1
- package/lib/cjs/workspace/SettingsSchemas.d.ts +76 -0
- package/lib/cjs/workspace/SettingsSchemas.d.ts.map +1 -0
- package/lib/cjs/workspace/SettingsSchemas.js +192 -0
- package/lib/cjs/workspace/SettingsSchemas.js.map +1 -0
- package/lib/cjs/workspace/Workspace.d.ts +240 -144
- package/lib/cjs/workspace/Workspace.d.ts.map +1 -1
- package/lib/cjs/workspace/Workspace.js +258 -95
- package/lib/cjs/workspace/Workspace.js.map +1 -1
- package/package.json +26 -21
- package/lib/cjs/ViewStateHydrater.d.ts.map +0 -1
- package/lib/cjs/ViewStateHydrater.js.map +0 -1
- package/lib/cjs/assets/Settings.schema.json +0 -25
- package/lib/cjs/workspace/SettingsSpecRegistry.d.ts +0 -68
- package/lib/cjs/workspace/SettingsSpecRegistry.d.ts.map +0 -1
- package/lib/cjs/workspace/SettingsSpecRegistry.js +0 -122
- package/lib/cjs/workspace/SettingsSpecRegistry.js.map +0 -1
package/lib/cjs/SQLiteDb.js
CHANGED
|
@@ -8,46 +8,104 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.SQLiteDb = void 0;
|
|
11
|
+
const imodeljs_native_1 = require("@bentley/imodeljs-native");
|
|
12
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
11
13
|
const IModelHost_1 = require("./IModelHost");
|
|
12
14
|
const SqliteStatement_1 = require("./SqliteStatement");
|
|
15
|
+
/* eslint-disable @typescript-eslint/unified-signatures */
|
|
13
16
|
/** A SQLiteDb file
|
|
14
17
|
* @public
|
|
15
18
|
*/
|
|
16
19
|
class SQLiteDb {
|
|
17
20
|
constructor() {
|
|
21
|
+
/** @internal */
|
|
22
|
+
this.nativeDb = new IModelHost_1.IModelHost.platform.SQLiteDb();
|
|
18
23
|
this._sqliteStatementCache = new SqliteStatement_1.StatementCache();
|
|
19
|
-
this._nativeDb = new IModelHost_1.IModelHost.platform.SQLiteDb();
|
|
20
24
|
}
|
|
21
25
|
/** @internal */
|
|
22
|
-
|
|
23
|
-
return
|
|
26
|
+
static createCloudContainer(args) {
|
|
27
|
+
return new IModelHost_1.IModelHost.platform.CloudContainer(args);
|
|
24
28
|
}
|
|
25
|
-
/**
|
|
29
|
+
/** @internal */
|
|
30
|
+
static createCloudCache(args) {
|
|
31
|
+
return new IModelHost_1.IModelHost.platform.CloudCache(args);
|
|
32
|
+
}
|
|
33
|
+
/** @internal */
|
|
34
|
+
static startCloudPrefetch(container, dbName, args) {
|
|
35
|
+
return new IModelHost_1.IModelHost.platform.CloudPrefetch(container, dbName, args);
|
|
36
|
+
}
|
|
37
|
+
/** @internal */
|
|
38
|
+
static createBlobIO() {
|
|
39
|
+
return new IModelHost_1.IModelHost.platform.BlobIO();
|
|
40
|
+
}
|
|
41
|
+
/** alias for closeDb. */
|
|
26
42
|
dispose() {
|
|
27
|
-
if (!this._nativeDb)
|
|
28
|
-
return;
|
|
29
43
|
this.closeDb();
|
|
30
|
-
this._nativeDb.dispose();
|
|
31
|
-
this._nativeDb = undefined;
|
|
32
44
|
}
|
|
33
45
|
/** Create a SQLiteDb
|
|
34
|
-
* @param
|
|
46
|
+
* @param dbName The path to the SQLiteDb file to create.
|
|
35
47
|
*/
|
|
36
|
-
createDb(
|
|
37
|
-
this.nativeDb.createDb(
|
|
48
|
+
createDb(dbName, container, params) {
|
|
49
|
+
this.nativeDb.createDb(dbName, container, params);
|
|
50
|
+
}
|
|
51
|
+
/** @internal */
|
|
52
|
+
openDb(dbName, openMode, container) {
|
|
53
|
+
this.nativeDb.openDb(dbName, openMode, container);
|
|
38
54
|
}
|
|
39
|
-
/**
|
|
40
|
-
* @param
|
|
55
|
+
/** Close SQLiteDb.
|
|
56
|
+
* @param saveChanges if true, call `saveChanges` before closing db.
|
|
41
57
|
*/
|
|
42
|
-
|
|
43
|
-
this.
|
|
58
|
+
closeDb(saveChanges) {
|
|
59
|
+
if (saveChanges && this.isOpen)
|
|
60
|
+
this.saveChanges();
|
|
61
|
+
this._sqliteStatementCache.clear();
|
|
62
|
+
this.nativeDb.closeDb();
|
|
44
63
|
}
|
|
45
64
|
/** Returns true if the SQLiteDb is open */
|
|
46
65
|
get isOpen() { return this.nativeDb.isOpen(); }
|
|
47
|
-
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
66
|
+
/**
|
|
67
|
+
* 1. open a database
|
|
68
|
+
* 2. call a function supplying the open SQliteDb as argument. If it is async, await its return.
|
|
69
|
+
* 3. close the database (even if exceptions are thrown)
|
|
70
|
+
*/
|
|
71
|
+
static withOpenDb(args, operation) {
|
|
72
|
+
var _a;
|
|
73
|
+
const db = new SQLiteDb();
|
|
74
|
+
db.openDb(args.dbName, (_a = args.openMode) !== null && _a !== void 0 ? _a : core_bentley_1.OpenMode.Readonly, args.container);
|
|
75
|
+
let fromPromise = false;
|
|
76
|
+
try {
|
|
77
|
+
const result = operation(db);
|
|
78
|
+
if (result instanceof Promise) {
|
|
79
|
+
fromPromise = true;
|
|
80
|
+
const doClose = () => db.closeDb();
|
|
81
|
+
result.then(doClose, doClose);
|
|
82
|
+
}
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
finally {
|
|
86
|
+
if (!fromPromise)
|
|
87
|
+
db.closeDb();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* 1. acquire the write lock on a CloudContainer
|
|
92
|
+
* 2. open a ReadWrite database in the container
|
|
93
|
+
* 3. call a function with the opened database as an argument
|
|
94
|
+
* 4. close the database
|
|
95
|
+
* 5. release the write lock and upload changes.
|
|
96
|
+
* @internal
|
|
97
|
+
*/
|
|
98
|
+
static async withLockedContainer(args,
|
|
99
|
+
/** an asynchronous operation performed on the database with the write lock held. */
|
|
100
|
+
operation) {
|
|
101
|
+
const fn = async () => SQLiteDb.withOpenDb({ ...args, openMode: core_bentley_1.OpenMode.ReadWrite }, operation);
|
|
102
|
+
await imodeljs_native_1.CloudSqlite.withWriteLock(args.user, args.container, fn, args.busyHandler);
|
|
103
|
+
}
|
|
104
|
+
/** vacuum this database
|
|
105
|
+
* @see https://www.sqlite.org/lang_vacuum.html
|
|
106
|
+
*/
|
|
107
|
+
vacuum(args) {
|
|
108
|
+
this.nativeDb.vacuum(args);
|
|
51
109
|
}
|
|
52
110
|
/** Commit the outermost transaction, writing changes to the file. Then, restart the transaction. */
|
|
53
111
|
saveChanges() {
|
|
@@ -58,17 +116,15 @@ class SQLiteDb {
|
|
|
58
116
|
this.nativeDb.abandonChanges();
|
|
59
117
|
}
|
|
60
118
|
/**
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
* @public
|
|
71
|
-
*/
|
|
119
|
+
* Use a prepared SQL statement, potentially from the statement cache. If the requested statement doesn't exist
|
|
120
|
+
* in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved
|
|
121
|
+
* in the statement cache so it can be reused in the future. Use this method for SQL statements that will be
|
|
122
|
+
* reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding
|
|
123
|
+
* the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withSqliteStatement]].
|
|
124
|
+
* @param sql The SQLite SQL statement to execute
|
|
125
|
+
* @param callback the callback to invoke on the prepared statement
|
|
126
|
+
* @returns the value returned by `callback`.
|
|
127
|
+
*/
|
|
72
128
|
withPreparedSqliteStatement(sql, callback) {
|
|
73
129
|
var _a;
|
|
74
130
|
const stmt = (_a = this._sqliteStatementCache.findAndRemove(sql)) !== null && _a !== void 0 ? _a : this.prepareSqliteStatement(sql);
|
|
@@ -89,14 +145,13 @@ class SQLiteDb {
|
|
|
89
145
|
}
|
|
90
146
|
}
|
|
91
147
|
/**
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
*/
|
|
148
|
+
* Prepared and execute a callback on a SQL statement. After the callback completes the statement is disposed.
|
|
149
|
+
* Use this method for SQL statements are either not expected to be reused, or are not expensive to prepare.
|
|
150
|
+
* For statements that will be reused often, instead use [[withPreparedSqliteStatement]].
|
|
151
|
+
* @param sql The SQLite SQL statement to execute
|
|
152
|
+
* @param callback the callback to invoke on the prepared statement
|
|
153
|
+
* @returns the value returned by `callback`.
|
|
154
|
+
*/
|
|
100
155
|
withSqliteStatement(sql, callback) {
|
|
101
156
|
const stmt = this.prepareSqliteStatement(sql);
|
|
102
157
|
const release = () => stmt.dispose();
|
|
@@ -137,4 +192,21 @@ class SQLiteDb {
|
|
|
137
192
|
}
|
|
138
193
|
}
|
|
139
194
|
exports.SQLiteDb = SQLiteDb;
|
|
195
|
+
/** @public */
|
|
196
|
+
(function (SQLiteDb) {
|
|
197
|
+
/** Default transaction mode for SQLiteDbs.
|
|
198
|
+
* @see https://www.sqlite.org/lang_transaction.html
|
|
199
|
+
*/
|
|
200
|
+
let DefaultTxnMode;
|
|
201
|
+
(function (DefaultTxnMode) {
|
|
202
|
+
/** no default transaction is started. You must use BEGIN/COMMIT or SQLite will use implicit transactions */
|
|
203
|
+
DefaultTxnMode[DefaultTxnMode["None"] = 0] = "None";
|
|
204
|
+
/** A deferred transaction is started when the file is first opened. This is the default. */
|
|
205
|
+
DefaultTxnMode[DefaultTxnMode["Deferred"] = 1] = "Deferred";
|
|
206
|
+
/** An immediate transaction is started when the file is first opened. */
|
|
207
|
+
DefaultTxnMode[DefaultTxnMode["Immediate"] = 2] = "Immediate";
|
|
208
|
+
/** An exclusive transaction is started when the file is first opened. */
|
|
209
|
+
DefaultTxnMode[DefaultTxnMode["Exclusive"] = 3] = "Exclusive";
|
|
210
|
+
})(DefaultTxnMode = SQLiteDb.DefaultTxnMode || (SQLiteDb.DefaultTxnMode = {}));
|
|
211
|
+
})(SQLiteDb = exports.SQLiteDb || (exports.SQLiteDb = {}));
|
|
140
212
|
//# sourceMappingURL=SQLiteDb.js.map
|
package/lib/cjs/SQLiteDb.js.map
CHANGED
|
@@ -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AED;;;;SAIK;IACE,sBAAsB,CAAC,GAAW,EAAE,SAAS,GAAG,IAAI;QACzD,MAAM,IAAI,GAAG,IAAI,iCAAe,CAAC,GAAG,CAAC,CAAC;QACtC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QACvC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,+BAA+B;IACxB,UAAU,CAAC,GAAW;QAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC;QAC9C,IAAI;YACF,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;SACpB;gBAAS;YACR,IAAI,CAAC,OAAO,EAAE,CAAC;SAChB;IACH,CAAC;CACF;AAlID,4BAkIC","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 { DbResult, IDisposable, OpenMode } from \"@itwin/core-bentley\";\r\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\nimport { IModelHost } from \"./IModelHost\";\r\nimport { SqliteStatement, StatementCache } from \"./SqliteStatement\";\r\n\r\n/** A SQLiteDb file\r\n * @public\r\n */\r\nexport class SQLiteDb implements IDisposable {\r\n private _nativeDb?: IModelJsNative.SQLiteDb;\r\n private _sqliteStatementCache = new StatementCache<SqliteStatement>();\r\n\r\n /** @internal */\r\n public get nativeDb(): IModelJsNative.SQLiteDb {\r\n return this._nativeDb!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n }\r\n\r\n constructor() {\r\n this._nativeDb = new IModelHost.platform.SQLiteDb();\r\n }\r\n /** Call this function when finished with this SQLiteDb. This releases the native resources */\r\n public dispose(): void {\r\n if (!this._nativeDb)\r\n return;\r\n\r\n this.closeDb();\r\n this._nativeDb.dispose();\r\n this._nativeDb = undefined;\r\n }\r\n\r\n /** Create a SQLiteDb\r\n * @param pathName The path to the SQLiteDb file to create.\r\n */\r\n public createDb(pathName: string): void {\r\n this.nativeDb.createDb(pathName);\r\n }\r\n\r\n /** Open a SQLiteDb.\r\n * @param pathName The path to the SQLiteDb file to open\r\n */\r\n public openDb(pathName: string, openMode: OpenMode): void {\r\n this.nativeDb.openDb(pathName, openMode);\r\n }\r\n\r\n /** Returns true if the SQLiteDb is open */\r\n public get isOpen(): boolean { return this.nativeDb.isOpen(); }\r\n\r\n /** Close SQLiteDb. */\r\n public closeDb(): void {\r\n this._sqliteStatementCache.clear();\r\n this.nativeDb.closeDb();\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 * @see [[withPreparedStatement]]\r\n * @public\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: T = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\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 * @public\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: T = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\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"]}
|
|
1
|
+
{"version":3,"file":"SQLiteDb.js","sourceRoot":"","sources":["../../src/SQLiteDb.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,8DAAuE;AACvE,sDAAsE;AAEtE,6CAA0C;AAC1C,uDAAoE;AAEpE,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;IAmNxE,CAAC;IAj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,OAAO,GAAG,CAAC;SACZ;QAAC,OAAO,GAAG,EAAE;YACZ,OAAO,EAAE,CAAC;YACV,MAAM,GAAG,CAAC;SACX;IACH,CAAC;IAED;;;;SAIK;IACE,sBAAsB,CAAC,GAAW,EAAE,SAAS,GAAG,IAAI;QACzD,MAAM,IAAI,GAAG,IAAI,iCAAe,CAAC,GAAG,CAAC,CAAC;QACtC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QACvC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,+BAA+B;IACxB,UAAU,CAAC,GAAW;QAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC;QAC9C,IAAI;YACF,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;SACpB;gBAAS;YACR,IAAI,CAAC,OAAO,EAAE,CAAC;SAChB;IACH,CAAC;CACF;AAtND,4BAsNC;AAED,cAAc;AACd,WAAiB,QAAQ;IAcvB;;QAEI;IACJ,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;AA8BH,CAAC,EAxDgB,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAwDxB","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 { CloudSqlite, IModelJsNative } from \"@bentley/imodeljs-native\";\r\nimport { DbResult, IDisposable, OpenMode } from \"@itwin/core-bentley\";\r\nimport { LocalFileName } from \"@itwin/core-common\";\r\nimport { IModelHost } from \"./IModelHost\";\r\nimport { SqliteStatement, StatementCache } from \"./SqliteStatement\";\r\n\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 createCloudContainer(args: CloudSqlite.ContainerAccessProps): SQLiteDb.CloudContainer {\r\n return new IModelHost.platform.CloudContainer(args);\r\n }\r\n /** @internal */\r\n public static createCloudCache(args: CloudSqlite.CacheProps): SQLiteDb.CloudCache {\r\n return new IModelHost.platform.CloudCache(args);\r\n }\r\n /** @internal */\r\n public static startCloudPrefetch(container: SQLiteDb.CloudContainer, dbName: string, args?: CloudSqlite.PrefetchProps): SQLiteDb.CloudPrefetch {\r\n return new IModelHost.platform.CloudPrefetch(container, dbName, args);\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, container?: SQLiteDb.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 * @internal\r\n */\r\n public openDb(dbName: string, openMode: OpenMode | SQLiteDb.OpenParams, container?: SQLiteDb.CloudContainer): void;\r\n\r\n /** @internal */\r\n public openDb(dbName: string, openMode: OpenMode | SQLiteDb.OpenParams, container?: SQLiteDb.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.\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 the SQLiteDb is open */\r\n public get isOpen(): boolean { return this.nativeDb.isOpen(); }\r\n\r\n /**\r\n * 1. open a database\r\n * 2. call a function supplying the open SQliteDb as argument. If it is async, await its return.\r\n * 3. close the database (even if exceptions are thrown)\r\n */\r\n public static withOpenDb<T>(args: {\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?: SQLiteDb.CloudContainer;\r\n }, operation: (db: SQLiteDb) => T): T {\r\n const db = new SQLiteDb();\r\n db.openDb(args.dbName, args.openMode ?? OpenMode.Readonly, args.container);\r\n let fromPromise = false;\r\n\r\n try {\r\n const result = operation(db);\r\n if (result instanceof Promise) {\r\n fromPromise = true;\r\n const doClose = () => db.closeDb();\r\n result.then(doClose, doClose);\r\n }\r\n return result;\r\n } finally {\r\n if (!fromPromise)\r\n db.closeDb();\r\n }\r\n }\r\n\r\n /**\r\n * 1. acquire the write lock on a CloudContainer\r\n * 2. open a ReadWrite database in the container\r\n * 3. call a function with the opened database as an argument\r\n * 4. close the database\r\n * 5. release the write lock and upload changes.\r\n * @internal\r\n */\r\n public static async withLockedContainer(\r\n args: {\r\n /** the name to be displayed in the event of lock collisions */\r\n user: string;\r\n /** the name of the database within the container */\r\n dbName: string;\r\n /** the CloudContainer on which the operation will be performed */\r\n container: SQLiteDb.CloudContainer;\r\n /** if present, function called when the write lock is currently held by another user. */\r\n busyHandler?: CloudSqlite.WriteLockBusyHandler;\r\n },\r\n /** an asynchronous operation performed on the database with the write lock held. */\r\n operation: (db: SQLiteDb) => Promise<void>) {\r\n const fn = async () => SQLiteDb.withOpenDb({ ...args, openMode: OpenMode.ReadWrite }, operation);\r\n await CloudSqlite.withWriteLock(args.user, args.container, fn, 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?: {\r\n /** new page size\r\n * @see https://www.sqlite.org/pragma.html#pragma_page_size\r\n */\r\n pageSize?: number;\r\n /** if present, name of new file to vacuum into */\r\n into?: LocalFileName;\r\n }) {\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: T = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\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: T = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\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 /** A CloudSqlite container that may be connected to a CloudCache.\r\n * @internal\r\n */\r\n export type CloudContainer = IModelJsNative.CloudContainer;\r\n /** @internal */\r\n export type CloudCache = IModelJsNative.CloudCache;\r\n /** @internal */\r\n export type CloudPrefetch = IModelJsNative.CloudPrefetch;\r\n /** Incremental IO for blobs\r\n * @internal\r\n */\r\n export type BlobIO = IModelJsNative.BlobIO;\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 /** Parameters for creating a new SQLiteDb */\r\n export interface CreateParams extends OpenOrCreateParams {\r\n /** see https://www.sqlite.org/pragma.html#pragma_page_size */\r\n pageSize?: number;\r\n }\r\n\r\n}\r\n"]}
|
|
@@ -111,6 +111,10 @@ export declare class SqliteStatement implements IterableIterator<any>, IDisposab
|
|
|
111
111
|
* @param val blob to bind.
|
|
112
112
|
*/
|
|
113
113
|
bindBlob(parameter: BindParameter, blob: Uint8Array): void;
|
|
114
|
+
/** Bind null to a parameter
|
|
115
|
+
* @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')
|
|
116
|
+
*/
|
|
117
|
+
bindNull(parameter: BindParameter): void;
|
|
114
118
|
/** Bind values to all parameters in the statement.
|
|
115
119
|
* @param values The values to bind to the parameters.
|
|
116
120
|
* Pass an *array* of values if the parameters are *positional*.
|
|
@@ -141,6 +145,10 @@ export declare class SqliteStatement implements IterableIterator<any>, IDisposab
|
|
|
141
145
|
* @param columnIx Index of SQL column in query result (0-based)
|
|
142
146
|
*/
|
|
143
147
|
getValue(columnIx: number): SqliteValue;
|
|
148
|
+
/** Get a size in bytes of a blob or text column
|
|
149
|
+
* @param colIndex Index of SQL column in query result (0-based)
|
|
150
|
+
*/
|
|
151
|
+
getColumnBytes(colIndex: number): number;
|
|
144
152
|
/** Get a value as a blob
|
|
145
153
|
* @param colIndex Index of SQL column in query result (0-based)
|
|
146
154
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SqliteStatement.d.ts","sourceRoot":"","sources":["../../src/SqliteStatement.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAU,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAU,MAAM,qBAAqB,CAAC;AAEpG,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAK1D;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,EAAE,CAAC,EAAE,UAAU,CAAC;IAChB,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAED;;GAEG;AACH,oBAAY,aAAa,GAAG,MAAM,GAAG,MAAM,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,eAAgB,YAAW,gBAAgB,CAAC,GAAG,CAAC,EAAE,WAAW;IAGrD,OAAO,CAAC,IAAI;IAF/B,OAAO,CAAC,KAAK,CAA6C;gBAE/B,IAAI,EAAE,MAAM;IACvC,IAAW,IAAI,+CAAyB;IACxC,IAAW,GAAG,WAAwB;IAEtC,oEAAoE;IACpE,IAAW,UAAU,IAAI,OAAO,CAAqC;IAErE;;;;;;OAMG;IACI,OAAO,CAAC,EAAE,EAAE,cAAc,CAAC,KAAK,GAAG,cAAc,CAAC,IAAI,GAAG,cAAc,CAAC,QAAQ,EAAE,SAAS,UAAO,GAAG,IAAI;IAOhH;;OAEG;IACH,IAAW,UAAU,IAAI,OAAO,CAE/B;IAED;OACG;IACI,KAAK,IAAI,IAAI;IAIpB,sHAAsH;IAC/G,OAAO,IAAI,IAAI;IAOtB;;;;;;;;;;;;;;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/B,SAAS,IAAI,MAAM;IAC1B,uCAAuC;IAChC,UAAU,IAAI,MAAM;IAC3B,sCAAsC;IAC/B,SAAS,IAAI,MAAM;IAC1B,mCAAmC;IAC5B,KAAK,IAAI,UAAU;IAC1B,oCAAoC;IAC7B,OAAO,IAAI,UAAU;CAC7B;AAED,UAAU,SAAS;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,IAAI,IAAI,CAAC;IAChB,KAAK,IAAI,IAAI,CAAC;IACd,aAAa,IAAI,IAAI,CAAC;CACvB;AAED;;;;GAIG;AACH,qBAAa,cAAc,CAAC,IAAI,SAAS,SAAS;IAChD,OAAO,CAAC,MAAM,CAAuB;gBAElB,QAAQ,SAAK;IAIhC,IAAW,IAAI,WAA+B;IACvC,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAiB9B,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAI5C,KAAK;CAIb"}
|
|
@@ -165,6 +165,12 @@ class SqliteStatement {
|
|
|
165
165
|
bindBlob(parameter, blob) {
|
|
166
166
|
this.checkBind(this._stmt.bindBlob(parameter, blob));
|
|
167
167
|
}
|
|
168
|
+
/** Bind null to a parameter
|
|
169
|
+
* @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')
|
|
170
|
+
*/
|
|
171
|
+
bindNull(parameter) {
|
|
172
|
+
this.checkBind(this._stmt.bindNull(parameter));
|
|
173
|
+
}
|
|
168
174
|
/** Bind values to all parameters in the statement.
|
|
169
175
|
* @param values The values to bind to the parameters.
|
|
170
176
|
* Pass an *array* of values if the parameters are *positional*.
|
|
@@ -217,6 +223,10 @@ class SqliteStatement {
|
|
|
217
223
|
* @param columnIx Index of SQL column in query result (0-based)
|
|
218
224
|
*/
|
|
219
225
|
getValue(columnIx) { return new SqliteValue(this._stmt, columnIx); }
|
|
226
|
+
/** Get a size in bytes of a blob or text column
|
|
227
|
+
* @param colIndex Index of SQL column in query result (0-based)
|
|
228
|
+
*/
|
|
229
|
+
getColumnBytes(colIndex) { return this._stmt.getColumnBytes(colIndex); }
|
|
220
230
|
/** Get a value as a blob
|
|
221
231
|
* @param colIndex Index of SQL column in query result (0-based)
|
|
222
232
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SqliteStatement.js","sourceRoot":"","sources":["../../src/SqliteStatement.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAoG;AACpG,oDAA4D;AAE5D,6CAA0C;AAmB1C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAa,eAAe;IAG1B,YAA2B,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAI,CAAC;IAC5C,IAAW,IAAI,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACxC,IAAW,GAAG,KAAK,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAEtC,oEAAoE;IACpE,IAAW,UAAU,KAAc,OAAO,SAAS,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAErE;;;;;;OAMG;IACI,OAAO,CAAC,EAAwE,EAAE,SAAS,GAAG,IAAI;QACvG,IAAI,IAAI,CAAC,UAAU;YACjB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACzD,IAAI,CAAC,KAAK,GAAG,IAAI,uBAAU,CAAC,QAAQ,CAAC,eAAe,EAAE,CAAC;QACvD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC/C,CAAC;IAED;;OAEG;IACH,IAAW,UAAU;QACnB,OAAO,IAAI,CAAC,KAAM,CAAC,UAAU,EAAE,CAAC;IAClC,CAAC;IAED;OACG;IACI,KAAK;QACV,IAAI,CAAC,KAAM,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;IAED,sHAAsH;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AI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;QAC9C,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;CACF;AAjCD,wCAiCC","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 SQLite\r\n */\r\n\r\nimport { assert, DbResult, GuidString, Id64String, IDisposable, LRUMap } from \"@itwin/core-bentley\";\r\nimport { ECJsNames, IModelError } from \"@itwin/core-common\";\r\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\nimport { IModelHost } from \"./IModelHost\";\r\n\r\n/* eslint-disable @typescript-eslint/no-non-null-assertion */\r\n\r\n/** Marks a string as either an [Id64String]($core-bentley) or [GuidString]($core-bentley), so\r\n * that it can be passed to the [bindValue]($backend.SqliteStatement) or [bindValues]($backend.SqliteStatement)\r\n * methods of [SqliteStatement]($backend).\r\n * @internal\r\n */\r\nexport interface StringParam {\r\n id?: Id64String;\r\n guid?: GuidString;\r\n}\r\n\r\n/** parameter Index (1-based), or name of the parameter (including the initial ':', '@' or '$')\r\n * @public\r\n */\r\nexport type BindParameter = number | string;\r\n\r\n/** Executes SQLite SQL statements.\r\n *\r\n * A statement must be prepared before it can be executed, and it must be released when no longer needed.\r\n * See [IModelDb.withPreparedSqliteStatement]($backend) or\r\n * [ECDb.withPreparedSqliteStatement]($backend) for a convenient and\r\n * reliable way to prepare, execute, and then release a statement.\r\n *\r\n * A statement may contain parameters that must be filled in before use by calling [SqliteStatement.bindValue]($backend)\r\n * or [SqliteStatement.bindValues]($backend).\r\n *\r\n * Once prepared (and parameters are bound, if any), the statement is executed by calling [SqliteStatement.step]($backend).\r\n * In case of an **SQL SELECT** statement, the current row can be retrieved with [SqliteStatement.getRow]($backend) as\r\n * a whole, or with [SqliteStatement.getValue]($backend) when individual values are needed.\r\n * Alternatively, query results of an **SQL SELECT** statement can be stepped through by using\r\n * standard iteration syntax, such as `for of`.\r\n *\r\n * > Preparing a statement can be time-consuming. The best way to reduce the effect of this overhead is to cache and reuse prepared\r\n * > statements. A cached prepared statement may be used in different places in an app, as long as the statement is general enough.\r\n * > The key to making this strategy work is to phrase a statement in a general way and use placeholders to represent parameters that will vary on each use.\r\n * @public\r\n */\r\nexport class SqliteStatement implements IterableIterator<any>, IDisposable {\r\n private _stmt: IModelJsNative.SqliteStatement | undefined;\r\n\r\n public constructor(private _sql: string) { }\r\n public get stmt() { return this._stmt; }\r\n public get sql() { return this._sql; }\r\n\r\n /** Check if this statement has been prepared successfully or not */\r\n public get isPrepared(): boolean { return undefined !== this._stmt; }\r\n\r\n /** Prepare this statement prior to first use.\r\n * @param db The DgnDb or ECDb to prepare the statement against\r\n * @param sql The SQL statement string to prepare\r\n * @param logErrors Determine if errors are logged or not\r\n * @throws if the SQL statement cannot be prepared. Normally, prepare fails due to SQL syntax errors or references to tables or properties that do not exist.\r\n * The error.message property will provide details.\r\n */\r\n public prepare(db: IModelJsNative.DgnDb | IModelJsNative.ECDb | IModelJsNative.SQLiteDb, logErrors = true): void {\r\n if (this.isPrepared)\r\n throw new Error(\"SqliteStatement is already prepared\");\r\n this._stmt = new IModelHost.platform.SqliteStatement();\r\n this._stmt.prepare(db, this._sql, logErrors);\r\n }\r\n\r\n /** Indicates whether the prepared statement makes no **direct* changes to the content of the file\r\n * or not. See [SQLite docs](https://www.sqlite.org/c3ref/stmt_readonly.html) for details.\r\n */\r\n public get isReadonly(): boolean {\r\n return this._stmt!.isReadonly();\r\n }\r\n\r\n /** Reset this statement so that the next call to step will return the first row, if any.\r\n */\r\n public reset(): void {\r\n this._stmt!.reset();\r\n }\r\n\r\n /** Call this function when finished with this statement. This releases the native resources held by the statement. */\r\n public dispose(): void {\r\n if (this._stmt) {\r\n this._stmt.dispose(); // free native statement\r\n this._stmt = undefined;\r\n }\r\n }\r\n\r\n /** Binds a value to the specified SQL parameter.\r\n * The value must be of one of these types:\r\n * JavaScript Type | SQLite Type\r\n * --- | ---\r\n * undefined | NULL\r\n * boolean | INTEGER with true being bound as 1 and false as 0\r\n * number | INTEGER if number is integral or REAL if number is not integral\r\n * string | TEXT\r\n * Uint8Array or ArrayBuffer | BLOB\r\n * [StringParam]($backend) where member **id** is set | INTEGER\r\n * [StringParam]($backend) where member **guid** is set | BLOB\r\n *\r\n * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')\r\n * @param value Value to bind.\r\n * @throws [IModelError]($common) if the value is of an unsupported type or in\r\n * case of other binding errors.\r\n */\r\n public bindValue(parameter: BindParameter, value: any): void {\r\n let stat: DbResult;\r\n if (value === undefined || value === null) {\r\n stat = this._stmt!.bindNull(parameter);\r\n } else if (typeof (value) === \"number\") {\r\n if (Number.isInteger(value))\r\n stat = this._stmt!.bindInteger(parameter, value);\r\n else\r\n stat = this._stmt!.bindDouble(parameter, value);\r\n } else if (typeof (value) === \"boolean\") {\r\n stat = this._stmt!.bindInteger(parameter, value ? 1 : 0);\r\n } else if (typeof (value) === \"string\") {\r\n stat = this._stmt!.bindString(parameter, value);\r\n } else if (!!value.id) {\r\n stat = this._stmt!.bindId(parameter, value.id);\r\n } else if (!!value.guid) {\r\n stat = this._stmt!.bindGuid(parameter, value.guid);\r\n } else if (value instanceof Uint8Array) {\r\n stat = this._stmt!.bindBlob(parameter, value);\r\n } else\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, `Parameter value ${value} is of an unsupported data type.`);\r\n\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, \"Error in bindValue\");\r\n }\r\n\r\n private checkBind(stat: DbResult) {\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, \"SQLite Bind error\");\r\n }\r\n /** Bind an integer parameter\r\n * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')\r\n * @param val integer to bind.\r\n */\r\n public bindInteger(parameter: BindParameter, val: number) {\r\n this.checkBind(this._stmt!.bindInteger(parameter, val));\r\n }\r\n /** Bind a double parameter\r\n * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')\r\n * @param val double to bind.\r\n */\r\n public bindDouble(parameter: BindParameter, val: number) {\r\n this.checkBind(this._stmt!.bindDouble(parameter, val));\r\n }\r\n /** Bind a string parameter\r\n * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')\r\n * @param val string to bind.\r\n */\r\n public bindString(parameter: BindParameter, val: string) {\r\n this.checkBind(this._stmt!.bindString(parameter, val));\r\n }\r\n /** Bind an Id64String parameter as a 64-bit integer\r\n * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')\r\n * @param val Id to bind.\r\n */\r\n public bindId(parameter: BindParameter, id: Id64String) {\r\n this.checkBind(this._stmt!.bindId(parameter, id));\r\n }\r\n /** Bind a Guid parameter\r\n * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')\r\n * @param val Guid to bind.\r\n */\r\n public bindGuid(parameter: BindParameter, guid: GuidString) {\r\n this.checkBind(this._stmt!.bindGuid(parameter, guid));\r\n }\r\n /** Bind a blob parameter\r\n * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')\r\n * @param val blob to bind.\r\n */\r\n public bindBlob(parameter: BindParameter, blob: Uint8Array) {\r\n this.checkBind(this._stmt!.bindBlob(parameter, blob));\r\n }\r\n\r\n /** Bind values to all parameters in the statement.\r\n * @param values The values to bind to the parameters.\r\n * Pass an *array* of values if the parameters are *positional*.\r\n * Pass an *object of the values keyed on the parameter name* for *named parameters*.\r\n * The values in either the array or object must match the respective types of the parameter.\r\n * See [[SqliteStatement.bindValue]] for details on the supported types.\r\n */\r\n public bindValues(values: any[] | object): void {\r\n if (Array.isArray(values)) {\r\n for (let i = 0; i < values.length; i++) {\r\n const paramIndex: number = i + 1;\r\n const paramValue: any = values[i];\r\n if (paramValue === undefined || paramValue === null)\r\n continue;\r\n\r\n this.bindValue(paramIndex, paramValue);\r\n }\r\n return;\r\n }\r\n\r\n for (const entry of Object.entries(values)) {\r\n const paramName: string = entry[0];\r\n const paramValue: any = entry[1];\r\n if (paramValue === undefined || paramValue === null)\r\n continue;\r\n\r\n this.bindValue(paramName, paramValue);\r\n }\r\n }\r\n\r\n /** Clear any bindings that were previously set on this statement.\r\n * @throws [IModelError]($common) in case of errors\r\n */\r\n public clearBindings(): void {\r\n const stat = this._stmt!.clearBindings();\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, \"Error in clearBindings\");\r\n }\r\n\r\n /** Step this statement to the next row.\r\n *\r\n * For **SQL SELECT** statements the method returns\r\n * - [DbResult.BE_SQLITE_ROW]($core-bentley) if the statement now points successfully to the next row.\r\n * - [DbResult.BE_SQLITE_DONE]($core-bentley) if the statement has no more rows.\r\n * - Error status in case of errors.\r\n *\r\n * For **SQL INSERT, UPDATE, DELETE** statements the method returns\r\n * - [DbResult.BE_SQLITE_DONE]($core-bentley) if the statement has been executed successfully.\r\n * - Error status in case of errors.\r\n */\r\n public step(): DbResult { return this._stmt!.step(); }\r\n\r\n /** Get the query result's column count (only for SQL SELECT statements). */\r\n public getColumnCount(): number { return this._stmt!.getColumnCount(); }\r\n\r\n /** Get the value for the column at the given index in the query result.\r\n * @param columnIx Index of SQL column in query result (0-based)\r\n */\r\n public getValue(columnIx: number): SqliteValue { return new SqliteValue(this._stmt!, columnIx); }\r\n\r\n /** Get a value as a blob\r\n * @param colIndex Index of SQL column in query result (0-based)\r\n */\r\n public getValueBlob(colIndex: number): Uint8Array { return this._stmt!.getValueBlob(colIndex); }\r\n /** Get a value as a double\r\n * @param colIndex Index of SQL column in query result (0-based)\r\n */\r\n public getValueDouble(colIndex: number): number { return this._stmt!.getValueDouble(colIndex); }\r\n /** Get a value as a integer\r\n * @param colIndex Index of SQL column in query result (0-based)\r\n */\r\n public getValueInteger(colIndex: number): number { return this._stmt!.getValueInteger(colIndex); }\r\n /** Get a value as a string\r\n * @param colIndex Index of SQL column in query result (0-based)\r\n */\r\n public getValueString(colIndex: number): string { return this._stmt!.getValueString(colIndex); }\r\n /** Get a value as an Id\r\n * @param colIndex Index of SQL column in query result (0-based)\r\n */\r\n public getValueId(colIndex: number): Id64String { return this._stmt!.getValueId(colIndex); }\r\n /** Get a value as a Guid\r\n * @param colIndex Index of SQL column in query result (0-based)\r\n */\r\n public getValueGuid(colIndex: number): GuidString { return this._stmt!.getValueGuid(colIndex); }\r\n\r\n /** Get the current row.\r\n * The returned row is formatted as JavaScript object where every SELECT clause item becomes a property in the JavaScript object.\r\n *\r\n * The SQL select clause item's name becomes the member name of the JavaScript object, **with the first character lowered**.\r\n *\r\n * SQLite Type | JavaScript Type\r\n * --- | ---\r\n * [SqliteValueType.Null]($backend) | undefined\r\n * [SqliteValueType.Integer]($backend) | number\r\n * [SqliteValueType.Double]($backend) | number\r\n * [SqliteValueType.String]($backend) | string\r\n * [SqliteValueType.Blob]($backend) | Uint8Array\r\n */\r\n public getRow(): any {\r\n const colCount = this.getColumnCount();\r\n const row: object = {};\r\n const duplicatePropNames = new Map<string, number>();\r\n for (let i = 0; i < colCount; i++) {\r\n const sqliteValue = this.getValue(i);\r\n if (!sqliteValue.isNull) {\r\n const propName: string = SqliteStatement.determineResultRowPropertyName(duplicatePropNames, sqliteValue);\r\n let val: any;\r\n switch (sqliteValue.type) {\r\n case SqliteValueType.Blob:\r\n val = sqliteValue.getBlob();\r\n break;\r\n case SqliteValueType.Double:\r\n val = sqliteValue.getDouble();\r\n break;\r\n case SqliteValueType.Integer:\r\n val = sqliteValue.getInteger();\r\n break;\r\n case SqliteValueType.String:\r\n val = sqliteValue.getString();\r\n break;\r\n\r\n default:\r\n throw new Error(\"Unsupported SqliteValueType\");\r\n }\r\n\r\n Object.defineProperty(row, propName, { enumerable: true, configurable: true, writable: true, value: val });\r\n }\r\n }\r\n return row;\r\n }\r\n\r\n private static determineResultRowPropertyName(duplicatePropNames: Map<string, number>, sqliteValue: SqliteValue): string {\r\n let jsName = ECJsNames.toJsName(sqliteValue.columnName);\r\n\r\n // now check duplicates. If there are, append a numeric suffix to the duplicates\r\n let suffix = duplicatePropNames.get(jsName);\r\n if (suffix === undefined)\r\n duplicatePropNames.set(jsName, 0);\r\n else {\r\n suffix++;\r\n duplicatePropNames.set(jsName, suffix);\r\n jsName += `_${suffix}`;\r\n }\r\n\r\n return jsName;\r\n }\r\n\r\n /** Calls step when called as an iterator.\r\n */\r\n public next(): IteratorResult<any> {\r\n return DbResult.BE_SQLITE_ROW === this.step() ? { done: false, value: this.getRow() } : { done: true, value: undefined };\r\n }\r\n\r\n /** The iterator that will step through the results of this statement. */\r\n public [Symbol.iterator](): IterableIterator<any> { return this; }\r\n}\r\n\r\n/** Data type of a value in in an SQLite SQL query result.\r\n * See also:\r\n * - [SqliteValue]($backend)\r\n * - [SqliteStatement]($backend)\r\n * - [SqliteStatement.getValue]($backend)\r\n * @public\r\n */\r\nexport enum SqliteValueType {\r\n // do not change the values of that enum. It must correspond to the respective\r\n // enum DbValueType in the native BeSQLite API.\r\n Integer = 1,\r\n Double = 2,\r\n String = 3,\r\n Blob = 4,\r\n Null = 5,\r\n}\r\n\r\n/** Value of a column in a row of an SQLite SQL query result.\r\n * See also:\r\n * - [SqliteStatement]($backend)\r\n * - [SqliteStatement.getValue]($backend)\r\n * @public\r\n */\r\nexport class SqliteValue {\r\n private readonly _stmt: IModelJsNative.SqliteStatement;\r\n private readonly _colIndex: number;\r\n\r\n public constructor(stmt: IModelJsNative.SqliteStatement, colIndex: number) {\r\n this._stmt = stmt;\r\n this._colIndex = colIndex;\r\n }\r\n\r\n /** Indicates whether the value is NULL or not. */\r\n public get isNull(): boolean { return this._stmt.isValueNull(this._colIndex); }\r\n\r\n /** Gets the data type of the value. */\r\n public get type(): SqliteValueType { return this._stmt.getColumnType(this._colIndex); }\r\n\r\n /** Gets the name of the column of the value. */\r\n public get columnName(): string { return this._stmt.getColumnName(this._colIndex); }\r\n\r\n /** Gets the SqlValue as JavaScript value.\r\n *\r\n * SQLite Type | JavaScript Type\r\n * --- | ---\r\n * [SqliteValueType.Null]($backend) | undefined\r\n * [SqliteValueType.Integer]($backend) | number\r\n * [SqliteValueType.Double]($backend) | number\r\n * [SqliteValueType.String]($backend) | string\r\n * [SqliteValueType.Blob]($backend) | Uint8Array\r\n */\r\n public get value(): any {\r\n switch (this.type) {\r\n case SqliteValueType.Null:\r\n return undefined;\r\n case SqliteValueType.Blob:\r\n return this.getBlob();\r\n case SqliteValueType.Double:\r\n return this.getDouble();\r\n case SqliteValueType.Integer:\r\n return this.getInteger();\r\n case SqliteValueType.String:\r\n return this.getString();\r\n default:\r\n throw new Error(\"Unhandled SqliteValueType\");\r\n }\r\n }\r\n\r\n /** Get the value as BLOB */\r\n public getBlob(): Uint8Array { return this._stmt.getValueBlob(this._colIndex); }\r\n /** Get the value as a double value */\r\n public getDouble(): number { return this._stmt.getValueDouble(this._colIndex); }\r\n /** Get the value as a integer value */\r\n public getInteger(): number { return this._stmt.getValueInteger(this._colIndex); }\r\n /** Get the value as a string value */\r\n public getString(): string { return this._stmt.getValueString(this._colIndex); }\r\n /** Get the value as an Id value */\r\n public getId(): Id64String { return this._stmt.getValueId(this._colIndex); }\r\n /** Get the value as a Guid value */\r\n public getGuid(): GuidString { return this._stmt.getValueGuid(this._colIndex); }\r\n}\r\n\r\ninterface Statement {\r\n isPrepared: boolean;\r\n sql: string;\r\n dispose(): void;\r\n reset(): void;\r\n clearBindings(): void;\r\n}\r\n\r\n/** A cache for previously prepared SqliteStatements.\r\n * It only holds Statements after they are no longer in use, resetting and clearing their bindings before saving them.\r\n * When a request to use a statement from the cache is made, it is first removed from the cache.\r\n * @internal\r\n */\r\nexport class StatementCache<Stmt extends Statement> {\r\n private _cache: LRUMap<string, Stmt>;\r\n\r\n public constructor(maxCount = 40) {\r\n this._cache = new LRUMap<string, Stmt>(maxCount);\r\n }\r\n\r\n public get size() { return this._cache.size; }\r\n public addOrDispose(stmt: Stmt): void {\r\n assert(stmt.isPrepared);\r\n\r\n const existing = this._cache.get(stmt.sql);\r\n if (existing !== undefined) {\r\n stmt.dispose(); // we already have a statement with this sql cached, we can't save another one so just dispose it\r\n return;\r\n }\r\n if (this._cache.size >= this._cache.limit) {\r\n const oldest = this._cache.shift()!;\r\n oldest[1].dispose();\r\n }\r\n stmt.reset();\r\n stmt.clearBindings();\r\n this._cache.set(stmt.sql, stmt);\r\n }\r\n\r\n public findAndRemove(sql: string): Stmt | undefined {\r\n return this._cache.delete(sql);\r\n }\r\n\r\n public clear() {\r\n this._cache.forEach((stmt) => stmt.dispose());\r\n this._cache.clear();\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"SqliteStatement.js","sourceRoot":"","sources":["../../src/SqliteStatement.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAoG;AACpG,oDAA4D;AAE5D,6CAA0C;AAmB1C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAa,eAAe;IAG1B,YAA2B,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAI,CAAC;IAC5C,IAAW,IAAI,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACxC,IAAW,GAAG,KAAK,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAEtC,oEAAoE;IACpE,IAAW,UAAU,KAAc,OAAO,SAAS,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAErE;;;;;;OAMG;IACI,OAAO,CAAC,EAAwE,EAAE,SAAS,GAAG,IAAI;QACvG,IAAI,IAAI,CAAC,UAAU;YACjB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACzD,IAAI,CAAC,KAAK,GAAG,IAAI,uBAAU,CAAC,QAAQ,CAAC,eAAe,EAAE,CAAC;QACvD,IAAI,CAAC,KAAK,CAAC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AC,iGAAiG;YACjH,OAAO;SACR;QACD,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE;YACzC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAG,CAAC;YACpC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SACrB;QACD,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;IAEM,aAAa,CAAC,GAAW;QAC9B,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;IAEM,KAAK;QACV,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;QAC9C,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;CACF;AAjCD,wCAiCC","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 SQLite\r\n */\r\n\r\nimport { assert, DbResult, GuidString, Id64String, IDisposable, LRUMap } from \"@itwin/core-bentley\";\r\nimport { ECJsNames, IModelError } from \"@itwin/core-common\";\r\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\nimport { IModelHost } from \"./IModelHost\";\r\n\r\n/* eslint-disable @typescript-eslint/no-non-null-assertion */\r\n\r\n/** Marks a string as either an [Id64String]($core-bentley) or [GuidString]($core-bentley), so\r\n * that it can be passed to the [bindValue]($backend.SqliteStatement) or [bindValues]($backend.SqliteStatement)\r\n * methods of [SqliteStatement]($backend).\r\n * @internal\r\n */\r\nexport interface StringParam {\r\n id?: Id64String;\r\n guid?: GuidString;\r\n}\r\n\r\n/** parameter Index (1-based), or name of the parameter (including the initial ':', '@' or '$')\r\n * @public\r\n */\r\nexport type BindParameter = number | string;\r\n\r\n/** Executes SQLite SQL statements.\r\n *\r\n * A statement must be prepared before it can be executed, and it must be released when no longer needed.\r\n * See [IModelDb.withPreparedSqliteStatement]($backend) or\r\n * [ECDb.withPreparedSqliteStatement]($backend) for a convenient and\r\n * reliable way to prepare, execute, and then release a statement.\r\n *\r\n * A statement may contain parameters that must be filled in before use by calling [SqliteStatement.bindValue]($backend)\r\n * or [SqliteStatement.bindValues]($backend).\r\n *\r\n * Once prepared (and parameters are bound, if any), the statement is executed by calling [SqliteStatement.step]($backend).\r\n * In case of an **SQL SELECT** statement, the current row can be retrieved with [SqliteStatement.getRow]($backend) as\r\n * a whole, or with [SqliteStatement.getValue]($backend) when individual values are needed.\r\n * Alternatively, query results of an **SQL SELECT** statement can be stepped through by using\r\n * standard iteration syntax, such as `for of`.\r\n *\r\n * > Preparing a statement can be time-consuming. The best way to reduce the effect of this overhead is to cache and reuse prepared\r\n * > statements. A cached prepared statement may be used in different places in an app, as long as the statement is general enough.\r\n * > The key to making this strategy work is to phrase a statement in a general way and use placeholders to represent parameters that will vary on each use.\r\n * @public\r\n */\r\nexport class SqliteStatement implements IterableIterator<any>, IDisposable {\r\n private _stmt: IModelJsNative.SqliteStatement | undefined;\r\n\r\n public constructor(private _sql: string) { }\r\n public get stmt() { return this._stmt; }\r\n public get sql() { return this._sql; }\r\n\r\n /** Check if this statement has been prepared successfully or not */\r\n public get isPrepared(): boolean { return undefined !== this._stmt; }\r\n\r\n /** Prepare this statement prior to first use.\r\n * @param db The DgnDb or ECDb to prepare the statement against\r\n * @param sql The SQL statement string to prepare\r\n * @param logErrors Determine if errors are logged or not\r\n * @throws if the SQL statement cannot be prepared. Normally, prepare fails due to SQL syntax errors or references to tables or properties that do not exist.\r\n * The error.message property will provide details.\r\n */\r\n public prepare(db: IModelJsNative.DgnDb | IModelJsNative.ECDb | IModelJsNative.SQLiteDb, logErrors = true): void {\r\n if (this.isPrepared)\r\n throw new Error(\"SqliteStatement is already prepared\");\r\n this._stmt = new IModelHost.platform.SqliteStatement();\r\n this._stmt.prepare(db, this._sql, logErrors);\r\n }\r\n\r\n /** Indicates whether the prepared statement makes no **direct* changes to the content of the file\r\n * or not. See [SQLite docs](https://www.sqlite.org/c3ref/stmt_readonly.html) for details.\r\n */\r\n public get isReadonly(): boolean {\r\n return this._stmt!.isReadonly();\r\n }\r\n\r\n /** Reset this statement so that the next call to step will return the first row, if any.\r\n */\r\n public reset(): void {\r\n this._stmt!.reset();\r\n }\r\n\r\n /** Call this function when finished with this statement. This releases the native resources held by the statement. */\r\n public dispose(): void {\r\n if (this._stmt) {\r\n this._stmt.dispose(); // free native statement\r\n this._stmt = undefined;\r\n }\r\n }\r\n\r\n /** Binds a value to the specified SQL parameter.\r\n * The value must be of one of these types:\r\n * JavaScript Type | SQLite Type\r\n * --- | ---\r\n * undefined | NULL\r\n * boolean | INTEGER with true being bound as 1 and false as 0\r\n * number | INTEGER if number is integral or REAL if number is not integral\r\n * string | TEXT\r\n * Uint8Array or ArrayBuffer | BLOB\r\n * [StringParam]($backend) where member **id** is set | INTEGER\r\n * [StringParam]($backend) where member **guid** is set | BLOB\r\n *\r\n * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')\r\n * @param value Value to bind.\r\n * @throws [IModelError]($common) if the value is of an unsupported type or in\r\n * case of other binding errors.\r\n */\r\n public bindValue(parameter: BindParameter, value: any): void {\r\n let stat: DbResult;\r\n if (value === undefined || value === null) {\r\n stat = this._stmt!.bindNull(parameter);\r\n } else if (typeof (value) === \"number\") {\r\n if (Number.isInteger(value))\r\n stat = this._stmt!.bindInteger(parameter, value);\r\n else\r\n stat = this._stmt!.bindDouble(parameter, value);\r\n } else if (typeof (value) === \"boolean\") {\r\n stat = this._stmt!.bindInteger(parameter, value ? 1 : 0);\r\n } else if (typeof (value) === \"string\") {\r\n stat = this._stmt!.bindString(parameter, value);\r\n } else if (!!value.id) {\r\n stat = this._stmt!.bindId(parameter, value.id);\r\n } else if (!!value.guid) {\r\n stat = this._stmt!.bindGuid(parameter, value.guid);\r\n } else if (value instanceof Uint8Array) {\r\n stat = this._stmt!.bindBlob(parameter, value);\r\n } else\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, `Parameter value ${value} is of an unsupported data type.`);\r\n\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, \"Error in bindValue\");\r\n }\r\n\r\n private checkBind(stat: DbResult) {\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, \"SQLite Bind error\");\r\n }\r\n /** Bind an integer parameter\r\n * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')\r\n * @param val integer to bind.\r\n */\r\n public bindInteger(parameter: BindParameter, val: number) {\r\n this.checkBind(this._stmt!.bindInteger(parameter, val));\r\n }\r\n /** Bind a double parameter\r\n * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')\r\n * @param val double to bind.\r\n */\r\n public bindDouble(parameter: BindParameter, val: number) {\r\n this.checkBind(this._stmt!.bindDouble(parameter, val));\r\n }\r\n /** Bind a string parameter\r\n * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')\r\n * @param val string to bind.\r\n */\r\n public bindString(parameter: BindParameter, val: string) {\r\n this.checkBind(this._stmt!.bindString(parameter, val));\r\n }\r\n /** Bind an Id64String parameter as a 64-bit integer\r\n * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')\r\n * @param val Id to bind.\r\n */\r\n public bindId(parameter: BindParameter, id: Id64String) {\r\n this.checkBind(this._stmt!.bindId(parameter, id));\r\n }\r\n /** Bind a Guid parameter\r\n * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')\r\n * @param val Guid to bind.\r\n */\r\n public bindGuid(parameter: BindParameter, guid: GuidString) {\r\n this.checkBind(this._stmt!.bindGuid(parameter, guid));\r\n }\r\n /** Bind a blob parameter\r\n * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')\r\n * @param val blob to bind.\r\n */\r\n public bindBlob(parameter: BindParameter, blob: Uint8Array) {\r\n this.checkBind(this._stmt!.bindBlob(parameter, blob));\r\n }\r\n /** Bind null to a parameter\r\n * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')\r\n */\r\n public bindNull(parameter: BindParameter) {\r\n this.checkBind(this._stmt!.bindNull(parameter));\r\n }\r\n\r\n /** Bind values to all parameters in the statement.\r\n * @param values The values to bind to the parameters.\r\n * Pass an *array* of values if the parameters are *positional*.\r\n * Pass an *object of the values keyed on the parameter name* for *named parameters*.\r\n * The values in either the array or object must match the respective types of the parameter.\r\n * See [[SqliteStatement.bindValue]] for details on the supported types.\r\n */\r\n public bindValues(values: any[] | object): void {\r\n if (Array.isArray(values)) {\r\n for (let i = 0; i < values.length; i++) {\r\n const paramIndex: number = i + 1;\r\n const paramValue: any = values[i];\r\n if (paramValue === undefined || paramValue === null)\r\n continue;\r\n\r\n this.bindValue(paramIndex, paramValue);\r\n }\r\n return;\r\n }\r\n\r\n for (const entry of Object.entries(values)) {\r\n const paramName: string = entry[0];\r\n const paramValue: any = entry[1];\r\n if (paramValue === undefined || paramValue === null)\r\n continue;\r\n\r\n this.bindValue(paramName, paramValue);\r\n }\r\n }\r\n\r\n /** Clear any bindings that were previously set on this statement.\r\n * @throws [IModelError]($common) in case of errors\r\n */\r\n public clearBindings(): void {\r\n const stat = this._stmt!.clearBindings();\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, \"Error in clearBindings\");\r\n }\r\n\r\n /** Step this statement to the next row.\r\n *\r\n * For **SQL SELECT** statements the method returns\r\n * - [DbResult.BE_SQLITE_ROW]($core-bentley) if the statement now points successfully to the next row.\r\n * - [DbResult.BE_SQLITE_DONE]($core-bentley) if the statement has no more rows.\r\n * - Error status in case of errors.\r\n *\r\n * For **SQL INSERT, UPDATE, DELETE** statements the method returns\r\n * - [DbResult.BE_SQLITE_DONE]($core-bentley) if the statement has been executed successfully.\r\n * - Error status in case of errors.\r\n */\r\n public step(): DbResult { return this._stmt!.step(); }\r\n\r\n /** Get the query result's column count (only for SQL SELECT statements). */\r\n public getColumnCount(): number { return this._stmt!.getColumnCount(); }\r\n\r\n /** Get the value for the column at the given index in the query result.\r\n * @param columnIx Index of SQL column in query result (0-based)\r\n */\r\n public getValue(columnIx: number): SqliteValue { return new SqliteValue(this._stmt!, columnIx); }\r\n\r\n /** Get a size in bytes of a blob or text column\r\n * @param colIndex Index of SQL column in query result (0-based)\r\n */\r\n public getColumnBytes(colIndex: number): number { return this._stmt!.getColumnBytes(colIndex); }\r\n\r\n /** Get a value as a blob\r\n * @param colIndex Index of SQL column in query result (0-based)\r\n */\r\n public getValueBlob(colIndex: number): Uint8Array { return this._stmt!.getValueBlob(colIndex); }\r\n /** Get a value as a double\r\n * @param colIndex Index of SQL column in query result (0-based)\r\n */\r\n public getValueDouble(colIndex: number): number { return this._stmt!.getValueDouble(colIndex); }\r\n /** Get a value as a integer\r\n * @param colIndex Index of SQL column in query result (0-based)\r\n */\r\n public getValueInteger(colIndex: number): number { return this._stmt!.getValueInteger(colIndex); }\r\n /** Get a value as a string\r\n * @param colIndex Index of SQL column in query result (0-based)\r\n */\r\n public getValueString(colIndex: number): string { return this._stmt!.getValueString(colIndex); }\r\n /** Get a value as an Id\r\n * @param colIndex Index of SQL column in query result (0-based)\r\n */\r\n public getValueId(colIndex: number): Id64String { return this._stmt!.getValueId(colIndex); }\r\n /** Get a value as a Guid\r\n * @param colIndex Index of SQL column in query result (0-based)\r\n */\r\n public getValueGuid(colIndex: number): GuidString { return this._stmt!.getValueGuid(colIndex); }\r\n\r\n /** Get the current row.\r\n * The returned row is formatted as JavaScript object where every SELECT clause item becomes a property in the JavaScript object.\r\n *\r\n * The SQL select clause item's name becomes the member name of the JavaScript object, **with the first character lowered**.\r\n *\r\n * SQLite Type | JavaScript Type\r\n * --- | ---\r\n * [SqliteValueType.Null]($backend) | undefined\r\n * [SqliteValueType.Integer]($backend) | number\r\n * [SqliteValueType.Double]($backend) | number\r\n * [SqliteValueType.String]($backend) | string\r\n * [SqliteValueType.Blob]($backend) | Uint8Array\r\n */\r\n public getRow(): any {\r\n const colCount = this.getColumnCount();\r\n const row: object = {};\r\n const duplicatePropNames = new Map<string, number>();\r\n for (let i = 0; i < colCount; i++) {\r\n const sqliteValue = this.getValue(i);\r\n if (!sqliteValue.isNull) {\r\n const propName: string = SqliteStatement.determineResultRowPropertyName(duplicatePropNames, sqliteValue);\r\n let val: any;\r\n switch (sqliteValue.type) {\r\n case SqliteValueType.Blob:\r\n val = sqliteValue.getBlob();\r\n break;\r\n case SqliteValueType.Double:\r\n val = sqliteValue.getDouble();\r\n break;\r\n case SqliteValueType.Integer:\r\n val = sqliteValue.getInteger();\r\n break;\r\n case SqliteValueType.String:\r\n val = sqliteValue.getString();\r\n break;\r\n\r\n default:\r\n throw new Error(\"Unsupported SqliteValueType\");\r\n }\r\n\r\n Object.defineProperty(row, propName, { enumerable: true, configurable: true, writable: true, value: val });\r\n }\r\n }\r\n return row;\r\n }\r\n\r\n private static determineResultRowPropertyName(duplicatePropNames: Map<string, number>, sqliteValue: SqliteValue): string {\r\n let jsName = ECJsNames.toJsName(sqliteValue.columnName);\r\n\r\n // now check duplicates. If there are, append a numeric suffix to the duplicates\r\n let suffix = duplicatePropNames.get(jsName);\r\n if (suffix === undefined)\r\n duplicatePropNames.set(jsName, 0);\r\n else {\r\n suffix++;\r\n duplicatePropNames.set(jsName, suffix);\r\n jsName += `_${suffix}`;\r\n }\r\n\r\n return jsName;\r\n }\r\n\r\n /** Calls step when called as an iterator.\r\n */\r\n public next(): IteratorResult<any> {\r\n return DbResult.BE_SQLITE_ROW === this.step() ? { done: false, value: this.getRow() } : { done: true, value: undefined };\r\n }\r\n\r\n /** The iterator that will step through the results of this statement. */\r\n public [Symbol.iterator](): IterableIterator<any> { return this; }\r\n}\r\n\r\n/** Data type of a value in in an SQLite SQL query result.\r\n * See also:\r\n * - [SqliteValue]($backend)\r\n * - [SqliteStatement]($backend)\r\n * - [SqliteStatement.getValue]($backend)\r\n * @public\r\n */\r\nexport enum SqliteValueType {\r\n // do not change the values of that enum. It must correspond to the respective\r\n // enum DbValueType in the native BeSQLite API.\r\n Integer = 1,\r\n Double = 2,\r\n String = 3,\r\n Blob = 4,\r\n Null = 5,\r\n}\r\n\r\n/** Value of a column in a row of an SQLite SQL query result.\r\n * See also:\r\n * - [SqliteStatement]($backend)\r\n * - [SqliteStatement.getValue]($backend)\r\n * @public\r\n */\r\nexport class SqliteValue {\r\n private readonly _stmt: IModelJsNative.SqliteStatement;\r\n private readonly _colIndex: number;\r\n\r\n public constructor(stmt: IModelJsNative.SqliteStatement, colIndex: number) {\r\n this._stmt = stmt;\r\n this._colIndex = colIndex;\r\n }\r\n\r\n /** Indicates whether the value is NULL or not. */\r\n public get isNull(): boolean { return this._stmt.isValueNull(this._colIndex); }\r\n\r\n /** Gets the data type of the value. */\r\n public get type(): SqliteValueType { return this._stmt.getColumnType(this._colIndex); }\r\n\r\n /** Gets the name of the column of the value. */\r\n public get columnName(): string { return this._stmt.getColumnName(this._colIndex); }\r\n\r\n /** Gets the SqlValue as JavaScript value.\r\n *\r\n * SQLite Type | JavaScript Type\r\n * --- | ---\r\n * [SqliteValueType.Null]($backend) | undefined\r\n * [SqliteValueType.Integer]($backend) | number\r\n * [SqliteValueType.Double]($backend) | number\r\n * [SqliteValueType.String]($backend) | string\r\n * [SqliteValueType.Blob]($backend) | Uint8Array\r\n */\r\n public get value(): any {\r\n switch (this.type) {\r\n case SqliteValueType.Null:\r\n return undefined;\r\n case SqliteValueType.Blob:\r\n return this.getBlob();\r\n case SqliteValueType.Double:\r\n return this.getDouble();\r\n case SqliteValueType.Integer:\r\n return this.getInteger();\r\n case SqliteValueType.String:\r\n return this.getString();\r\n default:\r\n throw new Error(\"Unhandled SqliteValueType\");\r\n }\r\n }\r\n\r\n /** Get the value as BLOB */\r\n public getBlob(): Uint8Array { return this._stmt.getValueBlob(this._colIndex); }\r\n /** Get the value as a double value */\r\n public getDouble(): number { return this._stmt.getValueDouble(this._colIndex); }\r\n /** Get the value as a integer value */\r\n public getInteger(): number { return this._stmt.getValueInteger(this._colIndex); }\r\n /** Get the value as a string value */\r\n public getString(): string { return this._stmt.getValueString(this._colIndex); }\r\n /** Get the value as an Id value */\r\n public getId(): Id64String { return this._stmt.getValueId(this._colIndex); }\r\n /** Get the value as a Guid value */\r\n public getGuid(): GuidString { return this._stmt.getValueGuid(this._colIndex); }\r\n}\r\n\r\ninterface Statement {\r\n isPrepared: boolean;\r\n sql: string;\r\n dispose(): void;\r\n reset(): void;\r\n clearBindings(): void;\r\n}\r\n\r\n/** A cache for previously prepared SqliteStatements.\r\n * It only holds Statements after they are no longer in use, resetting and clearing their bindings before saving them.\r\n * When a request to use a statement from the cache is made, it is first removed from the cache.\r\n * @internal\r\n */\r\nexport class StatementCache<Stmt extends Statement> {\r\n private _cache: LRUMap<string, Stmt>;\r\n\r\n public constructor(maxCount = 40) {\r\n this._cache = new LRUMap<string, Stmt>(maxCount);\r\n }\r\n\r\n public get size() { return this._cache.size; }\r\n public addOrDispose(stmt: Stmt): void {\r\n assert(stmt.isPrepared);\r\n\r\n const existing = this._cache.get(stmt.sql);\r\n if (existing !== undefined) {\r\n stmt.dispose(); // we already have a statement with this sql cached, we can't save another one so just dispose it\r\n return;\r\n }\r\n if (this._cache.size >= this._cache.limit) {\r\n const oldest = this._cache.shift()!;\r\n oldest[1].dispose();\r\n }\r\n stmt.reset();\r\n stmt.clearBindings();\r\n this._cache.set(stmt.sql, stmt);\r\n }\r\n\r\n public findAndRemove(sql: string): Stmt | undefined {\r\n return this._cache.delete(sql);\r\n }\r\n\r\n public clear() {\r\n this._cache.forEach((stmt) => stmt.dispose());\r\n this._cache.clear();\r\n }\r\n}\r\n"]}
|
|
@@ -23,7 +23,7 @@ export declare class ModelSelector extends DefinitionElement {
|
|
|
23
23
|
/** @internal */
|
|
24
24
|
toJSON(): ModelSelectorProps;
|
|
25
25
|
/** @internal */
|
|
26
|
-
protected
|
|
26
|
+
protected collectReferenceIds(referenceIds: Id64Set): void;
|
|
27
27
|
/** Create a Code for a ModelSelector given a name that is meant to be unique within the scope of the specified DefinitionModel.
|
|
28
28
|
* @param iModel The IModelDb
|
|
29
29
|
* @param scopeModelId The Id of the DefinitionModel that contains the ModelSelector and provides the scope for its name.
|
|
@@ -66,7 +66,7 @@ export declare class CategorySelector extends DefinitionElement {
|
|
|
66
66
|
/** @internal */
|
|
67
67
|
toJSON(): CategorySelectorProps;
|
|
68
68
|
/** @internal */
|
|
69
|
-
protected
|
|
69
|
+
protected collectReferenceIds(referenceIds: Id64Set): void;
|
|
70
70
|
/** Create a Code for a CategorySelector given a name that is meant to be unique within the scope of the specified DefinitionModel.
|
|
71
71
|
* @param iModel The IModelDb
|
|
72
72
|
* @param scopeModelId The Id of the DefinitionModel that contains the CategorySelector and provides the scope for its name.
|
|
@@ -120,7 +120,7 @@ export declare abstract class ViewDefinition extends DefinitionElement {
|
|
|
120
120
|
/** @internal */
|
|
121
121
|
toJSON(): ViewDefinitionProps;
|
|
122
122
|
/** @internal */
|
|
123
|
-
protected
|
|
123
|
+
protected collectReferenceIds(referenceIds: Id64Set): void;
|
|
124
124
|
/** @beta */
|
|
125
125
|
static readonly requiredReferenceKeys: ReadonlyArray<string>;
|
|
126
126
|
/** @internal */
|
|
@@ -200,7 +200,7 @@ export declare class SpatialViewDefinition extends ViewDefinition3d {
|
|
|
200
200
|
/** @internal */
|
|
201
201
|
toJSON(): SpatialViewDefinitionProps;
|
|
202
202
|
/** @internal */
|
|
203
|
-
protected
|
|
203
|
+
protected collectReferenceIds(referenceIds: Id64Set): void;
|
|
204
204
|
/** @beta */
|
|
205
205
|
static readonly requiredReferenceKeys: ReadonlyArray<string>;
|
|
206
206
|
/** Load this view's ModelSelector from the IModelDb. */
|
|
@@ -295,7 +295,7 @@ export declare class ViewDefinition2d extends ViewDefinition {
|
|
|
295
295
|
/** @internal */
|
|
296
296
|
toJSON(): ViewDefinition2dProps;
|
|
297
297
|
/** @internal */
|
|
298
|
-
protected
|
|
298
|
+
protected collectReferenceIds(referenceIds: Id64Set): void;
|
|
299
299
|
/** Provides access to optional detail settings for this view. */
|
|
300
300
|
get details(): ViewDetails;
|
|
301
301
|
/** Load this view's DisplayStyle2d from the IModelDb. */
|
|
@@ -420,7 +420,7 @@ export declare class ViewAttachment extends GraphicalElement2d {
|
|
|
420
420
|
view: RelatedElement;
|
|
421
421
|
constructor(props: ViewAttachmentProps, iModel: IModelDb);
|
|
422
422
|
/** @internal */
|
|
423
|
-
protected
|
|
423
|
+
protected collectReferenceIds(referenceIds: Id64Set): void;
|
|
424
424
|
}
|
|
425
425
|
/** The position in space of a Light.
|
|
426
426
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewDefinition.d.ts","sourceRoot":"","sources":["../../src/ViewDefinition.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAQ,SAAS,EAAE,OAAO,EAAE,UAAU,EAA2B,MAAM,qBAAqB,CAAC;AACpG,OAAO,EACL,KAAK,EAAY,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAa,QAAQ,EAAE,kBAAkB,EAChH,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,qBAAqB,EAAE,qBAAqB,EAAE,mBAAmB,EAAe,MAAM,EACtF,qBAAqB,EAAE,IAAI,EAAE,cAAc,EAAyB,kBAAkB,EAAE,kBAAkB,EAAE,cAAc,EAC1H,0BAA0B,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,WAAW,EAAE,aAAa,EAC/I,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAA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