@itwin/core-backend 5.15.0-dev.2 → 5.15.0-dev.20
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 +52 -1
- package/lib/cjs/BlobContainerService.d.ts +2 -0
- package/lib/cjs/BlobContainerService.d.ts.map +1 -1
- package/lib/cjs/BlobContainerService.js.map +1 -1
- package/lib/cjs/BriefcaseManager.d.ts +4 -3
- package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
- package/lib/cjs/BriefcaseManager.js +39 -9
- package/lib/cjs/BriefcaseManager.js.map +1 -1
- package/lib/cjs/ChangeUnifier.d.ts +82 -0
- package/lib/cjs/ChangeUnifier.d.ts.map +1 -0
- package/lib/cjs/ChangeUnifier.js +163 -0
- package/lib/cjs/ChangeUnifier.js.map +1 -0
- package/lib/cjs/ChangesetReader.d.ts +21 -2
- package/lib/cjs/ChangesetReader.d.ts.map +1 -1
- package/lib/cjs/ChangesetReader.js +37 -1
- package/lib/cjs/ChangesetReader.js.map +1 -1
- package/lib/cjs/ChangesetReaderTypes.d.ts +1 -1
- package/lib/cjs/ChangesetReaderTypes.js.map +1 -1
- package/lib/cjs/CloudSqlite.d.ts +15 -0
- package/lib/cjs/CloudSqlite.d.ts.map +1 -1
- package/lib/cjs/CloudSqlite.js.map +1 -1
- package/lib/cjs/ECDb.d.ts +1 -0
- package/lib/cjs/ECDb.d.ts.map +1 -1
- package/lib/cjs/ECDb.js +4 -1
- package/lib/cjs/ECDb.js.map +1 -1
- package/lib/cjs/ECSqlRowExecutor.d.ts +3 -3
- package/lib/cjs/ECSqlRowExecutor.d.ts.map +1 -1
- package/lib/cjs/ECSqlRowExecutor.js +2 -2
- package/lib/cjs/ECSqlRowExecutor.js.map +1 -1
- package/lib/cjs/ECSqlStatement.d.ts +5 -0
- package/lib/cjs/ECSqlStatement.d.ts.map +1 -1
- package/lib/cjs/ECSqlStatement.js +15 -2
- package/lib/cjs/ECSqlStatement.js.map +1 -1
- package/lib/cjs/ECSqlSyncReader.d.ts.map +1 -1
- package/lib/cjs/ECSqlSyncReader.js +2 -2
- package/lib/cjs/ECSqlSyncReader.js.map +1 -1
- package/lib/cjs/EditTxn.d.ts +61 -19
- package/lib/cjs/EditTxn.d.ts.map +1 -1
- package/lib/cjs/EditTxn.js +84 -29
- package/lib/cjs/EditTxn.js.map +1 -1
- package/lib/cjs/Element.d.ts +29 -2
- package/lib/cjs/Element.d.ts.map +1 -1
- package/lib/cjs/Element.js +38 -2
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/GeoCoordConfig.d.ts +1 -0
- package/lib/cjs/GeoCoordConfig.d.ts.map +1 -1
- package/lib/cjs/GeoCoordConfig.js +12 -8
- package/lib/cjs/GeoCoordConfig.js.map +1 -1
- package/lib/cjs/GeographicCRSServices.d.ts +50 -2
- package/lib/cjs/GeographicCRSServices.d.ts.map +1 -1
- package/lib/cjs/GeographicCRSServices.js +11 -1
- package/lib/cjs/GeographicCRSServices.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +22 -9
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +54 -12
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/NativeHost.d.ts.map +1 -1
- package/lib/cjs/NativeHost.js +5 -1
- package/lib/cjs/NativeHost.js.map +1 -1
- package/lib/cjs/Relationship.d.ts +28 -0
- package/lib/cjs/Relationship.d.ts.map +1 -1
- package/lib/cjs/Relationship.js +78 -0
- package/lib/cjs/Relationship.js.map +1 -1
- package/lib/cjs/SchemaSync.d.ts.map +1 -1
- package/lib/cjs/SchemaSync.js +1 -0
- package/lib/cjs/SchemaSync.js.map +1 -1
- package/lib/cjs/TxnManager.d.ts +126 -89
- package/lib/cjs/TxnManager.d.ts.map +1 -1
- package/lib/cjs/TxnManager.js +114 -76
- package/lib/cjs/TxnManager.js.map +1 -1
- package/lib/cjs/ViewStateHydrator.d.ts.map +1 -1
- package/lib/cjs/ViewStateHydrator.js.map +1 -1
- package/lib/cjs/ViewStore.d.ts.map +1 -1
- package/lib/cjs/ViewStore.js +62 -19
- package/lib/cjs/ViewStore.js.map +1 -1
- package/lib/cjs/annotations/LeaderGeometry.d.ts.map +1 -1
- package/lib/cjs/annotations/LeaderGeometry.js +3 -0
- package/lib/cjs/annotations/LeaderGeometry.js.map +1 -1
- package/lib/cjs/core-backend.d.ts +1 -0
- package/lib/cjs/core-backend.d.ts.map +1 -1
- package/lib/cjs/core-backend.js +1 -0
- package/lib/cjs/core-backend.js.map +1 -1
- package/lib/cjs/internal/BriefcaseUtils.d.ts +19 -0
- package/lib/cjs/internal/BriefcaseUtils.d.ts.map +1 -0
- package/lib/cjs/internal/BriefcaseUtils.js +65 -0
- package/lib/cjs/internal/BriefcaseUtils.js.map +1 -0
- package/lib/cjs/internal/QueryMetadataCache.d.ts +44 -0
- package/lib/cjs/internal/QueryMetadataCache.d.ts.map +1 -0
- package/lib/cjs/internal/QueryMetadataCache.js +107 -0
- package/lib/cjs/internal/QueryMetadataCache.js.map +1 -0
- package/lib/cjs/internal/Symbols.d.ts +9 -0
- package/lib/cjs/internal/Symbols.d.ts.map +1 -1
- package/lib/cjs/internal/Symbols.js +10 -1
- package/lib/cjs/internal/Symbols.js.map +1 -1
- package/lib/cjs/internal/workspace/WorkspaceImpl.d.ts.map +1 -1
- package/lib/cjs/internal/workspace/WorkspaceImpl.js +20 -6
- package/lib/cjs/internal/workspace/WorkspaceImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +6 -6
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/lib/cjs/workspace/SettingsEditor.d.ts +4 -3
- package/lib/cjs/workspace/SettingsEditor.d.ts.map +1 -1
- package/lib/cjs/workspace/SettingsEditor.js +7 -5
- package/lib/cjs/workspace/SettingsEditor.js.map +1 -1
- package/lib/esm/BlobContainerService.d.ts +2 -0
- package/lib/esm/BlobContainerService.d.ts.map +1 -1
- package/lib/esm/BlobContainerService.js.map +1 -1
- package/lib/esm/BriefcaseManager.d.ts +4 -3
- package/lib/esm/BriefcaseManager.d.ts.map +1 -1
- package/lib/esm/BriefcaseManager.js +40 -10
- package/lib/esm/BriefcaseManager.js.map +1 -1
- package/lib/esm/ChangeUnifier.d.ts +82 -0
- package/lib/esm/ChangeUnifier.d.ts.map +1 -0
- package/lib/esm/ChangeUnifier.js +159 -0
- package/lib/esm/ChangeUnifier.js.map +1 -0
- package/lib/esm/ChangesetReader.d.ts +21 -2
- package/lib/esm/ChangesetReader.d.ts.map +1 -1
- package/lib/esm/ChangesetReader.js +38 -2
- package/lib/esm/ChangesetReader.js.map +1 -1
- package/lib/esm/ChangesetReaderTypes.d.ts +1 -1
- package/lib/esm/ChangesetReaderTypes.js.map +1 -1
- package/lib/esm/CloudSqlite.d.ts +15 -0
- package/lib/esm/CloudSqlite.d.ts.map +1 -1
- package/lib/esm/CloudSqlite.js.map +1 -1
- package/lib/esm/ECDb.d.ts +1 -0
- package/lib/esm/ECDb.d.ts.map +1 -1
- package/lib/esm/ECDb.js +4 -1
- package/lib/esm/ECDb.js.map +1 -1
- package/lib/esm/ECSqlRowExecutor.d.ts +3 -3
- package/lib/esm/ECSqlRowExecutor.d.ts.map +1 -1
- package/lib/esm/ECSqlRowExecutor.js +2 -2
- package/lib/esm/ECSqlRowExecutor.js.map +1 -1
- package/lib/esm/ECSqlStatement.d.ts +5 -0
- package/lib/esm/ECSqlStatement.d.ts.map +1 -1
- package/lib/esm/ECSqlStatement.js +15 -2
- package/lib/esm/ECSqlStatement.js.map +1 -1
- package/lib/esm/ECSqlSyncReader.d.ts.map +1 -1
- package/lib/esm/ECSqlSyncReader.js +3 -3
- package/lib/esm/ECSqlSyncReader.js.map +1 -1
- package/lib/esm/EditTxn.d.ts +61 -19
- package/lib/esm/EditTxn.d.ts.map +1 -1
- package/lib/esm/EditTxn.js +85 -30
- package/lib/esm/EditTxn.js.map +1 -1
- package/lib/esm/Element.d.ts +29 -2
- package/lib/esm/Element.d.ts.map +1 -1
- package/lib/esm/Element.js +41 -5
- package/lib/esm/Element.js.map +1 -1
- package/lib/esm/GeoCoordConfig.d.ts +1 -0
- package/lib/esm/GeoCoordConfig.d.ts.map +1 -1
- package/lib/esm/GeoCoordConfig.js +12 -8
- package/lib/esm/GeoCoordConfig.js.map +1 -1
- package/lib/esm/GeographicCRSServices.d.ts +50 -2
- package/lib/esm/GeographicCRSServices.d.ts.map +1 -1
- package/lib/esm/GeographicCRSServices.js +10 -1
- package/lib/esm/GeographicCRSServices.js.map +1 -1
- package/lib/esm/IModelDb.d.ts +22 -9
- package/lib/esm/IModelDb.d.ts.map +1 -1
- package/lib/esm/IModelDb.js +56 -14
- package/lib/esm/IModelDb.js.map +1 -1
- package/lib/esm/NativeHost.d.ts.map +1 -1
- package/lib/esm/NativeHost.js +5 -1
- package/lib/esm/NativeHost.js.map +1 -1
- package/lib/esm/Relationship.d.ts +28 -0
- package/lib/esm/Relationship.d.ts.map +1 -1
- package/lib/esm/Relationship.js +78 -0
- package/lib/esm/Relationship.js.map +1 -1
- package/lib/esm/SchemaSync.d.ts.map +1 -1
- package/lib/esm/SchemaSync.js +1 -0
- package/lib/esm/SchemaSync.js.map +1 -1
- package/lib/esm/TxnManager.d.ts +126 -89
- package/lib/esm/TxnManager.d.ts.map +1 -1
- package/lib/esm/TxnManager.js +116 -78
- package/lib/esm/TxnManager.js.map +1 -1
- package/lib/esm/ViewStateHydrator.d.ts.map +1 -1
- package/lib/esm/ViewStateHydrator.js.map +1 -1
- package/lib/esm/ViewStore.d.ts.map +1 -1
- package/lib/esm/ViewStore.js +62 -19
- package/lib/esm/ViewStore.js.map +1 -1
- package/lib/esm/annotations/LeaderGeometry.d.ts.map +1 -1
- package/lib/esm/annotations/LeaderGeometry.js +3 -0
- package/lib/esm/annotations/LeaderGeometry.js.map +1 -1
- package/lib/esm/core-backend.d.ts +1 -0
- package/lib/esm/core-backend.d.ts.map +1 -1
- package/lib/esm/core-backend.js +1 -0
- package/lib/esm/core-backend.js.map +1 -1
- package/lib/esm/internal/BriefcaseUtils.d.ts +19 -0
- package/lib/esm/internal/BriefcaseUtils.d.ts.map +1 -0
- package/lib/esm/internal/BriefcaseUtils.js +61 -0
- package/lib/esm/internal/BriefcaseUtils.js.map +1 -0
- package/lib/esm/internal/QueryMetadataCache.d.ts +44 -0
- package/lib/esm/internal/QueryMetadataCache.d.ts.map +1 -0
- package/lib/esm/internal/QueryMetadataCache.js +103 -0
- package/lib/esm/internal/QueryMetadataCache.js.map +1 -0
- package/lib/esm/internal/Symbols.d.ts +9 -0
- package/lib/esm/internal/Symbols.d.ts.map +1 -1
- package/lib/esm/internal/Symbols.js +9 -0
- package/lib/esm/internal/Symbols.js.map +1 -1
- package/lib/esm/internal/workspace/WorkspaceImpl.d.ts.map +1 -1
- package/lib/esm/internal/workspace/WorkspaceImpl.js +20 -6
- package/lib/esm/internal/workspace/WorkspaceImpl.js.map +1 -1
- package/lib/esm/rpc-impl/IModelReadRpcImpl.d.ts +6 -6
- package/lib/esm/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -1
- package/lib/esm/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/lib/esm/test/annotations/LeaderGeometry.test.js +15 -1
- package/lib/esm/test/annotations/LeaderGeometry.test.js.map +1 -1
- package/lib/esm/test/ecdb/ConcurrentQuery.test.js +144 -30
- package/lib/esm/test/ecdb/ConcurrentQuery.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECSqlSyncReader.test.js +140 -0
- package/lib/esm/test/ecdb/ECSqlSyncReader.test.js.map +1 -1
- package/lib/esm/test/ecdb/QueryMetadataCache.test.d.ts +2 -0
- package/lib/esm/test/ecdb/QueryMetadataCache.test.d.ts.map +1 -0
- package/lib/esm/test/ecdb/QueryMetadataCache.test.js +630 -0
- package/lib/esm/test/ecdb/QueryMetadataCache.test.js.map +1 -0
- package/lib/esm/test/element/DeleteDefinitionElements.test.js +403 -249
- package/lib/esm/test/element/DeleteDefinitionElements.test.js.map +1 -1
- package/lib/esm/test/element/ElementSubModelInsert.test.d.ts +2 -0
- package/lib/esm/test/element/ElementSubModelInsert.test.d.ts.map +1 -0
- package/lib/esm/test/element/ElementSubModelInsert.test.js +183 -0
- package/lib/esm/test/element/ElementSubModelInsert.test.js.map +1 -0
- package/lib/esm/test/element/RelationshipBatchLookup.test.d.ts +2 -0
- package/lib/esm/test/element/RelationshipBatchLookup.test.d.ts.map +1 -0
- package/lib/esm/test/element/RelationshipBatchLookup.test.js +202 -0
- package/lib/esm/test/element/RelationshipBatchLookup.test.js.map +1 -0
- package/lib/esm/test/hubaccess/BriefcaseManager.test.js +187 -1
- package/lib/esm/test/hubaccess/BriefcaseManager.test.js.map +1 -1
- package/lib/esm/test/hubaccess/SchemaImportOrphanColumns.test.d.ts +2 -0
- package/lib/esm/test/hubaccess/SchemaImportOrphanColumns.test.d.ts.map +1 -0
- package/lib/esm/test/hubaccess/SchemaImportOrphanColumns.test.js +142 -0
- package/lib/esm/test/hubaccess/SchemaImportOrphanColumns.test.js.map +1 -0
- package/lib/esm/test/imodel/IModelGeolocation.test.js +13 -11
- package/lib/esm/test/imodel/IModelGeolocation.test.js.map +1 -1
- package/lib/esm/test/imodel/IModelProps.test.d.ts +2 -0
- package/lib/esm/test/imodel/IModelProps.test.d.ts.map +1 -0
- package/lib/esm/test/imodel/IModelProps.test.js +411 -0
- package/lib/esm/test/imodel/IModelProps.test.js.map +1 -0
- package/lib/esm/test/schema/SchemaViewPropertyOverrides.test.d.ts +2 -0
- package/lib/esm/test/schema/SchemaViewPropertyOverrides.test.d.ts.map +1 -0
- package/lib/esm/test/schema/SchemaViewPropertyOverrides.test.js +240 -0
- package/lib/esm/test/schema/SchemaViewPropertyOverrides.test.js.map +1 -0
- package/lib/esm/test/schema/SchemaViewValidation.test.js +2 -8
- package/lib/esm/test/schema/SchemaViewValidation.test.js.map +1 -1
- package/lib/esm/test/standalone/BriefcaseManagerDelete.test.d.ts +2 -0
- package/lib/esm/test/standalone/BriefcaseManagerDelete.test.d.ts.map +1 -0
- package/lib/esm/test/standalone/BriefcaseManagerDelete.test.js +159 -0
- package/lib/esm/test/standalone/BriefcaseManagerDelete.test.js.map +1 -0
- package/lib/esm/test/standalone/ChangeUnifier.test.d.ts +2 -0
- package/lib/esm/test/standalone/ChangeUnifier.test.d.ts.map +1 -0
- package/lib/esm/test/standalone/ChangeUnifier.test.js +732 -0
- package/lib/esm/test/standalone/ChangeUnifier.test.js.map +1 -0
- package/lib/esm/test/standalone/DeleteElements.test.js +962 -83
- package/lib/esm/test/standalone/DeleteElements.test.js.map +1 -1
- package/lib/esm/test/standalone/EditTxn.test.js +72 -1
- package/lib/esm/test/standalone/EditTxn.test.js.map +1 -1
- package/lib/esm/test/standalone/GeoCoordConfig.test.d.ts +2 -0
- package/lib/esm/test/standalone/GeoCoordConfig.test.d.ts.map +1 -0
- package/lib/esm/test/standalone/GeoCoordConfig.test.js +158 -0
- package/lib/esm/test/standalone/GeoCoordConfig.test.js.map +1 -0
- package/lib/esm/test/standalone/SessionApplyIndirect.test.d.ts +2 -0
- package/lib/esm/test/standalone/SessionApplyIndirect.test.d.ts.map +1 -0
- package/lib/esm/test/standalone/SessionApplyIndirect.test.js +211 -0
- package/lib/esm/test/standalone/SessionApplyIndirect.test.js.map +1 -0
- package/lib/esm/test/standalone/ViewStoreDb.test.js +53 -0
- package/lib/esm/test/standalone/ViewStoreDb.test.js.map +1 -1
- package/lib/esm/test/workspace/SettingsContainers.test.d.ts +2 -0
- package/lib/esm/test/workspace/SettingsContainers.test.d.ts.map +1 -0
- package/lib/esm/test/workspace/SettingsContainers.test.js +95 -0
- package/lib/esm/test/workspace/SettingsContainers.test.js.map +1 -0
- package/lib/esm/workspace/SettingsEditor.d.ts +4 -3
- package/lib/esm/workspace/SettingsEditor.d.ts.map +1 -1
- package/lib/esm/workspace/SettingsEditor.js +7 -5
- package/lib/esm/workspace/SettingsEditor.js.map +1 -1
- package/package.json +18 -18
package/lib/esm/EditTxn.d.ts
CHANGED
|
@@ -10,34 +10,62 @@ import type { ChangeElementModelProps, ChangeElementParentProps, IModelDb, Inser
|
|
|
10
10
|
import type { SettingsContainer } from "./workspace/Settings";
|
|
11
11
|
/** Options for bulk deleting elements from an iModelDb.
|
|
12
12
|
* @beta
|
|
13
|
+
* @deprecated Options are no longer used and [[EditTxn.deleteElements]] ignores this argument.
|
|
13
14
|
*/
|
|
14
15
|
export interface BulkDeleteElementsArgs {
|
|
15
16
|
/**
|
|
16
|
-
*
|
|
17
|
-
* This will improve performance, but if the user supplies elements which have FK constraint violations, it will result in the delete failing and an eventual rollback.
|
|
17
|
+
* @deprecated Skipping FK constraint validation is no longer supported.
|
|
18
18
|
*/
|
|
19
19
|
skipFKConstraintValidations?: boolean;
|
|
20
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Why an element could not be deleted by [[EditTxn.deleteElements]].
|
|
23
|
+
* @beta
|
|
24
|
+
*/
|
|
25
|
+
export declare enum BulkDeleteFailureReason {
|
|
26
|
+
/** A row outside the delete set references it via a NO ACTION / RESTRICT / SET DEFAULT FK. */
|
|
27
|
+
ReferencedByForeignKey = 0,
|
|
28
|
+
/** It is a DefinitionElement still used by elements outside the delete set. */
|
|
29
|
+
DefinitionInUse = 1,
|
|
30
|
+
/** It is one of the elements every iModel must keep: the root Subject, the DictionaryModel partition or the RealityDataSources partition. */
|
|
31
|
+
ProtectedElement = 2,
|
|
32
|
+
/** Its handler belongs to a read-only DgnDomain. */
|
|
33
|
+
ReadOnlyDomain = 3
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* One element that could not be deleted by [[EditTxn.deleteElements]], and why.
|
|
37
|
+
* @beta
|
|
38
|
+
*/
|
|
39
|
+
export interface BulkDeleteFailure {
|
|
40
|
+
/** The id of the element that could not be deleted. */
|
|
41
|
+
elementId: Id64String;
|
|
42
|
+
/** Why the element could not be deleted. */
|
|
43
|
+
reason: BulkDeleteFailureReason;
|
|
44
|
+
}
|
|
21
45
|
/**
|
|
22
46
|
* Result of a bulk element delete operation.
|
|
23
47
|
* @beta
|
|
24
48
|
*/
|
|
25
49
|
export interface BulkDeleteElementsResult {
|
|
26
|
-
/**
|
|
27
|
-
* Overall status of the bulk delete operation.
|
|
28
|
-
* - `Success`: All elements were deleted successfully. `failedIds` will be empty.
|
|
29
|
-
* - `PartialSuccess`: Some elements were deleted, but others failed. `failedIds` contains the ids that could not be deleted.
|
|
30
|
-
* - `DeletionFailed`: The delete operation failed entirely (e.g. due to an FK constraint violation). `failedIds` contains the ids that could not be deleted.
|
|
31
|
-
*/
|
|
50
|
+
/** Overall status of the bulk delete operation. See [[BulkDeleteElementsStatus]]. */
|
|
32
51
|
status: BulkDeleteElementsStatus;
|
|
52
|
+
/** The raw SQLite result code from the underlying SQL DELETE. Only meaningful when `status === DeletionFailed`. */
|
|
53
|
+
sqlDeleteStatus: DbResult;
|
|
33
54
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
55
|
+
* One entry per element that blocks the deletion, with the reason. Only populated on `ConstraintViolation`.
|
|
56
|
+
* Empty on `Success` and `DeletionFailed`.
|
|
57
|
+
* Because the whole expanded delete set is validated, a reported element may be a child or sub-model member
|
|
58
|
+
* that was not in the requested ids; its requested ancestor is not listed separately.
|
|
36
59
|
*/
|
|
37
|
-
|
|
60
|
+
failures: BulkDeleteFailure[];
|
|
38
61
|
/**
|
|
39
62
|
* The set of element ids that could not be deleted.
|
|
40
|
-
*
|
|
63
|
+
* - On `ConstraintViolation`: the unique element ids appearing in `failures`. May include cascaded descendants
|
|
64
|
+
* that were not in the requested ids, so this is not guaranteed to be a subset of the input. Never empty.
|
|
65
|
+
* Nothing was deleted, including requested ids that are not listed.
|
|
66
|
+
* - On `DeletionFailed`: every requested id (the iModel may be partially modified; abandon the current txn).
|
|
67
|
+
* - On `Success`: empty.
|
|
68
|
+
* @deprecated Use `failures` for a more detailed failure report.
|
|
41
69
|
*/
|
|
42
70
|
failedIds: Id64Set;
|
|
43
71
|
}
|
|
@@ -48,9 +76,9 @@ export interface BulkDeleteElementsResult {
|
|
|
48
76
|
export declare enum BulkDeleteElementsStatus {
|
|
49
77
|
/** All supplied elements were deleted successfully. */
|
|
50
78
|
Success = 0,
|
|
51
|
-
/**
|
|
52
|
-
|
|
53
|
-
/**
|
|
79
|
+
/** Nothing was deleted because some elements in the (expanded) delete set are still referenced from outside the set; see `failures` for the violators. */
|
|
80
|
+
ConstraintViolation = 1,
|
|
81
|
+
/** An internal error occurred. The iModel may be partially modified; the caller must abandon the current txn. `failures` will be empty. */
|
|
54
82
|
DeletionFailed = 2
|
|
55
83
|
}
|
|
56
84
|
/**
|
|
@@ -96,6 +124,7 @@ export declare class EditTxn {
|
|
|
96
124
|
verifyWriteable(): void;
|
|
97
125
|
/** Start this EditTxn, making it the active transaction for the iModel.
|
|
98
126
|
* @throws EditTxnError if this EditTxn is already active, another EditTxn is already active, or if unsaved changes are present.
|
|
127
|
+
* @throws IModelError if the geographic coordinate system is being restored.
|
|
99
128
|
*/
|
|
100
129
|
start(): void;
|
|
101
130
|
/** End this EditTxn, either by saving or abandoning the changes.
|
|
@@ -103,6 +132,7 @@ export declare class EditTxn {
|
|
|
103
132
|
* @param args Save changes arguments when saving.
|
|
104
133
|
* @throws EditTxnError if this EditTxn is not active.
|
|
105
134
|
* @throws IModelError if saving changes fails.
|
|
135
|
+
* @throws Re-throws any error propagated by a geographic coordinate system restoration listener after completing abandonment.
|
|
106
136
|
*/
|
|
107
137
|
end(): void;
|
|
108
138
|
end(mode: "save" | "abandon", args?: string | SaveChangesArgs): void;
|
|
@@ -117,6 +147,7 @@ export declare class EditTxn {
|
|
|
117
147
|
* @throws EditTxnError if this EditTxn is not active.
|
|
118
148
|
*/
|
|
119
149
|
abandonChanges(): void;
|
|
150
|
+
private abandonDatabaseChanges;
|
|
120
151
|
/** Save changes with additional arguments.
|
|
121
152
|
* @param args Save changes arguments.
|
|
122
153
|
* @throws EditTxnError if this EditTxn is not active.
|
|
@@ -198,14 +229,23 @@ export declare class EditTxn {
|
|
|
198
229
|
*/
|
|
199
230
|
private collectSubtreeIds;
|
|
200
231
|
/**
|
|
201
|
-
* Delete multiple elements from the iModel.
|
|
232
|
+
* Delete multiple elements from the iModel in a single bulk operation.
|
|
233
|
+
*
|
|
234
|
+
* Child elements and sub-model contents of the requested elements are deleted along with them.
|
|
235
|
+
*
|
|
236
|
+
* The operation is all-or-nothing:
|
|
237
|
+
* - On `Success`, all elements (and their children / sub-model contents) were deleted.
|
|
238
|
+
* - On `ConstraintViolation`, nothing was deleted and [[BulkDeleteElementsResult.failures]] lists every element in the
|
|
239
|
+
* expanded delete set that is still referenced from outside the set, and why. Fix or include those referencing elements and retry.
|
|
240
|
+
* - On `DeletionFailed` (an unexpected SQLite error) the iModel may be partially modified and the caller must abandon the current txn.
|
|
241
|
+
*
|
|
202
242
|
* @param ids The ids of the elements to delete. All ids must be well-formed and valid [[Id64String]]s.
|
|
203
|
-
* @param
|
|
204
|
-
* @returns A result object
|
|
243
|
+
* @param _deleteOptions Deprecated and ignored; kept for backward compatibility of the signature.
|
|
244
|
+
* @returns A result object describing the outcome of the operation and the elements that block it (if any).
|
|
205
245
|
* @throws [[ITwinError]] if any of the supplied ids are not well-formed/valid [[Id64String]]s.
|
|
206
246
|
* @beta
|
|
207
247
|
*/
|
|
208
|
-
deleteElements(ids: Id64Array,
|
|
248
|
+
deleteElements(ids: Id64Array, _deleteOptions?: BulkDeleteElementsArgs): BulkDeleteElementsResult;
|
|
209
249
|
/** Insert a new aspect into the iModel.
|
|
210
250
|
* @param aspectProps The properties of the new aspect.
|
|
211
251
|
* @returns The newly inserted aspect Id.
|
|
@@ -303,6 +343,7 @@ export declare class EditTxn {
|
|
|
303
343
|
*/
|
|
304
344
|
updateEcefLocation(ecef: EcefLocationProps): void;
|
|
305
345
|
/** Update the iModel props in the database from the current in-memory state.
|
|
346
|
+
* An unchanged geographic coordinate system is not replaced or re-resolved from its dictionary identifiers.
|
|
306
347
|
* @throws EditTxnError if this EditTxn is not active.
|
|
307
348
|
*/
|
|
308
349
|
updateIModelProps(): void;
|
|
@@ -332,6 +373,7 @@ export declare class EditTxn {
|
|
|
332
373
|
* and passed to `fn`. If `fn` returns normally (or its returned Promise resolves), the transaction
|
|
333
374
|
* is committed. If `fn` throws (or its returned Promise rejects), the transaction is abandoned —
|
|
334
375
|
* none of the changes made during the callback are saved — and the error is re-thrown.
|
|
376
|
+
* If abandonment also throws, logging that secondary error is attempted without allowing a logging failure to replace the callback error.
|
|
335
377
|
*
|
|
336
378
|
* This is the recommended way to perform a scoped unit of work on an iModel. It ensures that
|
|
337
379
|
* edits are committed atomically on success and rolled back on failure, without the caller needing
|
package/lib/esm/EditTxn.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditTxn.d.ts","sourceRoot":"","sources":["../../src/EditTxn.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAQ,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"EditTxn.d.ts","sourceRoot":"","sources":["../../src/EditTxn.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAQ,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAA8C,MAAM,qBAAqB,CAAC;AAC1I,OAAO,EAAgB,iBAAiB,EAAgB,kBAAkB,EAAgB,YAAY,EAAE,iBAAiB,EAAe,UAAU,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACnN,OAAO,EAAW,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,KAAK,EAAE,uBAAuB,E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IG;IACI,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAUlD;;;;OAIG;IACI,oBAAoB,CAAC,GAAG,EAAE,WAAW,CAAC,cAAc,GAAG,IAAI;CAMnE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;AAC7E;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,eAAe,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;AACjH;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAC/F;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,eAAe,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC"}
|
package/lib/esm/EditTxn.js
CHANGED
|
@@ -5,10 +5,26 @@
|
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module iModels
|
|
7
7
|
*/
|
|
8
|
-
import { DbResult, Id64, IModelStatus, ITwinError, OpenMode } from "@itwin/core-bentley";
|
|
8
|
+
import { DbResult, Id64, IModelStatus, ITwinError, Logger, OpenMode } from "@itwin/core-bentley";
|
|
9
9
|
import { EcefLocation, EditTxnError, ElementError, IModelError } from "@itwin/core-common";
|
|
10
10
|
import { Range3d } from "@itwin/core-geometry";
|
|
11
|
-
import {
|
|
11
|
+
import { BackendLoggerCategory } from "./BackendLoggerCategory";
|
|
12
|
+
import { _activeTxn, _cache, _instanceKeyCache, _nativeDb, _refreshGeographicCoordinateSystem, _updateIModelProps, _verifyChannel, _verifyTxnWrite } from "./internal/Symbols";
|
|
13
|
+
/**
|
|
14
|
+
* Why an element could not be deleted by [[EditTxn.deleteElements]].
|
|
15
|
+
* @beta
|
|
16
|
+
*/
|
|
17
|
+
export var BulkDeleteFailureReason;
|
|
18
|
+
(function (BulkDeleteFailureReason) {
|
|
19
|
+
/** A row outside the delete set references it via a NO ACTION / RESTRICT / SET DEFAULT FK. */
|
|
20
|
+
BulkDeleteFailureReason[BulkDeleteFailureReason["ReferencedByForeignKey"] = 0] = "ReferencedByForeignKey";
|
|
21
|
+
/** It is a DefinitionElement still used by elements outside the delete set. */
|
|
22
|
+
BulkDeleteFailureReason[BulkDeleteFailureReason["DefinitionInUse"] = 1] = "DefinitionInUse";
|
|
23
|
+
/** It is one of the elements every iModel must keep: the root Subject, the DictionaryModel partition or the RealityDataSources partition. */
|
|
24
|
+
BulkDeleteFailureReason[BulkDeleteFailureReason["ProtectedElement"] = 2] = "ProtectedElement";
|
|
25
|
+
/** Its handler belongs to a read-only DgnDomain. */
|
|
26
|
+
BulkDeleteFailureReason[BulkDeleteFailureReason["ReadOnlyDomain"] = 3] = "ReadOnlyDomain";
|
|
27
|
+
})(BulkDeleteFailureReason || (BulkDeleteFailureReason = {}));
|
|
12
28
|
/**
|
|
13
29
|
* Status of a bulk element delete operation, mirroring the C++ `BulkDeleteStatus` enum.
|
|
14
30
|
* @beta
|
|
@@ -17,9 +33,9 @@ export var BulkDeleteElementsStatus;
|
|
|
17
33
|
(function (BulkDeleteElementsStatus) {
|
|
18
34
|
/** All supplied elements were deleted successfully. */
|
|
19
35
|
BulkDeleteElementsStatus[BulkDeleteElementsStatus["Success"] = 0] = "Success";
|
|
20
|
-
/**
|
|
21
|
-
BulkDeleteElementsStatus[BulkDeleteElementsStatus["
|
|
22
|
-
/**
|
|
36
|
+
/** Nothing was deleted because some elements in the (expanded) delete set are still referenced from outside the set; see `failures` for the violators. */
|
|
37
|
+
BulkDeleteElementsStatus[BulkDeleteElementsStatus["ConstraintViolation"] = 1] = "ConstraintViolation";
|
|
38
|
+
/** An internal error occurred. The iModel may be partially modified; the caller must abandon the current txn. `failures` will be empty. */
|
|
23
39
|
BulkDeleteElementsStatus[BulkDeleteElementsStatus["DeletionFailed"] = 2] = "DeletionFailed";
|
|
24
40
|
})(BulkDeleteElementsStatus || (BulkDeleteElementsStatus = {}));
|
|
25
41
|
/**
|
|
@@ -68,14 +84,17 @@ export class EditTxn {
|
|
|
68
84
|
this.description = description;
|
|
69
85
|
}
|
|
70
86
|
verifyWriteable() {
|
|
87
|
+
this.iModel[_verifyTxnWrite]();
|
|
71
88
|
// Explicit transactions must always be active before writing.
|
|
72
89
|
if (!this.isActive)
|
|
73
90
|
EditTxnError.throwError("not-active", "EditTxn is not active", this.iModel.key);
|
|
74
91
|
}
|
|
75
92
|
/** Start this EditTxn, making it the active transaction for the iModel.
|
|
76
93
|
* @throws EditTxnError if this EditTxn is already active, another EditTxn is already active, or if unsaved changes are present.
|
|
94
|
+
* @throws IModelError if the geographic coordinate system is being restored.
|
|
77
95
|
*/
|
|
78
96
|
start() {
|
|
97
|
+
this.iModel[_verifyTxnWrite]();
|
|
79
98
|
if (this.isActive)
|
|
80
99
|
EditTxnError.throwError("already-active", "This EditTxn is already active", this.iModel.key);
|
|
81
100
|
const activeTxn = this.iModel[_activeTxn];
|
|
@@ -92,9 +111,11 @@ export class EditTxn {
|
|
|
92
111
|
this.saveChanges(args);
|
|
93
112
|
}
|
|
94
113
|
else {
|
|
95
|
-
this.
|
|
114
|
+
this.abandonDatabaseChanges();
|
|
96
115
|
}
|
|
97
116
|
this.iModel[_activeTxn] = undefined;
|
|
117
|
+
if (mode === "abandon")
|
|
118
|
+
this.iModel[_refreshGeographicCoordinateSystem]();
|
|
98
119
|
}
|
|
99
120
|
/** Invoked when the owning iModel is closing.
|
|
100
121
|
* The base implementation commits unsaved changes. Subclasses may override to customize how
|
|
@@ -110,6 +131,10 @@ export class EditTxn {
|
|
|
110
131
|
* @throws EditTxnError if this EditTxn is not active.
|
|
111
132
|
*/
|
|
112
133
|
abandonChanges() {
|
|
134
|
+
this.abandonDatabaseChanges();
|
|
135
|
+
this.iModel[_refreshGeographicCoordinateSystem]();
|
|
136
|
+
}
|
|
137
|
+
abandonDatabaseChanges() {
|
|
113
138
|
this.verifyWriteable();
|
|
114
139
|
this.iModel.clearCaches({ instanceCachesOnly: true });
|
|
115
140
|
this.iModel[_nativeDb].abandonChanges();
|
|
@@ -347,14 +372,24 @@ export class EditTxn {
|
|
|
347
372
|
return ids;
|
|
348
373
|
}
|
|
349
374
|
/**
|
|
350
|
-
* Delete multiple elements from the iModel.
|
|
375
|
+
* Delete multiple elements from the iModel in a single bulk operation.
|
|
376
|
+
*
|
|
377
|
+
* Child elements and sub-model contents of the requested elements are deleted along with them.
|
|
378
|
+
*
|
|
379
|
+
* The operation is all-or-nothing:
|
|
380
|
+
* - On `Success`, all elements (and their children / sub-model contents) were deleted.
|
|
381
|
+
* - On `ConstraintViolation`, nothing was deleted and [[BulkDeleteElementsResult.failures]] lists every element in the
|
|
382
|
+
* expanded delete set that is still referenced from outside the set, and why. Fix or include those referencing elements and retry.
|
|
383
|
+
* - On `DeletionFailed` (an unexpected SQLite error) the iModel may be partially modified and the caller must abandon the current txn.
|
|
384
|
+
*
|
|
351
385
|
* @param ids The ids of the elements to delete. All ids must be well-formed and valid [[Id64String]]s.
|
|
352
|
-
* @param
|
|
353
|
-
* @returns A result object
|
|
386
|
+
* @param _deleteOptions Deprecated and ignored; kept for backward compatibility of the signature.
|
|
387
|
+
* @returns A result object describing the outcome of the operation and the elements that block it (if any).
|
|
354
388
|
* @throws [[ITwinError]] if any of the supplied ids are not well-formed/valid [[Id64String]]s.
|
|
355
389
|
* @beta
|
|
356
390
|
*/
|
|
357
|
-
|
|
391
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
392
|
+
deleteElements(ids, _deleteOptions) {
|
|
358
393
|
this.verifyWriteable();
|
|
359
394
|
const invalidIds = new Set();
|
|
360
395
|
for (const id of ids) {
|
|
@@ -363,17 +398,27 @@ export class EditTxn {
|
|
|
363
398
|
}
|
|
364
399
|
if (invalidIds.size > 0)
|
|
365
400
|
ITwinError.throwError({ message: `Invalid element ids: ${Array.from(invalidIds).join(", ")}`, iTwinErrorId: { scope: "imodel", key: "invalid-arguments" } });
|
|
366
|
-
const
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
401
|
+
const nativeResult = this.iModel[_nativeDb].deleteElements(ids);
|
|
402
|
+
// When deletion fails with `DeletionFailed`, all requested ids are returned to maintain backward compatibilty.
|
|
403
|
+
// Once `failedIds` is deprecated, we will change this to throw instead as this is a SQLite failure.
|
|
404
|
+
const failedIds = nativeResult.status === BulkDeleteElementsStatus.DeletionFailed
|
|
405
|
+
? new Set(ids)
|
|
406
|
+
: new Set(nativeResult.failures.map((failure) => failure.elementId));
|
|
407
|
+
const result = {
|
|
408
|
+
status: nativeResult.status,
|
|
409
|
+
sqlDeleteStatus: nativeResult.sqlDeleteStatus,
|
|
410
|
+
failures: nativeResult.failures,
|
|
411
|
+
// `failedIds` is deprecated. `failures` provides a more comprehensive error report.
|
|
412
|
+
// We still need to return the deprecated `failedIds` to maintain backward compatibility.
|
|
413
|
+
failedIds,
|
|
414
|
+
};
|
|
415
|
+
// Nothing was deleted on ConstraintViolation; on DeletionFailed the caller must abandon the txn, which restores the cached state.
|
|
416
|
+
if (result.status !== BulkDeleteElementsStatus.Success)
|
|
417
|
+
return result;
|
|
418
|
+
// Native deletion also nulls logical navigation properties on surviving elements that referenced the deleted ones,
|
|
419
|
+
// so evicting only the requested ids would leave stale cached referrers. Clear all instance caches.
|
|
420
|
+
this.iModel.clearCaches({ instanceCachesOnly: true });
|
|
421
|
+
return result;
|
|
377
422
|
}
|
|
378
423
|
/** Insert a new aspect into the iModel.
|
|
379
424
|
* @param aspectProps The properties of the new aspect.
|
|
@@ -643,11 +688,12 @@ export class EditTxn {
|
|
|
643
688
|
this.updateIModelProps();
|
|
644
689
|
}
|
|
645
690
|
/** Update the iModel props in the database from the current in-memory state.
|
|
691
|
+
* An unchanged geographic coordinate system is not replaced or re-resolved from its dictionary identifiers.
|
|
646
692
|
* @throws EditTxnError if this EditTxn is not active.
|
|
647
693
|
*/
|
|
648
694
|
updateIModelProps() {
|
|
649
695
|
this.verifyWriteable();
|
|
650
|
-
this.iModel[
|
|
696
|
+
this.iModel[_updateIModelProps]();
|
|
651
697
|
}
|
|
652
698
|
static _settingPropNamespace = "settings";
|
|
653
699
|
static _viewStoreProperty = { namespace: "itwinjs", name: "DefaultViewStore" };
|
|
@@ -700,25 +746,34 @@ export function withEditTxn(iModel, saveArgsOrFn, maybeFn) {
|
|
|
700
746
|
throw new Error("withEditTxn requires a callback");
|
|
701
747
|
const txn = new EditTxn(iModel, "");
|
|
702
748
|
txn.start();
|
|
749
|
+
const abandonOnError = (error) => {
|
|
750
|
+
try {
|
|
751
|
+
if (txn.isActive)
|
|
752
|
+
txn.end("abandon");
|
|
753
|
+
}
|
|
754
|
+
catch (abandonError) {
|
|
755
|
+
try {
|
|
756
|
+
Logger.logError(BackendLoggerCategory.IModelDb, abandonError);
|
|
757
|
+
}
|
|
758
|
+
catch {
|
|
759
|
+
throw error;
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
throw error;
|
|
763
|
+
};
|
|
703
764
|
try {
|
|
704
765
|
const result = fn(txn);
|
|
705
766
|
if (result instanceof Promise) {
|
|
706
767
|
return result.then((value) => {
|
|
707
768
|
txn.end("save", saveArgs);
|
|
708
769
|
return value;
|
|
709
|
-
},
|
|
710
|
-
if (txn.isActive)
|
|
711
|
-
txn.end("abandon");
|
|
712
|
-
throw err;
|
|
713
|
-
});
|
|
770
|
+
}, abandonOnError);
|
|
714
771
|
}
|
|
715
772
|
txn.end("save", saveArgs);
|
|
716
773
|
return result;
|
|
717
774
|
}
|
|
718
775
|
catch (err) {
|
|
719
|
-
|
|
720
|
-
txn.end("abandon");
|
|
721
|
-
throw err;
|
|
776
|
+
return abandonOnError(err);
|
|
722
777
|
}
|
|
723
778
|
}
|
|
724
779
|
//# sourceMappingURL=EditTxn.js.map
|