@itwin/core-backend 5.15.0-dev.7 → 5.15.0

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 (220) hide show
  1. package/CHANGELOG.md +46 -1
  2. package/lib/cjs/BlobContainerService.d.ts +2 -0
  3. package/lib/cjs/BlobContainerService.d.ts.map +1 -1
  4. package/lib/cjs/BlobContainerService.js.map +1 -1
  5. package/lib/cjs/BriefcaseManager.d.ts +2 -1
  6. package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
  7. package/lib/cjs/BriefcaseManager.js +39 -9
  8. package/lib/cjs/BriefcaseManager.js.map +1 -1
  9. package/lib/cjs/ChangeUnifier.d.ts +82 -0
  10. package/lib/cjs/ChangeUnifier.d.ts.map +1 -0
  11. package/lib/cjs/ChangeUnifier.js +163 -0
  12. package/lib/cjs/ChangeUnifier.js.map +1 -0
  13. package/lib/cjs/ChangesetReader.d.ts +21 -2
  14. package/lib/cjs/ChangesetReader.d.ts.map +1 -1
  15. package/lib/cjs/ChangesetReader.js +37 -1
  16. package/lib/cjs/ChangesetReader.js.map +1 -1
  17. package/lib/cjs/CloudSqlite.d.ts +15 -0
  18. package/lib/cjs/CloudSqlite.d.ts.map +1 -1
  19. package/lib/cjs/CloudSqlite.js.map +1 -1
  20. package/lib/cjs/ECDb.d.ts +1 -0
  21. package/lib/cjs/ECDb.d.ts.map +1 -1
  22. package/lib/cjs/ECDb.js +4 -1
  23. package/lib/cjs/ECDb.js.map +1 -1
  24. package/lib/cjs/EditTxn.d.ts +61 -19
  25. package/lib/cjs/EditTxn.d.ts.map +1 -1
  26. package/lib/cjs/EditTxn.js +84 -29
  27. package/lib/cjs/EditTxn.js.map +1 -1
  28. package/lib/cjs/GeoCoordConfig.d.ts +1 -0
  29. package/lib/cjs/GeoCoordConfig.d.ts.map +1 -1
  30. package/lib/cjs/GeoCoordConfig.js +12 -8
  31. package/lib/cjs/GeoCoordConfig.js.map +1 -1
  32. package/lib/cjs/IModelDb.d.ts +22 -9
  33. package/lib/cjs/IModelDb.d.ts.map +1 -1
  34. package/lib/cjs/IModelDb.js +54 -12
  35. package/lib/cjs/IModelDb.js.map +1 -1
  36. package/lib/cjs/NativeHost.d.ts.map +1 -1
  37. package/lib/cjs/NativeHost.js +5 -1
  38. package/lib/cjs/NativeHost.js.map +1 -1
  39. package/lib/cjs/Relationship.d.ts +28 -0
  40. package/lib/cjs/Relationship.d.ts.map +1 -1
  41. package/lib/cjs/Relationship.js +78 -0
  42. package/lib/cjs/Relationship.js.map +1 -1
  43. package/lib/cjs/SchemaSync.d.ts.map +1 -1
  44. package/lib/cjs/SchemaSync.js +1 -0
  45. package/lib/cjs/SchemaSync.js.map +1 -1
  46. package/lib/cjs/TxnManager.d.ts +126 -89
  47. package/lib/cjs/TxnManager.d.ts.map +1 -1
  48. package/lib/cjs/TxnManager.js +114 -76
  49. package/lib/cjs/TxnManager.js.map +1 -1
  50. package/lib/cjs/ViewStateHydrator.d.ts.map +1 -1
  51. package/lib/cjs/ViewStateHydrator.js.map +1 -1
  52. package/lib/cjs/ViewStore.d.ts.map +1 -1
  53. package/lib/cjs/ViewStore.js +62 -19
  54. package/lib/cjs/ViewStore.js.map +1 -1
  55. package/lib/cjs/annotations/LeaderGeometry.d.ts.map +1 -1
  56. package/lib/cjs/annotations/LeaderGeometry.js +3 -0
  57. package/lib/cjs/annotations/LeaderGeometry.js.map +1 -1
  58. package/lib/cjs/core-backend.d.ts +1 -0
  59. package/lib/cjs/core-backend.d.ts.map +1 -1
  60. package/lib/cjs/core-backend.js +1 -0
  61. package/lib/cjs/core-backend.js.map +1 -1
  62. package/lib/cjs/internal/BriefcaseUtils.d.ts +19 -0
  63. package/lib/cjs/internal/BriefcaseUtils.d.ts.map +1 -0
  64. package/lib/cjs/internal/BriefcaseUtils.js +65 -0
  65. package/lib/cjs/internal/BriefcaseUtils.js.map +1 -0
  66. package/lib/cjs/internal/QueryMetadataCache.d.ts +44 -0
  67. package/lib/cjs/internal/QueryMetadataCache.d.ts.map +1 -0
  68. package/lib/cjs/internal/QueryMetadataCache.js +107 -0
  69. package/lib/cjs/internal/QueryMetadataCache.js.map +1 -0
  70. package/lib/cjs/internal/Symbols.d.ts +9 -0
  71. package/lib/cjs/internal/Symbols.d.ts.map +1 -1
  72. package/lib/cjs/internal/Symbols.js +10 -1
  73. package/lib/cjs/internal/Symbols.js.map +1 -1
  74. package/lib/cjs/internal/workspace/WorkspaceImpl.d.ts.map +1 -1
  75. package/lib/cjs/internal/workspace/WorkspaceImpl.js +20 -6
  76. package/lib/cjs/internal/workspace/WorkspaceImpl.js.map +1 -1
  77. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +6 -6
  78. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -1
  79. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  80. package/lib/cjs/workspace/SettingsEditor.d.ts +4 -3
  81. package/lib/cjs/workspace/SettingsEditor.d.ts.map +1 -1
  82. package/lib/cjs/workspace/SettingsEditor.js +7 -5
  83. package/lib/cjs/workspace/SettingsEditor.js.map +1 -1
  84. package/lib/esm/BlobContainerService.d.ts +2 -0
  85. package/lib/esm/BlobContainerService.d.ts.map +1 -1
  86. package/lib/esm/BlobContainerService.js.map +1 -1
  87. package/lib/esm/BriefcaseManager.d.ts +2 -1
  88. package/lib/esm/BriefcaseManager.d.ts.map +1 -1
  89. package/lib/esm/BriefcaseManager.js +40 -10
  90. package/lib/esm/BriefcaseManager.js.map +1 -1
  91. package/lib/esm/ChangeUnifier.d.ts +82 -0
  92. package/lib/esm/ChangeUnifier.d.ts.map +1 -0
  93. package/lib/esm/ChangeUnifier.js +159 -0
  94. package/lib/esm/ChangeUnifier.js.map +1 -0
  95. package/lib/esm/ChangesetReader.d.ts +21 -2
  96. package/lib/esm/ChangesetReader.d.ts.map +1 -1
  97. package/lib/esm/ChangesetReader.js +38 -2
  98. package/lib/esm/ChangesetReader.js.map +1 -1
  99. package/lib/esm/CloudSqlite.d.ts +15 -0
  100. package/lib/esm/CloudSqlite.d.ts.map +1 -1
  101. package/lib/esm/CloudSqlite.js.map +1 -1
  102. package/lib/esm/ECDb.d.ts +1 -0
  103. package/lib/esm/ECDb.d.ts.map +1 -1
  104. package/lib/esm/ECDb.js +4 -1
  105. package/lib/esm/ECDb.js.map +1 -1
  106. package/lib/esm/EditTxn.d.ts +61 -19
  107. package/lib/esm/EditTxn.d.ts.map +1 -1
  108. package/lib/esm/EditTxn.js +85 -30
  109. package/lib/esm/EditTxn.js.map +1 -1
  110. package/lib/esm/GeoCoordConfig.d.ts +1 -0
  111. package/lib/esm/GeoCoordConfig.d.ts.map +1 -1
  112. package/lib/esm/GeoCoordConfig.js +12 -8
  113. package/lib/esm/GeoCoordConfig.js.map +1 -1
  114. package/lib/esm/IModelDb.d.ts +22 -9
  115. package/lib/esm/IModelDb.d.ts.map +1 -1
  116. package/lib/esm/IModelDb.js +56 -14
  117. package/lib/esm/IModelDb.js.map +1 -1
  118. package/lib/esm/NativeHost.d.ts.map +1 -1
  119. package/lib/esm/NativeHost.js +5 -1
  120. package/lib/esm/NativeHost.js.map +1 -1
  121. package/lib/esm/Relationship.d.ts +28 -0
  122. package/lib/esm/Relationship.d.ts.map +1 -1
  123. package/lib/esm/Relationship.js +78 -0
  124. package/lib/esm/Relationship.js.map +1 -1
  125. package/lib/esm/SchemaSync.d.ts.map +1 -1
  126. package/lib/esm/SchemaSync.js +1 -0
  127. package/lib/esm/SchemaSync.js.map +1 -1
  128. package/lib/esm/TxnManager.d.ts +126 -89
  129. package/lib/esm/TxnManager.d.ts.map +1 -1
  130. package/lib/esm/TxnManager.js +116 -78
  131. package/lib/esm/TxnManager.js.map +1 -1
  132. package/lib/esm/ViewStateHydrator.d.ts.map +1 -1
  133. package/lib/esm/ViewStateHydrator.js.map +1 -1
  134. package/lib/esm/ViewStore.d.ts.map +1 -1
  135. package/lib/esm/ViewStore.js +62 -19
  136. package/lib/esm/ViewStore.js.map +1 -1
  137. package/lib/esm/annotations/LeaderGeometry.d.ts.map +1 -1
  138. package/lib/esm/annotations/LeaderGeometry.js +3 -0
  139. package/lib/esm/annotations/LeaderGeometry.js.map +1 -1
  140. package/lib/esm/core-backend.d.ts +1 -0
  141. package/lib/esm/core-backend.d.ts.map +1 -1
  142. package/lib/esm/core-backend.js +1 -0
  143. package/lib/esm/core-backend.js.map +1 -1
  144. package/lib/esm/internal/BriefcaseUtils.d.ts +19 -0
  145. package/lib/esm/internal/BriefcaseUtils.d.ts.map +1 -0
  146. package/lib/esm/internal/BriefcaseUtils.js +61 -0
  147. package/lib/esm/internal/BriefcaseUtils.js.map +1 -0
  148. package/lib/esm/internal/QueryMetadataCache.d.ts +44 -0
  149. package/lib/esm/internal/QueryMetadataCache.d.ts.map +1 -0
  150. package/lib/esm/internal/QueryMetadataCache.js +103 -0
  151. package/lib/esm/internal/QueryMetadataCache.js.map +1 -0
  152. package/lib/esm/internal/Symbols.d.ts +9 -0
  153. package/lib/esm/internal/Symbols.d.ts.map +1 -1
  154. package/lib/esm/internal/Symbols.js +9 -0
  155. package/lib/esm/internal/Symbols.js.map +1 -1
  156. package/lib/esm/internal/workspace/WorkspaceImpl.d.ts.map +1 -1
  157. package/lib/esm/internal/workspace/WorkspaceImpl.js +20 -6
  158. package/lib/esm/internal/workspace/WorkspaceImpl.js.map +1 -1
  159. package/lib/esm/rpc-impl/IModelReadRpcImpl.d.ts +6 -6
  160. package/lib/esm/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -1
  161. package/lib/esm/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  162. package/lib/esm/test/annotations/LeaderGeometry.test.js +15 -1
  163. package/lib/esm/test/annotations/LeaderGeometry.test.js.map +1 -1
  164. package/lib/esm/test/ecdb/ConcurrentQuery.test.js +144 -30
  165. package/lib/esm/test/ecdb/ConcurrentQuery.test.js.map +1 -1
  166. package/lib/esm/test/ecdb/QueryMetadataCache.test.d.ts +2 -0
  167. package/lib/esm/test/ecdb/QueryMetadataCache.test.d.ts.map +1 -0
  168. package/lib/esm/test/ecdb/QueryMetadataCache.test.js +630 -0
  169. package/lib/esm/test/ecdb/QueryMetadataCache.test.js.map +1 -0
  170. package/lib/esm/test/element/DeleteDefinitionElements.test.js +403 -249
  171. package/lib/esm/test/element/DeleteDefinitionElements.test.js.map +1 -1
  172. package/lib/esm/test/element/RelationshipBatchLookup.test.d.ts +2 -0
  173. package/lib/esm/test/element/RelationshipBatchLookup.test.d.ts.map +1 -0
  174. package/lib/esm/test/element/RelationshipBatchLookup.test.js +202 -0
  175. package/lib/esm/test/element/RelationshipBatchLookup.test.js.map +1 -0
  176. package/lib/esm/test/hubaccess/BriefcaseManager.test.js +187 -1
  177. package/lib/esm/test/hubaccess/BriefcaseManager.test.js.map +1 -1
  178. package/lib/esm/test/hubaccess/SchemaImportOrphanColumns.test.d.ts +2 -0
  179. package/lib/esm/test/hubaccess/SchemaImportOrphanColumns.test.d.ts.map +1 -0
  180. package/lib/esm/test/hubaccess/SchemaImportOrphanColumns.test.js +142 -0
  181. package/lib/esm/test/hubaccess/SchemaImportOrphanColumns.test.js.map +1 -0
  182. package/lib/esm/test/imodel/IModelGeolocation.test.js +8 -6
  183. package/lib/esm/test/imodel/IModelGeolocation.test.js.map +1 -1
  184. package/lib/esm/test/imodel/IModelProps.test.d.ts +2 -0
  185. package/lib/esm/test/imodel/IModelProps.test.d.ts.map +1 -0
  186. package/lib/esm/test/imodel/IModelProps.test.js +411 -0
  187. package/lib/esm/test/imodel/IModelProps.test.js.map +1 -0
  188. package/lib/esm/test/schema/SchemaViewPropertyOverrides.test.d.ts +2 -0
  189. package/lib/esm/test/schema/SchemaViewPropertyOverrides.test.d.ts.map +1 -0
  190. package/lib/esm/test/schema/SchemaViewPropertyOverrides.test.js +240 -0
  191. package/lib/esm/test/schema/SchemaViewPropertyOverrides.test.js.map +1 -0
  192. package/lib/esm/test/schema/SchemaViewValidation.test.js +2 -8
  193. package/lib/esm/test/schema/SchemaViewValidation.test.js.map +1 -1
  194. package/lib/esm/test/standalone/BriefcaseManagerDelete.test.d.ts +2 -0
  195. package/lib/esm/test/standalone/BriefcaseManagerDelete.test.d.ts.map +1 -0
  196. package/lib/esm/test/standalone/BriefcaseManagerDelete.test.js +159 -0
  197. package/lib/esm/test/standalone/BriefcaseManagerDelete.test.js.map +1 -0
  198. package/lib/esm/test/standalone/ChangeUnifier.test.d.ts +2 -0
  199. package/lib/esm/test/standalone/ChangeUnifier.test.d.ts.map +1 -0
  200. package/lib/esm/test/standalone/ChangeUnifier.test.js +732 -0
  201. package/lib/esm/test/standalone/ChangeUnifier.test.js.map +1 -0
  202. package/lib/esm/test/standalone/DeleteElements.test.js +962 -83
  203. package/lib/esm/test/standalone/DeleteElements.test.js.map +1 -1
  204. package/lib/esm/test/standalone/EditTxn.test.js +72 -1
  205. package/lib/esm/test/standalone/EditTxn.test.js.map +1 -1
  206. package/lib/esm/test/standalone/GeoCoordConfig.test.d.ts +2 -0
  207. package/lib/esm/test/standalone/GeoCoordConfig.test.d.ts.map +1 -0
  208. package/lib/esm/test/standalone/GeoCoordConfig.test.js +158 -0
  209. package/lib/esm/test/standalone/GeoCoordConfig.test.js.map +1 -0
  210. package/lib/esm/test/standalone/ViewStoreDb.test.js +53 -0
  211. package/lib/esm/test/standalone/ViewStoreDb.test.js.map +1 -1
  212. package/lib/esm/test/workspace/SettingsContainers.test.d.ts +2 -0
  213. package/lib/esm/test/workspace/SettingsContainers.test.d.ts.map +1 -0
  214. package/lib/esm/test/workspace/SettingsContainers.test.js +95 -0
  215. package/lib/esm/test/workspace/SettingsContainers.test.js.map +1 -0
  216. package/lib/esm/workspace/SettingsEditor.d.ts +4 -3
  217. package/lib/esm/workspace/SettingsEditor.d.ts.map +1 -1
  218. package/lib/esm/workspace/SettingsEditor.js +7 -5
  219. package/lib/esm/workspace/SettingsEditor.js.map +1 -1
  220. package/package.json +18 -18
