@itwin/core-backend 3.4.0-dev.3 → 3.4.0-dev.30

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.
Files changed (73) hide show
  1. package/CHANGELOG.md +39 -1
  2. package/lib/cjs/BackendHubAccess.d.ts.map +1 -1
  3. package/lib/cjs/BackendHubAccess.js.map +1 -1
  4. package/lib/cjs/ChangedElementsDb.d.ts +1 -0
  5. package/lib/cjs/ChangedElementsDb.d.ts.map +1 -1
  6. package/lib/cjs/ChangedElementsDb.js +2 -2
  7. package/lib/cjs/ChangedElementsDb.js.map +1 -1
  8. package/lib/cjs/CodeService.d.ts +392 -0
  9. package/lib/cjs/CodeService.d.ts.map +1 -0
  10. package/lib/cjs/CodeService.js +62 -0
  11. package/lib/cjs/CodeService.js.map +1 -0
  12. package/lib/cjs/CodeSpecs.js.map +1 -1
  13. package/lib/cjs/CustomViewState3dCreator.d.ts.map +1 -1
  14. package/lib/cjs/CustomViewState3dCreator.js +1 -0
  15. package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
  16. package/lib/cjs/Element.d.ts.map +1 -1
  17. package/lib/cjs/Element.js +4 -0
  18. package/lib/cjs/Element.js.map +1 -1
  19. package/lib/cjs/ElementTreeWalker.d.ts +41 -18
  20. package/lib/cjs/ElementTreeWalker.d.ts.map +1 -1
  21. package/lib/cjs/ElementTreeWalker.js +91 -57
  22. package/lib/cjs/ElementTreeWalker.js.map +1 -1
  23. package/lib/cjs/ExportGraphics.d.ts +9 -9
  24. package/lib/cjs/ExportGraphics.d.ts.map +1 -1
  25. package/lib/cjs/ExportGraphics.js.map +1 -1
  26. package/lib/cjs/GeoCoordConfig.d.ts +7 -1
  27. package/lib/cjs/GeoCoordConfig.d.ts.map +1 -1
  28. package/lib/cjs/GeoCoordConfig.js +15 -6
  29. package/lib/cjs/GeoCoordConfig.js.map +1 -1
  30. package/lib/cjs/HubMock.d.ts.map +1 -1
  31. package/lib/cjs/HubMock.js +7 -7
  32. package/lib/cjs/HubMock.js.map +1 -1
  33. package/lib/cjs/IModelDb.d.ts +17 -4
  34. package/lib/cjs/IModelDb.d.ts.map +1 -1
  35. package/lib/cjs/IModelDb.js +53 -11
  36. package/lib/cjs/IModelDb.js.map +1 -1
  37. package/lib/cjs/IModelHost.d.ts.map +1 -1
  38. package/lib/cjs/IModelHost.js +3 -1
  39. package/lib/cjs/IModelHost.js.map +1 -1
  40. package/lib/cjs/IModelSchemaLoader.d.ts.map +1 -1
  41. package/lib/cjs/IModelSchemaLoader.js +10 -18
  42. package/lib/cjs/IModelSchemaLoader.js.map +1 -1
  43. package/lib/cjs/LocalHub.js +1 -1
  44. package/lib/cjs/LocalHub.js.map +1 -1
  45. package/lib/cjs/Material.d.ts +3 -1
  46. package/lib/cjs/Material.d.ts.map +1 -1
  47. package/lib/cjs/Material.js +3 -1
  48. package/lib/cjs/Material.js.map +1 -1
  49. package/lib/cjs/PropertyStore.d.ts +134 -0
  50. package/lib/cjs/PropertyStore.d.ts.map +1 -0
  51. package/lib/cjs/PropertyStore.js +12 -0
  52. package/lib/cjs/PropertyStore.js.map +1 -0
  53. package/lib/cjs/SQLiteDb.d.ts +79 -40
  54. package/lib/cjs/SQLiteDb.d.ts.map +1 -1
  55. package/lib/cjs/SQLiteDb.js +57 -40
  56. package/lib/cjs/SQLiteDb.js.map +1 -1
  57. package/lib/cjs/SqliteStatement.d.ts +14 -2
  58. package/lib/cjs/SqliteStatement.d.ts.map +1 -1
  59. package/lib/cjs/SqliteStatement.js +50 -28
  60. package/lib/cjs/SqliteStatement.js.map +1 -1
  61. package/lib/cjs/TxnManager.js +1 -1
  62. package/lib/cjs/TxnManager.js.map +1 -1
  63. package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +10 -0
  64. package/lib/cjs/assets/Settings/backend.setting.json5 +1 -1
  65. package/lib/cjs/core-backend.d.ts +3 -0
  66. package/lib/cjs/core-backend.d.ts.map +1 -1
  67. package/lib/cjs/core-backend.js +3 -0
  68. package/lib/cjs/core-backend.js.map +1 -1
  69. package/lib/cjs/workspace/Workspace.d.ts +7 -3
  70. package/lib/cjs/workspace/Workspace.d.ts.map +1 -1
  71. package/lib/cjs/workspace/Workspace.js +25 -20
  72. package/lib/cjs/workspace/Workspace.js.map +1 -1
  73. package/package.json +15 -15
