@itwin/core-backend 4.8.0-dev.3 → 4.8.0-dev.31
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 +57 -1
- package/lib/cjs/BackendHubAccess.d.ts +18 -16
- package/lib/cjs/BackendHubAccess.d.ts.map +1 -1
- package/lib/cjs/BackendHubAccess.js +16 -15
- package/lib/cjs/BackendHubAccess.js.map +1 -1
- package/lib/cjs/BackendLoggerCategory.d.ts +3 -1
- package/lib/cjs/BackendLoggerCategory.d.ts.map +1 -1
- package/lib/cjs/BackendLoggerCategory.js +2 -0
- package/lib/cjs/BackendLoggerCategory.js.map +1 -1
- package/lib/cjs/BisCoreSchema.js.map +1 -1
- package/lib/cjs/BlobContainerService.d.ts +3 -3
- package/lib/cjs/BlobContainerService.d.ts.map +1 -1
- package/lib/cjs/BlobContainerService.js.map +1 -1
- package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
- package/lib/cjs/BriefcaseManager.js +19 -11
- package/lib/cjs/BriefcaseManager.js.map +1 -1
- package/lib/cjs/Category.d.ts +0 -6
- package/lib/cjs/Category.d.ts.map +1 -1
- package/lib/cjs/Category.js +0 -6
- package/lib/cjs/Category.js.map +1 -1
- package/lib/cjs/ChangeSummaryManager.d.ts.map +1 -1
- package/lib/cjs/ChangeSummaryManager.js +13 -11
- package/lib/cjs/ChangeSummaryManager.js.map +1 -1
- package/lib/cjs/ChangedElementsDb.d.ts +1 -0
- package/lib/cjs/ChangedElementsDb.d.ts.map +1 -1
- package/lib/cjs/ChangedElementsDb.js +6 -4
- package/lib/cjs/ChangedElementsDb.js.map +1 -1
- package/lib/cjs/ChangedElementsManager.js.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.d.ts.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.js +242 -237
- package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
- package/lib/cjs/ChannelControl.d.ts +4 -26
- package/lib/cjs/ChannelControl.d.ts.map +1 -1
- package/lib/cjs/ChannelControl.js +2 -101
- package/lib/cjs/ChannelControl.js.map +1 -1
- package/lib/cjs/CheckpointManager.d.ts.map +1 -1
- package/lib/cjs/CheckpointManager.js +5 -3
- package/lib/cjs/CheckpointManager.js.map +1 -1
- package/lib/cjs/ClassRegistry.d.ts.map +1 -1
- package/lib/cjs/ClassRegistry.js +8 -7
- package/lib/cjs/ClassRegistry.js.map +1 -1
- package/lib/cjs/CloudSqlite.d.ts +49 -24
- package/lib/cjs/CloudSqlite.d.ts.map +1 -1
- package/lib/cjs/CloudSqlite.js +66 -7
- package/lib/cjs/CloudSqlite.js.map +1 -1
- package/lib/cjs/CodeService.d.ts +4 -4
- package/lib/cjs/CodeService.d.ts.map +1 -1
- package/lib/cjs/CodeService.js.map +1 -1
- package/lib/cjs/CodeSpecs.js.map +1 -1
- package/lib/cjs/ConcurrentQuery.js.map +1 -1
- package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
- package/lib/cjs/DevTools.d.ts.map +1 -1
- package/lib/cjs/DevTools.js +2 -1
- package/lib/cjs/DevTools.js.map +1 -1
- package/lib/cjs/DisplayStyle.d.ts +0 -3
- package/lib/cjs/DisplayStyle.d.ts.map +1 -1
- package/lib/cjs/DisplayStyle.js +0 -3
- package/lib/cjs/DisplayStyle.js.map +1 -1
- package/lib/cjs/ECDb.d.ts +6 -1
- package/lib/cjs/ECDb.d.ts.map +1 -1
- package/lib/cjs/ECDb.js +19 -14
- package/lib/cjs/ECDb.js.map +1 -1
- package/lib/cjs/ECSchemaXmlContext.js +2 -2
- package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
- package/lib/cjs/ECSqlStatement.d.ts +6 -3
- package/lib/cjs/ECSqlStatement.d.ts.map +1 -1
- package/lib/cjs/ECSqlStatement.js +3 -3
- package/lib/cjs/ECSqlStatement.js.map +1 -1
- package/lib/cjs/Element.d.ts +3 -60
- package/lib/cjs/Element.d.ts.map +1 -1
- package/lib/cjs/Element.js +8 -64
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/ElementAspect.d.ts +0 -5
- package/lib/cjs/ElementAspect.d.ts.map +1 -1
- package/lib/cjs/ElementAspect.js +4 -8
- package/lib/cjs/ElementAspect.js.map +1 -1
- package/lib/cjs/ElementGraphics.d.ts.map +1 -1
- package/lib/cjs/ElementGraphics.js +2 -1
- package/lib/cjs/ElementGraphics.js.map +1 -1
- package/lib/cjs/ElementTreeWalker.js.map +1 -1
- package/lib/cjs/Entity.js.map +1 -1
- package/lib/cjs/EntityReferences.js.map +1 -1
- package/lib/cjs/ExportGraphics.js.map +1 -1
- package/lib/cjs/ExternalSource.js.map +1 -1
- package/lib/cjs/GeoCoordConfig.d.ts +10 -0
- package/lib/cjs/GeoCoordConfig.d.ts.map +1 -1
- package/lib/cjs/GeoCoordConfig.js +22 -24
- package/lib/cjs/GeoCoordConfig.js.map +1 -1
- package/lib/cjs/GeographicCRSServices.js +2 -2
- package/lib/cjs/GeographicCRSServices.js.map +1 -1
- package/lib/cjs/GeometrySummary.d.ts.map +1 -1
- package/lib/cjs/GeometrySummary.js +49 -48
- package/lib/cjs/GeometrySummary.js.map +1 -1
- package/lib/cjs/HubMock.js.map +1 -1
- package/lib/cjs/IModelCloneContext.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +33 -98
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +250 -164
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/IModelElementCloneContext.d.ts.map +1 -1
- package/lib/cjs/IModelElementCloneContext.js +5 -4
- package/lib/cjs/IModelElementCloneContext.js.map +1 -1
- package/lib/cjs/IModelHost.d.ts +13 -4
- package/lib/cjs/IModelHost.d.ts.map +1 -1
- package/lib/cjs/IModelHost.js +39 -32
- package/lib/cjs/IModelHost.js.map +1 -1
- package/lib/cjs/IModelJsFs.js.map +1 -1
- package/lib/cjs/IpcHost.d.ts.map +1 -1
- package/lib/cjs/IpcHost.js +15 -13
- package/lib/cjs/IpcHost.js.map +1 -1
- package/lib/cjs/LineStyle.js.map +1 -1
- package/lib/cjs/LocalHub.d.ts +2 -2
- package/lib/cjs/LocalHub.d.ts.map +1 -1
- package/lib/cjs/LocalHub.js +18 -18
- package/lib/cjs/LocalHub.js.map +1 -1
- package/lib/cjs/LocalhostIpcHost.js.map +1 -1
- package/lib/cjs/LockControl.d.ts +73 -0
- package/lib/cjs/LockControl.d.ts.map +1 -0
- package/lib/cjs/LockControl.js +11 -0
- package/lib/cjs/LockControl.js.map +1 -0
- package/lib/cjs/Material.d.ts +2 -5
- package/lib/cjs/Material.d.ts.map +1 -1
- package/lib/cjs/Material.js +6 -4
- package/lib/cjs/Material.js.map +1 -1
- package/lib/cjs/Model.d.ts +0 -22
- package/lib/cjs/Model.d.ts.map +1 -1
- package/lib/cjs/Model.js +5 -26
- package/lib/cjs/Model.js.map +1 -1
- package/lib/cjs/NativeAppStorage.js.map +1 -1
- package/lib/cjs/NativeHost.js.map +1 -1
- package/lib/cjs/NavigationRelationship.js.map +1 -1
- package/lib/cjs/PromiseMemoizer.js.map +1 -1
- package/lib/cjs/PropertyStore.d.ts +17 -7
- package/lib/cjs/PropertyStore.d.ts.map +1 -1
- package/lib/cjs/PropertyStore.js +11 -5
- package/lib/cjs/PropertyStore.js.map +1 -1
- package/lib/cjs/Relationship.d.ts +0 -12
- package/lib/cjs/Relationship.d.ts.map +1 -1
- package/lib/cjs/Relationship.js +5 -16
- package/lib/cjs/Relationship.js.map +1 -1
- package/lib/cjs/RpcBackend.js.map +1 -1
- package/lib/cjs/SQLiteDb.d.ts +8 -4
- package/lib/cjs/SQLiteDb.d.ts.map +1 -1
- package/lib/cjs/SQLiteDb.js +25 -19
- package/lib/cjs/SQLiteDb.js.map +1 -1
- package/lib/cjs/Schema.js.map +1 -1
- package/lib/cjs/SchemaSync.d.ts +4 -1
- package/lib/cjs/SchemaSync.d.ts.map +1 -1
- package/lib/cjs/SchemaSync.js +24 -11
- package/lib/cjs/SchemaSync.js.map +1 -1
- package/lib/cjs/SchemaUtils.js +3 -3
- package/lib/cjs/SchemaUtils.js.map +1 -1
- package/lib/cjs/SqliteChangesetReader.d.ts.map +1 -1
- package/lib/cjs/SqliteChangesetReader.js +2 -2
- package/lib/cjs/SqliteChangesetReader.js.map +1 -1
- package/lib/cjs/SqliteStatement.js +2 -2
- package/lib/cjs/SqliteStatement.js.map +1 -1
- package/lib/cjs/TextAnnotationElement.js.map +1 -1
- package/lib/cjs/TextAnnotationGeometry.d.ts +5 -1
- package/lib/cjs/TextAnnotationGeometry.d.ts.map +1 -1
- package/lib/cjs/TextAnnotationGeometry.js +11 -8
- package/lib/cjs/TextAnnotationGeometry.js.map +1 -1
- package/lib/cjs/TextAnnotationLayout.d.ts +21 -13
- package/lib/cjs/TextAnnotationLayout.d.ts.map +1 -1
- package/lib/cjs/TextAnnotationLayout.js +134 -92
- package/lib/cjs/TextAnnotationLayout.js.map +1 -1
- package/lib/cjs/Texture.js.map +1 -1
- package/lib/cjs/TileStorage.js.map +1 -1
- package/lib/cjs/TxnManager.d.ts +2 -1
- package/lib/cjs/TxnManager.d.ts.map +1 -1
- package/lib/cjs/TxnManager.js +4 -2
- package/lib/cjs/TxnManager.js.map +1 -1
- package/lib/cjs/ViewDefinition.d.ts +1 -18
- package/lib/cjs/ViewDefinition.d.ts.map +1 -1
- package/lib/cjs/ViewDefinition.js +1 -18
- package/lib/cjs/ViewDefinition.js.map +1 -1
- package/lib/cjs/ViewStateHydrator.js.map +1 -1
- package/lib/cjs/ViewStore.d.ts +16 -2
- package/lib/cjs/ViewStore.d.ts.map +1 -1
- package/lib/cjs/ViewStore.js +20 -6
- package/lib/cjs/ViewStore.js.map +1 -1
- package/lib/cjs/assets/IModelChange.02.00.00.ecschema.xml +90 -90
- package/lib/cjs/assets/Settings/Schemas/Base.Schema.json +33 -0
- package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +27 -31
- package/lib/cjs/assets/Settings/Schemas/Workspace.Schema.json +94 -52
- package/lib/cjs/assets/Settings/backend.setting.json5 +21 -132
- package/lib/cjs/core-backend.d.ts +4 -2
- package/lib/cjs/core-backend.d.ts.map +1 -1
- package/lib/cjs/core-backend.js +5 -6
- package/lib/cjs/core-backend.js.map +1 -1
- package/lib/cjs/domains/FunctionalElements.d.ts +0 -10
- package/lib/cjs/domains/FunctionalElements.d.ts.map +1 -1
- package/lib/cjs/domains/FunctionalElements.js +0 -10
- package/lib/cjs/domains/FunctionalElements.js.map +1 -1
- package/lib/cjs/domains/FunctionalSchema.d.ts.map +1 -1
- package/lib/cjs/domains/FunctionalSchema.js +2 -1
- package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
- package/lib/cjs/domains/GenericElements.d.ts +0 -18
- package/lib/cjs/domains/GenericElements.d.ts.map +1 -1
- package/lib/cjs/domains/GenericElements.js +0 -18
- package/lib/cjs/domains/GenericElements.js.map +1 -1
- package/lib/cjs/domains/GenericSchema.js.map +1 -1
- package/lib/cjs/internal/ChangesetConflictArgs.d.ts +24 -0
- package/lib/cjs/internal/ChangesetConflictArgs.d.ts.map +1 -0
- package/lib/cjs/internal/ChangesetConflictArgs.js +7 -0
- package/lib/cjs/internal/ChangesetConflictArgs.js.map +1 -0
- package/lib/cjs/internal/ChannelAdmin.d.ts +34 -0
- package/lib/cjs/internal/ChannelAdmin.d.ts.map +1 -0
- package/lib/cjs/internal/ChannelAdmin.js +117 -0
- package/lib/cjs/internal/ChannelAdmin.js.map +1 -0
- package/lib/cjs/internal/NativePlatform.d.ts +15 -0
- package/lib/cjs/internal/NativePlatform.d.ts.map +1 -0
- package/lib/cjs/internal/NativePlatform.js +49 -0
- package/lib/cjs/internal/NativePlatform.js.map +1 -0
- package/lib/cjs/internal/NoLocks.d.ts +6 -0
- package/lib/cjs/internal/NoLocks.d.ts.map +1 -0
- package/lib/cjs/internal/NoLocks.js +31 -0
- package/lib/cjs/internal/NoLocks.js.map +1 -0
- package/lib/cjs/{ServerBasedLocks.d.ts → internal/ServerBasedLocks.d.ts} +10 -16
- package/lib/cjs/internal/ServerBasedLocks.d.ts.map +1 -0
- package/lib/cjs/{ServerBasedLocks.js → internal/ServerBasedLocks.js} +29 -18
- package/lib/cjs/internal/ServerBasedLocks.js.map +1 -0
- package/lib/cjs/internal/Symbols.d.ts +11 -0
- package/lib/cjs/internal/Symbols.d.ts.map +1 -0
- package/lib/cjs/internal/Symbols.js +21 -0
- package/lib/cjs/internal/Symbols.js.map +1 -0
- package/lib/cjs/internal/cross-package.d.ts +4 -0
- package/lib/cjs/internal/cross-package.d.ts.map +1 -0
- package/lib/cjs/internal/cross-package.js +16 -0
- package/lib/cjs/internal/cross-package.js.map +1 -0
- package/lib/cjs/internal/workspace/SettingsImpl.d.ts +43 -0
- package/lib/cjs/internal/workspace/SettingsImpl.d.ts.map +1 -0
- package/lib/cjs/internal/workspace/SettingsImpl.js +161 -0
- package/lib/cjs/internal/workspace/SettingsImpl.js.map +1 -0
- package/lib/cjs/internal/workspace/SettingsSchemasImpl.d.ts +6 -0
- package/lib/cjs/internal/workspace/SettingsSchemasImpl.d.ts.map +1 -0
- package/lib/cjs/internal/workspace/SettingsSchemasImpl.js +276 -0
- package/lib/cjs/internal/workspace/SettingsSchemasImpl.js.map +1 -0
- package/lib/cjs/internal/workspace/WorkspaceImpl.d.ts +41 -0
- package/lib/cjs/internal/workspace/WorkspaceImpl.d.ts.map +1 -0
- package/lib/cjs/internal/workspace/WorkspaceImpl.js +696 -0
- package/lib/cjs/internal/workspace/WorkspaceImpl.js.map +1 -0
- package/lib/cjs/internal/workspace/WorkspaceSqliteDb.d.ts +10 -0
- package/lib/cjs/internal/workspace/WorkspaceSqliteDb.d.ts.map +1 -0
- package/lib/cjs/internal/workspace/WorkspaceSqliteDb.js +42 -0
- package/lib/cjs/internal/workspace/WorkspaceSqliteDb.js.map +1 -0
- package/lib/cjs/rpc/multipart.js.map +1 -1
- package/lib/cjs/rpc/tracing.d.ts.map +1 -1
- package/lib/cjs/rpc/tracing.js +5 -2
- package/lib/cjs/rpc/tracing.js.map +1 -1
- package/lib/cjs/rpc/web/logging.js.map +1 -1
- package/lib/cjs/rpc/web/request.js.map +1 -1
- package/lib/cjs/rpc/web/response.js.map +1 -1
- package/lib/cjs/rpc-impl/DevToolsRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +1 -0
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +10 -6
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +5 -3
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
- package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/WipRpcImpl.js.map +1 -1
- package/lib/cjs/workspace/Settings.d.ts +167 -138
- package/lib/cjs/workspace/Settings.d.ts.map +1 -1
- package/lib/cjs/workspace/Settings.js +68 -138
- package/lib/cjs/workspace/Settings.js.map +1 -1
- package/lib/cjs/workspace/SettingsSchemas.d.ts +112 -48
- package/lib/cjs/workspace/SettingsSchemas.d.ts.map +1 -1
- package/lib/cjs/workspace/SettingsSchemas.js +1 -172
- package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
- package/lib/cjs/workspace/Workspace.d.ts +411 -277
- package/lib/cjs/workspace/Workspace.d.ts.map +1 -1
- package/lib/cjs/workspace/Workspace.js +76 -457
- package/lib/cjs/workspace/Workspace.js.map +1 -1
- package/lib/cjs/workspace/WorkspaceEditor.d.ts +245 -0
- package/lib/cjs/workspace/WorkspaceEditor.d.ts.map +1 -0
- package/lib/cjs/workspace/WorkspaceEditor.js +34 -0
- package/lib/cjs/workspace/WorkspaceEditor.js.map +1 -0
- package/package.json +15 -14
- package/lib/cjs/ServerBasedLocks.d.ts.map +0 -1
- package/lib/cjs/ServerBasedLocks.js.map +0 -1
- package/lib/cjs/assets/Settings/Schemas/Cloud.Schema.json +0 -45
package/lib/cjs/IModelDb.js
CHANGED
|
@@ -17,6 +17,7 @@ const core_geometry_1 = require("@itwin/core-geometry");
|
|
|
17
17
|
const BackendLoggerCategory_1 = require("./BackendLoggerCategory");
|
|
18
18
|
const BriefcaseManager_1 = require("./BriefcaseManager");
|
|
19
19
|
const ChannelControl_1 = require("./ChannelControl");
|
|
20
|
+
const ChannelAdmin_1 = require("./internal/ChannelAdmin");
|
|
20
21
|
const CheckpointManager_1 = require("./CheckpointManager");
|
|
21
22
|
const ClassRegistry_1 = require("./ClassRegistry");
|
|
22
23
|
const CloudSqlite_1 = require("./CloudSqlite");
|
|
@@ -34,28 +35,20 @@ const IpcHost_1 = require("./IpcHost");
|
|
|
34
35
|
const Model_1 = require("./Model");
|
|
35
36
|
const Relationship_1 = require("./Relationship");
|
|
36
37
|
const SchemaSync_1 = require("./SchemaSync");
|
|
37
|
-
const ServerBasedLocks_1 = require("./ServerBasedLocks");
|
|
38
|
+
const ServerBasedLocks_1 = require("./internal/ServerBasedLocks");
|
|
38
39
|
const SqliteStatement_1 = require("./SqliteStatement");
|
|
39
40
|
const TxnManager_1 = require("./TxnManager");
|
|
40
41
|
const ViewDefinition_1 = require("./ViewDefinition");
|
|
41
42
|
const ViewStore_1 = require("./ViewStore");
|
|
42
43
|
const Settings_1 = require("./workspace/Settings");
|
|
43
44
|
const Workspace_1 = require("./workspace/Workspace");
|
|
45
|
+
const WorkspaceImpl_1 = require("./internal/workspace/WorkspaceImpl");
|
|
46
|
+
const SettingsImpl_1 = require("./internal/workspace/SettingsImpl");
|
|
47
|
+
const NativePlatform_1 = require("./internal/NativePlatform");
|
|
48
|
+
const NoLocks_1 = require("./internal/NoLocks");
|
|
49
|
+
const Symbols_1 = require("./internal/Symbols");
|
|
44
50
|
// spell:ignore fontid fontmap
|
|
45
51
|
const loggerCategory = BackendLoggerCategory_1.BackendLoggerCategory.IModelDb;
|
|
46
|
-
/** A null-implementation of LockControl that does not attempt to limit access between briefcases. This relies on change-merging to resolve conflicts. */
|
|
47
|
-
class NoLocks {
|
|
48
|
-
get isServerBased() { return false; }
|
|
49
|
-
close() { }
|
|
50
|
-
clearAllLocks() { }
|
|
51
|
-
holdsExclusiveLock() { return false; }
|
|
52
|
-
holdsSharedLock() { return false; }
|
|
53
|
-
checkExclusiveLock() { }
|
|
54
|
-
checkSharedLock() { }
|
|
55
|
-
elementWasCreated() { }
|
|
56
|
-
async acquireLocks() { }
|
|
57
|
-
async releaseAllLocks() { }
|
|
58
|
-
}
|
|
59
52
|
/** @internal */
|
|
60
53
|
var BriefcaseLocalValue;
|
|
61
54
|
(function (BriefcaseLocalValue) {
|
|
@@ -74,16 +67,16 @@ const withBriefcaseDb = async (briefcase, fn) => {
|
|
|
74
67
|
};
|
|
75
68
|
/**
|
|
76
69
|
* Settings for an individual iModel. May only include settings priority for iModel, iTwin and organization.
|
|
77
|
-
* @note if there is more than one iModel for an iTwin or organization, they will *each* hold
|
|
70
|
+
* @note if there is more than one iModel for an iTwin or organization, they will *each* hold an independent copy of the settings for those priorities.
|
|
78
71
|
*/
|
|
79
|
-
class IModelSettings extends
|
|
72
|
+
class IModelSettings extends SettingsImpl_1.SettingsImpl {
|
|
80
73
|
verifyPriority(priority) {
|
|
81
74
|
if (priority <= Settings_1.SettingsPriority.application)
|
|
82
|
-
throw new Error("Use IModelHost.appSettings");
|
|
75
|
+
throw new Error("Use IModelHost.appSettings to access settings of priority 'application' or lower");
|
|
83
76
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
77
|
+
*getSettingEntries(name) {
|
|
78
|
+
yield* super.getSettingEntries(name);
|
|
79
|
+
yield* IModelHost_1.IModelHost.appWorkspace.settings.getSettingEntries(name);
|
|
87
80
|
}
|
|
88
81
|
}
|
|
89
82
|
/** An iModel database file. The database file can either be a briefcase or a snapshot.
|
|
@@ -94,10 +87,7 @@ class IModelSettings extends Settings_1.BaseSettings {
|
|
|
94
87
|
class IModelDb extends core_common_1.IModel {
|
|
95
88
|
/** @alpha */
|
|
96
89
|
get codeService() { return this._codeService; }
|
|
97
|
-
/**
|
|
98
|
-
* Get the [[LockControl]] for this iModel.
|
|
99
|
-
* @beta
|
|
100
|
-
*/
|
|
90
|
+
/** The [[LockControl]] that orchestrates [concurrent editing]($docs/learning/backend/ConcurrencyControl.md) of this iModel. */
|
|
101
91
|
get locks() { return this._locks; } // eslint-disable-line @typescript-eslint/no-non-null-assertion
|
|
102
92
|
/**
|
|
103
93
|
* Get the [[Workspace]] for this iModel.
|
|
@@ -105,11 +95,11 @@ class IModelDb extends core_common_1.IModel {
|
|
|
105
95
|
*/
|
|
106
96
|
get workspace() {
|
|
107
97
|
if (undefined === this._workspace)
|
|
108
|
-
this._workspace =
|
|
98
|
+
this._workspace = (0, WorkspaceImpl_1.constructWorkspace)(new IModelSettings());
|
|
109
99
|
return this._workspace;
|
|
110
100
|
}
|
|
111
101
|
/** Acquire the exclusive schema lock on this iModel.
|
|
112
|
-
*
|
|
102
|
+
* @note: To acquire the schema lock, all other briefcases must first release *all* their locks. No other briefcases
|
|
113
103
|
* will be able to acquire *any* locks while the schema lock is held.
|
|
114
104
|
*/
|
|
115
105
|
async acquireSchemaLock() {
|
|
@@ -121,15 +111,15 @@ class IModelDb extends core_common_1.IModel {
|
|
|
121
111
|
}
|
|
122
112
|
/** @internal */
|
|
123
113
|
notifyChangesetApplied() {
|
|
124
|
-
this.changeset = this.
|
|
114
|
+
this.changeset = this[Symbols_1._nativeDb].getCurrentChangeset();
|
|
125
115
|
this.onChangesetApplied.raiseEvent();
|
|
126
116
|
}
|
|
127
117
|
/** @internal */
|
|
128
118
|
restartDefaultTxn() {
|
|
129
|
-
this.
|
|
119
|
+
this[Symbols_1._nativeDb].restartDefaultTxn();
|
|
130
120
|
}
|
|
131
121
|
get fontMap() {
|
|
132
|
-
return this._fontMap ?? (this._fontMap = new core_common_1.FontMap(this.
|
|
122
|
+
return this._fontMap ?? (this._fontMap = new core_common_1.FontMap(this[Symbols_1._nativeDb].readFontMap()));
|
|
133
123
|
}
|
|
134
124
|
/** @internal */
|
|
135
125
|
clearFontMap() {
|
|
@@ -146,7 +136,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
146
136
|
addNewFont(name, type) {
|
|
147
137
|
this.locks.checkExclusiveLock(core_common_1.IModel.repositoryModelId, "schema", "addNewFont");
|
|
148
138
|
this.clearFontMap();
|
|
149
|
-
return this.
|
|
139
|
+
return this[Symbols_1._nativeDb].addNewFont({ name, type: type ?? core_common_1.FontType.TrueType });
|
|
150
140
|
}
|
|
151
141
|
/** Check if this iModel has been opened read-only or not. */
|
|
152
142
|
get isReadonly() { return this.openMode === core_bentley_1.OpenMode.Readonly; }
|
|
@@ -155,10 +145,14 @@ class IModelDb extends core_common_1.IModel {
|
|
|
155
145
|
(0, core_bentley_1.assert)(undefined !== super.iModelId);
|
|
156
146
|
return super.iModelId;
|
|
157
147
|
} // GuidString | undefined for the IModel superclass, but required for all IModelDb subclasses
|
|
148
|
+
/** @internal
|
|
149
|
+
* @deprecated in 4.8. This internal API will be removed in 5.0. Use IModelDb's public API instead.
|
|
150
|
+
*/
|
|
151
|
+
get nativeDb() { return this[Symbols_1._nativeDb]; }
|
|
158
152
|
/** Get the full path fileName of this iModelDb
|
|
159
153
|
* @note this member is only valid while the iModel is opened.
|
|
160
154
|
*/
|
|
161
|
-
get pathName() { return this.
|
|
155
|
+
get pathName() { return this[Symbols_1._nativeDb].getFilePath(); }
|
|
162
156
|
/** Get the full path to this iModel's "watch file".
|
|
163
157
|
* A read-only briefcase opened with `watchForChanges: true` creates this file next to the briefcase file on open, if it doesn't already exist.
|
|
164
158
|
* A writable briefcase "touches" this file if it exists whenever it commits changes to the briefcase.
|
|
@@ -176,30 +170,30 @@ class IModelDb extends core_common_1.IModel {
|
|
|
176
170
|
this.views = new IModelDb.Views(this);
|
|
177
171
|
this.tiles = new IModelDb.Tiles(this);
|
|
178
172
|
/** @beta */
|
|
179
|
-
this.channels =
|
|
173
|
+
this.channels = (0, ChannelAdmin_1.createChannelControl)(this);
|
|
180
174
|
this._statementCache = new SqliteStatement_1.StatementCache();
|
|
181
175
|
this._sqliteStatementCache = new SqliteStatement_1.StatementCache();
|
|
182
176
|
this._snaps = new Map();
|
|
183
177
|
/** @internal */
|
|
184
|
-
this._locks =
|
|
178
|
+
this._locks = (0, NoLocks_1.createNoOpLockControl)();
|
|
185
179
|
/** Event called after a changeset is applied to this IModelDb. */
|
|
186
180
|
this.onChangesetApplied = new core_bentley_1.BeEvent();
|
|
187
181
|
/** Event called when the iModel is about to be closed. */
|
|
188
182
|
this.onBeforeClose = new core_bentley_1.BeEvent();
|
|
189
|
-
this.
|
|
183
|
+
this[Symbols_1._nativeDb] = args.nativeDb;
|
|
190
184
|
// it is illegal to create an IModelDb unless the nativeDb has been opened. Throw otherwise.
|
|
191
185
|
if (!this.isOpen)
|
|
192
186
|
throw new Error("cannot create an IModelDb unless it has already been opened");
|
|
193
187
|
// PR https://github.com/iTwin/imodel-native/pull/558 renamed closeIModel to closeFile because it changed its behavior.
|
|
194
188
|
// Ideally, nobody outside of core-backend would be calling it, but somebody important is.
|
|
195
189
|
// Make closeIModel available so their code doesn't break.
|
|
196
|
-
this.
|
|
190
|
+
this[Symbols_1._nativeDb].closeIModel = () => {
|
|
197
191
|
if (!this.isReadonly)
|
|
198
192
|
this.saveChanges(); // preserve old behavior of closeIModel that was removed when renamed to closeFile
|
|
199
|
-
this.
|
|
193
|
+
this[Symbols_1._nativeDb].closeFile();
|
|
200
194
|
};
|
|
201
|
-
this.
|
|
202
|
-
this.
|
|
195
|
+
this[Symbols_1._nativeDb].setIModelDb(this);
|
|
196
|
+
this.loadIModelSettings();
|
|
203
197
|
GeoCoordConfig_1.GeoCoordConfig.loadForImodel(this.workspace.settings); // load gcs data specified by iModel's settings dictionaries, must be done before calling initializeIModelDb
|
|
204
198
|
this.initializeIModelDb();
|
|
205
199
|
IModelDb._openDbs.set(this._fileKey, this);
|
|
@@ -222,13 +216,13 @@ class IModelDb extends core_common_1.IModel {
|
|
|
222
216
|
this.beforeClose();
|
|
223
217
|
IModelDb._openDbs.delete(this._fileKey);
|
|
224
218
|
this._workspace?.close();
|
|
225
|
-
this.locks.
|
|
219
|
+
this.locks[Symbols_1._close]();
|
|
226
220
|
this._locks = undefined;
|
|
227
221
|
this._codeService?.close();
|
|
228
222
|
this._codeService = undefined;
|
|
229
223
|
if (!this.isReadonly)
|
|
230
224
|
this.saveChanges();
|
|
231
|
-
this.
|
|
225
|
+
this[Symbols_1._nativeDb].closeFile();
|
|
232
226
|
}
|
|
233
227
|
/** @internal */
|
|
234
228
|
async refreshContainerForRpc(_userAccessToken) { }
|
|
@@ -242,7 +236,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
242
236
|
}
|
|
243
237
|
/** @internal */
|
|
244
238
|
initializeIModelDb() {
|
|
245
|
-
const props = this.
|
|
239
|
+
const props = this[Symbols_1._nativeDb].getIModelProps();
|
|
246
240
|
super.initialize(props.rootSubject.name, props);
|
|
247
241
|
if (this._initialized)
|
|
248
242
|
return;
|
|
@@ -279,9 +273,9 @@ class IModelDb extends core_common_1.IModel {
|
|
|
279
273
|
/** Return `true` if the underlying nativeDb is open and valid.
|
|
280
274
|
* @internal
|
|
281
275
|
*/
|
|
282
|
-
get isOpen() { return this.
|
|
276
|
+
get isOpen() { return this[Symbols_1._nativeDb].isOpen(); }
|
|
283
277
|
/** Get the briefcase Id of this iModel */
|
|
284
|
-
getBriefcaseId() { return this.isOpen ? this.
|
|
278
|
+
getBriefcaseId() { return this.isOpen ? this[Symbols_1._nativeDb].getBriefcaseId() : core_common_1.BriefcaseIdValue.Illegal; }
|
|
285
279
|
/**
|
|
286
280
|
* Use a prepared ECSQL statement, potentially from the statement cache. If the requested statement doesn't exist
|
|
287
281
|
* in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved
|
|
@@ -355,11 +349,11 @@ class IModelDb extends core_common_1.IModel {
|
|
|
355
349
|
* @public
|
|
356
350
|
* */
|
|
357
351
|
createQueryReader(ecsql, params, config) {
|
|
358
|
-
if (!this.
|
|
352
|
+
if (!this[Symbols_1._nativeDb].isOpen())
|
|
359
353
|
throw new core_common_1.IModelError(core_bentley_1.DbResult.BE_SQLITE_ERROR, "db not open");
|
|
360
354
|
const executor = {
|
|
361
355
|
execute: async (request) => {
|
|
362
|
-
return ConcurrentQuery_1.ConcurrentQuery.executeQueryRequest(this.
|
|
356
|
+
return ConcurrentQuery_1.ConcurrentQuery.executeQueryRequest(this[Symbols_1._nativeDb], request);
|
|
363
357
|
},
|
|
364
358
|
};
|
|
365
359
|
return new core_common_1.ECSqlReader(executor, ecsql, params, config);
|
|
@@ -494,11 +488,36 @@ class IModelDb extends core_common_1.IModel {
|
|
|
494
488
|
*/
|
|
495
489
|
prepareSqliteStatement(sql, logErrors = true) {
|
|
496
490
|
const stmt = new SqliteStatement_1.SqliteStatement(sql);
|
|
497
|
-
stmt.prepare(this.
|
|
491
|
+
stmt.prepare(this[Symbols_1._nativeDb], logErrors);
|
|
498
492
|
return stmt;
|
|
499
493
|
}
|
|
500
494
|
/**
|
|
501
|
-
* queries the BisCore.SubCategory table for
|
|
495
|
+
* queries the BisCore.SubCategory table for entries that are children of used spatial categories and 3D elements.
|
|
496
|
+
* @returns array of SubCategoryResultRow
|
|
497
|
+
* @internal
|
|
498
|
+
*/
|
|
499
|
+
async queryAllUsedSpatialSubCategories() {
|
|
500
|
+
const result = [];
|
|
501
|
+
const parentCategoriesQuery = `SELECT DISTINCT Category.Id AS id FROM BisCore.GeometricElement3d WHERE Category.Id IN (SELECT ECInstanceId FROM BisCore.SpatialCategory)`;
|
|
502
|
+
const parentCategories = [];
|
|
503
|
+
for await (const row of this.createQueryReader(parentCategoriesQuery)) {
|
|
504
|
+
parentCategories.push(row.id);
|
|
505
|
+
}
|
|
506
|
+
;
|
|
507
|
+
const where = [...parentCategories].join(",");
|
|
508
|
+
const query = `SELECT ECInstanceId as id, Parent.Id as parentId, Properties as appearance FROM BisCore.SubCategory WHERE Parent.Id IN (${where})`;
|
|
509
|
+
try {
|
|
510
|
+
for await (const row of this.createQueryReader(query, undefined, { rowFormat: core_common_1.QueryRowFormat.UseJsPropertyNames })) {
|
|
511
|
+
result.push(row.toRow());
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
catch {
|
|
515
|
+
// We can ignore the error here, and just return whatever we were able to query.
|
|
516
|
+
}
|
|
517
|
+
return result;
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* queries the BisCore.SubCategory table for the entries that are children of the passed categoryIds.
|
|
502
521
|
* @param categoryIds categoryIds to query
|
|
503
522
|
* @returns array of SubCategoryResultRow
|
|
504
523
|
* @internal
|
|
@@ -582,7 +601,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
582
601
|
computeProjectExtents(options) {
|
|
583
602
|
const wantFullExtents = true === options?.reportExtentsWithOutliers;
|
|
584
603
|
const wantOutliers = true === options?.reportOutliers;
|
|
585
|
-
const result = this.
|
|
604
|
+
const result = this[Symbols_1._nativeDb].computeProjectExtents(wantFullExtents, wantOutliers);
|
|
586
605
|
return {
|
|
587
606
|
extents: core_geometry_1.Range3d.fromJSON(result.extents),
|
|
588
607
|
extentsWithOutliers: result.fullExtents ? core_geometry_1.Range3d.fromJSON(result.fullExtents) : undefined,
|
|
@@ -596,7 +615,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
596
615
|
}
|
|
597
616
|
/** Update the IModelProps of this iModel in the database. */
|
|
598
617
|
updateIModelProps() {
|
|
599
|
-
this.
|
|
618
|
+
this[Symbols_1._nativeDb].updateIModelProps(this.toJSON());
|
|
600
619
|
}
|
|
601
620
|
/** Commit pending changes to this iModel.
|
|
602
621
|
* @param description Optional description of the changes
|
|
@@ -605,13 +624,13 @@ class IModelDb extends core_common_1.IModel {
|
|
|
605
624
|
saveChanges(description) {
|
|
606
625
|
if (this.openMode === core_bentley_1.OpenMode.Readonly)
|
|
607
626
|
throw new core_common_1.IModelError(core_bentley_1.IModelStatus.ReadOnly, "IModelDb was opened read-only");
|
|
608
|
-
const stat = this.
|
|
627
|
+
const stat = this[Symbols_1._nativeDb].saveChanges(description);
|
|
609
628
|
if (core_bentley_1.DbResult.BE_SQLITE_OK !== stat)
|
|
610
629
|
throw new core_common_1.IModelError(stat, `Could not save changes (${description})`);
|
|
611
630
|
}
|
|
612
631
|
/** Abandon pending changes in this iModel. */
|
|
613
632
|
abandonChanges() {
|
|
614
|
-
this.
|
|
633
|
+
this[Symbols_1._nativeDb].abandonChanges();
|
|
615
634
|
}
|
|
616
635
|
/**
|
|
617
636
|
* Save all changes and perform a [checkpoint](https://www.sqlite.org/c3ref/wal_checkpoint_v2.html) on this IModelDb.
|
|
@@ -624,20 +643,22 @@ class IModelDb extends core_common_1.IModel {
|
|
|
624
643
|
performCheckpoint() {
|
|
625
644
|
if (!this.isReadonly) {
|
|
626
645
|
this.saveChanges();
|
|
627
|
-
this.
|
|
646
|
+
this[Symbols_1._nativeDb].performCheckpoint();
|
|
628
647
|
}
|
|
629
648
|
}
|
|
630
|
-
/** @internal
|
|
649
|
+
/** @internal
|
|
650
|
+
* @deprecated in 4.8. Use `txns.reverseTxns`.
|
|
651
|
+
*/
|
|
631
652
|
reverseTxns(numOperations) {
|
|
632
|
-
return this.
|
|
653
|
+
return this[Symbols_1._nativeDb].reverseTxns(numOperations);
|
|
633
654
|
}
|
|
634
655
|
/** @internal */
|
|
635
656
|
reinstateTxn() {
|
|
636
|
-
return this.
|
|
657
|
+
return this[Symbols_1._nativeDb].reinstateTxn();
|
|
637
658
|
}
|
|
638
659
|
/** @internal */
|
|
639
660
|
restartTxnSession() {
|
|
640
|
-
return this.
|
|
661
|
+
return this[Symbols_1._nativeDb].restartTxnSession();
|
|
641
662
|
}
|
|
642
663
|
/** Import an ECSchema. On success, the schema definition is stored in the iModel.
|
|
643
664
|
* This method is asynchronous (must be awaited) because, in the case where this IModelDb is a briefcase, this method first obtains the schema lock from the iModel server.
|
|
@@ -653,20 +674,20 @@ class IModelDb extends core_common_1.IModel {
|
|
|
653
674
|
if (schemaFileNames.length === 0)
|
|
654
675
|
return;
|
|
655
676
|
const maybeCustomNativeContext = options?.ecSchemaXmlContext?.nativeContext;
|
|
656
|
-
if (this.
|
|
677
|
+
if (this[Symbols_1._nativeDb].schemaSyncEnabled()) {
|
|
657
678
|
await SchemaSync_1.SchemaSync.withLockedAccess(this, { openMode: core_bentley_1.OpenMode.Readonly, operationName: "schema sync" }, async (syncAccess) => {
|
|
658
679
|
const schemaSyncDbUri = syncAccess.getUri();
|
|
659
680
|
this.saveChanges();
|
|
660
681
|
try {
|
|
661
|
-
this.
|
|
682
|
+
this[Symbols_1._nativeDb].importSchemas(schemaFileNames, { schemaLockHeld: false, ecSchemaXmlContext: maybeCustomNativeContext, schemaSyncDbUri });
|
|
662
683
|
}
|
|
663
684
|
catch (outerErr) {
|
|
664
685
|
if (core_bentley_1.DbResult.BE_SQLITE_ERROR_DataTransformRequired === outerErr.errorNumber) {
|
|
665
686
|
this.abandonChanges();
|
|
666
|
-
if (this.
|
|
687
|
+
if (this[Symbols_1._nativeDb].getITwinId() !== core_bentley_1.Guid.empty)
|
|
667
688
|
await this.acquireSchemaLock();
|
|
668
689
|
try {
|
|
669
|
-
this.
|
|
690
|
+
this[Symbols_1._nativeDb].importSchemas(schemaFileNames, { schemaLockHeld: true, ecSchemaXmlContext: maybeCustomNativeContext, schemaSyncDbUri });
|
|
670
691
|
}
|
|
671
692
|
catch (innerErr) {
|
|
672
693
|
throw new core_common_1.IModelError(innerErr.errorNumber, innerErr.message);
|
|
@@ -683,10 +704,10 @@ class IModelDb extends core_common_1.IModel {
|
|
|
683
704
|
schemaLockHeld: true,
|
|
684
705
|
ecSchemaXmlContext: maybeCustomNativeContext,
|
|
685
706
|
};
|
|
686
|
-
if (this.
|
|
707
|
+
if (this[Symbols_1._nativeDb].getITwinId() !== core_bentley_1.Guid.empty) // if this iModel is associated with an iTwin, importing schema requires the schema lock
|
|
687
708
|
await this.acquireSchemaLock();
|
|
688
709
|
try {
|
|
689
|
-
this.
|
|
710
|
+
this[Symbols_1._nativeDb].importSchemas(schemaFileNames, nativeImportOptions);
|
|
690
711
|
}
|
|
691
712
|
catch (err) {
|
|
692
713
|
throw new core_common_1.IModelError(err.errorNumber, err.message);
|
|
@@ -706,20 +727,20 @@ class IModelDb extends core_common_1.IModel {
|
|
|
706
727
|
async importSchemaStrings(serializedXmlSchemas) {
|
|
707
728
|
if (serializedXmlSchemas.length === 0)
|
|
708
729
|
return;
|
|
709
|
-
if (this.
|
|
730
|
+
if (this[Symbols_1._nativeDb].schemaSyncEnabled()) {
|
|
710
731
|
await SchemaSync_1.SchemaSync.withLockedAccess(this, { openMode: core_bentley_1.OpenMode.Readonly, operationName: "schemaSync" }, async (syncAccess) => {
|
|
711
732
|
const schemaSyncDbUri = syncAccess.getUri();
|
|
712
733
|
this.saveChanges();
|
|
713
734
|
try {
|
|
714
|
-
this.
|
|
735
|
+
this[Symbols_1._nativeDb].importXmlSchemas(serializedXmlSchemas, { schemaLockHeld: false, schemaSyncDbUri });
|
|
715
736
|
}
|
|
716
737
|
catch (outerErr) {
|
|
717
738
|
if (core_bentley_1.DbResult.BE_SQLITE_ERROR_DataTransformRequired === outerErr.errorNumber) {
|
|
718
739
|
this.abandonChanges();
|
|
719
|
-
if (this.
|
|
740
|
+
if (this[Symbols_1._nativeDb].getITwinId() !== core_bentley_1.Guid.empty)
|
|
720
741
|
await this.acquireSchemaLock();
|
|
721
742
|
try {
|
|
722
|
-
this.
|
|
743
|
+
this[Symbols_1._nativeDb].importXmlSchemas(serializedXmlSchemas, { schemaLockHeld: true, schemaSyncDbUri });
|
|
723
744
|
}
|
|
724
745
|
catch (innerErr) {
|
|
725
746
|
throw new core_common_1.IModelError(innerErr.errorNumber, innerErr.message);
|
|
@@ -735,7 +756,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
735
756
|
if (this.iTwinId && this.iTwinId !== core_bentley_1.Guid.empty) // if this iModel is associated with an iTwin, importing schema requires the schema lock
|
|
736
757
|
await this.acquireSchemaLock();
|
|
737
758
|
try {
|
|
738
|
-
this.
|
|
759
|
+
this[Symbols_1._nativeDb].importXmlSchemas(serializedXmlSchemas, { schemaLockHeld: true });
|
|
739
760
|
}
|
|
740
761
|
catch (err) {
|
|
741
762
|
throw new core_common_1.IModelError(err.errorNumber, err.message);
|
|
@@ -780,7 +801,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
780
801
|
if (isUpgradeRequested && openMode !== core_bentley_1.OpenMode.ReadWrite)
|
|
781
802
|
throw new core_common_1.IModelError(core_bentley_1.IModelStatus.UpgradeFailed, "Cannot upgrade a Readonly Db");
|
|
782
803
|
try {
|
|
783
|
-
const nativeDb = new
|
|
804
|
+
const nativeDb = new NativePlatform_1.IModelNative.platform.DgnDb();
|
|
784
805
|
const container = props?.container;
|
|
785
806
|
if (container) {
|
|
786
807
|
// temp files for cloud-based Dbs should be in the profileDir in a subdirectory named for their container
|
|
@@ -870,7 +891,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
870
891
|
*/
|
|
871
892
|
prepareStatement(sql, logErrors = true) {
|
|
872
893
|
const stmt = new ECSqlStatement_1.ECSqlStatement();
|
|
873
|
-
stmt.prepare(this.
|
|
894
|
+
stmt.prepare(this[Symbols_1._nativeDb], sql, logErrors);
|
|
874
895
|
return stmt;
|
|
875
896
|
}
|
|
876
897
|
/** Prepare an ECSQL statement.
|
|
@@ -879,7 +900,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
879
900
|
*/
|
|
880
901
|
tryPrepareStatement(sql) {
|
|
881
902
|
const statement = new ECSqlStatement_1.ECSqlStatement();
|
|
882
|
-
const result = statement.tryPrepare(this.
|
|
903
|
+
const result = statement.tryPrepare(this[Symbols_1._nativeDb], sql);
|
|
883
904
|
return core_bentley_1.DbResult.BE_SQLITE_OK === result.status ? statement : undefined;
|
|
884
905
|
}
|
|
885
906
|
/** Construct an entity (Element or Model) from an iModel.
|
|
@@ -959,7 +980,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
959
980
|
const className = classFullName.split(":");
|
|
960
981
|
if (className.length !== 2)
|
|
961
982
|
throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadArg, `Invalid classFullName: ${classFullName}`);
|
|
962
|
-
const val = this.
|
|
983
|
+
const val = this[Symbols_1._nativeDb].getECClassMetaData(className[0], className[1]);
|
|
963
984
|
if (val.error)
|
|
964
985
|
throw new core_common_1.IModelError(val.error.status, `Error getting class meta data for: ${classFullName}`);
|
|
965
986
|
(0, core_bentley_1.assert)(undefined !== val.result);
|
|
@@ -975,7 +996,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
975
996
|
* @throws if the schema can not be found or loaded.
|
|
976
997
|
*/
|
|
977
998
|
getSchemaProps(name) {
|
|
978
|
-
return this.
|
|
999
|
+
return this[Symbols_1._nativeDb].getSchemaProps(name);
|
|
979
1000
|
}
|
|
980
1001
|
/** Query if this iModel contains the definition of the specified class.
|
|
981
1002
|
* @param classFullName The full name of the class, for example, SomeSchema:SomeClass
|
|
@@ -985,7 +1006,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
985
1006
|
*/
|
|
986
1007
|
containsClass(classFullName) {
|
|
987
1008
|
const classNameParts = classFullName.replace(".", ":").split(":");
|
|
988
|
-
return classNameParts.length === 2 && this.
|
|
1009
|
+
return classNameParts.length === 2 && this[Symbols_1._nativeDb].getECClassMetaData(classNameParts[0], classNameParts[1]).error === undefined;
|
|
989
1010
|
}
|
|
990
1011
|
/** Query for a schema of the specified name in this iModel.
|
|
991
1012
|
* @returns The schema version as a semver-compatible string or `undefined` if the schema has not been imported.
|
|
@@ -1009,49 +1030,49 @@ class IModelDb extends core_common_1.IModel {
|
|
|
1009
1030
|
* @alpha
|
|
1010
1031
|
*/
|
|
1011
1032
|
async queryTextureData(props) {
|
|
1012
|
-
return this.
|
|
1033
|
+
return this[Symbols_1._nativeDb].queryTextureData(props);
|
|
1013
1034
|
}
|
|
1014
1035
|
/** Query a "file property" from this iModel, as a string.
|
|
1015
1036
|
* @returns the property string or undefined if the property is not present.
|
|
1016
1037
|
*/
|
|
1017
1038
|
queryFilePropertyString(prop) {
|
|
1018
|
-
return this.
|
|
1039
|
+
return this[Symbols_1._nativeDb].queryFileProperty(prop, true);
|
|
1019
1040
|
}
|
|
1020
1041
|
/** Query a "file property" from this iModel, as a blob.
|
|
1021
1042
|
* @returns the property blob or undefined if the property is not present.
|
|
1022
1043
|
*/
|
|
1023
1044
|
queryFilePropertyBlob(prop) {
|
|
1024
|
-
return this.
|
|
1045
|
+
return this[Symbols_1._nativeDb].queryFileProperty(prop, false);
|
|
1025
1046
|
}
|
|
1026
1047
|
/** Save a "file property" to this iModel
|
|
1027
1048
|
* @param prop the FilePropertyProps that describes the new property
|
|
1028
1049
|
* @param value either a string or a blob to save as the file property
|
|
1029
1050
|
*/
|
|
1030
1051
|
saveFileProperty(prop, strValue, blobVal) {
|
|
1031
|
-
this.
|
|
1052
|
+
this[Symbols_1._nativeDb].saveFileProperty(prop, strValue, blobVal);
|
|
1032
1053
|
}
|
|
1033
1054
|
/** delete a "file property" from this iModel
|
|
1034
1055
|
* @param prop the FilePropertyProps that describes the property
|
|
1035
1056
|
*/
|
|
1036
1057
|
deleteFileProperty(prop) {
|
|
1037
|
-
this.
|
|
1058
|
+
this[Symbols_1._nativeDb].saveFileProperty(prop, undefined, undefined);
|
|
1038
1059
|
}
|
|
1039
1060
|
/** Query for the next available major id for a "file property" from this iModel.
|
|
1040
1061
|
* @param prop the FilePropertyProps that describes the property
|
|
1041
1062
|
* @returns the next available (that is, an unused) id for prop. If none are present, will return 0.
|
|
1042
1063
|
*/
|
|
1043
|
-
queryNextAvailableFileProperty(prop) { return this.
|
|
1064
|
+
queryNextAvailableFileProperty(prop) { return this[Symbols_1._nativeDb].queryNextAvailableFileProperty(prop); }
|
|
1044
1065
|
/** @internal */
|
|
1045
1066
|
async requestSnap(sessionId, props) {
|
|
1046
1067
|
let request = this._snaps.get(sessionId);
|
|
1047
1068
|
if (undefined === request) {
|
|
1048
|
-
request = new
|
|
1069
|
+
request = new NativePlatform_1.IModelNative.platform.SnapRequest();
|
|
1049
1070
|
this._snaps.set(sessionId, request);
|
|
1050
1071
|
}
|
|
1051
1072
|
else
|
|
1052
1073
|
request.cancelSnap();
|
|
1053
1074
|
try {
|
|
1054
|
-
return await request.doSnap(this.
|
|
1075
|
+
return await request.doSnap(this[Symbols_1._nativeDb], core_bentley_1.JsonUtils.toObject(props));
|
|
1055
1076
|
}
|
|
1056
1077
|
finally {
|
|
1057
1078
|
this._snaps.delete(sessionId);
|
|
@@ -1069,19 +1090,19 @@ class IModelDb extends core_common_1.IModel {
|
|
|
1069
1090
|
}
|
|
1070
1091
|
/** Get the clip containment status for the supplied elements. */
|
|
1071
1092
|
async getGeometryContainment(props) {
|
|
1072
|
-
return this.
|
|
1093
|
+
return this[Symbols_1._nativeDb].getGeometryContainment(core_bentley_1.JsonUtils.toObject(props));
|
|
1073
1094
|
}
|
|
1074
1095
|
/** Get the mass properties for the supplied elements. */
|
|
1075
1096
|
async getMassProperties(props) {
|
|
1076
|
-
return this.
|
|
1097
|
+
return this[Symbols_1._nativeDb].getMassProperties(core_bentley_1.JsonUtils.toObject(props));
|
|
1077
1098
|
}
|
|
1078
1099
|
/** Get the IModel coordinate corresponding to each GeoCoordinate point in the input */
|
|
1079
1100
|
async getIModelCoordinatesFromGeoCoordinates(props) {
|
|
1080
|
-
return this.
|
|
1101
|
+
return this[Symbols_1._nativeDb].getIModelCoordinatesFromGeoCoordinates(props);
|
|
1081
1102
|
}
|
|
1082
1103
|
/** Get the GeoCoordinate (longitude, latitude, elevation) corresponding to each IModel Coordinate point in the input */
|
|
1083
1104
|
async getGeoCoordinatesFromIModelCoordinates(props) {
|
|
1084
|
-
return this.
|
|
1105
|
+
return this[Symbols_1._nativeDb].getGeoCoordinatesFromIModelCoordinates(props);
|
|
1085
1106
|
}
|
|
1086
1107
|
/** Export meshes suitable for graphics APIs from arbitrary geometry in elements in this IModelDb.
|
|
1087
1108
|
* * Requests can be slow when processing many elements so it is expected that this function be used on a dedicated backend,
|
|
@@ -1116,7 +1137,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
1116
1137
|
* @public
|
|
1117
1138
|
*/
|
|
1118
1139
|
exportGraphics(exportProps) {
|
|
1119
|
-
return this.
|
|
1140
|
+
return this[Symbols_1._nativeDb].exportGraphics(exportProps);
|
|
1120
1141
|
}
|
|
1121
1142
|
/**
|
|
1122
1143
|
* Exports meshes suitable for graphics APIs from a specified [GeometryPart]($core-backend)
|
|
@@ -1131,14 +1152,14 @@ class IModelDb extends core_common_1.IModel {
|
|
|
1131
1152
|
* @public
|
|
1132
1153
|
*/
|
|
1133
1154
|
exportPartGraphics(exportProps) {
|
|
1134
|
-
return this.
|
|
1155
|
+
return this[Symbols_1._nativeDb].exportPartGraphics(exportProps);
|
|
1135
1156
|
}
|
|
1136
1157
|
/** Request geometry stream information from an element in binary format instead of json.
|
|
1137
1158
|
* @returns IModelStatus.Success if successful
|
|
1138
1159
|
* @beta
|
|
1139
1160
|
*/
|
|
1140
1161
|
elementGeometryRequest(requestProps) {
|
|
1141
|
-
return this.
|
|
1162
|
+
return this[Symbols_1._nativeDb].processGeometryStream(requestProps);
|
|
1142
1163
|
}
|
|
1143
1164
|
/** Create brep geometry for inclusion in an element's geometry stream.
|
|
1144
1165
|
* @returns IModelStatus.Success if successful
|
|
@@ -1146,7 +1167,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
1146
1167
|
* @alpha
|
|
1147
1168
|
*/
|
|
1148
1169
|
createBRepGeometry(createProps) {
|
|
1149
|
-
return this.
|
|
1170
|
+
return this[Symbols_1._nativeDb].createBRepGeometry(createProps);
|
|
1150
1171
|
}
|
|
1151
1172
|
/** Generate graphics for an element or geometry stream.
|
|
1152
1173
|
* @see [readElementGraphics]($frontend) to convert the result to a [RenderGraphic]($frontend) for display.
|
|
@@ -1182,35 +1203,65 @@ class IModelDb extends core_common_1.IModel {
|
|
|
1182
1203
|
this.saveChanges("delete settings");
|
|
1183
1204
|
}
|
|
1184
1205
|
/** Load all setting dictionaries in this iModel into `this.workspace.settings` */
|
|
1185
|
-
|
|
1186
|
-
if (!this.
|
|
1206
|
+
loadIModelSettings() {
|
|
1207
|
+
if (!this[Symbols_1._nativeDb].isOpen())
|
|
1187
1208
|
return;
|
|
1188
1209
|
this.withSqliteStatement("SELECT Name,StrData FROM be_Prop WHERE Namespace=?", (stmt) => {
|
|
1189
1210
|
stmt.bindString(1, IModelDb._settingPropNamespace);
|
|
1190
1211
|
while (stmt.nextRow()) {
|
|
1191
1212
|
try {
|
|
1192
|
-
const
|
|
1193
|
-
this.workspace.settings.addDictionary(stmt.getValueString(0), Settings_1.SettingsPriority.iModel,
|
|
1213
|
+
const settings = JSON.parse(stmt.getValueString(1));
|
|
1214
|
+
this.workspace.settings.addDictionary({ name: stmt.getValueString(0), priority: Settings_1.SettingsPriority.iModel }, settings);
|
|
1194
1215
|
}
|
|
1195
1216
|
catch (e) {
|
|
1196
|
-
|
|
1217
|
+
Workspace_1.Workspace.exceptionDiagnosticFn(e);
|
|
1197
1218
|
}
|
|
1198
1219
|
}
|
|
1199
1220
|
});
|
|
1200
1221
|
}
|
|
1222
|
+
/** @internal */
|
|
1223
|
+
async loadWorkspaceSettings() {
|
|
1224
|
+
try {
|
|
1225
|
+
const problems = [];
|
|
1226
|
+
const settingProps = [];
|
|
1227
|
+
// Note: we can't use `getArray` here because we only look at dictionaries in the iModel's workspace, not appWorkspace.
|
|
1228
|
+
// Also, we must concatenate all entries in all of the dictionaries stored in the iModel into a single array *before*
|
|
1229
|
+
// calling `loadSettingsDictionary` since that function will add new dictionaries to the workspace.
|
|
1230
|
+
for (const dict of this.workspace.settings.dictionaries) {
|
|
1231
|
+
try {
|
|
1232
|
+
const props = dict.getSetting(Workspace_1.WorkspaceSettingNames.settingsWorkspaces);
|
|
1233
|
+
if (props)
|
|
1234
|
+
settingProps.push(...IModelHost_1.IModelHost.settingsSchemas.validateSetting(props, Workspace_1.WorkspaceSettingNames.settingsWorkspaces));
|
|
1235
|
+
}
|
|
1236
|
+
catch (e) {
|
|
1237
|
+
problems.push(e); // something wrong with the setting stored in the iModel
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
if (settingProps.length > 0)
|
|
1241
|
+
await this.workspace.loadSettingsDictionary(settingProps, problems);
|
|
1242
|
+
if (problems.length > 0)
|
|
1243
|
+
(0, WorkspaceImpl_1.throwWorkspaceDbLoadErrors)(`attempting to load workspace settings for iModel '${this.name}':`, problems);
|
|
1244
|
+
}
|
|
1245
|
+
catch (e) {
|
|
1246
|
+
// we don't want to throw exceptions when attempting to load Dictionaries. Call the diagnostics function instead.
|
|
1247
|
+
Workspace_1.Workspace.exceptionDiagnosticFn(e);
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1201
1250
|
/**
|
|
1202
|
-
* Controls how [Code]($common)s are copied from this iModel into another iModel, to work around problems with iModels
|
|
1251
|
+
* Controls how [Code]($common)s are copied from this iModel into another iModel, to work around problems with iModels
|
|
1252
|
+
* created by older connectors. The [imodel-transformer](https://github.com/iTwin/imodel-transformer) sets this appropriately
|
|
1253
|
+
* on your behalf - you should never need to set or interrogate this property yourself.
|
|
1203
1254
|
* @public
|
|
1204
1255
|
*/
|
|
1205
1256
|
get codeValueBehavior() {
|
|
1206
|
-
return this.
|
|
1257
|
+
return this[Symbols_1._nativeDb].getCodeValueBehavior();
|
|
1207
1258
|
}
|
|
1208
1259
|
set codeValueBehavior(newBehavior) {
|
|
1209
|
-
this.
|
|
1260
|
+
this[Symbols_1._nativeDb].setCodeValueBehavior(newBehavior);
|
|
1210
1261
|
}
|
|
1211
1262
|
/** @internal */
|
|
1212
1263
|
computeRangesForText(args) {
|
|
1213
|
-
const props = this.
|
|
1264
|
+
const props = this[Symbols_1._nativeDb].computeRangesForText(args.chars, args.fontId, args.bold, args.italic, args.widthFactor, args.lineHeight);
|
|
1214
1265
|
return {
|
|
1215
1266
|
layout: core_geometry_1.Range2d.fromJSON(props.layout),
|
|
1216
1267
|
justification: core_geometry_1.Range2d.fromJSON(props.justification),
|
|
@@ -1316,7 +1367,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1316
1367
|
*/
|
|
1317
1368
|
tryGetModelJson(modelIdArg) {
|
|
1318
1369
|
try {
|
|
1319
|
-
return this._iModel.
|
|
1370
|
+
return this._iModel[Symbols_1._nativeDb].getModel(modelIdArg);
|
|
1320
1371
|
}
|
|
1321
1372
|
catch (err) {
|
|
1322
1373
|
return undefined;
|
|
@@ -1361,7 +1412,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1361
1412
|
*/
|
|
1362
1413
|
insertModel(props) {
|
|
1363
1414
|
try {
|
|
1364
|
-
return props.id = this._iModel.
|
|
1415
|
+
return props.id = this._iModel[Symbols_1._nativeDb].insertModel(props);
|
|
1365
1416
|
}
|
|
1366
1417
|
catch (err) {
|
|
1367
1418
|
throw new core_common_1.IModelError(err.errorNumber, `Error inserting model [${err.message}], class=${props.classFullName}`);
|
|
@@ -1373,7 +1424,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1373
1424
|
*/
|
|
1374
1425
|
updateModel(props) {
|
|
1375
1426
|
try {
|
|
1376
|
-
this._iModel.
|
|
1427
|
+
this._iModel[Symbols_1._nativeDb].updateModel(props);
|
|
1377
1428
|
}
|
|
1378
1429
|
catch (err) {
|
|
1379
1430
|
throw new core_common_1.IModelError(err.errorNumber, `error updating model [${err.message}] id=${props.id}`);
|
|
@@ -1389,7 +1440,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1389
1440
|
* @see [[TxnManager.onModelGeometryChanged]] for the event emitted in response to such a change.
|
|
1390
1441
|
*/
|
|
1391
1442
|
updateGeometryGuid(modelId) {
|
|
1392
|
-
const error = this._iModel.
|
|
1443
|
+
const error = this._iModel[Symbols_1._nativeDb].updateModelGeometryGuid(modelId);
|
|
1393
1444
|
if (error !== core_bentley_1.IModelStatus.Success)
|
|
1394
1445
|
throw new core_common_1.IModelError(error, `updating geometry guid for model ${modelId}`);
|
|
1395
1446
|
}
|
|
@@ -1400,7 +1451,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1400
1451
|
deleteModel(ids) {
|
|
1401
1452
|
core_bentley_1.Id64.toIdSet(ids).forEach((id) => {
|
|
1402
1453
|
try {
|
|
1403
|
-
this._iModel.
|
|
1454
|
+
this._iModel[Symbols_1._nativeDb].deleteModel(id);
|
|
1404
1455
|
}
|
|
1405
1456
|
catch (err) {
|
|
1406
1457
|
throw new core_common_1.IModelError(err.errorNumber, `error deleting model [${err.message}] id ${id}`);
|
|
@@ -1418,7 +1469,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1418
1469
|
ids = typeof ids === "string" ? [ids] : ids;
|
|
1419
1470
|
if (ids.length === 0)
|
|
1420
1471
|
return [];
|
|
1421
|
-
return this._iModel.
|
|
1472
|
+
return this._iModel[Symbols_1._nativeDb].queryModelExtentsAsync(ids);
|
|
1422
1473
|
}
|
|
1423
1474
|
/** Computes the union of the volumes of all geometric elements within one or more [[GeometricModel]]s, specified by model Id.
|
|
1424
1475
|
* @see [[queryExtents]] to obtain discrete volumes for each model.
|
|
@@ -1473,7 +1524,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1473
1524
|
*/
|
|
1474
1525
|
tryGetElementJson(loadProps) {
|
|
1475
1526
|
try {
|
|
1476
|
-
return this._iModel.
|
|
1527
|
+
return this._iModel[Symbols_1._nativeDb].getElement(loadProps);
|
|
1477
1528
|
}
|
|
1478
1529
|
catch (err) {
|
|
1479
1530
|
return undefined;
|
|
@@ -1491,7 +1542,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1491
1542
|
props = { code: props };
|
|
1492
1543
|
}
|
|
1493
1544
|
try {
|
|
1494
|
-
return this._iModel.
|
|
1545
|
+
return this._iModel[Symbols_1._nativeDb].getElement(props);
|
|
1495
1546
|
}
|
|
1496
1547
|
catch (err) {
|
|
1497
1548
|
throw new core_common_1.IModelError(err.errorNumber, err.message);
|
|
@@ -1605,7 +1656,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1605
1656
|
*/
|
|
1606
1657
|
insertElement(elProps) {
|
|
1607
1658
|
try {
|
|
1608
|
-
return elProps.id = this._iModel.
|
|
1659
|
+
return elProps.id = this._iModel[Symbols_1._nativeDb].insertElement(elProps);
|
|
1609
1660
|
}
|
|
1610
1661
|
catch (err) {
|
|
1611
1662
|
err.message = `Error inserting element [${err.message}]`;
|
|
@@ -1626,7 +1677,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1626
1677
|
*/
|
|
1627
1678
|
updateElement(elProps) {
|
|
1628
1679
|
try {
|
|
1629
|
-
this._iModel.
|
|
1680
|
+
this._iModel[Symbols_1._nativeDb].updateElement(elProps);
|
|
1630
1681
|
}
|
|
1631
1682
|
catch (err) {
|
|
1632
1683
|
err.message = `Error updating element [${err.message}], id: ${elProps.id}`;
|
|
@@ -1643,7 +1694,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1643
1694
|
const iModel = this._iModel;
|
|
1644
1695
|
core_bentley_1.Id64.toIdSet(ids).forEach((id) => {
|
|
1645
1696
|
try {
|
|
1646
|
-
iModel.
|
|
1697
|
+
iModel[Symbols_1._nativeDb].deleteElement(id);
|
|
1647
1698
|
}
|
|
1648
1699
|
catch (err) {
|
|
1649
1700
|
err.message = `Error deleting element [${err.message}], id: ${id}`;
|
|
@@ -1663,7 +1714,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1663
1714
|
* @beta
|
|
1664
1715
|
*/
|
|
1665
1716
|
deleteDefinitionElements(definitionElementIds) {
|
|
1666
|
-
const usageInfo = this._iModel.
|
|
1717
|
+
const usageInfo = this._iModel[Symbols_1._nativeDb].queryDefinitionElementUsage(definitionElementIds);
|
|
1667
1718
|
if (!usageInfo) {
|
|
1668
1719
|
throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadRequest, "Error querying for DefinitionElement usage");
|
|
1669
1720
|
}
|
|
@@ -1677,7 +1728,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1677
1728
|
}
|
|
1678
1729
|
};
|
|
1679
1730
|
try {
|
|
1680
|
-
this._iModel.
|
|
1731
|
+
this._iModel[Symbols_1._nativeDb].beginPurgeOperation();
|
|
1681
1732
|
deleteIfUnused(usageInfo.spatialCategoryIds, usedIdSet);
|
|
1682
1733
|
deleteIfUnused(usageInfo.drawingCategoryIds, usedIdSet);
|
|
1683
1734
|
deleteIfUnused(usageInfo.viewDefinitionIds, usedIdSet);
|
|
@@ -1694,7 +1745,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1694
1745
|
}
|
|
1695
1746
|
}
|
|
1696
1747
|
finally {
|
|
1697
|
-
this._iModel.
|
|
1748
|
+
this._iModel[Symbols_1._nativeDb].endPurgeOperation();
|
|
1698
1749
|
}
|
|
1699
1750
|
if (usageInfo.viewDefinitionIds) {
|
|
1700
1751
|
// take another pass in case a deleted ViewDefinition was the only usage of these view-related DefinitionElements
|
|
@@ -1706,17 +1757,17 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1706
1757
|
if (usageInfo.modelSelectorIds)
|
|
1707
1758
|
viewRelatedIds = viewRelatedIds.concat(usageInfo.modelSelectorIds.filter((id) => usedIdSet.has(id)));
|
|
1708
1759
|
if (viewRelatedIds.length > 0) {
|
|
1709
|
-
const viewRelatedUsageInfo = this._iModel.
|
|
1760
|
+
const viewRelatedUsageInfo = this._iModel[Symbols_1._nativeDb].queryDefinitionElementUsage(viewRelatedIds);
|
|
1710
1761
|
if (viewRelatedUsageInfo) {
|
|
1711
1762
|
const usedViewRelatedIdSet = viewRelatedUsageInfo.usedIds ? core_bentley_1.Id64.toIdSet(viewRelatedUsageInfo.usedIds) : new Set();
|
|
1712
1763
|
try {
|
|
1713
|
-
this._iModel.
|
|
1764
|
+
this._iModel[Symbols_1._nativeDb].beginPurgeOperation();
|
|
1714
1765
|
deleteIfUnused(viewRelatedUsageInfo.displayStyleIds, usedViewRelatedIdSet);
|
|
1715
1766
|
deleteIfUnused(viewRelatedUsageInfo.categorySelectorIds, usedViewRelatedIdSet);
|
|
1716
1767
|
deleteIfUnused(viewRelatedUsageInfo.modelSelectorIds, usedViewRelatedIdSet);
|
|
1717
1768
|
}
|
|
1718
1769
|
finally {
|
|
1719
|
-
this._iModel.
|
|
1770
|
+
this._iModel[Symbols_1._nativeDb].endPurgeOperation();
|
|
1720
1771
|
}
|
|
1721
1772
|
viewRelatedIds.forEach((id) => {
|
|
1722
1773
|
if (!usedViewRelatedIdSet.has(id))
|
|
@@ -1854,9 +1905,9 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1854
1905
|
*/
|
|
1855
1906
|
getAspects(elementId, aspectClassFullName, excludedClassFullNames) {
|
|
1856
1907
|
if (aspectClassFullName === undefined) {
|
|
1857
|
-
const allAspects = this.runInstanceQuery(`SELECT $ FROM (
|
|
1858
|
-
SELECT ECInstanceId, ECClassId FROM Bis.ElementMultiAspect WHERE Element.Id = :elementId
|
|
1859
|
-
UNION ALL
|
|
1908
|
+
const allAspects = this.runInstanceQuery(`SELECT $ FROM (
|
|
1909
|
+
SELECT ECInstanceId, ECClassId FROM Bis.ElementMultiAspect WHERE Element.Id = :elementId
|
|
1910
|
+
UNION ALL
|
|
1860
1911
|
SELECT ECInstanceId, ECClassId FROM Bis.ElementUniqueAspect WHERE Element.Id = :elementId) OPTIONS USE_JS_PROP_NAMES DO_NOT_TRUNCATE_BLOB`, elementId, excludedClassFullNames);
|
|
1861
1912
|
if (allAspects.length === 0)
|
|
1862
1913
|
core_bentley_1.Logger.logInfo(BackendLoggerCategory_1.BackendLoggerCategory.ECDb, `No aspects found for class ${aspectClassFullName} and element ${elementId}`);
|
|
@@ -1864,7 +1915,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1864
1915
|
}
|
|
1865
1916
|
// Check if class is abstract
|
|
1866
1917
|
const fullClassName = aspectClassFullName.replace(".", ":").split(":");
|
|
1867
|
-
const val = this._iModel.
|
|
1918
|
+
const val = this._iModel[Symbols_1._nativeDb].getECClassMetaData(fullClassName[0], fullClassName[1]);
|
|
1868
1919
|
if (val.result !== undefined) {
|
|
1869
1920
|
const metaData = new core_common_1.EntityMetaData(JSON.parse(val.result));
|
|
1870
1921
|
if (metaData.modifier !== "Abstract") // Class is not abstract, use normal query to retrieve aspects
|
|
@@ -1874,7 +1925,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1874
1925
|
let classIdList = IModelDb.Elements.classMap.get(aspectClassFullName);
|
|
1875
1926
|
if (classIdList === undefined) {
|
|
1876
1927
|
const classIds = [];
|
|
1877
|
-
this._iModel.withPreparedStatement(`select SourceECInstanceId from meta.ClassHasAllBaseClasses where TargetECInstanceId = (select ECInstanceId from meta.ECClassDef where Name='${fullClassName[1]}'
|
|
1928
|
+
this._iModel.withPreparedStatement(`select SourceECInstanceId from meta.ClassHasAllBaseClasses where TargetECInstanceId = (select ECInstanceId from meta.ECClassDef where Name='${fullClassName[1]}'
|
|
1878
1929
|
and Schema.Id = (select ECInstanceId from meta.ECSchemaDef where Name='${fullClassName[0]}')) and SourceECInstanceId != TargetECInstanceId`, (statement) => {
|
|
1879
1930
|
while (statement.step() === core_bentley_1.DbResult.BE_SQLITE_ROW)
|
|
1880
1931
|
classIds.push(statement.getValue(0).getId());
|
|
@@ -1889,10 +1940,10 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1889
1940
|
return [];
|
|
1890
1941
|
}
|
|
1891
1942
|
// Execute an instance query to retrieve all aspects from all the derived classes
|
|
1892
|
-
const aspects = this.runInstanceQuery(`SELECT $ FROM (
|
|
1893
|
-
SELECT ECInstanceId, ECClassId FROM Bis.ElementMultiAspect WHERE Element.Id = :elementId AND ECClassId IN (${classIdList})
|
|
1894
|
-
UNION ALL
|
|
1895
|
-
SELECT ECInstanceId, ECClassId FROM Bis.ElementUniqueAspect WHERE Element.Id = :elementId AND ECClassId IN (${classIdList})
|
|
1943
|
+
const aspects = this.runInstanceQuery(`SELECT $ FROM (
|
|
1944
|
+
SELECT ECInstanceId, ECClassId FROM Bis.ElementMultiAspect WHERE Element.Id = :elementId AND ECClassId IN (${classIdList})
|
|
1945
|
+
UNION ALL
|
|
1946
|
+
SELECT ECInstanceId, ECClassId FROM Bis.ElementUniqueAspect WHERE Element.Id = :elementId AND ECClassId IN (${classIdList})
|
|
1896
1947
|
) OPTIONS USE_JS_PROP_NAMES DO_NOT_TRUNCATE_BLOB`, elementId, excludedClassFullNames);
|
|
1897
1948
|
if (aspects.length === 0)
|
|
1898
1949
|
core_bentley_1.Logger.logInfo(BackendLoggerCategory_1.BackendLoggerCategory.ECDb, `No aspects found for class ${aspectClassFullName} and element ${elementId}`);
|
|
@@ -1907,7 +1958,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1907
1958
|
*/
|
|
1908
1959
|
insertAspect(aspectProps) {
|
|
1909
1960
|
try {
|
|
1910
|
-
return this._iModel.
|
|
1961
|
+
return this._iModel[Symbols_1._nativeDb].insertElementAspect(aspectProps);
|
|
1911
1962
|
}
|
|
1912
1963
|
catch (err) {
|
|
1913
1964
|
throw new core_common_1.IModelError(err.errorNumber, `Error inserting ElementAspect [${err.message}], class: ${aspectProps.classFullName}`);
|
|
@@ -1919,7 +1970,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1919
1970
|
*/
|
|
1920
1971
|
updateAspect(aspectProps) {
|
|
1921
1972
|
try {
|
|
1922
|
-
this._iModel.
|
|
1973
|
+
this._iModel[Symbols_1._nativeDb].updateElementAspect(aspectProps);
|
|
1923
1974
|
}
|
|
1924
1975
|
catch (err) {
|
|
1925
1976
|
throw new core_common_1.IModelError(err.errorNumber, `Error updating ElementAspect [${err.message}], id: ${aspectProps.id}`);
|
|
@@ -1933,7 +1984,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1933
1984
|
const iModel = this._iModel;
|
|
1934
1985
|
core_bentley_1.Id64.toIdSet(aspectInstanceIds).forEach((aspectInstanceId) => {
|
|
1935
1986
|
try {
|
|
1936
|
-
iModel.
|
|
1987
|
+
iModel[Symbols_1._nativeDb].deleteElementAspect(aspectInstanceId);
|
|
1937
1988
|
}
|
|
1938
1989
|
catch (err) {
|
|
1939
1990
|
throw new core_common_1.IModelError(err.errorNumber, `Error deleting ElementAspect [${err.message}], id: ${aspectInstanceId}`);
|
|
@@ -1972,7 +2023,6 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1972
2023
|
}
|
|
1973
2024
|
const accessToken = await CloudSqlite_1.CloudSqlite.requestToken({
|
|
1974
2025
|
...props,
|
|
1975
|
-
userToken: args.userToken,
|
|
1976
2026
|
accessLevel: args.accessLevel,
|
|
1977
2027
|
});
|
|
1978
2028
|
if (!this._viewStore)
|
|
@@ -2079,7 +2129,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
2079
2129
|
const viewStateData = this.loadViewData(viewDefinitionId, options);
|
|
2080
2130
|
const baseModelId = viewStateData.viewDefinitionProps.baseModelId;
|
|
2081
2131
|
if (baseModelId) {
|
|
2082
|
-
const drawingExtents = core_geometry_1.Range3d.fromJSON(this._iModel.
|
|
2132
|
+
const drawingExtents = core_geometry_1.Range3d.fromJSON(this._iModel[Symbols_1._nativeDb].queryModelExtents({ id: baseModelId }).modelExtents);
|
|
2083
2133
|
if (!drawingExtents.isNull)
|
|
2084
2134
|
viewStateData.modelExtents = drawingExtents.toJSON();
|
|
2085
2135
|
}
|
|
@@ -2107,11 +2157,11 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
2107
2157
|
*/
|
|
2108
2158
|
getThumbnail(viewDefinitionId) {
|
|
2109
2159
|
const viewArg = this.getViewThumbnailArg(viewDefinitionId);
|
|
2110
|
-
const sizeProps = this._iModel.
|
|
2160
|
+
const sizeProps = this._iModel[Symbols_1._nativeDb].queryFileProperty(viewArg, true);
|
|
2111
2161
|
if (undefined === sizeProps)
|
|
2112
2162
|
return undefined;
|
|
2113
2163
|
const out = JSON.parse(sizeProps);
|
|
2114
|
-
out.image = this._iModel.
|
|
2164
|
+
out.image = this._iModel[Symbols_1._nativeDb].queryFileProperty(viewArg, false);
|
|
2115
2165
|
return out;
|
|
2116
2166
|
}
|
|
2117
2167
|
/** Save a thumbnail for a view.
|
|
@@ -2122,7 +2172,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
2122
2172
|
saveThumbnail(viewDefinitionId, thumbnail) {
|
|
2123
2173
|
const viewArg = this.getViewThumbnailArg(viewDefinitionId);
|
|
2124
2174
|
const props = { format: thumbnail.format, height: thumbnail.height, width: thumbnail.width };
|
|
2125
|
-
this._iModel.
|
|
2175
|
+
this._iModel[Symbols_1._nativeDb].saveFileProperty(viewArg, JSON.stringify(props), thumbnail.image);
|
|
2126
2176
|
return 0;
|
|
2127
2177
|
}
|
|
2128
2178
|
/** Set the default view property the iModel.
|
|
@@ -2162,7 +2212,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
2162
2212
|
/** @internal */
|
|
2163
2213
|
async requestTileTreeProps(id) {
|
|
2164
2214
|
return new Promise((resolve, reject) => {
|
|
2165
|
-
this._iModel.
|
|
2215
|
+
this._iModel[Symbols_1._nativeDb].getTileTree(id, (ret) => {
|
|
2166
2216
|
if (undefined !== ret.error)
|
|
2167
2217
|
reject(new core_common_1.IModelError(ret.error.status, `TreeId=${id}`));
|
|
2168
2218
|
else
|
|
@@ -2173,7 +2223,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
2173
2223
|
pollTileContent(resolve, reject, treeId, tileId) {
|
|
2174
2224
|
let ret;
|
|
2175
2225
|
try {
|
|
2176
|
-
ret = this._iModel.
|
|
2226
|
+
ret = this._iModel[Symbols_1._nativeDb].pollTileContent(treeId, tileId);
|
|
2177
2227
|
}
|
|
2178
2228
|
catch (err) {
|
|
2179
2229
|
// Typically "imodel not open".
|
|
@@ -2212,7 +2262,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
2212
2262
|
/** @internal */
|
|
2213
2263
|
async getTileContent(treeId, tileId) {
|
|
2214
2264
|
const ret = await new Promise((resolve) => {
|
|
2215
|
-
this._iModel.
|
|
2265
|
+
this._iModel[Symbols_1._nativeDb].getTileContent(treeId, tileId, resolve);
|
|
2216
2266
|
});
|
|
2217
2267
|
if (undefined !== ret.error) {
|
|
2218
2268
|
throw new core_common_1.IModelError(ret.error.status, `TreeId=${treeId} TileId=${tileId}`);
|
|
@@ -2251,12 +2301,12 @@ class BriefcaseDb extends IModelDb {
|
|
|
2251
2301
|
* - the "no locking" flag is not present. This is a property of an iModel, established when the iModel is created in IModelHub.
|
|
2252
2302
|
*/
|
|
2253
2303
|
get useLockServer() {
|
|
2254
|
-
return !this.
|
|
2304
|
+
return !this[Symbols_1._nativeDb].isReadonly() && (this.briefcaseId !== core_common_1.BriefcaseIdValue.Unassigned) && (undefined === this[Symbols_1._nativeDb].queryLocalValue(BriefcaseLocalValue.NoLocking));
|
|
2255
2305
|
}
|
|
2256
2306
|
// if the iModel uses a lock server, create a ServerBasedLocks LockControl for this BriefcaseDb.
|
|
2257
2307
|
makeLockControl() {
|
|
2258
2308
|
if (this.useLockServer)
|
|
2259
|
-
this._locks =
|
|
2309
|
+
this._locks = (0, ServerBasedLocks_1.createServerBasedLocks)(this);
|
|
2260
2310
|
}
|
|
2261
2311
|
constructor(args) {
|
|
2262
2312
|
super({ ...args, changeset: args.nativeDb.getCurrentChangeset() });
|
|
@@ -2278,14 +2328,14 @@ class BriefcaseDb extends IModelDb {
|
|
|
2278
2328
|
};
|
|
2279
2329
|
const isSchemaSyncEnabled = await withBriefcaseDb(briefcase, async (db) => {
|
|
2280
2330
|
await SchemaSync_1.SchemaSync.pull(db);
|
|
2281
|
-
return db.
|
|
2331
|
+
return db[Symbols_1._nativeDb].schemaSyncEnabled();
|
|
2282
2332
|
});
|
|
2283
2333
|
if (isSchemaSyncEnabled) {
|
|
2284
2334
|
await SchemaSync_1.SchemaSync.withLockedAccess(briefcase, { openMode: core_bentley_1.OpenMode.Readonly, operationName: "schema sync" }, async (syncAccess) => {
|
|
2285
2335
|
const schemaSyncDbUri = syncAccess.getUri();
|
|
2286
2336
|
executeUpgrade();
|
|
2287
2337
|
await withBriefcaseDb(briefcase, async (db) => {
|
|
2288
|
-
db.
|
|
2338
|
+
db[Symbols_1._nativeDb].schemaSyncPush(schemaSyncDbUri);
|
|
2289
2339
|
db.saveChanges();
|
|
2290
2340
|
});
|
|
2291
2341
|
syncAccess.synchronizeWithCloud();
|
|
@@ -2327,7 +2377,7 @@ class BriefcaseDb extends IModelDb {
|
|
|
2327
2377
|
await this.doUpgrade(briefcase, { domain: core_common_1.DomainOptions.Upgrade, schemaLockHeld: true }, "Upgraded domain schemas");
|
|
2328
2378
|
}
|
|
2329
2379
|
finally {
|
|
2330
|
-
await withBriefcaseDb(briefcase, async (db) => db.locks.
|
|
2380
|
+
await withBriefcaseDb(briefcase, async (db) => db.locks[Symbols_1._releaseAllLocks]());
|
|
2331
2381
|
}
|
|
2332
2382
|
return;
|
|
2333
2383
|
}
|
|
@@ -2344,7 +2394,7 @@ class BriefcaseDb extends IModelDb {
|
|
|
2344
2394
|
await this.doUpgrade(briefcase, { domain: core_common_1.DomainOptions.Upgrade, schemaLockHeld: true }, "Upgraded domain schemas");
|
|
2345
2395
|
}
|
|
2346
2396
|
finally {
|
|
2347
|
-
await withBriefcaseDb(briefcase, async (db) => db.locks.
|
|
2397
|
+
await withBriefcaseDb(briefcase, async (db) => db.locks[Symbols_1._releaseAllLocks]());
|
|
2348
2398
|
}
|
|
2349
2399
|
}
|
|
2350
2400
|
throw error;
|
|
@@ -2368,26 +2418,44 @@ class BriefcaseDb extends IModelDb {
|
|
|
2368
2418
|
// Restart default txn to trigger events when watch file is changed by some other process.
|
|
2369
2419
|
const watcher = fs.watch(briefcaseDb.watchFilePathName, { persistent: false }, () => {
|
|
2370
2420
|
nativeDb.restartDefaultTxn();
|
|
2421
|
+
briefcaseDb.changeset = briefcaseDb[Symbols_1._nativeDb].getCurrentChangeset();
|
|
2371
2422
|
});
|
|
2372
2423
|
// Stop the watcher when we close this connection.
|
|
2373
2424
|
briefcaseDb.onBeforeClose.addOnce(() => {
|
|
2374
2425
|
watcher.close();
|
|
2375
2426
|
});
|
|
2376
2427
|
}
|
|
2428
|
+
// load all of the settings from workspaces
|
|
2429
|
+
await briefcaseDb.loadWorkspaceSettings();
|
|
2377
2430
|
if (openMode === core_bentley_1.OpenMode.ReadWrite && CodeService_1.CodeService.createForIModel) {
|
|
2378
2431
|
try {
|
|
2379
2432
|
briefcaseDb._codeService = await CodeService_1.CodeService.createForIModel(briefcaseDb);
|
|
2380
2433
|
this.onCodeServiceCreated.raiseEvent(briefcaseDb);
|
|
2381
2434
|
}
|
|
2382
2435
|
catch (e) {
|
|
2383
|
-
if (e.errorId !== "NoCodeIndex") // no code index means iModel isn't enforcing codes.
|
|
2384
|
-
|
|
2436
|
+
if (e.errorId !== "NoCodeIndex") { // no code index means iModel isn't enforcing codes.
|
|
2437
|
+
core_bentley_1.Logger.logWarning(loggerCategory, `The CodeService is not available for this briefcase: errorId: ${e.errorId}, errorMessage; ${e.message}. Proceeding with BriefcaseDb.open(), but all operations involving codes will fail.`);
|
|
2438
|
+
briefcaseDb._codeService = {
|
|
2439
|
+
verifyCode: (props) => {
|
|
2440
|
+
if (!core_common_1.Code.isEmpty(props.props.code)) {
|
|
2441
|
+
e.message = `The CodeService is not available for this briefcase: errorId: ${e.errorId}, errorMessage; ${e.message}.`;
|
|
2442
|
+
throw e;
|
|
2443
|
+
}
|
|
2444
|
+
},
|
|
2445
|
+
appParams: {
|
|
2446
|
+
author: { name: "unknown" },
|
|
2447
|
+
origin: { name: "unknown" },
|
|
2448
|
+
},
|
|
2449
|
+
close: () => { },
|
|
2450
|
+
initialize: async () => { },
|
|
2451
|
+
};
|
|
2452
|
+
}
|
|
2385
2453
|
}
|
|
2386
2454
|
}
|
|
2387
2455
|
this.onOpened.raiseEvent(briefcaseDb, args);
|
|
2388
2456
|
return briefcaseDb;
|
|
2389
2457
|
}
|
|
2390
|
-
|
|
2458
|
+
/** This is called by native code when applying a changeset */
|
|
2391
2459
|
onChangesetConflict(args) {
|
|
2392
2460
|
// returning undefined will result in native handler to resolve conflict
|
|
2393
2461
|
const category = "DgnCore";
|
|
@@ -2470,7 +2538,7 @@ class BriefcaseDb extends IModelDb {
|
|
|
2470
2538
|
const nConflicts = args.getForeignKeyConflicts();
|
|
2471
2539
|
// Note: There is no performance implication of follow code as it happen toward end of
|
|
2472
2540
|
// apply_changeset only once so we be querying value for 'DebugAllowFkViolations' only once.
|
|
2473
|
-
if (this.
|
|
2541
|
+
if (this[Symbols_1._nativeDb].queryLocalValue("DebugAllowFkViolations")) {
|
|
2474
2542
|
core_bentley_1.Logger.logError(category, `Detected ${nConflicts} foreign key conflicts in changeset. Continuing merge as 'DebugAllowFkViolations' flag is set. Run 'PRAGMA foreign_key_check' to get list of violations.`);
|
|
2475
2543
|
return core_bentley_1.DbConflictResolution.Skip;
|
|
2476
2544
|
}
|
|
@@ -2518,7 +2586,6 @@ class BriefcaseDb extends IModelDb {
|
|
|
2518
2586
|
* + Also see comments in TxnManager::MergeDataChanges()
|
|
2519
2587
|
*/
|
|
2520
2588
|
if (core_bentley_1.Logger.isEnabled(category, core_bentley_1.LogLevel.Info)) {
|
|
2521
|
-
core_bentley_1.Logger.logInfo(category, "------------------------------------------------------------------");
|
|
2522
2589
|
core_bentley_1.Logger.logInfo(category, `Conflict detected - Cause: ${interpretConflictCause(args.cause)}`);
|
|
2523
2590
|
args.dump();
|
|
2524
2591
|
core_bentley_1.Logger.logInfo(category, "Conflicting resolved by replacing the existing entry with the change");
|
|
@@ -2529,7 +2596,7 @@ class BriefcaseDb extends IModelDb {
|
|
|
2529
2596
|
* Execute the supplied function.
|
|
2530
2597
|
* If the briefcase was read-only, reopen the native briefcase as read-only.
|
|
2531
2598
|
* @note this._openMode is not changed from its initial value.
|
|
2532
|
-
* @internal Exported strictly for tests
|
|
2599
|
+
* @internal Exported strictly for tests
|
|
2533
2600
|
*/
|
|
2534
2601
|
async executeWritable(func) {
|
|
2535
2602
|
const fileName = this.pathName;
|
|
@@ -2546,7 +2613,7 @@ class BriefcaseDb extends IModelDb {
|
|
|
2546
2613
|
finally {
|
|
2547
2614
|
if (isReadonly) {
|
|
2548
2615
|
if (locks !== this._locks) { // did we have to create a ServerBasedLocks?
|
|
2549
|
-
this.locks.
|
|
2616
|
+
this.locks[Symbols_1._close](); // yes, close it and reset back to previous
|
|
2550
2617
|
this._locks = locks;
|
|
2551
2618
|
}
|
|
2552
2619
|
this.closeAndReopen(core_bentley_1.OpenMode.Readonly, fileName);
|
|
@@ -2557,10 +2624,15 @@ class BriefcaseDb extends IModelDb {
|
|
|
2557
2624
|
// Unclosed statements will produce BUSY error when attempting to close.
|
|
2558
2625
|
this.clearCaches();
|
|
2559
2626
|
// The following resets the native db's pointer to this JavaScript object.
|
|
2560
|
-
this.
|
|
2561
|
-
this.
|
|
2627
|
+
this[Symbols_1._nativeDb].closeFile();
|
|
2628
|
+
this[Symbols_1._nativeDb].openIModel(fileName, openMode);
|
|
2562
2629
|
// Restore the native db's pointer to this JavaScript object.
|
|
2563
|
-
this.
|
|
2630
|
+
this[Symbols_1._nativeDb].setIModelDb(this);
|
|
2631
|
+
// refresh cached properties that could have been changed by another process writing to the same briefcase
|
|
2632
|
+
this.changeset = this[Symbols_1._nativeDb].getCurrentChangeset();
|
|
2633
|
+
// assert what should never change
|
|
2634
|
+
if (this.iModelId !== this[Symbols_1._nativeDb].getIModelId() || this.iTwinId !== this[Symbols_1._nativeDb].getITwinId())
|
|
2635
|
+
throw new Error("closeAndReopen detected change in iModelId and/or iTwinId");
|
|
2564
2636
|
}
|
|
2565
2637
|
/** Pull and apply changesets from iModelHub */
|
|
2566
2638
|
async pullChanges(arg) {
|
|
@@ -2570,15 +2642,22 @@ class BriefcaseDb extends IModelDb {
|
|
|
2570
2642
|
this.initializeIModelDb();
|
|
2571
2643
|
});
|
|
2572
2644
|
IpcHost_1.IpcHost.notifyTxns(this, "notifyPulledChanges", this.changeset);
|
|
2645
|
+
this.txns.touchWatchFile();
|
|
2573
2646
|
}
|
|
2574
2647
|
/** Push changes to iModelHub. */
|
|
2575
2648
|
async pushChanges(arg) {
|
|
2576
2649
|
if (this.briefcaseId === core_common_1.BriefcaseIdValue.Unassigned)
|
|
2577
2650
|
return;
|
|
2578
|
-
if (this.
|
|
2651
|
+
if (this[Symbols_1._nativeDb].hasUnsavedChanges()) {
|
|
2579
2652
|
throw new core_common_1.IModelError(core_bentley_1.ChangeSetStatus.HasUncommittedChanges, "Cannot push with unsaved changes");
|
|
2580
|
-
|
|
2581
|
-
|
|
2653
|
+
}
|
|
2654
|
+
else if (!this[Symbols_1._nativeDb].hasPendingTxns()) {
|
|
2655
|
+
// Nothing to push.
|
|
2656
|
+
if (!arg.retainLocks) {
|
|
2657
|
+
await this.locks.releaseAllLocks();
|
|
2658
|
+
}
|
|
2659
|
+
return;
|
|
2660
|
+
}
|
|
2582
2661
|
// pushing changes requires a writeable briefcase
|
|
2583
2662
|
await this.executeWritable(async () => {
|
|
2584
2663
|
await BriefcaseManager_1.BriefcaseManager.pullMergePush(this, arg);
|
|
@@ -2586,6 +2665,7 @@ class BriefcaseDb extends IModelDb {
|
|
|
2586
2665
|
});
|
|
2587
2666
|
const changeset = this.changeset;
|
|
2588
2667
|
IpcHost_1.IpcHost.notifyTxns(this, "notifyPushedChanges", changeset);
|
|
2668
|
+
this.txns.touchWatchFile();
|
|
2589
2669
|
}
|
|
2590
2670
|
close() {
|
|
2591
2671
|
super.close();
|
|
@@ -2630,7 +2710,7 @@ class RefreshV2CheckpointSas {
|
|
|
2630
2710
|
core_bentley_1.Logger.logInfo(BackendLoggerCategory_1.BackendLoggerCategory.Authorization, "attempting to refresh sasToken for checkpoint");
|
|
2631
2711
|
try {
|
|
2632
2712
|
// this exchanges the supplied user accessToken for an expiring blob-store token to read the checkpoint.
|
|
2633
|
-
const container = iModel.
|
|
2713
|
+
const container = iModel[Symbols_1._nativeDb].cloudContainer;
|
|
2634
2714
|
if (!container)
|
|
2635
2715
|
throw new Error("checkpoint is not from a cloud container");
|
|
2636
2716
|
(0, core_bentley_1.assert)(undefined !== iModel.iTwinId);
|
|
@@ -2680,14 +2760,14 @@ class SnapshotDb extends IModelDb {
|
|
|
2680
2760
|
}
|
|
2681
2761
|
/** Create an *empty* local [Snapshot]($docs/learning/backend/AccessingIModels.md#snapshot-imodels) iModel file.
|
|
2682
2762
|
* Snapshots are not synchronized with iModelHub, so do not have a change timeline.
|
|
2683
|
-
*
|
|
2763
|
+
* @note: A *snapshot* cannot be modified after [[close]] is called.
|
|
2684
2764
|
* @param filePath The file that will contain the new iModel *snapshot*
|
|
2685
2765
|
* @param options The parameters that define the new iModel *snapshot*
|
|
2686
2766
|
* @returns A writeable SnapshotDb
|
|
2687
2767
|
* @see [Snapshot iModels]($docs/learning/backend/AccessingIModels.md#snapshot-imodels)
|
|
2688
2768
|
*/
|
|
2689
2769
|
static createEmpty(filePath, options) {
|
|
2690
|
-
const nativeDb = new
|
|
2770
|
+
const nativeDb = new NativePlatform_1.IModelNative.platform.DgnDb();
|
|
2691
2771
|
nativeDb.createIModel(filePath, options);
|
|
2692
2772
|
nativeDb.resetBriefcaseId(core_common_1.BriefcaseIdValue.Unassigned);
|
|
2693
2773
|
const snapshotDb = new SnapshotDb(nativeDb, core_bentley_1.Guid.createValue());
|
|
@@ -2698,7 +2778,7 @@ class SnapshotDb extends IModelDb {
|
|
|
2698
2778
|
}
|
|
2699
2779
|
/** Create a local [Snapshot]($docs/learning/backend/AccessingIModels.md#snapshot-imodels) iModel file, using this iModel as a *seed* or starting point.
|
|
2700
2780
|
* Snapshots are not synchronized with iModelHub, so do not have a change timeline.
|
|
2701
|
-
*
|
|
2781
|
+
* @note: A *snapshot* cannot be modified after [[close]] is called.
|
|
2702
2782
|
* @param iModelDb The snapshot will be initialized from the current contents of this iModelDb
|
|
2703
2783
|
* @param snapshotFile The file that will contain the new iModel *snapshot*
|
|
2704
2784
|
* @param options Optional properties that determine how the snapshot iModel is created.
|
|
@@ -2708,7 +2788,7 @@ class SnapshotDb extends IModelDb {
|
|
|
2708
2788
|
static createFrom(iModelDb, snapshotFile, options) {
|
|
2709
2789
|
iModelDb.performCheckpoint();
|
|
2710
2790
|
IModelJsFs_1.IModelJsFs.copySync(iModelDb.pathName, snapshotFile);
|
|
2711
|
-
const nativeDb = new
|
|
2791
|
+
const nativeDb = new NativePlatform_1.IModelNative.platform.DgnDb();
|
|
2712
2792
|
nativeDb.openIModel(snapshotFile, core_bentley_1.OpenMode.ReadWrite, undefined, options);
|
|
2713
2793
|
nativeDb.vacuum();
|
|
2714
2794
|
// Replace iModelId if seedFile is a snapshot, preserve iModelId if seedFile is an iModelHub-managed briefcase
|
|
@@ -2741,7 +2821,11 @@ class SnapshotDb extends IModelDb {
|
|
|
2741
2821
|
static openFile(path, opts) {
|
|
2742
2822
|
this.onOpen.raiseEvent(path, opts);
|
|
2743
2823
|
const file = { path, key: opts?.key };
|
|
2824
|
+
const wasKeyUndefined = opts?.key === undefined;
|
|
2744
2825
|
const nativeDb = this.openDgnDb(file, core_bentley_1.OpenMode.Readonly, undefined, opts);
|
|
2826
|
+
if (wasKeyUndefined) {
|
|
2827
|
+
file.key = `${nativeDb.getIModelId()}:${nativeDb.getCurrentChangeset().id}`;
|
|
2828
|
+
}
|
|
2745
2829
|
(0, core_bentley_1.assert)(undefined !== file.key);
|
|
2746
2830
|
const db = new SnapshotDb(nativeDb, file.key);
|
|
2747
2831
|
this.onOpened.raiseEvent(db);
|
|
@@ -2750,7 +2834,9 @@ class SnapshotDb extends IModelDb {
|
|
|
2750
2834
|
static async attachAndOpenCheckpoint(checkpoint) {
|
|
2751
2835
|
const { dbName, container } = await CheckpointManager_1.V2CheckpointManager.attach(checkpoint);
|
|
2752
2836
|
const key = CheckpointManager_1.CheckpointManager.getKey(checkpoint);
|
|
2753
|
-
|
|
2837
|
+
const db = SnapshotDb.openFile(dbName, { key, container });
|
|
2838
|
+
await db.loadWorkspaceSettings();
|
|
2839
|
+
return db;
|
|
2754
2840
|
}
|
|
2755
2841
|
/** @internal */
|
|
2756
2842
|
static async openCheckpointFromRpc(checkpoint) {
|
|
@@ -2768,7 +2854,7 @@ class SnapshotDb extends IModelDb {
|
|
|
2768
2854
|
snapshot.restartDefaultTxn();
|
|
2769
2855
|
}, (10 * 60) * 1000).unref(); // 10 minutes
|
|
2770
2856
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
2771
|
-
snapshot._refreshSas = new RefreshV2CheckpointSas(snapshot.
|
|
2857
|
+
snapshot._refreshSas = new RefreshV2CheckpointSas(snapshot[Symbols_1._nativeDb].cloudContainer.accessToken, checkpoint.reattachSafetySeconds);
|
|
2772
2858
|
return snapshot;
|
|
2773
2859
|
}
|
|
2774
2860
|
/**
|
|
@@ -2792,7 +2878,7 @@ class SnapshotDb extends IModelDb {
|
|
|
2792
2878
|
if (this._restartDefaultTxnTimer)
|
|
2793
2879
|
clearTimeout(this._restartDefaultTxnTimer);
|
|
2794
2880
|
if (this._createClassViewsOnClose) { // check for flag set during create
|
|
2795
|
-
if (core_bentley_1.BentleyStatus.SUCCESS !== this.
|
|
2881
|
+
if (core_bentley_1.BentleyStatus.SUCCESS !== this[Symbols_1._nativeDb].createClassViewsInDb()) {
|
|
2796
2882
|
throw new core_common_1.IModelError(core_bentley_1.IModelStatus.SQLiteError, "Error creating class views");
|
|
2797
2883
|
}
|
|
2798
2884
|
else {
|
|
@@ -2836,7 +2922,7 @@ class StandaloneDb extends BriefcaseDb {
|
|
|
2836
2922
|
* @param args The parameters that define the new iModel
|
|
2837
2923
|
*/
|
|
2838
2924
|
static createEmpty(filePath, args) {
|
|
2839
|
-
const nativeDb = new
|
|
2925
|
+
const nativeDb = new NativePlatform_1.IModelNative.platform.DgnDb();
|
|
2840
2926
|
nativeDb.createIModel(filePath, args);
|
|
2841
2927
|
nativeDb.saveLocalValue(BriefcaseLocalValue.StandaloneEdit, args.allowEdit);
|
|
2842
2928
|
nativeDb.setITwinId(core_bentley_1.Guid.empty);
|
|
@@ -2868,7 +2954,7 @@ class StandaloneDb extends BriefcaseDb {
|
|
|
2868
2954
|
* @beta
|
|
2869
2955
|
*/
|
|
2870
2956
|
createClassViews() {
|
|
2871
|
-
const result = this.
|
|
2957
|
+
const result = this[Symbols_1._nativeDb].createClassViewsInDb();
|
|
2872
2958
|
if (core_bentley_1.BentleyStatus.SUCCESS !== result)
|
|
2873
2959
|
throw new core_common_1.IModelError(result, "Error creating class views");
|
|
2874
2960
|
else
|