@itwin/core-backend 5.16.0-dev.7 → 5.16.0-dev.9

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 CHANGED
@@ -1,6 +1,13 @@
1
1
  # Change Log - @itwin/core-backend
2
2
 
3
- This log was last generated on Thu, 05 Nov 2026 17:48:51 GMT and should not be manually modified.
3
+ This log was last generated on Mon, 09 Nov 2026 16:53:07 GMT and should not be manually modified.
4
+
5
+ ## 5.15.1
6
+ Mon, 09 Nov 2026 16:52:11 GMT
7
+
8
+ ### Updates
9
+
10
+ - Expose raw SQLite changeset apply flags, a no-local-changes conflict policy, and custom conflict handlers through SQLiteDb.applyChangeset.
4
11
 
5
12
  ## 5.15.0
6
13
  Thu, 05 Nov 2026 17:47:36 GMT
@@ -10,11 +10,11 @@ import type { ChangeElementModelProps, ChangeElementParentProps, IModelDb, Inser
10
10
  import type { SettingsContainer } from "./workspace/Settings";
11
11
  /** Options for bulk deleting elements from an iModelDb.
12
12
  * @beta
13
- * @deprecated Options are no longer used and [[EditTxn.deleteElements]] ignores this argument.
13
+ * @deprecated in 5.15.0 - will not be removed until after 2027-11-05. Options are no longer used and [[EditTxn.deleteElements]] ignores this argument.
14
14
  */
15
15
  export interface BulkDeleteElementsArgs {
16
16
  /**
17
- * @deprecated Skipping FK constraint validation is no longer supported.
17
+ * @deprecated in 5.15.0 - will not be removed until after 2027-11-05. Skipping FK constraint validation is no longer supported.
18
18
  */
19
19
  skipFKConstraintValidations?: boolean;
20
20
  }
@@ -65,7 +65,7 @@ export interface BulkDeleteElementsResult {
65
65
  * Nothing was deleted, including requested ids that are not listed.
66
66
  * - On `DeletionFailed`: every requested id (the iModel may be partially modified; abandon the current txn).
67
67
  * - On `Success`: empty.
68
- * @deprecated Use `failures` for a more detailed failure report.
68
+ * @deprecated in 5.15.0 - will not be removed until after 2027-11-05. Use `failures` for a more detailed failure report.
69
69
  */
70
70
  failedIds: Id64Set;
71
71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esContent":["/*---------------------------------------------------------------------------------------------\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 Options are no longer used and [[EditTxn.deleteElements]] ignores this argument.\r\n */\r\nexport interface BulkDeleteElementsArgs {\r\n /**\r\n * @deprecated 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 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"]}
1
+ {"version":3,"file":"EditTxn.js","sourceRoot":"","sources":["../../src/EditTxn.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAg5B/F,kCAsCC;AAp7BD;;GAEG;AAEH,sDAA0I;AAC1I,oDAAmN;AACnN,wDAA6D;AAK7D,mEAAgE;AAChE,gDAA+K;AAa/K;;;GAGG;AACH,IAAY,uBASX;AATD,WAAY,uBAAuB;IACjC,8FAA8F;IAC9F,yGAA0B,CAAA;IAC1B,+EAA+E;IAC/E,2FAAmB,CAAA;IACnB,6IAA6I;IAC7I,6FAAoB,CAAA;IACpB,oDAAoD;IACpD,yFAAkB,CAAA;AACpB,CA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gBACd,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACvB,CAAC;QAAC,OAAO,YAAY,EAAE,CAAC;YACtB,IAAI,CAAC;gBACH,qBAAM,CAAC,QAAQ,CAAC,6CAAqB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;YAChE,CAAC;YAAC,MAAM,CAAC;gBACP,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC,CAAC;IAEF,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,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"]}
@@ -10,11 +10,11 @@ import type { ChangeElementModelProps, ChangeElementParentProps, IModelDb, Inser
10
10
  import type { SettingsContainer } from "./workspace/Settings";
11
11
  /** Options for bulk deleting elements from an iModelDb.
12
12
  * @beta
13
- * @deprecated Options are no longer used and [[EditTxn.deleteElements]] ignores this argument.
13
+ * @deprecated in 5.15.0 - will not be removed until after 2027-11-05. Options are no longer used and [[EditTxn.deleteElements]] ignores this argument.
14
14
  */
15
15
  export interface BulkDeleteElementsArgs {
16
16
  /**
17
- * @deprecated Skipping FK constraint validation is no longer supported.
17
+ * @deprecated in 5.15.0 - will not be removed until after 2027-11-05. Skipping FK constraint validation is no longer supported.
18
18
  */
19
19
  skipFKConstraintValidations?: boolean;
20
20
  }
@@ -65,7 +65,7 @@ export interface BulkDeleteElementsResult {
65
65
  * Nothing was deleted, including requested ids that are not listed.
66
66
  * - On `DeletionFailed`: every requested id (the iModel may be partially modified; abandon the current txn).
67
67
  * - On `Success`: empty.
68
- * @deprecated Use `failures` for a more detailed failure report.
68
+ * @deprecated in 5.15.0 - will not be removed until after 2027-11-05. Use `failures` for a more detailed failure report.
69
69
  */
70
70
  failedIds: Id64Set;
71
71
  }
@@ -1 +1 @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AC;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 Options are no longer used and [[EditTxn.deleteElements]] ignores this argument.\r\n */\r\nexport interface BulkDeleteElementsArgs {\r\n /**\r\n * @deprecated 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 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"]}
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,EAA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,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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/core-backend",
3
- "version": "5.16.0-dev.7",
3
+ "version": "5.16.0-dev.9",
4
4
  "description": "iTwin.js backend components",
5
5
  "main": "lib/cjs/core-backend.js",
6
6
  "module": "lib/esm/core-backend.js",
@@ -27,11 +27,11 @@
27
27
  },
28
28
  "peerDependencies": {
29
29
  "@opentelemetry/api": "^1.0.4",
30
- "@itwin/core-bentley": "5.16.0-dev.7",
31
- "@itwin/core-common": "5.16.0-dev.7",
32
- "@itwin/core-geometry": "5.16.0-dev.7",
33
- "@itwin/ecschema-metadata": "5.16.0-dev.7",
34
- "@itwin/core-quantity": "5.16.0-dev.7"
30
+ "@itwin/core-bentley": "5.16.0-dev.9",
31
+ "@itwin/core-common": "5.16.0-dev.9",
32
+ "@itwin/core-quantity": "5.16.0-dev.9",
33
+ "@itwin/core-geometry": "5.16.0-dev.9",
34
+ "@itwin/ecschema-metadata": "5.16.0-dev.9"
35
35
  },
36
36
  "peerDependenciesMeta": {
37
37
  "@opentelemetry/api": {
@@ -72,18 +72,18 @@
72
72
  "marked": "^14.1.3",
73
73
  "sql-formatter": "^15.4.6",
74
74
  "vite": "^6.4.4",
75
- "@itwin/build-tools": "5.16.0-dev.7",
76
- "@itwin/core-bentley": "5.16.0-dev.7",
77
- "@itwin/core-common": "5.16.0-dev.7",
78
- "@itwin/core-quantity": "5.16.0-dev.7",
79
- "@itwin/core-geometry": "5.16.0-dev.7",
80
- "@itwin/ecschema-locaters": "5.16.0-dev.7",
81
- "@itwin/ecschema-metadata": "5.16.0-dev.7",
82
- "@itwin/ecsql-common": "5.16.0-dev.7",
75
+ "@itwin/build-tools": "5.16.0-dev.9",
76
+ "@itwin/core-common": "5.16.0-dev.9",
77
+ "@itwin/core-bentley": "5.16.0-dev.9",
78
+ "@itwin/core-geometry": "5.16.0-dev.9",
79
+ "@itwin/core-quantity": "5.16.0-dev.9",
80
+ "@itwin/ecschema-locaters": "5.16.0-dev.9",
81
+ "@itwin/ecschema-metadata": "5.16.0-dev.9",
82
+ "@itwin/ecsql-common": "5.16.0-dev.9",
83
83
  "internal-tools": "3.0.0-dev.69"
84
84
  },
85
85
  "dependencies": {
86
- "@bentley/imodeljs-native": "5.16.16",
86
+ "@bentley/imodeljs-native": "5.16.18",
87
87
  "@itwin/object-storage-azure": "^3.0.4",
88
88
  "@azure/storage-blob": "^12.28.0",
89
89
  "form-data": "^4.0.6",