@itwin/core-backend 4.0.0-dev.4 → 4.0.0-dev.40
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 +89 -67
- package/lib/cjs/AliCloudStorageService.d.ts +1 -1
- package/lib/cjs/AliCloudStorageService.js.map +1 -1
- package/lib/cjs/BackendHubAccess.d.ts +3 -3
- package/lib/cjs/BackendHubAccess.js.map +1 -1
- package/lib/cjs/BriefcaseManager.js +13 -19
- package/lib/cjs/BriefcaseManager.js.map +1 -1
- package/lib/cjs/ChangeSummaryManager.js +6 -7
- package/lib/cjs/ChangeSummaryManager.js.map +1 -1
- package/lib/cjs/CheckpointManager.js +3 -4
- package/lib/cjs/CheckpointManager.js.map +1 -1
- package/lib/cjs/ClassRegistry.js +1 -2
- package/lib/cjs/ClassRegistry.js.map +1 -1
- package/lib/cjs/CloudSqlite.js +1 -1
- package/lib/cjs/CloudSqlite.js.map +1 -1
- package/lib/cjs/CloudStorageBackend.d.ts +4 -4
- package/lib/cjs/CloudStorageBackend.js +8 -11
- package/lib/cjs/CloudStorageBackend.js.map +1 -1
- package/lib/cjs/CodeService.d.ts +6 -6
- package/lib/cjs/CodeService.d.ts.map +1 -1
- package/lib/cjs/CodeService.js +3 -3
- package/lib/cjs/CodeService.js.map +1 -1
- package/lib/cjs/CustomViewState3dCreator.js +2 -2
- package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
- package/lib/cjs/DevTools.d.ts +4 -2
- package/lib/cjs/DevTools.d.ts.map +1 -1
- package/lib/cjs/DevTools.js +4 -2
- package/lib/cjs/DevTools.js.map +1 -1
- package/lib/cjs/DisplayStyle.js +8 -11
- package/lib/cjs/DisplayStyle.js.map +1 -1
- package/lib/cjs/ECDb.js +2 -4
- package/lib/cjs/ECDb.js.map +1 -1
- package/lib/cjs/Element.js +13 -21
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/ElementTreeWalker.js +2 -2
- package/lib/cjs/ElementTreeWalker.js.map +1 -1
- package/lib/cjs/GeoCoordConfig.js +1 -1
- package/lib/cjs/GeoCoordConfig.js.map +1 -1
- package/lib/cjs/HubMock.js +3 -5
- package/lib/cjs/HubMock.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +15 -1
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +44 -59
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/IModelHost.d.ts +4 -4
- package/lib/cjs/IModelHost.d.ts.map +1 -1
- package/lib/cjs/IModelHost.js +15 -23
- package/lib/cjs/IModelHost.js.map +1 -1
- package/lib/cjs/IModelJsFs.js +2 -3
- package/lib/cjs/IModelJsFs.js.map +1 -1
- package/lib/cjs/IpcHost.js +11 -13
- package/lib/cjs/IpcHost.js.map +1 -1
- package/lib/cjs/LocalHub.js +11 -16
- package/lib/cjs/LocalHub.js.map +1 -1
- package/lib/cjs/LocalhostIpcHost.js +3 -5
- package/lib/cjs/LocalhostIpcHost.js.map +1 -1
- package/lib/cjs/Material.js +1 -2
- package/lib/cjs/Material.js.map +1 -1
- package/lib/cjs/NativeHost.js +3 -6
- package/lib/cjs/NativeHost.js.map +1 -1
- package/lib/cjs/SQLiteDb.js +2 -4
- package/lib/cjs/SQLiteDb.js.map +1 -1
- package/lib/cjs/TileStorage.js +4 -7
- package/lib/cjs/TileStorage.js.map +1 -1
- package/lib/cjs/ViewDefinition.d.ts +10 -14
- package/lib/cjs/ViewDefinition.d.ts.map +1 -1
- package/lib/cjs/ViewDefinition.js +14 -14
- package/lib/cjs/ViewDefinition.js.map +1 -1
- package/lib/cjs/rpc/tracing.js +1 -2
- package/lib/cjs/rpc/tracing.js.map +1 -1
- package/lib/cjs/rpc/web/request.js +1 -2
- package/lib/cjs/rpc/web/request.js.map +1 -1
- package/lib/cjs/rpc/web/response.js +1 -2
- package/lib/cjs/rpc/web/response.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +2 -3
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +4 -7
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +6 -8
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
- package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js +1 -2
- package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
- package/lib/cjs/workspace/Settings.js +1 -2
- package/lib/cjs/workspace/Settings.js.map +1 -1
- package/lib/cjs/workspace/SettingsSchemas.js +3 -4
- package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
- package/lib/cjs/workspace/Workspace.js +15 -21
- package/lib/cjs/workspace/Workspace.js.map +1 -1
- package/package.json +17 -17
package/lib/cjs/IModelDb.js
CHANGED
|
@@ -77,8 +77,7 @@ class IModelSettings extends Settings_1.BaseSettings {
|
|
|
77
77
|
}
|
|
78
78
|
// attempt to resolve a setting from this iModel's settings, otherwise use appWorkspace's settings, otherwise defaultValue.
|
|
79
79
|
resolveSetting(name, resolver, defaultValue) {
|
|
80
|
-
|
|
81
|
-
return (_a = super.resolveSetting(name, resolver)) !== null && _a !== void 0 ? _a : IModelHost_1.IModelHost.appWorkspace.settings.resolveSetting(name, resolver, defaultValue);
|
|
80
|
+
return super.resolveSetting(name, resolver) ?? IModelHost_1.IModelHost.appWorkspace.settings.resolveSetting(name, resolver, defaultValue);
|
|
82
81
|
}
|
|
83
82
|
}
|
|
84
83
|
/** An iModel database file. The database file can either be a briefcase or a snapshot.
|
|
@@ -155,8 +154,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
155
154
|
this.onChangesetApplied.raiseEvent();
|
|
156
155
|
}
|
|
157
156
|
get fontMap() {
|
|
158
|
-
|
|
159
|
-
return (_a = this._fontMap) !== null && _a !== void 0 ? _a : (this._fontMap = new core_common_1.FontMap(this.nativeDb.readFontMap()));
|
|
157
|
+
return this._fontMap ?? (this._fontMap = new core_common_1.FontMap(this.nativeDb.readFontMap()));
|
|
160
158
|
}
|
|
161
159
|
/** @internal */
|
|
162
160
|
clearFontMap() {
|
|
@@ -173,7 +171,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
173
171
|
addNewFont(name, type) {
|
|
174
172
|
this.locks.checkExclusiveLock(core_common_1.IModel.repositoryModelId, "schema", "addNewFont");
|
|
175
173
|
this.clearFontMap();
|
|
176
|
-
return this.nativeDb.addNewFont({ name, type: type
|
|
174
|
+
return this.nativeDb.addNewFont({ name, type: type ?? core_common_1.FontType.TrueType });
|
|
177
175
|
}
|
|
178
176
|
/** Check if this iModel has been opened read-only or not. */
|
|
179
177
|
get isReadonly() { return this.openMode === core_bentley_1.OpenMode.Readonly; }
|
|
@@ -190,15 +188,14 @@ class IModelDb extends core_common_1.IModel {
|
|
|
190
188
|
get pathName() { return this.nativeDb.getFilePath(); }
|
|
191
189
|
/** Close this IModel, if it is currently open. */
|
|
192
190
|
close() {
|
|
193
|
-
var _a, _b;
|
|
194
191
|
if (!this.isOpen)
|
|
195
192
|
return; // don't continue if already closed
|
|
196
193
|
this.beforeClose();
|
|
197
194
|
IModelDb._openDbs.delete(this._fileKey);
|
|
198
|
-
|
|
195
|
+
this._workspace?.close();
|
|
199
196
|
this.locks.close();
|
|
200
197
|
this._locks = undefined;
|
|
201
|
-
|
|
198
|
+
this._codeService?.close();
|
|
202
199
|
this._codeService = undefined;
|
|
203
200
|
this.nativeDb.closeIModel();
|
|
204
201
|
this._nativeDb = undefined; // the underlying nativeDb has been freed by closeIModel
|
|
@@ -227,8 +224,8 @@ class IModelDb extends core_common_1.IModel {
|
|
|
227
224
|
db.onRootSubjectChanged.addListener(() => IpcHost_1.IpcHost.notifyTxns(db, "notifyRootSubjectChanged", db.rootSubject));
|
|
228
225
|
db.onProjectExtentsChanged.addListener(() => IpcHost_1.IpcHost.notifyTxns(db, "notifyProjectExtentsChanged", db.projectExtents.toJSON()));
|
|
229
226
|
db.onGlobalOriginChanged.addListener(() => IpcHost_1.IpcHost.notifyTxns(db, "notifyGlobalOriginChanged", db.globalOrigin.toJSON()));
|
|
230
|
-
db.onEcefLocationChanged.addListener(() =>
|
|
231
|
-
db.onGeographicCoordinateSystemChanged.addListener(() =>
|
|
227
|
+
db.onEcefLocationChanged.addListener(() => IpcHost_1.IpcHost.notifyTxns(db, "notifyEcefLocationChanged", db.ecefLocation?.toJSON()));
|
|
228
|
+
db.onGeographicCoordinateSystemChanged.addListener(() => IpcHost_1.IpcHost.notifyTxns(db, "notifyGeographicCoordinateSystemChanged", db.geographicCoordinateSystem?.toJSON()));
|
|
232
229
|
}
|
|
233
230
|
/** Returns true if this is a BriefcaseDb
|
|
234
231
|
* @see [[BriefcaseDb.open]]
|
|
@@ -271,8 +268,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
271
268
|
* @public
|
|
272
269
|
*/
|
|
273
270
|
withPreparedStatement(ecsql, callback, logErrors = true) {
|
|
274
|
-
|
|
275
|
-
const stmt = (_a = this._statementCache.findAndRemove(ecsql)) !== null && _a !== void 0 ? _a : this.prepareStatement(ecsql, logErrors);
|
|
271
|
+
const stmt = this._statementCache.findAndRemove(ecsql) ?? this.prepareStatement(ecsql, logErrors);
|
|
276
272
|
const release = () => this._statementCache.addOrDispose(stmt);
|
|
277
273
|
try {
|
|
278
274
|
const val = callback(stmt);
|
|
@@ -410,8 +406,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
410
406
|
* @public
|
|
411
407
|
*/
|
|
412
408
|
withPreparedSqliteStatement(sql, callback, logErrors = true) {
|
|
413
|
-
|
|
414
|
-
const stmt = (_a = this._sqliteStatementCache.findAndRemove(sql)) !== null && _a !== void 0 ? _a : this.prepareSqliteStatement(sql, logErrors);
|
|
409
|
+
const stmt = this._sqliteStatementCache.findAndRemove(sql) ?? this.prepareSqliteStatement(sql, logErrors);
|
|
415
410
|
const release = () => this._sqliteStatementCache.addOrDispose(stmt);
|
|
416
411
|
try {
|
|
417
412
|
const val = callback(stmt);
|
|
@@ -548,8 +543,8 @@ class IModelDb extends core_common_1.IModel {
|
|
|
548
543
|
* @note This method does not modify the IModel's stored project extents. @see [[updateProjectExtents]].
|
|
549
544
|
*/
|
|
550
545
|
computeProjectExtents(options) {
|
|
551
|
-
const wantFullExtents = true ===
|
|
552
|
-
const wantOutliers = true ===
|
|
546
|
+
const wantFullExtents = true === options?.reportExtentsWithOutliers;
|
|
547
|
+
const wantOutliers = true === options?.reportOutliers;
|
|
553
548
|
const result = this.nativeDb.computeProjectExtents(wantFullExtents, wantOutliers);
|
|
554
549
|
return {
|
|
555
550
|
extents: core_geometry_1.Range3d.fromJSON(result.extents),
|
|
@@ -611,20 +606,20 @@ class IModelDb extends core_common_1.IModel {
|
|
|
611
606
|
* 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.
|
|
612
607
|
* You must import a schema into an iModel before you can insert instances of the classes in that schema. See [[Element]]
|
|
613
608
|
* @param schemaFileName array of Full paths to ECSchema.xml files to be imported.
|
|
609
|
+
* @param {SchemaImportOptions} options - options during schema import.
|
|
614
610
|
* @throws [[IModelError]] if the schema lock cannot be obtained or there is a problem importing the schema.
|
|
615
611
|
* @note Changes are saved if importSchemas is successful and abandoned if not successful.
|
|
616
612
|
* @see querySchemaVersion
|
|
617
613
|
*/
|
|
618
|
-
async importSchemas(schemaFileNames) {
|
|
619
|
-
if (this.
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
const stat = this.nativeDb.importSchemas(schemaFileNames);
|
|
614
|
+
async importSchemas(schemaFileNames, options) {
|
|
615
|
+
if (this.nativeDb.getITwinId() !== core_bentley_1.Guid.empty) // if this iModel is associated with an iTwin, importing schema requires the schema lock
|
|
616
|
+
await this.acquireSchemaLock();
|
|
617
|
+
const maybeCustomNativeContext = options?.ecSchemaXmlContext?.nativeContext;
|
|
618
|
+
const nativeImportOptions = {
|
|
619
|
+
schemaLockHeld: true,
|
|
620
|
+
ecSchemaXmlContext: maybeCustomNativeContext,
|
|
621
|
+
};
|
|
622
|
+
const stat = this.nativeDb.importSchemas(schemaFileNames, nativeImportOptions);
|
|
628
623
|
if (core_bentley_1.DbResult.BE_SQLITE_OK !== stat) {
|
|
629
624
|
throw new core_common_1.IModelError(stat, "Error importing schema");
|
|
630
625
|
}
|
|
@@ -640,16 +635,9 @@ class IModelDb extends core_common_1.IModel {
|
|
|
640
635
|
* @alpha
|
|
641
636
|
*/
|
|
642
637
|
async importSchemaStrings(serializedXmlSchemas) {
|
|
643
|
-
if (this.
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
throw new core_common_1.IModelError(status, "Error importing schema");
|
|
647
|
-
}
|
|
648
|
-
this.clearCaches();
|
|
649
|
-
return;
|
|
650
|
-
}
|
|
651
|
-
await this.acquireSchemaLock();
|
|
652
|
-
const stat = this.nativeDb.importXmlSchemas(serializedXmlSchemas);
|
|
638
|
+
if (this.iTwinId && this.iTwinId !== core_bentley_1.Guid.empty) // if this iModel is associated with an iTwin, importing schema requires the schema lock
|
|
639
|
+
await this.acquireSchemaLock();
|
|
640
|
+
const stat = this.nativeDb.importXmlSchemas(serializedXmlSchemas, { schemaLockHeld: true });
|
|
653
641
|
if (core_bentley_1.DbResult.BE_SQLITE_OK !== stat)
|
|
654
642
|
throw new core_common_1.IModelError(stat, "Error importing schema");
|
|
655
643
|
this.clearCaches();
|
|
@@ -683,16 +671,15 @@ class IModelDb extends core_common_1.IModel {
|
|
|
683
671
|
}
|
|
684
672
|
/** @internal */
|
|
685
673
|
static openDgnDb(file, openMode, upgradeOptions, props) {
|
|
686
|
-
|
|
687
|
-
file.key = (_a = file.key) !== null && _a !== void 0 ? _a : core_bentley_1.Guid.createValue();
|
|
674
|
+
file.key = file.key ?? core_bentley_1.Guid.createValue();
|
|
688
675
|
if (this.tryFindByKey(file.key))
|
|
689
676
|
throw new core_common_1.IModelError(core_bentley_1.IModelStatus.AlreadyOpen, `key [${file.key}] for file [${file.path}] is already in use`);
|
|
690
|
-
const isUpgradeRequested =
|
|
677
|
+
const isUpgradeRequested = upgradeOptions?.domain === core_common_1.DomainOptions.Upgrade || upgradeOptions?.profile === core_common_1.ProfileOptions.Upgrade;
|
|
691
678
|
if (isUpgradeRequested && openMode !== core_bentley_1.OpenMode.ReadWrite)
|
|
692
679
|
throw new core_common_1.IModelError(core_bentley_1.IModelStatus.UpgradeFailed, "Cannot upgrade a Readonly Db");
|
|
693
680
|
try {
|
|
694
681
|
const nativeDb = new IModelHost_1.IModelHost.platform.DgnDb();
|
|
695
|
-
nativeDb.openIModel(file.path, openMode, upgradeOptions, props, props
|
|
682
|
+
nativeDb.openIModel(file.path, openMode, upgradeOptions, props, props?.container);
|
|
696
683
|
return nativeDb;
|
|
697
684
|
}
|
|
698
685
|
catch (err) {
|
|
@@ -1218,7 +1205,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1218
1205
|
*/
|
|
1219
1206
|
tryGetSubModel(modeledElementId, modelClass) {
|
|
1220
1207
|
const modeledElementProps = this._iModel.elements.tryGetElementProps(modeledElementId);
|
|
1221
|
-
if (undefined ===
|
|
1208
|
+
if (undefined === modeledElementProps?.id || (core_common_1.IModel.rootSubjectId === modeledElementProps.id))
|
|
1222
1209
|
return undefined;
|
|
1223
1210
|
return this.tryGetModel(modeledElementProps.id, modelClass);
|
|
1224
1211
|
}
|
|
@@ -1790,7 +1777,7 @@ IModelDb._settingPropNamespace = "settings";
|
|
|
1790
1777
|
const categorySelectorProps = elements.getElementProps(viewDefinitionProps.categorySelectorId);
|
|
1791
1778
|
const displayStyleProps = elements.getElementProps({
|
|
1792
1779
|
id: viewDefinitionProps.displayStyleId,
|
|
1793
|
-
displayStyle: options
|
|
1780
|
+
displayStyle: options?.displayStyle,
|
|
1794
1781
|
});
|
|
1795
1782
|
const viewStateData = {
|
|
1796
1783
|
viewDefinitionProps,
|
|
@@ -1996,7 +1983,7 @@ class BriefcaseDb extends IModelDb {
|
|
|
1996
1983
|
}
|
|
1997
1984
|
static tryFindByKey(key) {
|
|
1998
1985
|
const db = super.tryFindByKey(key);
|
|
1999
|
-
return
|
|
1986
|
+
return db?.isBriefcaseDb() ? db : undefined;
|
|
2000
1987
|
}
|
|
2001
1988
|
/**
|
|
2002
1989
|
* The Guid that identifies the *context* that owns this iModel.
|
|
@@ -2041,8 +2028,8 @@ class BriefcaseDb extends IModelDb {
|
|
|
2041
2028
|
// good thing computers are fast. Fortunately upgrading should be rare (and the push time will dominate anyway.) Don't try to optimize any of this away.
|
|
2042
2029
|
await withBriefcaseDb(briefcase, async (db) => db.acquireSchemaLock()); // may not really acquire lock if iModel uses "noLocks" mode.
|
|
2043
2030
|
try {
|
|
2044
|
-
await this.doUpgrade(briefcase, { profile: core_common_1.ProfileOptions.Upgrade }, "Upgraded profile");
|
|
2045
|
-
await this.doUpgrade(briefcase, { domain: core_common_1.DomainOptions.Upgrade }, "Upgraded domain schemas");
|
|
2031
|
+
await this.doUpgrade(briefcase, { profile: core_common_1.ProfileOptions.Upgrade, schemaLockHeld: true }, "Upgraded profile");
|
|
2032
|
+
await this.doUpgrade(briefcase, { domain: core_common_1.DomainOptions.Upgrade, schemaLockHeld: true }, "Upgraded domain schemas");
|
|
2046
2033
|
}
|
|
2047
2034
|
finally {
|
|
2048
2035
|
await withBriefcaseDb(briefcase, async (db) => db.locks.releaseAllLocks());
|
|
@@ -2052,12 +2039,11 @@ class BriefcaseDb extends IModelDb {
|
|
|
2052
2039
|
* @param args parameters that specify the file name, and options for opening the briefcase file
|
|
2053
2040
|
*/
|
|
2054
2041
|
static async open(args) {
|
|
2055
|
-
var _a;
|
|
2056
2042
|
this.onOpen.raiseEvent(args);
|
|
2057
2043
|
const file = { path: args.fileName, key: args.key };
|
|
2058
2044
|
const openMode = args.readonly ? core_bentley_1.OpenMode.Readonly : core_bentley_1.OpenMode.ReadWrite;
|
|
2059
2045
|
const nativeDb = this.openDgnDb(file, openMode, undefined, args);
|
|
2060
|
-
const briefcaseDb = new BriefcaseDb({ nativeDb, key:
|
|
2046
|
+
const briefcaseDb = new BriefcaseDb({ nativeDb, key: file.key ?? core_bentley_1.Guid.createValue(), openMode, briefcaseId: nativeDb.getBriefcaseId() });
|
|
2061
2047
|
if (openMode === core_bentley_1.OpenMode.ReadWrite && CodeService_1.CodeService.createForIModel) {
|
|
2062
2048
|
try {
|
|
2063
2049
|
const codeService = CodeService_1.CodeService.createForIModel(briefcaseDb);
|
|
@@ -2083,7 +2069,7 @@ class BriefcaseDb extends IModelDb {
|
|
|
2083
2069
|
if (this.isReadonly) // we allow pulling changes into a briefcase that is readonly - close and reopen it writeable
|
|
2084
2070
|
this.closeAndReopen(core_bentley_1.OpenMode.ReadWrite);
|
|
2085
2071
|
try {
|
|
2086
|
-
await BriefcaseManager_1.BriefcaseManager.pullAndApplyChangesets(this, arg
|
|
2072
|
+
await BriefcaseManager_1.BriefcaseManager.pullAndApplyChangesets(this, arg ?? {});
|
|
2087
2073
|
this.initializeIModelDb();
|
|
2088
2074
|
}
|
|
2089
2075
|
finally {
|
|
@@ -2135,7 +2121,7 @@ class RefreshV2CheckpointSas {
|
|
|
2135
2121
|
constructor(sasToken, safetySeconds) {
|
|
2136
2122
|
/** the time at which the current token should be refreshed (its expiry minus safetySeconds) */
|
|
2137
2123
|
this._timestamp = 0;
|
|
2138
|
-
this._safetySeconds = safetySeconds
|
|
2124
|
+
this._safetySeconds = safetySeconds ?? 60 * 60; // default to 1 hour
|
|
2139
2125
|
this.setTimestamp(sasToken);
|
|
2140
2126
|
}
|
|
2141
2127
|
async performRefresh(accessToken, iModel) {
|
|
@@ -2190,7 +2176,7 @@ class SnapshotDb extends IModelDb {
|
|
|
2190
2176
|
}
|
|
2191
2177
|
static tryFindByKey(key) {
|
|
2192
2178
|
const db = super.tryFindByKey(key);
|
|
2193
|
-
return
|
|
2179
|
+
return db?.isSnapshotDb() ? db : undefined;
|
|
2194
2180
|
}
|
|
2195
2181
|
/** Create an *empty* local [Snapshot]($docs/learning/backend/AccessingIModels.md#snapshot-imodels) iModel file.
|
|
2196
2182
|
* Snapshots are not synchronized with iModelHub, so do not have a change timeline.
|
|
@@ -2232,7 +2218,7 @@ class SnapshotDb extends IModelDb {
|
|
|
2232
2218
|
nativeDb.deleteAllTxns();
|
|
2233
2219
|
nativeDb.resetBriefcaseId(core_common_1.BriefcaseIdValue.Unassigned);
|
|
2234
2220
|
const snapshotDb = new SnapshotDb(nativeDb, core_bentley_1.Guid.createValue());
|
|
2235
|
-
if (options
|
|
2221
|
+
if (options?.createClassViews)
|
|
2236
2222
|
snapshotDb._createClassViewsOnClose = true; // save flag that will be checked when close() is called
|
|
2237
2223
|
return snapshotDb;
|
|
2238
2224
|
}
|
|
@@ -2240,7 +2226,7 @@ class SnapshotDb extends IModelDb {
|
|
|
2240
2226
|
* @internal
|
|
2241
2227
|
*/
|
|
2242
2228
|
static openForApplyChangesets(path, props) {
|
|
2243
|
-
const file = { path, key: props
|
|
2229
|
+
const file = { path, key: props?.key };
|
|
2244
2230
|
const nativeDb = this.openDgnDb(file, core_bentley_1.OpenMode.ReadWrite, undefined, props);
|
|
2245
2231
|
(0, core_bentley_1.assert)(undefined !== file.key);
|
|
2246
2232
|
return new SnapshotDb(nativeDb, file.key);
|
|
@@ -2252,7 +2238,7 @@ class SnapshotDb extends IModelDb {
|
|
|
2252
2238
|
* @throws [[IModelError]] If the file is not found or is not a valid *snapshot*.
|
|
2253
2239
|
*/
|
|
2254
2240
|
static openFile(path, opts) {
|
|
2255
|
-
const file = { path, key: opts
|
|
2241
|
+
const file = { path, key: opts?.key };
|
|
2256
2242
|
const nativeDb = this.openDgnDb(file, core_bentley_1.OpenMode.Readonly, undefined, opts);
|
|
2257
2243
|
(0, core_bentley_1.assert)(undefined !== file.key);
|
|
2258
2244
|
return new SnapshotDb(nativeDb, file.key);
|
|
@@ -2297,8 +2283,7 @@ class SnapshotDb extends IModelDb {
|
|
|
2297
2283
|
* @internal
|
|
2298
2284
|
*/
|
|
2299
2285
|
async refreshContainerSas(userAccessToken) {
|
|
2300
|
-
|
|
2301
|
-
return (_a = this._refreshSas) === null || _a === void 0 ? void 0 : _a.refreshSas(userAccessToken, this);
|
|
2286
|
+
return this._refreshSas?.refreshSas(userAccessToken, this);
|
|
2302
2287
|
}
|
|
2303
2288
|
/** @internal */
|
|
2304
2289
|
beforeClose() {
|
|
@@ -2339,7 +2324,7 @@ class StandaloneDb extends BriefcaseDb {
|
|
|
2339
2324
|
}
|
|
2340
2325
|
static tryFindByKey(key) {
|
|
2341
2326
|
const db = super.tryFindByKey(key);
|
|
2342
|
-
return
|
|
2327
|
+
return db?.isStandaloneDb() ? db : undefined;
|
|
2343
2328
|
}
|
|
2344
2329
|
/** Create an *empty* standalone iModel.
|
|
2345
2330
|
* @param filePath The file path for the iModel
|
|
@@ -2362,9 +2347,9 @@ class StandaloneDb extends BriefcaseDb {
|
|
|
2362
2347
|
* @see [[StandaloneDb.validateSchemas]]
|
|
2363
2348
|
*/
|
|
2364
2349
|
static upgradeStandaloneSchemas(filePath) {
|
|
2365
|
-
let nativeDb = this.openDgnDb({ path: filePath }, core_bentley_1.OpenMode.ReadWrite, { profile: core_common_1.ProfileOptions.Upgrade });
|
|
2350
|
+
let nativeDb = this.openDgnDb({ path: filePath }, core_bentley_1.OpenMode.ReadWrite, { profile: core_common_1.ProfileOptions.Upgrade, schemaLockHeld: true });
|
|
2366
2351
|
nativeDb.closeIModel();
|
|
2367
|
-
nativeDb = this.openDgnDb({ path: filePath }, core_bentley_1.OpenMode.ReadWrite, { domain: core_common_1.DomainOptions.Upgrade });
|
|
2352
|
+
nativeDb = this.openDgnDb({ path: filePath }, core_bentley_1.OpenMode.ReadWrite, { domain: core_common_1.DomainOptions.Upgrade, schemaLockHeld: true });
|
|
2368
2353
|
nativeDb.closeIModel();
|
|
2369
2354
|
}
|
|
2370
2355
|
/** Open a standalone iModel file.
|
|
@@ -2374,7 +2359,7 @@ class StandaloneDb extends BriefcaseDb {
|
|
|
2374
2359
|
* @see [BriefcaseConnection.openStandalone]($frontend) to open a StandaloneDb from the frontend
|
|
2375
2360
|
*/
|
|
2376
2361
|
static openFile(filePath, openMode = core_bentley_1.OpenMode.ReadWrite, options) {
|
|
2377
|
-
const file = { path: filePath, key: options
|
|
2362
|
+
const file = { path: filePath, key: options?.key };
|
|
2378
2363
|
const nativeDb = this.openDgnDb(file, openMode, undefined, options);
|
|
2379
2364
|
try {
|
|
2380
2365
|
const iTwinId = nativeDb.getITwinId();
|