@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.
- package/CHANGELOG.md +46 -1
- package/lib/cjs/BlobContainerService.d.ts +2 -0
- package/lib/cjs/BlobContainerService.d.ts.map +1 -1
- package/lib/cjs/BlobContainerService.js.map +1 -1
- package/lib/cjs/BriefcaseManager.d.ts +2 -1
- package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
- package/lib/cjs/BriefcaseManager.js +39 -9
- package/lib/cjs/BriefcaseManager.js.map +1 -1
- package/lib/cjs/ChangeUnifier.d.ts +82 -0
- package/lib/cjs/ChangeUnifier.d.ts.map +1 -0
- package/lib/cjs/ChangeUnifier.js +163 -0
- package/lib/cjs/ChangeUnifier.js.map +1 -0
- package/lib/cjs/ChangesetReader.d.ts +21 -2
- package/lib/cjs/ChangesetReader.d.ts.map +1 -1
- package/lib/cjs/ChangesetReader.js +37 -1
- package/lib/cjs/ChangesetReader.js.map +1 -1
- package/lib/cjs/CloudSqlite.d.ts +15 -0
- package/lib/cjs/CloudSqlite.d.ts.map +1 -1
- package/lib/cjs/CloudSqlite.js.map +1 -1
- package/lib/cjs/ECDb.d.ts +1 -0
- package/lib/cjs/ECDb.d.ts.map +1 -1
- package/lib/cjs/ECDb.js +4 -1
- package/lib/cjs/ECDb.js.map +1 -1
- package/lib/cjs/EditTxn.d.ts +61 -19
- package/lib/cjs/EditTxn.d.ts.map +1 -1
- package/lib/cjs/EditTxn.js +84 -29
- package/lib/cjs/EditTxn.js.map +1 -1
- package/lib/cjs/GeoCoordConfig.d.ts +1 -0
- package/lib/cjs/GeoCoordConfig.d.ts.map +1 -1
- package/lib/cjs/GeoCoordConfig.js +12 -8
- package/lib/cjs/GeoCoordConfig.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +22 -9
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +54 -12
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/NativeHost.d.ts.map +1 -1
- package/lib/cjs/NativeHost.js +5 -1
- package/lib/cjs/NativeHost.js.map +1 -1
- package/lib/cjs/Relationship.d.ts +28 -0
- package/lib/cjs/Relationship.d.ts.map +1 -1
- package/lib/cjs/Relationship.js +78 -0
- package/lib/cjs/Relationship.js.map +1 -1
- package/lib/cjs/SchemaSync.d.ts.map +1 -1
- package/lib/cjs/SchemaSync.js +1 -0
- package/lib/cjs/SchemaSync.js.map +1 -1
- package/lib/cjs/TxnManager.d.ts +126 -89
- package/lib/cjs/TxnManager.d.ts.map +1 -1
- package/lib/cjs/TxnManager.js +114 -76
- package/lib/cjs/TxnManager.js.map +1 -1
- package/lib/cjs/ViewStateHydrator.d.ts.map +1 -1
- package/lib/cjs/ViewStateHydrator.js.map +1 -1
- package/lib/cjs/ViewStore.d.ts.map +1 -1
- package/lib/cjs/ViewStore.js +62 -19
- package/lib/cjs/ViewStore.js.map +1 -1
- package/lib/cjs/annotations/LeaderGeometry.d.ts.map +1 -1
- package/lib/cjs/annotations/LeaderGeometry.js +3 -0
- package/lib/cjs/annotations/LeaderGeometry.js.map +1 -1
- package/lib/cjs/core-backend.d.ts +1 -0
- package/lib/cjs/core-backend.d.ts.map +1 -1
- package/lib/cjs/core-backend.js +1 -0
- package/lib/cjs/core-backend.js.map +1 -1
- package/lib/cjs/internal/BriefcaseUtils.d.ts +19 -0
- package/lib/cjs/internal/BriefcaseUtils.d.ts.map +1 -0
- package/lib/cjs/internal/BriefcaseUtils.js +65 -0
- package/lib/cjs/internal/BriefcaseUtils.js.map +1 -0
- package/lib/cjs/internal/QueryMetadataCache.d.ts +44 -0
- package/lib/cjs/internal/QueryMetadataCache.d.ts.map +1 -0
- package/lib/cjs/internal/QueryMetadataCache.js +107 -0
- package/lib/cjs/internal/QueryMetadataCache.js.map +1 -0
- package/lib/cjs/internal/Symbols.d.ts +9 -0
- package/lib/cjs/internal/Symbols.d.ts.map +1 -1
- package/lib/cjs/internal/Symbols.js +10 -1
- package/lib/cjs/internal/Symbols.js.map +1 -1
- package/lib/cjs/internal/workspace/WorkspaceImpl.d.ts.map +1 -1
- package/lib/cjs/internal/workspace/WorkspaceImpl.js +20 -6
- package/lib/cjs/internal/workspace/WorkspaceImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +6 -6
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/lib/cjs/workspace/SettingsEditor.d.ts +4 -3
- package/lib/cjs/workspace/SettingsEditor.d.ts.map +1 -1
- package/lib/cjs/workspace/SettingsEditor.js +7 -5
- package/lib/cjs/workspace/SettingsEditor.js.map +1 -1
- package/lib/esm/BlobContainerService.d.ts +2 -0
- package/lib/esm/BlobContainerService.d.ts.map +1 -1
- package/lib/esm/BlobContainerService.js.map +1 -1
- package/lib/esm/BriefcaseManager.d.ts +2 -1
- package/lib/esm/BriefcaseManager.d.ts.map +1 -1
- package/lib/esm/BriefcaseManager.js +40 -10
- package/lib/esm/BriefcaseManager.js.map +1 -1
- package/lib/esm/ChangeUnifier.d.ts +82 -0
- package/lib/esm/ChangeUnifier.d.ts.map +1 -0
- package/lib/esm/ChangeUnifier.js +159 -0
- package/lib/esm/ChangeUnifier.js.map +1 -0
- package/lib/esm/ChangesetReader.d.ts +21 -2
- package/lib/esm/ChangesetReader.d.ts.map +1 -1
- package/lib/esm/ChangesetReader.js +38 -2
- package/lib/esm/ChangesetReader.js.map +1 -1
- package/lib/esm/CloudSqlite.d.ts +15 -0
- package/lib/esm/CloudSqlite.d.ts.map +1 -1
- package/lib/esm/CloudSqlite.js.map +1 -1
- package/lib/esm/ECDb.d.ts +1 -0
- package/lib/esm/ECDb.d.ts.map +1 -1
- package/lib/esm/ECDb.js +4 -1
- package/lib/esm/ECDb.js.map +1 -1
- package/lib/esm/EditTxn.d.ts +61 -19
- package/lib/esm/EditTxn.d.ts.map +1 -1
- package/lib/esm/EditTxn.js +85 -30
- package/lib/esm/EditTxn.js.map +1 -1
- package/lib/esm/GeoCoordConfig.d.ts +1 -0
- package/lib/esm/GeoCoordConfig.d.ts.map +1 -1
- package/lib/esm/GeoCoordConfig.js +12 -8
- package/lib/esm/GeoCoordConfig.js.map +1 -1
- package/lib/esm/IModelDb.d.ts +22 -9
- package/lib/esm/IModelDb.d.ts.map +1 -1
- package/lib/esm/IModelDb.js +56 -14
- package/lib/esm/IModelDb.js.map +1 -1
- package/lib/esm/NativeHost.d.ts.map +1 -1
- package/lib/esm/NativeHost.js +5 -1
- package/lib/esm/NativeHost.js.map +1 -1
- package/lib/esm/Relationship.d.ts +28 -0
- package/lib/esm/Relationship.d.ts.map +1 -1
- package/lib/esm/Relationship.js +78 -0
- package/lib/esm/Relationship.js.map +1 -1
- package/lib/esm/SchemaSync.d.ts.map +1 -1
- package/lib/esm/SchemaSync.js +1 -0
- package/lib/esm/SchemaSync.js.map +1 -1
- package/lib/esm/TxnManager.d.ts +126 -89
- package/lib/esm/TxnManager.d.ts.map +1 -1
- package/lib/esm/TxnManager.js +116 -78
- package/lib/esm/TxnManager.js.map +1 -1
- package/lib/esm/ViewStateHydrator.d.ts.map +1 -1
- package/lib/esm/ViewStateHydrator.js.map +1 -1
- package/lib/esm/ViewStore.d.ts.map +1 -1
- package/lib/esm/ViewStore.js +62 -19
- package/lib/esm/ViewStore.js.map +1 -1
- package/lib/esm/annotations/LeaderGeometry.d.ts.map +1 -1
- package/lib/esm/annotations/LeaderGeometry.js +3 -0
- package/lib/esm/annotations/LeaderGeometry.js.map +1 -1
- package/lib/esm/core-backend.d.ts +1 -0
- package/lib/esm/core-backend.d.ts.map +1 -1
- package/lib/esm/core-backend.js +1 -0
- package/lib/esm/core-backend.js.map +1 -1
- package/lib/esm/internal/BriefcaseUtils.d.ts +19 -0
- package/lib/esm/internal/BriefcaseUtils.d.ts.map +1 -0
- package/lib/esm/internal/BriefcaseUtils.js +61 -0
- package/lib/esm/internal/BriefcaseUtils.js.map +1 -0
- package/lib/esm/internal/QueryMetadataCache.d.ts +44 -0
- package/lib/esm/internal/QueryMetadataCache.d.ts.map +1 -0
- package/lib/esm/internal/QueryMetadataCache.js +103 -0
- package/lib/esm/internal/QueryMetadataCache.js.map +1 -0
- package/lib/esm/internal/Symbols.d.ts +9 -0
- package/lib/esm/internal/Symbols.d.ts.map +1 -1
- package/lib/esm/internal/Symbols.js +9 -0
- package/lib/esm/internal/Symbols.js.map +1 -1
- package/lib/esm/internal/workspace/WorkspaceImpl.d.ts.map +1 -1
- package/lib/esm/internal/workspace/WorkspaceImpl.js +20 -6
- package/lib/esm/internal/workspace/WorkspaceImpl.js.map +1 -1
- package/lib/esm/rpc-impl/IModelReadRpcImpl.d.ts +6 -6
- package/lib/esm/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -1
- package/lib/esm/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/lib/esm/test/annotations/LeaderGeometry.test.js +15 -1
- package/lib/esm/test/annotations/LeaderGeometry.test.js.map +1 -1
- package/lib/esm/test/ecdb/ConcurrentQuery.test.js +144 -30
- package/lib/esm/test/ecdb/ConcurrentQuery.test.js.map +1 -1
- package/lib/esm/test/ecdb/QueryMetadataCache.test.d.ts +2 -0
- package/lib/esm/test/ecdb/QueryMetadataCache.test.d.ts.map +1 -0
- package/lib/esm/test/ecdb/QueryMetadataCache.test.js +630 -0
- package/lib/esm/test/ecdb/QueryMetadataCache.test.js.map +1 -0
- package/lib/esm/test/element/DeleteDefinitionElements.test.js +403 -249
- package/lib/esm/test/element/DeleteDefinitionElements.test.js.map +1 -1
- package/lib/esm/test/element/RelationshipBatchLookup.test.d.ts +2 -0
- package/lib/esm/test/element/RelationshipBatchLookup.test.d.ts.map +1 -0
- package/lib/esm/test/element/RelationshipBatchLookup.test.js +202 -0
- package/lib/esm/test/element/RelationshipBatchLookup.test.js.map +1 -0
- package/lib/esm/test/hubaccess/BriefcaseManager.test.js +187 -1
- package/lib/esm/test/hubaccess/BriefcaseManager.test.js.map +1 -1
- package/lib/esm/test/hubaccess/SchemaImportOrphanColumns.test.d.ts +2 -0
- package/lib/esm/test/hubaccess/SchemaImportOrphanColumns.test.d.ts.map +1 -0
- package/lib/esm/test/hubaccess/SchemaImportOrphanColumns.test.js +142 -0
- package/lib/esm/test/hubaccess/SchemaImportOrphanColumns.test.js.map +1 -0
- package/lib/esm/test/imodel/IModelGeolocation.test.js +8 -6
- package/lib/esm/test/imodel/IModelGeolocation.test.js.map +1 -1
- package/lib/esm/test/imodel/IModelProps.test.d.ts +2 -0
- package/lib/esm/test/imodel/IModelProps.test.d.ts.map +1 -0
- package/lib/esm/test/imodel/IModelProps.test.js +411 -0
- package/lib/esm/test/imodel/IModelProps.test.js.map +1 -0
- package/lib/esm/test/schema/SchemaViewPropertyOverrides.test.d.ts +2 -0
- package/lib/esm/test/schema/SchemaViewPropertyOverrides.test.d.ts.map +1 -0
- package/lib/esm/test/schema/SchemaViewPropertyOverrides.test.js +240 -0
- package/lib/esm/test/schema/SchemaViewPropertyOverrides.test.js.map +1 -0
- package/lib/esm/test/schema/SchemaViewValidation.test.js +2 -8
- package/lib/esm/test/schema/SchemaViewValidation.test.js.map +1 -1
- package/lib/esm/test/standalone/BriefcaseManagerDelete.test.d.ts +2 -0
- package/lib/esm/test/standalone/BriefcaseManagerDelete.test.d.ts.map +1 -0
- package/lib/esm/test/standalone/BriefcaseManagerDelete.test.js +159 -0
- package/lib/esm/test/standalone/BriefcaseManagerDelete.test.js.map +1 -0
- package/lib/esm/test/standalone/ChangeUnifier.test.d.ts +2 -0
- package/lib/esm/test/standalone/ChangeUnifier.test.d.ts.map +1 -0
- package/lib/esm/test/standalone/ChangeUnifier.test.js +732 -0
- package/lib/esm/test/standalone/ChangeUnifier.test.js.map +1 -0
- package/lib/esm/test/standalone/DeleteElements.test.js +962 -83
- package/lib/esm/test/standalone/DeleteElements.test.js.map +1 -1
- package/lib/esm/test/standalone/EditTxn.test.js +72 -1
- package/lib/esm/test/standalone/EditTxn.test.js.map +1 -1
- package/lib/esm/test/standalone/GeoCoordConfig.test.d.ts +2 -0
- package/lib/esm/test/standalone/GeoCoordConfig.test.d.ts.map +1 -0
- package/lib/esm/test/standalone/GeoCoordConfig.test.js +158 -0
- package/lib/esm/test/standalone/GeoCoordConfig.test.js.map +1 -0
- package/lib/esm/test/standalone/ViewStoreDb.test.js +53 -0
- package/lib/esm/test/standalone/ViewStoreDb.test.js.map +1 -1
- package/lib/esm/test/workspace/SettingsContainers.test.d.ts +2 -0
- package/lib/esm/test/workspace/SettingsContainers.test.d.ts.map +1 -0
- package/lib/esm/test/workspace/SettingsContainers.test.js +95 -0
- package/lib/esm/test/workspace/SettingsContainers.test.js.map +1 -0
- package/lib/esm/workspace/SettingsEditor.d.ts +4 -3
- package/lib/esm/workspace/SettingsEditor.d.ts.map +1 -1
- package/lib/esm/workspace/SettingsEditor.js +7 -5
- package/lib/esm/workspace/SettingsEditor.js.map +1 -1
- package/package.json +18 -18
package/lib/esm/EditTxn.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditTxn.js","sourceRoot":"","sources":["../../src/EditTxn.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,IAAI,EAA2C,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAClI,OAAO,EAAE,YAAY,EAAqB,YAAY,EAAsB,YAAY,EAAmC,WAAW,EAAkD,MAAM,oBAAoB,CAAC;AACnN,OAAO,EAAE,OAAO,EAAgB,MAAM,sBAAsB,CAAC;AAK7D,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,iBAAiB,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAqCtG;;;GAGG;AACH,MAAM,CAAN,IAAY,wBAOX;AAPD,WAAY,wBAAwB;IAClC,uDAAuD;IACv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IAC/C,CAAC;;AA2CH,MAAM,UAAU,WAAW,CAAI,MAAgB,EAAE,YAA2E,EAAE,OAA0C;IACtK,MAAM,QAAQ,GAAG,UAAU,KAAK,OAAO,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC;IAC/E,MAAM,EAAE,GAAG,UAAU,KAAK,OAAO,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC;IAEvE,IAAI,SAAS,KAAK,EAAE;QAClB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IAErD,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACpC,GAAG,CAAC,KAAK,EAAE,CAAC;IAEZ,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;QACvB,IAAI,MAAM,YAAY,OAAO,EAAE,CAAC;YAC9B,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;gBAC3B,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;gBAC1B,OAAO,KAAK,CAAC;YACf,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE;gBACT,IAAI,GAAG,CAAC,QAAQ;oBACd,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;gBAErB,MAAM,GAAG,CAAC;YACZ,CAAC,CAAC,CAAC;QACL,CAAC;QAED,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAC1B,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,CAAC,QAAQ;YACd,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAErB,MAAM,GAAG,CAAC;IACZ,CAAC;AACH,CAAC","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 iModels\r\n */\r\n\r\nimport { DbResult, Id64, Id64Arg, Id64Array, Id64Set, Id64String, IModelStatus, ITwinError, OpenMode } from \"@itwin/core-bentley\";\r\nimport { EcefLocation, EcefLocationProps, EditTxnError, ElementAspectProps, ElementError, ElementProps, FilePropertyProps, IModelError, ModelProps, RelationshipProps, SaveChangesArgs } from \"@itwin/core-common\";\r\nimport { Range3d, Range3dProps } from \"@itwin/core-geometry\";\r\nimport type { CloudSqlite } from \"./CloudSqlite\";\r\nimport type { ImplicitWriteEnforcement } from \"./IModelHost\";\r\nimport type { ChangeElementModelProps, ChangeElementParentProps, IModelDb, InsertElementOptions, UpdateModelOptions } from \"./IModelDb\";\r\nimport type { SettingsContainer } from \"./workspace/Settings\";\r\nimport { _activeTxn, _cache, _instanceKeyCache, _nativeDb, _verifyChannel } from \"./internal/Symbols\";\r\n\r\n/** Options for bulk deleting elements from an iModelDb.\r\n * @beta\r\n */\r\nexport interface BulkDeleteElementsArgs {\r\n /**\r\n * Skips pre-deletion **NO ACTION** foreign key constraint validation checks, which may improve performance for large deletions.\r\n * 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.\r\n */\r\n skipFKConstraintValidations?: boolean;\r\n}\r\n\r\n/**\r\n * Result of a bulk element delete operation.\r\n * @beta\r\n */\r\nexport interface BulkDeleteElementsResult {\r\n /**\r\n * Overall status of the bulk delete operation.\r\n * - `Success`: All elements were deleted successfully. `failedIds` will be empty.\r\n * - `PartialSuccess`: Some elements were deleted, but others failed. `failedIds` contains the ids that could not be deleted.\r\n * - `DeletionFailed`: The delete operation failed entirely (e.g. due to an FK constraint violation). `failedIds` contains the ids that could not be deleted.\r\n */\r\n status: BulkDeleteElementsStatus;\r\n /**\r\n * The raw SQLite result code from the underlying SQL DELETE statement.\r\n * `DbResult.BE_SQLITE_OK` on success; a non-OK code indicates a database-level error such as a constraint violation.\r\n */\r\n sqlDeleteStatus: DbResult;\r\n /**\r\n * The set of element ids that could not be deleted.\r\n * Empty when `status` is `Success`. Non-empty when `status` is `PartialSuccess` or `DeletionFailed`.\r\n */\r\n failedIds: Id64Set;\r\n}\r\n\r\n/**\r\n * Status of a bulk element delete operation, mirroring the C++ `BulkDeleteStatus` enum.\r\n * @beta\r\n */\r\nexport enum BulkDeleteElementsStatus {\r\n /** All supplied elements were deleted successfully. */\r\n Success = 0,\r\n /** Some elements were deleted but others could not be, typically due to foreign key constraints on the elements not being deleted. */\r\n PartialSuccess = 1,\r\n /** 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. */\r\n DeletionFailed = 2,\r\n}\r\n\r\n/**\r\n * Represents an explicit editing transaction for an iModel.\r\n *\r\n * An explicit EditTxn lets callers define a deliberate unit of work by choosing when editing\r\n * starts (`start`) and how it ends (`end()` / `end(\"save\")` or `end(\"abandon\")`). This avoids mixing\r\n * unrelated edits into one implicit unit of work and makes save/rollback boundaries explicit.\r\n *\r\n * Explicit EditTxn instances must be active before mutating operations are performed, regardless of enforcement level.\r\n * In other words, explicit transaction behavior is independent of `implicitWriteEnforcement`.\r\n *\r\n * @see [EditTxn transaction model and migration guidance]($docs/learning/backend/EditTxn.md)\r\n *\r\n * *During indirect changes (commit processing):* Use callback args (`indirectEditTxn`) in callbacks like\r\n * [[Relationship.onRootChangedArg]] and [[Relationship.onDeletedDependencyArg]] that fire during indirect processing.\r\n *\r\n * @beta\r\n */\r\nexport class EditTxn {\r\n /** Controls how writes through the implicit transaction are handled.\r\n *\r\n * This does not relax activation requirements for explicit transactions: explicit EditTxn writes\r\n * must always come from the active EditTxn.\r\n *\r\n * - `allow`: allow implicit writes for backwards compatibility, even while an explicit EditTxn is active.\r\n * - `log`: allow implicit writes but log `implicit-txn-write-disallowed` errors.\r\n * - `throw`: reject implicit writes with `implicit-txn-write-disallowed`.\r\n *\r\n * This is initialized from [[IModelHostOptions.implicitWriteEnforcement]] during [[IModelHost.startup]].\r\n *\r\n * Defaults to `allow` for backwards compatibility.\r\n * @beta\r\n */\r\n public static implicitWriteEnforcement: ImplicitWriteEnforcement = \"allow\";\r\n\r\n /** The iModel this EditTxn may modify. */\r\n public readonly iModel: IModelDb;\r\n\r\n /** Default description passed to [[saveChanges]] when saving this transaction. */\r\n public description: string;\r\n\r\n /** True if this transaction currently owns the iModel write surface. */\r\n public get isActive(): boolean {\r\n return this.iModel[_activeTxn] === this;\r\n }\r\n\r\n public constructor(iModel: IModelDb, description: string) {\r\n this.iModel = iModel;\r\n this.description = description;\r\n }\r\n\r\n public verifyWriteable(): void {\r\n // Explicit transactions must always be active before writing.\r\n if (!this.isActive)\r\n EditTxnError.throwError(\"not-active\", \"EditTxn is not active\", this.iModel.key);\r\n }\r\n\r\n /** Start this EditTxn, making it the active transaction for the iModel.\r\n * @throws EditTxnError if this EditTxn is already active, another EditTxn is already active, or if unsaved changes are present.\r\n */\r\n public start(): void {\r\n if (this.isActive)\r\n EditTxnError.throwError(\"already-active\", \"This EditTxn is already active\", this.iModel.key);\r\n\r\n const activeTxn = this.iModel[_activeTxn];\r\n if (undefined !== activeTxn)\r\n EditTxnError.throwError(\"already-active\", \"Cannot start EditTxn while another EditTxn is active\", this.iModel.key, activeTxn.description);\r\n\r\n if (this.iModel[_nativeDb].hasUnsavedChanges())\r\n EditTxnError.throwError(\"unsaved-changes\", \"Cannot start a new EditTxn with unsaved changes\", this.iModel.key);\r\n\r\n this.iModel[_activeTxn] = this;\r\n }\r\n\r\n /** End this EditTxn, either by saving or abandoning the changes.\r\n * @param mode Whether to \"save\" or \"abandon\" the changes. Defaults to \"save\".\r\n * @param args Save changes arguments when saving.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @throws IModelError if saving changes fails.\r\n */\r\n public end(): void;\r\n public end(mode: \"save\" | \"abandon\", args?: string | SaveChangesArgs): void;\r\n public end(mode: \"save\" | \"abandon\" = \"save\", args?: string | SaveChangesArgs): void {\r\n if (!this.isActive)\r\n EditTxnError.throwError(\"not-active\", \"EditTxn is not active\", this.iModel.key);\r\n\r\n if (mode === \"save\") {\r\n this.saveChanges(args);\r\n } else {\r\n this.abandonChanges();\r\n }\r\n this.iModel[_activeTxn] = undefined;\r\n }\r\n\r\n /** Invoked when the owning iModel is closing.\r\n * The base implementation commits unsaved changes. Subclasses may override to customize how\r\n * their changes are handled before the iModel closes.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @throws IModelError if saving on close fails.\r\n */\r\n public onClose(): void {\r\n if (!this.iModel.isReadonly && this.iModel[_nativeDb].hasUnsavedChanges())\r\n this.saveChanges();\r\n }\r\n\r\n /** Abandon database changes while keeping this EditTxn active.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n */\r\n public abandonChanges(): void {\r\n this.verifyWriteable();\r\n this.iModel.clearCaches({ instanceCachesOnly: true });\r\n this.iModel[_nativeDb].abandonChanges();\r\n }\r\n\r\n /** Save changes with additional arguments.\r\n * @param args Save changes arguments.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @throws IModelError if the iModel is readonly, if indirect changes are active, or if the native save fails.\r\n */\r\n public saveChanges(args?: string | SaveChangesArgs): void {\r\n this.verifyWriteable();\r\n const iModel = this.iModel;\r\n if (iModel.openMode === OpenMode.Readonly)\r\n throw new IModelError(IModelStatus.ReadOnly, \"IModelDb was opened read-only\");\r\n\r\n if (iModel.isBriefcaseDb() && iModel.txns.isIndirectChanges)\r\n throw new IModelError(IModelStatus.BadRequest, \"Cannot save changes while in an indirect change scope\");\r\n\r\n args ??= this.description;\r\n const saveArgs = typeof args === \"string\" ? { description: args } : args;\r\n const stat = iModel[_nativeDb].saveChanges(JSON.stringify(saveArgs));\r\n if (DbResult.BE_SQLITE_ERROR_PropagateChangesFailed === stat)\r\n throw new IModelError(stat, \"Could not save changes due to propagation failure.\");\r\n\r\n if (DbResult.BE_SQLITE_OK !== stat)\r\n throw new IModelError(stat, `Could not save changes (${saveArgs.description})`);\r\n }\r\n\r\n /** Insert a new element into the iModel.\r\n * @param elProps The properties of the new element.\r\n * @returns The newly inserted element's Id.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @throws [[ITwinError]] if insertion fails.\r\n */\r\n public insertElement(elProps: ElementProps, options?: InsertElementOptions): Id64String {\r\n this.verifyWriteable();\r\n try {\r\n options ??= {};\r\n this.iModel.elements[_cache].delete({\r\n id: elProps.id,\r\n federationGuid: elProps.federationGuid,\r\n code: elProps.code,\r\n });\r\n return elProps.id = this.iModel[_nativeDb].insertElement(elProps, options);\r\n } catch (err: any) {\r\n err.message = `Error inserting element [${err.message}]`;\r\n err.metadata = { elProps };\r\n throw err;\r\n }\r\n }\r\n\r\n /** Update an existing element in the iModel.\r\n * @param elProps The properties to update.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @throws [[ITwinError]] if update fails.\r\n */\r\n public updateElement<T extends ElementProps>(elProps: Partial<T>): void {\r\n this.verifyWriteable();\r\n try {\r\n if (elProps.id) {\r\n this.iModel.elements[_instanceKeyCache].deleteById(elProps.id);\r\n } else {\r\n this.iModel.elements[_instanceKeyCache].delete({\r\n federationGuid: elProps.federationGuid,\r\n code: elProps.code,\r\n });\r\n }\r\n this.iModel.elements[_cache].delete({\r\n id: elProps.id,\r\n federationGuid: elProps.federationGuid,\r\n code: elProps.code,\r\n });\r\n this.iModel[_nativeDb].updateElement(elProps);\r\n } catch (err: any) {\r\n err.message = `Error updating element [${err.message}], id: ${elProps.id}`;\r\n err.metadata = { elProps };\r\n throw err;\r\n }\r\n }\r\n\r\n /** Delete elements from the iModel.\r\n * @param ids The Ids of the elements to delete.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @throws [[ITwinError]] if deletion fails.\r\n */\r\n public deleteElement(ids: Id64Arg): void {\r\n this.verifyWriteable();\r\n const iModel = this.iModel;\r\n Id64.toIdSet(ids).forEach((id) => {\r\n try {\r\n this.iModel.elements[_cache].delete({ id });\r\n this.iModel.elements[_instanceKeyCache].deleteById(id);\r\n iModel[_nativeDb].deleteElement(id);\r\n } catch (err: any) {\r\n err.message = `Error deleting element [${err.message}], id: ${id}`;\r\n err.metadata = { elementId: id };\r\n throw err;\r\n }\r\n });\r\n }\r\n\r\n /** Change the parent of an element within its model.\r\n *\r\n * The new parent must be in the same model as the element. Cross-model reparenting is not allowed;\r\n * use [[changeElementModel]] only to move root elements between models.\r\n * Only the target element is reparented — its children and their model membership are unaffected.\r\n *\r\n * **Blocked cases** (will throw):\r\n * - The new parent is in a different model than the element.\r\n * - Element has a `ParentElement`-scoped code (code uniqueness is tied to the parent; use delete+insert instead).\r\n *\r\n * **Allowed cases**:\r\n * - Element has a `Repository`-scoped code (unique across entire iModel — unaffected by the parent change).\r\n * - Element has a `RelatedElement`-scoped code (scope element is independent of the parent).\r\n * - Element has a `Model`-scoped code (the model does not change, so the code remains valid).\r\n * - Element has no meaningful code (empty code).\r\n *\r\n * Channel verification is performed on the element's model.\r\n * Lock enforcement: requires an exclusive lock on the element, and a shared lock on the new parent.\r\n * @param props The reparent parameters: element id and new parent id.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @throws [[ITwinError]] if the operation fails.\r\n * @beta\r\n */\r\n public changeElementParent(props: ChangeElementParentProps): void {\r\n this.verifyWriteable();\r\n const iModel = this.iModel;\r\n\r\n // Lock enforcement: exclusive lock on the element being reparented, shared lock on the new parent.\r\n iModel.locks.checkExclusiveLock(props.id, \"element\", \"changeParent\");\r\n iModel.locks.checkSharedLock(props.parentId, \"parent\", \"changeParent\");\r\n\r\n // The new parent must be in the same model as the element. Cross-model reparenting is not\r\n // allowed here; changeElementModel only moves root elements between models. Check this up\r\n // front so consumers get a clear error instead of the addon's lower-level \"wrong model\" status.\r\n const sourceModelId = iModel.elements.getElementProps({ id: props.id }).model;\r\n const parentModelId = iModel.elements.getElementProps({ id: props.parentId }).model;\r\n if (sourceModelId !== parentModelId)\r\n ElementError.throwError(\"invalid-arguments\", `cannot reparent element '${props.id}' to a parent in a different model ('${parentModelId}' != '${sourceModelId}'); changeElementModel only moves root elements between models`);\r\n\r\n // Channel verification on the element's model.\r\n iModel.channels[_verifyChannel](sourceModelId);\r\n\r\n // Invalidate caches for the element being reparented.\r\n iModel.elements[_cache].delete({ id: props.id });\r\n iModel.elements[_instanceKeyCache].deleteById(props.id);\r\n\r\n try {\r\n iModel[_nativeDb].changeElementParent({ id: props.id, parentId: props.parentId });\r\n } catch (err: any) {\r\n err.message = `Error changing element parent [${err.message}], id: ${props.id}, parentId: ${props.parentId}`;\r\n err.metadata = { props };\r\n throw err;\r\n }\r\n\r\n // The model is unchanged and descendants are not moved, so only the reparented element's cache is stale.\r\n iModel.elements[_cache].delete({ id: props.id });\r\n iModel.elements[_instanceKeyCache].deleteById(props.id);\r\n }\r\n\r\n /** Change the model of a root element, making it a root element in the new model.\r\n *\r\n * The element must not have a parent.\r\n * The element's entire subtree moves with it: BIS requires a parent and all of its children to reside\r\n * in the same model, so every descendant of the element is relocated into the target model as well.\r\n * The parent-child hierarchy is preserved. The whole subtree is validated before anything is moved, so\r\n * a rejected change leaves the iModel untouched.\r\n *\r\n * **Blocked cases** (will throw):\r\n * - Element has a parent (only root elements can be moved between models).\r\n * - Any element in the subtree has a `Model`-scoped code (code uniqueness is tied to the source model; use delete+insert instead).\r\n * - The moved (root) element has a `ParentElement`-scoped code (use delete+insert instead). A descendant's `ParentElement`-scoped code is allowed, because its parent moves with it.\r\n *\r\n * **Allowed cases** (for any element in the subtree):\r\n * - A `Repository`-scoped code (unique across entire iModel — unaffected by the model change).\r\n * - A `RelatedElement`-scoped code (scope element is independent of the model).\r\n * - No meaningful code (empty code).\r\n *\r\n * The source and target models must be of the same class (classFullName must match exactly).\r\n * Channel verification is performed on both the source and target models.\r\n * Lock enforcement: requires an exclusive lock on every element in the moved subtree, and a shared lock on the target model.\r\n * @param props The model change parameters: element id and target model id.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @throws [[ITwinError]] if the operation fails.\r\n * @beta\r\n */\r\n public changeElementModel(props: ChangeElementModelProps): void {\r\n this.verifyWriteable();\r\n const iModel = this.iModel;\r\n\r\n // Resolve the source model\r\n const sourceModelId = iModel.elements.getElementProps({ id: props.id }).model;\r\n\r\n // Channel verification on the source model\r\n iModel.channels[_verifyChannel](sourceModelId);\r\n\r\n // Model type check: source and target models must be the same class\r\n const sourceModel = iModel.models.getModel(sourceModelId);\r\n const targetModel = iModel.models.getModel(props.modelId);\r\n if (sourceModel.classFullName !== targetModel.classFullName)\r\n ElementError.throwError(\"model-type-mismatch\", `cannot move element from model of type '${sourceModel.classFullName}' to model of type '${targetModel.classFullName}'`);\r\n\r\n // Shared lock on target model\r\n iModel.locks.checkSharedLock(props.modelId, \"model\", \"changeModel\");\r\n\r\n // Lock enforcement: every element in the subtree is updated by the native bulk move.\r\n const subtreeIds = this.collectSubtreeIds(props.id);\r\n for (const id of subtreeIds)\r\n iModel.locks.checkExclusiveLock(id, \"element\", \"changeModel\");\r\n\r\n // Channel verification on the target model\r\n iModel.channels[_verifyChannel](props.modelId);\r\n\r\n // Invalidate caches\r\n iModel.elements[_cache].delete({ id: props.id });\r\n iModel.elements[_instanceKeyCache].deleteById(props.id);\r\n\r\n try {\r\n iModel[_nativeDb].changeElementModel({ id: props.id, modelId: props.modelId });\r\n } catch (err: any) {\r\n err.message = `Error changing element model [${err.message}], id: ${props.id}, modelId: ${props.modelId}`;\r\n err.metadata = { props };\r\n throw err;\r\n }\r\n\r\n // The move relocates the element's entire subtree into the target model (BIS requires a parent and\r\n // its children to reside in the same model). Every descendant's cached props therefore hold a stale\r\n // `model`, so invalidate the whole subtree rather than just the target element.\r\n for (const id of subtreeIds) {\r\n iModel.elements[_cache].delete({ id });\r\n iModel.elements[_instanceKeyCache].deleteById(id);\r\n }\r\n\r\n // Moving the subtree changes the membership - and therefore the geometry-derived state such as\r\n // GeometricModel.geometryGuid - of both the source and target models. Element insert/update/delete\r\n // invalidate models[_cache] via Element.onInserted/onUpdated/onDeleted for the same reason, but the\r\n // native changeElementModel does not fire those element callbacks, so invalidate both affected models\r\n // here to keep the model cache contract local to this wrapper.\r\n iModel.models[_cache].delete(sourceModelId);\r\n iModel.models[_cache].delete(props.modelId);\r\n }\r\n\r\n /** Collect an element together with all of its descendants by walking the `ElementOwnsChildElements`\r\n * hierarchy depth-first. Used to invalidate the cached props of every element affected by a subtree move.\r\n */\r\n private collectSubtreeIds(rootId: Id64String): Id64String[] {\r\n const ids: Id64String[] = [];\r\n const stack: Id64String[] = [rootId];\r\n for (let id = stack.pop(); undefined !== id; id = stack.pop()) {\r\n ids.push(id);\r\n for (const childId of this.iModel.elements.queryChildren(id))\r\n stack.push(childId);\r\n }\r\n return ids;\r\n }\r\n\r\n /**\r\n * Delete multiple elements from the iModel.\r\n * @param ids The ids of the elements to delete. All ids must be well-formed and valid [[Id64String]]s.\r\n * @param deleteOptions Options for the delete operation.\r\n * @returns A result object containing information about the deletion operation success and the element ids that failed to delete (if any).\r\n * @throws [[ITwinError]] if any of the supplied ids are not well-formed/valid [[Id64String]]s.\r\n * @beta\r\n */\r\n public deleteElements(ids: Id64Array, deleteOptions?: BulkDeleteElementsArgs): BulkDeleteElementsResult {\r\n this.verifyWriteable();\r\n const invalidIds: Id64Set = new Set<Id64String>();\r\n for (const id of ids) {\r\n if (!Id64.isValidId64(id))\r\n invalidIds.add(id);\r\n }\r\n\r\n if (invalidIds.size > 0)\r\n ITwinError.throwError({ message: `Invalid element ids: ${Array.from(invalidIds).join(\", \")}`, iTwinErrorId: { scope: \"imodel\", key: \"invalid-arguments\" } });\r\n\r\n const bulkDeletionResult = this.iModel[_nativeDb].deleteElements(ids, deleteOptions);\r\n const finalResult = { ...bulkDeletionResult, failedIds: Id64.toIdSet(bulkDeletionResult.failedIds) };\r\n\r\n if (finalResult.status === BulkDeleteElementsStatus.DeletionFailed)\r\n return finalResult;\r\n\r\n for (const id of ids) {\r\n if (!finalResult.failedIds.has(id)) {\r\n this.iModel.elements[_cache].delete({ id });\r\n this.iModel.elements[_instanceKeyCache].deleteById(id);\r\n }\r\n }\r\n\r\n return finalResult;\r\n }\r\n\r\n /** Insert a new aspect into the iModel.\r\n * @param aspectProps The properties of the new aspect.\r\n * @returns The newly inserted aspect Id.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @throws IModelError if insertion fails.\r\n */\r\n public insertAspect(aspectProps: ElementAspectProps): Id64String {\r\n this.verifyWriteable();\r\n try {\r\n return this.iModel[_nativeDb].insertElementAspect(aspectProps);\r\n } catch (err: any) {\r\n const error = new IModelError(err.errorNumber, `Error inserting ElementAspect [${err.message}], class: ${aspectProps.classFullName}`, aspectProps);\r\n error.cause = err;\r\n throw error;\r\n }\r\n }\r\n\r\n /** Update an existing aspect in the iModel.\r\n * @param aspectProps The properties of the aspect to update.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @throws IModelError if update fails.\r\n */\r\n public updateAspect(aspectProps: ElementAspectProps): void {\r\n this.verifyWriteable();\r\n try {\r\n this.iModel[_nativeDb].updateElementAspect(aspectProps);\r\n } catch (err: any) {\r\n const error = new IModelError(err.errorNumber, `Error updating ElementAspect [${err.message}], id: ${aspectProps.id}`, aspectProps);\r\n error.cause = err;\r\n throw error;\r\n }\r\n }\r\n\r\n /** Delete one or more aspects from the iModel.\r\n * @param aspectInstanceIds The Ids of the aspects to delete.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @throws IModelError if deletion fails.\r\n */\r\n public deleteAspect(aspectInstanceIds: Id64Arg): void {\r\n this.verifyWriteable();\r\n Id64.toIdSet(aspectInstanceIds).forEach((aspectInstanceId) => {\r\n try {\r\n this.iModel[_nativeDb].deleteElementAspect(aspectInstanceId);\r\n } catch (err: any) {\r\n const error = new IModelError(err.errorNumber, `Error deleting ElementAspect [${err.message}], id: ${aspectInstanceId}`);\r\n error.cause = err;\r\n throw error;\r\n }\r\n });\r\n }\r\n\r\n /** Delete definition elements from the iModel when they are not referenced.\r\n * @param definitionElementIds The Ids of the definition elements to attempt to delete.\r\n * @returns The set of definition elements that were still in use and therefore not deleted.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @throws IModelError if usage queries fail.\r\n */\r\n public deleteDefinitionElements(definitionElementIds: Id64Array): Id64Set {\r\n this.verifyWriteable();\r\n const usageInfo = this.iModel[_nativeDb].queryDefinitionElementUsage(definitionElementIds);\r\n if (!usageInfo)\r\n throw new IModelError(IModelStatus.BadRequest, \"Error querying for DefinitionElement usage\");\r\n\r\n const usedIdSet = usageInfo.usedIds ? Id64.toIdSet(usageInfo.usedIds) : new Set<Id64String>();\r\n const deleteIfUnused = (ids: Id64Array | undefined, used: Id64Set): void => {\r\n ids?.forEach((id) => {\r\n if (!used.has(id))\r\n this.deleteElement(id);\r\n });\r\n };\r\n\r\n try {\r\n this.iModel[_nativeDb].beginPurgeOperation();\r\n deleteIfUnused(usageInfo.spatialCategoryIds, usedIdSet);\r\n deleteIfUnused(usageInfo.drawingCategoryIds, usedIdSet);\r\n deleteIfUnused(usageInfo.viewDefinitionIds, usedIdSet);\r\n deleteIfUnused(usageInfo.geometryPartIds, usedIdSet);\r\n deleteIfUnused(usageInfo.lineStyleIds, usedIdSet);\r\n deleteIfUnused(usageInfo.renderMaterialIds, usedIdSet);\r\n deleteIfUnused(usageInfo.subCategoryIds, usedIdSet);\r\n deleteIfUnused(usageInfo.textureIds, usedIdSet);\r\n deleteIfUnused(usageInfo.displayStyleIds, usedIdSet);\r\n deleteIfUnused(usageInfo.categorySelectorIds, usedIdSet);\r\n deleteIfUnused(usageInfo.modelSelectorIds, usedIdSet);\r\n if (usageInfo.otherDefinitionElementIds)\r\n this.deleteElement(usageInfo.otherDefinitionElementIds);\r\n } finally {\r\n this.iModel[_nativeDb].endPurgeOperation();\r\n }\r\n\r\n if (usageInfo.viewDefinitionIds) {\r\n // Recheck view-related definitions after deleting view definitions that may have been their last reference.\r\n let viewRelatedIds: Id64Array = [];\r\n if (usageInfo.displayStyleIds)\r\n viewRelatedIds = viewRelatedIds.concat(usageInfo.displayStyleIds.filter((id) => usedIdSet.has(id)));\r\n\r\n if (usageInfo.categorySelectorIds)\r\n viewRelatedIds = viewRelatedIds.concat(usageInfo.categorySelectorIds.filter((id) => usedIdSet.has(id)));\r\n\r\n if (usageInfo.modelSelectorIds)\r\n viewRelatedIds = viewRelatedIds.concat(usageInfo.modelSelectorIds.filter((id) => usedIdSet.has(id)));\r\n\r\n if (viewRelatedIds.length > 0) {\r\n const viewRelatedUsageInfo = this.iModel[_nativeDb].queryDefinitionElementUsage(viewRelatedIds);\r\n if (viewRelatedUsageInfo) {\r\n const usedViewRelatedIdSet: Id64Set = viewRelatedUsageInfo.usedIds ? Id64.toIdSet(viewRelatedUsageInfo.usedIds) : new Set<Id64String>();\r\n try {\r\n this.iModel[_nativeDb].beginPurgeOperation();\r\n deleteIfUnused(viewRelatedUsageInfo.displayStyleIds, usedViewRelatedIdSet);\r\n deleteIfUnused(viewRelatedUsageInfo.categorySelectorIds, usedViewRelatedIdSet);\r\n deleteIfUnused(viewRelatedUsageInfo.modelSelectorIds, usedViewRelatedIdSet);\r\n } finally {\r\n this.iModel[_nativeDb].endPurgeOperation();\r\n }\r\n\r\n viewRelatedIds.forEach((id) => {\r\n if (!usedViewRelatedIdSet.has(id))\r\n usedIdSet.delete(id);\r\n });\r\n }\r\n }\r\n }\r\n\r\n return usedIdSet;\r\n }\r\n\r\n /** Insert a new model into the iModel.\r\n * @param props The data for the new model.\r\n * @returns The newly inserted model's Id.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @throws IModelError if insertion fails.\r\n */\r\n public insertModel(props: ModelProps): Id64String {\r\n this.verifyWriteable();\r\n try {\r\n return props.id = this.iModel[_nativeDb].insertModel(props);\r\n } catch (err: any) {\r\n const error = new IModelError(err.errorNumber, `Error inserting model [${err.message}], class=${props.classFullName}`);\r\n error.cause = err;\r\n throw error;\r\n }\r\n }\r\n\r\n /** Update an existing model in the iModel.\r\n * @param props the properties of the model to change\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @throws IModelError if update fails.\r\n */\r\n public updateModel(props: UpdateModelOptions): void {\r\n this.verifyWriteable();\r\n try {\r\n if (props.id)\r\n this.iModel.models[_cache].delete(props.id);\r\n\r\n this.iModel[_nativeDb].updateModel(props);\r\n } catch (err: any) {\r\n const error = new IModelError(err.errorNumber, `Error updating model [${err.message}], id: ${props.id}`);\r\n error.cause = err;\r\n throw error;\r\n }\r\n }\r\n\r\n /** Update the geometry guid of a model.\r\n * @param modelId The Id of the model to update.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @throws IModelError if the update fails.\r\n */\r\n public updateGeometryGuid(modelId: Id64String): void {\r\n this.verifyWriteable();\r\n this.iModel.models[_cache].delete(modelId);\r\n const error = this.iModel[_nativeDb].updateModelGeometryGuid(modelId);\r\n if (error !== IModelStatus.Success)\r\n throw new IModelError(error, `Error updating geometry guid for model ${modelId}`);\r\n }\r\n\r\n /** Delete models from the iModel.\r\n * @param ids The Ids of the models to delete.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @throws IModelError if deletion fails.\r\n */\r\n public deleteModel(ids: Id64Arg): void {\r\n this.verifyWriteable();\r\n Id64.toIdSet(ids).forEach((id) => {\r\n try {\r\n this.iModel.models[_cache].delete(id);\r\n this.iModel.models[_instanceKeyCache].deleteById(id);\r\n this.iModel[_nativeDb].deleteModel(id);\r\n } catch (err: any) {\r\n const error = new IModelError(err.errorNumber, `Error deleting model [${err.message}], id: ${id}`);\r\n error.cause = err;\r\n throw error;\r\n }\r\n });\r\n }\r\n\r\n /** Insert a new relationship into the iModel.\r\n * @param props The properties of the new relationship.\r\n * @returns The Id of the newly inserted relationship.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @throws IModelError if the class is invalid for link-table insertion.\r\n */\r\n public insertRelationship(props: RelationshipProps): Id64String {\r\n this.verifyWriteable();\r\n if (!this.iModel[_nativeDb].isLinkTableRelationship(props.classFullName.replace(\".\", \":\")))\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, `Class '${props.classFullName}' must be a relationship class and it should be subclass of BisCore:ElementRefersToElements or BisCore:ElementDrivesElement.`);\r\n\r\n return props.id = this.iModel[_nativeDb].insertLinkTableRelationship(props);\r\n }\r\n\r\n /** Update an existing relationship in the iModel.\r\n * @param props the properties of the relationship to update.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n */\r\n public updateRelationship(props: RelationshipProps): void {\r\n this.verifyWriteable();\r\n this.iModel[_nativeDb].updateLinkTableRelationship(props);\r\n }\r\n\r\n /** Delete a relationship from the iModel.\r\n * @param props The properties of the relationship to delete.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n */\r\n public deleteRelationship(props: RelationshipProps): void {\r\n this.verifyWriteable();\r\n this.iModel[_nativeDb].deleteLinkTableRelationship(props);\r\n }\r\n\r\n /** Delete multiple relationships from the iModel.\r\n * @param props The properties of the relationships to delete.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n */\r\n public deleteRelationships(props: ReadonlyArray<RelationshipProps>): void {\r\n this.verifyWriteable();\r\n this.iModel[_nativeDb].deleteLinkTableRelationships(props);\r\n }\r\n\r\n\r\n /** Save a file property to the iModel.\r\n * @param prop The file property to save.\r\n * @param strValue String value.\r\n * @param blobVal Blob value.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n */\r\n public saveFileProperty(prop: FilePropertyProps, strValue: string | undefined, blobVal?: Uint8Array): void {\r\n this.verifyWriteable();\r\n const imodel = this.iModel;\r\n if (imodel.isBriefcaseDb()) {\r\n if (imodel.txns.isIndirectChanges) {\r\n throw new IModelError(IModelStatus.BadRequest, \"Cannot save file property while in an indirect change scope\");\r\n }\r\n }\r\n imodel[_nativeDb].saveFileProperty(prop, strValue, blobVal);\r\n }\r\n\r\n /** Delete a file property from the iModel.\r\n * @param prop The file property to delete.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n */\r\n public deleteFileProperty(prop: FilePropertyProps): void {\r\n this.saveFileProperty(prop, undefined, undefined);\r\n }\r\n\r\n /** Update the project extents of the iModel.\r\n * @param newExtents The new project extents.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @throws IModelError if extents are invalid.\r\n */\r\n public updateProjectExtents(newExtents: Range3dProps): void {\r\n this.verifyWriteable();\r\n const extents = Range3d.fromJSON(newExtents);\r\n if (extents.isNull)\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Invalid project extents\");\r\n\r\n this.iModel.projectExtents = extents;\r\n this.updateIModelProps();\r\n }\r\n\r\n /** Update the ECEF location of the iModel.\r\n * @param ecef The new ECEF location.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n */\r\n public updateEcefLocation(ecef: EcefLocationProps): void {\r\n this.verifyWriteable();\r\n this.iModel.setEcefLocation(new EcefLocation(ecef));\r\n this.updateIModelProps();\r\n }\r\n\r\n /** Update the iModel props in the database from the current in-memory state.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n */\r\n public updateIModelProps(): void {\r\n this.verifyWriteable();\r\n this.iModel[_nativeDb].updateIModelProps(this.iModel.toJSON());\r\n }\r\n\r\n private static readonly _settingPropNamespace = \"settings\";\r\n private static readonly _viewStoreProperty: FilePropertyProps = { namespace: \"itwinjs\", name: \"DefaultViewStore\" };\r\n\r\n /** Save a `SettingDictionary` in this iModel.\r\n * @param name The name for the SettingDictionary. If a dictionary by that name already exists, its value is replaced.\r\n * @param dict The SettingDictionary object to stringify and save.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @beta\r\n */\r\n public saveSettingDictionary(name: string, dict: SettingsContainer): void {\r\n this.verifyWriteable();\r\n this.iModel.withSqliteStatement(\"REPLACE INTO be_Prop(id,SubId,TxnMode,Namespace,Name,strData) VALUES(0,0,0,?,?,?)\", (stmt) => {\r\n stmt.bindString(1, EditTxn._settingPropNamespace);\r\n stmt.bindString(2, name);\r\n stmt.bindString(3, JSON.stringify(dict));\r\n stmt.stepForWrite();\r\n });\r\n this.saveChanges(\"add settings\");\r\n }\r\n\r\n /** Delete a SettingDictionary from this iModel.\r\n * @param name The name of the dictionary to delete.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @beta\r\n */\r\n public deleteSettingDictionary(name: string): void {\r\n this.verifyWriteable();\r\n this.iModel.withSqliteStatement(\"DELETE FROM be_Prop WHERE Namespace=? AND Name=?\", (stmt) => {\r\n stmt.bindString(1, EditTxn._settingPropNamespace);\r\n stmt.bindString(2, name);\r\n stmt.stepForWrite();\r\n });\r\n this.saveChanges(\"delete settings\");\r\n }\r\n\r\n /** Save a default ViewStore container reference in this iModel.\r\n * @param arg The cloud container properties for the ViewStore.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @beta\r\n */\r\n public saveDefaultViewStore(arg: CloudSqlite.ContainerProps): void {\r\n this.verifyWriteable();\r\n const props = { baseUri: arg.baseUri, containerId: arg.containerId, storageType: arg.storageType }; // sanitize to only known properties\r\n this.saveFileProperty(EditTxn._viewStoreProperty, JSON.stringify(props));\r\n this.saveChanges(\"update default ViewStore\");\r\n }\r\n}\r\n\r\n/** Execute a callback within an explicit editing transaction. A new [[EditTxn]] is created, started,\r\n * and passed to `fn`. If `fn` returns normally (or its returned Promise resolves), the transaction\r\n * is committed. If `fn` throws (or its returned Promise rejects), the transaction is abandoned —\r\n * none of the changes made during the callback are saved — and the error is re-thrown.\r\n *\r\n * This is the recommended way to perform a scoped unit of work on an iModel. It ensures that\r\n * edits are committed atomically on success and rolled back on failure, without the caller needing\r\n * to manage `start` / `end` manually.\r\n *\r\n * @param iModel The iModel to edit.\r\n * @param fn A callback that receives the active [[EditTxn]] and performs edits.\r\n * @returns The value returned by `fn`.\r\n * @throws EditTxnError if the transaction cannot be started (e.g. unsaved changes or another EditTxn is active).\r\n * @throws Re-throws any error thrown by `fn` after abandoning the transaction.\r\n * @beta\r\n */\r\nexport function withEditTxn<T>(iModel: IModelDb, fn: (txn: EditTxn) => T): T;\r\n/** Execute a callback within an explicit editing transaction, supplying commit arguments.\r\n * @param iModel The iModel to edit.\r\n * @param saveArgs Description or structured arguments passed to [[EditTxn.saveChanges]] on save.\r\n * @param fn A callback that receives the active [[EditTxn]] and performs edits.\r\n * @returns The value returned by `fn`.\r\n * @beta\r\n */\r\nexport function withEditTxn<T>(iModel: IModelDb, saveArgs: string | SaveChangesArgs, fn: (txn: EditTxn) => T): T;\r\n/** Execute an async callback within an explicit editing transaction.\r\n * @param iModel The iModel to edit.\r\n * @param fn An async callback that receives the active [[EditTxn]] and performs edits.\r\n * @returns A Promise that resolves to the value returned by `fn`.\r\n * @beta\r\n */\r\nexport function withEditTxn<T>(iModel: IModelDb, fn: (txn: EditTxn) => Promise<T>): Promise<T>;\r\n/** Execute an async callback within an explicit editing transaction, supplying commit arguments.\r\n * @param iModel The iModel to edit.\r\n * @param saveArgs Description or structured arguments passed to [[EditTxn.saveChanges]] on save.\r\n * @param fn An async callback that receives the active [[EditTxn]] and performs edits.\r\n * @returns A Promise that resolves to the value returned by `fn`.\r\n * @beta\r\n */\r\nexport function withEditTxn<T>(iModel: IModelDb, saveArgs: string | SaveChangesArgs, fn: (txn: EditTxn) => Promise<T>): Promise<T>;\r\nexport function withEditTxn<T>(iModel: IModelDb, saveArgsOrFn: string | SaveChangesArgs | ((txn: EditTxn) => T | Promise<T>), maybeFn?: (txn: EditTxn) => T | Promise<T>): T | Promise<T> {\r\n const saveArgs = \"function\" === typeof saveArgsOrFn ? undefined : saveArgsOrFn;\r\n const fn = \"function\" === typeof saveArgsOrFn ? saveArgsOrFn : maybeFn;\r\n\r\n if (undefined === fn)\r\n throw new Error(\"withEditTxn requires a callback\");\r\n\r\n const txn = new EditTxn(iModel, \"\");\r\n txn.start();\r\n\r\n try {\r\n const result = fn(txn);\r\n if (result instanceof Promise) {\r\n return result.then((value) => {\r\n txn.end(\"save\", saveArgs);\r\n return value;\r\n }, (err) => {\r\n if (txn.isActive)\r\n txn.end(\"abandon\");\r\n\r\n throw err;\r\n });\r\n }\r\n\r\n txn.end(\"save\", saveArgs);\r\n return result;\r\n } catch (err) {\r\n if (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AC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;gBAC1B,OAAO,KAAK,CAAC;YACf,CAAC,EAAE,cAAc,CAAC,CAAC;QACrB,CAAC;QAED,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAC1B,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,cAAc,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;AACH,CAAC","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 iModels\r\n */\r\n\r\nimport { DbResult, Id64, Id64Arg, Id64Array, Id64Set, Id64String, IModelStatus, ITwinError, Logger, OpenMode } from \"@itwin/core-bentley\";\r\nimport { EcefLocation, EcefLocationProps, EditTxnError, ElementAspectProps, ElementError, ElementProps, FilePropertyProps, IModelError, ModelProps, RelationshipProps, SaveChangesArgs } from \"@itwin/core-common\";\r\nimport { Range3d, Range3dProps } from \"@itwin/core-geometry\";\r\nimport type { CloudSqlite } from \"./CloudSqlite\";\r\nimport type { ImplicitWriteEnforcement } from \"./IModelHost\";\r\nimport type { ChangeElementModelProps, ChangeElementParentProps, IModelDb, InsertElementOptions, UpdateModelOptions } from \"./IModelDb\";\r\nimport type { SettingsContainer } from \"./workspace/Settings\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { _activeTxn, _cache, _instanceKeyCache, _nativeDb, _refreshGeographicCoordinateSystem, _updateIModelProps, _verifyChannel, _verifyTxnWrite } from \"./internal/Symbols\";\r\n\r\n/** Options for bulk deleting elements from an iModelDb.\r\n * @beta\r\n * @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.\r\n */\r\nexport interface BulkDeleteElementsArgs {\r\n /**\r\n * @deprecated in 5.15.0 - will not be removed until after 2027-11-05. Skipping FK constraint validation is no longer supported.\r\n */\r\n skipFKConstraintValidations?: boolean;\r\n}\r\n\r\n/**\r\n * Why an element could not be deleted by [[EditTxn.deleteElements]].\r\n * @beta\r\n */\r\nexport enum BulkDeleteFailureReason {\r\n /** A row outside the delete set references it via a NO ACTION / RESTRICT / SET DEFAULT FK. */\r\n ReferencedByForeignKey = 0,\r\n /** It is a DefinitionElement still used by elements outside the delete set. */\r\n DefinitionInUse = 1,\r\n /** It is one of the elements every iModel must keep: the root Subject, the DictionaryModel partition or the RealityDataSources partition. */\r\n ProtectedElement = 2,\r\n /** Its handler belongs to a read-only DgnDomain. */\r\n ReadOnlyDomain = 3,\r\n}\r\n\r\n/**\r\n * One element that could not be deleted by [[EditTxn.deleteElements]], and why.\r\n * @beta\r\n */\r\nexport interface BulkDeleteFailure {\r\n /** The id of the element that could not be deleted. */\r\n elementId: Id64String;\r\n /** Why the element could not be deleted. */\r\n reason: BulkDeleteFailureReason;\r\n}\r\n\r\n/**\r\n * Result of a bulk element delete operation.\r\n * @beta\r\n */\r\nexport interface BulkDeleteElementsResult {\r\n /** Overall status of the bulk delete operation. See [[BulkDeleteElementsStatus]]. */\r\n status: BulkDeleteElementsStatus;\r\n /** The raw SQLite result code from the underlying SQL DELETE. Only meaningful when `status === DeletionFailed`. */\r\n sqlDeleteStatus: DbResult;\r\n /**\r\n * One entry per element that blocks the deletion, with the reason. Only populated on `ConstraintViolation`.\r\n * Empty on `Success` and `DeletionFailed`.\r\n * Because the whole expanded delete set is validated, a reported element may be a child or sub-model member\r\n * that was not in the requested ids; its requested ancestor is not listed separately.\r\n */\r\n failures: BulkDeleteFailure[];\r\n /**\r\n * The set of element ids that could not be deleted.\r\n * - On `ConstraintViolation`: the unique element ids appearing in `failures`. May include cascaded descendants\r\n * that were not in the requested ids, so this is not guaranteed to be a subset of the input. Never empty.\r\n * Nothing was deleted, including requested ids that are not listed.\r\n * - On `DeletionFailed`: every requested id (the iModel may be partially modified; abandon the current txn).\r\n * - On `Success`: empty.\r\n * @deprecated in 5.15.0 - will not be removed until after 2027-11-05. Use `failures` for a more detailed failure report.\r\n */\r\n failedIds: Id64Set;\r\n}\r\n\r\n/**\r\n * Status of a bulk element delete operation, mirroring the C++ `BulkDeleteStatus` enum.\r\n * @beta\r\n */\r\nexport enum BulkDeleteElementsStatus {\r\n /** All supplied elements were deleted successfully. */\r\n Success = 0,\r\n /** Nothing was deleted because some elements in the (expanded) delete set are still referenced from outside the set; see `failures` for the violators. */\r\n ConstraintViolation = 1,\r\n /** An internal error occurred. The iModel may be partially modified; the caller must abandon the current txn. `failures` will be empty. */\r\n DeletionFailed = 2,\r\n}\r\n\r\n/**\r\n * Represents an explicit editing transaction for an iModel.\r\n *\r\n * An explicit EditTxn lets callers define a deliberate unit of work by choosing when editing\r\n * starts (`start`) and how it ends (`end()` / `end(\"save\")` or `end(\"abandon\")`). This avoids mixing\r\n * unrelated edits into one implicit unit of work and makes save/rollback boundaries explicit.\r\n *\r\n * Explicit EditTxn instances must be active before mutating operations are performed, regardless of enforcement level.\r\n * In other words, explicit transaction behavior is independent of `implicitWriteEnforcement`.\r\n *\r\n * @see [EditTxn transaction model and migration guidance]($docs/learning/backend/EditTxn.md)\r\n *\r\n * *During indirect changes (commit processing):* Use callback args (`indirectEditTxn`) in callbacks like\r\n * [[Relationship.onRootChangedArg]] and [[Relationship.onDeletedDependencyArg]] that fire during indirect processing.\r\n *\r\n * @beta\r\n */\r\nexport class EditTxn {\r\n /** Controls how writes through the implicit transaction are handled.\r\n *\r\n * This does not relax activation requirements for explicit transactions: explicit EditTxn writes\r\n * must always come from the active EditTxn.\r\n *\r\n * - `allow`: allow implicit writes for backwards compatibility, even while an explicit EditTxn is active.\r\n * - `log`: allow implicit writes but log `implicit-txn-write-disallowed` errors.\r\n * - `throw`: reject implicit writes with `implicit-txn-write-disallowed`.\r\n *\r\n * This is initialized from [[IModelHostOptions.implicitWriteEnforcement]] during [[IModelHost.startup]].\r\n *\r\n * Defaults to `allow` for backwards compatibility.\r\n * @beta\r\n */\r\n public static implicitWriteEnforcement: ImplicitWriteEnforcement = \"allow\";\r\n\r\n /** The iModel this EditTxn may modify. */\r\n public readonly iModel: IModelDb;\r\n\r\n /** Default description passed to [[saveChanges]] when saving this transaction. */\r\n public description: string;\r\n\r\n /** True if this transaction currently owns the iModel write surface. */\r\n public get isActive(): boolean {\r\n return this.iModel[_activeTxn] === this;\r\n }\r\n\r\n public constructor(iModel: IModelDb, description: string) {\r\n this.iModel = iModel;\r\n this.description = description;\r\n }\r\n\r\n public verifyWriteable(): void {\r\n this.iModel[_verifyTxnWrite]();\r\n // Explicit transactions must always be active before writing.\r\n if (!this.isActive)\r\n EditTxnError.throwError(\"not-active\", \"EditTxn is not active\", this.iModel.key);\r\n }\r\n\r\n /** Start this EditTxn, making it the active transaction for the iModel.\r\n * @throws EditTxnError if this EditTxn is already active, another EditTxn is already active, or if unsaved changes are present.\r\n * @throws IModelError if the geographic coordinate system is being restored.\r\n */\r\n public start(): void {\r\n this.iModel[_verifyTxnWrite]();\r\n if (this.isActive)\r\n EditTxnError.throwError(\"already-active\", \"This EditTxn is already active\", this.iModel.key);\r\n\r\n const activeTxn = this.iModel[_activeTxn];\r\n if (undefined !== activeTxn)\r\n EditTxnError.throwError(\"already-active\", \"Cannot start EditTxn while another EditTxn is active\", this.iModel.key, activeTxn.description);\r\n\r\n if (this.iModel[_nativeDb].hasUnsavedChanges())\r\n EditTxnError.throwError(\"unsaved-changes\", \"Cannot start a new EditTxn with unsaved changes\", this.iModel.key);\r\n\r\n this.iModel[_activeTxn] = this;\r\n }\r\n\r\n /** End this EditTxn, either by saving or abandoning the changes.\r\n * @param mode Whether to \"save\" or \"abandon\" the changes. Defaults to \"save\".\r\n * @param args Save changes arguments when saving.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @throws IModelError if saving changes fails.\r\n * @throws Re-throws any error propagated by a geographic coordinate system restoration listener after completing abandonment.\r\n */\r\n public end(): void;\r\n public end(mode: \"save\" | \"abandon\", args?: string | SaveChangesArgs): void;\r\n public end(mode: \"save\" | \"abandon\" = \"save\", args?: string | SaveChangesArgs): void {\r\n if (!this.isActive)\r\n EditTxnError.throwError(\"not-active\", \"EditTxn is not active\", this.iModel.key);\r\n\r\n if (mode === \"save\") {\r\n this.saveChanges(args);\r\n } else {\r\n this.abandonDatabaseChanges();\r\n }\r\n this.iModel[_activeTxn] = undefined;\r\n if (mode === \"abandon\")\r\n this.iModel[_refreshGeographicCoordinateSystem]();\r\n }\r\n\r\n /** Invoked when the owning iModel is closing.\r\n * The base implementation commits unsaved changes. Subclasses may override to customize how\r\n * their changes are handled before the iModel closes.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @throws IModelError if saving on close fails.\r\n */\r\n public onClose(): void {\r\n if (!this.iModel.isReadonly && this.iModel[_nativeDb].hasUnsavedChanges())\r\n this.saveChanges();\r\n }\r\n\r\n /** Abandon database changes while keeping this EditTxn active.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n */\r\n public abandonChanges(): void {\r\n this.abandonDatabaseChanges();\r\n this.iModel[_refreshGeographicCoordinateSystem]();\r\n }\r\n\r\n private abandonDatabaseChanges(): void {\r\n this.verifyWriteable();\r\n this.iModel.clearCaches({ instanceCachesOnly: true });\r\n this.iModel[_nativeDb].abandonChanges();\r\n }\r\n\r\n /** Save changes with additional arguments.\r\n * @param args Save changes arguments.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @throws IModelError if the iModel is readonly, if indirect changes are active, or if the native save fails.\r\n */\r\n public saveChanges(args?: string | SaveChangesArgs): void {\r\n this.verifyWriteable();\r\n const iModel = this.iModel;\r\n if (iModel.openMode === OpenMode.Readonly)\r\n throw new IModelError(IModelStatus.ReadOnly, \"IModelDb was opened read-only\");\r\n\r\n if (iModel.isBriefcaseDb() && iModel.txns.isIndirectChanges)\r\n throw new IModelError(IModelStatus.BadRequest, \"Cannot save changes while in an indirect change scope\");\r\n\r\n args ??= this.description;\r\n const saveArgs = typeof args === \"string\" ? { description: args } : args;\r\n const stat = iModel[_nativeDb].saveChanges(JSON.stringify(saveArgs));\r\n if (DbResult.BE_SQLITE_ERROR_PropagateChangesFailed === stat)\r\n throw new IModelError(stat, \"Could not save changes due to propagation failure.\");\r\n\r\n if (DbResult.BE_SQLITE_OK !== stat)\r\n throw new IModelError(stat, `Could not save changes (${saveArgs.description})`);\r\n }\r\n\r\n /** Insert a new element into the iModel.\r\n * @param elProps The properties of the new element.\r\n * @returns The newly inserted element's Id.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @throws [[ITwinError]] if insertion fails.\r\n */\r\n public insertElement(elProps: ElementProps, options?: InsertElementOptions): Id64String {\r\n this.verifyWriteable();\r\n try {\r\n options ??= {};\r\n this.iModel.elements[_cache].delete({\r\n id: elProps.id,\r\n federationGuid: elProps.federationGuid,\r\n code: elProps.code,\r\n });\r\n return elProps.id = this.iModel[_nativeDb].insertElement(elProps, options);\r\n } catch (err: any) {\r\n err.message = `Error inserting element [${err.message}]`;\r\n err.metadata = { elProps };\r\n throw err;\r\n }\r\n }\r\n\r\n /** Update an existing element in the iModel.\r\n * @param elProps The properties to update.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @throws [[ITwinError]] if update fails.\r\n */\r\n public updateElement<T extends ElementProps>(elProps: Partial<T>): void {\r\n this.verifyWriteable();\r\n try {\r\n if (elProps.id) {\r\n this.iModel.elements[_instanceKeyCache].deleteById(elProps.id);\r\n } else {\r\n this.iModel.elements[_instanceKeyCache].delete({\r\n federationGuid: elProps.federationGuid,\r\n code: elProps.code,\r\n });\r\n }\r\n this.iModel.elements[_cache].delete({\r\n id: elProps.id,\r\n federationGuid: elProps.federationGuid,\r\n code: elProps.code,\r\n });\r\n this.iModel[_nativeDb].updateElement(elProps);\r\n } catch (err: any) {\r\n err.message = `Error updating element [${err.message}], id: ${elProps.id}`;\r\n err.metadata = { elProps };\r\n throw err;\r\n }\r\n }\r\n\r\n /** Delete elements from the iModel.\r\n * @param ids The Ids of the elements to delete.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @throws [[ITwinError]] if deletion fails.\r\n */\r\n public deleteElement(ids: Id64Arg): void {\r\n this.verifyWriteable();\r\n const iModel = this.iModel;\r\n Id64.toIdSet(ids).forEach((id) => {\r\n try {\r\n this.iModel.elements[_cache].delete({ id });\r\n this.iModel.elements[_instanceKeyCache].deleteById(id);\r\n iModel[_nativeDb].deleteElement(id);\r\n } catch (err: any) {\r\n err.message = `Error deleting element [${err.message}], id: ${id}`;\r\n err.metadata = { elementId: id };\r\n throw err;\r\n }\r\n });\r\n }\r\n\r\n /** Change the parent of an element within its model.\r\n *\r\n * The new parent must be in the same model as the element. Cross-model reparenting is not allowed;\r\n * use [[changeElementModel]] only to move root elements between models.\r\n * Only the target element is reparented — its children and their model membership are unaffected.\r\n *\r\n * **Blocked cases** (will throw):\r\n * - The new parent is in a different model than the element.\r\n * - Element has a `ParentElement`-scoped code (code uniqueness is tied to the parent; use delete+insert instead).\r\n *\r\n * **Allowed cases**:\r\n * - Element has a `Repository`-scoped code (unique across entire iModel — unaffected by the parent change).\r\n * - Element has a `RelatedElement`-scoped code (scope element is independent of the parent).\r\n * - Element has a `Model`-scoped code (the model does not change, so the code remains valid).\r\n * - Element has no meaningful code (empty code).\r\n *\r\n * Channel verification is performed on the element's model.\r\n * Lock enforcement: requires an exclusive lock on the element, and a shared lock on the new parent.\r\n * @param props The reparent parameters: element id and new parent id.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @throws [[ITwinError]] if the operation fails.\r\n * @beta\r\n */\r\n public changeElementParent(props: ChangeElementParentProps): void {\r\n this.verifyWriteable();\r\n const iModel = this.iModel;\r\n\r\n // Lock enforcement: exclusive lock on the element being reparented, shared lock on the new parent.\r\n iModel.locks.checkExclusiveLock(props.id, \"element\", \"changeParent\");\r\n iModel.locks.checkSharedLock(props.parentId, \"parent\", \"changeParent\");\r\n\r\n // The new parent must be in the same model as the element. Cross-model reparenting is not\r\n // allowed here; changeElementModel only moves root elements between models. Check this up\r\n // front so consumers get a clear error instead of the addon's lower-level \"wrong model\" status.\r\n const sourceModelId = iModel.elements.getElementProps({ id: props.id }).model;\r\n const parentModelId = iModel.elements.getElementProps({ id: props.parentId }).model;\r\n if (sourceModelId !== parentModelId)\r\n ElementError.throwError(\"invalid-arguments\", `cannot reparent element '${props.id}' to a parent in a different model ('${parentModelId}' != '${sourceModelId}'); changeElementModel only moves root elements between models`);\r\n\r\n // Channel verification on the element's model.\r\n iModel.channels[_verifyChannel](sourceModelId);\r\n\r\n // Invalidate caches for the element being reparented.\r\n iModel.elements[_cache].delete({ id: props.id });\r\n iModel.elements[_instanceKeyCache].deleteById(props.id);\r\n\r\n try {\r\n iModel[_nativeDb].changeElementParent({ id: props.id, parentId: props.parentId });\r\n } catch (err: any) {\r\n err.message = `Error changing element parent [${err.message}], id: ${props.id}, parentId: ${props.parentId}`;\r\n err.metadata = { props };\r\n throw err;\r\n }\r\n\r\n // The model is unchanged and descendants are not moved, so only the reparented element's cache is stale.\r\n iModel.elements[_cache].delete({ id: props.id });\r\n iModel.elements[_instanceKeyCache].deleteById(props.id);\r\n }\r\n\r\n /** Change the model of a root element, making it a root element in the new model.\r\n *\r\n * The element must not have a parent.\r\n * The element's entire subtree moves with it: BIS requires a parent and all of its children to reside\r\n * in the same model, so every descendant of the element is relocated into the target model as well.\r\n * The parent-child hierarchy is preserved. The whole subtree is validated before anything is moved, so\r\n * a rejected change leaves the iModel untouched.\r\n *\r\n * **Blocked cases** (will throw):\r\n * - Element has a parent (only root elements can be moved between models).\r\n * - Any element in the subtree has a `Model`-scoped code (code uniqueness is tied to the source model; use delete+insert instead).\r\n * - The moved (root) element has a `ParentElement`-scoped code (use delete+insert instead). A descendant's `ParentElement`-scoped code is allowed, because its parent moves with it.\r\n *\r\n * **Allowed cases** (for any element in the subtree):\r\n * - A `Repository`-scoped code (unique across entire iModel — unaffected by the model change).\r\n * - A `RelatedElement`-scoped code (scope element is independent of the model).\r\n * - No meaningful code (empty code).\r\n *\r\n * The source and target models must be of the same class (classFullName must match exactly).\r\n * Channel verification is performed on both the source and target models.\r\n * Lock enforcement: requires an exclusive lock on every element in the moved subtree, and a shared lock on the target model.\r\n * @param props The model change parameters: element id and target model id.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @throws [[ITwinError]] if the operation fails.\r\n * @beta\r\n */\r\n public changeElementModel(props: ChangeElementModelProps): void {\r\n this.verifyWriteable();\r\n const iModel = this.iModel;\r\n\r\n // Resolve the source model\r\n const sourceModelId = iModel.elements.getElementProps({ id: props.id }).model;\r\n\r\n // Channel verification on the source model\r\n iModel.channels[_verifyChannel](sourceModelId);\r\n\r\n // Model type check: source and target models must be the same class\r\n const sourceModel = iModel.models.getModel(sourceModelId);\r\n const targetModel = iModel.models.getModel(props.modelId);\r\n if (sourceModel.classFullName !== targetModel.classFullName)\r\n ElementError.throwError(\"model-type-mismatch\", `cannot move element from model of type '${sourceModel.classFullName}' to model of type '${targetModel.classFullName}'`);\r\n\r\n // Shared lock on target model\r\n iModel.locks.checkSharedLock(props.modelId, \"model\", \"changeModel\");\r\n\r\n // Lock enforcement: every element in the subtree is updated by the native bulk move.\r\n const subtreeIds = this.collectSubtreeIds(props.id);\r\n for (const id of subtreeIds)\r\n iModel.locks.checkExclusiveLock(id, \"element\", \"changeModel\");\r\n\r\n // Channel verification on the target model\r\n iModel.channels[_verifyChannel](props.modelId);\r\n\r\n // Invalidate caches\r\n iModel.elements[_cache].delete({ id: props.id });\r\n iModel.elements[_instanceKeyCache].deleteById(props.id);\r\n\r\n try {\r\n iModel[_nativeDb].changeElementModel({ id: props.id, modelId: props.modelId });\r\n } catch (err: any) {\r\n err.message = `Error changing element model [${err.message}], id: ${props.id}, modelId: ${props.modelId}`;\r\n err.metadata = { props };\r\n throw err;\r\n }\r\n\r\n // The move relocates the element's entire subtree into the target model (BIS requires a parent and\r\n // its children to reside in the same model). Every descendant's cached props therefore hold a stale\r\n // `model`, so invalidate the whole subtree rather than just the target element.\r\n for (const id of subtreeIds) {\r\n iModel.elements[_cache].delete({ id });\r\n iModel.elements[_instanceKeyCache].deleteById(id);\r\n }\r\n\r\n // Moving the subtree changes the membership - and therefore the geometry-derived state such as\r\n // GeometricModel.geometryGuid - of both the source and target models. Element insert/update/delete\r\n // invalidate models[_cache] via Element.onInserted/onUpdated/onDeleted for the same reason, but the\r\n // native changeElementModel does not fire those element callbacks, so invalidate both affected models\r\n // here to keep the model cache contract local to this wrapper.\r\n iModel.models[_cache].delete(sourceModelId);\r\n iModel.models[_cache].delete(props.modelId);\r\n }\r\n\r\n /** Collect an element together with all of its descendants by walking the `ElementOwnsChildElements`\r\n * hierarchy depth-first. Used to invalidate the cached props of every element affected by a subtree move.\r\n */\r\n private collectSubtreeIds(rootId: Id64String): Id64String[] {\r\n const ids: Id64String[] = [];\r\n const stack: Id64String[] = [rootId];\r\n for (let id = stack.pop(); undefined !== id; id = stack.pop()) {\r\n ids.push(id);\r\n for (const childId of this.iModel.elements.queryChildren(id))\r\n stack.push(childId);\r\n }\r\n return ids;\r\n }\r\n\r\n /**\r\n * Delete multiple elements from the iModel in a single bulk operation.\r\n *\r\n * Child elements and sub-model contents of the requested elements are deleted along with them.\r\n *\r\n * The operation is all-or-nothing:\r\n * - On `Success`, all elements (and their children / sub-model contents) were deleted.\r\n * - On `ConstraintViolation`, nothing was deleted and [[BulkDeleteElementsResult.failures]] lists every element in the\r\n * expanded delete set that is still referenced from outside the set, and why. Fix or include those referencing elements and retry.\r\n * - On `DeletionFailed` (an unexpected SQLite error) the iModel may be partially modified and the caller must abandon the current txn.\r\n *\r\n * @param ids The ids of the elements to delete. All ids must be well-formed and valid [[Id64String]]s.\r\n * @param _deleteOptions Deprecated and ignored; kept for backward compatibility of the signature.\r\n * @returns A result object describing the outcome of the operation and the elements that block it (if any).\r\n * @throws [[ITwinError]] if any of the supplied ids are not well-formed/valid [[Id64String]]s.\r\n * @beta\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n public deleteElements(ids: Id64Array, _deleteOptions?: BulkDeleteElementsArgs): BulkDeleteElementsResult {\r\n this.verifyWriteable();\r\n const invalidIds: Id64Set = new Set<Id64String>();\r\n for (const id of ids) {\r\n if (!Id64.isValidId64(id))\r\n invalidIds.add(id);\r\n }\r\n\r\n if (invalidIds.size > 0)\r\n ITwinError.throwError({ message: `Invalid element ids: ${Array.from(invalidIds).join(\", \")}`, iTwinErrorId: { scope: \"imodel\", key: \"invalid-arguments\" } });\r\n\r\n const nativeResult = this.iModel[_nativeDb].deleteElements(ids);\r\n\r\n // When deletion fails with `DeletionFailed`, all requested ids are returned to maintain backward compatibilty.\r\n // Once `failedIds` is deprecated, we will change this to throw instead as this is a SQLite failure.\r\n const failedIds = nativeResult.status === BulkDeleteElementsStatus.DeletionFailed\r\n ? new Set<Id64String>(ids)\r\n : new Set<Id64String>(nativeResult.failures.map((failure: BulkDeleteFailure) => failure.elementId));\r\n\r\n const result: BulkDeleteElementsResult = {\r\n status: nativeResult.status,\r\n sqlDeleteStatus: nativeResult.sqlDeleteStatus,\r\n failures: nativeResult.failures,\r\n // `failedIds` is deprecated. `failures` provides a more comprehensive error report.\r\n // We still need to return the deprecated `failedIds` to maintain backward compatibility.\r\n failedIds,\r\n };\r\n\r\n // Nothing was deleted on ConstraintViolation; on DeletionFailed the caller must abandon the txn, which restores the cached state.\r\n if (result.status !== BulkDeleteElementsStatus.Success)\r\n return result;\r\n\r\n // Native deletion also nulls logical navigation properties on surviving elements that referenced the deleted ones,\r\n // so evicting only the requested ids would leave stale cached referrers. Clear all instance caches.\r\n this.iModel.clearCaches({ instanceCachesOnly: true });\r\n\r\n return result;\r\n }\r\n\r\n /** Insert a new aspect into the iModel.\r\n * @param aspectProps The properties of the new aspect.\r\n * @returns The newly inserted aspect Id.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @throws IModelError if insertion fails.\r\n */\r\n public insertAspect(aspectProps: ElementAspectProps): Id64String {\r\n this.verifyWriteable();\r\n try {\r\n return this.iModel[_nativeDb].insertElementAspect(aspectProps);\r\n } catch (err: any) {\r\n const error = new IModelError(err.errorNumber, `Error inserting ElementAspect [${err.message}], class: ${aspectProps.classFullName}`, aspectProps);\r\n error.cause = err;\r\n throw error;\r\n }\r\n }\r\n\r\n /** Update an existing aspect in the iModel.\r\n * @param aspectProps The properties of the aspect to update.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @throws IModelError if update fails.\r\n */\r\n public updateAspect(aspectProps: ElementAspectProps): void {\r\n this.verifyWriteable();\r\n try {\r\n this.iModel[_nativeDb].updateElementAspect(aspectProps);\r\n } catch (err: any) {\r\n const error = new IModelError(err.errorNumber, `Error updating ElementAspect [${err.message}], id: ${aspectProps.id}`, aspectProps);\r\n error.cause = err;\r\n throw error;\r\n }\r\n }\r\n\r\n /** Delete one or more aspects from the iModel.\r\n * @param aspectInstanceIds The Ids of the aspects to delete.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @throws IModelError if deletion fails.\r\n */\r\n public deleteAspect(aspectInstanceIds: Id64Arg): void {\r\n this.verifyWriteable();\r\n Id64.toIdSet(aspectInstanceIds).forEach((aspectInstanceId) => {\r\n try {\r\n this.iModel[_nativeDb].deleteElementAspect(aspectInstanceId);\r\n } catch (err: any) {\r\n const error = new IModelError(err.errorNumber, `Error deleting ElementAspect [${err.message}], id: ${aspectInstanceId}`);\r\n error.cause = err;\r\n throw error;\r\n }\r\n });\r\n }\r\n\r\n /** Delete definition elements from the iModel when they are not referenced.\r\n * @param definitionElementIds The Ids of the definition elements to attempt to delete.\r\n * @returns The set of definition elements that were still in use and therefore not deleted.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @throws IModelError if usage queries fail.\r\n */\r\n public deleteDefinitionElements(definitionElementIds: Id64Array): Id64Set {\r\n this.verifyWriteable();\r\n const usageInfo = this.iModel[_nativeDb].queryDefinitionElementUsage(definitionElementIds);\r\n if (!usageInfo)\r\n throw new IModelError(IModelStatus.BadRequest, \"Error querying for DefinitionElement usage\");\r\n\r\n const usedIdSet = usageInfo.usedIds ? Id64.toIdSet(usageInfo.usedIds) : new Set<Id64String>();\r\n const deleteIfUnused = (ids: Id64Array | undefined, used: Id64Set): void => {\r\n ids?.forEach((id) => {\r\n if (!used.has(id))\r\n this.deleteElement(id);\r\n });\r\n };\r\n\r\n try {\r\n this.iModel[_nativeDb].beginPurgeOperation();\r\n deleteIfUnused(usageInfo.spatialCategoryIds, usedIdSet);\r\n deleteIfUnused(usageInfo.drawingCategoryIds, usedIdSet);\r\n deleteIfUnused(usageInfo.viewDefinitionIds, usedIdSet);\r\n deleteIfUnused(usageInfo.geometryPartIds, usedIdSet);\r\n deleteIfUnused(usageInfo.lineStyleIds, usedIdSet);\r\n deleteIfUnused(usageInfo.renderMaterialIds, usedIdSet);\r\n deleteIfUnused(usageInfo.subCategoryIds, usedIdSet);\r\n deleteIfUnused(usageInfo.textureIds, usedIdSet);\r\n deleteIfUnused(usageInfo.displayStyleIds, usedIdSet);\r\n deleteIfUnused(usageInfo.categorySelectorIds, usedIdSet);\r\n deleteIfUnused(usageInfo.modelSelectorIds, usedIdSet);\r\n if (usageInfo.otherDefinitionElementIds)\r\n this.deleteElement(usageInfo.otherDefinitionElementIds);\r\n } finally {\r\n this.iModel[_nativeDb].endPurgeOperation();\r\n }\r\n\r\n if (usageInfo.viewDefinitionIds) {\r\n // Recheck view-related definitions after deleting view definitions that may have been their last reference.\r\n let viewRelatedIds: Id64Array = [];\r\n if (usageInfo.displayStyleIds)\r\n viewRelatedIds = viewRelatedIds.concat(usageInfo.displayStyleIds.filter((id) => usedIdSet.has(id)));\r\n\r\n if (usageInfo.categorySelectorIds)\r\n viewRelatedIds = viewRelatedIds.concat(usageInfo.categorySelectorIds.filter((id) => usedIdSet.has(id)));\r\n\r\n if (usageInfo.modelSelectorIds)\r\n viewRelatedIds = viewRelatedIds.concat(usageInfo.modelSelectorIds.filter((id) => usedIdSet.has(id)));\r\n\r\n if (viewRelatedIds.length > 0) {\r\n const viewRelatedUsageInfo = this.iModel[_nativeDb].queryDefinitionElementUsage(viewRelatedIds);\r\n if (viewRelatedUsageInfo) {\r\n const usedViewRelatedIdSet: Id64Set = viewRelatedUsageInfo.usedIds ? Id64.toIdSet(viewRelatedUsageInfo.usedIds) : new Set<Id64String>();\r\n try {\r\n this.iModel[_nativeDb].beginPurgeOperation();\r\n deleteIfUnused(viewRelatedUsageInfo.displayStyleIds, usedViewRelatedIdSet);\r\n deleteIfUnused(viewRelatedUsageInfo.categorySelectorIds, usedViewRelatedIdSet);\r\n deleteIfUnused(viewRelatedUsageInfo.modelSelectorIds, usedViewRelatedIdSet);\r\n } finally {\r\n this.iModel[_nativeDb].endPurgeOperation();\r\n }\r\n\r\n viewRelatedIds.forEach((id) => {\r\n if (!usedViewRelatedIdSet.has(id))\r\n usedIdSet.delete(id);\r\n });\r\n }\r\n }\r\n }\r\n\r\n return usedIdSet;\r\n }\r\n\r\n /** Insert a new model into the iModel.\r\n * @param props The data for the new model.\r\n * @returns The newly inserted model's Id.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @throws IModelError if insertion fails.\r\n */\r\n public insertModel(props: ModelProps): Id64String {\r\n this.verifyWriteable();\r\n try {\r\n return props.id = this.iModel[_nativeDb].insertModel(props);\r\n } catch (err: any) {\r\n const error = new IModelError(err.errorNumber, `Error inserting model [${err.message}], class=${props.classFullName}`);\r\n error.cause = err;\r\n throw error;\r\n }\r\n }\r\n\r\n /** Update an existing model in the iModel.\r\n * @param props the properties of the model to change\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @throws IModelError if update fails.\r\n */\r\n public updateModel(props: UpdateModelOptions): void {\r\n this.verifyWriteable();\r\n try {\r\n if (props.id)\r\n this.iModel.models[_cache].delete(props.id);\r\n\r\n this.iModel[_nativeDb].updateModel(props);\r\n } catch (err: any) {\r\n const error = new IModelError(err.errorNumber, `Error updating model [${err.message}], id: ${props.id}`);\r\n error.cause = err;\r\n throw error;\r\n }\r\n }\r\n\r\n /** Update the geometry guid of a model.\r\n * @param modelId The Id of the model to update.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @throws IModelError if the update fails.\r\n */\r\n public updateGeometryGuid(modelId: Id64String): void {\r\n this.verifyWriteable();\r\n this.iModel.models[_cache].delete(modelId);\r\n const error = this.iModel[_nativeDb].updateModelGeometryGuid(modelId);\r\n if (error !== IModelStatus.Success)\r\n throw new IModelError(error, `Error updating geometry guid for model ${modelId}`);\r\n }\r\n\r\n /** Delete models from the iModel.\r\n * @param ids The Ids of the models to delete.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @throws IModelError if deletion fails.\r\n */\r\n public deleteModel(ids: Id64Arg): void {\r\n this.verifyWriteable();\r\n Id64.toIdSet(ids).forEach((id) => {\r\n try {\r\n this.iModel.models[_cache].delete(id);\r\n this.iModel.models[_instanceKeyCache].deleteById(id);\r\n this.iModel[_nativeDb].deleteModel(id);\r\n } catch (err: any) {\r\n const error = new IModelError(err.errorNumber, `Error deleting model [${err.message}], id: ${id}`);\r\n error.cause = err;\r\n throw error;\r\n }\r\n });\r\n }\r\n\r\n /** Insert a new relationship into the iModel.\r\n * @param props The properties of the new relationship.\r\n * @returns The Id of the newly inserted relationship.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @throws IModelError if the class is invalid for link-table insertion.\r\n */\r\n public insertRelationship(props: RelationshipProps): Id64String {\r\n this.verifyWriteable();\r\n if (!this.iModel[_nativeDb].isLinkTableRelationship(props.classFullName.replace(\".\", \":\")))\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, `Class '${props.classFullName}' must be a relationship class and it should be subclass of BisCore:ElementRefersToElements or BisCore:ElementDrivesElement.`);\r\n\r\n return props.id = this.iModel[_nativeDb].insertLinkTableRelationship(props);\r\n }\r\n\r\n /** Update an existing relationship in the iModel.\r\n * @param props the properties of the relationship to update.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n */\r\n public updateRelationship(props: RelationshipProps): void {\r\n this.verifyWriteable();\r\n this.iModel[_nativeDb].updateLinkTableRelationship(props);\r\n }\r\n\r\n /** Delete a relationship from the iModel.\r\n * @param props The properties of the relationship to delete.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n */\r\n public deleteRelationship(props: RelationshipProps): void {\r\n this.verifyWriteable();\r\n this.iModel[_nativeDb].deleteLinkTableRelationship(props);\r\n }\r\n\r\n /** Delete multiple relationships from the iModel.\r\n * @param props The properties of the relationships to delete.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n */\r\n public deleteRelationships(props: ReadonlyArray<RelationshipProps>): void {\r\n this.verifyWriteable();\r\n this.iModel[_nativeDb].deleteLinkTableRelationships(props);\r\n }\r\n\r\n\r\n /** Save a file property to the iModel.\r\n * @param prop The file property to save.\r\n * @param strValue String value.\r\n * @param blobVal Blob value.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n */\r\n public saveFileProperty(prop: FilePropertyProps, strValue: string | undefined, blobVal?: Uint8Array): void {\r\n this.verifyWriteable();\r\n const imodel = this.iModel;\r\n if (imodel.isBriefcaseDb()) {\r\n if (imodel.txns.isIndirectChanges) {\r\n throw new IModelError(IModelStatus.BadRequest, \"Cannot save file property while in an indirect change scope\");\r\n }\r\n }\r\n imodel[_nativeDb].saveFileProperty(prop, strValue, blobVal);\r\n }\r\n\r\n /** Delete a file property from the iModel.\r\n * @param prop The file property to delete.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n */\r\n public deleteFileProperty(prop: FilePropertyProps): void {\r\n this.saveFileProperty(prop, undefined, undefined);\r\n }\r\n\r\n /** Update the project extents of the iModel.\r\n * @param newExtents The new project extents.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @throws IModelError if extents are invalid.\r\n */\r\n public updateProjectExtents(newExtents: Range3dProps): void {\r\n this.verifyWriteable();\r\n const extents = Range3d.fromJSON(newExtents);\r\n if (extents.isNull)\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Invalid project extents\");\r\n\r\n this.iModel.projectExtents = extents;\r\n this.updateIModelProps();\r\n }\r\n\r\n /** Update the ECEF location of the iModel.\r\n * @param ecef The new ECEF location.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n */\r\n public updateEcefLocation(ecef: EcefLocationProps): void {\r\n this.verifyWriteable();\r\n this.iModel.setEcefLocation(new EcefLocation(ecef));\r\n this.updateIModelProps();\r\n }\r\n\r\n /** Update the iModel props in the database from the current in-memory state.\r\n * An unchanged geographic coordinate system is not replaced or re-resolved from its dictionary identifiers.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n */\r\n public updateIModelProps(): void {\r\n this.verifyWriteable();\r\n this.iModel[_updateIModelProps]();\r\n }\r\n\r\n private static readonly _settingPropNamespace = \"settings\";\r\n private static readonly _viewStoreProperty: FilePropertyProps = { namespace: \"itwinjs\", name: \"DefaultViewStore\" };\r\n\r\n /** Save a `SettingDictionary` in this iModel.\r\n * @param name The name for the SettingDictionary. If a dictionary by that name already exists, its value is replaced.\r\n * @param dict The SettingDictionary object to stringify and save.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @beta\r\n */\r\n public saveSettingDictionary(name: string, dict: SettingsContainer): void {\r\n this.verifyWriteable();\r\n this.iModel.withSqliteStatement(\"REPLACE INTO be_Prop(id,SubId,TxnMode,Namespace,Name,strData) VALUES(0,0,0,?,?,?)\", (stmt) => {\r\n stmt.bindString(1, EditTxn._settingPropNamespace);\r\n stmt.bindString(2, name);\r\n stmt.bindString(3, JSON.stringify(dict));\r\n stmt.stepForWrite();\r\n });\r\n this.saveChanges(\"add settings\");\r\n }\r\n\r\n /** Delete a SettingDictionary from this iModel.\r\n * @param name The name of the dictionary to delete.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @beta\r\n */\r\n public deleteSettingDictionary(name: string): void {\r\n this.verifyWriteable();\r\n this.iModel.withSqliteStatement(\"DELETE FROM be_Prop WHERE Namespace=? AND Name=?\", (stmt) => {\r\n stmt.bindString(1, EditTxn._settingPropNamespace);\r\n stmt.bindString(2, name);\r\n stmt.stepForWrite();\r\n });\r\n this.saveChanges(\"delete settings\");\r\n }\r\n\r\n /** Save a default ViewStore container reference in this iModel.\r\n * @param arg The cloud container properties for the ViewStore.\r\n * @throws EditTxnError if this EditTxn is not active.\r\n * @beta\r\n */\r\n public saveDefaultViewStore(arg: CloudSqlite.ContainerProps): void {\r\n this.verifyWriteable();\r\n const props = { baseUri: arg.baseUri, containerId: arg.containerId, storageType: arg.storageType }; // sanitize to only known properties\r\n this.saveFileProperty(EditTxn._viewStoreProperty, JSON.stringify(props));\r\n this.saveChanges(\"update default ViewStore\");\r\n }\r\n}\r\n\r\n/** Execute a callback within an explicit editing transaction. A new [[EditTxn]] is created, started,\r\n * and passed to `fn`. If `fn` returns normally (or its returned Promise resolves), the transaction\r\n * is committed. If `fn` throws (or its returned Promise rejects), the transaction is abandoned —\r\n * none of the changes made during the callback are saved — and the error is re-thrown.\r\n * If abandonment also throws, logging that secondary error is attempted without allowing a logging failure to replace the callback error.\r\n *\r\n * This is the recommended way to perform a scoped unit of work on an iModel. It ensures that\r\n * edits are committed atomically on success and rolled back on failure, without the caller needing\r\n * to manage `start` / `end` manually.\r\n *\r\n * @param iModel The iModel to edit.\r\n * @param fn A callback that receives the active [[EditTxn]] and performs edits.\r\n * @returns The value returned by `fn`.\r\n * @throws EditTxnError if the transaction cannot be started (e.g. unsaved changes or another EditTxn is active).\r\n * @throws Re-throws any error thrown by `fn` after abandoning the transaction.\r\n * @beta\r\n */\r\nexport function withEditTxn<T>(iModel: IModelDb, fn: (txn: EditTxn) => T): T;\r\n/** Execute a callback within an explicit editing transaction, supplying commit arguments.\r\n * @param iModel The iModel to edit.\r\n * @param saveArgs Description or structured arguments passed to [[EditTxn.saveChanges]] on save.\r\n * @param fn A callback that receives the active [[EditTxn]] and performs edits.\r\n * @returns The value returned by `fn`.\r\n * @beta\r\n */\r\nexport function withEditTxn<T>(iModel: IModelDb, saveArgs: string | SaveChangesArgs, fn: (txn: EditTxn) => T): T;\r\n/** Execute an async callback within an explicit editing transaction.\r\n * @param iModel The iModel to edit.\r\n * @param fn An async callback that receives the active [[EditTxn]] and performs edits.\r\n * @returns A Promise that resolves to the value returned by `fn`.\r\n * @beta\r\n */\r\nexport function withEditTxn<T>(iModel: IModelDb, fn: (txn: EditTxn) => Promise<T>): Promise<T>;\r\n/** Execute an async callback within an explicit editing transaction, supplying commit arguments.\r\n * @param iModel The iModel to edit.\r\n * @param saveArgs Description or structured arguments passed to [[EditTxn.saveChanges]] on save.\r\n * @param fn An async callback that receives the active [[EditTxn]] and performs edits.\r\n * @returns A Promise that resolves to the value returned by `fn`.\r\n * @beta\r\n */\r\nexport function withEditTxn<T>(iModel: IModelDb, saveArgs: string | SaveChangesArgs, fn: (txn: EditTxn) => Promise<T>): Promise<T>;\r\nexport function withEditTxn<T>(iModel: IModelDb, saveArgsOrFn: string | SaveChangesArgs | ((txn: EditTxn) => T | Promise<T>), maybeFn?: (txn: EditTxn) => T | Promise<T>): T | Promise<T> {\r\n const saveArgs = \"function\" === typeof saveArgsOrFn ? undefined : saveArgsOrFn;\r\n const fn = \"function\" === typeof saveArgsOrFn ? saveArgsOrFn : maybeFn;\r\n\r\n if (undefined === fn)\r\n throw new Error(\"withEditTxn requires a callback\");\r\n\r\n const txn = new EditTxn(iModel, \"\");\r\n txn.start();\r\n\r\n const abandonOnError = (error: unknown): never => {\r\n try {\r\n if (txn.isActive)\r\n txn.end(\"abandon\");\r\n } catch (abandonError) {\r\n try {\r\n Logger.logError(BackendLoggerCategory.IModelDb, abandonError);\r\n } catch {\r\n throw error;\r\n }\r\n }\r\n throw error;\r\n };\r\n\r\n try {\r\n const result = fn(txn);\r\n if (result instanceof Promise) {\r\n return result.then((value) => {\r\n txn.end(\"save\", saveArgs);\r\n return value;\r\n }, abandonOnError);\r\n }\r\n\r\n txn.end(\"save\", saveArgs);\r\n return result;\r\n } catch (err) {\r\n return abandonOnError(err);\r\n }\r\n}\r\n"]}
|
|
@@ -17,6 +17,7 @@ export interface GcsDbProps extends WorkspaceDbCloudProps {
|
|
|
17
17
|
* at [SettingsPriority.application]($backend)), which is useful for unit tests and other offline
|
|
18
18
|
* scenarios that don't require GCS data. GCS workspaces load lazily on first iModel open, so applying
|
|
19
19
|
* the override any time after `IModelHost.startup` is sufficient.
|
|
20
|
+
* Failed default workspace loads are retried on the next request that loads GCS workspaces.
|
|
20
21
|
*/
|
|
21
22
|
export declare class GeoCoordConfig {
|
|
22
23
|
/** array of cloud prefetch tasks that may be awaited to permit offline usage */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GeoCoordConfig.d.ts","sourceRoot":"","sources":["../../src/GeoCoordConfig.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAK9D,gBAAgB;AAChB,MAAM,WAAW,UAAW,SAAQ,qBAAqB;IACvD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAGD
|
|
1
|
+
{"version":3,"file":"GeoCoordConfig.d.ts","sourceRoot":"","sources":["../../src/GeoCoordConfig.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAK9D,gBAAgB;AAChB,MAAM,WAAW,UAAW,SAAQ,qBAAqB;IACvD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAGD;;;;;;;;;;GAUG;AACH,qBAAa,cAAc;IACzB,gFAAgF;IAChF,gBAAuB,UAAU,EAAE,WAAW,CAAC,aAAa,EAAE,CAAM;IACpE,gBAAuB,WAAW;;;;MAIhC;IAEF,OAAO,CAAC,MAAM,CAAC,eAAe;IAoC9B,OAAO,CAAC,MAAM,CAAC,OAAO;IAYtB,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAS;WAC3B,SAAS;WAKT,oBAAoB,IAAI,IAAI;WAK5B,aAAa,CAAC,QAAQ,EAAE,QAAQ;CAI/C"}
|
|
@@ -20,6 +20,7 @@ const makeSettingName = (name) => `${"itwin/core/gcs"}/${name}`;
|
|
|
20
20
|
* at [SettingsPriority.application]($backend)), which is useful for unit tests and other offline
|
|
21
21
|
* scenarios that don't require GCS data. GCS workspaces load lazily on first iModel open, so applying
|
|
22
22
|
* the override any time after `IModelHost.startup` is sufficient.
|
|
23
|
+
* Failed default workspace loads are retried on the next request that loads GCS workspaces.
|
|
23
24
|
*/
|
|
24
25
|
export class GeoCoordConfig {
|
|
25
26
|
/** array of cloud prefetch tasks that may be awaited to permit offline usage */
|
|
@@ -32,38 +33,43 @@ export class GeoCoordConfig {
|
|
|
32
33
|
static addGcsWorkspace(dbProps) {
|
|
33
34
|
// override to disable loading GCS data from workspaces
|
|
34
35
|
if (IModelHost.appWorkspace.settings.getBoolean(GeoCoordConfig.settingName.disableWorkspaces, false))
|
|
35
|
-
return;
|
|
36
|
+
return false;
|
|
36
37
|
try {
|
|
37
38
|
const ws = IModelHost.appWorkspace;
|
|
38
39
|
const container = ws.getContainer({ ...dbProps, accessToken: "" }); // all gcs containers are public so no accessToken is required
|
|
39
40
|
const cloudContainer = container.cloudContainer;
|
|
40
41
|
if (!cloudContainer?.isConnected) {
|
|
41
42
|
Logger.logError("GeoCoord", `could not load gcs database "${dbProps.dbName}"`);
|
|
42
|
-
return;
|
|
43
|
+
return false;
|
|
43
44
|
}
|
|
44
45
|
const gcsDbName = container.resolveDbFileName(dbProps);
|
|
45
46
|
const gcsDbProps = cloudContainer.queryDatabase(gcsDbName);
|
|
46
47
|
if (undefined === gcsDbProps)
|
|
47
48
|
throw new Error(`database "${gcsDbName}" not found in container "${dbProps.containerId}"`);
|
|
48
49
|
if (!IModelNative.platform.addGcsWorkspaceDb(gcsDbName, cloudContainer, dbProps.priority))
|
|
49
|
-
return; // already had this db
|
|
50
|
+
return true; // already had this db
|
|
50
51
|
Logger.logInfo(loggerCat, `loaded gcsDb "${gcsDbName}", from "${dbProps.baseUri}/${dbProps.containerId}" size=${gcsDbProps.totalBlocks}, local=${gcsDbProps.localBlocks}`);
|
|
51
52
|
if (true === dbProps.prefetch)
|
|
52
53
|
this.prefetches.push(CloudSqlite.startCloudPrefetch(cloudContainer, gcsDbName));
|
|
54
|
+
return true;
|
|
53
55
|
}
|
|
54
56
|
catch (e) {
|
|
55
57
|
let msg = `Cannot load GCS workspace (${e.errorNumber}): ${BentleyError.getErrorMessage(e)}`;
|
|
56
58
|
msg += `,container=${dbProps.baseUri}/${dbProps.containerId}, storage=${dbProps.storageType}, public=${dbProps.isPublic}, cacheDir=${IModelHost.cacheDir}`;
|
|
57
59
|
Logger.logError(loggerCat, msg);
|
|
60
|
+
return false;
|
|
58
61
|
}
|
|
59
62
|
}
|
|
60
63
|
static loadAll(settings, settingName) {
|
|
64
|
+
let loaded = true;
|
|
61
65
|
const dbProps = settings.getArray(settingName);
|
|
62
66
|
if (dbProps) {
|
|
63
67
|
for (const entry of dbProps) {
|
|
64
|
-
this.addGcsWorkspace(entry)
|
|
68
|
+
if (!this.addGcsWorkspace(entry))
|
|
69
|
+
loaded = false;
|
|
65
70
|
}
|
|
66
71
|
}
|
|
72
|
+
return loaded;
|
|
67
73
|
}
|
|
68
74
|
static _defaultDbsLoaded = false;
|
|
69
75
|
static onStartup() {
|
|
@@ -71,10 +77,8 @@ export class GeoCoordConfig {
|
|
|
71
77
|
this.prefetches.length = 0;
|
|
72
78
|
}
|
|
73
79
|
static loadDefaultDatabases() {
|
|
74
|
-
if (!this._defaultDbsLoaded)
|
|
75
|
-
this._defaultDbsLoaded =
|
|
76
|
-
this.loadAll(IModelHost.appWorkspace.settings, this.settingName.defaultDatabases);
|
|
77
|
-
}
|
|
80
|
+
if (!this._defaultDbsLoaded)
|
|
81
|
+
this._defaultDbsLoaded = this.loadAll(IModelHost.appWorkspace.settings, this.settingName.defaultDatabases);
|
|
78
82
|
}
|
|
79
83
|
static loadForImodel(settings) {
|
|
80
84
|
this.loadDefaultDatabases();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GeoCoordConfig.js","sourceRoot":"","sources":["../../src/GeoCoordConfig.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,MAAM,SAAS,GAAG,UAAU,CAAC;AAM7B,MAAM,eAAe,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,GAAG,gBAAgB,IAAI,IAAI,EAAE,CAAC;AAExE
|
|
1
|
+
{"version":3,"file":"GeoCoordConfig.js","sourceRoot":"","sources":["../../src/GeoCoordConfig.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,MAAM,SAAS,GAAG,UAAU,CAAC;AAM7B,MAAM,eAAe,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,GAAG,gBAAgB,IAAI,IAAI,EAAE,CAAC;AAExE;;;;;;;;;;GAUG;AACH,MAAM,OAAO,cAAc;IACzB,gFAAgF;IACzE,MAAM,CAAU,UAAU,GAAgC,EAAE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AC,MAAM,GAAG,CAAC,CAAC;IAC7B,CAAC;IAEM,MAAM,CAAC,oBAAoB;QAChC,IAAI,CAAC,IAAI,CAAC,iBAAiB;YACzB,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,QAAQ,EAAE,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;IAC/G,CAAC;IAEM,MAAM,CAAC,aAAa,CAAC,QAAkB;QAC5C,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC5B,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IACrD,CAAC","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 iModels\r\n */\r\n\r\nimport { BentleyError, Logger } from \"@itwin/core-bentley\";\r\nimport { CloudSqlite } from \"./CloudSqlite\";\r\nimport { IModelHost } from \"./IModelHost\";\r\nimport { Settings } from \"./workspace/Settings\";\r\nimport { WorkspaceDbCloudProps } from \"./workspace/Workspace\";\r\nimport { IModelNative } from \"./internal/NativePlatform\";\r\n\r\nconst loggerCat = \"GeoCoord\";\r\n\r\n/** @internal */\r\nexport interface GcsDbProps extends WorkspaceDbCloudProps {\r\n priority?: number;\r\n}\r\nconst makeSettingName = (name: string) => `${\"itwin/core/gcs\"}/${name}`;\r\n\r\n/**\r\n * Internal class to configure and load the gcs workspaces for an iModel.\r\n * @internal\r\n * @note GCS workspaces are loaded by default (the `disableWorkspaces` setting defaults to `false`). To\r\n * suppress loading them from cloud containers and the network requests they issue when iModels are\r\n * opened — override the `disableWorkspaces` setting (e.g. via [Settings.addDictionary]($backend)\r\n * at [SettingsPriority.application]($backend)), which is useful for unit tests and other offline\r\n * scenarios that don't require GCS data. GCS workspaces load lazily on first iModel open, so applying\r\n * the override any time after `IModelHost.startup` is sufficient.\r\n * Failed default workspace loads are retried on the next request that loads GCS workspaces.\r\n */\r\nexport class GeoCoordConfig {\r\n /** array of cloud prefetch tasks that may be awaited to permit offline usage */\r\n public static readonly prefetches: CloudSqlite.CloudPrefetch[] = [];\r\n public static readonly settingName = {\r\n databases: makeSettingName(\"databases\"),\r\n defaultDatabases: makeSettingName(\"default/databases\"),\r\n disableWorkspaces: makeSettingName(\"disableWorkspaces\"),\r\n };\r\n\r\n private static addGcsWorkspace(dbProps: GcsDbProps): boolean {\r\n // override to disable loading GCS data from workspaces\r\n if (IModelHost.appWorkspace.settings.getBoolean(GeoCoordConfig.settingName.disableWorkspaces, false))\r\n return false;\r\n\r\n try {\r\n const ws = IModelHost.appWorkspace;\r\n const container = ws.getContainer({ ...dbProps, accessToken: \"\" }); // all gcs containers are public so no accessToken is required\r\n const cloudContainer = container.cloudContainer;\r\n if (!cloudContainer?.isConnected) {\r\n Logger.logError(\"GeoCoord\", `could not load gcs database \"${dbProps.dbName}\"`);\r\n return false;\r\n }\r\n\r\n const gcsDbName = container.resolveDbFileName(dbProps);\r\n const gcsDbProps = cloudContainer.queryDatabase(gcsDbName);\r\n if (undefined === gcsDbProps)\r\n throw new Error(`database \"${gcsDbName}\" not found in container \"${dbProps.containerId}\"`);\r\n\r\n if (!IModelNative.platform.addGcsWorkspaceDb(gcsDbName, cloudContainer, dbProps.priority))\r\n return true; // already had this db\r\n\r\n Logger.logInfo(loggerCat, `loaded gcsDb \"${gcsDbName}\", from \"${dbProps.baseUri}/${dbProps.containerId}\" size=${gcsDbProps.totalBlocks}, local=${gcsDbProps.localBlocks}`);\r\n\r\n if (true === dbProps.prefetch)\r\n this.prefetches.push(CloudSqlite.startCloudPrefetch(cloudContainer, gcsDbName));\r\n\r\n return true;\r\n } catch (e: any) {\r\n let msg = `Cannot load GCS workspace (${e.errorNumber}): ${BentleyError.getErrorMessage(e)}`;\r\n msg += `,container=${dbProps.baseUri}/${dbProps.containerId}, storage=${dbProps.storageType}, public=${dbProps.isPublic}, cacheDir=${IModelHost.cacheDir}`;\r\n Logger.logError(loggerCat, msg);\r\n return false;\r\n }\r\n }\r\n\r\n private static loadAll(settings: Settings, settingName: string): boolean {\r\n let loaded = true;\r\n const dbProps = settings.getArray<GcsDbProps>(settingName);\r\n if (dbProps) {\r\n for (const entry of dbProps) {\r\n if (!this.addGcsWorkspace(entry))\r\n loaded = false;\r\n }\r\n }\r\n return loaded;\r\n }\r\n\r\n private static _defaultDbsLoaded = false;\r\n public static onStartup() {\r\n this._defaultDbsLoaded = false;\r\n this.prefetches.length = 0;\r\n }\r\n\r\n public static loadDefaultDatabases(): void {\r\n if (!this._defaultDbsLoaded)\r\n this._defaultDbsLoaded = this.loadAll(IModelHost.appWorkspace.settings, this.settingName.defaultDatabases);\r\n }\r\n\r\n public static loadForImodel(settings: Settings) {\r\n this.loadDefaultDatabases();\r\n this.loadAll(settings, this.settingName.databases);\r\n }\r\n}\r\n"]}
|
package/lib/esm/IModelDb.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { IModelJsNative } from "@bentley/imodeljs-native";
|
|
5
5
|
import { AccessToken, BeEvent, BentleyStatus, DbResult, GuidString, Id64Arg, Id64Array, Id64Set, Id64String, IModelStatus, LRUMap, OpenMode } from "@itwin/core-bentley";
|
|
6
|
-
import { AxisAlignedBox3d, BRepGeometryCreate, BriefcaseConnectionProps, BriefcaseId, ChangesetHealthStats, ChangesetIdWithIndex, Code, CodeProps, CreateEmptySnapshotIModelProps, CreateEmptyStandaloneIModelProps, CreateSnapshotIModelProps, EcefLocation, ECSchemaProps, ECSqlReader, ElementAspectProps, ElementGeometryCacheOperationRequestProps, ElementGeometryCacheRequestProps, ElementGeometryCacheResponseProps, ElementGeometryRequest, ElementGraphicsRequestProps, ElementLoadProps, ElementProps, EntityMetaData, EntityProps, EntityQueryParams, FilePropertyProps, FontMap, GeoCoordinatesRequestProps, GeoCoordinatesResponseProps, GeometryContainmentRequestProps, GeometryContainmentResponseProps, IModel, IModelCoordinatesRequestProps, IModelCoordinatesResponseProps, IModelTileTreeProps, LocalFileName, MassPropertiesRequestProps, MassPropertiesResponseProps, ModelExtentsProps, ModelProps, OpenBriefcaseProps, OpenCheckpointArgs, OpenSqliteArgs, PropertyCallback, QueryBinder, QueryOptions, SaveChangesArgs, SchemaState, SnapRequestProps, SnapResponseProps, SnapshotOpenOptions, SubCategoryResultRow, TextureData, TextureLoadProps, ThumbnailProps, UpgradeOptions, ViewDefinitionProps, ViewIdString, ViewQueryParams, ViewStateLoadProps, ViewStateProps } from "@itwin/core-common";
|
|
6
|
+
import { AxisAlignedBox3d, BRepGeometryCreate, BriefcaseConnectionProps, BriefcaseId, ChangesetHealthStats, ChangesetIdWithIndex, Code, CodeProps, CreateEmptySnapshotIModelProps, CreateEmptyStandaloneIModelProps, CreateSnapshotIModelProps, EcefLocation, ECSchemaProps, ECSqlReader, ElementAspectProps, ElementGeometryCacheOperationRequestProps, ElementGeometryCacheRequestProps, ElementGeometryCacheResponseProps, ElementGeometryRequest, ElementGraphicsRequestProps, ElementLoadProps, ElementProps, EntityMetaData, EntityProps, EntityQueryParams, FilePropertyProps, FontMap, GeoCoordinatesRequestProps, GeoCoordinatesResponseProps, GeometryContainmentRequestProps, GeometryContainmentResponseProps, IModel, IModelCoordinatesRequestProps, IModelCoordinatesResponseProps, IModelTileTreeProps, LocalFileName, MassPropertiesRequestProps, MassPropertiesResponseProps, ModelExtentsProps, ModelProps, OpenBriefcaseProps, OpenCheckpointArgs, OpenSqliteArgs, Persisted, PropertyCallback, QueryBinder, QueryOptions, SaveChangesArgs, SchemaState, SnapRequestProps, SnapResponseProps, SnapshotOpenOptions, SubCategoryResultRow, TextureData, TextureLoadProps, ThumbnailProps, UpgradeOptions, ViewDefinitionProps, ViewIdString, ViewQueryParams, ViewStateLoadProps, ViewStateProps } from "@itwin/core-common";
|
|
7
7
|
import { Range3d } from "@itwin/core-geometry";
|
|
8
8
|
import { PullChangesArgs, PushChangesArgs, RevertChangesArgs } from "./BriefcaseManager";
|
|
9
9
|
import { ChannelControl, ChannelUpgradeOptions } from "./ChannelControl";
|
|
@@ -31,7 +31,7 @@ import { Workspace } from "./workspace/Workspace";
|
|
|
31
31
|
import { LockControl } from "./LockControl";
|
|
32
32
|
import type { BlobContainer } from "./BlobContainerService";
|
|
33
33
|
import { IModelDbFonts } from "./IModelDbFonts";
|
|
34
|
-
import { _activeTxn, _cache, _close, _implicitTxn, _instanceKeyCache, _nativeDb, _resetIModelDb } from "./internal/Symbols";
|
|
34
|
+
import { _activeTxn, _cache, _close, _implicitTxn, _instanceKeyCache, _nativeDb, _refreshGeographicCoordinateSystem, _refreshIModelProps, _resetIModelDb, _updateIModelProps, _verifyTxnWrite } from "./internal/Symbols";
|
|
35
35
|
import { ECSpecVersion, ECVersion, type GetSchemaViewArgs, SchemaContext, SchemaView } from "@itwin/ecschema-metadata";
|
|
36
36
|
import { SchemaMap } from "./Schema";
|
|
37
37
|
import { ElementLRUCache, InstanceKeyLRUCache } from "./internal/ElementLRUCache";
|
|
@@ -356,6 +356,7 @@ export interface CloseIModelArgs {
|
|
|
356
356
|
*/
|
|
357
357
|
export declare abstract class IModelDb extends IModel {
|
|
358
358
|
private _initialized;
|
|
359
|
+
private _lastUpdatedGeographicCoordinateSystem?;
|
|
359
360
|
/** Keep track of open imodels to support `tryFind` for RPC purposes */
|
|
360
361
|
private static readonly _openDbs;
|
|
361
362
|
static readonly defaultLimit = 1000;
|
|
@@ -369,6 +370,7 @@ export declare abstract class IModelDb extends IModel {
|
|
|
369
370
|
private _relationships?;
|
|
370
371
|
private readonly _statementCache;
|
|
371
372
|
private readonly _sqliteStatementCache;
|
|
373
|
+
private readonly _queryMetadataCache;
|
|
372
374
|
private _codeSpecs?;
|
|
373
375
|
private _classMetaDataRegistry?;
|
|
374
376
|
private _jsClassMap?;
|
|
@@ -567,6 +569,17 @@ export declare abstract class IModelDb extends IModel {
|
|
|
567
569
|
protected beforeClose(): void;
|
|
568
570
|
/** @internal */
|
|
569
571
|
protected initializeIModelDb(when?: "pullMerge"): void;
|
|
572
|
+
/** Reload the cached iModel properties (extents, geolocation, name, etc.) from the database, e.g. after changesets were merged.
|
|
573
|
+
* @internal
|
|
574
|
+
*/
|
|
575
|
+
[_refreshIModelProps](): void;
|
|
576
|
+
/** @internal */
|
|
577
|
+
[_refreshGeographicCoordinateSystem](): void;
|
|
578
|
+
private _isRefreshingGeographicCoordinateSystem;
|
|
579
|
+
/** @internal */
|
|
580
|
+
[_verifyTxnWrite](): void;
|
|
581
|
+
/** @internal */
|
|
582
|
+
[_updateIModelProps](): void;
|
|
570
583
|
/** Returns true if this is a BriefcaseDb
|
|
571
584
|
* @see [[BriefcaseDb.open]]
|
|
572
585
|
*/
|
|
@@ -1318,7 +1331,7 @@ export declare namespace IModelDb {
|
|
|
1318
1331
|
* @throws [[IModelError]] if the model is not found or cannot be loaded.
|
|
1319
1332
|
* @see tryGetModelProps
|
|
1320
1333
|
*/
|
|
1321
|
-
getModelProps<T extends ModelProps>(id: Id64String): T
|
|
1334
|
+
getModelProps<T extends ModelProps>(id: Id64String): Persisted<T>;
|
|
1322
1335
|
/** Get the ModelProps with the specified identifier.
|
|
1323
1336
|
* @param modelId The Model identifier.
|
|
1324
1337
|
* @returns The ModelProps or `undefined` if the model is not found.
|
|
@@ -1326,7 +1339,7 @@ export declare namespace IModelDb {
|
|
|
1326
1339
|
* @note Useful for cases when a model may or may not exist and throwing an `Error` would be overkill.
|
|
1327
1340
|
* @see getModelProps
|
|
1328
1341
|
*/
|
|
1329
|
-
tryGetModelProps<T extends ModelProps>(id: Id64String): T | undefined;
|
|
1342
|
+
tryGetModelProps<T extends ModelProps>(id: Id64String): Persisted<T> | undefined;
|
|
1330
1343
|
/** Query for the last modified time for a [[Model]].
|
|
1331
1344
|
* @param modelId The Id of the model.
|
|
1332
1345
|
* @throws IModelError if `modelId` does not identify a model in the iModel.
|
|
@@ -1436,7 +1449,7 @@ export declare namespace IModelDb {
|
|
|
1436
1449
|
* @throws [[IModelError]] if the element is not found or cannot be loaded.
|
|
1437
1450
|
* @see tryGetElementProps
|
|
1438
1451
|
*/
|
|
1439
|
-
getElementProps<T extends ElementProps>(props: Id64String | GuidString | Code | ElementLoadProps): T
|
|
1452
|
+
getElementProps<T extends ElementProps>(props: Id64String | GuidString | Code | ElementLoadProps): Persisted<T>;
|
|
1440
1453
|
private resolveElementKey;
|
|
1441
1454
|
/** Get properties of an Element by Id, FederationGuid, or Code
|
|
1442
1455
|
* @returns The properties of the element or `undefined` if the element is not found.
|
|
@@ -1444,7 +1457,7 @@ export declare namespace IModelDb {
|
|
|
1444
1457
|
* @note Useful for cases when an element may or may not exist and throwing an `Error` would be overkill.
|
|
1445
1458
|
* @see getElementProps
|
|
1446
1459
|
*/
|
|
1447
|
-
tryGetElementProps<T extends ElementProps>(props: Id64String | GuidString | Code | ElementLoadProps): T | undefined;
|
|
1460
|
+
tryGetElementProps<T extends ElementProps>(props: Id64String | GuidString | Code | ElementLoadProps): Persisted<T> | undefined;
|
|
1448
1461
|
/** Get an element by Id, FederationGuid, or Code
|
|
1449
1462
|
* @param elementId either the element's Id, Code, or FederationGuid, or an ElementLoadProps
|
|
1450
1463
|
* @param elementClass Optional class to validate instance against. This parameter can accept abstract or concrete classes, but should be the same as the template (`T`) parameter.
|
|
@@ -1515,10 +1528,10 @@ export declare namespace IModelDb {
|
|
|
1515
1528
|
*/
|
|
1516
1529
|
deleteElement(ids: Id64Arg): void;
|
|
1517
1530
|
/**
|
|
1518
|
-
* Delete multiple elements from the iModel.
|
|
1531
|
+
* Delete multiple elements from the iModel in a single bulk operation. See [[EditTxn.deleteElements]].
|
|
1519
1532
|
* @param ids The ids of the elements to delete. All ids must be well-formed and valid [[Id64String]]s.
|
|
1520
|
-
* @param deleteOptions
|
|
1521
|
-
* @returns A result object
|
|
1533
|
+
* @param deleteOptions Deprecated and ignored; kept for backward compatibility of the signature.
|
|
1534
|
+
* @returns A result object describing the outcome of the operation and the elements that block it (if any).
|
|
1522
1535
|
* @throws [[ITwinError]] if any of the supplied ids are not well-formed/valid [[Id64String]]s.
|
|
1523
1536
|
* @deprecated in 5.1.9 - might be removed in next major version. Use EditTxn.deleteElements instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
|
|
1524
1537
|
* @beta
|