@@ -36,55 +36,44 @@ export declare class SQLiteDb implements IDisposable {
36
36
  */
37
37
  openDb(dbName: string, openMode: OpenMode | SQLiteDb.OpenParams, container?: SQLiteDb.CloudContainer): void;
38
38
  /** Close SQLiteDb.
39
- * @param saveChanges if true, call `saveChanges` before closing db.
39
+ * @param saveChanges if true, call `saveChanges` before closing db. Otherwise unsaved changes are abandoned.
40
40
  */
41
41
  closeDb(saveChanges?: boolean): void;
42
- /** Returns true if the SQLiteDb is open */
42
+ /** Returns true if this SQLiteDb is open */
43
43
  get isOpen(): boolean;
44
+ /** Returns true if this SQLiteDb is open readonly */
45
+ get isReadonly(): boolean;
44
46
  /**
45
- * 1. open a database
46
- * 2. call a function supplying the open SQliteDb as argument. If it is async, await its return.
47
- * 3. close the database (even if exceptions are thrown)
47
+ * Open a database, perform an operation, then close the database.
48
+ *
49
+ * Details:
50
+ * - if database is open, throw an error
51
+ * - open a database
52
+ * - call a function with the database opened. If it is async, await its return.
53
+ * - if function throws, abandon all changes, close database, and rethrow
54
+ * - save all changes
55
+ * - close the database
56
+ * @return value from operation
48
57
  */
49
- static withOpenDb<T>(args: {
50
- /** The name of the database to open */
51
- dbName: string;
52
- /** either an object with the open parameters or just OpenMode value. */
53
- openMode?: OpenMode | SQLiteDb.OpenParams;
54
- /** @internal */
55
- container?: SQLiteDb.CloudContainer;
56
- }, operation: (db: SQLiteDb) => T): T;
58
+ withOpenDb<T>(args: SQLiteDb.WithOpenDbArgs, operation: () => T): T;
57
59
  /**
58
- * 1. acquire the write lock on a CloudContainer
59
- * 2. open a ReadWrite database in the container
60
- * 3. call a function with the opened database as an argument
61
- * 4. close the database
62
- * 5. release the write lock and upload changes.
60
+ * Perform an operation on a database in a CloudContainer with the write lock held.
61
+ *
62
+ * Details:
63
+ * - acquire the write lock on a CloudContainer
64
+ * - call `withOpenDb` with openMode `ReadWrite`
65
+ * - upload changes
66
+ * - release the write lock
67
+ * @param args arguments to lock the container and open the database
68
+ * @param operation an operation performed on the database with the write lock held.
69
+ * @return value from operation
63
70
  * @internal
64
71
  */
65
- static withLockedContainer(args: {
66
- /** the name to be displayed in the event of lock collisions */
67
- user: string;
68
- /** the name of the database within the container */
69
- dbName: string;
70
- /** the CloudContainer on which the operation will be performed */
71
- container: SQLiteDb.CloudContainer;
72
- /** if present, function called when the write lock is currently held by another user. */
73
- busyHandler?: CloudSqlite.WriteLockBusyHandler;
74
- },
75
- /** an asynchronous operation performed on the database with the write lock held. */
76
- operation: (db: SQLiteDb) => Promise<void>): Promise<void>;
72
+ withLockedContainer<T>(args: SQLiteDb.LockAndOpenArgs, operation: () => T): Promise<T>;
77
73
  /** vacuum this database
78
74
  * @see https://www.sqlite.org/lang_vacuum.html
79
75
  */
80
- vacuum(args?: {
81
- /** new page size
82
- * @see https://www.sqlite.org/pragma.html#pragma_page_size
83
- */
84
- pageSize?: number;
85
- /** if present, name of new file to vacuum into */
86
- into?: LocalFileName;
87
- }): void;
76
+ vacuum(args?: SQLiteDb.VacuumDbArgs): void;
88
77
  /** Commit the outermost transaction, writing changes to the file. Then, restart the transaction. */
89
78
  saveChanges(): void;
90
79
  /** Abandon (cancel) the outermost transaction, discarding all changes since last save. Then, restart the transaction. */
@@ -109,6 +98,12 @@ export declare class SQLiteDb implements IDisposable {
109
98
  * @returns the value returned by `callback`.
110
99
  */
111
100
  withSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T): T;
101
+ /**
102
+ * Perform an operation on this database within a [savepoint](https://www.sqlite.org/lang_savepoint.html). If the operation completes successfully, the
103
+ * changes remain in the current transaction. If the operation throws an exception, the savepoint is rolled back
104
+ * and all changes to the database from this method are reversed, leaving the transaction exactly as it was before this method.
105
+ */
106
+ withSavePoint(savePointName: string, operation: () => void): void;
112
107
  /** Prepare an SQL statement.
113
108
  * @param sql The SQLite SQL statement to prepare
114
109
  * @param logErrors Determine if errors are logged or not
@@ -165,10 +160,54 @@ export declare namespace SQLiteDb {
165
160
  /** use OpenMode.ReadWrite to open the file with write access */
166
161
  openMode: OpenMode;
167
162
  }
