@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/cjs/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/cjs/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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OAIG;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/cjs/EditTxn.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.EditTxn = exports.BulkDeleteElementsStatus = void 0;
|
|
7
|
+
exports.EditTxn = exports.BulkDeleteElementsStatus = exports.BulkDeleteFailureReason = void 0;
|
|
8
8
|
exports.withEditTxn = withEditTxn;
|
|
9
9
|
/** @packageDocumentation
|
|
10
10
|
* @module iModels
|
|
@@ -12,7 +12,23 @@ exports.withEditTxn = withEditTxn;
|
|
|
12
12
|
const core_bentley_1 = require("@itwin/core-bentley");
|
|
13
13
|
const core_common_1 = require("@itwin/core-common");
|
|
14
14
|
const core_geometry_1 = require("@itwin/core-geometry");
|
|
15
|
+
const BackendLoggerCategory_1 = require("./BackendLoggerCategory");
|
|
15
16
|
const Symbols_1 = require("./internal/Symbols");
|
|
17
|
+
/**
|
|
18
|
+
* Why an element could not be deleted by [[EditTxn.deleteElements]].
|
|
19
|
+
* @beta
|
|
20
|
+
*/
|
|
21
|
+
var BulkDeleteFailureReason;
|
|
22
|
+
(function (BulkDeleteFailureReason) {
|
|
23
|
+
/** A row outside the delete set references it via a NO ACTION / RESTRICT / SET DEFAULT FK. */
|
|
24
|
+
BulkDeleteFailureReason[BulkDeleteFailureReason["ReferencedByForeignKey"] = 0] = "ReferencedByForeignKey";
|
|
25
|
+
/** It is a DefinitionElement still used by elements outside the delete set. */
|
|
26
|
+
BulkDeleteFailureReason[BulkDeleteFailureReason["DefinitionInUse"] = 1] = "DefinitionInUse";
|
|
27
|
+
/** It is one of the elements every iModel must keep: the root Subject, the DictionaryModel partition or the RealityDataSources partition. */
|
|
28
|
+
BulkDeleteFailureReason[BulkDeleteFailureReason["ProtectedElement"] = 2] = "ProtectedElement";
|
|
29
|
+
/** Its handler belongs to a read-only DgnDomain. */
|
|
30
|
+
BulkDeleteFailureReason[BulkDeleteFailureReason["ReadOnlyDomain"] = 3] = "ReadOnlyDomain";
|
|
31
|
+
})(BulkDeleteFailureReason || (exports.BulkDeleteFailureReason = BulkDeleteFailureReason = {}));
|
|
16
32
|
/**
|
|
17
33
|
* Status of a bulk element delete operation, mirroring the C++ `BulkDeleteStatus` enum.
|
|
18
34
|
* @beta
|
|
@@ -21,9 +37,9 @@ var BulkDeleteElementsStatus;
|
|
|
21
37
|
(function (BulkDeleteElementsStatus) {
|
|
22
38
|
/** All supplied elements were deleted successfully. */
|
|
23
39
|
BulkDeleteElementsStatus[BulkDeleteElementsStatus["Success"] = 0] = "Success";
|
|
24
|
-
/**
|
|
25
|
-
BulkDeleteElementsStatus[BulkDeleteElementsStatus["
|
|
26
|
-
/**
|
|
40
|
+
/** Nothing was deleted because some elements in the (expanded) delete set are still referenced from outside the set; see `failures` for the violators. */
|
|
41
|
+
BulkDeleteElementsStatus[BulkDeleteElementsStatus["ConstraintViolation"] = 1] = "ConstraintViolation";
|
|
42
|
+
/** An internal error occurred. The iModel may be partially modified; the caller must abandon the current txn. `failures` will be empty. */
|
|
27
43
|
BulkDeleteElementsStatus[BulkDeleteElementsStatus["DeletionFailed"] = 2] = "DeletionFailed";
|
|
28
44
|
})(BulkDeleteElementsStatus || (exports.BulkDeleteElementsStatus = BulkDeleteElementsStatus = {}));
|
|
29
45
|
/**
|
|
@@ -72,14 +88,17 @@ class EditTxn {
|
|
|
72
88
|
this.description = description;
|
|
73
89
|
}
|
|
74
90
|
verifyWriteable() {
|
|
91
|
+
this.iModel[Symbols_1._verifyTxnWrite]();
|
|
75
92
|
// Explicit transactions must always be active before writing.
|
|
76
93
|
if (!this.isActive)
|
|
77
94
|
core_common_1.EditTxnError.throwError("not-active", "EditTxn is not active", this.iModel.key);
|
|
78
95
|
}
|
|
79
96
|
/** Start this EditTxn, making it the active transaction for the iModel.
|
|
80
97
|
* @throws EditTxnError if this EditTxn is already active, another EditTxn is already active, or if unsaved changes are present.
|
|
98
|
+
* @throws IModelError if the geographic coordinate system is being restored.
|
|
81
99
|
*/
|
|
82
100
|
start() {
|
|
101
|
+
this.iModel[Symbols_1._verifyTxnWrite]();
|
|
83
102
|
if (this.isActive)
|
|
84
103
|
core_common_1.EditTxnError.throwError("already-active", "This EditTxn is already active", this.iModel.key);
|
|
85
104
|
const activeTxn = this.iModel[Symbols_1._activeTxn];
|
|
@@ -96,9 +115,11 @@ class EditTxn {
|
|
|
96
115
|
this.saveChanges(args);
|
|
97
116
|
}
|
|
98
117
|
else {
|
|
99
|
-
this.
|
|
118
|
+
this.abandonDatabaseChanges();
|
|
100
119
|
}
|
|
101
120
|
this.iModel[Symbols_1._activeTxn] = undefined;
|
|
121
|
+
if (mode === "abandon")
|
|
122
|
+
this.iModel[Symbols_1._refreshGeographicCoordinateSystem]();
|
|
102
123
|
}
|
|
103
124
|
/** Invoked when the owning iModel is closing.
|
|
104
125
|
* The base implementation commits unsaved changes. Subclasses may override to customize how
|
|
@@ -114,6 +135,10 @@ class EditTxn {
|
|
|
114
135
|
* @throws EditTxnError if this EditTxn is not active.
|
|
115
136
|
*/
|
|
116
137
|
abandonChanges() {
|
|
138
|
+
this.abandonDatabaseChanges();
|
|
139
|
+
this.iModel[Symbols_1._refreshGeographicCoordinateSystem]();
|
|
140
|
+
}
|
|
141
|
+
abandonDatabaseChanges() {
|
|
117
142
|
this.verifyWriteable();
|
|
118
143
|
this.iModel.clearCaches({ instanceCachesOnly: true });
|
|
119
144
|
this.iModel[Symbols_1._nativeDb].abandonChanges();
|
|
@@ -351,14 +376,24 @@ class EditTxn {
|
|
|
351
376
|
return ids;
|
|
352
377
|
}
|
|
353
378
|
/**
|
|
354
|
-
* Delete multiple elements from the iModel.
|
|
379
|
+
* Delete multiple elements from the iModel in a single bulk operation.
|
|
380
|
+
*
|
|
381
|
+
* Child elements and sub-model contents of the requested elements are deleted along with them.
|
|
382
|
+
*
|
|
383
|
+
* The operation is all-or-nothing:
|
|
384
|
+
* - On `Success`, all elements (and their children / sub-model contents) were deleted.
|
|
385
|
+
* - On `ConstraintViolation`, nothing was deleted and [[BulkDeleteElementsResult.failures]] lists every element in the
|
|
386
|
+
* expanded delete set that is still referenced from outside the set, and why. Fix or include those referencing elements and retry.
|
|
387
|
+
* - On `DeletionFailed` (an unexpected SQLite error) the iModel may be partially modified and the caller must abandon the current txn.
|
|
388
|
+
*
|
|
355
389
|
* @param ids The ids of the elements to delete. All ids must be well-formed and valid [[Id64String]]s.
|
|
356
|
-
* @param
|
|
357
|
-
* @returns A result object
|
|
390
|
+
* @param _deleteOptions Deprecated and ignored; kept for backward compatibility of the signature.
|
|
391
|
+
* @returns A result object describing the outcome of the operation and the elements that block it (if any).
|
|
358
392
|
* @throws [[ITwinError]] if any of the supplied ids are not well-formed/valid [[Id64String]]s.
|
|
359
393
|
* @beta
|
|
360
394
|
*/
|
|
361
|
-
|
|
395
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
396
|
+
deleteElements(ids, _deleteOptions) {
|
|
362
397
|
this.verifyWriteable();
|
|
363
398
|
const invalidIds = new Set();
|
|
364
399
|
for (const id of ids) {
|
|
@@ -367,17 +402,27 @@ class EditTxn {
|
|
|
367
402
|
}
|
|
368
403
|
if (invalidIds.size > 0)
|
|
369
404
|
core_bentley_1.ITwinError.throwError({ message: `Invalid element ids: ${Array.from(invalidIds).join(", ")}`, iTwinErrorId: { scope: "imodel", key: "invalid-arguments" } });
|
|
370
|
-
const
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
405
|
+
const nativeResult = this.iModel[Symbols_1._nativeDb].deleteElements(ids);
|
|
406
|
+
// When deletion fails with `DeletionFailed`, all requested ids are returned to maintain backward compatibilty.
|
|
407
|
+
// Once `failedIds` is deprecated, we will change this to throw instead as this is a SQLite failure.
|
|
408
|
+
const failedIds = nativeResult.status === BulkDeleteElementsStatus.DeletionFailed
|
|
409
|
+
? new Set(ids)
|
|
410
|
+
: new Set(nativeResult.failures.map((failure) => failure.elementId));
|
|
411
|
+
const result = {
|
|
412
|
+
status: nativeResult.status,
|
|
413
|
+
sqlDeleteStatus: nativeResult.sqlDeleteStatus,
|
|
414
|
+
failures: nativeResult.failures,
|
|
415
|
+
// `failedIds` is deprecated. `failures` provides a more comprehensive error report.
|
|
416
|
+
// We still need to return the deprecated `failedIds` to maintain backward compatibility.
|
|
417
|
+
failedIds,
|
|
418
|
+
};
|
|
419
|
+
// Nothing was deleted on ConstraintViolation; on DeletionFailed the caller must abandon the txn, which restores the cached state.
|
|
420
|
+
if (result.status !== BulkDeleteElementsStatus.Success)
|
|
421
|
+
return result;
|
|
422
|
+
// Native deletion also nulls logical navigation properties on surviving elements that referenced the deleted ones,
|
|
423
|
+
// so evicting only the requested ids would leave stale cached referrers. Clear all instance caches.
|
|
424
|
+
this.iModel.clearCaches({ instanceCachesOnly: true });
|
|
425
|
+
return result;
|
|
381
426
|
}
|
|
382
427
|
/** Insert a new aspect into the iModel.
|
|
383
428
|
* @param aspectProps The properties of the new aspect.
|
|
@@ -647,11 +692,12 @@ class EditTxn {
|
|
|
647
692
|
this.updateIModelProps();
|
|
648
693
|
}
|
|
649
694
|
/** Update the iModel props in the database from the current in-memory state.
|
|
695
|
+
* An unchanged geographic coordinate system is not replaced or re-resolved from its dictionary identifiers.
|
|
650
696
|
* @throws EditTxnError if this EditTxn is not active.
|
|
651
697
|
*/
|
|
652
698
|
updateIModelProps() {
|
|
653
699
|
this.verifyWriteable();
|
|
654
|
-
this.iModel[Symbols_1.
|
|
700
|
+
this.iModel[Symbols_1._updateIModelProps]();
|
|
655
701
|
}
|
|
656
702
|
static _settingPropNamespace = "settings";
|
|
657
703
|
static _viewStoreProperty = { namespace: "itwinjs", name: "DefaultViewStore" };
|
|
@@ -705,25 +751,34 @@ function withEditTxn(iModel, saveArgsOrFn, maybeFn) {
|
|
|
705
751
|
throw new Error("withEditTxn requires a callback");
|
|
706
752
|
const txn = new EditTxn(iModel, "");
|
|
707
753
|
txn.start();
|
|
754
|
+
const abandonOnError = (error) => {
|
|
755
|
+
try {
|
|
756
|
+
if (txn.isActive)
|
|
757
|
+
txn.end("abandon");
|
|
758
|
+
}
|
|
759
|
+
catch (abandonError) {
|
|
760
|
+
try {
|
|
761
|
+
core_bentley_1.Logger.logError(BackendLoggerCategory_1.BackendLoggerCategory.IModelDb, abandonError);
|
|
762
|
+
}
|
|
763
|
+
catch {
|
|
764
|
+
throw error;
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
throw error;
|
|
768
|
+
};
|
|
708
769
|
try {
|
|
709
770
|
const result = fn(txn);
|
|
710
771
|
if (result instanceof Promise) {
|
|
711
772
|
return result.then((value) => {
|
|
712
773
|
txn.end("save", saveArgs);
|
|
713
774
|
return value;
|
|
714
|
-
},
|
|
715
|
-
if (txn.isActive)
|
|
716
|
-
txn.end("abandon");
|
|
717
|
-
throw err;
|
|
718
|
-
});
|
|
775
|
+
}, abandonOnError);
|
|
719
776
|
}
|
|
720
777
|
txn.end("save", saveArgs);
|
|
721
778
|
return result;
|
|
722
779
|
}
|
|
723
780
|
catch (err) {
|
|
724
|
-
|
|
725
|
-
txn.end("abandon");
|
|
726
|
-
throw err;
|
|
781
|
+
return abandonOnError(err);
|
|
727
782
|
}
|
|
728
783
|
}
|
|
729
784
|
//# sourceMappingURL=EditTxn.js.map
|