@itwin/core-backend 4.8.0-dev.21 → 4.8.0-dev.24
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 +8 -1
- package/lib/cjs/BackendHubAccess.js.map +1 -1
- package/lib/cjs/BackendLoggerCategory.js.map +1 -1
- package/lib/cjs/BisCoreSchema.js.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 +15 -9
- package/lib/cjs/BriefcaseManager.js.map +1 -1
- package/lib/cjs/Category.js.map +1 -1
- package/lib/cjs/ChangeSummaryManager.d.ts.map +1 -1
- package/lib/cjs/ChangeSummaryManager.js +9 -8
- package/lib/cjs/ChangeSummaryManager.js.map +1 -1
- package/lib/cjs/ChangedElementsDb.d.ts.map +1 -1
- package/lib/cjs/ChangedElementsDb.js +3 -2
- package/lib/cjs/ChangedElementsDb.js.map +1 -1
- package/lib/cjs/ChangedElementsManager.js.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.js +237 -237
- 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 +3 -2
- 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.js.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.js.map +1 -1
- 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 +17 -12
- package/lib/cjs/ECDb.js.map +1 -1
- package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
- package/lib/cjs/ECSqlStatement.js.map +1 -1
- package/lib/cjs/Element.js.map +1 -1
- 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.js.map +1 -1
- 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 +6 -1
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +115 -111
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/IModelElementCloneContext.d.ts.map +1 -1
- package/lib/cjs/IModelElementCloneContext.js +4 -3
- package/lib/cjs/IModelElementCloneContext.js.map +1 -1
- package/lib/cjs/IModelHost.d.ts +1 -1
- package/lib/cjs/IModelHost.js +1 -1
- 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 +13 -12
- package/lib/cjs/IpcHost.js.map +1 -1
- package/lib/cjs/LineStyle.js.map +1 -1
- package/lib/cjs/LocalHub.js +1 -1
- package/lib/cjs/LocalHub.js.map +1 -1
- package/lib/cjs/LocalhostIpcHost.js.map +1 -1
- package/lib/cjs/LockControl.js.map +1 -1
- package/lib/cjs/Material.js.map +1 -1
- package/lib/cjs/Model.js +1 -1
- 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.js.map +1 -1
- package/lib/cjs/Relationship.d.ts.map +1 -1
- package/lib/cjs/Relationship.js +5 -4
- package/lib/cjs/Relationship.js.map +1 -1
- package/lib/cjs/RpcBackend.js.map +1 -1
- package/lib/cjs/SQLiteDb.d.ts +6 -1
- package/lib/cjs/SQLiteDb.d.ts.map +1 -1
- package/lib/cjs/SQLiteDb.js +21 -14
- package/lib/cjs/SQLiteDb.js.map +1 -1
- package/lib/cjs/Schema.js.map +1 -1
- package/lib/cjs/SchemaSync.d.ts +3 -0
- package/lib/cjs/SchemaSync.d.ts.map +1 -1
- package/lib/cjs/SchemaSync.js +22 -9
- package/lib/cjs/SchemaSync.js.map +1 -1
- package/lib/cjs/SchemaUtils.js.map +1 -1
- package/lib/cjs/SqliteChangesetReader.js.map +1 -1
- package/lib/cjs/SqliteStatement.js.map +1 -1
- package/lib/cjs/TextAnnotationElement.js.map +1 -1
- package/lib/cjs/TextAnnotationGeometry.js.map +1 -1
- 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.map +1 -1
- package/lib/cjs/TxnManager.js +2 -1
- package/lib/cjs/TxnManager.js.map +1 -1
- package/lib/cjs/ViewDefinition.js.map +1 -1
- package/lib/cjs/ViewStateHydrator.js.map +1 -1
- package/lib/cjs/ViewStore.d.ts.map +1 -1
- package/lib/cjs/ViewStore.js +6 -5
- 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.js.map +1 -1
- 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.js.map +1 -1
- package/lib/cjs/domains/GenericSchema.js.map +1 -1
- package/lib/cjs/internal/ChangesetConflictArgs.js.map +1 -1
- package/lib/cjs/internal/ChannelAdmin.d.ts.map +1 -1
- package/lib/cjs/internal/ChannelAdmin.js +1 -1
- package/lib/cjs/internal/ChannelAdmin.js.map +1 -1
- package/lib/cjs/internal/NativePlatform.js.map +1 -1
- 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 +1 -1
- package/lib/cjs/internal/ServerBasedLocks.js.map +1 -1
- package/lib/cjs/internal/Symbols.d.ts +2 -0
- package/lib/cjs/internal/Symbols.d.ts.map +1 -1
- package/lib/cjs/internal/Symbols.js +3 -1
- package/lib/cjs/internal/Symbols.js.map +1 -1
- package/lib/cjs/internal/cross-package.d.ts +1 -0
- package/lib/cjs/internal/cross-package.d.ts.map +1 -1
- package/lib/cjs/internal/cross-package.js +3 -1
- package/lib/cjs/internal/cross-package.js.map +1 -1
- package/lib/cjs/internal/workspace/SettingsImpl.js.map +1 -1
- package/lib/cjs/internal/workspace/SettingsSchemasImpl.js.map +1 -1
- package/lib/cjs/internal/workspace/WorkspaceImpl.js +9 -9
- package/lib/cjs/internal/workspace/WorkspaceImpl.js.map +1 -1
- package/lib/cjs/internal/workspace/WorkspaceSqliteDb.d.ts.map +1 -1
- package/lib/cjs/internal/workspace/WorkspaceSqliteDb.js +2 -1
- package/lib/cjs/internal/workspace/WorkspaceSqliteDb.js.map +1 -1
- package/lib/cjs/rpc/multipart.js.map +1 -1
- 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.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +5 -4
- 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 +3 -2
- 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.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 +13 -13
package/lib/cjs/IModelDb.js
CHANGED
|
@@ -111,15 +111,15 @@ class IModelDb extends core_common_1.IModel {
|
|
|
111
111
|
}
|
|
112
112
|
/** @internal */
|
|
113
113
|
notifyChangesetApplied() {
|
|
114
|
-
this.changeset = this.
|
|
114
|
+
this.changeset = this[Symbols_1._nativeDb].getCurrentChangeset();
|
|
115
115
|
this.onChangesetApplied.raiseEvent();
|
|
116
116
|
}
|
|
117
117
|
/** @internal */
|
|
118
118
|
restartDefaultTxn() {
|
|
119
|
-
this.
|
|
119
|
+
this[Symbols_1._nativeDb].restartDefaultTxn();
|
|
120
120
|
}
|
|
121
121
|
get fontMap() {
|
|
122
|
-
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()));
|
|
123
123
|
}
|
|
124
124
|
/** @internal */
|
|
125
125
|
clearFontMap() {
|
|
@@ -136,7 +136,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
136
136
|
addNewFont(name, type) {
|
|
137
137
|
this.locks.checkExclusiveLock(core_common_1.IModel.repositoryModelId, "schema", "addNewFont");
|
|
138
138
|
this.clearFontMap();
|
|
139
|
-
return this.
|
|
139
|
+
return this[Symbols_1._nativeDb].addNewFont({ name, type: type ?? core_common_1.FontType.TrueType });
|
|
140
140
|
}
|
|
141
141
|
/** Check if this iModel has been opened read-only or not. */
|
|
142
142
|
get isReadonly() { return this.openMode === core_bentley_1.OpenMode.Readonly; }
|
|
@@ -145,10 +145,14 @@ class IModelDb extends core_common_1.IModel {
|
|
|
145
145
|
(0, core_bentley_1.assert)(undefined !== super.iModelId);
|
|
146
146
|
return super.iModelId;
|
|
147
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]; }
|
|
148
152
|
/** Get the full path fileName of this iModelDb
|
|
149
153
|
* @note this member is only valid while the iModel is opened.
|
|
150
154
|
*/
|
|
151
|
-
get pathName() { return this.
|
|
155
|
+
get pathName() { return this[Symbols_1._nativeDb].getFilePath(); }
|
|
152
156
|
/** Get the full path to this iModel's "watch file".
|
|
153
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.
|
|
154
158
|
* A writable briefcase "touches" this file if it exists whenever it commits changes to the briefcase.
|
|
@@ -176,19 +180,19 @@ class IModelDb extends core_common_1.IModel {
|
|
|
176
180
|
this.onChangesetApplied = new core_bentley_1.BeEvent();
|
|
177
181
|
/** Event called when the iModel is about to be closed. */
|
|
178
182
|
this.onBeforeClose = new core_bentley_1.BeEvent();
|
|
179
|
-
this.
|
|
183
|
+
this[Symbols_1._nativeDb] = args.nativeDb;
|
|
180
184
|
// it is illegal to create an IModelDb unless the nativeDb has been opened. Throw otherwise.
|
|
181
185
|
if (!this.isOpen)
|
|
182
186
|
throw new Error("cannot create an IModelDb unless it has already been opened");
|
|
183
187
|
// PR https://github.com/iTwin/imodel-native/pull/558 renamed closeIModel to closeFile because it changed its behavior.
|
|
184
188
|
// Ideally, nobody outside of core-backend would be calling it, but somebody important is.
|
|
185
189
|
// Make closeIModel available so their code doesn't break.
|
|
186
|
-
this.
|
|
190
|
+
this[Symbols_1._nativeDb].closeIModel = () => {
|
|
187
191
|
if (!this.isReadonly)
|
|
188
192
|
this.saveChanges(); // preserve old behavior of closeIModel that was removed when renamed to closeFile
|
|
189
|
-
this.
|
|
193
|
+
this[Symbols_1._nativeDb].closeFile();
|
|
190
194
|
};
|
|
191
|
-
this.
|
|
195
|
+
this[Symbols_1._nativeDb].setIModelDb(this);
|
|
192
196
|
this.loadIModelSettings();
|
|
193
197
|
GeoCoordConfig_1.GeoCoordConfig.loadForImodel(this.workspace.settings); // load gcs data specified by iModel's settings dictionaries, must be done before calling initializeIModelDb
|
|
194
198
|
this.initializeIModelDb();
|
|
@@ -218,7 +222,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
218
222
|
this._codeService = undefined;
|
|
219
223
|
if (!this.isReadonly)
|
|
220
224
|
this.saveChanges();
|
|
221
|
-
this.
|
|
225
|
+
this[Symbols_1._nativeDb].closeFile();
|
|
222
226
|
}
|
|
223
227
|
/** @internal */
|
|
224
228
|
async refreshContainerForRpc(_userAccessToken) { }
|
|
@@ -232,7 +236,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
232
236
|
}
|
|
233
237
|
/** @internal */
|
|
234
238
|
initializeIModelDb() {
|
|
235
|
-
const props = this.
|
|
239
|
+
const props = this[Symbols_1._nativeDb].getIModelProps();
|
|
236
240
|
super.initialize(props.rootSubject.name, props);
|
|
237
241
|
if (this._initialized)
|
|
238
242
|
return;
|
|
@@ -269,9 +273,9 @@ class IModelDb extends core_common_1.IModel {
|
|
|
269
273
|
/** Return `true` if the underlying nativeDb is open and valid.
|
|
270
274
|
* @internal
|
|
271
275
|
*/
|
|
272
|
-
get isOpen() { return this.
|
|
276
|
+
get isOpen() { return this[Symbols_1._nativeDb].isOpen(); }
|
|
273
277
|
/** Get the briefcase Id of this iModel */
|
|
274
|
-
getBriefcaseId() { return this.isOpen ? this.
|
|
278
|
+
getBriefcaseId() { return this.isOpen ? this[Symbols_1._nativeDb].getBriefcaseId() : core_common_1.BriefcaseIdValue.Illegal; }
|
|
275
279
|
/**
|
|
276
280
|
* Use a prepared ECSQL statement, potentially from the statement cache. If the requested statement doesn't exist
|
|
277
281
|
* in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved
|
|
@@ -345,11 +349,11 @@ class IModelDb extends core_common_1.IModel {
|
|
|
345
349
|
* @public
|
|
346
350
|
* */
|
|
347
351
|
createQueryReader(ecsql, params, config) {
|
|
348
|
-
if (!this.
|
|
352
|
+
if (!this[Symbols_1._nativeDb].isOpen())
|
|
349
353
|
throw new core_common_1.IModelError(core_bentley_1.DbResult.BE_SQLITE_ERROR, "db not open");
|
|
350
354
|
const executor = {
|
|
351
355
|
execute: async (request) => {
|
|
352
|
-
return ConcurrentQuery_1.ConcurrentQuery.executeQueryRequest(this.
|
|
356
|
+
return ConcurrentQuery_1.ConcurrentQuery.executeQueryRequest(this[Symbols_1._nativeDb], request);
|
|
353
357
|
},
|
|
354
358
|
};
|
|
355
359
|
return new core_common_1.ECSqlReader(executor, ecsql, params, config);
|
|
@@ -484,7 +488,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
484
488
|
*/
|
|
485
489
|
prepareSqliteStatement(sql, logErrors = true) {
|
|
486
490
|
const stmt = new SqliteStatement_1.SqliteStatement(sql);
|
|
487
|
-
stmt.prepare(this.
|
|
491
|
+
stmt.prepare(this[Symbols_1._nativeDb], logErrors);
|
|
488
492
|
return stmt;
|
|
489
493
|
}
|
|
490
494
|
/**
|
|
@@ -597,7 +601,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
597
601
|
computeProjectExtents(options) {
|
|
598
602
|
const wantFullExtents = true === options?.reportExtentsWithOutliers;
|
|
599
603
|
const wantOutliers = true === options?.reportOutliers;
|
|
600
|
-
const result = this.
|
|
604
|
+
const result = this[Symbols_1._nativeDb].computeProjectExtents(wantFullExtents, wantOutliers);
|
|
601
605
|
return {
|
|
602
606
|
extents: core_geometry_1.Range3d.fromJSON(result.extents),
|
|
603
607
|
extentsWithOutliers: result.fullExtents ? core_geometry_1.Range3d.fromJSON(result.fullExtents) : undefined,
|
|
@@ -611,7 +615,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
611
615
|
}
|
|
612
616
|
/** Update the IModelProps of this iModel in the database. */
|
|
613
617
|
updateIModelProps() {
|
|
614
|
-
this.
|
|
618
|
+
this[Symbols_1._nativeDb].updateIModelProps(this.toJSON());
|
|
615
619
|
}
|
|
616
620
|
/** Commit pending changes to this iModel.
|
|
617
621
|
* @param description Optional description of the changes
|
|
@@ -620,13 +624,13 @@ class IModelDb extends core_common_1.IModel {
|
|
|
620
624
|
saveChanges(description) {
|
|
621
625
|
if (this.openMode === core_bentley_1.OpenMode.Readonly)
|
|
622
626
|
throw new core_common_1.IModelError(core_bentley_1.IModelStatus.ReadOnly, "IModelDb was opened read-only");
|
|
623
|
-
const stat = this.
|
|
627
|
+
const stat = this[Symbols_1._nativeDb].saveChanges(description);
|
|
624
628
|
if (core_bentley_1.DbResult.BE_SQLITE_OK !== stat)
|
|
625
629
|
throw new core_common_1.IModelError(stat, `Could not save changes (${description})`);
|
|
626
630
|
}
|
|
627
631
|
/** Abandon pending changes in this iModel. */
|
|
628
632
|
abandonChanges() {
|
|
629
|
-
this.
|
|
633
|
+
this[Symbols_1._nativeDb].abandonChanges();
|
|
630
634
|
}
|
|
631
635
|
/**
|
|
632
636
|
* Save all changes and perform a [checkpoint](https://www.sqlite.org/c3ref/wal_checkpoint_v2.html) on this IModelDb.
|
|
@@ -639,22 +643,22 @@ class IModelDb extends core_common_1.IModel {
|
|
|
639
643
|
performCheckpoint() {
|
|
640
644
|
if (!this.isReadonly) {
|
|
641
645
|
this.saveChanges();
|
|
642
|
-
this.
|
|
646
|
+
this[Symbols_1._nativeDb].performCheckpoint();
|
|
643
647
|
}
|
|
644
648
|
}
|
|
645
649
|
/** @internal
|
|
646
650
|
* @deprecated in 4.8. Use `txns.reverseTxns`.
|
|
647
651
|
*/
|
|
648
652
|
reverseTxns(numOperations) {
|
|
649
|
-
return this.
|
|
653
|
+
return this[Symbols_1._nativeDb].reverseTxns(numOperations);
|
|
650
654
|
}
|
|
651
655
|
/** @internal */
|
|
652
656
|
reinstateTxn() {
|
|
653
|
-
return this.
|
|
657
|
+
return this[Symbols_1._nativeDb].reinstateTxn();
|
|
654
658
|
}
|
|
655
659
|
/** @internal */
|
|
656
660
|
restartTxnSession() {
|
|
657
|
-
return this.
|
|
661
|
+
return this[Symbols_1._nativeDb].restartTxnSession();
|
|
658
662
|
}
|
|
659
663
|
/** Import an ECSchema. On success, the schema definition is stored in the iModel.
|
|
660
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.
|
|
@@ -670,20 +674,20 @@ class IModelDb extends core_common_1.IModel {
|
|
|
670
674
|
if (schemaFileNames.length === 0)
|
|
671
675
|
return;
|
|
672
676
|
const maybeCustomNativeContext = options?.ecSchemaXmlContext?.nativeContext;
|
|
673
|
-
if (this.
|
|
677
|
+
if (this[Symbols_1._nativeDb].schemaSyncEnabled()) {
|
|
674
678
|
await SchemaSync_1.SchemaSync.withLockedAccess(this, { openMode: core_bentley_1.OpenMode.Readonly, operationName: "schema sync" }, async (syncAccess) => {
|
|
675
679
|
const schemaSyncDbUri = syncAccess.getUri();
|
|
676
680
|
this.saveChanges();
|
|
677
681
|
try {
|
|
678
|
-
this.
|
|
682
|
+
this[Symbols_1._nativeDb].importSchemas(schemaFileNames, { schemaLockHeld: false, ecSchemaXmlContext: maybeCustomNativeContext, schemaSyncDbUri });
|
|
679
683
|
}
|
|
680
684
|
catch (outerErr) {
|
|
681
685
|
if (core_bentley_1.DbResult.BE_SQLITE_ERROR_DataTransformRequired === outerErr.errorNumber) {
|
|
682
686
|
this.abandonChanges();
|
|
683
|
-
if (this.
|
|
687
|
+
if (this[Symbols_1._nativeDb].getITwinId() !== core_bentley_1.Guid.empty)
|
|
684
688
|
await this.acquireSchemaLock();
|
|
685
689
|
try {
|
|
686
|
-
this.
|
|
690
|
+
this[Symbols_1._nativeDb].importSchemas(schemaFileNames, { schemaLockHeld: true, ecSchemaXmlContext: maybeCustomNativeContext, schemaSyncDbUri });
|
|
687
691
|
}
|
|
688
692
|
catch (innerErr) {
|
|
689
693
|
throw new core_common_1.IModelError(innerErr.errorNumber, innerErr.message);
|
|
@@ -700,10 +704,10 @@ class IModelDb extends core_common_1.IModel {
|
|
|
700
704
|
schemaLockHeld: true,
|
|
701
705
|
ecSchemaXmlContext: maybeCustomNativeContext,
|
|
702
706
|
};
|
|
703
|
-
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
|
|
704
708
|
await this.acquireSchemaLock();
|
|
705
709
|
try {
|
|
706
|
-
this.
|
|
710
|
+
this[Symbols_1._nativeDb].importSchemas(schemaFileNames, nativeImportOptions);
|
|
707
711
|
}
|
|
708
712
|
catch (err) {
|
|
709
713
|
throw new core_common_1.IModelError(err.errorNumber, err.message);
|
|
@@ -723,20 +727,20 @@ class IModelDb extends core_common_1.IModel {
|
|
|
723
727
|
async importSchemaStrings(serializedXmlSchemas) {
|
|
724
728
|
if (serializedXmlSchemas.length === 0)
|
|
725
729
|
return;
|
|
726
|
-
if (this.
|
|
730
|
+
if (this[Symbols_1._nativeDb].schemaSyncEnabled()) {
|
|
727
731
|
await SchemaSync_1.SchemaSync.withLockedAccess(this, { openMode: core_bentley_1.OpenMode.Readonly, operationName: "schemaSync" }, async (syncAccess) => {
|
|
728
732
|
const schemaSyncDbUri = syncAccess.getUri();
|
|
729
733
|
this.saveChanges();
|
|
730
734
|
try {
|
|
731
|
-
this.
|
|
735
|
+
this[Symbols_1._nativeDb].importXmlSchemas(serializedXmlSchemas, { schemaLockHeld: false, schemaSyncDbUri });
|
|
732
736
|
}
|
|
733
737
|
catch (outerErr) {
|
|
734
738
|
if (core_bentley_1.DbResult.BE_SQLITE_ERROR_DataTransformRequired === outerErr.errorNumber) {
|
|
735
739
|
this.abandonChanges();
|
|
736
|
-
if (this.
|
|
740
|
+
if (this[Symbols_1._nativeDb].getITwinId() !== core_bentley_1.Guid.empty)
|
|
737
741
|
await this.acquireSchemaLock();
|
|
738
742
|
try {
|
|
739
|
-
this.
|
|
743
|
+
this[Symbols_1._nativeDb].importXmlSchemas(serializedXmlSchemas, { schemaLockHeld: true, schemaSyncDbUri });
|
|
740
744
|
}
|
|
741
745
|
catch (innerErr) {
|
|
742
746
|
throw new core_common_1.IModelError(innerErr.errorNumber, innerErr.message);
|
|
@@ -752,7 +756,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
752
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
|
|
753
757
|
await this.acquireSchemaLock();
|
|
754
758
|
try {
|
|
755
|
-
this.
|
|
759
|
+
this[Symbols_1._nativeDb].importXmlSchemas(serializedXmlSchemas, { schemaLockHeld: true });
|
|
756
760
|
}
|
|
757
761
|
catch (err) {
|
|
758
762
|
throw new core_common_1.IModelError(err.errorNumber, err.message);
|
|
@@ -887,7 +891,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
887
891
|
*/
|
|
888
892
|
prepareStatement(sql, logErrors = true) {
|
|
889
893
|
const stmt = new ECSqlStatement_1.ECSqlStatement();
|
|
890
|
-
stmt.prepare(this.
|
|
894
|
+
stmt.prepare(this[Symbols_1._nativeDb], sql, logErrors);
|
|
891
895
|
return stmt;
|
|
892
896
|
}
|
|
893
897
|
/** Prepare an ECSQL statement.
|
|
@@ -896,7 +900,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
896
900
|
*/
|
|
897
901
|
tryPrepareStatement(sql) {
|
|
898
902
|
const statement = new ECSqlStatement_1.ECSqlStatement();
|
|
899
|
-
const result = statement.tryPrepare(this.
|
|
903
|
+
const result = statement.tryPrepare(this[Symbols_1._nativeDb], sql);
|
|
900
904
|
return core_bentley_1.DbResult.BE_SQLITE_OK === result.status ? statement : undefined;
|
|
901
905
|
}
|
|
902
906
|
/** Construct an entity (Element or Model) from an iModel.
|
|
@@ -976,7 +980,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
976
980
|
const className = classFullName.split(":");
|
|
977
981
|
if (className.length !== 2)
|
|
978
982
|
throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadArg, `Invalid classFullName: ${classFullName}`);
|
|
979
|
-
const val = this.
|
|
983
|
+
const val = this[Symbols_1._nativeDb].getECClassMetaData(className[0], className[1]);
|
|
980
984
|
if (val.error)
|
|
981
985
|
throw new core_common_1.IModelError(val.error.status, `Error getting class meta data for: ${classFullName}`);
|
|
982
986
|
(0, core_bentley_1.assert)(undefined !== val.result);
|
|
@@ -992,7 +996,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
992
996
|
* @throws if the schema can not be found or loaded.
|
|
993
997
|
*/
|
|
994
998
|
getSchemaProps(name) {
|
|
995
|
-
return this.
|
|
999
|
+
return this[Symbols_1._nativeDb].getSchemaProps(name);
|
|
996
1000
|
}
|
|
997
1001
|
/** Query if this iModel contains the definition of the specified class.
|
|
998
1002
|
* @param classFullName The full name of the class, for example, SomeSchema:SomeClass
|
|
@@ -1002,7 +1006,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
1002
1006
|
*/
|
|
1003
1007
|
containsClass(classFullName) {
|
|
1004
1008
|
const classNameParts = classFullName.replace(".", ":").split(":");
|
|
1005
|
-
return classNameParts.length === 2 && this.
|
|
1009
|
+
return classNameParts.length === 2 && this[Symbols_1._nativeDb].getECClassMetaData(classNameParts[0], classNameParts[1]).error === undefined;
|
|
1006
1010
|
}
|
|
1007
1011
|
/** Query for a schema of the specified name in this iModel.
|
|
1008
1012
|
* @returns The schema version as a semver-compatible string or `undefined` if the schema has not been imported.
|
|
@@ -1026,38 +1030,38 @@ class IModelDb extends core_common_1.IModel {
|
|
|
1026
1030
|
* @alpha
|
|
1027
1031
|
*/
|
|
1028
1032
|
async queryTextureData(props) {
|
|
1029
|
-
return this.
|
|
1033
|
+
return this[Symbols_1._nativeDb].queryTextureData(props);
|
|
1030
1034
|
}
|
|
1031
1035
|
/** Query a "file property" from this iModel, as a string.
|
|
1032
1036
|
* @returns the property string or undefined if the property is not present.
|
|
1033
1037
|
*/
|
|
1034
1038
|
queryFilePropertyString(prop) {
|
|
1035
|
-
return this.
|
|
1039
|
+
return this[Symbols_1._nativeDb].queryFileProperty(prop, true);
|
|
1036
1040
|
}
|
|
1037
1041
|
/** Query a "file property" from this iModel, as a blob.
|
|
1038
1042
|
* @returns the property blob or undefined if the property is not present.
|
|
1039
1043
|
*/
|
|
1040
1044
|
queryFilePropertyBlob(prop) {
|
|
1041
|
-
return this.
|
|
1045
|
+
return this[Symbols_1._nativeDb].queryFileProperty(prop, false);
|
|
1042
1046
|
}
|
|
1043
1047
|
/** Save a "file property" to this iModel
|
|
1044
1048
|
* @param prop the FilePropertyProps that describes the new property
|
|
1045
1049
|
* @param value either a string or a blob to save as the file property
|
|
1046
1050
|
*/
|
|
1047
1051
|
saveFileProperty(prop, strValue, blobVal) {
|
|
1048
|
-
this.
|
|
1052
|
+
this[Symbols_1._nativeDb].saveFileProperty(prop, strValue, blobVal);
|
|
1049
1053
|
}
|
|
1050
1054
|
/** delete a "file property" from this iModel
|
|
1051
1055
|
* @param prop the FilePropertyProps that describes the property
|
|
1052
1056
|
*/
|
|
1053
1057
|
deleteFileProperty(prop) {
|
|
1054
|
-
this.
|
|
1058
|
+
this[Symbols_1._nativeDb].saveFileProperty(prop, undefined, undefined);
|
|
1055
1059
|
}
|
|
1056
1060
|
/** Query for the next available major id for a "file property" from this iModel.
|
|
1057
1061
|
* @param prop the FilePropertyProps that describes the property
|
|
1058
1062
|
* @returns the next available (that is, an unused) id for prop. If none are present, will return 0.
|
|
1059
1063
|
*/
|
|
1060
|
-
queryNextAvailableFileProperty(prop) { return this.
|
|
1064
|
+
queryNextAvailableFileProperty(prop) { return this[Symbols_1._nativeDb].queryNextAvailableFileProperty(prop); }
|
|
1061
1065
|
/** @internal */
|
|
1062
1066
|
async requestSnap(sessionId, props) {
|
|
1063
1067
|
let request = this._snaps.get(sessionId);
|
|
@@ -1068,7 +1072,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
1068
1072
|
else
|
|
1069
1073
|
request.cancelSnap();
|
|
1070
1074
|
try {
|
|
1071
|
-
return await request.doSnap(this.
|
|
1075
|
+
return await request.doSnap(this[Symbols_1._nativeDb], core_bentley_1.JsonUtils.toObject(props));
|
|
1072
1076
|
}
|
|
1073
1077
|
finally {
|
|
1074
1078
|
this._snaps.delete(sessionId);
|
|
@@ -1086,19 +1090,19 @@ class IModelDb extends core_common_1.IModel {
|
|
|
1086
1090
|
}
|
|
1087
1091
|
/** Get the clip containment status for the supplied elements. */
|
|
1088
1092
|
async getGeometryContainment(props) {
|
|
1089
|
-
return this.
|
|
1093
|
+
return this[Symbols_1._nativeDb].getGeometryContainment(core_bentley_1.JsonUtils.toObject(props));
|
|
1090
1094
|
}
|
|
1091
1095
|
/** Get the mass properties for the supplied elements. */
|
|
1092
1096
|
async getMassProperties(props) {
|
|
1093
|
-
return this.
|
|
1097
|
+
return this[Symbols_1._nativeDb].getMassProperties(core_bentley_1.JsonUtils.toObject(props));
|
|
1094
1098
|
}
|
|
1095
1099
|
/** Get the IModel coordinate corresponding to each GeoCoordinate point in the input */
|
|
1096
1100
|
async getIModelCoordinatesFromGeoCoordinates(props) {
|
|
1097
|
-
return this.
|
|
1101
|
+
return this[Symbols_1._nativeDb].getIModelCoordinatesFromGeoCoordinates(props);
|
|
1098
1102
|
}
|
|
1099
1103
|
/** Get the GeoCoordinate (longitude, latitude, elevation) corresponding to each IModel Coordinate point in the input */
|
|
1100
1104
|
async getGeoCoordinatesFromIModelCoordinates(props) {
|
|
1101
|
-
return this.
|
|
1105
|
+
return this[Symbols_1._nativeDb].getGeoCoordinatesFromIModelCoordinates(props);
|
|
1102
1106
|
}
|
|
1103
1107
|
/** Export meshes suitable for graphics APIs from arbitrary geometry in elements in this IModelDb.
|
|
1104
1108
|
* * Requests can be slow when processing many elements so it is expected that this function be used on a dedicated backend,
|
|
@@ -1133,7 +1137,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
1133
1137
|
* @public
|
|
1134
1138
|
*/
|
|
1135
1139
|
exportGraphics(exportProps) {
|
|
1136
|
-
return this.
|
|
1140
|
+
return this[Symbols_1._nativeDb].exportGraphics(exportProps);
|
|
1137
1141
|
}
|
|
1138
1142
|
/**
|
|
1139
1143
|
* Exports meshes suitable for graphics APIs from a specified [GeometryPart]($core-backend)
|
|
@@ -1148,14 +1152,14 @@ class IModelDb extends core_common_1.IModel {
|
|
|
1148
1152
|
* @public
|
|
1149
1153
|
*/
|
|
1150
1154
|
exportPartGraphics(exportProps) {
|
|
1151
|
-
return this.
|
|
1155
|
+
return this[Symbols_1._nativeDb].exportPartGraphics(exportProps);
|
|
1152
1156
|
}
|
|
1153
1157
|
/** Request geometry stream information from an element in binary format instead of json.
|
|
1154
1158
|
* @returns IModelStatus.Success if successful
|
|
1155
1159
|
* @beta
|
|
1156
1160
|
*/
|
|
1157
1161
|
elementGeometryRequest(requestProps) {
|
|
1158
|
-
return this.
|
|
1162
|
+
return this[Symbols_1._nativeDb].processGeometryStream(requestProps);
|
|
1159
1163
|
}
|
|
1160
1164
|
/** Create brep geometry for inclusion in an element's geometry stream.
|
|
1161
1165
|
* @returns IModelStatus.Success if successful
|
|
@@ -1163,7 +1167,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
1163
1167
|
* @alpha
|
|
1164
1168
|
*/
|
|
1165
1169
|
createBRepGeometry(createProps) {
|
|
1166
|
-
return this.
|
|
1170
|
+
return this[Symbols_1._nativeDb].createBRepGeometry(createProps);
|
|
1167
1171
|
}
|
|
1168
1172
|
/** Generate graphics for an element or geometry stream.
|
|
1169
1173
|
* @see [readElementGraphics]($frontend) to convert the result to a [RenderGraphic]($frontend) for display.
|
|
@@ -1200,7 +1204,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
1200
1204
|
}
|
|
1201
1205
|
/** Load all setting dictionaries in this iModel into `this.workspace.settings` */
|
|
1202
1206
|
loadIModelSettings() {
|
|
1203
|
-
if (!this.
|
|
1207
|
+
if (!this[Symbols_1._nativeDb].isOpen())
|
|
1204
1208
|
return;
|
|
1205
1209
|
this.withSqliteStatement("SELECT Name,StrData FROM be_Prop WHERE Namespace=?", (stmt) => {
|
|
1206
1210
|
stmt.bindString(1, IModelDb._settingPropNamespace);
|
|
@@ -1250,14 +1254,14 @@ class IModelDb extends core_common_1.IModel {
|
|
|
1250
1254
|
* @public
|
|
1251
1255
|
*/
|
|
1252
1256
|
get codeValueBehavior() {
|
|
1253
|
-
return this.
|
|
1257
|
+
return this[Symbols_1._nativeDb].getCodeValueBehavior();
|
|
1254
1258
|
}
|
|
1255
1259
|
set codeValueBehavior(newBehavior) {
|
|
1256
|
-
this.
|
|
1260
|
+
this[Symbols_1._nativeDb].setCodeValueBehavior(newBehavior);
|
|
1257
1261
|
}
|
|
1258
1262
|
/** @internal */
|
|
1259
1263
|
computeRangesForText(args) {
|
|
1260
|
-
const props = this.
|
|
1264
|
+
const props = this[Symbols_1._nativeDb].computeRangesForText(args.chars, args.fontId, args.bold, args.italic, args.widthFactor, args.lineHeight);
|
|
1261
1265
|
return {
|
|
1262
1266
|
layout: core_geometry_1.Range2d.fromJSON(props.layout),
|
|
1263
1267
|
justification: core_geometry_1.Range2d.fromJSON(props.justification),
|
|
@@ -1363,7 +1367,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1363
1367
|
*/
|
|
1364
1368
|
tryGetModelJson(modelIdArg) {
|
|
1365
1369
|
try {
|
|
1366
|
-
return this._iModel.
|
|
1370
|
+
return this._iModel[Symbols_1._nativeDb].getModel(modelIdArg);
|
|
1367
1371
|
}
|
|
1368
1372
|
catch (err) {
|
|
1369
1373
|
return undefined;
|
|
@@ -1408,7 +1412,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1408
1412
|
*/
|
|
1409
1413
|
insertModel(props) {
|
|
1410
1414
|
try {
|
|
1411
|
-
return props.id = this._iModel.
|
|
1415
|
+
return props.id = this._iModel[Symbols_1._nativeDb].insertModel(props);
|
|
1412
1416
|
}
|
|
1413
1417
|
catch (err) {
|
|
1414
1418
|
throw new core_common_1.IModelError(err.errorNumber, `Error inserting model [${err.message}], class=${props.classFullName}`);
|
|
@@ -1420,7 +1424,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1420
1424
|
*/
|
|
1421
1425
|
updateModel(props) {
|
|
1422
1426
|
try {
|
|
1423
|
-
this._iModel.
|
|
1427
|
+
this._iModel[Symbols_1._nativeDb].updateModel(props);
|
|
1424
1428
|
}
|
|
1425
1429
|
catch (err) {
|
|
1426
1430
|
throw new core_common_1.IModelError(err.errorNumber, `error updating model [${err.message}] id=${props.id}`);
|
|
@@ -1436,7 +1440,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1436
1440
|
* @see [[TxnManager.onModelGeometryChanged]] for the event emitted in response to such a change.
|
|
1437
1441
|
*/
|
|
1438
1442
|
updateGeometryGuid(modelId) {
|
|
1439
|
-
const error = this._iModel.
|
|
1443
|
+
const error = this._iModel[Symbols_1._nativeDb].updateModelGeometryGuid(modelId);
|
|
1440
1444
|
if (error !== core_bentley_1.IModelStatus.Success)
|
|
1441
1445
|
throw new core_common_1.IModelError(error, `updating geometry guid for model ${modelId}`);
|
|
1442
1446
|
}
|
|
@@ -1447,7 +1451,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1447
1451
|
deleteModel(ids) {
|
|
1448
1452
|
core_bentley_1.Id64.toIdSet(ids).forEach((id) => {
|
|
1449
1453
|
try {
|
|
1450
|
-
this._iModel.
|
|
1454
|
+
this._iModel[Symbols_1._nativeDb].deleteModel(id);
|
|
1451
1455
|
}
|
|
1452
1456
|
catch (err) {
|
|
1453
1457
|
throw new core_common_1.IModelError(err.errorNumber, `error deleting model [${err.message}] id ${id}`);
|
|
@@ -1465,7 +1469,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1465
1469
|
ids = typeof ids === "string" ? [ids] : ids;
|
|
1466
1470
|
if (ids.length === 0)
|
|
1467
1471
|
return [];
|
|
1468
|
-
return this._iModel.
|
|
1472
|
+
return this._iModel[Symbols_1._nativeDb].queryModelExtentsAsync(ids);
|
|
1469
1473
|
}
|
|
1470
1474
|
/** Computes the union of the volumes of all geometric elements within one or more [[GeometricModel]]s, specified by model Id.
|
|
1471
1475
|
* @see [[queryExtents]] to obtain discrete volumes for each model.
|
|
@@ -1520,7 +1524,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1520
1524
|
*/
|
|
1521
1525
|
tryGetElementJson(loadProps) {
|
|
1522
1526
|
try {
|
|
1523
|
-
return this._iModel.
|
|
1527
|
+
return this._iModel[Symbols_1._nativeDb].getElement(loadProps);
|
|
1524
1528
|
}
|
|
1525
1529
|
catch (err) {
|
|
1526
1530
|
return undefined;
|
|
@@ -1538,7 +1542,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1538
1542
|
props = { code: props };
|
|
1539
1543
|
}
|
|
1540
1544
|
try {
|
|
1541
|
-
return this._iModel.
|
|
1545
|
+
return this._iModel[Symbols_1._nativeDb].getElement(props);
|
|
1542
1546
|
}
|
|
1543
1547
|
catch (err) {
|
|
1544
1548
|
throw new core_common_1.IModelError(err.errorNumber, err.message);
|
|
@@ -1652,7 +1656,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1652
1656
|
*/
|
|
1653
1657
|
insertElement(elProps) {
|
|
1654
1658
|
try {
|
|
1655
|
-
return elProps.id = this._iModel.
|
|
1659
|
+
return elProps.id = this._iModel[Symbols_1._nativeDb].insertElement(elProps);
|
|
1656
1660
|
}
|
|
1657
1661
|
catch (err) {
|
|
1658
1662
|
err.message = `Error inserting element [${err.message}]`;
|
|
@@ -1673,7 +1677,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1673
1677
|
*/
|
|
1674
1678
|
updateElement(elProps) {
|
|
1675
1679
|
try {
|
|
1676
|
-
this._iModel.
|
|
1680
|
+
this._iModel[Symbols_1._nativeDb].updateElement(elProps);
|
|
1677
1681
|
}
|
|
1678
1682
|
catch (err) {
|
|
1679
1683
|
err.message = `Error updating element [${err.message}], id: ${elProps.id}`;
|
|
@@ -1690,7 +1694,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1690
1694
|
const iModel = this._iModel;
|
|
1691
1695
|
core_bentley_1.Id64.toIdSet(ids).forEach((id) => {
|
|
1692
1696
|
try {
|
|
1693
|
-
iModel.
|
|
1697
|
+
iModel[Symbols_1._nativeDb].deleteElement(id);
|
|
1694
1698
|
}
|
|
1695
1699
|
catch (err) {
|
|
1696
1700
|
err.message = `Error deleting element [${err.message}], id: ${id}`;
|
|
@@ -1710,7 +1714,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1710
1714
|
* @beta
|
|
1711
1715
|
*/
|
|
1712
1716
|
deleteDefinitionElements(definitionElementIds) {
|
|
1713
|
-
const usageInfo = this._iModel.
|
|
1717
|
+
const usageInfo = this._iModel[Symbols_1._nativeDb].queryDefinitionElementUsage(definitionElementIds);
|
|
1714
1718
|
if (!usageInfo) {
|
|
1715
1719
|
throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadRequest, "Error querying for DefinitionElement usage");
|
|
1716
1720
|
}
|
|
@@ -1724,7 +1728,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1724
1728
|
}
|
|
1725
1729
|
};
|
|
1726
1730
|
try {
|
|
1727
|
-
this._iModel.
|
|
1731
|
+
this._iModel[Symbols_1._nativeDb].beginPurgeOperation();
|
|
1728
1732
|
deleteIfUnused(usageInfo.spatialCategoryIds, usedIdSet);
|
|
1729
1733
|
deleteIfUnused(usageInfo.drawingCategoryIds, usedIdSet);
|
|
1730
1734
|
deleteIfUnused(usageInfo.viewDefinitionIds, usedIdSet);
|
|
@@ -1741,7 +1745,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1741
1745
|
}
|
|
1742
1746
|
}
|
|
1743
1747
|
finally {
|
|
1744
|
-
this._iModel.
|
|
1748
|
+
this._iModel[Symbols_1._nativeDb].endPurgeOperation();
|
|
1745
1749
|
}
|
|
1746
1750
|
if (usageInfo.viewDefinitionIds) {
|
|
1747
1751
|
// take another pass in case a deleted ViewDefinition was the only usage of these view-related DefinitionElements
|
|
@@ -1753,17 +1757,17 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1753
1757
|
if (usageInfo.modelSelectorIds)
|
|
1754
1758
|
viewRelatedIds = viewRelatedIds.concat(usageInfo.modelSelectorIds.filter((id) => usedIdSet.has(id)));
|
|
1755
1759
|
if (viewRelatedIds.length > 0) {
|
|
1756
|
-
const viewRelatedUsageInfo = this._iModel.
|
|
1760
|
+
const viewRelatedUsageInfo = this._iModel[Symbols_1._nativeDb].queryDefinitionElementUsage(viewRelatedIds);
|
|
1757
1761
|
if (viewRelatedUsageInfo) {
|
|
1758
1762
|
const usedViewRelatedIdSet = viewRelatedUsageInfo.usedIds ? core_bentley_1.Id64.toIdSet(viewRelatedUsageInfo.usedIds) : new Set();
|
|
1759
1763
|
try {
|
|
1760
|
-
this._iModel.
|
|
1764
|
+
this._iModel[Symbols_1._nativeDb].beginPurgeOperation();
|
|
1761
1765
|
deleteIfUnused(viewRelatedUsageInfo.displayStyleIds, usedViewRelatedIdSet);
|
|
1762
1766
|
deleteIfUnused(viewRelatedUsageInfo.categorySelectorIds, usedViewRelatedIdSet);
|
|
1763
1767
|
deleteIfUnused(viewRelatedUsageInfo.modelSelectorIds, usedViewRelatedIdSet);
|
|
1764
1768
|
}
|
|
1765
1769
|
finally {
|
|
1766
|
-
this._iModel.
|
|
1770
|
+
this._iModel[Symbols_1._nativeDb].endPurgeOperation();
|
|
1767
1771
|
}
|
|
1768
1772
|
viewRelatedIds.forEach((id) => {
|
|
1769
1773
|
if (!usedViewRelatedIdSet.has(id))
|
|
@@ -1901,9 +1905,9 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1901
1905
|
*/
|
|
1902
1906
|
getAspects(elementId, aspectClassFullName, excludedClassFullNames) {
|
|
1903
1907
|
if (aspectClassFullName === undefined) {
|
|
1904
|
-
const allAspects = this.runInstanceQuery(`SELECT $ FROM (
|
|
1905
|
-
SELECT ECInstanceId, ECClassId FROM Bis.ElementMultiAspect WHERE Element.Id = :elementId
|
|
1906
|
-
UNION ALL
|
|
1908
|
+
const allAspects = this.runInstanceQuery(`SELECT $ FROM (
|
|
1909
|
+
SELECT ECInstanceId, ECClassId FROM Bis.ElementMultiAspect WHERE Element.Id = :elementId
|
|
1910
|
+
UNION ALL
|
|
1907
1911
|
SELECT ECInstanceId, ECClassId FROM Bis.ElementUniqueAspect WHERE Element.Id = :elementId) OPTIONS USE_JS_PROP_NAMES DO_NOT_TRUNCATE_BLOB`, elementId, excludedClassFullNames);
|
|
1908
1912
|
if (allAspects.length === 0)
|
|
1909
1913
|
core_bentley_1.Logger.logInfo(BackendLoggerCategory_1.BackendLoggerCategory.ECDb, `No aspects found for class ${aspectClassFullName} and element ${elementId}`);
|
|
@@ -1911,7 +1915,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1911
1915
|
}
|
|
1912
1916
|
// Check if class is abstract
|
|
1913
1917
|
const fullClassName = aspectClassFullName.replace(".", ":").split(":");
|
|
1914
|
-
const val = this._iModel.
|
|
1918
|
+
const val = this._iModel[Symbols_1._nativeDb].getECClassMetaData(fullClassName[0], fullClassName[1]);
|
|
1915
1919
|
if (val.result !== undefined) {
|
|
1916
1920
|
const metaData = new core_common_1.EntityMetaData(JSON.parse(val.result));
|
|
1917
1921
|
if (metaData.modifier !== "Abstract") // Class is not abstract, use normal query to retrieve aspects
|
|
@@ -1921,7 +1925,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1921
1925
|
let classIdList = IModelDb.Elements.classMap.get(aspectClassFullName);
|
|
1922
1926
|
if (classIdList === undefined) {
|
|
1923
1927
|
const classIds = [];
|
|
1924
|
-
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]}'
|
|
1925
1929
|
and Schema.Id = (select ECInstanceId from meta.ECSchemaDef where Name='${fullClassName[0]}')) and SourceECInstanceId != TargetECInstanceId`, (statement) => {
|
|
1926
1930
|
while (statement.step() === core_bentley_1.DbResult.BE_SQLITE_ROW)
|
|
1927
1931
|
classIds.push(statement.getValue(0).getId());
|
|
@@ -1936,10 +1940,10 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1936
1940
|
return [];
|
|
1937
1941
|
}
|
|
1938
1942
|
// Execute an instance query to retrieve all aspects from all the derived classes
|
|
1939
|
-
const aspects = this.runInstanceQuery(`SELECT $ FROM (
|
|
1940
|
-
SELECT ECInstanceId, ECClassId FROM Bis.ElementMultiAspect WHERE Element.Id = :elementId AND ECClassId IN (${classIdList})
|
|
1941
|
-
UNION ALL
|
|
1942
|
-
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})
|
|
1943
1947
|
) OPTIONS USE_JS_PROP_NAMES DO_NOT_TRUNCATE_BLOB`, elementId, excludedClassFullNames);
|
|
1944
1948
|
if (aspects.length === 0)
|
|
1945
1949
|
core_bentley_1.Logger.logInfo(BackendLoggerCategory_1.BackendLoggerCategory.ECDb, `No aspects found for class ${aspectClassFullName} and element ${elementId}`);
|
|
@@ -1954,7 +1958,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1954
1958
|
*/
|
|
1955
1959
|
insertAspect(aspectProps) {
|
|
1956
1960
|
try {
|
|
1957
|
-
return this._iModel.
|
|
1961
|
+
return this._iModel[Symbols_1._nativeDb].insertElementAspect(aspectProps);
|
|
1958
1962
|
}
|
|
1959
1963
|
catch (err) {
|
|
1960
1964
|
throw new core_common_1.IModelError(err.errorNumber, `Error inserting ElementAspect [${err.message}], class: ${aspectProps.classFullName}`);
|
|
@@ -1966,7 +1970,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1966
1970
|
*/
|
|
1967
1971
|
updateAspect(aspectProps) {
|
|
1968
1972
|
try {
|
|
1969
|
-
this._iModel.
|
|
1973
|
+
this._iModel[Symbols_1._nativeDb].updateElementAspect(aspectProps);
|
|
1970
1974
|
}
|
|
1971
1975
|
catch (err) {
|
|
1972
1976
|
throw new core_common_1.IModelError(err.errorNumber, `Error updating ElementAspect [${err.message}], id: ${aspectProps.id}`);
|
|
@@ -1980,7 +1984,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1980
1984
|
const iModel = this._iModel;
|
|
1981
1985
|
core_bentley_1.Id64.toIdSet(aspectInstanceIds).forEach((aspectInstanceId) => {
|
|
1982
1986
|
try {
|
|
1983
|
-
iModel.
|
|
1987
|
+
iModel[Symbols_1._nativeDb].deleteElementAspect(aspectInstanceId);
|
|
1984
1988
|
}
|
|
1985
1989
|
catch (err) {
|
|
1986
1990
|
throw new core_common_1.IModelError(err.errorNumber, `Error deleting ElementAspect [${err.message}], id: ${aspectInstanceId}`);
|
|
@@ -2125,7 +2129,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
2125
2129
|
const viewStateData = this.loadViewData(viewDefinitionId, options);
|
|
2126
2130
|
const baseModelId = viewStateData.viewDefinitionProps.baseModelId;
|
|
2127
2131
|
if (baseModelId) {
|
|
2128
|
-
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);
|
|
2129
2133
|
if (!drawingExtents.isNull)
|
|
2130
2134
|
viewStateData.modelExtents = drawingExtents.toJSON();
|
|
2131
2135
|
}
|
|
@@ -2153,11 +2157,11 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
2153
2157
|
*/
|
|
2154
2158
|
getThumbnail(viewDefinitionId) {
|
|
2155
2159
|
const viewArg = this.getViewThumbnailArg(viewDefinitionId);
|
|
2156
|
-
const sizeProps = this._iModel.
|
|
2160
|
+
const sizeProps = this._iModel[Symbols_1._nativeDb].queryFileProperty(viewArg, true);
|
|
2157
2161
|
if (undefined === sizeProps)
|
|
2158
2162
|
return undefined;
|
|
2159
2163
|
const out = JSON.parse(sizeProps);
|
|
2160
|
-
out.image = this._iModel.
|
|
2164
|
+
out.image = this._iModel[Symbols_1._nativeDb].queryFileProperty(viewArg, false);
|
|
2161
2165
|
return out;
|
|
2162
2166
|
}
|
|
2163
2167
|
/** Save a thumbnail for a view.
|
|
@@ -2168,7 +2172,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
2168
2172
|
saveThumbnail(viewDefinitionId, thumbnail) {
|
|
2169
2173
|
const viewArg = this.getViewThumbnailArg(viewDefinitionId);
|
|
2170
2174
|
const props = { format: thumbnail.format, height: thumbnail.height, width: thumbnail.width };
|
|
2171
|
-
this._iModel.
|
|
2175
|
+
this._iModel[Symbols_1._nativeDb].saveFileProperty(viewArg, JSON.stringify(props), thumbnail.image);
|
|
2172
2176
|
return 0;
|
|
2173
2177
|
}
|
|
2174
2178
|
/** Set the default view property the iModel.
|
|
@@ -2208,7 +2212,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
2208
2212
|
/** @internal */
|
|
2209
2213
|
async requestTileTreeProps(id) {
|
|
2210
2214
|
return new Promise((resolve, reject) => {
|
|
2211
|
-
this._iModel.
|
|
2215
|
+
this._iModel[Symbols_1._nativeDb].getTileTree(id, (ret) => {
|
|
2212
2216
|
if (undefined !== ret.error)
|
|
2213
2217
|
reject(new core_common_1.IModelError(ret.error.status, `TreeId=${id}`));
|
|
2214
2218
|
else
|
|
@@ -2219,7 +2223,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
2219
2223
|
pollTileContent(resolve, reject, treeId, tileId) {
|
|
2220
2224
|
let ret;
|
|
2221
2225
|
try {
|
|
2222
|
-
ret = this._iModel.
|
|
2226
|
+
ret = this._iModel[Symbols_1._nativeDb].pollTileContent(treeId, tileId);
|
|
2223
2227
|
}
|
|
2224
2228
|
catch (err) {
|
|
2225
2229
|
// Typically "imodel not open".
|
|
@@ -2258,7 +2262,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
2258
2262
|
/** @internal */
|
|
2259
2263
|
async getTileContent(treeId, tileId) {
|
|
2260
2264
|
const ret = await new Promise((resolve) => {
|
|
2261
|
-
this._iModel.
|
|
2265
|
+
this._iModel[Symbols_1._nativeDb].getTileContent(treeId, tileId, resolve);
|
|
2262
2266
|
});
|
|
2263
2267
|
if (undefined !== ret.error) {
|
|
2264
2268
|
throw new core_common_1.IModelError(ret.error.status, `TreeId=${treeId} TileId=${tileId}`);
|
|
@@ -2297,7 +2301,7 @@ class BriefcaseDb extends IModelDb {
|
|
|
2297
2301
|
* - the "no locking" flag is not present. This is a property of an iModel, established when the iModel is created in IModelHub.
|
|
2298
2302
|
*/
|
|
2299
2303
|
get useLockServer() {
|
|
2300
|
-
return !this.
|
|
2304
|
+
return !this[Symbols_1._nativeDb].isReadonly() && (this.briefcaseId !== core_common_1.BriefcaseIdValue.Unassigned) && (undefined === this[Symbols_1._nativeDb].queryLocalValue(BriefcaseLocalValue.NoLocking));
|
|
2301
2305
|
}
|
|
2302
2306
|
// if the iModel uses a lock server, create a ServerBasedLocks LockControl for this BriefcaseDb.
|
|
2303
2307
|
makeLockControl() {
|
|
@@ -2324,14 +2328,14 @@ class BriefcaseDb extends IModelDb {
|
|
|
2324
2328
|
};
|
|
2325
2329
|
const isSchemaSyncEnabled = await withBriefcaseDb(briefcase, async (db) => {
|
|
2326
2330
|
await SchemaSync_1.SchemaSync.pull(db);
|
|
2327
|
-
return db.
|
|
2331
|
+
return db[Symbols_1._nativeDb].schemaSyncEnabled();
|
|
2328
2332
|
});
|
|
2329
2333
|
if (isSchemaSyncEnabled) {
|
|
2330
2334
|
await SchemaSync_1.SchemaSync.withLockedAccess(briefcase, { openMode: core_bentley_1.OpenMode.Readonly, operationName: "schema sync" }, async (syncAccess) => {
|
|
2331
2335
|
const schemaSyncDbUri = syncAccess.getUri();
|
|
2332
2336
|
executeUpgrade();
|
|
2333
2337
|
await withBriefcaseDb(briefcase, async (db) => {
|
|
2334
|
-
db.
|
|
2338
|
+
db[Symbols_1._nativeDb].schemaSyncPush(schemaSyncDbUri);
|
|
2335
2339
|
db.saveChanges();
|
|
2336
2340
|
});
|
|
2337
2341
|
syncAccess.synchronizeWithCloud();
|
|
@@ -2414,7 +2418,7 @@ class BriefcaseDb extends IModelDb {
|
|
|
2414
2418
|
// Restart default txn to trigger events when watch file is changed by some other process.
|
|
2415
2419
|
const watcher = fs.watch(briefcaseDb.watchFilePathName, { persistent: false }, () => {
|
|
2416
2420
|
nativeDb.restartDefaultTxn();
|
|
2417
|
-
briefcaseDb.changeset = briefcaseDb.
|
|
2421
|
+
briefcaseDb.changeset = briefcaseDb[Symbols_1._nativeDb].getCurrentChangeset();
|
|
2418
2422
|
});
|
|
2419
2423
|
// Stop the watcher when we close this connection.
|
|
2420
2424
|
briefcaseDb.onBeforeClose.addOnce(() => {
|
|
@@ -2534,7 +2538,7 @@ class BriefcaseDb extends IModelDb {
|
|
|
2534
2538
|
const nConflicts = args.getForeignKeyConflicts();
|
|
2535
2539
|
// Note: There is no performance implication of follow code as it happen toward end of
|
|
2536
2540
|
// apply_changeset only once so we be querying value for 'DebugAllowFkViolations' only once.
|
|
2537
|
-
if (this.
|
|
2541
|
+
if (this[Symbols_1._nativeDb].queryLocalValue("DebugAllowFkViolations")) {
|
|
2538
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.`);
|
|
2539
2543
|
return core_bentley_1.DbConflictResolution.Skip;
|
|
2540
2544
|
}
|
|
@@ -2620,14 +2624,14 @@ class BriefcaseDb extends IModelDb {
|
|
|
2620
2624
|
// Unclosed statements will produce BUSY error when attempting to close.
|
|
2621
2625
|
this.clearCaches();
|
|
2622
2626
|
// The following resets the native db's pointer to this JavaScript object.
|
|
2623
|
-
this.
|
|
2624
|
-
this.
|
|
2627
|
+
this[Symbols_1._nativeDb].closeFile();
|
|
2628
|
+
this[Symbols_1._nativeDb].openIModel(fileName, openMode);
|
|
2625
2629
|
// Restore the native db's pointer to this JavaScript object.
|
|
2626
|
-
this.
|
|
2630
|
+
this[Symbols_1._nativeDb].setIModelDb(this);
|
|
2627
2631
|
// refresh cached properties that could have been changed by another process writing to the same briefcase
|
|
2628
|
-
this.changeset = this.
|
|
2632
|
+
this.changeset = this[Symbols_1._nativeDb].getCurrentChangeset();
|
|
2629
2633
|
// assert what should never change
|
|
2630
|
-
if (this.iModelId !== this.
|
|
2634
|
+
if (this.iModelId !== this[Symbols_1._nativeDb].getIModelId() || this.iTwinId !== this[Symbols_1._nativeDb].getITwinId())
|
|
2631
2635
|
throw new Error("closeAndReopen detected change in iModelId and/or iTwinId");
|
|
2632
2636
|
}
|
|
2633
2637
|
/** Pull and apply changesets from iModelHub */
|
|
@@ -2644,9 +2648,9 @@ class BriefcaseDb extends IModelDb {
|
|
|
2644
2648
|
async pushChanges(arg) {
|
|
2645
2649
|
if (this.briefcaseId === core_common_1.BriefcaseIdValue.Unassigned)
|
|
2646
2650
|
return;
|
|
2647
|
-
if (this.
|
|
2651
|
+
if (this[Symbols_1._nativeDb].hasUnsavedChanges())
|
|
2648
2652
|
throw new core_common_1.IModelError(core_bentley_1.ChangeSetStatus.HasUncommittedChanges, "Cannot push with unsaved changes");
|
|
2649
|
-
if (!this.
|
|
2653
|
+
if (!this[Symbols_1._nativeDb].hasPendingTxns())
|
|
2650
2654
|
return; // nothing to push
|
|
2651
2655
|
// pushing changes requires a writeable briefcase
|
|
2652
2656
|
await this.executeWritable(async () => {
|
|
@@ -2700,7 +2704,7 @@ class RefreshV2CheckpointSas {
|
|
|
2700
2704
|
core_bentley_1.Logger.logInfo(BackendLoggerCategory_1.BackendLoggerCategory.Authorization, "attempting to refresh sasToken for checkpoint");
|
|
2701
2705
|
try {
|
|
2702
2706
|
// this exchanges the supplied user accessToken for an expiring blob-store token to read the checkpoint.
|
|
2703
|
-
const container = iModel.
|
|
2707
|
+
const container = iModel[Symbols_1._nativeDb].cloudContainer;
|
|
2704
2708
|
if (!container)
|
|
2705
2709
|
throw new Error("checkpoint is not from a cloud container");
|
|
2706
2710
|
(0, core_bentley_1.assert)(undefined !== iModel.iTwinId);
|
|
@@ -2844,7 +2848,7 @@ class SnapshotDb extends IModelDb {
|
|
|
2844
2848
|
snapshot.restartDefaultTxn();
|
|
2845
2849
|
}, (10 * 60) * 1000).unref(); // 10 minutes
|
|
2846
2850
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
2847
|
-
snapshot._refreshSas = new RefreshV2CheckpointSas(snapshot.
|
|
2851
|
+
snapshot._refreshSas = new RefreshV2CheckpointSas(snapshot[Symbols_1._nativeDb].cloudContainer.accessToken, checkpoint.reattachSafetySeconds);
|
|
2848
2852
|
return snapshot;
|
|
2849
2853
|
}
|
|
2850
2854
|
/**
|
|
@@ -2868,7 +2872,7 @@ class SnapshotDb extends IModelDb {
|
|
|
2868
2872
|
if (this._restartDefaultTxnTimer)
|
|
2869
2873
|
clearTimeout(this._restartDefaultTxnTimer);
|
|
2870
2874
|
if (this._createClassViewsOnClose) { // check for flag set during create
|
|
2871
|
-
if (core_bentley_1.BentleyStatus.SUCCESS !== this.
|
|
2875
|
+
if (core_bentley_1.BentleyStatus.SUCCESS !== this[Symbols_1._nativeDb].createClassViewsInDb()) {
|
|
2872
2876
|
throw new core_common_1.IModelError(core_bentley_1.IModelStatus.SQLiteError, "Error creating class views");
|
|
2873
2877
|
}
|
|
2874
2878
|
else {
|
|
@@ -2944,7 +2948,7 @@ class StandaloneDb extends BriefcaseDb {
|
|
|
2944
2948
|
* @beta
|
|
2945
2949
|
*/
|
|
2946
2950
|
createClassViews() {
|
|
2947
|
-
const result = this.
|
|
2951
|
+
const result = this[Symbols_1._nativeDb].createClassViewsInDb();
|
|
2948
2952
|
if (core_bentley_1.BentleyStatus.SUCCESS !== result)
|
|
2949
2953
|
throw new core_common_1.IModelError(result, "Error creating class views");
|
|
2950
2954
|
else
|