168
- /** Parameters for creating a new SQLiteDb */
169
- interface CreateParams extends OpenOrCreateParams {
163
+ /** Size of a SQLiteDb page in bytes */
164
+ interface PageSize {
170
165
  /** see https://www.sqlite.org/pragma.html#pragma_page_size */
171
166
  pageSize?: number;
172
167
  }
168
+ /** Parameters for creating a new SQLiteDb */
169
+ type CreateParams = OpenOrCreateParams & PageSize;
170
+ /** Parameters used to obtain the write lock on a cloud container
171
+ * @internal
172
+ */
173
+ interface ObtainLockParams {
174
+ /** The name of the user attempting to acquire the write lock. This name will be shown to other users while the lock is held. */
175
+ user?: string;
176
+ /** number of times to retry in the event the lock currently held by someone else.
177
+ * After this number of attempts, `onFailure` is called. Default is 20.
178
+ */
179
+ nRetries: number;
180
+ /** Delay between retries, in milliseconds. Default is 100. */
181
+ retryDelayMs: number;
182
+ /** function called if lock cannot be obtained after all retries. It is called with the name of the user currently holding the lock and
183
+ * generally is expected that the user will be consulted whether to wait further.
184
+ * If this function returns "stop", an exception will be thrown. Otherwise the retry cycle is restarted. */
185
+ onFailure?: CloudSqlite.WriteLockBusyHandler;
186
+ }
187
+ /** @internal */
188
+ interface LockAndOpenArgs {
189
+ /** the name to be displayed in the event of lock collisions */
190
+ user: string;
191
+ /** the name of the database within the container */
192
+ dbName: string;
193
+ /** the CloudContainer on which the operation will be performed */
194
+ container: SQLiteDb.CloudContainer;
195
+ /** if present, function called when the write lock is currently held by another user. */
196
+ busyHandler?: CloudSqlite.WriteLockBusyHandler;
197
+ }
198
+ /** Arguments for `SqliteDb.withOpenDb` */
199
+ interface WithOpenDbArgs {
200
+ /** The name of the database to open */
201
+ dbName: string;
202
+ /** either an object with the open parameters or just OpenMode value. */
203
+ openMode?: OpenMode | SQLiteDb.OpenParams;
204
+ /** @internal */
205
+ container?: SQLiteDb.CloudContainer;
206
+ }
207
+ /** Arguments for `SQLiteDb.vacuum` */
208
+ interface VacuumDbArgs extends PageSize {
209
+ /** if present, name of new file to [vacuum into](https://www.sqlite.org/lang_vacuum.html) */
210
+ into?: LocalFileName;
211
+ }
173
212
  }