@@ -1 +1 @@
1
- {"version":3,"file":"ECDb.js","sourceRoot":"","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AC3B,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7B,CAAC;iBAAM,CAAC;gBACN,OAAO,EAAE,CAAC;YACZ,CAAC;YACD,OAAO,GAAG,CAAC;QACb,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,OAAO,EAAE,CAAC;YACV,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;CACF","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 ECDb\r\n */\r\nimport { assert, BeEvent, DbResult, Logger, OpenMode } from \"@itwin/core-bentley\";\r\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\nimport { DbQueryRequest, ECSchemaProps, ECSqlReader, IModelError, QueryBinder, QueryOptions } from \"@itwin/core-common\";\r\nimport { serialize } from \"node:v8\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { ConcurrentQuery } from \"./ConcurrentQuery\";\r\nimport { ECSqlStatement, ECSqlWriteStatement } from \"./ECSqlStatement\";\r\nimport { IModelNative } from \"./internal/NativePlatform\";\r\nimport { SqliteStatement, StatementCache } from \"./SqliteStatement\";\r\nimport { _nativeDb } from \"./internal/Symbols\";\r\nimport { ECSqlRowExecutor, releaseECSqlStatement } from \"./ECSqlRowExecutor\";\r\nimport { ECSqlSyncReader, SynchronousQueryOptions } from \"./ECSqlSyncReader\";\r\n\r\nconst loggerCategory: string = BackendLoggerCategory.ECDb;\r\n\r\n/** Maps a zero-based CSV column to an EC property.\r\n * @beta\r\n */\r\nexport interface CSVColumnMapping {\r\n /** Zero-based index of the source CSV column. */\r\n columnIndex: number;\r\n /** EC property access string to receive the column value. */\r\n propertyName: string;\r\n}\r\n\r\n/** Common options for importing CSV data into an ECClass.\r\n * @beta\r\n */\r\nexport interface CSVImportOptions {\r\n /** Full name or ECSQL name of the ECClass to insert. */\r\n className: string;\r\n /** Source-column to EC-property mappings. Unmapped source columns are ignored. */\r\n mapping: readonly CSVColumnMapping[];\r\n /** Exact CSV value to bind as null. By default, every field is treated as a value. */\r\n nullValue?: string;\r\n}\r\n\r\n/** Options for [[ECDb.importCSVFile]].\r\n * @beta\r\n */\r\nexport interface CSVFileImportOptions extends CSVImportOptions {\r\n /** Whether the first CSV row is a header to skip. Defaults to false. */\r\n hasHeader?: boolean;\r\n}\r\n\r\nfunction validateCSVMapping(mapping: readonly CSVColumnMapping[]): void {\r\n if (0 === mapping.length)\r\n throw new TypeError(\"mapping must not be empty\");\r\n\r\n const columnIndexes = new Set<number>();\r\n for (const entry of mapping) {\r\n if (undefined === entry || null === entry || \"object\" !== typeof entry)\r\n throw new TypeError(\"mapping must contain only objects\");\r\n if (!Number.isSafeInteger(entry.columnIndex) || entry.columnIndex < 0 || entry.columnIndex >= 0xffff_ffff)\r\n throw new TypeError(\"mapping columnIndex values must be non-negative safe integers\");\r\n if (\"string\" !== typeof entry.propertyName || 0 === entry.propertyName.length)\r\n throw new TypeError(\"mapping propertyName values must not be empty\");\r\n if (columnIndexes.has(entry.columnIndex))\r\n throw new TypeError(\"mapping must not contain duplicate columnIndex values\");\r\n columnIndexes.add(entry.columnIndex);\r\n }\r\n}\r\n\r\n/** Modes for how to open [ECDb]($backend) files.\r\n * @public\r\n */\r\nexport enum ECDbOpenMode {\r\n Readonly,\r\n ReadWrite,\r\n /** Opens the file read-write and upgrades the file if necessary to the latest file format version. */\r\n FileUpgrade,\r\n}\r\n\r\n/** An ECDb file\r\n * @public\r\n */\r\nexport class ECDb implements Disposable {\r\n private _nativeDb?: IModelJsNative.ECDb;\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n private readonly _statementCache = new StatementCache<ECSqlStatement>();\r\n private _sqliteStatementCache = new StatementCache<SqliteStatement>();\r\n\r\n /** Event called when the ECDb is about to be closed. */\r\n public readonly onBeforeClose = new BeEvent<() => void>();\r\n\r\n /** only for tests\r\n * @internal\r\n */\r\n public resetSqliteCache(size: number) {\r\n this._sqliteStatementCache.clear();\r\n this._sqliteStatementCache = new StatementCache<SqliteStatement>(size);\r\n }\r\n\r\n constructor() {\r\n this._nativeDb = new IModelNative.platform.ECDb();\r\n }\r\n /** Call this function when finished with this ECDb object. This releases the native resources held by the\r\n * ECDb object.\r\n */\r\n public [Symbol.dispose](): void {\r\n if (!this._nativeDb)\r\n return;\r\n\r\n this.closeDb();\r\n this._nativeDb.dispose();\r\n this._nativeDb = undefined;\r\n }\r\n /**\r\n * Attach an iModel file to this connection and load and register its schemas.\r\n * @note There are some reserve tablespace names that cannot be used. They are 'main', 'schema_sync_db', 'ecchange' & 'temp'\r\n * @param fileName IModel file name\r\n * @param alias identifier for the attached file. This identifer is used to access schema from the attached file. e.g. if alias is 'abc' then schema can be accessed using 'abc.MySchema.MyClass'\r\n */\r\n public attachDb(fileName: string, alias: string): void {\r\n if (alias.toLowerCase() === \"main\" || alias.toLowerCase() === \"schema_sync_db\" || alias.toLowerCase() === \"ecchange\" || alias.toLowerCase() === \"temp\") {\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Reserved tablespace name cannot be used\");\r\n }\r\n this[_nativeDb].attachDb(fileName, alias);\r\n }\r\n /**\r\n * Detach the attached file from this connection. The attached file is closed and its schemas are unregistered.\r\n * @note There are some reserve tablespace names that cannot be used. They are 'main', 'schema_sync_db', 'ecchange' & 'temp'\r\n * @param alias identifer that was used in the call to [[attachDb]]\r\n */\r\n public detachDb(alias: string): void {\r\n if (alias.toLowerCase() === \"main\" || alias.toLowerCase() === \"schema_sync_db\" || alias.toLowerCase() === \"ecchange\" || alias.toLowerCase() === \"temp\") {\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Reserved tablespace name cannot be used\");\r\n }\r\n this.clearCaches();\r\n this[_nativeDb].detachDb(alias);\r\n }\r\n\r\n /** @deprecated in 5.0 - might be removed in next major version. Use [Symbol.dispose] instead. */\r\n public dispose(): void {\r\n this[Symbol.dispose]();\r\n }\r\n\r\n /** Create an ECDb\r\n * @param pathName The path to the ECDb file to create.\r\n * @throws [IModelError]($common) if the operation failed.\r\n */\r\n public createDb(pathName: string): void {\r\n const status: DbResult = this[_nativeDb].createDb(pathName);\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to created ECDb\");\r\n }\r\n\r\n /** Open the ECDb.\r\n * @param pathName The path to the ECDb file to open\r\n * @param openMode Open mode\r\n * @throws [IModelError]($common) if the operation failed.\r\n */\r\n public openDb(pathName: string, openMode: ECDbOpenMode = ECDbOpenMode.Readonly): void {\r\n const nativeOpenMode: OpenMode = openMode === ECDbOpenMode.Readonly ? OpenMode.Readonly : OpenMode.ReadWrite;\r\n const tryUpgrade: boolean = openMode === ECDbOpenMode.FileUpgrade;\r\n const status: DbResult = this[_nativeDb].openDb(pathName, nativeOpenMode, tryUpgrade);\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to open ECDb\");\r\n }\r\n\r\n /** Returns true if the ECDb is open */\r\n public get isOpen(): boolean { return this[_nativeDb].isOpen(); }\r\n\r\n /** Close the Db after saving any uncommitted changes.\r\n * @throws [IModelError]($common) if the database is not open.\r\n */\r\n public closeDb(): void {\r\n this.onBeforeClose.raiseEvent();\r\n this.clearCaches();\r\n this[_nativeDb].closeDb();\r\n }\r\n\r\n /** Clear all in-memory caches held in this ECDb.\r\n * @beta\r\n */\r\n public clearCaches(): void {\r\n this._statementCache.clear();\r\n this._sqliteStatementCache.clear();\r\n this[_nativeDb].clearECDbCache();\r\n }\r\n\r\n /** @internal use to test statement caching */\r\n public clearStatementCache() {\r\n this._statementCache.clear();\r\n }\r\n\r\n /** @internal use to test statement caching */\r\n public getCachedStatementCount() {\r\n return this._statementCache.size;\r\n }\r\n\r\n /** Commit the outermost transaction, writing changes to the file. Then, restart the transaction.\r\n * @param changesetName The name of the operation that generated these changes.\r\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\r\n */\r\n public saveChanges(changesetName?: string): void {\r\n const status: DbResult = this[_nativeDb].saveChanges(changesetName);\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to save changes\");\r\n }\r\n\r\n /** Abandon (cancel) the outermost transaction, discarding all changes since last save. Then, restart the transaction.\r\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\r\n */\r\n public abandonChanges(): void {\r\n const status: DbResult = this[_nativeDb].abandonChanges();\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to abandon changes\");\r\n }\r\n\r\n /** Import a schema.\r\n *\r\n * If the import was successful, the database is automatically saved to disk.\r\n * @param pathName Path to ECSchema XML file to import.\r\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\r\n */\r\n public importSchema(pathName: string): void {\r\n const status: DbResult = this[_nativeDb].importSchema(pathName);\r\n if (status !== DbResult.BE_SQLITE_OK) {\r\n Logger.logError(loggerCategory, `Failed to import schema from '${pathName}'.`);\r\n throw new IModelError(status, `Failed to import schema from '${pathName}'.`);\r\n }\r\n this.clearCaches();\r\n }\r\n\r\n /** Removes unused schemas from the database.\r\n *\r\n * If the removal was successful, the database is automatically saved to disk.\r\n * @param schemaNames Array of schema names to drop\r\n * @throws [IModelError]($common) if the database if the operation failed.\r\n * @alpha\r\n */\r\n public dropSchemas(schemaNames: string[]): void {\r\n if (schemaNames.length === 0)\r\n return;\r\n // SchemaSync.isEnabled() should be used, but ECDb is not an iModelDb so it has no container props\r\n if (this[_nativeDb].schemaSyncEnabled())\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Cannot drop schemas when schema sync is enabled\");\r\n\r\n try {\r\n this[_nativeDb].dropSchemas(schemaNames);\r\n this.saveChanges('dropped unused schemas');\r\n } catch (error: any) {\r\n Logger.logError(loggerCategory, `Failed to drop schemas: ${error}`);\r\n this.abandonChanges();\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, `Failed to drop schemas: ${error}`);\r\n } finally {\r\n this.clearCaches();\r\n }\r\n }\r\n\r\n /**\r\n * Returns the full schema for the input name.\r\n * @param name The name of the schema e.g. 'ECDbMeta'\r\n * @returns The SchemaProps for the requested schema\r\n * @throws if the schema can not be found or loaded.\r\n */\r\n public getSchemaProps(name: string): ECSchemaProps {\r\n return this[_nativeDb].getSchemaProps(name);\r\n }\r\n\r\n /** Import in-memory CSV rows into an ECClass.\r\n *\r\n * The rows are V8-serialized and processed in one native call. Values are converted from\r\n * their CSV string representation according to the mapped EC property type. One ECSQL\r\n * statement is reused for all rows. Every row must have the same number of columns.\r\n * Boolean fields accept `true`, `false`, `1`, or `0`. Integer fields must contain a\r\n * base-10 value in the signed 32-bit range. Boolean, double, integer, and string EC\r\n * properties are supported. The import is all-or-nothing and callers must call\r\n * [[saveChanges]] to commit it to disk.\r\n * @returns The number of imported rows.\r\n * @beta\r\n */\r\n public importCSVData(rows: readonly (readonly string[])[], options: CSVImportOptions): number {\r\n validateCSVMapping(options.mapping);\r\n return this[_nativeDb].importCSVData(options.className, serialize(rows), options.mapping, { nullValue: options.nullValue });\r\n }\r\n\r\n /** Stream a CSV file into an ECClass.\r\n *\r\n * The file must be UTF-8 encoded; an optional UTF-8 byte-order mark is accepted. It is read\r\n * and parsed in native code, and one ECSQL statement is reused for all rows. Every record must\r\n * have the same number of columns; blank records are not skipped. Boolean fields accept\r\n * `true`, `false`, `1`, or `0`. Integer fields must contain a base-10 value in the signed\r\n * 32-bit range. Boolean, double, integer, and string EC properties are supported. The import\r\n * is all-or-nothing and callers must call [[saveChanges]] to commit it to disk.\r\n * @returns The number of imported rows, excluding an optional header.\r\n * @beta\r\n */\r\n public importCSVFile(csvFilePath: string, options: CSVFileImportOptions): number {\r\n validateCSVMapping(options.mapping);\r\n return this[_nativeDb].importCSVFile(options.className, csvFilePath, options.mapping, {\r\n hasHeader: options.hasHeader,\r\n nullValue: options.nullValue,\r\n });\r\n }\r\n\r\n /**\r\n * Use a prepared ECSQL 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 ECSQL 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 [[withStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withWriteStatement]]\r\n * @beta\r\n */\r\n public withCachedWriteStatement<T>(ecsql: string, callback: (stmt: ECSqlWriteStatement) => T, logErrors = true): T {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n const stmt = this._statementCache.findAndRemove(ecsql) ?? this.prepareStatement(ecsql, logErrors);\r\n const release = () => this._statementCache.addOrDispose(stmt);\r\n try {\r\n const val = callback(new ECSqlWriteStatement(stmt));\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Prepared and execute a callback on an ECSQL statement. After the callback completes the statement is disposed.\r\n * Use this method for ECSQL 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 [[withPreparedStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withCachedWriteStatement]]\r\n * @beta\r\n */\r\n public withWriteStatement<T>(ecsql: string, callback: (stmt: ECSqlWriteStatement) => T, logErrors = true): T {\r\n const stmt = this.prepareWriteStatement(ecsql, logErrors);\r\n const release = () => stmt[Symbol.dispose]();\r\n try {\r\n const val = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /** Prepare an ECSQL statement.\r\n * @param ecsql The ECSQL statement to prepare\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @throws [IModelError]($common) if there is a problem preparing the statement.\r\n * @beta\r\n */\r\n public prepareWriteStatement(ecsql: string, logErrors = true): ECSqlWriteStatement {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n return new ECSqlWriteStatement(this.prepareStatement(ecsql, logErrors));\r\n }\r\n\r\n /**\r\n * Use a prepared ECSQL 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 ECSQL 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 [[withStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withStatement]]\r\n * @public\r\n * @deprecated in 4.11 - might be removed in next major version. Use [[createQueryReader]] for SELECT statements and [[withCachedWriteStatement]] for INSERT/UPDATE/DELETE instead.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n public withPreparedStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors = true): T {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n const stmt = this._statementCache.findAndRemove(ecsql) ?? this.prepareStatement(ecsql, logErrors);\r\n const release = () => this._statementCache.addOrDispose(stmt);\r\n try {\r\n const val = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Prepared and execute a callback on an ECSQL statement. After the callback completes the statement is disposed.\r\n * Use this method for ECSQL 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 [[withPreparedStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withPreparedStatement]]\r\n * @public\r\n * @deprecated in 4.11 - might be removed in next major version. Use [[createQueryReader]] for SELECT statements and [[withWriteStatement]] for INSERT/UPDATE/DELETE instead.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n public withStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors = true): T {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n const stmt = this.prepareStatement(ecsql, logErrors);\r\n const release = () => stmt[Symbol.dispose]();\r\n try {\r\n const val = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /** Prepare an ECSQL statement.\r\n * @param ecsql The ECSQL statement to prepare\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @throws [IModelError]($common) if there is a problem preparing the statement.\r\n * @deprecated in 4.11 - might be removed in next major version. Use [[prepareWriteStatement]] when preparing an INSERT/UPDATE/DELETE statement or [[createQueryReader]] to execute a SELECT statement.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n public prepareStatement(ecsql: string, logErrors = true): ECSqlStatement {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n const stmt = new ECSqlStatement();\r\n stmt.prepare(this[_nativeDb], ecsql, logErrors);\r\n return stmt;\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 * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withPreparedStatement]]\r\n * @public\r\n */\r\n public withPreparedSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors = true): T {\r\n const stmt = this._sqliteStatementCache.findAndRemove(sql) ?? this.prepareSqliteStatement(sql, logErrors);\r\n const release = () => this._sqliteStatementCache.addOrDispose(stmt);\r\n try {\r\n const val: T = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Prepared and execute a callback on a SQL statement. After the callback completes the statement is disposed.\r\n * Use this method for SQL statements are either not expected to be reused, or are not expensive to prepare.\r\n * For statements that will be reused often, instead use [[withPreparedSqliteStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @public\r\n */\r\n public withSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors = true): T {\r\n const stmt = this.prepareSqliteStatement(sql, logErrors);\r\n const release = () => stmt[Symbol.dispose]();\r\n try {\r\n const val: T = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /** Prepare an SQL statement.\r\n * @param sql The SQLite SQL statement to prepare\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @throws [IModelError]($common) if there is a problem preparing the statement.\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 /** @internal */\r\n public get [_nativeDb](): IModelJsNative.ECDb {\r\n assert(undefined !== this._nativeDb);\r\n return this._nativeDb;\r\n }\r\n\r\n /** Creates a reader for asynchronous ECSQL query execution.\r\n * Execution starts when the reader is consumed using asynchronous iteration or awaited calls to `step()` or `toArray()`.\r\n * Results are fetched and buffered in batches. For synchronous, callback-scoped execution, use [[withQueryReader]].\r\n *\r\n * See also:\r\n * - [Choosing a query reader]($docs/learning/backend/ExecutingECSQL)\r\n * - [Asynchronous query examples]($docs/learning/ECSQLCodeExamples)\r\n * - [ECSQL Row Format]($docs/learning/ECSQLRowFormat)\r\n *\r\n * @param params The values to bind to the parameters (if the ECSQL has any).\r\n * @param config Allow to specify certain flags which control how query is executed.\r\n * @returns Returns an [ECSqlReader]($common) which helps iterate over the result set and also give access to metadata.\r\n * @public\r\n * */\r\n public createQueryReader(ecsql: string, params?: QueryBinder, config?: QueryOptions): ECSqlReader {\r\n if (!this._nativeDb || !this._nativeDb.isOpen()) {\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR_NOTOPEN, \"db not open\");\r\n }\r\n const executor = {\r\n execute: async (request: DbQueryRequest) => {\r\n return ConcurrentQuery.executeQueryRequest(this[_nativeDb], request);\r\n },\r\n };\r\n return new ECSqlReader(executor, ecsql, params, config);\r\n }\r\n\r\n /** Executes a callback with a synchronous ECSQL reader on the owning database connection.\r\n * The reader steps one row at a time without buffering result batches. Finish using it before the callback completes.\r\n * Return materialized rows or computed values rather than the reader. For asynchronous execution, use [[createQueryReader]].\r\n * The prepared statement may be reused from the statement cache between completed calls.\r\n *\r\n * See also:\r\n * - [Choosing a query reader]($docs/learning/backend/ExecutingECSQL)\r\n * - [Synchronous query examples]($docs/learning/backend/WithQueryReaderCodeExamples)\r\n * - [ECSQL Row Format]($docs/learning/ECSQLRowFormat)\r\n * @param ecsql The ECSQL query to execute.\r\n * @param callback the callback to invoke on the prepared ECSqlSyncReader\r\n * @param params The values to bind to the parameters (if the ECSQL has any).\r\n * @param config Optional flags which control how query is executed.\r\n * @returns the value returned by `callback`.\r\n * @throws IModelError if db is not open or if error occurs during statement execution\r\n * @beta\r\n * */\r\n public withQueryReader<T>(ecsql: string, callback: (reader: ECSqlSyncReader) => T, params?: QueryBinder, config?: SynchronousQueryOptions): T {\r\n if (!this[_nativeDb].isOpen())\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR_NOTOPEN, \"db not open\");\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n const stmt = this._statementCache.findAndRemove(ecsql) ?? new ECSqlStatement();\r\n const executor = new ECSqlRowExecutor(this, stmt, loggerCategory);\r\n const release = () => {\r\n executor[Symbol.dispose]();\r\n releaseECSqlStatement(stmt, this._statementCache, loggerCategory, executor.canCacheStatement);\r\n };\r\n try {\r\n const reader = new ECSqlSyncReader(executor, ecsql, params, config);\r\n const val = callback(reader);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err: any) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ECDb.js","sourceRoot":"","sources":["../../src/ECDb.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAElF,OAAO,EAAiC,WAAW,EAAE,WAAW,EAA6B,MAAM,oBAAoB,CAAC;AACxH,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,YAAY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GAAG,CAAC;QACZ,CAAC;IACH,CAAC;CACF","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 ECDb\r\n */\r\nimport { assert, BeEvent, DbResult, Logger, OpenMode } from \"@itwin/core-bentley\";\r\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\nimport { DbQueryRequest, ECSchemaProps, ECSqlReader, IModelError, QueryBinder, QueryOptions } from \"@itwin/core-common\";\r\nimport { serialize } from \"node:v8\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { ConcurrentQuery } from \"./ConcurrentQuery\";\r\nimport { ECSqlStatement, ECSqlWriteStatement } from \"./ECSqlStatement\";\r\nimport { IModelNative } from \"./internal/NativePlatform\";\r\nimport { SqliteStatement, StatementCache } from \"./SqliteStatement\";\r\nimport { _nativeDb } from \"./internal/Symbols\";\r\nimport { QueryMetadataCache } from \"./internal/QueryMetadataCache\";\r\nimport { ECSqlRowExecutor, releaseECSqlStatement } from \"./ECSqlRowExecutor\";\r\nimport { ECSqlSyncReader, SynchronousQueryOptions } from \"./ECSqlSyncReader\";\r\n\r\nconst loggerCategory: string = BackendLoggerCategory.ECDb;\r\n\r\n/** Maps a zero-based CSV column to an EC property.\r\n * @beta\r\n */\r\nexport interface CSVColumnMapping {\r\n /** Zero-based index of the source CSV column. */\r\n columnIndex: number;\r\n /** EC property access string to receive the column value. */\r\n propertyName: string;\r\n}\r\n\r\n/** Common options for importing CSV data into an ECClass.\r\n * @beta\r\n */\r\nexport interface CSVImportOptions {\r\n /** Full name or ECSQL name of the ECClass to insert. */\r\n className: string;\r\n /** Source-column to EC-property mappings. Unmapped source columns are ignored. */\r\n mapping: readonly CSVColumnMapping[];\r\n /** Exact CSV value to bind as null. By default, every field is treated as a value. */\r\n nullValue?: string;\r\n}\r\n\r\n/** Options for [[ECDb.importCSVFile]].\r\n * @beta\r\n */\r\nexport interface CSVFileImportOptions extends CSVImportOptions {\r\n /** Whether the first CSV row is a header to skip. Defaults to false. */\r\n hasHeader?: boolean;\r\n}\r\n\r\nfunction validateCSVMapping(mapping: readonly CSVColumnMapping[]): void {\r\n if (0 === mapping.length)\r\n throw new TypeError(\"mapping must not be empty\");\r\n\r\n const columnIndexes = new Set<number>();\r\n for (const entry of mapping) {\r\n if (undefined === entry || null === entry || \"object\" !== typeof entry)\r\n throw new TypeError(\"mapping must contain only objects\");\r\n if (!Number.isSafeInteger(entry.columnIndex) || entry.columnIndex < 0 || entry.columnIndex >= 0xffff_ffff)\r\n throw new TypeError(\"mapping columnIndex values must be non-negative safe integers\");\r\n if (\"string\" !== typeof entry.propertyName || 0 === entry.propertyName.length)\r\n throw new TypeError(\"mapping propertyName values must not be empty\");\r\n if (columnIndexes.has(entry.columnIndex))\r\n throw new TypeError(\"mapping must not contain duplicate columnIndex values\");\r\n columnIndexes.add(entry.columnIndex);\r\n }\r\n}\r\n\r\n/** Modes for how to open [ECDb]($backend) files.\r\n * @public\r\n */\r\nexport enum ECDbOpenMode {\r\n Readonly,\r\n ReadWrite,\r\n /** Opens the file read-write and upgrades the file if necessary to the latest file format version. */\r\n FileUpgrade,\r\n}\r\n\r\n/** An ECDb file\r\n * @public\r\n */\r\nexport class ECDb implements Disposable {\r\n private _nativeDb?: IModelJsNative.ECDb;\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n private readonly _statementCache = new StatementCache<ECSqlStatement>();\r\n private _sqliteStatementCache = new StatementCache<SqliteStatement>();\r\n private readonly _queryMetadataCache = new QueryMetadataCache();\r\n\r\n /** Event called when the ECDb is about to be closed. */\r\n public readonly onBeforeClose = new BeEvent<() => void>();\r\n\r\n /** only for tests\r\n * @internal\r\n */\r\n public resetSqliteCache(size: number) {\r\n this._sqliteStatementCache.clear();\r\n this._sqliteStatementCache = new StatementCache<SqliteStatement>(size);\r\n }\r\n\r\n constructor() {\r\n this._nativeDb = new IModelNative.platform.ECDb();\r\n }\r\n /** Call this function when finished with this ECDb object. This releases the native resources held by the\r\n * ECDb object.\r\n */\r\n public [Symbol.dispose](): void {\r\n if (!this._nativeDb)\r\n return;\r\n\r\n this.closeDb();\r\n this._nativeDb.dispose();\r\n this._nativeDb = undefined;\r\n }\r\n /**\r\n * Attach an iModel file to this connection and load and register its schemas.\r\n * @note There are some reserve tablespace names that cannot be used. They are 'main', 'schema_sync_db', 'ecchange' & 'temp'\r\n * @param fileName IModel file name\r\n * @param alias identifier for the attached file. This identifer is used to access schema from the attached file. e.g. if alias is 'abc' then schema can be accessed using 'abc.MySchema.MyClass'\r\n */\r\n public attachDb(fileName: string, alias: string): void {\r\n if (alias.toLowerCase() === \"main\" || alias.toLowerCase() === \"schema_sync_db\" || alias.toLowerCase() === \"ecchange\" || alias.toLowerCase() === \"temp\") {\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Reserved tablespace name cannot be used\");\r\n }\r\n this[_nativeDb].attachDb(fileName, alias);\r\n }\r\n /**\r\n * Detach the attached file from this connection. The attached file is closed and its schemas are unregistered.\r\n * @note There are some reserve tablespace names that cannot be used. They are 'main', 'schema_sync_db', 'ecchange' & 'temp'\r\n * @param alias identifer that was used in the call to [[attachDb]]\r\n */\r\n public detachDb(alias: string): void {\r\n if (alias.toLowerCase() === \"main\" || alias.toLowerCase() === \"schema_sync_db\" || alias.toLowerCase() === \"ecchange\" || alias.toLowerCase() === \"temp\") {\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Reserved tablespace name cannot be used\");\r\n }\r\n this.clearCaches();\r\n this[_nativeDb].detachDb(alias);\r\n }\r\n\r\n /** @deprecated in 5.0 - might be removed in next major version. Use [Symbol.dispose] instead. */\r\n public dispose(): void {\r\n this[Symbol.dispose]();\r\n }\r\n\r\n /** Create an ECDb\r\n * @param pathName The path to the ECDb file to create.\r\n * @throws [IModelError]($common) if the operation failed.\r\n */\r\n public createDb(pathName: string): void {\r\n const status: DbResult = this[_nativeDb].createDb(pathName);\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to created ECDb\");\r\n }\r\n\r\n /** Open the ECDb.\r\n * @param pathName The path to the ECDb file to open\r\n * @param openMode Open mode\r\n * @throws [IModelError]($common) if the operation failed.\r\n */\r\n public openDb(pathName: string, openMode: ECDbOpenMode = ECDbOpenMode.Readonly): void {\r\n const nativeOpenMode: OpenMode = openMode === ECDbOpenMode.Readonly ? OpenMode.Readonly : OpenMode.ReadWrite;\r\n const tryUpgrade: boolean = openMode === ECDbOpenMode.FileUpgrade;\r\n const status: DbResult = this[_nativeDb].openDb(pathName, nativeOpenMode, tryUpgrade);\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to open ECDb\");\r\n }\r\n\r\n /** Returns true if the ECDb is open */\r\n public get isOpen(): boolean { return this[_nativeDb].isOpen(); }\r\n\r\n /** Close the Db after saving any uncommitted changes.\r\n * @throws [IModelError]($common) if the database is not open.\r\n */\r\n public closeDb(): void {\r\n this.onBeforeClose.raiseEvent();\r\n this.clearCaches();\r\n this[_nativeDb].closeDb();\r\n }\r\n\r\n /** Clear all in-memory caches held in this ECDb.\r\n * @beta\r\n */\r\n public clearCaches(): void {\r\n this._queryMetadataCache.clear();\r\n this._statementCache.clear();\r\n this._sqliteStatementCache.clear();\r\n this[_nativeDb].clearECDbCache();\r\n }\r\n\r\n /** @internal use to test statement caching */\r\n public clearStatementCache() {\r\n this._statementCache.clear();\r\n }\r\n\r\n /** @internal use to test statement caching */\r\n public getCachedStatementCount() {\r\n return this._statementCache.size;\r\n }\r\n\r\n /** Commit the outermost transaction, writing changes to the file. Then, restart the transaction.\r\n * @param changesetName The name of the operation that generated these changes.\r\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\r\n */\r\n public saveChanges(changesetName?: string): void {\r\n const status: DbResult = this[_nativeDb].saveChanges(changesetName);\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to save changes\");\r\n }\r\n\r\n /** Abandon (cancel) the outermost transaction, discarding all changes since last save. Then, restart the transaction.\r\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\r\n */\r\n public abandonChanges(): void {\r\n const status: DbResult = this[_nativeDb].abandonChanges();\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to abandon changes\");\r\n }\r\n\r\n /** Import a schema.\r\n *\r\n * If the import was successful, the database is automatically saved to disk.\r\n * @param pathName Path to ECSchema XML file to import.\r\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\r\n */\r\n public importSchema(pathName: string): void {\r\n const status: DbResult = this[_nativeDb].importSchema(pathName);\r\n if (status !== DbResult.BE_SQLITE_OK) {\r\n Logger.logError(loggerCategory, `Failed to import schema from '${pathName}'.`);\r\n throw new IModelError(status, `Failed to import schema from '${pathName}'.`);\r\n }\r\n this.clearCaches();\r\n }\r\n\r\n /** Removes unused schemas from the database.\r\n *\r\n * If the removal was successful, the database is automatically saved to disk.\r\n * @param schemaNames Array of schema names to drop\r\n * @throws [IModelError]($common) if the database if the operation failed.\r\n * @alpha\r\n */\r\n public dropSchemas(schemaNames: string[]): void {\r\n if (schemaNames.length === 0)\r\n return;\r\n // SchemaSync.isEnabled() should be used, but ECDb is not an iModelDb so it has no container props\r\n if (this[_nativeDb].schemaSyncEnabled())\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Cannot drop schemas when schema sync is enabled\");\r\n\r\n try {\r\n this[_nativeDb].dropSchemas(schemaNames);\r\n this.saveChanges('dropped unused schemas');\r\n } catch (error: any) {\r\n Logger.logError(loggerCategory, `Failed to drop schemas: ${error}`);\r\n this.abandonChanges();\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, `Failed to drop schemas: ${error}`);\r\n } finally {\r\n this.clearCaches();\r\n }\r\n }\r\n\r\n /**\r\n * Returns the full schema for the input name.\r\n * @param name The name of the schema e.g. 'ECDbMeta'\r\n * @returns The SchemaProps for the requested schema\r\n * @throws if the schema can not be found or loaded.\r\n */\r\n public getSchemaProps(name: string): ECSchemaProps {\r\n return this[_nativeDb].getSchemaProps(name);\r\n }\r\n\r\n /** Import in-memory CSV rows into an ECClass.\r\n *\r\n * The rows are V8-serialized and processed in one native call. Values are converted from\r\n * their CSV string representation according to the mapped EC property type. One ECSQL\r\n * statement is reused for all rows. Every row must have the same number of columns.\r\n * Boolean fields accept `true`, `false`, `1`, or `0`. Integer fields must contain a\r\n * base-10 value in the signed 32-bit range. Boolean, double, integer, and string EC\r\n * properties are supported. The import is all-or-nothing and callers must call\r\n * [[saveChanges]] to commit it to disk.\r\n * @returns The number of imported rows.\r\n * @beta\r\n */\r\n public importCSVData(rows: readonly (readonly string[])[], options: CSVImportOptions): number {\r\n validateCSVMapping(options.mapping);\r\n return this[_nativeDb].importCSVData(options.className, serialize(rows), options.mapping, { nullValue: options.nullValue });\r\n }\r\n\r\n /** Stream a CSV file into an ECClass.\r\n *\r\n * The file must be UTF-8 encoded; an optional UTF-8 byte-order mark is accepted. It is read\r\n * and parsed in native code, and one ECSQL statement is reused for all rows. Every record must\r\n * have the same number of columns; blank records are not skipped. Boolean fields accept\r\n * `true`, `false`, `1`, or `0`. Integer fields must contain a base-10 value in the signed\r\n * 32-bit range. Boolean, double, integer, and string EC properties are supported. The import\r\n * is all-or-nothing and callers must call [[saveChanges]] to commit it to disk.\r\n * @returns The number of imported rows, excluding an optional header.\r\n * @beta\r\n */\r\n public importCSVFile(csvFilePath: string, options: CSVFileImportOptions): number {\r\n validateCSVMapping(options.mapping);\r\n return this[_nativeDb].importCSVFile(options.className, csvFilePath, options.mapping, {\r\n hasHeader: options.hasHeader,\r\n nullValue: options.nullValue,\r\n });\r\n }\r\n\r\n /**\r\n * Use a prepared ECSQL 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 ECSQL 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 [[withStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withWriteStatement]]\r\n * @beta\r\n */\r\n public withCachedWriteStatement<T>(ecsql: string, callback: (stmt: ECSqlWriteStatement) => T, logErrors = true): T {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n const stmt = this._statementCache.findAndRemove(ecsql) ?? this.prepareStatement(ecsql, logErrors);\r\n const release = () => this._statementCache.addOrDispose(stmt);\r\n try {\r\n const val = callback(new ECSqlWriteStatement(stmt));\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Prepared and execute a callback on an ECSQL statement. After the callback completes the statement is disposed.\r\n * Use this method for ECSQL 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 [[withPreparedStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withCachedWriteStatement]]\r\n * @beta\r\n */\r\n public withWriteStatement<T>(ecsql: string, callback: (stmt: ECSqlWriteStatement) => T, logErrors = true): T {\r\n const stmt = this.prepareWriteStatement(ecsql, logErrors);\r\n const release = () => stmt[Symbol.dispose]();\r\n try {\r\n const val = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /** Prepare an ECSQL statement.\r\n * @param ecsql The ECSQL statement to prepare\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @throws [IModelError]($common) if there is a problem preparing the statement.\r\n * @beta\r\n */\r\n public prepareWriteStatement(ecsql: string, logErrors = true): ECSqlWriteStatement {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n return new ECSqlWriteStatement(this.prepareStatement(ecsql, logErrors));\r\n }\r\n\r\n /**\r\n * Use a prepared ECSQL 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 ECSQL 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 [[withStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withStatement]]\r\n * @public\r\n * @deprecated in 4.11 - might be removed in next major version. Use [[createQueryReader]] for SELECT statements and [[withCachedWriteStatement]] for INSERT/UPDATE/DELETE instead.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n public withPreparedStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors = true): T {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n const stmt = this._statementCache.findAndRemove(ecsql) ?? this.prepareStatement(ecsql, logErrors);\r\n const release = () => this._statementCache.addOrDispose(stmt);\r\n try {\r\n const val = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Prepared and execute a callback on an ECSQL statement. After the callback completes the statement is disposed.\r\n * Use this method for ECSQL 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 [[withPreparedStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withPreparedStatement]]\r\n * @public\r\n * @deprecated in 4.11 - might be removed in next major version. Use [[createQueryReader]] for SELECT statements and [[withWriteStatement]] for INSERT/UPDATE/DELETE instead.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n public withStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors = true): T {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n const stmt = this.prepareStatement(ecsql, logErrors);\r\n const release = () => stmt[Symbol.dispose]();\r\n try {\r\n const val = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /** Prepare an ECSQL statement.\r\n * @param ecsql The ECSQL statement to prepare\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @throws [IModelError]($common) if there is a problem preparing the statement.\r\n * @deprecated in 4.11 - might be removed in next major version. Use [[prepareWriteStatement]] when preparing an INSERT/UPDATE/DELETE statement or [[createQueryReader]] to execute a SELECT statement.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n public prepareStatement(ecsql: string, logErrors = true): ECSqlStatement {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n const stmt = new ECSqlStatement();\r\n stmt.prepare(this[_nativeDb], ecsql, logErrors);\r\n return stmt;\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 * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withPreparedStatement]]\r\n * @public\r\n */\r\n public withPreparedSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors = true): T {\r\n const stmt = this._sqliteStatementCache.findAndRemove(sql) ?? this.prepareSqliteStatement(sql, logErrors);\r\n const release = () => this._sqliteStatementCache.addOrDispose(stmt);\r\n try {\r\n const val: T = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Prepared and execute a callback on a SQL statement. After the callback completes the statement is disposed.\r\n * Use this method for SQL statements are either not expected to be reused, or are not expensive to prepare.\r\n * For statements that will be reused often, instead use [[withPreparedSqliteStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @public\r\n */\r\n public withSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors = true): T {\r\n const stmt = this.prepareSqliteStatement(sql, logErrors);\r\n const release = () => stmt[Symbol.dispose]();\r\n try {\r\n const val: T = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /** Prepare an SQL statement.\r\n * @param sql The SQLite SQL statement to prepare\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @throws [IModelError]($common) if there is a problem preparing the statement.\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 /** @internal */\r\n public get [_nativeDb](): IModelJsNative.ECDb {\r\n assert(undefined !== this._nativeDb);\r\n return this._nativeDb;\r\n }\r\n\r\n /** Creates a reader for asynchronous ECSQL query execution.\r\n * Execution starts when the reader is consumed using asynchronous iteration or awaited calls to `step()` or `toArray()`.\r\n * Results are fetched and buffered in batches. For synchronous, callback-scoped execution, use [[withQueryReader]].\r\n *\r\n * See also:\r\n * - [Choosing a query reader]($docs/learning/backend/ExecutingECSQL)\r\n * - [Asynchronous query examples]($docs/learning/ECSQLCodeExamples)\r\n * - [ECSQL Row Format]($docs/learning/ECSQLRowFormat)\r\n *\r\n * @param params The values to bind to the parameters (if the ECSQL has any).\r\n * @param config Allow to specify certain flags which control how query is executed.\r\n * @returns Returns an [ECSqlReader]($common) which helps iterate over the result set and also give access to metadata.\r\n * @public\r\n * */\r\n public createQueryReader(ecsql: string, params?: QueryBinder, config?: QueryOptions): ECSqlReader {\r\n if (!this._nativeDb || !this._nativeDb.isOpen()) {\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR_NOTOPEN, \"db not open\");\r\n }\r\n const executor = {\r\n execute: async (request: DbQueryRequest) => {\r\n return this._queryMetadataCache.executeCachedQueryRequest(request, async (req) => ConcurrentQuery.executeQueryRequest(this[_nativeDb], req));\r\n },\r\n };\r\n return new ECSqlReader(executor, ecsql, params, config);\r\n }\r\n\r\n /** Executes a callback with a synchronous ECSQL reader on the owning database connection.\r\n * The reader steps one row at a time without buffering result batches. Finish using it before the callback completes.\r\n * Return materialized rows or computed values rather than the reader. For asynchronous execution, use [[createQueryReader]].\r\n * The prepared statement may be reused from the statement cache between completed calls.\r\n *\r\n * See also:\r\n * - [Choosing a query reader]($docs/learning/backend/ExecutingECSQL)\r\n * - [Synchronous query examples]($docs/learning/backend/WithQueryReaderCodeExamples)\r\n * - [ECSQL Row Format]($docs/learning/ECSQLRowFormat)\r\n * @param ecsql The ECSQL query to execute.\r\n * @param callback the callback to invoke on the prepared ECSqlSyncReader\r\n * @param params The values to bind to the parameters (if the ECSQL has any).\r\n * @param config Optional flags which control how query is executed.\r\n * @returns the value returned by `callback`.\r\n * @throws IModelError if db is not open or if error occurs during statement execution\r\n * @beta\r\n * */\r\n public withQueryReader<T>(ecsql: string, callback: (reader: ECSqlSyncReader) => T, params?: QueryBinder, config?: SynchronousQueryOptions): T {\r\n if (!this[_nativeDb].isOpen())\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR_NOTOPEN, \"db not open\");\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n const stmt = this._statementCache.findAndRemove(ecsql) ?? new ECSqlStatement();\r\n const executor = new ECSqlRowExecutor(this, stmt, loggerCategory);\r\n const release = () => {\r\n executor[Symbol.dispose]();\r\n releaseECSqlStatement(stmt, this._statementCache, loggerCategory, executor.canCacheStatement);\r\n };\r\n try {\r\n const reader = new ECSqlSyncReader(executor, ecsql, params, config);\r\n const val = callback(reader);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err: any) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n}\r\n"]}
@@ -10,34 +10,62 @@ import type { ChangeElementModelProps, ChangeElementParentProps, IModelDb, Inser
10
10
  import type { SettingsContainer } from "./workspace/Settings";
11
11
  /** Options for bulk deleting elements from an iModelDb.
12
12
  * @beta
13
+ * @deprecated in 5.15.0 - will not be removed until after 2027-11-05. Options are no longer used and [[EditTxn.deleteElements]] ignores this argument.
13
14
  */
14
15
  export interface BulkDeleteElementsArgs {
15
16
  /**
16
- * Skips pre-deletion **NO ACTION** foreign key constraint validation checks, which may improve performance for large deletions.
17
- * This will improve performance, but if the user supplies elements which have FK constraint violations, it will result in the delete failing and an eventual rollback.
17
+ * @deprecated in 5.15.0 - will not be removed until after 2027-11-05. Skipping FK constraint validation is no longer supported.
18
18
  */
19
19
  skipFKConstraintValidations?: boolean;
20
20
  }
21
+ /**
22
+ * Why an element could not be deleted by [[EditTxn.deleteElements]].
23
+ * @beta
24
+ */
25
+ export declare enum BulkDeleteFailureReason {
26
+ /** A row outside the delete set references it via a NO ACTION / RESTRICT / SET DEFAULT FK. */
27
+ ReferencedByForeignKey = 0,
28
+ /** It is a DefinitionElement still used by elements outside the delete set. */
29
+ DefinitionInUse = 1,
30
+ /** It is one of the elements every iModel must keep: the root Subject, the DictionaryModel partition or the RealityDataSources partition. */
31
+ ProtectedElement = 2,
32
+ /** Its handler belongs to a read-only DgnDomain. */
33
+ ReadOnlyDomain = 3
34
+ }
35
+ /**
36
+ * One element that could not be deleted by [[EditTxn.deleteElements]], and why.
37
+ * @beta
38
+ */
39
+ export interface BulkDeleteFailure {
40
+ /** The id of the element that could not be deleted. */
41
+ elementId: Id64String;
42
+ /** Why the element could not be deleted. */
43
+ reason: BulkDeleteFailureReason;
44
+ }
21
45
  /**
22
46
  * Result of a bulk element delete operation.
23
47
  * @beta
24
48
  */
25
49
  export interface BulkDeleteElementsResult {
26
- /**
27
- * Overall status of the bulk delete operation.
28
- * - `Success`: All elements were deleted successfully. `failedIds` will be empty.
29
- * - `PartialSuccess`: Some elements were deleted, but others failed. `failedIds` contains the ids that could not be deleted.
30
- * - `DeletionFailed`: The delete operation failed entirely (e.g. due to an FK constraint violation). `failedIds` contains the ids that could not be deleted.
31
- */
50
+ /** Overall status of the bulk delete operation. See [[BulkDeleteElementsStatus]]. */
32
51
  status: BulkDeleteElementsStatus;
52
+ /** The raw SQLite result code from the underlying SQL DELETE. Only meaningful when `status === DeletionFailed`. */
53
+ sqlDeleteStatus: DbResult;
33
54
  /**
34
- * The raw SQLite result code from the underlying SQL DELETE statement.
35
- * `DbResult.BE_SQLITE_OK` on success; a non-OK code indicates a database-level error such as a constraint violation.
55
+ * One entry per element that blocks the deletion, with the reason. Only populated on `ConstraintViolation`.
56
+ * Empty on `Success` and `DeletionFailed`.
57
+ * Because the whole expanded delete set is validated, a reported element may be a child or sub-model member
58
+ * that was not in the requested ids; its requested ancestor is not listed separately.
36
59
  */
37
- sqlDeleteStatus: DbResult;
60
+ failures: BulkDeleteFailure[];
38
61
  /**
39
62
  * The set of element ids that could not be deleted.
40
- * Empty when `status` is `Success`. Non-empty when `status` is `PartialSuccess` or `DeletionFailed`.
63
+ * - On `ConstraintViolation`: the unique element ids appearing in `failures`. May include cascaded descendants
64
+ * that were not in the requested ids, so this is not guaranteed to be a subset of the input. Never empty.
65
+ * Nothing was deleted, including requested ids that are not listed.
66
+ * - On `DeletionFailed`: every requested id (the iModel may be partially modified; abandon the current txn).
67
+ * - On `Success`: empty.
68
+ * @deprecated in 5.15.0 - will not be removed until after 2027-11-05. Use `failures` for a more detailed failure report.
41
69
  */
42
70
  failedIds: Id64Set;
43
71
  }
@@ -48,9 +76,9 @@ export interface BulkDeleteElementsResult {
48
76
  export declare enum BulkDeleteElementsStatus {
49
77
  /** All supplied elements were deleted successfully. */
50
78
  Success = 0,
51
- /** Some elements were deleted but others could not be, typically due to foreign key constraints on the elements not being deleted. */
52
- PartialSuccess = 1,
53
- /** No elements were deleted. This occurs when the SQL DELETE statement itself fails, e.g. due to a FK constraint violation that prevents the entire batch from being processed. */
79
+ /** Nothing was deleted because some elements in the (expanded) delete set are still referenced from outside the set; see `failures` for the violators. */
80
+ ConstraintViolation = 1,
81
+ /** An internal error occurred. The iModel may be partially modified; the caller must abandon the current txn. `failures` will be empty. */
54
82
  DeletionFailed = 2
55
83
  }
56
84
  /**
@@ -96,6 +124,7 @@ export declare class EditTxn {
96
124
  verifyWriteable(): void;
97
125
  /** Start this EditTxn, making it the active transaction for the iModel.
98
126
  * @throws EditTxnError if this EditTxn is already active, another EditTxn is already active, or if unsaved changes are present.
127
+ * @throws IModelError if the geographic coordinate system is being restored.
99
128
  */
100
129
  start(): void;
101
130
  /** End this EditTxn, either by saving or abandoning the changes.
@@ -103,6 +132,7 @@ export declare class EditTxn {
103
132
  * @param args Save changes arguments when saving.
104
133
  * @throws EditTxnError if this EditTxn is not active.
105
134
  * @throws IModelError if saving changes fails.
135
+ * @throws Re-throws any error propagated by a geographic coordinate system restoration listener after completing abandonment.
106
136
  */
107
137
  end(): void;
108
138
  end(mode: "save" | "abandon", args?: string | SaveChangesArgs): void;
@@ -117,6 +147,7 @@ export declare class EditTxn {
117
147
  * @throws EditTxnError if this EditTxn is not active.
118
148
  */
119
149
  abandonChanges(): void;
150
+ private abandonDatabaseChanges;
120
151
  /** Save changes with additional arguments.
121
152
  * @param args Save changes arguments.
122
153
  * @throws EditTxnError if this EditTxn is not active.
@@ -198,14 +229,23 @@ export declare class EditTxn {
198
229
  */
199
230
  private collectSubtreeIds;
200
231
  /**
201
- * Delete multiple elements from the iModel.
232
+ * Delete multiple elements from the iModel in a single bulk operation.
233
+ *
234
+ * Child elements and sub-model contents of the requested elements are deleted along with them.
235
+ *
236
+ * The operation is all-or-nothing:
237
+ * - On `Success`, all elements (and their children / sub-model contents) were deleted.
238
+ * - On `ConstraintViolation`, nothing was deleted and [[BulkDeleteElementsResult.failures]] lists every element in the
239
+ * expanded delete set that is still referenced from outside the set, and why. Fix or include those referencing elements and retry.
240
+ * - On `DeletionFailed` (an unexpected SQLite error) the iModel may be partially modified and the caller must abandon the current txn.
241
+ *
202
242
  * @param ids The ids of the elements to delete. All ids must be well-formed and valid [[Id64String]]s.
203
- * @param deleteOptions Options for the delete operation.
204
- * @returns A result object containing information about the deletion operation success and the element ids that failed to delete (if any).
243
+ * @param _deleteOptions Deprecated and ignored; kept for backward compatibility of the signature.
244
+ * @returns A result object describing the outcome of the operation and the elements that block it (if any).
205
245
  * @throws [[ITwinError]] if any of the supplied ids are not well-formed/valid [[Id64String]]s.
206
246
  * @beta
207
247
  */
208
- deleteElements(ids: Id64Array, deleteOptions?: BulkDeleteElementsArgs): BulkDeleteElementsResult;
248
+ deleteElements(ids: Id64Array, _deleteOptions?: BulkDeleteElementsArgs): BulkDeleteElementsResult;
209
249
  /** Insert a new aspect into the iModel.
210
250
  * @param aspectProps The properties of the new aspect.
211
251
  * @returns The newly inserted aspect Id.
@@ -303,6 +343,7 @@ export declare class EditTxn {
303
343
  */
304
344
  updateEcefLocation(ecef: EcefLocationProps): void;
305
345
  /** Update the iModel props in the database from the current in-memory state.
346
+ * An unchanged geographic coordinate system is not replaced or re-resolved from its dictionary identifiers.
306
347
  * @throws EditTxnError if this EditTxn is not active.
307
348
  */
308
349
  updateIModelProps(): void;
@@ -332,6 +373,7 @@ export declare class EditTxn {
332
373
  * and passed to `fn`. If `fn` returns normally (or its returned Promise resolves), the transaction
333
374
  * is committed. If `fn` throws (or its returned Promise rejects), the transaction is abandoned —
334
375
  * none of the changes made during the callback are saved — and the error is re-thrown.
376
+ * If abandonment also throws, logging that secondary error is attempted without allowing a logging failure to replace the callback error.
335
377
  *
336
378
  * This is the recommended way to perform a scoped unit of work on an iModel. It ensures that
337
379
  * edits are committed atomically on success and rolled back on failure, without the caller needing
@@ -1 +1 @@
1
- {"version":3,"file":"EditTxn.d.ts","sourceRoot":"","sources":["../../src/EditTxn.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAQ,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAsC,MAAM,qBAAqB,CAAC;AAClI,OAAO,EAAgB,iBAAiB,EAAgB,kBAAkB,EAAgB,YAAY,EAAE,iBAAiB,EAAe,UAAU,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACnN,OAAO,EAAW,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,KAAK,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,QAAQ,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACxI,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAG9D;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,2BAA2B,CAAC,EAAE,OAAO,CAAC;CACv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;AACjH;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAC/F;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,eAAe,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC"}
@@ -5,10 +5,26 @@
5
5
  /** @packageDocumentation
6
6
  * @module iModels
7
7
  */
8
- import { DbResult, Id64, IModelStatus, ITwinError, OpenMode } from "@itwin/core-bentley";
8
+ import { DbResult, Id64, IModelStatus, ITwinError, Logger, OpenMode } from "@itwin/core-bentley";
9
9
  import { EcefLocation, EditTxnError, ElementError, IModelError } from "@itwin/core-common";
10
10
  import { Range3d } from "@itwin/core-geometry";
11
- import { _activeTxn, _cache, _instanceKeyCache, _nativeDb, _verifyChannel } from "./internal/Symbols";
11
+ import { BackendLoggerCategory } from "./BackendLoggerCategory";
12
+ import { _activeTxn, _cache, _instanceKeyCache, _nativeDb, _refreshGeographicCoordinateSystem, _updateIModelProps, _verifyChannel, _verifyTxnWrite } from "./internal/Symbols";
13
+ /**
14
+ * Why an element could not be deleted by [[EditTxn.deleteElements]].
15
+ * @beta
16
+ */
17
+ export var BulkDeleteFailureReason;
18
+ (function (BulkDeleteFailureReason) {
19
+ /** A row outside the delete set references it via a NO ACTION / RESTRICT / SET DEFAULT FK. */
20
+ BulkDeleteFailureReason[BulkDeleteFailureReason["ReferencedByForeignKey"] = 0] = "ReferencedByForeignKey";
21
+ /** It is a DefinitionElement still used by elements outside the delete set. */
22
+ BulkDeleteFailureReason[BulkDeleteFailureReason["DefinitionInUse"] = 1] = "DefinitionInUse";
23
+ /** It is one of the elements every iModel must keep: the root Subject, the DictionaryModel partition or the RealityDataSources partition. */
24
+ BulkDeleteFailureReason[BulkDeleteFailureReason["ProtectedElement"] = 2] = "ProtectedElement";
25
+ /** Its handler belongs to a read-only DgnDomain. */
26
+ BulkDeleteFailureReason[BulkDeleteFailureReason["ReadOnlyDomain"] = 3] = "ReadOnlyDomain";
27
+ })(BulkDeleteFailureReason || (BulkDeleteFailureReason = {}));
12
28
  /**
13
29
  * Status of a bulk element delete operation, mirroring the C++ `BulkDeleteStatus` enum.
14
30
  * @beta
@@ -17,9 +33,9 @@ export var BulkDeleteElementsStatus;
17
33
  (function (BulkDeleteElementsStatus) {
18
34
  /** All supplied elements were deleted successfully. */
19
35
  BulkDeleteElementsStatus[BulkDeleteElementsStatus["Success"] = 0] = "Success";
20
- /** Some elements were deleted but others could not be, typically due to foreign key constraints on the elements not being deleted. */
21
- BulkDeleteElementsStatus[BulkDeleteElementsStatus["PartialSuccess"] = 1] = "PartialSuccess";
22
- /** No elements were deleted. This occurs when the SQL DELETE statement itself fails, e.g. due to a FK constraint violation that prevents the entire batch from being processed. */
36
+ /** Nothing was deleted because some elements in the (expanded) delete set are still referenced from outside the set; see `failures` for the violators. */
37
+ BulkDeleteElementsStatus[BulkDeleteElementsStatus["ConstraintViolation"] = 1] = "ConstraintViolation";
38
+ /** An internal error occurred. The iModel may be partially modified; the caller must abandon the current txn. `failures` will be empty. */
23
39
  BulkDeleteElementsStatus[BulkDeleteElementsStatus["DeletionFailed"] = 2] = "DeletionFailed";
24
40
  })(BulkDeleteElementsStatus || (BulkDeleteElementsStatus = {}));
25
41
  /**
@@ -68,14 +84,17 @@ export class EditTxn {
68
84
  this.description = description;
69
85
  }
70
86
  verifyWriteable() {
87
+ this.iModel[_verifyTxnWrite]();
71
88
  // Explicit transactions must always be active before writing.
72
89
  if (!this.isActive)
73
90
  EditTxnError.throwError("not-active", "EditTxn is not active", this.iModel.key);
74
91
  }
75
92
  /** Start this EditTxn, making it the active transaction for the iModel.
76
93
  * @throws EditTxnError if this EditTxn is already active, another EditTxn is already active, or if unsaved changes are present.
94
+ * @throws IModelError if the geographic coordinate system is being restored.
77
95
  */
78
96
  start() {
97
+ this.iModel[_verifyTxnWrite]();
79
98
  if (this.isActive)
80
99
  EditTxnError.throwError("already-active", "This EditTxn is already active", this.iModel.key);
81
100
  const activeTxn = this.iModel[_activeTxn];
@@ -92,9 +111,11 @@ export class EditTxn {
92
111
  this.saveChanges(args);
93
112
  }
94
113
  else {
95
- this.abandonChanges();
114
+ this.abandonDatabaseChanges();
96
115
  }
97
116
  this.iModel[_activeTxn] = undefined;
117
+ if (mode === "abandon")
118
+ this.iModel[_refreshGeographicCoordinateSystem]();
98
119
  }
99
120
  /** Invoked when the owning iModel is closing.
100
121
  * The base implementation commits unsaved changes. Subclasses may override to customize how
@@ -110,6 +131,10 @@ export class EditTxn {
110
131
  * @throws EditTxnError if this EditTxn is not active.
111
132
  */
112
133
  abandonChanges() {
134
+ this.abandonDatabaseChanges();
135
+ this.iModel[_refreshGeographicCoordinateSystem]();
136
+ }
137
+ abandonDatabaseChanges() {
113
138
  this.verifyWriteable();
114
139
  this.iModel.clearCaches({ instanceCachesOnly: true });
115
140
  this.iModel[_nativeDb].abandonChanges();
@@ -347,14 +372,24 @@ export class EditTxn {
347
372
  return ids;
348
373
  }
349
374
  /**
350
- * Delete multiple elements from the iModel.
375
+ * Delete multiple elements from the iModel in a single bulk operation.
376
+ *
377
+ * Child elements and sub-model contents of the requested elements are deleted along with them.
378
+ *
379
+ * The operation is all-or-nothing:
380
+ * - On `Success`, all elements (and their children / sub-model contents) were deleted.
381
+ * - On `ConstraintViolation`, nothing was deleted and [[BulkDeleteElementsResult.failures]] lists every element in the
382
+ * expanded delete set that is still referenced from outside the set, and why. Fix or include those referencing elements and retry.
383
+ * - On `DeletionFailed` (an unexpected SQLite error) the iModel may be partially modified and the caller must abandon the current txn.
384
+ *
351
385
  * @param ids The ids of the elements to delete. All ids must be well-formed and valid [[Id64String]]s.
352
- * @param deleteOptions Options for the delete operation.
353
- * @returns A result object containing information about the deletion operation success and the element ids that failed to delete (if any).
386
+ * @param _deleteOptions Deprecated and ignored; kept for backward compatibility of the signature.
387
+ * @returns A result object describing the outcome of the operation and the elements that block it (if any).
354
388
  * @throws [[ITwinError]] if any of the supplied ids are not well-formed/valid [[Id64String]]s.
355
389
  * @beta
356
390
  */
357
- deleteElements(ids, deleteOptions) {
391
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
392
+ deleteElements(ids, _deleteOptions) {
358
393
  this.verifyWriteable();
359
394
  const invalidIds = new Set();
360
395
  for (const id of ids) {
@@ -363,17 +398,27 @@ export class EditTxn {
363
398
  }
364
399
  if (invalidIds.size > 0)
365
400
  ITwinError.throwError({ message: `Invalid element ids: ${Array.from(invalidIds).join(", ")}`, iTwinErrorId: { scope: "imodel", key: "invalid-arguments" } });
366
- const bulkDeletionResult = this.iModel[_nativeDb].deleteElements(ids, deleteOptions);
367
- const finalResult = { ...bulkDeletionResult, failedIds: Id64.toIdSet(bulkDeletionResult.failedIds) };
368
- if (finalResult.status === BulkDeleteElementsStatus.DeletionFailed)
369
- return finalResult;
370
- for (const id of ids) {
371
- if (!finalResult.failedIds.has(id)) {
372
- this.iModel.elements[_cache].delete({ id });
373
- this.iModel.elements[_instanceKeyCache].deleteById(id);
374
- }
375
- }
376
- return finalResult;
401
+ const nativeResult = this.iModel[_nativeDb].deleteElements(ids);
402
+ // When deletion fails with `DeletionFailed`, all requested ids are returned to maintain backward compatibilty.
403
+ // Once `failedIds` is deprecated, we will change this to throw instead as this is a SQLite failure.
404
+ const failedIds = nativeResult.status === BulkDeleteElementsStatus.DeletionFailed
405
+ ? new Set(ids)
406
+ : new Set(nativeResult.failures.map((failure) => failure.elementId));
407
+ const result = {
408
+ status: nativeResult.status,
409
+ sqlDeleteStatus: nativeResult.sqlDeleteStatus,
410
+ failures: nativeResult.failures,
411
+ // `failedIds` is deprecated. `failures` provides a more comprehensive error report.
412
+ // We still need to return the deprecated `failedIds` to maintain backward compatibility.
413
+ failedIds,
414
+ };
415
+ // Nothing was deleted on ConstraintViolation; on DeletionFailed the caller must abandon the txn, which restores the cached state.
416
+ if (result.status !== BulkDeleteElementsStatus.Success)
417
+ return result;
418
+ // Native deletion also nulls logical navigation properties on surviving elements that referenced the deleted ones,
419
+ // so evicting only the requested ids would leave stale cached referrers. Clear all instance caches.
420
+ this.iModel.clearCaches({ instanceCachesOnly: true });
421
+ return result;
377
422
  }
378
423
  /** Insert a new aspect into the iModel.
379
424
  * @param aspectProps The properties of the new aspect.
@@ -643,11 +688,12 @@ export class EditTxn {
643
688
  this.updateIModelProps();
644
689
  }
645
690
  /** Update the iModel props in the database from the current in-memory state.
691
+ * An unchanged geographic coordinate system is not replaced or re-resolved from its dictionary identifiers.
646
692
  * @throws EditTxnError if this EditTxn is not active.
647
693
  */
648
694
  updateIModelProps() {
649
695
  this.verifyWriteable();
650
- this.iModel[_nativeDb].updateIModelProps(this.iModel.toJSON());
696
+ this.iModel[_updateIModelProps]();
651
697
  }
652
698
  static _settingPropNamespace = "settings";
653
699
  static _viewStoreProperty = { namespace: "itwinjs", name: "DefaultViewStore" };
@@ -700,25 +746,34 @@ export function withEditTxn(iModel, saveArgsOrFn, maybeFn) {
700
746
  throw new Error("withEditTxn requires a callback");
701
747
  const txn = new EditTxn(iModel, "");
702
748
  txn.start();
749
+ const abandonOnError = (error) => {
750
+ try {
751
+ if (txn.isActive)
752
+ txn.end("abandon");
753
+ }
754
+ catch (abandonError) {
755
+ try {
756
+ Logger.logError(BackendLoggerCategory.IModelDb, abandonError);
757
+ }
758
+ catch {
759
+ throw error;
760
+ }
761
+ }
762
+ throw error;
763
+ };
703
764
  try {
704
765
  const result = fn(txn);
705
766
  if (result instanceof Promise) {
706
767
  return result.then((value) => {
707
768
  txn.end("save", saveArgs);
708
769
  return value;
709
- }, (err) => {
710
- if (txn.isActive)
711
- txn.end("abandon");
712
- throw err;
713
- });
770
+ }, abandonOnError);
714
771
  }
715
772
  txn.end("save", saveArgs);
716
773
  return result;
717
774
  }
718
775
  catch (err) {
719
- if (txn.isActive)
720
- txn.end("abandon");
721
- throw err;
776
+ return abandonOnError(err);
722
777
  }
723
778
  }
724
779
  //# sourceMappingURL=EditTxn.js.map