@itwin/core-backend 4.8.0-dev.3 → 4.8.0-dev.4

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 (98) hide show
  1. package/lib/cjs/BackendLoggerCategory.d.ts +3 -1
  2. package/lib/cjs/BackendLoggerCategory.d.ts.map +1 -1
  3. package/lib/cjs/BackendLoggerCategory.js +2 -0
  4. package/lib/cjs/BackendLoggerCategory.js.map +1 -1
  5. package/lib/cjs/BlobContainerService.d.ts +3 -3
  6. package/lib/cjs/BlobContainerService.d.ts.map +1 -1
  7. package/lib/cjs/BlobContainerService.js.map +1 -1
  8. package/lib/cjs/CloudSqlite.d.ts +21 -13
  9. package/lib/cjs/CloudSqlite.d.ts.map +1 -1
  10. package/lib/cjs/CloudSqlite.js +24 -6
  11. package/lib/cjs/CloudSqlite.js.map +1 -1
  12. package/lib/cjs/CodeService.d.ts +4 -4
  13. package/lib/cjs/CodeService.d.ts.map +1 -1
  14. package/lib/cjs/CodeService.js.map +1 -1
  15. package/lib/cjs/GeoCoordConfig.d.ts +10 -0
  16. package/lib/cjs/GeoCoordConfig.d.ts.map +1 -1
  17. package/lib/cjs/GeoCoordConfig.js +20 -23
  18. package/lib/cjs/GeoCoordConfig.js.map +1 -1
  19. package/lib/cjs/IModelDb.d.ts +14 -9
  20. package/lib/cjs/IModelDb.d.ts.map +1 -1
  21. package/lib/cjs/IModelDb.js +53 -17
  22. package/lib/cjs/IModelDb.js.map +1 -1
  23. package/lib/cjs/IModelHost.d.ts +8 -1
  24. package/lib/cjs/IModelHost.d.ts.map +1 -1
  25. package/lib/cjs/IModelHost.js +24 -15
  26. package/lib/cjs/IModelHost.js.map +1 -1
  27. package/lib/cjs/PropertyStore.d.ts +17 -7
  28. package/lib/cjs/PropertyStore.d.ts.map +1 -1
  29. package/lib/cjs/PropertyStore.js +11 -5
  30. package/lib/cjs/PropertyStore.js.map +1 -1
  31. package/lib/cjs/SQLiteDb.d.ts +2 -3
  32. package/lib/cjs/SQLiteDb.d.ts.map +1 -1
  33. package/lib/cjs/SQLiteDb.js +2 -3
  34. package/lib/cjs/SQLiteDb.js.map +1 -1
  35. package/lib/cjs/SchemaSync.d.ts +1 -1
  36. package/lib/cjs/SchemaSync.d.ts.map +1 -1
  37. package/lib/cjs/SchemaSync.js.map +1 -1
  38. package/lib/cjs/TextAnnotationGeometry.d.ts +4 -0
  39. package/lib/cjs/TextAnnotationGeometry.d.ts.map +1 -1
  40. package/lib/cjs/TextAnnotationGeometry.js +2 -3
  41. package/lib/cjs/TextAnnotationGeometry.js.map +1 -1
  42. package/lib/cjs/TextAnnotationLayout.d.ts +21 -13
  43. package/lib/cjs/TextAnnotationLayout.d.ts.map +1 -1
  44. package/lib/cjs/TextAnnotationLayout.js +119 -90
  45. package/lib/cjs/TextAnnotationLayout.js.map +1 -1
  46. package/lib/cjs/ViewStore.d.ts +16 -2
  47. package/lib/cjs/ViewStore.d.ts.map +1 -1
  48. package/lib/cjs/ViewStore.js +14 -1
  49. package/lib/cjs/ViewStore.js.map +1 -1
  50. package/lib/cjs/assets/Settings/Schemas/Base.Schema.json +33 -0
  51. package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +17 -21
  52. package/lib/cjs/assets/Settings/Schemas/Workspace.Schema.json +80 -38
  53. package/lib/cjs/assets/Settings/backend.setting.json5 +8 -119
  54. package/lib/cjs/core-backend.d.ts +2 -1
  55. package/lib/cjs/core-backend.d.ts.map +1 -1
  56. package/lib/cjs/core-backend.js +3 -2
  57. package/lib/cjs/core-backend.js.map +1 -1
  58. package/lib/cjs/internal/ImplementationProhibited.d.ts +44 -0
  59. package/lib/cjs/internal/ImplementationProhibited.d.ts.map +1 -0
  60. package/lib/cjs/internal/ImplementationProhibited.js +51 -0
  61. package/lib/cjs/internal/ImplementationProhibited.js.map +1 -0
  62. package/lib/cjs/internal/workspace/SettingsImpl.d.ts +43 -0
  63. package/lib/cjs/internal/workspace/SettingsImpl.d.ts.map +1 -0
  64. package/lib/cjs/internal/workspace/SettingsImpl.js +161 -0
  65. package/lib/cjs/internal/workspace/SettingsImpl.js.map +1 -0
  66. package/lib/cjs/internal/workspace/SettingsSchemasImpl.d.ts +6 -0
  67. package/lib/cjs/internal/workspace/SettingsSchemasImpl.d.ts.map +1 -0
  68. package/lib/cjs/internal/workspace/SettingsSchemasImpl.js +276 -0
  69. package/lib/cjs/internal/workspace/SettingsSchemasImpl.js.map +1 -0
  70. package/lib/cjs/internal/workspace/WorkspaceImpl.d.ts +41 -0
  71. package/lib/cjs/internal/workspace/WorkspaceImpl.d.ts.map +1 -0
  72. package/lib/cjs/internal/workspace/WorkspaceImpl.js +696 -0
  73. package/lib/cjs/internal/workspace/WorkspaceImpl.js.map +1 -0
  74. package/lib/cjs/internal/workspace/WorkspaceSqliteDb.d.ts +10 -0
  75. package/lib/cjs/internal/workspace/WorkspaceSqliteDb.d.ts.map +1 -0
  76. package/lib/cjs/internal/workspace/WorkspaceSqliteDb.js +41 -0
  77. package/lib/cjs/internal/workspace/WorkspaceSqliteDb.js.map +1 -0
  78. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -1
  79. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +1 -2
  80. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  81. package/lib/cjs/workspace/Settings.d.ts +167 -138
  82. package/lib/cjs/workspace/Settings.d.ts.map +1 -1
  83. package/lib/cjs/workspace/Settings.js +68 -138
  84. package/lib/cjs/workspace/Settings.js.map +1 -1
  85. package/lib/cjs/workspace/SettingsSchemas.d.ts +112 -48
  86. package/lib/cjs/workspace/SettingsSchemas.d.ts.map +1 -1
  87. package/lib/cjs/workspace/SettingsSchemas.js +1 -172
  88. package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
  89. package/lib/cjs/workspace/Workspace.d.ts +411 -277
  90. package/lib/cjs/workspace/Workspace.d.ts.map +1 -1
  91. package/lib/cjs/workspace/Workspace.js +76 -457
  92. package/lib/cjs/workspace/Workspace.js.map +1 -1
  93. package/lib/cjs/workspace/WorkspaceEditor.d.ts +245 -0
  94. package/lib/cjs/workspace/WorkspaceEditor.d.ts.map +1 -0
  95. package/lib/cjs/workspace/WorkspaceEditor.js +34 -0
  96. package/lib/cjs/workspace/WorkspaceEditor.js.map +1 -0
  97. package/package.json +12 -12
  98. package/lib/cjs/assets/Settings/Schemas/Cloud.Schema.json +0 -45