174
213
  //# sourceMappingURL=SQLiteDb.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SQLiteDb.d.ts","sourceRoot":"","sources":["../../src/SQLiteDb.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,eAAe,EAAkB,MAAM,mBAAmB,CAAC;AAIpE;;GAEG;AACH,qBAAa,QAAS,YAAW,WAAW;IAC1C,gBAAgB;IAChB,SAAgB,QAAQ,0BAAsC;IAC9D,OAAO,CAAC,qBAAqB,CAAyC;IAEtE,gBAAgB;WACF,oBAAoB,CAAC,IAAI,EAAE,WAAW,CAAC,oBAAoB,GAAG,QAAQ,CAAC,cAAc;IAGnG,gBAAgB;WACF,gBAAgB,CAAC,IAAI,EAAE,WAAW,CAAC,UAAU,GAAG,QAAQ,CAAC,UAAU;IAGjF,gBAAgB;WACF,kBAAkB,CAAC,SAAS,EAAE,QAAQ,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,CAAC,aAAa,GAAG,QAAQ,CAAC,aAAa;IAG9I,gBAAgB;WACF,YAAY,IAAI,QAAQ,CAAC,MAAM;IAI7C,yBAAyB;IAClB,OAAO,IAAI,IAAI;IAItB;;OAEG;IACI,QAAQ,CAAC,MAAM,EAAE,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,8DAA8D;QAC9D,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB;IAED,6CAA6C;IAC7C,KAAY,YAAY,GAAG,kBAAkB,GAAG,QAAQ,CAAC;IAEzD;;OAEG;IACH,UAAiB,gBAAgB;QAC/B,gIAAgI;QAChI,IAAI,CAAC,EAAE,MAAM,CAAC;QACd;;SAEC;QACD,QAAQ,EAAE,MAAM,CAAC;QACjB,8DAA8D;QAC9D,YAAY,EAAE,MAAM,CAAC;QACrB;;iHAEyG;QACzG,SAAS,CAAC,EAAE,WAAW,CAAC,oBAAoB,CAAC;KAC9C;IAED,gBAAgB;IAChB,UAAiB,eAAe;QAC9B,+DAA+D;QAC/D,IAAI,EAAE,MAAM,CAAC;QACb,oDAAoD;QACpD,MAAM,EAAE,MAAM,CAAC;QACf,kEAAkE;QAClE,SAAS,EAAE,QAAQ,CAAC,cAAc,CAAC;QACnC,yFAAyF;QACzF,WAAW,CAAC,EAAE,WAAW,CAAC,oBAAoB,CAAC;KAChD;IAED,0CAA0C;IAC1C,UAAiB,cAAc;QAC7B,uCAAuC;QACvC,MAAM,EAAE,MAAM,CAAC;QACf,wEAAwE;QACxE,QAAQ,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC,UAAU,CAAC;QAC1C,gBAAgB;QAChB,SAAS,CAAC,EAAE,QAAQ,CAAC,cAAc,CAAC;KACrC;IAED,sCAAsC;IACtC,UAAiB,YAAa,SAAQ,QAAQ;QAC5C,6FAA6F;QAC7F,IAAI,CAAC,EAAE,aAAa,CAAC;KACtB;CACF"}
