@itwin/core-backend 5.0.0-dev.9 → 5.0.0-dev.90
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 +60 -1
- package/lib/cjs/BackendHubAccess.d.ts +14 -28
- package/lib/cjs/BackendHubAccess.d.ts.map +1 -1
- package/lib/cjs/BackendHubAccess.js +2 -0
- package/lib/cjs/BackendHubAccess.js.map +1 -1
- package/lib/cjs/BackendLoggerCategory.js.map +1 -1
- package/lib/cjs/BisCoreSchema.d.ts.map +1 -1
- package/lib/cjs/BisCoreSchema.js +2 -0
- package/lib/cjs/BisCoreSchema.js.map +1 -1
- package/lib/cjs/BlobContainerService.d.ts +4 -4
- package/lib/cjs/BlobContainerService.d.ts.map +1 -1
- package/lib/cjs/BlobContainerService.js.map +1 -1
- package/lib/cjs/BriefcaseManager.d.ts +10 -0
- package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
- package/lib/cjs/BriefcaseManager.js +63 -20
- package/lib/cjs/BriefcaseManager.js.map +1 -1
- package/lib/cjs/Category.js +6 -1
- package/lib/cjs/Category.js.map +1 -1
- package/lib/cjs/ChangeSummaryManager.d.ts.map +1 -1
- package/lib/cjs/ChangeSummaryManager.js +92 -24
- package/lib/cjs/ChangeSummaryManager.js.map +1 -1
- package/lib/cjs/ChangedElementsDb.d.ts +3 -3
- package/lib/cjs/ChangedElementsDb.d.ts.map +1 -1
- package/lib/cjs/ChangedElementsDb.js +8 -7
- package/lib/cjs/ChangedElementsDb.js.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.d.ts +3 -3
- package/lib/cjs/ChangesetECAdaptor.d.ts.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.js +273 -261
- package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
- package/lib/cjs/ChannelControl.js.map +1 -1
- package/lib/cjs/CheckpointManager.d.ts.map +1 -1
- package/lib/cjs/CheckpointManager.js +15 -12
- package/lib/cjs/CheckpointManager.js.map +1 -1
- package/lib/cjs/ClassRegistry.d.ts +46 -2
- package/lib/cjs/ClassRegistry.d.ts.map +1 -1
- package/lib/cjs/ClassRegistry.js +98 -42
- package/lib/cjs/ClassRegistry.js.map +1 -1
- package/lib/cjs/CloudSqlite.d.ts +2 -1
- package/lib/cjs/CloudSqlite.d.ts.map +1 -1
- package/lib/cjs/CloudSqlite.js +15 -8
- package/lib/cjs/CloudSqlite.js.map +1 -1
- package/lib/cjs/CodeService.d.ts +2 -0
- package/lib/cjs/CodeService.d.ts.map +1 -1
- package/lib/cjs/CodeService.js +4 -0
- package/lib/cjs/CodeService.js.map +1 -1
- package/lib/cjs/CodeSpecs.js +3 -2
- package/lib/cjs/CodeSpecs.js.map +1 -1
- package/lib/cjs/ConcurrentQuery.js.map +1 -1
- package/lib/cjs/CustomViewState3dCreator.js +7 -6
- package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
- package/lib/cjs/DevTools.js +16 -16
- package/lib/cjs/DevTools.js.map +1 -1
- package/lib/cjs/DisplayStyle.js +2 -0
- package/lib/cjs/DisplayStyle.js.map +1 -1
- package/lib/cjs/ECDb.d.ts +16 -59
- package/lib/cjs/ECDb.d.ts.map +1 -1
- package/lib/cjs/ECDb.js +34 -73
- package/lib/cjs/ECDb.js.map +1 -1
- package/lib/cjs/ECSchemaXmlContext.js +1 -0
- package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
- package/lib/cjs/ECSqlStatement.d.ts +4 -2
- package/lib/cjs/ECSqlStatement.d.ts.map +1 -1
- package/lib/cjs/ECSqlStatement.js +13 -4
- package/lib/cjs/ECSqlStatement.js.map +1 -1
- package/lib/cjs/Element.d.ts +14 -23
- package/lib/cjs/Element.d.ts.map +1 -1
- package/lib/cjs/Element.js +133 -46
- 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 +24 -16
- package/lib/cjs/ElementAspect.js.map +1 -1
- package/lib/cjs/ElementGraphics.js.map +1 -1
- package/lib/cjs/ElementTreeWalker.js +13 -12
- package/lib/cjs/ElementTreeWalker.js.map +1 -1
- package/lib/cjs/Entity.d.ts +46 -10
- package/lib/cjs/Entity.d.ts.map +1 -1
- package/lib/cjs/Entity.js +79 -16
- package/lib/cjs/Entity.js.map +1 -1
- package/lib/cjs/EntityReferences.js.map +1 -1
- package/lib/cjs/ExportGraphics.js +4 -0
- package/lib/cjs/ExportGraphics.js.map +1 -1
- package/lib/cjs/ExternalSource.js +22 -0
- package/lib/cjs/ExternalSource.js.map +1 -1
- package/lib/cjs/FontFile.d.ts +68 -0
- package/lib/cjs/FontFile.d.ts.map +1 -0
- package/lib/cjs/FontFile.js +36 -0
- package/lib/cjs/FontFile.js.map +1 -0
- package/lib/cjs/GeoCoordConfig.js +8 -8
- package/lib/cjs/GeoCoordConfig.js.map +1 -1
- package/lib/cjs/GeographicCRSServices.js.map +1 -1
- package/lib/cjs/GeometrySummary.js +53 -50
- package/lib/cjs/GeometrySummary.js.map +1 -1
- package/lib/cjs/HubMock.d.ts +4 -4
- package/lib/cjs/HubMock.d.ts.map +1 -1
- package/lib/cjs/HubMock.js +9 -6
- package/lib/cjs/HubMock.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +203 -72
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +338 -168
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/IModelDbFonts.d.ts +54 -0
- package/lib/cjs/IModelDbFonts.d.ts.map +1 -0
- package/lib/cjs/{IModelCloneContext.js → IModelDbFonts.js} +2 -7
- package/lib/cjs/IModelDbFonts.js.map +1 -0
- package/lib/cjs/IModelElementCloneContext.d.ts +2 -0
- package/lib/cjs/IModelElementCloneContext.d.ts.map +1 -1
- package/lib/cjs/IModelElementCloneContext.js +12 -1
- package/lib/cjs/IModelElementCloneContext.js.map +1 -1
- package/lib/cjs/IModelHost.d.ts +14 -14
- package/lib/cjs/IModelHost.d.ts.map +1 -1
- package/lib/cjs/IModelHost.js +75 -42
- package/lib/cjs/IModelHost.js.map +1 -1
- package/lib/cjs/IModelJsFs.d.ts.map +1 -1
- package/lib/cjs/IModelJsFs.js +17 -1
- package/lib/cjs/IModelJsFs.js.map +1 -1
- package/lib/cjs/ImageSourceConversion.d.ts +49 -0
- package/lib/cjs/ImageSourceConversion.d.ts.map +1 -0
- package/lib/cjs/ImageSourceConversion.js +37 -0
- package/lib/cjs/ImageSourceConversion.js.map +1 -0
- package/lib/cjs/IpcHost.d.ts.map +1 -1
- package/lib/cjs/IpcHost.js +17 -12
- package/lib/cjs/IpcHost.js.map +1 -1
- package/lib/cjs/LineStyle.js.map +1 -1
- package/lib/cjs/LocalHub.js +9 -3
- package/lib/cjs/LocalHub.js.map +1 -1
- package/lib/cjs/LocalhostIpcHost.js +5 -6
- package/lib/cjs/LocalhostIpcHost.js.map +1 -1
- package/lib/cjs/LockControl.js.map +1 -1
- package/lib/cjs/Material.js +40 -0
- package/lib/cjs/Material.js.map +1 -1
- package/lib/cjs/Model.d.ts +1 -1
- package/lib/cjs/Model.d.ts.map +1 -1
- package/lib/cjs/Model.js +27 -2
- package/lib/cjs/Model.js.map +1 -1
- package/lib/cjs/NativeAppStorage.js +5 -3
- package/lib/cjs/NativeAppStorage.js.map +1 -1
- package/lib/cjs/NativeHost.js +6 -3
- package/lib/cjs/NativeHost.js.map +1 -1
- package/lib/cjs/NavigationRelationship.js +25 -25
- package/lib/cjs/NavigationRelationship.js.map +1 -1
- package/lib/cjs/PromiseMemoizer.d.ts +2 -3
- package/lib/cjs/PromiseMemoizer.d.ts.map +1 -1
- package/lib/cjs/PromiseMemoizer.js +12 -5
- package/lib/cjs/PromiseMemoizer.js.map +1 -1
- package/lib/cjs/PropertyStore.js +1 -4
- package/lib/cjs/PropertyStore.js.map +1 -1
- package/lib/cjs/Relationship.d.ts.map +1 -1
- package/lib/cjs/Relationship.js +13 -1
- package/lib/cjs/Relationship.js.map +1 -1
- package/lib/cjs/RpcBackend.js.map +1 -1
- package/lib/cjs/SQLiteDb.d.ts +6 -4
- package/lib/cjs/SQLiteDb.d.ts.map +1 -1
- package/lib/cjs/SQLiteDb.js +74 -15
- package/lib/cjs/SQLiteDb.js.map +1 -1
- package/lib/cjs/Schema.d.ts +25 -1
- package/lib/cjs/Schema.d.ts.map +1 -1
- package/lib/cjs/Schema.js +44 -8
- package/lib/cjs/Schema.js.map +1 -1
- package/lib/cjs/SchemaSync.js +1 -4
- package/lib/cjs/SchemaSync.js.map +1 -1
- package/lib/cjs/SchemaUtils.js.map +1 -1
- package/lib/cjs/SheetIndex.js +6 -0
- package/lib/cjs/SheetIndex.js.map +1 -1
- package/lib/cjs/SqliteChangesetReader.d.ts +11 -3
- package/lib/cjs/SqliteChangesetReader.d.ts.map +1 -1
- package/lib/cjs/SqliteChangesetReader.js +21 -5
- package/lib/cjs/SqliteChangesetReader.js.map +1 -1
- package/lib/cjs/SqliteStatement.d.ts +4 -2
- package/lib/cjs/SqliteStatement.d.ts.map +1 -1
- package/lib/cjs/SqliteStatement.js +13 -1
- package/lib/cjs/SqliteStatement.js.map +1 -1
- package/lib/cjs/TextAnnotationElement.js.map +1 -1
- package/lib/cjs/TextAnnotationGeometry.d.ts.map +1 -1
- package/lib/cjs/TextAnnotationGeometry.js +38 -11
- package/lib/cjs/TextAnnotationGeometry.js.map +1 -1
- package/lib/cjs/TextAnnotationLayout.d.ts +10 -3
- package/lib/cjs/TextAnnotationLayout.d.ts.map +1 -1
- package/lib/cjs/TextAnnotationLayout.js +56 -18
- package/lib/cjs/TextAnnotationLayout.js.map +1 -1
- package/lib/cjs/Texture.js +3 -0
- package/lib/cjs/Texture.js.map +1 -1
- package/lib/cjs/TileStorage.js +6 -1
- package/lib/cjs/TileStorage.js.map +1 -1
- package/lib/cjs/TxnManager.d.ts +55 -4
- package/lib/cjs/TxnManager.d.ts.map +1 -1
- package/lib/cjs/TxnManager.js +234 -58
- package/lib/cjs/TxnManager.js.map +1 -1
- package/lib/cjs/ViewDefinition.d.ts +6 -6
- package/lib/cjs/ViewDefinition.d.ts.map +1 -1
- package/lib/cjs/ViewDefinition.js +81 -26
- package/lib/cjs/ViewDefinition.js.map +1 -1
- package/lib/cjs/ViewStateHydrator.d.ts +0 -1
- package/lib/cjs/ViewStateHydrator.d.ts.map +1 -1
- package/lib/cjs/ViewStateHydrator.js +1 -11
- package/lib/cjs/ViewStateHydrator.js.map +1 -1
- package/lib/cjs/ViewStore.js +3 -1
- 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 +32 -32
- package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +27 -27
- package/lib/cjs/assets/Settings/Schemas/Workspace.Schema.json +94 -94
- package/lib/cjs/assets/Settings/backend.setting.json5 +21 -21
- package/lib/cjs/core-backend.d.ts +7 -1
- package/lib/cjs/core-backend.d.ts.map +1 -1
- package/lib/cjs/core-backend.js +7 -1
- package/lib/cjs/core-backend.js.map +1 -1
- package/lib/cjs/domains/FunctionalElements.js +1 -1
- package/lib/cjs/domains/FunctionalElements.js.map +1 -1
- package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
- 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 +40 -2
- package/lib/cjs/internal/ChangesetConflictArgs.d.ts.map +1 -1
- package/lib/cjs/internal/ChangesetConflictArgs.js +101 -0
- package/lib/cjs/internal/ChangesetConflictArgs.js.map +1 -1
- package/lib/cjs/internal/ChannelAdmin.d.ts +1 -1
- package/lib/cjs/internal/ChannelAdmin.d.ts.map +1 -1
- package/lib/cjs/internal/ChannelAdmin.js +25 -16
- package/lib/cjs/internal/ChannelAdmin.js.map +1 -1
- package/lib/cjs/internal/FontFileImpl.d.ts +34 -0
- package/lib/cjs/internal/FontFileImpl.d.ts.map +1 -0
- package/lib/cjs/internal/FontFileImpl.js +143 -0
- package/lib/cjs/internal/FontFileImpl.js.map +1 -0
- package/lib/cjs/internal/IModelDbFontsImpl.d.ts +7 -0
- package/lib/cjs/internal/IModelDbFontsImpl.d.ts.map +1 -0
- package/lib/cjs/internal/IModelDbFontsImpl.js +186 -0
- package/lib/cjs/internal/IModelDbFontsImpl.js.map +1 -0
- package/lib/cjs/internal/NativePlatform.js.map +1 -1
- package/lib/cjs/internal/NoLocks.js +2 -5
- package/lib/cjs/internal/NoLocks.js.map +1 -1
- package/lib/cjs/internal/ServerBasedLocks.d.ts.map +1 -1
- package/lib/cjs/internal/ServerBasedLocks.js +6 -6
- package/lib/cjs/internal/ServerBasedLocks.js.map +1 -1
- package/lib/cjs/internal/Symbols.d.ts +7 -0
- package/lib/cjs/internal/Symbols.d.ts.map +1 -1
- package/lib/cjs/internal/Symbols.js +8 -1
- package/lib/cjs/internal/Symbols.js.map +1 -1
- package/lib/cjs/internal/cross-package.js.map +1 -1
- package/lib/cjs/internal/workspace/SettingsImpl.js +6 -9
- package/lib/cjs/internal/workspace/SettingsImpl.js.map +1 -1
- package/lib/cjs/internal/workspace/SettingsSchemasImpl.js +8 -12
- package/lib/cjs/internal/workspace/SettingsSchemasImpl.js.map +1 -1
- package/lib/cjs/internal/workspace/WorkspaceImpl.js +22 -17
- package/lib/cjs/internal/workspace/WorkspaceImpl.js.map +1 -1
- package/lib/cjs/internal/workspace/WorkspaceSqliteDb.js +1 -4
- package/lib/cjs/internal/workspace/WorkspaceSqliteDb.js.map +1 -1
- package/lib/cjs/rpc/multipart.d.ts.map +1 -1
- package/lib/cjs/rpc/multipart.js +2 -1
- package/lib/cjs/rpc/multipart.js.map +1 -1
- package/lib/cjs/rpc/tracing.js +2 -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.d.ts.map +1 -1
- package/lib/cjs/rpc/web/request.js +2 -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.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +5 -2
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.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.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +4 -3
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
- package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
- package/lib/cjs/workspace/Settings.js.map +1 -1
- package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
- package/lib/cjs/workspace/Workspace.js.map +1 -1
- package/lib/cjs/workspace/WorkspaceEditor.js.map +1 -1
- package/package.json +29 -26
- package/lib/cjs/IModelCloneContext.d.ts +0 -9
- package/lib/cjs/IModelCloneContext.d.ts.map +0 -1
- package/lib/cjs/IModelCloneContext.js.map +0 -1
package/lib/cjs/IModelDb.js
CHANGED
|
@@ -46,7 +46,10 @@ const WorkspaceImpl_1 = require("./internal/workspace/WorkspaceImpl");
|
|
|
46
46
|
const SettingsImpl_1 = require("./internal/workspace/SettingsImpl");
|
|
47
47
|
const NativePlatform_1 = require("./internal/NativePlatform");
|
|
48
48
|
const NoLocks_1 = require("./internal/NoLocks");
|
|
49
|
+
const IModelDbFontsImpl_1 = require("./internal/IModelDbFontsImpl");
|
|
49
50
|
const Symbols_1 = require("./internal/Symbols");
|
|
51
|
+
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
52
|
+
const Schema_1 = require("./Schema");
|
|
50
53
|
// spell:ignore fontid fontmap
|
|
51
54
|
const loggerCategory = BackendLoggerCategory_1.BackendLoggerCategory.IModelDb;
|
|
52
55
|
/** @internal */
|
|
@@ -85,10 +88,44 @@ class IModelSettings extends SettingsImpl_1.SettingsImpl {
|
|
|
85
88
|
* @public
|
|
86
89
|
*/
|
|
87
90
|
class IModelDb extends core_common_1.IModel {
|
|
91
|
+
_initialized = false;
|
|
92
|
+
/** Keep track of open imodels to support `tryFind` for RPC purposes */
|
|
93
|
+
static _openDbs = new Map();
|
|
94
|
+
static defaultLimit = 1000; // default limit for batching queries
|
|
95
|
+
static maxLimit = 10000; // maximum limit for batching queries
|
|
96
|
+
models = new IModelDb.Models(this);
|
|
97
|
+
elements = new IModelDb.Elements(this);
|
|
98
|
+
views = new IModelDb.Views(this);
|
|
99
|
+
tiles = new IModelDb.Tiles(this);
|
|
100
|
+
/** @beta */
|
|
101
|
+
channels = (0, ChannelAdmin_1.createChannelControl)(this);
|
|
102
|
+
_relationships;
|
|
103
|
+
_statementCache = new SqliteStatement_1.StatementCache();
|
|
104
|
+
_sqliteStatementCache = new SqliteStatement_1.StatementCache();
|
|
105
|
+
_codeSpecs;
|
|
106
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
107
|
+
_classMetaDataRegistry;
|
|
108
|
+
_jsClassMap;
|
|
109
|
+
_schemaMap;
|
|
110
|
+
_schemaContext;
|
|
111
|
+
/** @deprecated in 5.0.0. Use [[fonts]]. */
|
|
112
|
+
_fontMap; // eslint-disable-line @typescript-eslint/no-deprecated
|
|
113
|
+
_fonts = (0, IModelDbFontsImpl_1.createIModelDbFonts)(this);
|
|
114
|
+
_workspace;
|
|
115
|
+
_snaps = new Map();
|
|
116
|
+
static _shutdownListener; // so we only register listener once
|
|
117
|
+
/** @internal */
|
|
118
|
+
_locks = (0, NoLocks_1.createNoOpLockControl)();
|
|
119
|
+
/** @internal */
|
|
120
|
+
_codeService;
|
|
88
121
|
/** @alpha */
|
|
89
122
|
get codeService() { return this._codeService; }
|
|
90
123
|
/** The [[LockControl]] that orchestrates [concurrent editing]($docs/learning/backend/ConcurrencyControl.md) of this iModel. */
|
|
91
124
|
get locks() { return this._locks; } // eslint-disable-line @typescript-eslint/no-non-null-assertion
|
|
125
|
+
/** Provides methods for interacting with [font-related information]($docs/learning/backend/Fonts.md) stored in this iModel.
|
|
126
|
+
* @beta
|
|
127
|
+
*/
|
|
128
|
+
get fonts() { return this._fonts; }
|
|
92
129
|
/**
|
|
93
130
|
* Get the [[Workspace]] for this iModel.
|
|
94
131
|
* @beta
|
|
@@ -109,6 +146,8 @@ class IModelDb extends core_common_1.IModel {
|
|
|
109
146
|
get holdsSchemaLock() {
|
|
110
147
|
return this.locks.holdsExclusiveLock(core_common_1.IModel.repositoryModelId);
|
|
111
148
|
}
|
|
149
|
+
/** Event called after a changeset is applied to this IModelDb. */
|
|
150
|
+
onChangesetApplied = new core_bentley_1.BeEvent();
|
|
112
151
|
/** @internal */
|
|
113
152
|
notifyChangesetApplied() {
|
|
114
153
|
this.changeset = this[Symbols_1._nativeDb].getCurrentChangeset();
|
|
@@ -118,25 +157,14 @@ class IModelDb extends core_common_1.IModel {
|
|
|
118
157
|
restartDefaultTxn() {
|
|
119
158
|
this[Symbols_1._nativeDb].restartDefaultTxn();
|
|
120
159
|
}
|
|
160
|
+
/** @deprecated in 5.0.0. Use [[fonts]]. */
|
|
121
161
|
get fontMap() {
|
|
122
|
-
return this._fontMap ?? (this._fontMap = new core_common_1.FontMap(this[Symbols_1._nativeDb].readFontMap()));
|
|
162
|
+
return this._fontMap ?? (this._fontMap = new core_common_1.FontMap(this[Symbols_1._nativeDb].readFontMap())); // eslint-disable-line @typescript-eslint/no-deprecated
|
|
123
163
|
}
|
|
124
164
|
/** @internal */
|
|
125
165
|
clearFontMap() {
|
|
126
|
-
this._fontMap = undefined;
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Add a new font name/type to the FontMap for this iModel and return its FontId.
|
|
130
|
-
* @param name The name of the font to add
|
|
131
|
-
* @param type The type of the font. Default is TrueType.
|
|
132
|
-
* @returns The FontId for the newly added font. If a font by that name/type already exists, this method does not fail, it returns the existing Id.
|
|
133
|
-
* @see [FontId and FontMap]($docs/learning/backend/Fonts.md#fontid-and-fontmap)
|
|
134
|
-
* @beta
|
|
135
|
-
*/
|
|
136
|
-
addNewFont(name, type) {
|
|
137
|
-
this.locks.checkExclusiveLock(core_common_1.IModel.repositoryModelId, "schema", "addNewFont");
|
|
138
|
-
this.clearFontMap();
|
|
139
|
-
return this[Symbols_1._nativeDb].addNewFont({ name, type: type ?? core_common_1.FontType.TrueType });
|
|
166
|
+
this._fontMap = undefined; // eslint-disable-line @typescript-eslint/no-deprecated
|
|
167
|
+
this[Symbols_1._nativeDb].invalidateFontMap();
|
|
140
168
|
}
|
|
141
169
|
/** Check if this iModel has been opened read-only or not. */
|
|
142
170
|
get isReadonly() { return this.openMode === core_bentley_1.OpenMode.Readonly; }
|
|
@@ -145,10 +173,8 @@ class IModelDb extends core_common_1.IModel {
|
|
|
145
173
|
(0, core_bentley_1.assert)(undefined !== super.iModelId);
|
|
146
174
|
return super.iModelId;
|
|
147
175
|
} // GuidString | undefined for the IModel superclass, but required for all IModelDb subclasses
|
|
148
|
-
/** @internal
|
|
149
|
-
|
|
150
|
-
*/
|
|
151
|
-
get nativeDb() { return this[Symbols_1._nativeDb]; }
|
|
176
|
+
/** @internal*/
|
|
177
|
+
[Symbols_1._nativeDb];
|
|
152
178
|
/** Get the full path fileName of this iModelDb
|
|
153
179
|
* @note this member is only valid while the iModel is opened.
|
|
154
180
|
*/
|
|
@@ -164,22 +190,6 @@ class IModelDb extends core_common_1.IModel {
|
|
|
164
190
|
/** @internal */
|
|
165
191
|
constructor(args) {
|
|
166
192
|
super({ ...args, iTwinId: args.nativeDb.getITwinId(), iModelId: args.nativeDb.getIModelId() });
|
|
167
|
-
this._initialized = false;
|
|
168
|
-
this.models = new IModelDb.Models(this);
|
|
169
|
-
this.elements = new IModelDb.Elements(this);
|
|
170
|
-
this.views = new IModelDb.Views(this);
|
|
171
|
-
this.tiles = new IModelDb.Tiles(this);
|
|
172
|
-
/** @beta */
|
|
173
|
-
this.channels = (0, ChannelAdmin_1.createChannelControl)(this);
|
|
174
|
-
this._statementCache = new SqliteStatement_1.StatementCache();
|
|
175
|
-
this._sqliteStatementCache = new SqliteStatement_1.StatementCache();
|
|
176
|
-
this._snaps = new Map();
|
|
177
|
-
/** @internal */
|
|
178
|
-
this._locks = (0, NoLocks_1.createNoOpLockControl)();
|
|
179
|
-
/** Event called after a changeset is applied to this IModelDb. */
|
|
180
|
-
this.onChangesetApplied = new core_bentley_1.BeEvent();
|
|
181
|
-
/** Event called when the iModel is about to be closed. */
|
|
182
|
-
this.onBeforeClose = new core_bentley_1.BeEvent();
|
|
183
193
|
this[Symbols_1._nativeDb] = args.nativeDb;
|
|
184
194
|
// it is illegal to create an IModelDb unless the nativeDb has been opened. Throw otherwise.
|
|
185
195
|
if (!this.isOpen)
|
|
@@ -209,6 +219,40 @@ class IModelDb extends core_common_1.IModel {
|
|
|
209
219
|
});
|
|
210
220
|
}
|
|
211
221
|
}
|
|
222
|
+
/**
|
|
223
|
+
* Attach an iModel file to this connection and load and register its schemas.
|
|
224
|
+
* @note There are some reserve tablespace names that cannot be used. They are 'main', 'schema_sync_db', 'ecchange' & 'temp'
|
|
225
|
+
* @param fileName IModel file name
|
|
226
|
+
* @param alias identifier for the attached file. This identifer is used to access schema from the attached file. e.g. if alias is 'abc' then schema can be accessed using 'abc.MySchema.MyClass'
|
|
227
|
+
*
|
|
228
|
+
* *Example:*
|
|
229
|
+
* ``` ts
|
|
230
|
+
* [[include:IModelDb_attachDb.code]]
|
|
231
|
+
* ```
|
|
232
|
+
*/
|
|
233
|
+
attachDb(fileName, alias) {
|
|
234
|
+
if (alias.toLowerCase() === "main" || alias.toLowerCase() === "schema_sync_db" || alias.toLowerCase() === "ecchange" || alias.toLowerCase() === "temp") {
|
|
235
|
+
throw new core_common_1.IModelError(core_bentley_1.DbResult.BE_SQLITE_ERROR, "Reserved tablespace name cannot be used");
|
|
236
|
+
}
|
|
237
|
+
this[Symbols_1._nativeDb].attachDb(fileName, alias);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Detach the attached file from this connection. The attached file is closed and its schemas are unregistered.
|
|
241
|
+
* @note There are some reserve tablespace names that cannot be used. They are 'main', 'schema_sync_db', 'ecchange' & 'temp'
|
|
242
|
+
* @param alias identifer that was used in the call to [[attachDb]]
|
|
243
|
+
*
|
|
244
|
+
* *Example:*
|
|
245
|
+
* ``` ts
|
|
246
|
+
* [[include:IModelDb_attachDb.code]]
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
detachDb(alias) {
|
|
250
|
+
if (alias.toLowerCase() === "main" || alias.toLowerCase() === "schema_sync_db" || alias.toLowerCase() === "ecchange" || alias.toLowerCase() === "temp") {
|
|
251
|
+
throw new core_common_1.IModelError(core_bentley_1.DbResult.BE_SQLITE_ERROR, "Reserved tablespace name cannot be used");
|
|
252
|
+
}
|
|
253
|
+
this.clearCaches();
|
|
254
|
+
this[Symbols_1._nativeDb].detachDb(alias);
|
|
255
|
+
}
|
|
212
256
|
/** Close this IModel, if it is currently open, and save changes if it was opened in ReadWrite mode. */
|
|
213
257
|
close() {
|
|
214
258
|
if (!this.isOpen)
|
|
@@ -226,6 +270,8 @@ class IModelDb extends core_common_1.IModel {
|
|
|
226
270
|
}
|
|
227
271
|
/** @internal */
|
|
228
272
|
async refreshContainerForRpc(_userAccessToken) { }
|
|
273
|
+
/** Event called when the iModel is about to be closed. */
|
|
274
|
+
onBeforeClose = new core_bentley_1.BeEvent();
|
|
229
275
|
/**
|
|
230
276
|
* Called by derived classes before closing the connection
|
|
231
277
|
* @internal
|
|
@@ -320,7 +366,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
320
366
|
*/
|
|
321
367
|
withStatement(ecsql, callback, logErrors = true) {
|
|
322
368
|
const stmt = this.prepareStatement(ecsql, logErrors);
|
|
323
|
-
const release = () => stmt.dispose();
|
|
369
|
+
const release = () => stmt[Symbol.dispose]();
|
|
324
370
|
try {
|
|
325
371
|
const val = callback(stmt);
|
|
326
372
|
if (val instanceof Promise) {
|
|
@@ -358,70 +404,6 @@ class IModelDb extends core_common_1.IModel {
|
|
|
358
404
|
};
|
|
359
405
|
return new core_common_1.ECSqlReader(executor, ecsql, params, config);
|
|
360
406
|
}
|
|
361
|
-
/** Execute a query and stream its results
|
|
362
|
-
* The result of the query is async iterator over the rows. The iterator will get next page automatically once rows in current page has been read.
|
|
363
|
-
* [ECSQL row]($docs/learning/ECSQLRowFormat).
|
|
364
|
-
*
|
|
365
|
-
* See also:
|
|
366
|
-
* - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)
|
|
367
|
-
* - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)
|
|
368
|
-
*
|
|
369
|
-
* @param ecsql The ECSQL statement to execute
|
|
370
|
-
* @param params The values to bind to the parameters (if the ECSQL has any).
|
|
371
|
-
* @param options Allow to specify certain flags which control how query is executed.
|
|
372
|
-
* @returns Returns the query result as an *AsyncIterableIterator<any>* which lazy load result as needed. The row format is determined by *rowFormat* parameter.
|
|
373
|
-
* See [ECSQL row format]($docs/learning/ECSQLRowFormat) for details about the format of the returned rows.
|
|
374
|
-
* @throws [IModelError]($common) If there was any error while submitting, preparing or stepping into query
|
|
375
|
-
* @deprecated in 3.7. Use [[createQueryReader]] instead; it accepts the same parameters.
|
|
376
|
-
*/
|
|
377
|
-
async *query(ecsql, params, options) {
|
|
378
|
-
const builder = new core_common_1.QueryOptionsBuilder(options);
|
|
379
|
-
const reader = this.createQueryReader(ecsql, params, builder.getOptions());
|
|
380
|
-
while (await reader.step())
|
|
381
|
-
yield reader.formatCurrentRow();
|
|
382
|
-
}
|
|
383
|
-
/** Compute number of rows that would be returned by the ECSQL.
|
|
384
|
-
*
|
|
385
|
-
* See also:
|
|
386
|
-
* - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)
|
|
387
|
-
* - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)
|
|
388
|
-
*
|
|
389
|
-
* @param ecsql The ECSQL statement to execute
|
|
390
|
-
* @param params The values to bind to the parameters (if the ECSQL has any).
|
|
391
|
-
* See "[iTwin.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)" for details.
|
|
392
|
-
* @returns Return row count.
|
|
393
|
-
* @throws [IModelError]($common) If the statement is invalid
|
|
394
|
-
* @deprecated in 3.7. Count the number of results using `count(*)` where the original query is a subquery instead. E.g., `SELECT count(*) FROM (<query-whose-rows-to-count>)`.
|
|
395
|
-
*/
|
|
396
|
-
async queryRowCount(ecsql, params) {
|
|
397
|
-
for await (const row of this.createQueryReader(`SELECT count(*) FROM (${ecsql})`, params)) {
|
|
398
|
-
return row[0];
|
|
399
|
-
}
|
|
400
|
-
throw new core_common_1.IModelError(core_bentley_1.DbResult.BE_SQLITE_ERROR, "Failed to get row count");
|
|
401
|
-
}
|
|
402
|
-
/** Cancel any previous query with same token and run execute the current specified query.
|
|
403
|
-
* The result of the query is async iterator over the rows. The iterator will get next page automatically once rows in current page has been read.
|
|
404
|
-
* [ECSQL row]($docs/learning/ECSQLRowFormat).
|
|
405
|
-
*
|
|
406
|
-
* See also:
|
|
407
|
-
* - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)
|
|
408
|
-
* - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)
|
|
409
|
-
*
|
|
410
|
-
* @param ecsql The ECSQL statement to execute
|
|
411
|
-
* @param token None empty restart token. The previous query with same token would be cancelled. This would cause
|
|
412
|
-
* exception which user code must handle.
|
|
413
|
-
* @param params The values to bind to the parameters (if the ECSQL has any).
|
|
414
|
-
* @param options Allow to specify certain flags which control how query is executed.
|
|
415
|
-
* @returns Returns the query result as an *AsyncIterableIterator<any>* which lazy load result as needed. The row format is determined by *rowFormat* parameter.
|
|
416
|
-
* See [ECSQL row format]($docs/learning/ECSQLRowFormat) for details about the format of the returned rows.
|
|
417
|
-
* @throws [IModelError]($common) If there was any error while submitting, preparing or stepping into query
|
|
418
|
-
* @deprecated in 3.7. Use [[createQueryReader]] instead. Pass in the restart token as part of the `config` argument; e.g., `{ restartToken: myToken }` or `new QueryOptionsBuilder().setRestartToken(myToken).getOptions()`.
|
|
419
|
-
*/
|
|
420
|
-
async *restartQuery(token, ecsql, params, options) {
|
|
421
|
-
for await (const row of this.createQueryReader(ecsql, params, new core_common_1.QueryOptionsBuilder(options).setRestartToken(token).getOptions())) {
|
|
422
|
-
yield row;
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
407
|
/**
|
|
426
408
|
* Use a prepared SQL statement, potentially from the statement cache. If the requested statement doesn't exist
|
|
427
409
|
* in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved
|
|
@@ -465,7 +447,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
465
447
|
*/
|
|
466
448
|
withSqliteStatement(sql, callback, logErrors = true) {
|
|
467
449
|
const stmt = this.prepareSqliteStatement(sql, logErrors);
|
|
468
|
-
const release = () => stmt.dispose();
|
|
450
|
+
const release = () => stmt[Symbol.dispose]();
|
|
469
451
|
try {
|
|
470
452
|
const val = callback(stmt);
|
|
471
453
|
if (val instanceof Promise) {
|
|
@@ -579,6 +561,9 @@ class IModelDb extends core_common_1.IModel {
|
|
|
579
561
|
this._statementCache.clear();
|
|
580
562
|
this._sqliteStatementCache.clear();
|
|
581
563
|
this._classMetaDataRegistry = undefined;
|
|
564
|
+
this._jsClassMap = undefined;
|
|
565
|
+
this._schemaMap = undefined;
|
|
566
|
+
this._schemaContext = undefined;
|
|
582
567
|
}
|
|
583
568
|
/** Update the project extents for this iModel.
|
|
584
569
|
* <p><em>Example:</em>
|
|
@@ -617,9 +602,11 @@ class IModelDb extends core_common_1.IModel {
|
|
|
617
602
|
updateIModelProps() {
|
|
618
603
|
this[Symbols_1._nativeDb].updateIModelProps(this.toJSON());
|
|
619
604
|
}
|
|
620
|
-
/** Commit
|
|
605
|
+
/** Commit unsaved changes in memory as a Txn to this iModelDb.
|
|
621
606
|
* @param description Optional description of the changes
|
|
622
607
|
* @throws [[IModelError]] if there is a problem saving changes or if there are pending, un-processed lock or code requests.
|
|
608
|
+
* @note This will not push changes to the iModelHub.
|
|
609
|
+
* @see [[IModelDb.pushChanges]] to push changes to the iModelHub.
|
|
623
610
|
*/
|
|
624
611
|
saveChanges(description) {
|
|
625
612
|
if (this.openMode === core_bentley_1.OpenMode.Readonly)
|
|
@@ -628,7 +615,9 @@ class IModelDb extends core_common_1.IModel {
|
|
|
628
615
|
if (core_bentley_1.DbResult.BE_SQLITE_OK !== stat)
|
|
629
616
|
throw new core_common_1.IModelError(stat, `Could not save changes (${description})`);
|
|
630
617
|
}
|
|
631
|
-
/** Abandon
|
|
618
|
+
/** Abandon changes in memory that have not been saved as a Txn to this iModelDb.
|
|
619
|
+
* @note This will not delete Txns that have already been saved, even if they have not yet been pushed.
|
|
620
|
+
*/
|
|
632
621
|
abandonChanges() {
|
|
633
622
|
this[Symbols_1._nativeDb].abandonChanges();
|
|
634
623
|
}
|
|
@@ -873,12 +862,54 @@ class IModelDb extends core_common_1.IModel {
|
|
|
873
862
|
}
|
|
874
863
|
/** The registry of entity metadata for this iModel.
|
|
875
864
|
* @internal
|
|
865
|
+
* @deprecated in 5.0. Please use `schemaContext` from the `iModel` instead.
|
|
866
|
+
*
|
|
867
|
+
* @example
|
|
868
|
+
* ```typescript
|
|
869
|
+
* // Current usage:
|
|
870
|
+
* const classMetaData: EntityMetaData | undefined = iModel.classMetaDataRegistry.find("SchemaName:ClassName");
|
|
871
|
+
*
|
|
872
|
+
* // Replacement:
|
|
873
|
+
* const metaData: EntityClass | undefined = imodel.schemaContext.getSchemaItemSync("SchemaName.ClassName", EntityClass);
|
|
874
|
+
* ```
|
|
876
875
|
*/
|
|
876
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
877
877
|
get classMetaDataRegistry() {
|
|
878
878
|
if (this._classMetaDataRegistry === undefined)
|
|
879
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
879
880
|
this._classMetaDataRegistry = new ClassRegistry_1.MetaDataRegistry();
|
|
880
881
|
return this._classMetaDataRegistry;
|
|
881
882
|
}
|
|
883
|
+
/**
|
|
884
|
+
* Allows registering js classes mapped to ECClasses
|
|
885
|
+
*/
|
|
886
|
+
get jsClassMap() {
|
|
887
|
+
if (this._jsClassMap === undefined)
|
|
888
|
+
this._jsClassMap = new ClassRegistry_1.EntityJsClassMap();
|
|
889
|
+
return this._jsClassMap;
|
|
890
|
+
}
|
|
891
|
+
/**
|
|
892
|
+
* Allows locally registering a schema for this imodel, in constrast to [Schemas.registerSchema] which is a global operation
|
|
893
|
+
*/
|
|
894
|
+
get schemaMap() {
|
|
895
|
+
if (this._schemaMap === undefined)
|
|
896
|
+
this._schemaMap = new Schema_1.SchemaMap();
|
|
897
|
+
return this._schemaMap;
|
|
898
|
+
}
|
|
899
|
+
/**
|
|
900
|
+
* Gets the context that allows accessing the metadata (ecschema-metadata package) of this iModel
|
|
901
|
+
* @beta
|
|
902
|
+
*/
|
|
903
|
+
get schemaContext() {
|
|
904
|
+
if (this._schemaContext === undefined) {
|
|
905
|
+
const context = new ecschema_metadata_1.SchemaContext();
|
|
906
|
+
// TODO: We probably need a more optimized locater for here
|
|
907
|
+
const locater = new ecschema_metadata_1.SchemaJsonLocater((name) => this.getSchemaProps(name));
|
|
908
|
+
context.addLocater(locater);
|
|
909
|
+
this._schemaContext = context;
|
|
910
|
+
}
|
|
911
|
+
return this._schemaContext;
|
|
912
|
+
}
|
|
882
913
|
/** Get the linkTableRelationships for this IModel */
|
|
883
914
|
get relationships() {
|
|
884
915
|
return this._relationships || (this._relationships = new Relationship_1.Relationships(this));
|
|
@@ -922,26 +953,54 @@ class IModelDb extends core_common_1.IModel {
|
|
|
922
953
|
if (!ClassRegistry_1.ClassRegistry.isNotFoundError(err)) {
|
|
923
954
|
throw err;
|
|
924
955
|
}
|
|
956
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
925
957
|
this.loadMetaData(classFullName);
|
|
926
958
|
return ClassRegistry_1.ClassRegistry.getClass(classFullName, this);
|
|
927
959
|
}
|
|
928
960
|
}
|
|
929
961
|
/** Get metadata for a class. This method will load the metadata from the iModel into the cache as a side-effect, if necessary.
|
|
930
962
|
* @throws [[IModelError]] if the metadata cannot be found nor loaded.
|
|
963
|
+
* @deprecated in 5.0. Please use `getSchemaItem` from `SchemaContext` class instead.
|
|
964
|
+
*
|
|
965
|
+
* @example
|
|
966
|
+
* * ```typescript
|
|
967
|
+
* // Current usage:
|
|
968
|
+
* const metaData: EntityMetaData = imodel.getMetaData("SchemaName:ClassName");
|
|
969
|
+
*
|
|
970
|
+
* // Replacement:
|
|
971
|
+
* const metaData: EntityClass | undefined = imodel.schemaContext.getSchemaItemSync("SchemaName", "ClassName", EntityClass);
|
|
972
|
+
* ```
|
|
931
973
|
*/
|
|
974
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
932
975
|
getMetaData(classFullName) {
|
|
976
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
933
977
|
let metadata = this.classMetaDataRegistry.find(classFullName);
|
|
934
978
|
if (metadata === undefined) {
|
|
979
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
935
980
|
this.loadMetaData(classFullName);
|
|
981
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
936
982
|
metadata = this.classMetaDataRegistry.find(classFullName);
|
|
937
983
|
if (metadata === undefined)
|
|
938
984
|
throw ClassRegistry_1.ClassRegistry.makeMetaDataNotFoundError(classFullName); // do not log
|
|
939
985
|
}
|
|
940
986
|
return metadata;
|
|
941
987
|
}
|
|
942
|
-
/** Identical to [[getMetaData]], except it returns `undefined` instead of throwing an error if the metadata cannot be found nor loaded.
|
|
988
|
+
/** Identical to [[getMetaData]], except it returns `undefined` instead of throwing an error if the metadata cannot be found nor loaded.
|
|
989
|
+
* @deprecated in 5.0. Please use `getSchemaItem` from `SchemaContext` class instead.
|
|
990
|
+
*
|
|
991
|
+
* @example
|
|
992
|
+
* * ```typescript
|
|
993
|
+
* // Current usage:
|
|
994
|
+
* const metaData: EntityMetaData | undefined = imodel.tryGetMetaData("SchemaName:ClassName");
|
|
995
|
+
*
|
|
996
|
+
* // Replacement:
|
|
997
|
+
* const metaData: EntityClass | undefined = imodel.schemaContext.getSchemaItemSync("SchemaName.ClassName", EntityClass);
|
|
998
|
+
* ```
|
|
999
|
+
*/
|
|
1000
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
943
1001
|
tryGetMetaData(classFullName) {
|
|
944
1002
|
try {
|
|
1003
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
945
1004
|
return this.getMetaData(classFullName);
|
|
946
1005
|
}
|
|
947
1006
|
catch {
|
|
@@ -955,8 +1014,24 @@ class IModelDb extends core_common_1.IModel {
|
|
|
955
1014
|
* @param func The callback to be invoked on each property
|
|
956
1015
|
* @param includeCustom If true (default), include custom-handled properties in the iteration. Otherwise, skip custom-handled properties.
|
|
957
1016
|
* @note Custom-handled properties are core properties that have behavior enforced by C++ handlers.
|
|
1017
|
+
* @deprecated in 5.0. Please use `forEachProperty` instead.
|
|
1018
|
+
*
|
|
1019
|
+
* @example
|
|
1020
|
+
* ```typescript
|
|
1021
|
+
* // Current usage:
|
|
1022
|
+
* IModelDb.forEachMetaData(imodel, "BisCore:Element", true, (name: string, propMetaData: PropertyMetaData) => {
|
|
1023
|
+
* console.log(`Property name: ${name}, Property type: ${propMetaData.primitiveType}`);
|
|
1024
|
+
* }, false);
|
|
1025
|
+
*
|
|
1026
|
+
* // Replacement:
|
|
1027
|
+
* await IModelDb.forEachProperty(imodel, "TestDomain.TestDomainClass", true, (propName: string, property: Property) => {
|
|
1028
|
+
* console.log(`Property name: ${propName}, Property type: ${property.propertyType}`);
|
|
1029
|
+
* }, false);
|
|
1030
|
+
* ```
|
|
958
1031
|
*/
|
|
1032
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
959
1033
|
static forEachMetaData(iModel, classFullName, wantSuper, func, includeCustom = true) {
|
|
1034
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
960
1035
|
iModel.forEachMetaData(classFullName, wantSuper, func, includeCustom);
|
|
961
1036
|
}
|
|
962
1037
|
/** Invoke a callback on each property of the specified class, optionally including superclass properties.
|
|
@@ -965,8 +1040,24 @@ class IModelDb extends core_common_1.IModel {
|
|
|
965
1040
|
* @param func The callback to be invoked on each property
|
|
966
1041
|
* @param includeCustom If true (default), include custom-handled properties in the iteration. Otherwise, skip custom-handled properties.
|
|
967
1042
|
* @note Custom-handled properties are core properties that have behavior enforced by C++ handlers.
|
|
1043
|
+
* @deprecated in 5.0. Use `forEachProperty` from `SchemaContext` class instead.
|
|
1044
|
+
*
|
|
1045
|
+
* @example
|
|
1046
|
+
* ```typescript
|
|
1047
|
+
* // Current usage:
|
|
1048
|
+
* iModel.forEachMetaData("BisCore:Element", true, (name: string, propMetaData: PropertyMetaData) => {
|
|
1049
|
+
* console.log(`Property name: ${name}, Property type: ${propMetaData.primitiveType}`);
|
|
1050
|
+
* });
|
|
1051
|
+
*
|
|
1052
|
+
* // Replacement:
|
|
1053
|
+
* imodel.schemaContext.forEachProperty("BisCore:Element", true, (propName: string, property: Property) => {
|
|
1054
|
+
* console.log(`Property name: ${propName}, Property type: ${property.propertyType}`);
|
|
1055
|
+
* });
|
|
1056
|
+
* ```
|
|
968
1057
|
*/
|
|
1058
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
969
1059
|
forEachMetaData(classFullName, wantSuper, func, includeCustom = true) {
|
|
1060
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
970
1061
|
const meta = this.getMetaData(classFullName); // will load if necessary
|
|
971
1062
|
for (const propName in meta.properties) { // eslint-disable-line guard-for-in
|
|
972
1063
|
const propMeta = meta.properties[propName];
|
|
@@ -974,10 +1065,15 @@ class IModelDb extends core_common_1.IModel {
|
|
|
974
1065
|
func(propName, propMeta);
|
|
975
1066
|
}
|
|
976
1067
|
if (wantSuper && meta.baseClasses && meta.baseClasses.length > 0)
|
|
1068
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
977
1069
|
meta.baseClasses.forEach((baseClass) => this.forEachMetaData(baseClass, true, func, includeCustom));
|
|
978
1070
|
}
|
|
979
|
-
/**
|
|
1071
|
+
/**
|
|
1072
|
+
* @internal
|
|
1073
|
+
* @deprecated in 5.0. Please use `schemaContext` from `iModel` instead to get metadata.
|
|
1074
|
+
*/
|
|
980
1075
|
loadMetaData(classFullName) {
|
|
1076
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
981
1077
|
if (this.classMetaDataRegistry.find(classFullName))
|
|
982
1078
|
return;
|
|
983
1079
|
const className = classFullName.split(":");
|
|
@@ -987,10 +1083,13 @@ class IModelDb extends core_common_1.IModel {
|
|
|
987
1083
|
if (val.error)
|
|
988
1084
|
throw new core_common_1.IModelError(val.error.status, `Error getting class meta data for: ${classFullName}`);
|
|
989
1085
|
(0, core_bentley_1.assert)(undefined !== val.result);
|
|
1086
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
990
1087
|
const metaData = new core_common_1.EntityMetaData(JSON.parse(val.result));
|
|
1088
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
991
1089
|
this.classMetaDataRegistry.add(classFullName, metaData);
|
|
992
1090
|
// Recursive, to make sure that base classes are cached.
|
|
993
1091
|
if (metaData.baseClasses !== undefined && metaData.baseClasses.length > 0)
|
|
1092
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
994
1093
|
metaData.baseClasses.forEach((baseClassName) => this.loadMetaData(baseClassName));
|
|
995
1094
|
}
|
|
996
1095
|
/** Returns the full schema for the input name.
|
|
@@ -1192,6 +1291,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
1192
1291
|
async generateElementGraphics(request) {
|
|
1193
1292
|
return (0, ElementGraphics_1.generateElementGraphics)(request, this);
|
|
1194
1293
|
}
|
|
1294
|
+
static _settingPropNamespace = "settings";
|
|
1195
1295
|
/** Save a `SettingDictionary` in this iModel that will be loaded into [[workspace.settings]] every time this iModel is opened in future sessions.
|
|
1196
1296
|
* @param name The name for the SettingDictionary. If a dictionary by that name already exists in the iModel, its value is replaced.
|
|
1197
1297
|
* @param dict The SettingDictionary object to stringify and save.
|
|
@@ -1284,19 +1384,61 @@ class IModelDb extends core_common_1.IModel {
|
|
|
1284
1384
|
justification: core_geometry_1.Range2d.fromJSON(props.justification),
|
|
1285
1385
|
};
|
|
1286
1386
|
}
|
|
1387
|
+
/** Writes the contents of a single ECSchema to a file on the local file system.
|
|
1388
|
+
* @beta
|
|
1389
|
+
*/
|
|
1390
|
+
exportSchema(args) {
|
|
1391
|
+
processSchemaWriteStatus(this[Symbols_1._nativeDb].exportSchema(args.schemaName, args.outputDirectory, args.outputFileName));
|
|
1392
|
+
}
|
|
1393
|
+
/** Writes the contents of all ECSchemas in this iModel to files in a directory on the local file system.
|
|
1394
|
+
* @beta
|
|
1395
|
+
*/
|
|
1396
|
+
exportSchemas(outputDirectory) {
|
|
1397
|
+
processSchemaWriteStatus(this[Symbols_1._nativeDb].exportSchemas(outputDirectory));
|
|
1398
|
+
}
|
|
1399
|
+
/** Attempt to simplify the geometry stream of a single [[GeometricElement]] or [[GeometryPart]] as specified by `args`.
|
|
1400
|
+
* @beta
|
|
1401
|
+
*/
|
|
1402
|
+
simplifyElementGeometry(args) {
|
|
1403
|
+
return this[Symbols_1._nativeDb].simplifyElementGeometry(args);
|
|
1404
|
+
}
|
|
1405
|
+
/** Attempts to optimize all of the geometry in this iModel by identifying [[GeometryPart]]s that are referenced by exactly one
|
|
1406
|
+
* element's geometry stream. Each such reference is replaced by inserting the part's geometry directly into the element's geometry stream.
|
|
1407
|
+
* Then, the no-longer-used geometry part is deleted.
|
|
1408
|
+
* This can improve performance when a connector inadvertently creates large numbers of parts that are each only used once.
|
|
1409
|
+
* @beta
|
|
1410
|
+
*/
|
|
1411
|
+
inlineGeometryParts() {
|
|
1412
|
+
return this[Symbols_1._nativeDb].inlineGeometryPartReferences();
|
|
1413
|
+
}
|
|
1414
|
+
/** Returns a string representation of the error that most recently arose during an operation on the underlying SQLite database.
|
|
1415
|
+
* If no errors have occurred, an empty string is returned.
|
|
1416
|
+
* Otherwise, a string of the format `message (code)` is returned, where `message` is a human-readable diagnostic string and `code` is an integer status code.
|
|
1417
|
+
* See [SQLite error codes and messages](https://www.sqlite.org/c3ref/errcode.html)
|
|
1418
|
+
* @note Do not rely upon this value or its specific contents in error handling logic. It is only intended for use in debugging.
|
|
1419
|
+
*/
|
|
1420
|
+
getLastError() {
|
|
1421
|
+
return this[Symbols_1._nativeDb].getLastError();
|
|
1422
|
+
}
|
|
1287
1423
|
}
|
|
1288
1424
|
exports.IModelDb = IModelDb;
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1425
|
+
function processSchemaWriteStatus(status) {
|
|
1426
|
+
switch (status) {
|
|
1427
|
+
case 0 /* SchemaWriteStatus.Success */: return;
|
|
1428
|
+
case 1 /* SchemaWriteStatus.FailedToSaveXml */: throw new Error("Failed to save schema XML");
|
|
1429
|
+
case 2 /* SchemaWriteStatus.FailedToCreateXml */: throw new Error("Failed to create schema XML");
|
|
1430
|
+
case 3 /* SchemaWriteStatus.FailedToCreateJson */: throw new Error("Failed to create schema JSON");
|
|
1431
|
+
case 4 /* SchemaWriteStatus.FailedToWriteFile */: throw new Error("Failed to write schema file");
|
|
1432
|
+
default: throw new Error("Unknown error while exporting schema");
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1294
1435
|
/** @public */
|
|
1295
1436
|
(function (IModelDb) {
|
|
1296
1437
|
/** The collection of models in an [[IModelDb]].
|
|
1297
1438
|
* @public
|
|
1298
1439
|
*/
|
|
1299
1440
|
class Models {
|
|
1441
|
+
_iModel;
|
|
1300
1442
|
/** @internal */
|
|
1301
1443
|
constructor(_iModel) {
|
|
1302
1444
|
this._iModel = _iModel;
|
|
@@ -1504,6 +1646,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1504
1646
|
* @public
|
|
1505
1647
|
*/
|
|
1506
1648
|
class Elements {
|
|
1649
|
+
_iModel;
|
|
1507
1650
|
/** @internal */
|
|
1508
1651
|
constructor(_iModel) {
|
|
1509
1652
|
this._iModel = _iModel;
|
|
@@ -1671,9 +1814,9 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1671
1814
|
* the value of `elProps.federationGuid` is *not* updated. Generally, it is best to re-read the element after inserting (e.g. via [[getElementProps]])
|
|
1672
1815
|
* if you intend to continue working with it. That will ensure its values reflect the persistent state.
|
|
1673
1816
|
*/
|
|
1674
|
-
insertElement(elProps) {
|
|
1817
|
+
insertElement(elProps, options) {
|
|
1675
1818
|
try {
|
|
1676
|
-
return elProps.id = this._iModel[Symbols_1._nativeDb].insertElement(elProps);
|
|
1819
|
+
return elProps.id = this._iModel[Symbols_1._nativeDb].insertElement(elProps, options);
|
|
1677
1820
|
}
|
|
1678
1821
|
catch (err) {
|
|
1679
1822
|
err.message = `Error inserting element [${err.message}]`;
|
|
@@ -1893,6 +2036,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1893
2036
|
}
|
|
1894
2037
|
return this._queryAspect(aspectInstanceId, aspectClassFullName);
|
|
1895
2038
|
}
|
|
2039
|
+
static classMap = new Map();
|
|
1896
2040
|
runInstanceQuery(sql, elementId, excludedClassFullNames) {
|
|
1897
2041
|
return this._iModel.withPreparedStatement(sql, (statement) => {
|
|
1898
2042
|
statement.bindId("elementId", elementId);
|
|
@@ -1922,9 +2066,9 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1922
2066
|
*/
|
|
1923
2067
|
getAspects(elementId, aspectClassFullName, excludedClassFullNames) {
|
|
1924
2068
|
if (aspectClassFullName === undefined) {
|
|
1925
|
-
const allAspects = this.runInstanceQuery(`SELECT $ FROM (
|
|
1926
|
-
SELECT ECInstanceId, ECClassId FROM Bis.ElementMultiAspect WHERE Element.Id = :elementId
|
|
1927
|
-
UNION ALL
|
|
2069
|
+
const allAspects = this.runInstanceQuery(`SELECT $ FROM (
|
|
2070
|
+
SELECT ECInstanceId, ECClassId FROM Bis.ElementMultiAspect WHERE Element.Id = :elementId
|
|
2071
|
+
UNION ALL
|
|
1928
2072
|
SELECT ECInstanceId, ECClassId FROM Bis.ElementUniqueAspect WHERE Element.Id = :elementId) OPTIONS USE_JS_PROP_NAMES DO_NOT_TRUNCATE_BLOB`, elementId, excludedClassFullNames);
|
|
1929
2073
|
if (allAspects.length === 0)
|
|
1930
2074
|
core_bentley_1.Logger.logInfo(BackendLoggerCategory_1.BackendLoggerCategory.ECDb, `No aspects found for class ${aspectClassFullName} and element ${elementId}`);
|
|
@@ -1934,6 +2078,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1934
2078
|
const fullClassName = aspectClassFullName.replace(".", ":").split(":");
|
|
1935
2079
|
const val = this._iModel[Symbols_1._nativeDb].getECClassMetaData(fullClassName[0], fullClassName[1]);
|
|
1936
2080
|
if (val.result !== undefined) {
|
|
2081
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
1937
2082
|
const metaData = new core_common_1.EntityMetaData(JSON.parse(val.result));
|
|
1938
2083
|
if (metaData.modifier !== "Abstract") // Class is not abstract, use normal query to retrieve aspects
|
|
1939
2084
|
return this._queryAspects(elementId, aspectClassFullName, excludedClassFullNames);
|
|
@@ -1942,7 +2087,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1942
2087
|
let classIdList = IModelDb.Elements.classMap.get(aspectClassFullName);
|
|
1943
2088
|
if (classIdList === undefined) {
|
|
1944
2089
|
const classIds = [];
|
|
1945
|
-
this._iModel.withPreparedStatement(`select SourceECInstanceId from meta.ClassHasAllBaseClasses where TargetECInstanceId = (select ECInstanceId from meta.ECClassDef where Name='${fullClassName[1]}'
|
|
2090
|
+
this._iModel.withPreparedStatement(`select SourceECInstanceId from meta.ClassHasAllBaseClasses where TargetECInstanceId = (select ECInstanceId from meta.ECClassDef where Name='${fullClassName[1]}'
|
|
1946
2091
|
and Schema.Id = (select ECInstanceId from meta.ECSchemaDef where Name='${fullClassName[0]}')) and SourceECInstanceId != TargetECInstanceId`, (statement) => {
|
|
1947
2092
|
while (statement.step() === core_bentley_1.DbResult.BE_SQLITE_ROW)
|
|
1948
2093
|
classIds.push(statement.getValue(0).getId());
|
|
@@ -1957,10 +2102,10 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1957
2102
|
return [];
|
|
1958
2103
|
}
|
|
1959
2104
|
// Execute an instance query to retrieve all aspects from all the derived classes
|
|
1960
|
-
const aspects = this.runInstanceQuery(`SELECT $ FROM (
|
|
1961
|
-
SELECT ECInstanceId, ECClassId FROM Bis.ElementMultiAspect WHERE Element.Id = :elementId AND ECClassId IN (${classIdList})
|
|
1962
|
-
UNION ALL
|
|
1963
|
-
SELECT ECInstanceId, ECClassId FROM Bis.ElementUniqueAspect WHERE Element.Id = :elementId AND ECClassId IN (${classIdList})
|
|
2105
|
+
const aspects = this.runInstanceQuery(`SELECT $ FROM (
|
|
2106
|
+
SELECT ECInstanceId, ECClassId FROM Bis.ElementMultiAspect WHERE Element.Id = :elementId AND ECClassId IN (${classIdList})
|
|
2107
|
+
UNION ALL
|
|
2108
|
+
SELECT ECInstanceId, ECClassId FROM Bis.ElementUniqueAspect WHERE Element.Id = :elementId AND ECClassId IN (${classIdList})
|
|
1964
2109
|
) OPTIONS USE_JS_PROP_NAMES DO_NOT_TRUNCATE_BLOB`, elementId, excludedClassFullNames);
|
|
1965
2110
|
if (aspects.length === 0)
|
|
1966
2111
|
core_bentley_1.Logger.logInfo(BackendLoggerCategory_1.BackendLoggerCategory.ECDb, `No aspects found for class ${aspectClassFullName} and element ${elementId}`);
|
|
@@ -2009,16 +2154,18 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
2009
2154
|
});
|
|
2010
2155
|
}
|
|
2011
2156
|
}
|
|
2012
|
-
Elements.classMap = new Map();
|
|
2013
2157
|
IModelDb.Elements = Elements;
|
|
2014
2158
|
/** The collection of views in an [[IModelDb]].
|
|
2015
2159
|
* @public
|
|
2016
2160
|
*/
|
|
2017
2161
|
class Views {
|
|
2162
|
+
_iModel;
|
|
2018
2163
|
/** @internal */
|
|
2019
2164
|
constructor(_iModel) {
|
|
2020
2165
|
this._iModel = _iModel;
|
|
2021
2166
|
}
|
|
2167
|
+
static viewStoreProperty = { namespace: "itwinjs", name: "DefaultViewStore" };
|
|
2168
|
+
_viewStore;
|
|
2022
2169
|
get hasViewStore() { return undefined !== this._viewStore; }
|
|
2023
2170
|
/** @beta */
|
|
2024
2171
|
get viewStore() {
|
|
@@ -2070,6 +2217,8 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
2070
2217
|
});
|
|
2071
2218
|
return props;
|
|
2072
2219
|
}
|
|
2220
|
+
/** Default parameters for iterating/querying ViewDefinitions. Includes all subclasses of ViewDefinition, excluding only those marked 'private'. */
|
|
2221
|
+
static defaultQueryParams = { from: "BisCore.ViewDefinition", where: "IsPrivate=FALSE" };
|
|
2073
2222
|
/** Iterate all ViewDefinitions matching the supplied query.
|
|
2074
2223
|
* @param params Specifies the query by which views are selected.
|
|
2075
2224
|
* @param callback Function invoked for each ViewDefinition matching the query. Return false to terminate iteration, true to continue.
|
|
@@ -2141,17 +2290,6 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
2141
2290
|
}
|
|
2142
2291
|
return props;
|
|
2143
2292
|
}
|
|
2144
|
-
/** @deprecated in 3.x. use [[getViewStateProps]]. */
|
|
2145
|
-
getViewStateData(viewDefinitionId, options) {
|
|
2146
|
-
const viewStateData = this.loadViewData(viewDefinitionId, options);
|
|
2147
|
-
const baseModelId = viewStateData.viewDefinitionProps.baseModelId;
|
|
2148
|
-
if (baseModelId) {
|
|
2149
|
-
const drawingExtents = core_geometry_1.Range3d.fromJSON(this._iModel[Symbols_1._nativeDb].queryModelExtents({ id: baseModelId }).modelExtents);
|
|
2150
|
-
if (!drawingExtents.isNull)
|
|
2151
|
-
viewStateData.modelExtents = drawingExtents.toJSON();
|
|
2152
|
-
}
|
|
2153
|
-
return viewStateData;
|
|
2154
|
-
}
|
|
2155
2293
|
/** Obtain a [ViewStateProps]($common) for a [[ViewDefinition]] specified by ViewIdString. */
|
|
2156
2294
|
async getViewStateProps(viewDefinitionId, options) {
|
|
2157
2295
|
const viewStateData = this.loadViewData(viewDefinitionId, options);
|
|
@@ -2206,9 +2344,6 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
2206
2344
|
this._iModel.saveFileProperty(spec, undefined, blob8);
|
|
2207
2345
|
}
|
|
2208
2346
|
}
|
|
2209
|
-
Views.viewStoreProperty = { namespace: "itwinjs", name: "DefaultViewStore" };
|
|
2210
|
-
/** Default parameters for iterating/querying ViewDefinitions. Includes all subclasses of ViewDefinition, excluding only those marked 'private'. */
|
|
2211
|
-
Views.defaultQueryParams = { from: "BisCore.ViewDefinition", where: "IsPrivate=FALSE" };
|
|
2212
2347
|
IModelDb.Views = Views;
|
|
2213
2348
|
/** Represents the current state of a pollable tile content request.
|
|
2214
2349
|
* Note: lack of a "completed" state because polling a completed request returns the content as a Uint8Array.
|
|
@@ -2222,6 +2357,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
2222
2357
|
})(TileContentState = IModelDb.TileContentState || (IModelDb.TileContentState = {}));
|
|
2223
2358
|
/** @internal */
|
|
2224
2359
|
class Tiles {
|
|
2360
|
+
_iModel;
|
|
2225
2361
|
/** @internal */
|
|
2226
2362
|
constructor(_iModel) {
|
|
2227
2363
|
this._iModel = _iModel;
|
|
@@ -2296,10 +2432,38 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
2296
2432
|
* @public
|
|
2297
2433
|
*/
|
|
2298
2434
|
class BriefcaseDb extends IModelDb {
|
|
2435
|
+
/** Manages local changes to this briefcase. */
|
|
2436
|
+
txns = new TxnManager_1.TxnManager(this);
|
|
2299
2437
|
/** override superclass method */
|
|
2300
2438
|
get isBriefcase() { return true; }
|
|
2439
|
+
/* the BriefcaseId of the briefcase opened with this BriefcaseDb */
|
|
2440
|
+
briefcaseId;
|
|
2441
|
+
_skipSyncSchemasOnPullAndPush;
|
|
2301
2442
|
/** @internal */
|
|
2302
2443
|
get skipSyncSchemasOnPullAndPush() { return this._skipSyncSchemasOnPullAndPush ?? false; }
|
|
2444
|
+
/**
|
|
2445
|
+
* Event raised just before a BriefcaseDb is opened. Supplies the arguments that will be used to open the BriefcaseDb.
|
|
2446
|
+
* Throw an exception to stop the open.
|
|
2447
|
+
*
|
|
2448
|
+
* **Example:**
|
|
2449
|
+
* ``` ts
|
|
2450
|
+
* [[include:BriefcaseDb.onOpen]]
|
|
2451
|
+
* ```
|
|
2452
|
+
*/
|
|
2453
|
+
static onOpen = new core_bentley_1.BeEvent();
|
|
2454
|
+
/**
|
|
2455
|
+
* Event raised just after a BriefcaseDb is opened. Supplies the newly opened BriefcaseDb and the arguments that were used to open it.
|
|
2456
|
+
*
|
|
2457
|
+
* **Example:**
|
|
2458
|
+
* ``` ts
|
|
2459
|
+
* [[include:BriefcaseDb.onOpened]]
|
|
2460
|
+
* ```
|
|
2461
|
+
*/
|
|
2462
|
+
static onOpened = new core_bentley_1.BeEvent();
|
|
2463
|
+
/** Event raised after a BriefcaseDb has been closed. */
|
|
2464
|
+
onClosed = new core_bentley_1.BeEvent();
|
|
2465
|
+
/** @alpha */
|
|
2466
|
+
static onCodeServiceCreated = new core_bentley_1.BeEvent();
|
|
2303
2467
|
static findByKey(key) {
|
|
2304
2468
|
return super.findByKey(key);
|
|
2305
2469
|
}
|
|
@@ -2329,10 +2493,6 @@ class BriefcaseDb extends IModelDb {
|
|
|
2329
2493
|
}
|
|
2330
2494
|
constructor(args) {
|
|
2331
2495
|
super({ ...args, changeset: args.nativeDb.getCurrentChangeset() });
|
|
2332
|
-
/** Manages local changes to this briefcase. */
|
|
2333
|
-
this.txns = new TxnManager_1.TxnManager(this);
|
|
2334
|
-
/** Event raised after a BriefcaseDb has been closed. */
|
|
2335
|
-
this.onClosed = new core_bentley_1.BeEvent();
|
|
2336
2496
|
this._openMode = args.openMode;
|
|
2337
2497
|
this.briefcaseId = args.briefcaseId;
|
|
2338
2498
|
this.makeLockControl();
|
|
@@ -2415,6 +2575,7 @@ class BriefcaseDb extends IModelDb {
|
|
|
2415
2575
|
finally {
|
|
2416
2576
|
await withBriefcaseDb(briefcase, async (db) => db.locks[Symbols_1._releaseAllLocks]());
|
|
2417
2577
|
}
|
|
2578
|
+
return;
|
|
2418
2579
|
}
|
|
2419
2580
|
throw error;
|
|
2420
2581
|
}
|
|
@@ -2748,39 +2909,25 @@ class BriefcaseDb extends IModelDb {
|
|
|
2748
2909
|
this.txns.touchWatchFile();
|
|
2749
2910
|
}
|
|
2750
2911
|
close() {
|
|
2912
|
+
if (this.isBriefcase && this.isOpen && !this.isReadonly && this.txns.changeMergeManager.inProgress()) {
|
|
2913
|
+
this.abandonChanges();
|
|
2914
|
+
}
|
|
2751
2915
|
super.close();
|
|
2752
2916
|
this.onClosed.raiseEvent();
|
|
2753
2917
|
}
|
|
2754
2918
|
}
|
|
2755
2919
|
exports.BriefcaseDb = BriefcaseDb;
|
|
2756
|
-
/**
|
|
2757
|
-
* Event raised just before a BriefcaseDb is opened. Supplies the arguments that will be used to open the BriefcaseDb.
|
|
2758
|
-
* Throw an exception to stop the open.
|
|
2759
|
-
*
|
|
2760
|
-
* **Example:**
|
|
2761
|
-
* ``` ts
|
|
2762
|
-
* [[include:BriefcaseDb.onOpen]]
|
|
2763
|
-
* ```
|
|
2764
|
-
*/
|
|
2765
|
-
BriefcaseDb.onOpen = new core_bentley_1.BeEvent();
|
|
2766
|
-
/**
|
|
2767
|
-
* Event raised just after a BriefcaseDb is opened. Supplies the newly opened BriefcaseDb and the arguments that were used to open it.
|
|
2768
|
-
*
|
|
2769
|
-
* **Example:**
|
|
2770
|
-
* ``` ts
|
|
2771
|
-
* [[include:BriefcaseDb.onOpened]]
|
|
2772
|
-
* ```
|
|
2773
|
-
*/
|
|
2774
|
-
BriefcaseDb.onOpened = new core_bentley_1.BeEvent();
|
|
2775
|
-
/** @alpha */
|
|
2776
|
-
BriefcaseDb.onCodeServiceCreated = new core_bentley_1.BeEvent();
|
|
2777
2920
|
/** Used to reattach Daemon from a user's accessToken for V2 checkpoints.
|
|
2778
2921
|
* @note Reattach only happens if the previous access token either has expired or is about to expire within an application-supplied safety duration.
|
|
2779
2922
|
*/
|
|
2780
2923
|
class RefreshV2CheckpointSas {
|
|
2924
|
+
/** the time at which the current token should be refreshed (its expiry minus safetySeconds) */
|
|
2925
|
+
_timestamp = 0;
|
|
2926
|
+
/** while a refresh is happening, all callers get this promise. */
|
|
2927
|
+
_promise;
|
|
2928
|
+
/** Time, in seconds, before the current token expires to obtain a new token. Default is 1 hour. */
|
|
2929
|
+
_safetySeconds;
|
|
2781
2930
|
constructor(sasToken, safetySeconds) {
|
|
2782
|
-
/** the time at which the current token should be refreshed (its expiry minus safetySeconds) */
|
|
2783
|
-
this._timestamp = 0;
|
|
2784
2931
|
this._safetySeconds = safetySeconds ?? 60 * 60; // default to 1 hour
|
|
2785
2932
|
this.setTimestamp(sasToken);
|
|
2786
2933
|
}
|
|
@@ -2794,7 +2941,7 @@ class RefreshV2CheckpointSas {
|
|
|
2794
2941
|
if (!container)
|
|
2795
2942
|
throw new Error("checkpoint is not from a cloud container");
|
|
2796
2943
|
(0, core_bentley_1.assert)(undefined !== iModel.iTwinId);
|
|
2797
|
-
const props = await IModelHost_1.IModelHost.
|
|
2944
|
+
const props = await IModelHost_1.IModelHost[Symbols_1._hubAccess].queryV2Checkpoint({ accessToken, iTwinId: iModel.iTwinId, iModelId: iModel.iModelId, changeset: iModel.changeset });
|
|
2798
2945
|
if (!props)
|
|
2799
2946
|
throw new Error("can't reset checkpoint sas token");
|
|
2800
2947
|
container.accessToken = props.sasToken;
|
|
@@ -2827,9 +2974,18 @@ class RefreshV2CheckpointSas {
|
|
|
2827
2974
|
*/
|
|
2828
2975
|
class SnapshotDb extends IModelDb {
|
|
2829
2976
|
get isSnapshot() { return true; }
|
|
2977
|
+
_refreshSas;
|
|
2978
|
+
/** Timer used to restart the default txn on the SnapshotDb after some inactivity. This is only used for checkpoints.
|
|
2979
|
+
* Restarting the default txn lets CloudSqlite know that any blocks that may have been read may now be ejected.
|
|
2980
|
+
* Without restarting the default txn, CloudSQLite can get into a state where it can not evict any blocks to make space for more blocks.
|
|
2981
|
+
*/
|
|
2982
|
+
_restartDefaultTxnTimer;
|
|
2983
|
+
_createClassViewsOnClose;
|
|
2984
|
+
static onOpen = new core_bentley_1.BeEvent();
|
|
2985
|
+
static onOpened = new core_bentley_1.BeEvent();
|
|
2830
2986
|
constructor(nativeDb, key) {
|
|
2831
|
-
super({ nativeDb, key, changeset: nativeDb.getCurrentChangeset() });
|
|
2832
|
-
this._openMode = nativeDb.isReadonly() ? core_bentley_1.OpenMode.Readonly : core_bentley_1.OpenMode.ReadWrite;
|
|
2987
|
+
super({ nativeDb, key, changeset: nativeDb.getCurrentChangeset() });
|
|
2988
|
+
this._openMode = nativeDb.isReadonly() ? core_bentley_1.OpenMode.Readonly : core_bentley_1.OpenMode.ReadWrite;
|
|
2833
2989
|
}
|
|
2834
2990
|
static findByKey(key) {
|
|
2835
2991
|
return super.findByKey(key);
|
|
@@ -2869,7 +3025,7 @@ class SnapshotDb extends IModelDb {
|
|
|
2869
3025
|
iModelDb.performCheckpoint();
|
|
2870
3026
|
IModelJsFs_1.IModelJsFs.copySync(iModelDb.pathName, snapshotFile);
|
|
2871
3027
|
const nativeDb = new NativePlatform_1.IModelNative.platform.DgnDb();
|
|
2872
|
-
nativeDb.openIModel(snapshotFile, core_bentley_1.OpenMode.ReadWrite, undefined
|
|
3028
|
+
nativeDb.openIModel(snapshotFile, core_bentley_1.OpenMode.ReadWrite, undefined);
|
|
2873
3029
|
nativeDb.vacuum();
|
|
2874
3030
|
// Replace iModelId if seedFile is a snapshot, preserve iModelId if seedFile is an iModelHub-managed briefcase
|
|
2875
3031
|
if (!BriefcaseManager_1.BriefcaseManager.isValidBriefcaseId(nativeDb.getBriefcaseId()))
|
|
@@ -2968,8 +3124,6 @@ class SnapshotDb extends IModelDb {
|
|
|
2968
3124
|
}
|
|
2969
3125
|
}
|
|
2970
3126
|
exports.SnapshotDb = SnapshotDb;
|
|
2971
|
-
SnapshotDb.onOpen = new core_bentley_1.BeEvent();
|
|
2972
|
-
SnapshotDb.onOpened = new core_bentley_1.BeEvent();
|
|
2973
3127
|
/**
|
|
2974
3128
|
* Standalone iModels are read/write files that are not associated with an iTwin or managed by iModelHub.
|
|
2975
3129
|
* They are relevant only for testing, or for small-scale single-user scenarios.
|
|
@@ -3062,6 +3216,22 @@ class StandaloneDb extends BriefcaseDb {
|
|
|
3062
3216
|
throw error;
|
|
3063
3217
|
}
|
|
3064
3218
|
}
|
|
3219
|
+
/** Convert an iModel stored on the local file system into a StandaloneDb, chiefly for testing purposes.
|
|
3220
|
+
* The file must not be open in any application.
|
|
3221
|
+
* @param iModelFileName the path to the iModel on the local file system.
|
|
3222
|
+
* @beta
|
|
3223
|
+
*/
|
|
3224
|
+
static convertToStandalone(iModelFileName) {
|
|
3225
|
+
const nativeDb = new NativePlatform_1.IModelNative.platform.DgnDb();
|
|
3226
|
+
nativeDb.openIModel(iModelFileName, core_bentley_1.OpenMode.ReadWrite);
|
|
3227
|
+
nativeDb.setITwinId(core_bentley_1.Guid.empty); // empty iTwinId means "standalone"
|
|
3228
|
+
nativeDb.saveChanges(); // save change to iTwinId
|
|
3229
|
+
nativeDb.deleteAllTxns(); // necessary before resetting briefcaseId
|
|
3230
|
+
nativeDb.resetBriefcaseId(core_common_1.BriefcaseIdValue.Unassigned); // standalone iModels should always have BriefcaseId unassigned
|
|
3231
|
+
nativeDb.saveLocalValue("StandaloneEdit", JSON.stringify({ txns: true }));
|
|
3232
|
+
nativeDb.saveChanges(); // save change to briefcaseId
|
|
3233
|
+
nativeDb.closeFile();
|
|
3234
|
+
}
|
|
3065
3235
|
}
|
|
3066
3236
|
exports.StandaloneDb = StandaloneDb;
|
|
3067
3237
|
//# sourceMappingURL=IModelDb.js.map
|