@@ -1 +1 @@
1
- {"version":3,"file":"SQLiteDb.d.ts","sourceRoot":"","sources":["../../src/SQLiteDb.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,OAAO,EAAE,eAAe,EAAkB,MAAM,mBAAmB,CAAC;AAMpE;;;GAGG;AACH,qBAAa,QAAQ;IACnB,gBAAgB;IAChB,SAAgB,QAAQ,0BAAsC;IAC9D,OAAO,CAAC,qBAAqB,CAAyC;IAEtE,gBAAgB;WACF,YAAY,IAAI,QAAQ,CAAC,MAAM;IAI7C;;OAEG;IACI,OAAO,IAAI,IAAI;IAItB;;OAEG;IACI,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IACrC,YAAY;IACL,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,WAAW,CAAC,cAAc,EAAE,MAAM,CAAC,EAAE,QAAQ,CAAC,YAAY,GAAG,IAAI;IAK7G;;OAEG;IACI,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,QAAQ,CAAC,UAAU,GAAG,IAAI;IAC7E;;;OAGG;IACI,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE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AG,kBAAkB,GAAG,QAAQ,CAAC;IAEzD,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,WAAW,CAAC,cAAc,CAAC;KACxC;IAED,sCAAsC;IACtC,UAAiB,YAAa,SAAQ,QAAQ;QAC5C,6FAA6F;QAC7F,IAAI,CAAC,EAAE,aAAa,CAAC;KACtB;CACF"}
@@ -253,16 +253,15 @@ class VersionedSqliteDb extends SQLiteDb {
253
253
  }
254
254
  /**
255
255
  * Create a new database file for the subclass of VersionedSqliteDb.
256
- * @param fileName the name of a local
257
256
  * @note The required versions are saved as [[myVersion]] or newer for both read and write.
258
257
  */
259
- static createNewDb(fileName) {
258
+ static createNewDb(fileName, setupArgs) {
260
259
  const db = new this(); // "as any" necessary because VersionedSqliteDb is abstract
261
260
  IModelJsFs_1.IModelJsFs.recursiveMkDirSync((0, path_1.dirname)(fileName));
262
261
  if (fs.existsSync(fileName))
263
262
  fs.unlinkSync(fileName);
264
263
  db.createDb(fileName);
265
- db.createDDL();
264
+ db.createDDL(setupArgs);
266
265
  const minVer = `^${db.myVersion}`;
267
266
  db.setRequiredVersions({ readVersion: minVer, writeVersion: minVer });
268
267
  db.closeDb(true);
@@ -1 +1 @@
1
- {"version":3,"file":"SQLiteDb.js","sourceRoot":"","sources":["../../src/SQLiteDb.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,yBAAyB;AACzB,+BAA+B;AAC/B,iCAAiC;AAEjC,sDAAyD;AAEzD,+CAA4C;AAC5C,6CAA0C;AAC1C,6CAA0C;AAC1C,uDAAoE;AAEpE,0CAA0C;AAE1C,0DAA0D;AAE1D;;;GAGG;AACH,MAAa,QAAQ;IAArB;QACE,gBAAgB;QACA,aAAQ,GAAG,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AO,CAAC,CAAC,CAAC,OAAO,eAAe,IAAI,CAAC,WAAW,CAAC,IAAI,QAAQ,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;IAEpK,CAAC;IAED;;;;OAIG;IACa,MAAM,CAAC,MAAc,EAAE,QAAwC,EAAE,SAAsC;QACrH,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;QAC1C,IAAI,CAAC,cAAc,EAAE,CAAC;IACxB,CAAC;IAEM,KAAK,CAAC,aAAa,CAAC,GAAuH;QAChJ,2EAA2E;QAC3E,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC;YAC1B,KAAK,CAAC,mBAAmB,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,aAAa,EAAE,EAAE,KAAK,IAAI,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;YACpG,KAAK,CAAC,UAAU,CAAC,EAAE,GAAG,GAAG,EAAE,QAAQ,EAAE,uBAAQ,CAAC,SAAS,EAAE,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC;IAC9E,CAAC;;AA9FH,8CA+FC;AA9FkB,+BAAa,GAAG,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAW,CAAC;AAgGxF,cAAc;AACd,WAAiB,QAAQ;IAqEvB;;OAEG;IACH,IAAY,cASX;IATD,WAAY,cAAc;QACxB,4GAA4G;QAC5G,mDAAQ,CAAA;QACR,4FAA4F;QAC5F,2DAAY,CAAA;QACZ,yEAAyE;QACzE,6DAAa,CAAA;QACb,yEAAyE;QACzE,6DAAa,CAAA;IACf,CAAC,EATW,cAAc,GAAd,uBAAc,KAAd,uBAAc,QASzB;AAgDH,CAAC,EAjIgB,QAAQ,wBAAR,QAAQ,QAiIxB","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module SQLiteDb\r\n */\r\n\r\nimport * as fs from \"fs\";\r\nimport { dirname } from \"path\";\r\nimport * as semver from \"semver\";\r\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\nimport { DbResult, OpenMode } from \"@itwin/core-bentley\";\r\nimport { LocalFileName } from \"@itwin/core-common\";\r\nimport { CloudSqlite } from \"./CloudSqlite\";\r\nimport { IModelHost } from \"./IModelHost\";\r\nimport { IModelJsFs } from \"./IModelJsFs\";\r\nimport { SqliteStatement, StatementCache } from \"./SqliteStatement\";\r\n\r\n// cspell:ignore savepoint julianday rowid\r\n\r\n/* eslint-disable @typescript-eslint/unified-signatures */\r\n\r\n/**\r\n * A \"generic\" SQLiteDb. This class may be used to access local files or databases in a cloud container.\r\n * @public\r\n */\r\nexport class SQLiteDb {\r\n /** @internal */\r\n public readonly nativeDb = new IModelHost.platform.SQLiteDb();\r\n private _sqliteStatementCache = new StatementCache<SqliteStatement>();\r\n\r\n /** @internal */\r\n public static createBlobIO(): SQLiteDb.BlobIO {\r\n return new IModelHost.platform.BlobIO();\r\n }\r\n\r\n /** alias for closeDb.\r\n * @deprecated in 4.0, use [[closeDb]]\r\n */\r\n public dispose(): void {\r\n this.closeDb();\r\n }\r\n\r\n /** Create a SQLiteDb\r\n * @param dbName The path to the SQLiteDb file to create.\r\n */\r\n public createDb(dbName: string): void;\r\n /** @beta */\r\n public createDb(dbName: string, container?: CloudSqlite.CloudContainer, params?: SQLiteDb.CreateParams): void;\r\n public createDb(dbName: string, container?: CloudSqlite.CloudContainer, params?: SQLiteDb.CreateParams): void {\r\n this.nativeDb.createDb(dbName, container, params);\r\n }\r\n\r\n /** Open a SQLiteDb.\r\n * @param dbName The path to the SQLiteDb file to open\r\n */\r\n public openDb(dbName: string, openMode: OpenMode | SQLiteDb.OpenParams): void;\r\n /**\r\n * @param container optional CloudContainer holding database\r\n * @beta\r\n */\r\n public openDb(dbName: string, openMode: OpenMode | SQLiteDb.OpenParams, container?: CloudSqlite.CloudContainer): void;\r\n public openDb(dbName: string, openMode: OpenMode | SQLiteDb.OpenParams, container?: CloudSqlite.CloudContainer): void {\r\n this.nativeDb.openDb(dbName, openMode, container);\r\n }\r\n\r\n /** Close SQLiteDb.\r\n * @param saveChanges if true, call `saveChanges` before closing db. Otherwise unsaved changes are abandoned.\r\n */\r\n public closeDb(saveChanges?: boolean): void {\r\n if (saveChanges && this.isOpen)\r\n this.saveChanges();\r\n this._sqliteStatementCache.clear();\r\n this.nativeDb.closeDb();\r\n }\r\n\r\n /** Returns true if this SQLiteDb is open */\r\n public get isOpen(): boolean { return this.nativeDb.isOpen(); }\r\n\r\n /** Returns true if this SQLiteDb is open readonly */\r\n public get isReadonly(): boolean { return this.nativeDb.isReadonly(); }\r\n\r\n /** Create a new table in this database. */\r\n protected createTable(args: {\r\n /** The name of the table to create. */\r\n tableName: string;\r\n /** all of the columns in the table. */\r\n columns: string;\r\n /** any unique or foreign key constraints */\r\n constraints?: string;\r\n /** if true, add a \"lastMod\" timestamp column and triggers to automatically update it. */\r\n addTimestamp?: boolean;\r\n }) {\r\n const timestampCol = args.addTimestamp ? \",lastMod TIMESTAMP NOT NULL DEFAULT(julianday('now'))\" : \"\";\r\n const constraints = args.constraints ? `,${args.constraints}` : \"\";\r\n this.executeSQL(`CREATE TABLE ${args.tableName}(${args.columns}${timestampCol}${constraints})`);\r\n if (args.addTimestamp)\r\n this.executeSQL(`CREATE TRIGGER ${args.tableName}_timestamp AFTER UPDATE ON ${args.tableName} WHEN old.lastMod=new.lastMod AND old.lastMod != julianday('now') BEGIN UPDATE ${args.tableName} SET lastMod=julianday('now') WHERE rowid=new.rowid; END`);\r\n }\r\n\r\n /**\r\n * Get the last modified date for a row in a table of this database.\r\n * @note the table must have been created with `addTimestamp: true`\r\n */\r\n public readLastModTime(tableName: string, rowId: number): Date {\r\n return this.withSqliteStatement(`SELECT lastMod from ${tableName} WHERE rowid=?`, (stmt) => {\r\n stmt.bindInteger(1, rowId);\r\n return stmt.getValueDate(0);\r\n });\r\n }\r\n\r\n /**\r\n * Open a database, perform an operation, then close the database.\r\n *\r\n * Details:\r\n * - if database is open, throw an error\r\n * - open a database\r\n * - call a function with the database opened. If it is async, await its return.\r\n * - if function throws, abandon all changes, close database, and rethrow\r\n * - save all changes\r\n * - close the database\r\n * @return value from operation\r\n */\r\n public withOpenDb<T>(args: SQLiteDb.WithOpenDbArgs, operation: () => T): T {\r\n if (this.isOpen)\r\n throw new Error(\"database is already open\");\r\n\r\n const save = () => this.closeDb(true), abandon = () => this.closeDb(false);\r\n this.openDb(args.dbName, args.openMode ?? OpenMode.Readonly, args.container);\r\n try {\r\n const result = operation();\r\n result instanceof Promise ? result.then(save, abandon) : save();\r\n return result;\r\n } catch (e) {\r\n abandon();\r\n throw e;\r\n }\r\n }\r\n\r\n /**\r\n * Perform an operation on a database in a CloudContainer with the write lock held.\r\n *\r\n * Details:\r\n * - acquire the write lock on a CloudContainer\r\n * - call `withOpenDb` with openMode `ReadWrite`\r\n * - upload changes\r\n * - release the write lock\r\n * @param args arguments to lock the container and open the database\r\n * @param operation an operation performed on the database with the write lock held.\r\n * @return value from operation\r\n * @internal\r\n */\r\n public async withLockedContainer<T>(args: CloudSqlite.LockAndOpenArgs, operation: () => Promise<T>) {\r\n return CloudSqlite.withWriteLock(args, async () => this.withOpenDb({ ...args, openMode: args.openMode ?? OpenMode.ReadWrite }, operation));\r\n }\r\n\r\n /** vacuum this database\r\n * @see https://www.sqlite.org/lang_vacuum.html\r\n */\r\n public vacuum(args?: SQLiteDb.VacuumDbArgs) {\r\n this.nativeDb.vacuum(args);\r\n }\r\n\r\n /** Commit the outermost transaction, writing changes to the file. Then, restart the default transaction. */\r\n public saveChanges(): void {\r\n this.nativeDb.saveChanges();\r\n }\r\n\r\n /** Abandon (cancel) the outermost transaction, discarding all changes since last save. Then, restart the default transaction. */\r\n public abandonChanges(): void {\r\n this.nativeDb.abandonChanges();\r\n }\r\n\r\n /**\r\n * Use a prepared SQL statement, potentially from the statement cache. If the requested statement doesn't exist\r\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\r\n * in the statement cache so it can be reused in the future. Use this method for SQL statements that will be\r\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\r\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withSqliteStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @returns the value returned by `callback`.\r\n */\r\n public withPreparedSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T): T {\r\n const stmt = this._sqliteStatementCache.findAndRemove(sql) ?? this.prepareSqliteStatement(sql);\r\n const release = () => this._sqliteStatementCache.addOrDispose(stmt);\r\n try {\r\n const val = callback(stmt);\r\n val instanceof Promise ? val.then(release, release) : release();\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Prepare and execute a callback on a SQL statement. After the callback completes the statement is disposed.\r\n * Use this method for SQL statements are either not expected to be reused, or are not expensive to prepare.\r\n * For statements that will be reused often, instead use [[withPreparedSqliteStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @returns the value returned by `callback`.\r\n */\r\n public withSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T): T {\r\n const stmt = this.prepareSqliteStatement(sql);\r\n const release = () => stmt.dispose();\r\n try {\r\n const val = callback(stmt);\r\n val instanceof Promise ? val.then(release, release) : release();\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Perform an operation on this database within a [savepoint](https://www.sqlite.org/lang_savepoint.html). If the operation completes successfully, the\r\n * changes remain in the current transaction. If the operation throws an exception, the savepoint is rolled back\r\n * and all changes to the database from this method are reversed, leaving the transaction exactly as it was before this method.\r\n */\r\n public withSavePoint(savePointName: string, operation: () => void) {\r\n if (this.isReadonly)\r\n throw new Error(\"database is readonly\");\r\n\r\n this.executeSQL(`SAVEPOINT ${savePointName}`);\r\n try {\r\n operation();\r\n this.executeSQL(`RELEASE ${savePointName}`);\r\n } catch (e) {\r\n this.executeSQL(`ROLLBACK TO ${savePointName}`);\r\n throw e;\r\n }\r\n }\r\n\r\n /** Prepare an SQL statement.\r\n * @param sql The SQLite SQL statement to prepare\r\n * @param logErrors Determine if errors are logged or not\r\n * @internal\r\n */\r\n public prepareSqliteStatement(sql: string, logErrors = true): SqliteStatement {\r\n const stmt = new SqliteStatement(sql);\r\n stmt.prepare(this.nativeDb, logErrors);\r\n return stmt;\r\n }\r\n\r\n /** execute an SQL statement */\r\n public executeSQL(sql: string): DbResult {\r\n const stmt = this.prepareSqliteStatement(sql);\r\n try {\r\n return stmt.step();\r\n } finally {\r\n stmt.dispose();\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Abstract base class for a SQLite database that has [[SQLiteDb.RequiredVersionRanges]] stored in it.\r\n * This class provides version checking when the database is opened, to guarantee that a valid version of software is\r\n * always used for access.\r\n *\r\n * Notes:\r\n * - This class may be used either to access a local file, or one stored in a cloud container.\r\n * - Subclasses must provide a `myVersion` member indicating the version of its software, and implement the `createDDL` member to create its\r\n * tables.\r\n * @beta\r\n */\r\nexport abstract class VersionedSqliteDb extends SQLiteDb {\r\n protected static _versionProps = { namespace: \"SQLiteDb\", name: \"versions\" } as const;\r\n\r\n /** The current semver \"persistence version\" of this class.\r\n * @note This value should only be changed when logic in its code is modified in a way that affects the operation of extant copies.\r\n * If this value is outside of the range of accepted versions of a to-be-opened VersionedSqliteDb, the operation will fail. In this manner, if\r\n * changes are made to the format of a VersionedSqliteDb, or if bug fixes are necessary, the `requiredVersions` property in a VersionedSqliteDb may be updated\r\n * and immediately old versions of the package will refuse to open the VersionedSqliteDb, with a message to the user that they need to upgrade their\r\n * software. Likewise, if a new version of the package is asked to open an older VersionedSqliteDb that has not been upgraded to the lowest version\r\n * supported by it, the user will be informed that they need to upgrade their software.\r\n * @note this identifier is independent of versions in `package.json` files.\r\n */\r\n public abstract myVersion: string;\r\n\r\n /**\r\n * Change the \"versions required to open this database\" property stored in this database. After this call,\r\n * versions of software that don't meet the supplied ranges will fail.\r\n * @param versions the new versions required for reading and writing this database.\r\n * @note the database must be opened for write access.\r\n */\r\n public setRequiredVersions(versions: SQLiteDb.RequiredVersionRanges) {\r\n // NOTE: It might look tempting to just stringify the supplied `versions` object, but we only include required members - there may be others.\r\n this.nativeDb.saveFileProperty(VersionedSqliteDb._versionProps, JSON.stringify({ readVersion: versions.readVersion, writeVersion: versions.writeVersion }));\r\n }\r\n\r\n /** Get the required version ranges necessary to open this VersionedSqliteDb. */\r\n public getRequiredVersions() {\r\n const checkIsString = (value: any) => {\r\n if (typeof value !== \"string\")\r\n throw new Error(`CloudDb ${this.nativeDb.getFilePath()} has invalid \"versions\" property`);\r\n return value;\r\n };\r\n const versionJson = checkIsString(this.nativeDb.queryFileProperty(VersionedSqliteDb._versionProps, true));\r\n const versionRanges = JSON.parse(versionJson) as SQLiteDb.RequiredVersionRanges;\r\n checkIsString(versionRanges.readVersion);\r\n checkIsString(versionRanges.writeVersion);\r\n return versionRanges;\r\n }\r\n\r\n /**\r\n * Implement this method to create all tables for this subclass of `VersionedSqliteDb` when a new database file is created. Called from [[createNewDb]].\r\n */\r\n protected abstract createDDL(): void;\r\n\r\n /**\r\n * Create a new database file for the subclass of VersionedSqliteDb.\r\n * @param fileName the name of a local\r\n * @note The required versions are saved as [[myVersion]] or newer for both read and write.\r\n */\r\n public static createNewDb(fileName: LocalFileName) {\r\n const db = new (this as any)() as VersionedSqliteDb; // \"as any\" necessary because VersionedSqliteDb is abstract\r\n IModelJsFs.recursiveMkDirSync(dirname(fileName));\r\n if (fs.existsSync(fileName))\r\n fs.unlinkSync(fileName);\r\n\r\n db.createDb(fileName);\r\n db.createDDL();\r\n const minVer = `^${db.myVersion}`;\r\n db.setRequiredVersions({ readVersion: minVer, writeVersion: minVer });\r\n db.closeDb(true);\r\n }\r\n\r\n /**\r\n * Verify that this version of the software meets the required version range (as appropriate, read or write) stored in the database.\r\n * Throws otherwise.\r\n */\r\n protected verifyVersions() {\r\n const versions = this.getRequiredVersions();\r\n const isReadonly = this.isReadonly; // so we can tell read/write after the file is closed.\r\n const range = isReadonly ? versions.readVersion : versions.writeVersion;\r\n if (semver.satisfies(this.myVersion, range))\r\n return;\r\n\r\n this.closeDb();\r\n const tooNew = semver.gtr(this.myVersion, range);\r\n throw new Error(`${this.nativeDb.getFilePath()} requires ${tooNew ? \"older\" : \"newer\"} version of ${this.constructor.name} for ${isReadonly ? \"read\" : \"write\"}`);\r\n\r\n }\r\n\r\n /**\r\n * Open this database and verify that this version of the software meets the required version range (as appropriate, read or write) stored in the database.\r\n * Throws otherwise.\r\n * @see [[SqliteDb.openDb]] for argument types\r\n */\r\n public override openDb(dbName: string, openMode: OpenMode | SQLiteDb.OpenParams, container?: CloudSqlite.CloudContainer) {\r\n super.openDb(dbName, openMode, container);\r\n this.verifyVersions();\r\n }\r\n\r\n public async upgradeSchema(arg: { dbName: string, lockContainer?: { container: CloudSqlite.CloudContainer, user: string }, upgradeFn: () => void }) {\r\n // can't use \"this\" because it checks for version, which we don't want here\r\n return (arg.lockContainer) ?\r\n super.withLockedContainer({ dbName: arg.dbName, ...arg.lockContainer }, async () => arg.upgradeFn) :\r\n super.withOpenDb({ ...arg, openMode: OpenMode.ReadWrite }, arg.upgradeFn);\r\n }\r\n}\r\n\r\n/** @public */\r\nexport namespace SQLiteDb {\r\n /** A semver version range.\r\n * @see https://docs.npmjs.com/cli/v6/using-npm/semver\r\n */\r\n export type VersionRange = string;\r\n\r\n /**\r\n * A pair of semver [[SQLiteDb.VersionRange]]s, one for read and one for write, required to access a [[VersionedSqliteDb]].\r\n * If the version of the software attempting to read or write the database does not satisfy the range, access is denied.\r\n */\r\n export interface RequiredVersionRanges {\r\n /** a range of acceptable persistence versions for reading from a VersionedSqliteDb. */\r\n readonly readVersion: VersionRange;\r\n /** a range of acceptable persistence versions for writing to a VersionedSqliteDb. */\r\n readonly writeVersion: VersionRange;\r\n }\r\n\r\n /** interface for reading and writing to a blob in a SQLiteDb\r\n * @internal\r\n */\r\n export interface BlobIO {\r\n /** Close this BlobIO if it is opened.\r\n * @note this BlobIO *may* be reused after this call by calling `open` again.\r\n */\r\n close(): void;\r\n /** get the total number of bytes in the blob */\r\n getNumBytes(): number;\r\n /** @return true if this BlobIO was successfully opened and may be use to read or write the blob */\r\n isValid(): boolean;\r\n /** Open this BlobIO against a table/row/column in a Db */\r\n open(\r\n /** The database for the blob */\r\n db: IModelJsNative.AnyDb,\r\n args: {\r\n /** the name of the table for the blob*/\r\n tableName: string;\r\n /** the name of the column for the blob */\r\n columnName: string;\r\n /** The rowId of the blob */\r\n row: number;\r\n /** If true, open this BlobIO for write access */\r\n writeable?: boolean;\r\n }): void;\r\n /** Read from a blob\r\n * @returns the contents of the requested byte range\r\n */\r\n read(args: {\r\n /** The number of bytes to read */\r\n numBytes: number;\r\n /** starting offset within the blob to read */\r\n offset: number;\r\n /** If present and of sufficient size, use this ArrayBuffer for the value. */\r\n blob?: ArrayBuffer;\r\n }): Uint8Array;\r\n /** Reposition this BlobIO to a new rowId\r\n * @note this BlobIO must be valid when this methods is called.\r\n */\r\n changeRow(row: number): void;\r\n /** Write to a blob */\r\n write(args: {\r\n /** The number of bytes to write */\r\n numBytes: number;\r\n /** starting offset within the blob to write */\r\n offset: number;\r\n /** the value to write */\r\n blob: ArrayBuffer;\r\n }): void;\r\n }\r\n\r\n /** Default transaction mode for SQLiteDbs.\r\n * @see https://www.sqlite.org/lang_transaction.html\r\n */\r\n export enum DefaultTxnMode {\r\n /** no default transaction is started. You must use BEGIN/COMMIT or SQLite will use implicit transactions */\r\n None = 0,\r\n /** A deferred transaction is started when the file is first opened. This is the default. */\r\n Deferred = 1,\r\n /** An immediate transaction is started when the file is first opened. */\r\n Immediate = 2,\r\n /** An exclusive transaction is started when the file is first opened. */\r\n Exclusive = 3\r\n }\r\n\r\n /** parameters common to opening or creating a new SQLiteDb */\r\n export interface OpenOrCreateParams {\r\n /** If true, do not require that the `be_Prop` table exist */\r\n rawSQLite?: boolean;\r\n /** @see immutable option at https://www.sqlite.org/c3ref/open.html */\r\n immutable?: boolean;\r\n /** Do not attempt to verify that the file is a valid sQLite file before opening. */\r\n skipFileCheck?: boolean;\r\n /** the default transaction mode\r\n * @see [[SQLiteDb.DefaultTxnMode]]\r\n */\r\n defaultTxn?: 0 | 1 | 2 | 3;\r\n /** see query parameters from 'URI Filenames' in https://www.sqlite.org/c3ref/open.html */\r\n queryParam?: string;\r\n }\r\n\r\n /** Parameters for opening an existing SQLiteDb */\r\n export interface OpenParams extends OpenOrCreateParams {\r\n /** use OpenMode.ReadWrite to open the file with write access */\r\n openMode: OpenMode;\r\n }\r\n\r\n /** Size of a SQLiteDb page in bytes */\r\n export interface PageSize {\r\n /** see https://www.sqlite.org/pragma.html#pragma_page_size */\r\n pageSize?: number;\r\n }\r\n\r\n /** Parameters for creating a new SQLiteDb */\r\n export type CreateParams = OpenOrCreateParams & PageSize;\r\n\r\n /** Arguments for `SqliteDb.withOpenDb` */\r\n export interface WithOpenDbArgs {\r\n /** The name of the database to open */\r\n dbName: string;\r\n /** either an object with the open parameters or just OpenMode value. */\r\n openMode?: OpenMode | SQLiteDb.OpenParams;\r\n /** @internal */\r\n container?: CloudSqlite.CloudContainer;\r\n }\r\n\r\n /** Arguments for `SQLiteDb.vacuum` */\r\n export interface VacuumDbArgs extends PageSize {\r\n /** if present, name of new file to [vacuum into](https://www.sqlite.org/lang_vacuum.html) */\r\n into?: LocalFileName;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"SQLiteDb.js","sourceRoot":"","sources":["../../src/SQLiteDb.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,yBAAyB;AACzB,+BAA+B;A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A;QACZ,yEAAyE;QACzE,6DAAa,CAAA;QACb,yEAAyE;QACzE,6DAAa,CAAA;IACf,CAAC,EATW,cAAc,GAAd,uBAAc,KAAd,uBAAc,QASzB;AAgDH,CAAC,EAjIgB,QAAQ,wBAAR,QAAQ,QAiIxB","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module SQLiteDb\r\n */\r\n\r\nimport * as fs from \"fs\";\r\nimport { dirname } from \"path\";\r\nimport * as semver from \"semver\";\r\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\nimport { DbResult, OpenMode } from \"@itwin/core-bentley\";\r\nimport { LocalFileName } from \"@itwin/core-common\";\r\nimport { CloudSqlite } from \"./CloudSqlite\";\r\nimport { IModelHost } from \"./IModelHost\";\r\nimport { IModelJsFs } from \"./IModelJsFs\";\r\nimport { SqliteStatement, StatementCache } from \"./SqliteStatement\";\r\n\r\n// cspell:ignore savepoint julianday rowid\r\n\r\n/* eslint-disable @typescript-eslint/unified-signatures */\r\n\r\n/**\r\n * A \"generic\" SQLiteDb. This class may be used to access local files or databases in a cloud container.\r\n * @public\r\n */\r\nexport class SQLiteDb {\r\n /** @internal */\r\n public readonly nativeDb = new IModelHost.platform.SQLiteDb();\r\n private _sqliteStatementCache = new StatementCache<SqliteStatement>();\r\n\r\n /** @internal */\r\n public static createBlobIO(): SQLiteDb.BlobIO {\r\n return new IModelHost.platform.BlobIO();\r\n }\r\n\r\n /** alias for closeDb.\r\n * @deprecated in 4.0, use [[closeDb]]\r\n */\r\n public dispose(): void {\r\n this.closeDb();\r\n }\r\n\r\n /** Create a SQLiteDb\r\n * @param dbName The path to the SQLiteDb file to create.\r\n */\r\n public createDb(dbName: string): void;\r\n /** @beta */\r\n public createDb(dbName: string, container?: CloudSqlite.CloudContainer, params?: SQLiteDb.CreateParams): void;\r\n public createDb(dbName: string, container?: CloudSqlite.CloudContainer, params?: SQLiteDb.CreateParams): void {\r\n this.nativeDb.createDb(dbName, container, params);\r\n }\r\n\r\n /** Open a SQLiteDb.\r\n * @param dbName The path to the SQLiteDb file to open\r\n */\r\n public openDb(dbName: string, openMode: OpenMode | SQLiteDb.OpenParams): void;\r\n /**\r\n * @param container optional CloudContainer holding database\r\n * @beta\r\n */\r\n public openDb(dbName: string, openMode: OpenMode | SQLiteDb.OpenParams, container?: CloudSqlite.CloudContainer): void;\r\n public openDb(dbName: string, openMode: OpenMode | SQLiteDb.OpenParams, container?: CloudSqlite.CloudContainer): void {\r\n this.nativeDb.openDb(dbName, openMode, container);\r\n }\r\n\r\n /** Close SQLiteDb.\r\n * @param saveChanges if true, call `saveChanges` before closing db. Otherwise unsaved changes are abandoned.\r\n */\r\n public closeDb(saveChanges?: boolean): void {\r\n if (saveChanges && this.isOpen)\r\n this.saveChanges();\r\n this._sqliteStatementCache.clear();\r\n this.nativeDb.closeDb();\r\n }\r\n\r\n /** Returns true if this SQLiteDb is open */\r\n public get isOpen(): boolean { return this.nativeDb.isOpen(); }\r\n\r\n /** Returns true if this SQLiteDb is open readonly */\r\n public get isReadonly(): boolean { return this.nativeDb.isReadonly(); }\r\n\r\n /** Create a new table in this database. */\r\n protected createTable(args: {\r\n /** The name of the table to create. */\r\n tableName: string;\r\n /** all of the columns in the table. */\r\n columns: string;\r\n /** any unique or foreign key constraints */\r\n constraints?: string;\r\n /** if true, add a \"lastMod\" timestamp column and triggers to automatically update it. */\r\n addTimestamp?: boolean;\r\n }) {\r\n const timestampCol = args.addTimestamp ? \",lastMod TIMESTAMP NOT NULL DEFAULT(julianday('now'))\" : \"\";\r\n const constraints = args.constraints ? `,${args.constraints}` : \"\";\r\n this.executeSQL(`CREATE TABLE ${args.tableName}(${args.columns}${timestampCol}${constraints})`);\r\n if (args.addTimestamp)\r\n this.executeSQL(`CREATE TRIGGER ${args.tableName}_timestamp AFTER UPDATE ON ${args.tableName} WHEN old.lastMod=new.lastMod AND old.lastMod != julianday('now') BEGIN UPDATE ${args.tableName} SET lastMod=julianday('now') WHERE rowid=new.rowid; END`);\r\n }\r\n\r\n /**\r\n * Get the last modified date for a row in a table of this database.\r\n * @note the table must have been created with `addTimestamp: true`\r\n */\r\n public readLastModTime(tableName: string, rowId: number): Date {\r\n return this.withSqliteStatement(`SELECT lastMod from ${tableName} WHERE rowid=?`, (stmt) => {\r\n stmt.bindInteger(1, rowId);\r\n return stmt.getValueDate(0);\r\n });\r\n }\r\n\r\n /**\r\n * Open a database, perform an operation, then close the database.\r\n *\r\n * Details:\r\n * - if database is open, throw an error\r\n * - open a database\r\n * - call a function with the database opened. If it is async, await its return.\r\n * - if function throws, abandon all changes, close database, and rethrow\r\n * - save all changes\r\n * - close the database\r\n * @return value from operation\r\n */\r\n public withOpenDb<T>(args: SQLiteDb.WithOpenDbArgs, operation: () => T): T {\r\n if (this.isOpen)\r\n throw new Error(\"database is already open\");\r\n\r\n const save = () => this.closeDb(true), abandon = () => this.closeDb(false);\r\n this.openDb(args.dbName, args.openMode ?? OpenMode.Readonly, args.container);\r\n try {\r\n const result = operation();\r\n result instanceof Promise ? result.then(save, abandon) : save();\r\n return result;\r\n } catch (e) {\r\n abandon();\r\n throw e;\r\n }\r\n }\r\n\r\n /**\r\n * Perform an operation on a database in a CloudContainer with the write lock held.\r\n *\r\n * Details:\r\n * - acquire the write lock on a CloudContainer\r\n * - call `withOpenDb` with openMode `ReadWrite`\r\n * - upload changes\r\n * - release the write lock\r\n * @param args arguments to lock the container and open the database\r\n * @param operation an operation performed on the database with the write lock held.\r\n * @return value from operation\r\n * @internal\r\n */\r\n public async withLockedContainer<T>(args: CloudSqlite.LockAndOpenArgs, operation: () => Promise<T>) {\r\n return CloudSqlite.withWriteLock(args, async () => this.withOpenDb({ ...args, openMode: args.openMode ?? OpenMode.ReadWrite }, operation));\r\n }\r\n\r\n /** vacuum this database\r\n * @see https://www.sqlite.org/lang_vacuum.html\r\n */\r\n public vacuum(args?: SQLiteDb.VacuumDbArgs) {\r\n this.nativeDb.vacuum(args);\r\n }\r\n\r\n /** Commit the outermost transaction, writing changes to the file. Then, restart the default transaction. */\r\n public saveChanges(): void {\r\n this.nativeDb.saveChanges();\r\n }\r\n\r\n /** Abandon (cancel) the outermost transaction, discarding all changes since last save. Then, restart the default transaction. */\r\n public abandonChanges(): void {\r\n this.nativeDb.abandonChanges();\r\n }\r\n\r\n /**\r\n * Use a prepared SQL statement, potentially from the statement cache. If the requested statement doesn't exist\r\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\r\n * in the statement cache so it can be reused in the future. Use this method for SQL statements that will be\r\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\r\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withSqliteStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @returns the value returned by `callback`.\r\n */\r\n public withPreparedSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T): T {\r\n const stmt = this._sqliteStatementCache.findAndRemove(sql) ?? this.prepareSqliteStatement(sql);\r\n const release = () => this._sqliteStatementCache.addOrDispose(stmt);\r\n try {\r\n const val = callback(stmt);\r\n val instanceof Promise ? val.then(release, release) : release();\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Prepare and execute a callback on a SQL statement. After the callback completes the statement is disposed.\r\n * Use this method for SQL statements are either not expected to be reused, or are not expensive to prepare.\r\n * For statements that will be reused often, instead use [[withPreparedSqliteStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @returns the value returned by `callback`.\r\n */\r\n public withSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T): T {\r\n const stmt = this.prepareSqliteStatement(sql);\r\n const release = () => stmt.dispose();\r\n try {\r\n const val = callback(stmt);\r\n val instanceof Promise ? val.then(release, release) : release();\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Perform an operation on this database within a [savepoint](https://www.sqlite.org/lang_savepoint.html). If the operation completes successfully, the\r\n * changes remain in the current transaction. If the operation throws an exception, the savepoint is rolled back\r\n * and all changes to the database from this method are reversed, leaving the transaction exactly as it was before this method.\r\n */\r\n public withSavePoint(savePointName: string, operation: () => void) {\r\n if (this.isReadonly)\r\n throw new Error(\"database is readonly\");\r\n\r\n this.executeSQL(`SAVEPOINT ${savePointName}`);\r\n try {\r\n operation();\r\n this.executeSQL(`RELEASE ${savePointName}`);\r\n } catch (e) {\r\n this.executeSQL(`ROLLBACK TO ${savePointName}`);\r\n throw e;\r\n }\r\n }\r\n\r\n /** Prepare an SQL statement.\r\n * @param sql The SQLite SQL statement to prepare\r\n * @param logErrors Determine if errors are logged or not\r\n * @internal\r\n */\r\n public prepareSqliteStatement(sql: string, logErrors = true): SqliteStatement {\r\n const stmt = new SqliteStatement(sql);\r\n stmt.prepare(this.nativeDb, logErrors);\r\n return stmt;\r\n }\r\n\r\n /** execute an SQL statement */\r\n public executeSQL(sql: string): DbResult {\r\n const stmt = this.prepareSqliteStatement(sql);\r\n try {\r\n return stmt.step();\r\n } finally {\r\n stmt.dispose();\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Abstract base class for a SQLite database that has [[SQLiteDb.RequiredVersionRanges]] stored in it.\r\n * This class provides version checking when the database is opened, to guarantee that a valid version of software is\r\n * always used for access.\r\n *\r\n * Notes:\r\n * - This class may be used either to access a local file, or one stored in a cloud container.\r\n * - Subclasses must provide a `myVersion` member indicating the version of its software, and implement the `createDDL` member to create its\r\n * tables.\r\n * @beta\r\n */\r\nexport abstract class VersionedSqliteDb extends SQLiteDb {\r\n protected static _versionProps = { namespace: \"SQLiteDb\", name: \"versions\" } as const;\r\n\r\n /** The current semver \"persistence version\" of this class.\r\n * @note This value should only be changed when logic in its code is modified in a way that affects the operation of extant copies.\r\n * If this value is outside of the range of accepted versions of a to-be-opened VersionedSqliteDb, the operation will fail. In this manner, if\r\n * changes are made to the format of a VersionedSqliteDb, or if bug fixes are necessary, the `requiredVersions` property in a VersionedSqliteDb may be updated\r\n * and immediately old versions of the package will refuse to open the VersionedSqliteDb, with a message to the user that they need to upgrade their\r\n * software. Likewise, if a new version of the package is asked to open an older VersionedSqliteDb that has not been upgraded to the lowest version\r\n * supported by it, the user will be informed that they need to upgrade their software.\r\n * @note this identifier is independent of versions in `package.json` files.\r\n */\r\n public abstract myVersion: string;\r\n\r\n /**\r\n * Change the \"versions required to open this database\" property stored in this database. After this call,\r\n * versions of software that don't meet the supplied ranges will fail.\r\n * @param versions the new versions required for reading and writing this database.\r\n * @note the database must be opened for write access.\r\n */\r\n public setRequiredVersions(versions: SQLiteDb.RequiredVersionRanges) {\r\n // NOTE: It might look tempting to just stringify the supplied `versions` object, but we only include required members - there may be others.\r\n this.nativeDb.saveFileProperty(VersionedSqliteDb._versionProps, JSON.stringify({ readVersion: versions.readVersion, writeVersion: versions.writeVersion }));\r\n }\r\n\r\n /** Get the required version ranges necessary to open this VersionedSqliteDb. */\r\n public getRequiredVersions() {\r\n const checkIsString = (value: any) => {\r\n if (typeof value !== \"string\")\r\n throw new Error(`CloudDb ${this.nativeDb.getFilePath()} has invalid \"versions\" property`);\r\n return value;\r\n };\r\n const versionJson = checkIsString(this.nativeDb.queryFileProperty(VersionedSqliteDb._versionProps, true));\r\n const versionRanges = JSON.parse(versionJson) as SQLiteDb.RequiredVersionRanges;\r\n checkIsString(versionRanges.readVersion);\r\n checkIsString(versionRanges.writeVersion);\r\n return versionRanges;\r\n }\r\n\r\n /**\r\n * Implement this method to create all tables for this subclass of `VersionedSqliteDb` when a new database file is created. Called from [[createNewDb]].\r\n */\r\n protected abstract createDDL(args: any): void;\r\n\r\n /**\r\n * Create a new database file for the subclass of VersionedSqliteDb.\r\n * @note The required versions are saved as [[myVersion]] or newer for both read and write.\r\n */\r\n public static createNewDb(fileName: LocalFileName, setupArgs?: any) {\r\n const db = new (this as any)() as VersionedSqliteDb; // \"as any\" necessary because VersionedSqliteDb is abstract\r\n IModelJsFs.recursiveMkDirSync(dirname(fileName));\r\n if (fs.existsSync(fileName))\r\n fs.unlinkSync(fileName);\r\n\r\n db.createDb(fileName);\r\n db.createDDL(setupArgs);\r\n const minVer = `^${db.myVersion}`;\r\n db.setRequiredVersions({ readVersion: minVer, writeVersion: minVer });\r\n db.closeDb(true);\r\n }\r\n\r\n /**\r\n * Verify that this version of the software meets the required version range (as appropriate, read or write) stored in the database.\r\n * Throws otherwise.\r\n */\r\n protected verifyVersions() {\r\n const versions = this.getRequiredVersions();\r\n const isReadonly = this.isReadonly; // so we can tell read/write after the file is closed.\r\n const range = isReadonly ? versions.readVersion : versions.writeVersion;\r\n if (semver.satisfies(this.myVersion, range))\r\n return;\r\n\r\n this.closeDb();\r\n const tooNew = semver.gtr(this.myVersion, range);\r\n throw new Error(`${this.nativeDb.getFilePath()} requires ${tooNew ? \"older\" : \"newer\"} version of ${this.constructor.name} for ${isReadonly ? \"read\" : \"write\"}`);\r\n\r\n }\r\n\r\n /**\r\n * Open this database and verify that this version of the software meets the required version range (as appropriate, read or write) stored in the database.\r\n * Throws otherwise.\r\n * @see [[SqliteDb.openDb]] for argument types\r\n */\r\n public override openDb(dbName: string, openMode: OpenMode | SQLiteDb.OpenParams, container?: CloudSqlite.CloudContainer) {\r\n super.openDb(dbName, openMode, container);\r\n this.verifyVersions();\r\n }\r\n\r\n public async upgradeSchema(arg: { dbName: string, lockContainer?: { container: CloudSqlite.CloudContainer, user: string }, upgradeFn: () => void }) {\r\n // can't use \"this\" because it checks for version, which we don't want here\r\n return (arg.lockContainer) ?\r\n super.withLockedContainer({ dbName: arg.dbName, ...arg.lockContainer }, async () => arg.upgradeFn) :\r\n super.withOpenDb({ ...arg, openMode: OpenMode.ReadWrite }, arg.upgradeFn);\r\n }\r\n}\r\n\r\n/** @public */\r\nexport namespace SQLiteDb {\r\n /** A semver version range.\r\n * @see https://docs.npmjs.com/cli/v6/using-npm/semver\r\n */\r\n export type VersionRange = string;\r\n\r\n /**\r\n * A pair of semver [[SQLiteDb.VersionRange]]s, one for read and one for write, required to access a [[VersionedSqliteDb]].\r\n * If the version of the software attempting to read or write the database does not satisfy the range, access is denied.\r\n */\r\n export interface RequiredVersionRanges {\r\n /** a range of acceptable persistence versions for reading from a VersionedSqliteDb. */\r\n readonly readVersion: VersionRange;\r\n /** a range of acceptable persistence versions for writing to a VersionedSqliteDb. */\r\n readonly writeVersion: VersionRange;\r\n }\r\n\r\n /** interface for reading and writing to a blob in a SQLiteDb\r\n * @internal\r\n */\r\n export interface BlobIO {\r\n /** Close this BlobIO if it is opened.\r\n * @note this BlobIO *may* be reused after this call by calling `open` again.\r\n */\r\n close(): void;\r\n /** get the total number of bytes in the blob */\r\n getNumBytes(): number;\r\n /** @return true if this BlobIO was successfully opened and may be use to read or write the blob */\r\n isValid(): boolean;\r\n /** Open this BlobIO against a table/row/column in a Db */\r\n open(\r\n /** The database for the blob */\r\n db: IModelJsNative.AnyDb,\r\n args: {\r\n /** the name of the table for the blob*/\r\n tableName: string;\r\n /** the name of the column for the blob */\r\n columnName: string;\r\n /** The rowId of the blob */\r\n row: number;\r\n /** If true, open this BlobIO for write access */\r\n writeable?: boolean;\r\n }): void;\r\n /** Read from a blob\r\n * @returns the contents of the requested byte range\r\n */\r\n read(args: {\r\n /** The number of bytes to read */\r\n numBytes: number;\r\n /** starting offset within the blob to read */\r\n offset: number;\r\n /** If present and of sufficient size, use this ArrayBuffer for the value. */\r\n blob?: ArrayBuffer;\r\n }): Uint8Array;\r\n /** Reposition this BlobIO to a new rowId\r\n * @note this BlobIO must be valid when this methods is called.\r\n */\r\n changeRow(row: number): void;\r\n /** Write to a blob */\r\n write(args: {\r\n /** The number of bytes to write */\r\n numBytes: number;\r\n /** starting offset within the blob to write */\r\n offset: number;\r\n /** the value to write */\r\n blob: ArrayBuffer;\r\n }): void;\r\n }\r\n\r\n /** Default transaction mode for SQLiteDbs.\r\n * @see https://www.sqlite.org/lang_transaction.html\r\n */\r\n export enum DefaultTxnMode {\r\n /** no default transaction is started. You must use BEGIN/COMMIT or SQLite will use implicit transactions */\r\n None = 0,\r\n /** A deferred transaction is started when the file is first opened. This is the default. */\r\n Deferred = 1,\r\n /** An immediate transaction is started when the file is first opened. */\r\n Immediate = 2,\r\n /** An exclusive transaction is started when the file is first opened. */\r\n Exclusive = 3\r\n }\r\n\r\n /** parameters common to opening or creating a new SQLiteDb */\r\n export interface OpenOrCreateParams {\r\n /** If true, do not require that the `be_Prop` table exist */\r\n rawSQLite?: boolean;\r\n /** @see immutable option at https://www.sqlite.org/c3ref/open.html */\r\n immutable?: boolean;\r\n /** Do not attempt to verify that the file is a valid sQLite file before opening. */\r\n skipFileCheck?: boolean;\r\n /** the default transaction mode\r\n * @see [[SQLiteDb.DefaultTxnMode]]\r\n */\r\n defaultTxn?: 0 | 1 | 2 | 3;\r\n /** see query parameters from 'URI Filenames' in https://www.sqlite.org/c3ref/open.html */\r\n queryParam?: string;\r\n }\r\n\r\n /** Parameters for opening an existing SQLiteDb */\r\n export interface OpenParams extends OpenOrCreateParams {\r\n /** use OpenMode.ReadWrite to open the file with write access */\r\n openMode: OpenMode;\r\n }\r\n\r\n /** Size of a SQLiteDb page in bytes */\r\n export interface PageSize {\r\n /** see https://www.sqlite.org/pragma.html#pragma_page_size */\r\n pageSize?: number;\r\n }\r\n\r\n /** Parameters for creating a new SQLiteDb */\r\n export type CreateParams = OpenOrCreateParams & PageSize;\r\n\r\n /** Arguments for `SqliteDb.withOpenDb` */\r\n export interface WithOpenDbArgs {\r\n /** The name of the database to open */\r\n dbName: string;\r\n /** either an object with the open parameters or just OpenMode value. */\r\n openMode?: OpenMode | SQLiteDb.OpenParams;\r\n /** @internal */\r\n container?: CloudSqlite.CloudContainer;\r\n }\r\n\r\n /** Arguments for `SQLiteDb.vacuum` */\r\n export interface VacuumDbArgs extends PageSize {\r\n /** if present, name of new file to [vacuum into](https://www.sqlite.org/lang_vacuum.html) */\r\n into?: LocalFileName;\r\n }\r\n}\r\n"]}
@@ -37,7 +37,7 @@ export declare namespace SchemaSync {
37
37
  * A valid sasToken that grants write access must be supplied. This function creates and uploads an empty ChannelDb into the container.
38
38
  * @note this deletes any existing content in the container.
39
39
  */
40
- static initializeDb(props: CloudSqlite.ContainerAccessProps): Promise<void>;
40
+ static initializeDb(props: CloudSqlite.ContainerProps): Promise<void>;
41
41
  }
42
42
  }
43
43
  //# sourceMappingURL=SchemaSync.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaSync.d.ts","sourceRoot":"","sources":["../../src/SchemaSync.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAe,QAAQ,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAY,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAe,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAIhE,gBAAgB;AAChB,yBAAiB,UAAU,CAAC;IAE1B,kFAAkF;IAClF,MAAa,YAAa,SAAQ,iBAAiB;QACjD,SAAyB,SAAS,WAAW;kBAC1B,SAAS;KAC7B;IAMM,MAAM,YAAY,WAAY,QAAQ,cAAc,MAAM,SAKhE,CAAC;IA8BK,MAAM,gBAAgB,WAAkB,QAAQ,GAAG;QAAE,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAA;KAAE,QAAQ;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,sBAAsB,WAAW,KAAK,QAAQ,IAAI,CAAC,KAAG,QAAQ,IAAI,CAOpO,CAAC;IAEF,+DAA+D;IACxD,MAAM,IAAI,WAAkB,QAAQ,kB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E,WAAW,EAAE,mDAAmD,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QACzH,CAAC;IACH,CAAC,CAAC;IAEF,0EAA0E;IAC1E,MAAa,WAAY,SAAQ,yBAAW,CAAC,QAAsB;QACjE,YAAmB,KAAuC;YACxD,KAAK,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC;QAChE,CAAC;QAEM,MAAM;YACX,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC,QAAQ,CAAC,WAAW,EAAE,QAAQ,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,aAAa,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACxI,CAAC;QACD;;;;SAIC;QACM,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,KAAuC;YACtE,OAAO,KAAK,CAAC,aAAa,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC;QACrF,CAAC;KACF;IAhBY,sBAAW,cAgBvB,CAAA;AACH,CAAC,EAtHgB,UAAU,0BAAV,UAAU,QAsH1B","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module SQLiteDb\r\n */\r\n\r\nimport { CloudSqlite } from \"./CloudSqlite\";\r\nimport { VersionedSqliteDb } from \"./SQLiteDb\";\r\nimport { BriefcaseDb, IModelDb } from \"./IModelDb\";\r\nimport { DbResult, OpenMode } from \"@itwin/core-bentley\";\r\nimport { IModelError, LocalFileName } from \"@itwin/core-common\";\r\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\nimport { IModelHost } from \"./IModelHost\";\r\n\r\n/** @internal */\r\nexport namespace SchemaSync {\r\n\r\n /** A CloudSqlite database for synchronizing schema changes across briefcases. */\r\n export class SchemaSyncDb extends VersionedSqliteDb {\r\n public override readonly myVersion = \"4.0.0\";\r\n protected override createDDL() { }\r\n }\r\n\r\n const syncProperty = { namespace: \"itwinjs\", name: \"SchemaSync\" };\r\n const defaultDbName = \"SchemaSyncDb\" as const;\r\n const testSyncCachePropKey = \"test.schema_sync.cache_name\" as const;\r\n // for tests only\r\n export const setTestCache = (iModel: IModelDb, cacheName?: string) => {\r\n if (cacheName)\r\n iModel.nativeDb.saveLocalValue(testSyncCachePropKey, cacheName);\r\n else\r\n iModel.nativeDb.deleteLocalValue(testSyncCachePropKey);\r\n };\r\n\r\n const getCloudAccess = async (arg: IModelDb | { readonly fileName: LocalFileName }) => {\r\n let nativeDb: IModelJsNative.DgnDb | undefined;\r\n const argIsIModelDb = arg instanceof IModelDb;\r\n if (argIsIModelDb) {\r\n nativeDb = arg.nativeDb;\r\n } else {\r\n nativeDb = new IModelHost.platform.DgnDb();\r\n nativeDb.openIModel(arg.fileName, OpenMode.Readonly);\r\n }\r\n\r\n const propsString = nativeDb.queryFileProperty(syncProperty, true) as string | undefined;\r\n if (!propsString)\r\n throw new Error(\"iModel does not have a SchemaSyncDb\");\r\n try {\r\n const props = JSON.parse(propsString) as CloudSqlite.ContainerProps;\r\n const accessToken = await CloudSqlite.requestToken(props);\r\n const access = new CloudAccess({ ...props, accessToken });\r\n const testSyncCache = nativeDb.queryLocalValue(testSyncCachePropKey);\r\n if (testSyncCache)\r\n access.setCache(CloudSqlite.CloudCaches.getCache({ cacheName: testSyncCache }));\r\n return access;\r\n } finally {\r\n if (!argIsIModelDb) {\r\n nativeDb.closeFile();\r\n }\r\n }\r\n };\r\n\r\n export const withLockedAccess = async (iModel: IModelDb | { readonly fileName: LocalFileName }, args: { operationName: string, openMode?: OpenMode, user?: string }, operation: (access: CloudAccess) => Promise<void>): Promise<void> => {\r\n const access = await getCloudAccess(iModel);\r\n try {\r\n await access.withLockedDb(args, async () => operation(access));\r\n } finally {\r\n access.close();\r\n }\r\n };\r\n\r\n /** Synchronize local briefcase schemas with cloud container */\r\n export const pull = async (iModel: IModelDb) => {\r\n if (iModel.nativeDb.schemaSyncEnabled() && !iModel.isReadonly) {\r\n await SchemaSync.withLockedAccess(iModel, { openMode: OpenMode.Readonly, operationName: \"schema sync\" }, async (syncAccess) => {\r\n const schemaSyncDbUri = syncAccess.getUri();\r\n syncAccess.synchronizeWithCloud();\r\n iModel.clearCaches();\r\n iModel.nativeDb.schemaSyncPull(schemaSyncDbUri);\r\n iModel.saveChanges(\"schema synchronized with cloud container\");\r\n });\r\n }\r\n };\r\n\r\n export const initializeForIModel = async (arg: { iModel: IModelDb, containerProps: CloudSqlite.ContainerProps, overrideContainer?: boolean }) => {\r\n const props = { baseUri: arg.containerProps.baseUri, containerId: arg.containerProps.containerId, storageType: arg.containerProps.storageType }; // sanitize to only known properties\r\n const iModel = arg.iModel;\r\n const briefcase = iModel instanceof BriefcaseDb ? iModel : undefined;\r\n await iModel.acquireSchemaLock();\r\n if (briefcase) {\r\n if (briefcase.txns.hasLocalChanges) {\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Enabling SchemaSync for iModel failed. There are unsaved or un-pushed local changes.\");\r\n }\r\n await briefcase.pullChanges();\r\n }\r\n try {\r\n iModel.saveFileProperty(syncProperty, JSON.stringify(props));\r\n await withLockedAccess(arg.iModel, { operationName: \"initialize schemaSync\", openMode: OpenMode.Readonly }, async (syncAccess) => {\r\n iModel.nativeDb.schemaSyncInit(syncAccess.getUri(), props.containerId, arg.overrideContainer ?? false);\r\n iModel.saveChanges(`Enable SchemaSync (container id: ${props.containerId})`);\r\n });\r\n } catch (err) {\r\n throw err;\r\n } finally {\r\n iModel.abandonChanges();\r\n }\r\n\r\n if (briefcase) {\r\n if (arg.overrideContainer)\r\n await briefcase.pushChanges({ description: `Overriding SchemaSync for iModel with container-id: ${props.containerId}` });\r\n else\r\n await briefcase.pushChanges({ description: `Enable SchemaSync for iModel with container-id: ${props.containerId}` });\r\n }\r\n };\r\n\r\n /** Provides access to a cloud-based `SchemaSyncDb` to hold ECSchemas. */\r\n export class CloudAccess extends CloudSqlite.DbAccess<SchemaSyncDb> {\r\n public constructor(props: CloudSqlite.ContainerAccessProps) {\r\n super({ dbType: SchemaSyncDb, props, dbName: defaultDbName });\r\n }\r\n\r\n public getUri() {\r\n return `${this.getCloudDb().nativeDb.getFilePath()}?vfs=${this.container.cache?.name}&writable=${this.container.isWriteable ? 1 : 0}`;\r\n }\r\n /**\r\n * Initialize a cloud container for use as a SchemaSync. The container must first be created via its storage supplier api (e.g. Azure, or AWS).\r\n * A valid sasToken that grants write access must be supplied. This function creates and uploads an empty ChannelDb into the container.\r\n * @note this deletes any existing content in the container.\r\n */\r\n public static async initializeDb(props: CloudSqlite.ContainerAccessProps) {\r\n return super._initializeDb({ props, dbType: SchemaSyncDb, dbName: defaultDbName });\r\n }\r\n }\r\n}\r\n\r\n"]}
1
+ {"version":3,"file":"SchemaSync.js","sourceRoot":"","sources":["../../src/SchemaSync.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,+CAA4C;AAC5C,yCAA+C;AAC/C,yCAAmD;AACnD,sDAAyD;AACzD,oDAAgE;AAEhE,6CAA0C;AAE1C,gBAAgB;AAChB,IAAiB,UAAU,CAsH1B;AAtHD,WAAiB,UAAU;IAEzB,kFAAkF;IAClF,MAAa,YAAa,SAAQ,4BAAiB;QAAnD;;YAC2B,cAAS,GAAG,OAAO,CAAC;QAE/C,CAAC;QADoB,SAAS,KAAK,CAAC;KACnC;IAHY,uBAAY,eAGxB,CAAA;IAED,MAAM,YAAY,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;IAClE,MAAM,aAAa,GAAG,cAAuB,CAAC;IAC9C,MAAM,oBAAoB,GAAG,6BAAsC,CAAC;IACpE,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c,EAAE,CAAC;QAC1B,CAAC;QAED,IAAI,SAAS,EAAE,CAAC;YACd,IAAI,GAAG,CAAC,iBAAiB;gBACvB,MAAM,SAAS,CAAC,WAAW,CAAC,EAAE,WAAW,EAAE,uDAAuD,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;;gBAEzH,MAAM,SAAS,CAAC,WAAW,CAAC,EAAE,WAAW,EAAE,mDAAmD,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QACzH,CAAC;IACH,CAAC,CAAC;IAEF,0EAA0E;IAC1E,MAAa,WAAY,SAAQ,yBAAW,CAAC,QAAsB;QACjE,YAAmB,KAAuC;YACxD,KAAK,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC;QAChE,CAAC;QAEM,MAAM;YACX,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC,QAAQ,CAAC,WAAW,EAAE,QAAQ,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,aAAa,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACxI,CAAC;QACD;;;;SAIC;QACM,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,KAAiC;YAChE,OAAO,KAAK,CAAC,aAAa,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC;QACrF,CAAC;KACF;IAhBY,sBAAW,cAgBvB,CAAA;AACH,CAAC,EAtHgB,UAAU,0BAAV,UAAU,QAsH1B","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module SQLiteDb\r\n */\r\n\r\nimport { CloudSqlite } from \"./CloudSqlite\";\r\nimport { VersionedSqliteDb } from \"./SQLiteDb\";\r\nimport { BriefcaseDb, IModelDb } from \"./IModelDb\";\r\nimport { DbResult, OpenMode } from \"@itwin/core-bentley\";\r\nimport { IModelError, LocalFileName } from \"@itwin/core-common\";\r\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\nimport { IModelHost } from \"./IModelHost\";\r\n\r\n/** @internal */\r\nexport namespace SchemaSync {\r\n\r\n /** A CloudSqlite database for synchronizing schema changes across briefcases. */\r\n export class SchemaSyncDb extends VersionedSqliteDb {\r\n public override readonly myVersion = \"4.0.0\";\r\n protected override createDDL() { }\r\n }\r\n\r\n const syncProperty = { namespace: \"itwinjs\", name: \"SchemaSync\" };\r\n const defaultDbName = \"SchemaSyncDb\" as const;\r\n const testSyncCachePropKey = \"test.schema_sync.cache_name\" as const;\r\n // for tests only\r\n export const setTestCache = (iModel: IModelDb, cacheName?: string) => {\r\n if (cacheName)\r\n iModel.nativeDb.saveLocalValue(testSyncCachePropKey, cacheName);\r\n else\r\n iModel.nativeDb.deleteLocalValue(testSyncCachePropKey);\r\n };\r\n\r\n const getCloudAccess = async (arg: IModelDb | { readonly fileName: LocalFileName }) => {\r\n let nativeDb: IModelJsNative.DgnDb | undefined;\r\n const argIsIModelDb = arg instanceof IModelDb;\r\n if (argIsIModelDb) {\r\n nativeDb = arg.nativeDb;\r\n } else {\r\n nativeDb = new IModelHost.platform.DgnDb();\r\n nativeDb.openIModel(arg.fileName, OpenMode.Readonly);\r\n }\r\n\r\n const propsString = nativeDb.queryFileProperty(syncProperty, true) as string | undefined;\r\n if (!propsString)\r\n throw new Error(\"iModel does not have a SchemaSyncDb\");\r\n try {\r\n const props = JSON.parse(propsString) as CloudSqlite.ContainerProps;\r\n const accessToken = await CloudSqlite.requestToken(props);\r\n const access = new CloudAccess({ ...props, accessToken });\r\n const testSyncCache = nativeDb.queryLocalValue(testSyncCachePropKey);\r\n if (testSyncCache)\r\n access.setCache(CloudSqlite.CloudCaches.getCache({ cacheName: testSyncCache }));\r\n return access;\r\n } finally {\r\n if (!argIsIModelDb) {\r\n nativeDb.closeFile();\r\n }\r\n }\r\n };\r\n\r\n export const withLockedAccess = async (iModel: IModelDb | { readonly fileName: LocalFileName }, args: { operationName: string, openMode?: OpenMode, user?: string }, operation: (access: CloudAccess) => Promise<void>): Promise<void> => {\r\n const access = await getCloudAccess(iModel);\r\n try {\r\n await access.withLockedDb(args, async () => operation(access));\r\n } finally {\r\n access.close();\r\n }\r\n };\r\n\r\n /** Synchronize local briefcase schemas with cloud container */\r\n export const pull = async (iModel: IModelDb) => {\r\n if (iModel.nativeDb.schemaSyncEnabled() && !iModel.isReadonly) {\r\n await SchemaSync.withLockedAccess(iModel, { openMode: OpenMode.Readonly, operationName: \"schema sync\" }, async (syncAccess) => {\r\n const schemaSyncDbUri = syncAccess.getUri();\r\n syncAccess.synchronizeWithCloud();\r\n iModel.clearCaches();\r\n iModel.nativeDb.schemaSyncPull(schemaSyncDbUri);\r\n iModel.saveChanges(\"schema synchronized with cloud container\");\r\n });\r\n }\r\n };\r\n\r\n export const initializeForIModel = async (arg: { iModel: IModelDb, containerProps: CloudSqlite.ContainerProps, overrideContainer?: boolean }) => {\r\n const props = { baseUri: arg.containerProps.baseUri, containerId: arg.containerProps.containerId, storageType: arg.containerProps.storageType }; // sanitize to only known properties\r\n const iModel = arg.iModel;\r\n const briefcase = iModel instanceof BriefcaseDb ? iModel : undefined;\r\n await iModel.acquireSchemaLock();\r\n if (briefcase) {\r\n if (briefcase.txns.hasLocalChanges) {\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Enabling SchemaSync for iModel failed. There are unsaved or un-pushed local changes.\");\r\n }\r\n await briefcase.pullChanges();\r\n }\r\n try {\r\n iModel.saveFileProperty(syncProperty, JSON.stringify(props));\r\n await withLockedAccess(arg.iModel, { operationName: \"initialize schemaSync\", openMode: OpenMode.Readonly }, async (syncAccess) => {\r\n iModel.nativeDb.schemaSyncInit(syncAccess.getUri(), props.containerId, arg.overrideContainer ?? false);\r\n iModel.saveChanges(`Enable SchemaSync (container id: ${props.containerId})`);\r\n });\r\n } catch (err) {\r\n throw err;\r\n } finally {\r\n iModel.abandonChanges();\r\n }\r\n\r\n if (briefcase) {\r\n if (arg.overrideContainer)\r\n await briefcase.pushChanges({ description: `Overriding SchemaSync for iModel with container-id: ${props.containerId}` });\r\n else\r\n await briefcase.pushChanges({ description: `Enable SchemaSync for iModel with container-id: ${props.containerId}` });\r\n }\r\n };\r\n\r\n /** Provides access to a cloud-based `SchemaSyncDb` to hold ECSchemas. */\r\n export class CloudAccess extends CloudSqlite.DbAccess<SchemaSyncDb> {\r\n public constructor(props: CloudSqlite.ContainerAccessProps) {\r\n super({ dbType: SchemaSyncDb, props, dbName: defaultDbName });\r\n }\r\n\r\n public getUri() {\r\n return `${this.getCloudDb().nativeDb.getFilePath()}?vfs=${this.container.cache?.name}&writable=${this.container.isWriteable ? 1 : 0}`;\r\n }\r\n /**\r\n * Initialize a cloud container for use as a SchemaSync. The container must first be created via its storage supplier api (e.g. Azure, or AWS).\r\n * A valid sasToken that grants write access must be supplied. This function creates and uploads an empty ChannelDb into the container.\r\n * @note this deletes any existing content in the container.\r\n */\r\n public static async initializeDb(props: CloudSqlite.ContainerProps) {\r\n return super._initializeDb({ props, dbType: SchemaSyncDb, dbName: defaultDbName });\r\n }\r\n }\r\n}\r\n\r\n"]}
@@ -12,6 +12,10 @@ export interface ProduceTextAnnotationGeometryArgs {
12
12
  annotation: TextAnnotation;
13
13
  /** The iModel from which to obtain fonts and text styles. */
14
14
  iModel: IModelDb;
15
+ /** For debugging purposes only, whether to include geometry representing the bounding box and anchor point of the annotation.
16
+ * If true, two red lines indicating the horizontal and vertical extents of the bounding box will be included, intersecting at the anchor point.
17
+ */
18
+ debugAnchorPointAndRange?: boolean;
15
19
  /** @internal chiefly for tests */
16
20
  computeTextRange?: ComputeRangesForTextLayout;
17
21
  /** @internal chiefly for tests */
@@ -1 +1 @@
1
- {"version":3,"file":"TextAnnotationGeometry.d.ts","sourceRoot":"","sources":["../../src/TextAnnotationGeometry.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAY,cAAc,EAAE,sBAAsB,EAA2D,MAAM,oBAAoB,CAAC;AAC/I,OAAO,EAAE,0BAA0B,EAAE,UAAU,EAAE,aAAa,EAA+C,MAAM,wBAAwB,CAAC;AAG5I,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AA8JtC;;GAEG;AACH,MAAM,WAAW,iCAAiC;IAChD,yDAAyD;IACzD,UAAU,EAAE,cAAc,CAAC;IAC3B,6DAA6D;IAC7D,MAAM,EAAE,QAAQ,CAAC;IACjB,kCAAkC;IAClC,gBAAgB,CAAC,EAAE,0BAA0B,CAAC;IAC9C,kCAAkC;IAClC,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,kCAAkC;IAClC,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,iCAAiC,GAAG,sBAAsB,CAY7G"}
1
+ {"version":3,"file":"TextAnnotationGeometry.d.ts","sourceRoot":"","sources":["../../src/TextAnnotationGeometry.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAY,cAAc,EAAE,sBAAsB,EAA2D,MAAM,oBAAoB,CAAC;AAC/I,OAAO,EAAE,0BAA0B,EAAE,UAAU,EAAE,aAAa,EAA+C,MAAM,wBAAwB,CAAC;AAG5I,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AA8JtC;;GAEG;AACH,MAAM,WAAW,iCAAiC;IAChD,yDAAyD;IACzD,UAAU,EAAE,cAAc,CAAC;IAC3B,6DAA6D;IAC7D,MAAM,EAAE,QAAQ,CAAC;IACjB;;OAEG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,kCAAkC;IAClC,gBAAgB,CAAC,EAAE,0BAA0B,CAAC;IAC9C,kCAAkC;IAClC,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,kCAAkC;IAClC,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,iCAAiC,GAAG,sBAAsB,CAW7G"}
@@ -145,10 +145,9 @@ function produceTextAnnotationGeometry(args) {
145
145
  ...args,
146
146
  textBlock: args.annotation.textBlock,
147
147
  });
148
- const dimensions = layout.range.diagonal();
148
+ const dimensions = layout.range;
149
149
  const transform = args.annotation.computeTransform(dimensions);
150
- const debugAnchorPointAndRange = false;
151
- const anchorPoint = debugAnchorPointAndRange ? args.annotation.computeAnchorPoint(dimensions) : undefined;
150
+ const anchorPoint = args.debugAnchorPointAndRange ? args.annotation.computeAnchorPoint(dimensions) : undefined;
152
151
  return produceTextBlockGeometry(layout, transform, anchorPoint);
153
152
  }
154
153
  exports.produceTextAnnotationGeometry = produceTextAnnotationGeometry;
@@ -1 +1 @@
1
- {"version":3,"file":"TextAnnotationGeometry.js","sourceRoot":"","sources":["../../src/TextAnnotationGeometry.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAA+I;AAC/I,iEAA4I;AAC5I,wDAA4F;AAC5F,sDAA6C;AAQ7C,SAAS,QAAQ,CAAC,KAAqB,EAAE,OAAwB;IAC/D,IAAI,KAAK,KAAK,OAAO,CAAC,QAAQ,EAAE,CAAC;QAC/B,OAAO,CAAC,QAAQ,GAAG,KAAK,CAAC;QACzB,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAClC,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAY,EAAE,GAAc,EAAE,MAAgB;IACtE,IAAA,qBAAM,EAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAExB,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,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AI,CAAC;YACnB,SAAS,EAAE;gBACT,UAAU,EAAE,CAAC,aAAa,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;gBACpD,QAAQ,EAAE,CAAC,aAAa,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;aACpD;SACF,CAAC,CAAC;IACL,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC;AACtC,CAAC;AAkBD;;;;GAIG;AACH,SAAgB,6BAA6B,CAAC,IAAuC;IACnF,MAAM,MAAM,GAAG,IAAA,sCAAe,EAAC;QAC7B,GAAG,IAAI;QACP,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,SAAS;KACrC,CAAC,CAAC;IAEH,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC3C,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAE/D,MAAM,wBAAwB,GAAG,KAAK,CAAC;IACvC,MAAM,WAAW,GAAG,wBAAwB,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1G,OAAO,wBAAwB,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;AAClE,CAAC;AAZD,sEAYC","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 ElementGeometry\r\n */\r\n\r\nimport { ColorDef, TextAnnotation, TextBlockGeometryProps, TextBlockGeometryPropsEntry, TextString, TextStyleColor } from \"@itwin/core-common\";\r\nimport { ComputeRangesForTextLayout, FindFontId, FindTextStyle, layoutTextBlock, RunLayout, TextBlockLayout } from \"./TextAnnotationLayout\";\r\nimport { LineSegment3d, Point3d, Range2d, Transform, Vector2d } from \"@itwin/core-geometry\";\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { IModelDb } from \"./IModelDb\";\r\n\r\ninterface GeometryContext {\r\n curColor?: TextStyleColor;\r\n entries: TextBlockGeometryPropsEntry[];\r\n}\r\n\r\nfunction setColor(color: TextStyleColor, context: GeometryContext): void {\r\n if (color !== context.curColor) {\r\n context.curColor = color;\r\n context.entries.push({ color });\r\n }\r\n}\r\n\r\nfunction createTextString(text: string, run: RunLayout, origin?: Point3d): TextString {\r\n assert(text.length > 0);\r\n\r\n const { lineHeight, widthFactor, isBold, isItalic, isUnderlined } = run.style;\r\n\r\n return new TextString({\r\n text,\r\n font: run.fontId,\r\n height: lineHeight,\r\n widthFactor,\r\n bold: isBold,\r\n italic: isItalic,\r\n underline: isUnderlined,\r\n origin,\r\n });\r\n}\r\n\r\nfunction processTextRun(run: RunLayout, transform: Transform, context: GeometryContext): void {\r\n assert(run.source.type === \"text\");\r\n const text = run.source.content.substring(run.charOffset, run.charOffset + run.numChars);\r\n if (text.length === 0) {\r\n return;\r\n }\r\n\r\n const ts = createTextString(text, run);\r\n if (\"none\" !== run.source.baselineShift) {\r\n const isSub = \"subscript\" === run.source.baselineShift;\r\n const offsetFactor = run.style[isSub ? \"subScriptOffsetFactor\" : \"superScriptOffsetFactor\"];\r\n const scale = run.style[isSub ? \"subScriptScale\" : \"superScriptScale\"];\r\n\r\n ts.origin.y += offsetFactor * ts.height;\r\n ts.height *= scale;\r\n }\r\n\r\n ts.transformInPlace(transform);\r\n\r\n setColor(run.style.color, context);\r\n context.entries.push({ text: ts});\r\n}\r\n\r\nfunction createFractionTextString(text: string, run: RunLayout, origin: Point3d, transform: Transform): TextString {\r\n const ts = createTextString(text, run, origin);\r\n assert(undefined !== ts.widthFactor);\r\n\r\n ts.height *= run.style.stackedFractionScale;\r\n\r\n ts.transformInPlace(transform);\r\n\r\n return ts;\r\n}\r\n\r\nfunction processFractionRun(run: RunLayout, transform: Transform, context: GeometryContext): void {\r\n const source = run.source;\r\n assert(source.type === \"fraction\");\r\n\r\n if (source.numerator.length === 0 && source.denominator.length === 0) {\r\n return;\r\n }\r\n\r\n assert(undefined !== run.numeratorRange && undefined !== run.denominatorRange);\r\n\r\n const fontSize = new Vector2d(run.style.lineHeight * run.style.widthFactor, run.style.lineHeight);\r\n fontSize.scale(run.style.stackedFractionScale, fontSize);\r\n\r\n const numeratorOffset = new Point3d(run.numeratorRange.low.x, run.numeratorRange.low.y, 0);\r\n const denominatorOffset = new Point3d(run.denominatorRange.low.x, run.denominatorRange.low.y, 0);\r\n\r\n setColor(run.style.color, context);\r\n\r\n if (source.numerator.length > 0) {\r\n context.entries.push({ text: createFractionTextString(source.numerator, run, numeratorOffset, transform) });\r\n }\r\n\r\n const numeratorRange = Range2d.fromJSON(run.numeratorRange);\r\n const denominatorRange = Range2d.fromJSON(run.denominatorRange);\r\n\r\n let separator: LineSegment3d;\r\n if (run.style.stackedFractionType === \"horizontal\") {\r\n const fractionWidth = Math.max(numeratorRange.xLength(), denominatorRange.xLength());\r\n const y = 1.25 * denominatorRange.yLength();\r\n separator = LineSegment3d.createXYXY(0, y, fractionWidth, y);\r\n } else {\r\n const p0 = new Point3d(denominatorRange.low.x - fontSize.x / 2, denominatorRange.low.y + fontSize.y * (1 / 3), 0);\r\n const p1 = new Point3d(p0.x + fontSize.x, p0.y + fontSize.y * 1.5, 0);\r\n separator = LineSegment3d.createCapture(p0, p1);\r\n }\r\n\r\n separator.tryTransformInPlace(transform);\r\n\r\n context.entries.push({\r\n separator: {\r\n startPoint: separator.point0Ref.toJSON(),\r\n endPoint: separator.point1Ref.toJSON(),\r\n },\r\n });\r\n\r\n if (source.denominator.length > 0) {\r\n context.entries.push({ text: createFractionTextString(source.denominator, run,denominatorOffset, transform) });\r\n }\r\n}\r\n\r\nfunction produceTextBlockGeometry(layout: TextBlockLayout, documentTransform: Transform, debugAnchorPt?: Point3d): TextBlockGeometryProps {\r\n const context: GeometryContext = { entries: [] };\r\n for (const line of layout.lines) {\r\n const lineTrans = Transform.createTranslationXYZ(line.offsetFromDocument.x, line.offsetFromDocument.y, 0);\r\n for (const run of line.runs) {\r\n if (\"linebreak\" === run.source.type) {\r\n continue;\r\n }\r\n\r\n const runTrans = Transform.createTranslationXYZ(run.offsetFromLine.x, run.offsetFromLine.y, 0);\r\n lineTrans.multiplyTransformTransform(runTrans, runTrans);\r\n documentTransform.multiplyTransformTransform(runTrans, runTrans);\r\n if (\"text\" === run.source.type) {\r\n processTextRun(run, runTrans, context);\r\n } else {\r\n processFractionRun(run, runTrans, context);\r\n }\r\n }\r\n }\r\n\r\n if (debugAnchorPt) {\r\n // Draw lines representing the horizontal and vertical ranges, intersecting at the anchor point.\r\n context.entries.push({\r\n color: ColorDef.red.toJSON(),\r\n });\r\n\r\n context.entries.push({\r\n separator: {\r\n startPoint: [layout.range.low.x, debugAnchorPt.y, 0],\r\n endPoint: [layout.range.high.x, debugAnchorPt.y, 0],\r\n },\r\n });\r\n context.entries.push({\r\n separator: {\r\n startPoint: [debugAnchorPt.x, layout.range.low.y, 0],\r\n endPoint: [debugAnchorPt.x, layout.range.high.y, 0],\r\n },\r\n });\r\n }\r\n\r\n return { entries: context.entries };\r\n}\r\n\r\n/** Arguments supplied to [[produceTextAnnotationGeometry]].\r\n * @beta\r\n */\r\nexport interface ProduceTextAnnotationGeometryArgs {\r\n /** The annotation from which to produce the geometry. */\r\n annotation: TextAnnotation;\r\n /** The iModel from which to obtain fonts and text styles. */\r\n iModel: IModelDb;\r\n /** @internal chiefly for tests */\r\n computeTextRange?: ComputeRangesForTextLayout;\r\n /** @internal chiefly for tests */\r\n findTextStyle?: FindTextStyle;\r\n /** @internal chiefly for tests */\r\n findFontId?: FindFontId;\r\n}\r\n\r\n/** Produce a geometric representation of a text annotation.\r\n * The result can be supplied to [GeometryStreamBuilder.appendTextBlock]($common).\r\n * @see [[TextAnnotation2d.setAnnotation]] and [[TextAnnotation3d.setAnnotation]] to update the annotation, geometry, and placement of an annotation element.\r\n * @beta\r\n */\r\nexport function produceTextAnnotationGeometry(args: ProduceTextAnnotationGeometryArgs): TextBlockGeometryProps {\r\n const layout = layoutTextBlock({\r\n ...args,\r\n textBlock: args.annotation.textBlock,\r\n });\r\n\r\n const dimensions = layout.range.diagonal();\r\n const transform = args.annotation.computeTransform(dimensions);\r\n\r\n const debugAnchorPointAndRange = false;\r\n const anchorPoint = debugAnchorPointAndRange ? args.annotation.computeAnchorPoint(dimensions) : undefined;\r\n return produceTextBlockGeometry(layout, transform, anchorPoint);\r\n}\r\n"]}
1
+ {"version":3,"file":"TextAnnotationGeometry.js","sourceRoot":"","sources":["../../src/TextAnnotationGeometry.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAA+I;AAC/I,iEAA4I;AAC5I,wDAA4F;AAC5F,sDAA6C;AAQ7C,SAAS,QAAQ,CAAC,KAAqB,EAAE,OAAwB;IAC/D,IAAI,KAAK,KAAK,OAAO,CAAC,QAAQ,EAAE,CAAC;QAC/B,OAAO,CAAC,QAAQ,GAAG,KAAK,CAAC;QACzB,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAClC,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAY,EAAE,GAAc,EAAE,MAAgB;IACtE,IAAA,qBAAM,EAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAExB,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC;IAE9E,OAAO,IAAI,wBAAU,CAAC;QACpB,IAAI;QACJ,IAAI,EAAE,GAAG,CAAC,MAAM;QAChB,MAAM,EAAE,UAAU;QAClB,WAAW;QACX,IAAI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aAAa,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;aACpD;SACF,CAAC,CAAC;IACL,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC;AACtC,CAAC;AAsBD;;;;GAIG;AACH,SAAgB,6BAA6B,CAAC,IAAuC;IACnF,MAAM,MAAM,GAAG,IAAA,sCAAe,EAAC;QAC7B,GAAG,IAAI;QACP,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,SAAS;KACrC,CAAC,CAAC;IAEH,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC;IAChC,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAE/D,MAAM,WAAW,GAAG,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/G,OAAO,wBAAwB,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;AAClE,CAAC;AAXD,sEAWC","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 ElementGeometry\r\n */\r\n\r\nimport { ColorDef, TextAnnotation, TextBlockGeometryProps, TextBlockGeometryPropsEntry, TextString, TextStyleColor } from \"@itwin/core-common\";\r\nimport { ComputeRangesForTextLayout, FindFontId, FindTextStyle, layoutTextBlock, RunLayout, TextBlockLayout } from \"./TextAnnotationLayout\";\r\nimport { LineSegment3d, Point3d, Range2d, Transform, Vector2d } from \"@itwin/core-geometry\";\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { IModelDb } from \"./IModelDb\";\r\n\r\ninterface GeometryContext {\r\n curColor?: TextStyleColor;\r\n entries: TextBlockGeometryPropsEntry[];\r\n}\r\n\r\nfunction setColor(color: TextStyleColor, context: GeometryContext): void {\r\n if (color !== context.curColor) {\r\n context.curColor = color;\r\n context.entries.push({ color });\r\n }\r\n}\r\n\r\nfunction createTextString(text: string, run: RunLayout, origin?: Point3d): TextString {\r\n assert(text.length > 0);\r\n\r\n const { lineHeight, widthFactor, isBold, isItalic, isUnderlined } = run.style;\r\n\r\n return new TextString({\r\n text,\r\n font: run.fontId,\r\n height: lineHeight,\r\n widthFactor,\r\n bold: isBold,\r\n italic: isItalic,\r\n underline: isUnderlined,\r\n origin,\r\n });\r\n}\r\n\r\nfunction processTextRun(run: RunLayout, transform: Transform, context: GeometryContext): void {\r\n assert(run.source.type === \"text\");\r\n const text = run.source.content.substring(run.charOffset, run.charOffset + run.numChars);\r\n if (text.length === 0) {\r\n return;\r\n }\r\n\r\n const ts = createTextString(text, run);\r\n if (\"none\" !== run.source.baselineShift) {\r\n const isSub = \"subscript\" === run.source.baselineShift;\r\n const offsetFactor = run.style[isSub ? \"subScriptOffsetFactor\" : \"superScriptOffsetFactor\"];\r\n const scale = run.style[isSub ? \"subScriptScale\" : \"superScriptScale\"];\r\n\r\n ts.origin.y += offsetFactor * ts.height;\r\n ts.height *= scale;\r\n }\r\n\r\n ts.transformInPlace(transform);\r\n\r\n setColor(run.style.color, context);\r\n context.entries.push({ text: ts});\r\n}\r\n\r\nfunction createFractionTextString(text: string, run: RunLayout, origin: Point3d, transform: Transform): TextString {\r\n const ts = createTextString(text, run, origin);\r\n assert(undefined !== ts.widthFactor);\r\n\r\n ts.height *= run.style.stackedFractionScale;\r\n\r\n ts.transformInPlace(transform);\r\n\r\n return ts;\r\n}\r\n\r\nfunction processFractionRun(run: RunLayout, transform: Transform, context: GeometryContext): void {\r\n const source = run.source;\r\n assert(source.type === \"fraction\");\r\n\r\n if (source.numerator.length === 0 && source.denominator.length === 0) {\r\n return;\r\n }\r\n\r\n assert(undefined !== run.numeratorRange && undefined !== run.denominatorRange);\r\n\r\n const fontSize = new Vector2d(run.style.lineHeight * run.style.widthFactor, run.style.lineHeight);\r\n fontSize.scale(run.style.stackedFractionScale, fontSize);\r\n\r\n const numeratorOffset = new Point3d(run.numeratorRange.low.x, run.numeratorRange.low.y, 0);\r\n const denominatorOffset = new Point3d(run.denominatorRange.low.x, run.denominatorRange.low.y, 0);\r\n\r\n setColor(run.style.color, context);\r\n\r\n if (source.numerator.length > 0) {\r\n context.entries.push({ text: createFractionTextString(source.numerator, run, numeratorOffset, transform) });\r\n }\r\n\r\n const numeratorRange = Range2d.fromJSON(run.numeratorRange);\r\n const denominatorRange = Range2d.fromJSON(run.denominatorRange);\r\n\r\n let separator: LineSegment3d;\r\n if (run.style.stackedFractionType === \"horizontal\") {\r\n const fractionWidth = Math.max(numeratorRange.xLength(), denominatorRange.xLength());\r\n const y = 1.25 * denominatorRange.yLength();\r\n separator = LineSegment3d.createXYXY(0, y, fractionWidth, y);\r\n } else {\r\n const p0 = new Point3d(denominatorRange.low.x - fontSize.x / 2, denominatorRange.low.y + fontSize.y * (1 / 3), 0);\r\n const p1 = new Point3d(p0.x + fontSize.x, p0.y + fontSize.y * 1.5, 0);\r\n separator = LineSegment3d.createCapture(p0, p1);\r\n }\r\n\r\n separator.tryTransformInPlace(transform);\r\n\r\n context.entries.push({\r\n separator: {\r\n startPoint: separator.point0Ref.toJSON(),\r\n endPoint: separator.point1Ref.toJSON(),\r\n },\r\n });\r\n\r\n if (source.denominator.length > 0) {\r\n context.entries.push({ text: createFractionTextString(source.denominator, run,denominatorOffset, transform) });\r\n }\r\n}\r\n\r\nfunction produceTextBlockGeometry(layout: TextBlockLayout, documentTransform: Transform, debugAnchorPt?: Point3d): TextBlockGeometryProps {\r\n const context: GeometryContext = { entries: [] };\r\n for (const line of layout.lines) {\r\n const lineTrans = Transform.createTranslationXYZ(line.offsetFromDocument.x, line.offsetFromDocument.y, 0);\r\n for (const run of line.runs) {\r\n if (\"linebreak\" === run.source.type) {\r\n continue;\r\n }\r\n\r\n const runTrans = Transform.createTranslationXYZ(run.offsetFromLine.x, run.offsetFromLine.y, 0);\r\n lineTrans.multiplyTransformTransform(runTrans, runTrans);\r\n documentTransform.multiplyTransformTransform(runTrans, runTrans);\r\n if (\"text\" === run.source.type) {\r\n processTextRun(run, runTrans, context);\r\n } else {\r\n processFractionRun(run, runTrans, context);\r\n }\r\n }\r\n }\r\n\r\n if (debugAnchorPt) {\r\n // Draw lines representing the horizontal and vertical ranges, intersecting at the anchor point.\r\n context.entries.push({\r\n color: ColorDef.red.toJSON(),\r\n });\r\n\r\n context.entries.push({\r\n separator: {\r\n startPoint: [layout.range.low.x, debugAnchorPt.y, 0],\r\n endPoint: [layout.range.high.x, debugAnchorPt.y, 0],\r\n },\r\n });\r\n context.entries.push({\r\n separator: {\r\n startPoint: [debugAnchorPt.x, layout.range.low.y, 0],\r\n endPoint: [debugAnchorPt.x, layout.range.high.y, 0],\r\n },\r\n });\r\n }\r\n\r\n return { entries: context.entries };\r\n}\r\n\r\n/** Arguments supplied to [[produceTextAnnotationGeometry]].\r\n * @beta\r\n */\r\nexport interface ProduceTextAnnotationGeometryArgs {\r\n /** The annotation from which to produce the geometry. */\r\n annotation: TextAnnotation;\r\n /** The iModel from which to obtain fonts and text styles. */\r\n iModel: IModelDb;\r\n /** For debugging purposes only, whether to include geometry representing the bounding box and anchor point of the annotation.\r\n * If true, two red lines indicating the horizontal and vertical extents of the bounding box will be included, intersecting at the anchor point.\r\n */\r\n debugAnchorPointAndRange?: boolean;\r\n /** @internal chiefly for tests */\r\n computeTextRange?: ComputeRangesForTextLayout;\r\n /** @internal chiefly for tests */\r\n findTextStyle?: FindTextStyle;\r\n /** @internal chiefly for tests */\r\n findFontId?: FindFontId;\r\n}\r\n\r\n/** Produce a geometric representation of a text annotation.\r\n * The result can be supplied to [GeometryStreamBuilder.appendTextBlock]($common).\r\n * @see [[TextAnnotation2d.setAnnotation]] and [[TextAnnotation3d.setAnnotation]] to update the annotation, geometry, and placement of an annotation element.\r\n * @beta\r\n */\r\nexport function produceTextAnnotationGeometry(args: ProduceTextAnnotationGeometryArgs): TextBlockGeometryProps {\r\n const layout = layoutTextBlock({\r\n ...args,\r\n textBlock: args.annotation.textBlock,\r\n });\r\n\r\n const dimensions = layout.range;\r\n const transform = args.annotation.computeTransform(dimensions);\r\n\r\n const anchorPoint = args.debugAnchorPointAndRange ? args.annotation.computeAnchorPoint(dimensions) : undefined;\r\n return produceTextBlockGeometry(layout, transform, anchorPoint);\r\n}\r\n"]}
@@ -1,8 +1,8 @@
1
1
  /** @packageDocumentation
2
2
  * @module ElementGeometry
3
3
  */
4
- import { BaselineShift, FontId, FractionRun, Paragraph, Run, TextBlock, TextRun, TextStyleSettings } from "@itwin/core-common";
5
- import { Range2d, XAndY } from "@itwin/core-geometry";
4
+ import { BaselineShift, FontId, FractionRun, LineLayoutResult, Paragraph, Run, RunLayoutResult, TextBlock, TextBlockLayoutResult, TextRun, TextStyleSettings } from "@itwin/core-common";
5
+ import { Range2d } from "@itwin/core-geometry";
6
6
  import { IModelDb } from "./IModelDb";
7
7
  /** @internal */
8
8
  export interface TextLayoutRanges {
@@ -29,17 +29,15 @@ export type ComputeRangesForTextLayout = (args: ComputeRangesForTextLayoutArgs)
29
29
  export type FindFontId = (name: string) => FontId;
30
30
  /** @internal */
31
31
  export type FindTextStyle = (name: string) => TextStyleSettings;
32
- /** Arguments supplied to [[computeTextBlockExtents]].
32
+ /**
33
+ * Arguments supplied to [[computeLayoutTextBlockResult]].
33
34
  * @beta
34
35
  */
35
- export interface ComputeTextBlockExtentsArgs {
36
+ export interface LayoutTextBlockArgs {
36
37
  /** The text block whose extents are to be computed. */
37
38
  textBlock: TextBlock;
38
39
  /** The iModel from which to obtain fonts and [TextStyle]($common)s when laying out glyphs. */
39
40
  iModel: IModelDb;
40
- }
41
- /** @internal */
42
- export interface LayoutTextBlockArgs extends ComputeTextBlockExtentsArgs {
43
41
  /** @internal chiefly for tests, by default uses IModelJsNative.DgnDb.computeRangesForText. */
44
42
  computeTextRange?: ComputeRangesForTextLayout;
45
43
  /** @internal chiefly for tests, by default looks up styles from a workspace. */
@@ -53,16 +51,17 @@ export interface LayoutTextBlockArgs extends ComputeTextBlockExtentsArgs {
53
51
  * Each series of consecutive non-linebreak runs within a paragraph is concatenated into one line.
54
52
  * If the document specifies a width > 0, individual lines are split to try to avoid exceeding that width.
55
53
  * Individual TextRuns can be split onto multiple lines at word boundaries if necessary. Individual FractionRuns are never split.
54
+ * @see [[computeLayoutTextBlockResult]]
56
55
  * @internal
57
56
  */
58
57
  export declare function layoutTextBlock(args: LayoutTextBlockArgs): TextBlockLayout;
59
- /** Compute the bounding box containing the contents of a [TextBlock]($common).
60
- * This process converts each [Paragraph]($common) into a set of lines of text, laying out the glyphs of individual
61
- * [Run]($common)s based on their [TextStyle]($common)s and fonts, and applying work-wrapping based on [TextBlock.width]($common).
62
- * The resultant extents can be supplied to [TextAnnotation.computeTransform]($common) and [TextAnnotation.computeAnchorPoint]($common).
58
+ /**
59
+ * Gets the result of laying out the the contents of a TextBlock into a series of lines containing runs.
60
+ * The visual layout accounts for the [TextStyle]($common)s, fonts, and [TextBlock.width]($common). It applies word-wrapping if needed.
61
+ * The layout returned matches the visual layout of the geometry produced by [[produceTextAnnotationGeometry]].
63
62
  * @beta
64
63
  */
65
- export declare function computeTextBlockExtents(args: ComputeTextBlockExtentsArgs): XAndY;
64
+ export declare function computeLayoutTextBlockResult(args: LayoutTextBlockArgs): TextBlockLayoutResult;
66
65
  declare class LayoutContext {
67
66
  private readonly _computeTextRange;
68
67
  private readonly _findTextStyle;
@@ -99,11 +98,14 @@ export declare class RunLayout {
99
98
  fontId: FontId;
100
99
  private constructor();
101
100
  static create(source: Run, context: LayoutContext): RunLayout;
101
+ /** Compute a string representation, primarily for debugging purposes. */
102
+ stringify(): string;
102
103
  canWrap(): this is {
103
104
  source: TextRun;
104
105
  };
105
106
  private cloneForWrap;
106
- wrap(availableWidth: number, shouldForceLeadingUnit: boolean, context: LayoutContext): RunLayout | undefined;
107
+ split(context: LayoutContext): RunLayout[];
108
+ toResult(paragraph: Paragraph): RunLayoutResult;
107
109
  }
108
110
  /** @internal */
109
111
  export declare class LineLayout {
@@ -116,12 +118,15 @@ export declare class LineLayout {
116
118
  };
117
119
  private _runs;
118
120
  constructor(source: Paragraph);
121
+ /** Compute a string representation, primarily for debugging purposes. */
122
+ stringify(): string;
119
123
  get runs(): ReadonlyArray<RunLayout>;
120
124
  get isEmpty(): boolean;
121
125
  get back(): RunLayout;
122
126
  append(run: RunLayout): void;
123
127
  /** Invoked every time a run is appended,. */
124
128
  private computeRanges;
129
+ toResult(textBlock: TextBlock): LineLayoutResult;
125
130
  }
126
131
  /**
127
132
  * Describes the layout of a text block as a collection of lines containing runs.
@@ -132,6 +137,9 @@ export declare class TextBlockLayout {
132
137
  range: Range2d;
133
138
  lines: LineLayout[];
134
139
  constructor(source: TextBlock, context: LayoutContext);
140
+ toResult(): TextBlockLayoutResult;
141
+ /** Compute a string representation, primarily for debugging purposes. */
142
+ stringify(): string;
135
143
  private get _back();
136
144
  private populateLines;
137
145
  private justifyLines;
@@ -1 +1 @@
1
- {"version":3,"file":"TextAnnotationLayout.d.ts","sourceRoot":"","sources":["../../src/TextAnnotationLayout.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,iBAAiB,EAA0B,MAAM,oBAAoB,CAAC;AACvJ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,gBAAgB;AAChB,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,8BAA8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