@@ -12,6 +12,7 @@ const imodeljs_native_1 = require("@bentley/imodeljs-native");
12
12
  const core_bentley_1 = require("@itwin/core-bentley");
13
13
  const IModelHost_1 = require("./IModelHost");
14
14
  const SqliteStatement_1 = require("./SqliteStatement");
15
+ // cspell:ignore savepoint
15
16
  /* eslint-disable @typescript-eslint/unified-signatures */
16
17
  /** A SQLiteDb file
17
18
  * @public
@@ -53,7 +54,7 @@ class SQLiteDb {
53
54
  this.nativeDb.openDb(dbName, openMode, container);
54
55
  }
55
56
  /** Close SQLiteDb.
56
- * @param saveChanges if true, call `saveChanges` before closing db.
57
+ * @param saveChanges if true, call `saveChanges` before closing db. Otherwise unsaved changes are abandoned.
57
58
  */
58
59
  closeDb(saveChanges) {
59
60
  if (saveChanges && this.isOpen)
@@ -61,45 +62,53 @@ class SQLiteDb {
61
62
  this._sqliteStatementCache.clear();
62
63
  this.nativeDb.closeDb();
63
64
  }
64
- /** Returns true if the SQLiteDb is open */
65
+ /** Returns true if this SQLiteDb is open */
65
66
  get isOpen() { return this.nativeDb.isOpen(); }
67
+ /** Returns true if this SQLiteDb is open readonly */
68
+ get isReadonly() { return this.nativeDb.isReadonly(); }
66
69
  /**
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
+ * Open a database, perform an operation, then close the database.
71
+ *
72
+ * Details:
73
+ * - if database is open, throw an error
74
+ * - open a database
75
+ * - call a function with the database opened. If it is async, await its return.
76
+ * - if function throws, abandon all changes, close database, and rethrow
77
+ * - save all changes
78
+ * - close the database
79
+ * @return value from operation
70
80
  */
71
- static withOpenDb(args, operation) {
81
+ withOpenDb(args, operation) {
72
82
  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;
83
+ if (this.isOpen)
84
+ throw new Error("database is already open");
85
+ const save = () => this.closeDb(true), abandon = () => this.closeDb(false);
86
+ this.openDb(args.dbName, (_a = args.openMode) !== null && _a !== void 0 ? _a : core_bentley_1.OpenMode.Readonly, args.container);
76
87
  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
- }
88
+ const result = operation();
89
+ result instanceof Promise ? result.then(save, abandon) : save();
83
90
  return result;
84
91
  }
85
- finally {
86
- if (!fromPromise)
87
- db.closeDb();
92
+ catch (e) {
93
+ abandon();
94
+ throw e;
88
95
  }
89
96
  }
90
97
  /**
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.
98
+ * Perform an operation on a database in a CloudContainer with the write lock held.
99
+ *
100
+ * Details:
101
+ * - acquire the write lock on a CloudContainer
102
+ * - call `withOpenDb` with openMode `ReadWrite`
103
+ * - upload changes
104
+ * - release the write lock
105
+ * @param args arguments to lock the container and open the database
106
+ * @param operation an operation performed on the database with the write lock held.
107
+ * @return value from operation
96
108
  * @internal
97
109
  */
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);
110
+ async withLockedContainer(args, operation) {
111
+ return imodeljs_native_1.CloudSqlite.withWriteLock(args.user, args.container, () => this.withOpenDb({ ...args, openMode: core_bentley_1.OpenMode.ReadWrite }, operation), args.busyHandler);
103
112
  }
104
113
  /** vacuum this database
105
114
  * @see https://www.sqlite.org/lang_vacuum.html
@@ -131,12 +140,7 @@ class SQLiteDb {
131
140
  const release = () => this._sqliteStatementCache.addOrDispose(stmt);
132
141
  try {
133
142
  const val = callback(stmt);
134
- if (val instanceof Promise) {
135
- val.then(release, release);
136
- }
137
- else {
138
- release();
139
- }
143
+ val instanceof Promise ? val.then(release, release) : release();
140
144
  return val;
141
145
  }
142
146
  catch (err) {
@@ -157,12 +161,7 @@ class SQLiteDb {
157
161
  const release = () => stmt.dispose();
158
162
  try {
159
163
  const val = callback(stmt);
160
- if (val instanceof Promise) {
161
- val.then(release, release);
162
- }
163
- else {
164
- release();
165
- }
164
+ val instanceof Promise ? val.then(release, release) : release();
166
165
  return val;
167
166
  }
168
167
  catch (err) {
@@ -170,6 +169,24 @@ class SQLiteDb {
170
169
  throw err;
171
170
  }
172
171
  }
172
+ /**
173
+ * Perform an operation on this database within a [savepoint](https://www.sqlite.org/lang_savepoint.html). If the operation completes successfully, the
174
+ * changes remain in the current transaction. If the operation throws an exception, the savepoint is rolled back
175
+ * and all changes to the database from this method are reversed, leaving the transaction exactly as it was before this method.
176
+ */
177
+ withSavePoint(savePointName, operation) {
178
+ if (this.isReadonly)
179
+ throw new Error("database is readonly");
180
+ this.executeSQL(`SAVEPOINT ${savePointName}`);
181
+ try {
182
+ operation();
183
+ this.executeSQL(`RELEASE ${savePointName}`);
184
+ }
185
+ catch (e) {
186
+ this.executeSQL(`ROLLBACK TO ${savePointName}`);
187
+ throw e;
188
+ }
189
+ }
173
190
  /** Prepare an SQL statement.
174
191
  * @param sql The SQLite SQL statement to prepare
175
192
  * @param logErrors Determine if errors are logged or not
@@ -1 +1 @@
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;IAjNC,gBAAgB;IACT,MAAM,CAAC,oBAAoB,CAAC,IAAsC;QACvE,OAAO,IAAI,uBAAU,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IACD,gBAAgB;IACT,MAAM,CAAC,gBAAgB,CAAC,IAA4B;QACzD,OAAO,IAAI,uBAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IA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,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"]}
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,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;IA+MxE,CAAC;IA7MC,gBAAgB;IACT,MAAM,CAAC,oBAAoB,CAAC,IAAsC;QACvE,OAAO,IAAI,uBAAU,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IACD,gBAAgB;IACT,MAAM,CAAC,gBAAgB,CAAC,IAA4B;QACzD,OAAO,IAAI,uBAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC;IACD,gBAAgB;IACT,MAAM,CAAC,kBAAkB,CAAC,SAAkC,EAAE,MAAc,EAAE,IAAgC;QACnH,OAAO,IAAI,uBAAU,CAAC,QAAQ,CAAC,aAAa,CA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CAAC;YACZ,IAAI,CAAC,UAAU,CAAC,WAAW,aAAa,EAAE,CAAC,CAAC;SAC7C;QAAC,OAAO,CAAC,EAAE;YACV,IAAI,CAAC,UAAU,CAAC,eAAe,aAAa,EAAE,CAAC,CAAC;YAChD,MAAM,CAAC,CAAC;SACT;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;AAlND,4BAkNC;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;AA8EH,CAAC,EAxGgB,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAwGxB","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// 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 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. 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: SQLiteDb.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 /** 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 /** 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 /** Parameters used to obtain the write lock on a cloud container\r\n * @internal\r\n */\r\n export interface ObtainLockParams {\r\n /** The name of the user attempting to acquire the write lock. This name will be shown to other users while the lock is held. */\r\n user?: string;\r\n /** number of times to retry in the event the lock currently held by someone else.\r\n * After this number of attempts, `onFailure` is called. Default is 20.\r\n */\r\n nRetries: number;\r\n /** Delay between retries, in milliseconds. Default is 100. */\r\n retryDelayMs: number;\r\n /** function called if lock cannot be obtained after all retries. It is called with the name of the user currently holding the lock and\r\n * generally is expected that the user will be consulted whether to wait further.\r\n * If this function returns \"stop\", an exception will be thrown. Otherwise the retry cycle is restarted. */\r\n onFailure?: CloudSqlite.WriteLockBusyHandler;\r\n }\r\n\r\n /** @internal */\r\n export interface LockAndOpenArgs {\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\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?: SQLiteDb.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"]}
@@ -40,8 +40,9 @@ export declare type BindParameter = number | string;
40
40
  export declare class SqliteStatement implements IterableIterator<any>, IDisposable {
41
41
  private _sql;
42
42
  private _stmt;
43
+ private _db;
43
44
  constructor(_sql: string);
44
- get stmt(): IModelJsNative.SqliteStatement | undefined;
45
+ get stmt(): IModelJsNative.SqliteStatement;
45
46
  get sql(): string;
46
47
  /** Check if this statement has been prepared successfully or not */
47
48
  get isPrepared(): boolean;
@@ -52,7 +53,7 @@ export declare class SqliteStatement implements IterableIterator<any>, IDisposab
52
53
  * @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.
53
54
  * The error.message property will provide details.
54
55
  */
55
- prepare(db: IModelJsNative.DgnDb | IModelJsNative.ECDb | IModelJsNative.SQLiteDb, logErrors?: boolean): void;
56
+ prepare(db: IModelJsNative.AnyDb, logErrors?: boolean): void;
56
57
  /** Indicates whether the prepared statement makes no **direct* changes to the content of the file
57
58
  * or not. See [SQLite docs](https://www.sqlite.org/c3ref/stmt_readonly.html) for details.
58
59
  */
@@ -62,6 +63,13 @@ export declare class SqliteStatement implements IterableIterator<any>, IDisposab
62
63
  reset(): void;
63
64
  /** Call this function when finished with this statement. This releases the native resources held by the statement. */
64
65
  dispose(): void;
66
+ /**
67
+ * Call `step` on this statement and determine whether a new row is available.
68
+ * Use this method only when this statement has been prepared with a SELECT statement.
69
+ * @return true if a new row is available, false otherwise.
70
+ * @throws if `step` returns anything other than BE_SQLITE_ROW or BE_SQLITE_DONE.
71
+ */
72
+ nextRow(): boolean;
65
73
  /** Binds a value to the specified SQL parameter.
66
74
  * The value must be of one of these types:
67
75
  * JavaScript Type | SQLite Type
@@ -145,6 +153,10 @@ export declare class SqliteStatement implements IterableIterator<any>, IDisposab
145
153
  * @param columnIx Index of SQL column in query result (0-based)
146
154
  */
147
155
  getValue(columnIx: number): SqliteValue;
156
+ /** Determine whether the value of the specified column is null
157
+ * @param colIndex Index of SQL column in query result (0-based)
158
+ */
159
+ isValueNull(colIndex: number): boolean;
148
160
  /** Get a size in bytes of a blob or text column
149
161
  * @param colIndex Index of SQL column in query result (0-based)
150
162
  */
@@ -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,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