@itwin/core-backend 3.0.0-extension.0 → 3.1.0-dev.11
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 +82 -1
- package/LICENSE.md +1 -1
- package/lib/cjs/AliCloudStorageService.d.ts +8 -2
- package/lib/cjs/AliCloudStorageService.d.ts.map +1 -1
- package/lib/cjs/AliCloudStorageService.js +4 -5
- package/lib/cjs/AliCloudStorageService.js.map +1 -1
- package/lib/cjs/BackendHubAccess.d.ts +9 -9
- package/lib/cjs/BackendHubAccess.d.ts.map +1 -1
- package/lib/cjs/BackendHubAccess.js.map +1 -1
- package/lib/cjs/BriefcaseManager.js +4 -3
- package/lib/cjs/BriefcaseManager.js.map +1 -1
- package/lib/cjs/Category.d.ts +1 -1
- package/lib/cjs/Category.d.ts.map +1 -1
- package/lib/cjs/Category.js +6 -6
- package/lib/cjs/Category.js.map +1 -1
- package/lib/cjs/ChangeSummaryManager.d.ts.map +1 -1
- package/lib/cjs/ChangeSummaryManager.js +2 -0
- package/lib/cjs/ChangeSummaryManager.js.map +1 -1
- package/lib/cjs/ChangedElementsDb.d.ts +2 -0
- package/lib/cjs/ChangedElementsDb.d.ts.map +1 -1
- package/lib/cjs/ChangedElementsDb.js +1 -1
- package/lib/cjs/ChangedElementsDb.js.map +1 -1
- package/lib/cjs/CheckpointManager.d.ts.map +1 -1
- package/lib/cjs/CheckpointManager.js +10 -7
- package/lib/cjs/CheckpointManager.js.map +1 -1
- package/lib/cjs/ClassRegistry.d.ts.map +1 -1
- package/lib/cjs/ClassRegistry.js +10 -3
- package/lib/cjs/ClassRegistry.js.map +1 -1
- package/lib/cjs/CloudStorageBackend.d.ts +2 -3
- package/lib/cjs/CloudStorageBackend.d.ts.map +1 -1
- package/lib/cjs/CloudStorageBackend.js +5 -2
- package/lib/cjs/CloudStorageBackend.js.map +1 -1
- package/lib/cjs/ConcurrentQuery.d.ts.map +1 -1
- package/lib/cjs/ConcurrentQuery.js +7 -0
- package/lib/cjs/ConcurrentQuery.js.map +1 -1
- package/lib/cjs/DevTools.d.ts +2 -2
- package/lib/cjs/DevTools.d.ts.map +1 -1
- package/lib/cjs/DevTools.js +2 -2
- package/lib/cjs/DevTools.js.map +1 -1
- package/lib/cjs/DisplayStyle.d.ts +2 -2
- package/lib/cjs/DisplayStyle.d.ts.map +1 -1
- package/lib/cjs/DisplayStyle.js +15 -47
- package/lib/cjs/DisplayStyle.js.map +1 -1
- package/lib/cjs/ECDb.d.ts +5 -9
- package/lib/cjs/ECDb.d.ts.map +1 -1
- package/lib/cjs/ECDb.js +11 -14
- package/lib/cjs/ECDb.js.map +1 -1
- package/lib/cjs/ECSchemaXmlContext.d.ts +1 -0
- package/lib/cjs/ECSchemaXmlContext.d.ts.map +1 -1
- package/lib/cjs/ECSchemaXmlContext.js +10 -4
- package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
- package/lib/cjs/ECSqlStatement.d.ts +8 -8
- package/lib/cjs/ECSqlStatement.d.ts.map +1 -1
- package/lib/cjs/ECSqlStatement.js +24 -15
- package/lib/cjs/ECSqlStatement.js.map +1 -1
- package/lib/cjs/Element.d.ts +25 -17
- package/lib/cjs/Element.d.ts.map +1 -1
- package/lib/cjs/Element.js +9 -9
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/ElementAspect.d.ts +2 -2
- package/lib/cjs/ElementAspect.d.ts.map +1 -1
- package/lib/cjs/ElementAspect.js +2 -2
- package/lib/cjs/ElementAspect.js.map +1 -1
- package/lib/cjs/ElementGraphics.js +1 -1
- package/lib/cjs/ElementGraphics.js.map +1 -1
- package/lib/cjs/Entity.d.ts +11 -3
- package/lib/cjs/Entity.d.ts.map +1 -1
- package/lib/cjs/Entity.js +10 -2
- package/lib/cjs/Entity.js.map +1 -1
- package/lib/cjs/ExportGraphics.d.ts +1 -1
- package/lib/cjs/ExportGraphics.d.ts.map +1 -1
- package/lib/cjs/ExportGraphics.js +3 -0
- package/lib/cjs/ExportGraphics.js.map +1 -1
- package/lib/cjs/GeometrySummary.d.ts.map +1 -1
- package/lib/cjs/GeometrySummary.js +5 -2
- package/lib/cjs/GeometrySummary.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +44 -32
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +114 -50
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/IModelHost.d.ts +40 -19
- package/lib/cjs/IModelHost.d.ts.map +1 -1
- package/lib/cjs/IModelHost.js +70 -20
- package/lib/cjs/IModelHost.js.map +1 -1
- package/lib/cjs/IModelJsFs.js +1 -1
- package/lib/cjs/IModelJsFs.js.map +1 -1
- package/lib/cjs/IpcHost.js +2 -1
- package/lib/cjs/IpcHost.js.map +1 -1
- package/lib/cjs/LocalhostIpcHost.d.ts.map +1 -1
- package/lib/cjs/LocalhostIpcHost.js +10 -3
- package/lib/cjs/LocalhostIpcHost.js.map +1 -1
- package/lib/cjs/Material.d.ts +1 -1
- package/lib/cjs/Material.d.ts.map +1 -1
- package/lib/cjs/Material.js +1 -1
- package/lib/cjs/Material.js.map +1 -1
- package/lib/cjs/Model.d.ts +4 -4
- package/lib/cjs/Model.d.ts.map +1 -1
- package/lib/cjs/Model.js +3 -3
- package/lib/cjs/Model.js.map +1 -1
- package/lib/cjs/NativeHost.d.ts +4 -22
- package/lib/cjs/NativeHost.d.ts.map +1 -1
- package/lib/cjs/NativeHost.js +4 -56
- package/lib/cjs/NativeHost.js.map +1 -1
- package/lib/cjs/Relationship.d.ts +10 -9
- package/lib/cjs/Relationship.d.ts.map +1 -1
- package/lib/cjs/Relationship.js +14 -8
- package/lib/cjs/Relationship.js.map +1 -1
- package/lib/cjs/RpcBackend.d.ts +4 -0
- package/lib/cjs/RpcBackend.d.ts.map +1 -1
- package/lib/cjs/RpcBackend.js +7 -0
- package/lib/cjs/RpcBackend.js.map +1 -1
- package/lib/cjs/SQLiteDb.js +1 -1
- package/lib/cjs/SQLiteDb.js.map +1 -1
- package/lib/cjs/ServerBasedLocks.d.ts +4 -10
- package/lib/cjs/ServerBasedLocks.d.ts.map +1 -1
- package/lib/cjs/ServerBasedLocks.js +12 -20
- package/lib/cjs/ServerBasedLocks.js.map +1 -1
- package/lib/cjs/SqliteStatement.d.ts.map +1 -1
- package/lib/cjs/SqliteStatement.js.map +1 -1
- package/lib/cjs/Texture.js +1 -1
- package/lib/cjs/Texture.js.map +1 -1
- package/lib/cjs/TxnManager.js +1 -1
- package/lib/cjs/TxnManager.js.map +1 -1
- package/lib/cjs/ViewDefinition.d.ts +11 -11
- package/lib/cjs/ViewDefinition.d.ts.map +1 -1
- package/lib/cjs/ViewDefinition.js +5 -5
- package/lib/cjs/ViewDefinition.js.map +1 -1
- package/lib/cjs/assets/Settings.schema.json +25 -0
- package/lib/cjs/core-backend.d.ts +8 -1
- package/lib/cjs/core-backend.d.ts.map +1 -1
- package/lib/cjs/core-backend.js +9 -1
- package/lib/cjs/core-backend.js.map +1 -1
- package/lib/cjs/domains/FunctionalElements.d.ts +1 -1
- package/lib/cjs/domains/FunctionalElements.d.ts.map +1 -1
- package/lib/cjs/domains/FunctionalElements.js.map +1 -1
- package/lib/cjs/domains/GenericElements.d.ts +2 -2
- package/lib/cjs/domains/GenericElements.d.ts.map +1 -1
- package/lib/cjs/domains/GenericElements.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +33 -24
- 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 +10 -7
- 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 +11 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
- package/lib/cjs/rpc-impl/WipRpcImpl.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/WipRpcImpl.js +3 -0
- package/lib/cjs/rpc-impl/WipRpcImpl.js.map +1 -1
- package/lib/cjs/workspace/Settings.d.ts +182 -0
- package/lib/cjs/workspace/Settings.d.ts.map +1 -0
- package/lib/cjs/workspace/Settings.js +144 -0
- package/lib/cjs/workspace/Settings.js.map +1 -0
- package/lib/cjs/workspace/SettingsSpecRegistry.d.ts +68 -0
- package/lib/cjs/workspace/SettingsSpecRegistry.d.ts.map +1 -0
- package/lib/cjs/workspace/SettingsSpecRegistry.js +122 -0
- package/lib/cjs/workspace/SettingsSpecRegistry.js.map +1 -0
- package/lib/cjs/workspace/Workspace.d.ts +306 -0
- package/lib/cjs/workspace/Workspace.d.ts.map +1 -0
- package/lib/cjs/workspace/Workspace.js +372 -0
- package/lib/cjs/workspace/Workspace.js.map +1 -0
- package/package.json +33 -19
package/lib/cjs/IModelDb.js
CHANGED
|
@@ -19,7 +19,6 @@ const ClassRegistry_1 = require("./ClassRegistry");
|
|
|
19
19
|
const CodeSpecs_1 = require("./CodeSpecs");
|
|
20
20
|
const ConcurrentQuery_1 = require("./ConcurrentQuery");
|
|
21
21
|
const ECSqlStatement_1 = require("./ECSqlStatement");
|
|
22
|
-
const Element_1 = require("./Element");
|
|
23
22
|
const ElementAspect_1 = require("./ElementAspect");
|
|
24
23
|
const ElementGraphics_1 = require("./ElementGraphics");
|
|
25
24
|
const IModelHost_1 = require("./IModelHost");
|
|
@@ -31,6 +30,8 @@ const ServerBasedLocks_1 = require("./ServerBasedLocks");
|
|
|
31
30
|
const SqliteStatement_1 = require("./SqliteStatement");
|
|
32
31
|
const TxnManager_1 = require("./TxnManager");
|
|
33
32
|
const ViewDefinition_1 = require("./ViewDefinition");
|
|
33
|
+
const Settings_1 = require("./workspace/Settings");
|
|
34
|
+
const Workspace_1 = require("./workspace/Workspace");
|
|
34
35
|
const loggerCategory = BackendLoggerCategory_1.BackendLoggerCategory.IModelDb;
|
|
35
36
|
/** A null-implementation of LockControl that does not attempt to limit access between briefcases. This relies on change-merging to resolve conflicts. */
|
|
36
37
|
class NoLocks {
|
|
@@ -42,8 +43,7 @@ class NoLocks {
|
|
|
42
43
|
checkExclusiveLock() { }
|
|
43
44
|
checkSharedLock() { }
|
|
44
45
|
elementWasCreated() { }
|
|
45
|
-
async
|
|
46
|
-
async acquireSharedLock() { }
|
|
46
|
+
async acquireLocks() { }
|
|
47
47
|
async releaseAllLocks() { }
|
|
48
48
|
}
|
|
49
49
|
/** @internal */
|
|
@@ -62,6 +62,21 @@ const withBriefcaseDb = async (briefcase, fn) => {
|
|
|
62
62
|
db.close();
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
|
+
/**
|
|
66
|
+
* Settings for an individual iModel. May only include settings priority for iModel, iTwin and organization.
|
|
67
|
+
* @note if there is more than one iModel for an iTwin or organization, they will *each* hold a copy of the settings for those priorities.
|
|
68
|
+
*/
|
|
69
|
+
class IModelSettings extends Settings_1.BaseSettings {
|
|
70
|
+
verifyPriority(priority) {
|
|
71
|
+
if (priority <= Settings_1.SettingsPriority.application)
|
|
72
|
+
throw new Error("Use IModelHost.appSettings");
|
|
73
|
+
}
|
|
74
|
+
// attempt to resolve a setting from this iModel's settings, otherwise use appWorkspace's settings, otherwise defaultValue.
|
|
75
|
+
resolveSetting(name, resolver, defaultValue) {
|
|
76
|
+
var _a;
|
|
77
|
+
return (_a = super.resolveSetting(name, resolver)) !== null && _a !== void 0 ? _a : IModelHost_1.IModelHost.appWorkspace.settings.resolveSetting(name, resolver, defaultValue);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
65
80
|
/** An iModel database file. The database file can either be a briefcase or a snapshot.
|
|
66
81
|
* @see [Accessing iModels]($docs/learning/backend/AccessingIModels.md)
|
|
67
82
|
* @see [About IModelDb]($docs/learning/backend/IModelDb.md)
|
|
@@ -78,7 +93,6 @@ class IModelDb extends core_common_1.IModel {
|
|
|
78
93
|
this.tiles = new IModelDb.Tiles(this);
|
|
79
94
|
this._statementCache = new SqliteStatement_1.StatementCache();
|
|
80
95
|
this._sqliteStatementCache = new SqliteStatement_1.StatementCache();
|
|
81
|
-
this._concurrentQueryStats = { resetTimerHandle: null, logTimerHandle: null, lastActivityTime: Date.now(), dispose: () => { } };
|
|
82
96
|
this._snaps = new Map();
|
|
83
97
|
/** @internal */
|
|
84
98
|
this._locks = new NoLocks();
|
|
@@ -90,6 +104,8 @@ class IModelDb extends core_common_1.IModel {
|
|
|
90
104
|
this.nativeDb.setIModelDb(this);
|
|
91
105
|
this.initializeIModelDb();
|
|
92
106
|
IModelDb._openDbs.set(this._fileKey, this);
|
|
107
|
+
this._workspace = new Workspace_1.ITwinWorkspace(new IModelSettings(), IModelHost_1.IModelHost.appWorkspace);
|
|
108
|
+
this.loadSettingDictionaries();
|
|
93
109
|
if (undefined === IModelDb._shutdownListener) { // the first time we create an IModelDb, add a listener to close any orphan files at shutdown.
|
|
94
110
|
IModelDb._shutdownListener = IModelHost_1.IModelHost.onBeforeShutdown.addListener(() => {
|
|
95
111
|
IModelDb._openDbs.forEach((db) => {
|
|
@@ -103,16 +119,21 @@ class IModelDb extends core_common_1.IModel {
|
|
|
103
119
|
}
|
|
104
120
|
}
|
|
105
121
|
/**
|
|
106
|
-
* Get the
|
|
122
|
+
* Get the [[LockControl]] for this iModel.
|
|
107
123
|
* @beta
|
|
108
124
|
*/
|
|
109
|
-
get locks() { return this._locks; }
|
|
125
|
+
get locks() { return this._locks; } // eslint-disable-line @typescript-eslint/no-non-null-assertion
|
|
126
|
+
/**
|
|
127
|
+
* Get the [[Workspace]] for this iModel.
|
|
128
|
+
* @beta
|
|
129
|
+
*/
|
|
130
|
+
get workspace() { return this._workspace; }
|
|
110
131
|
/** Acquire the exclusive schema lock on this iModel.
|
|
111
132
|
* > Note: To acquire the schema lock, all other briefcases must first release *all* their locks. No other briefcases
|
|
112
133
|
* will be able to acquire *any* locks while the schema lock is held.
|
|
113
134
|
*/
|
|
114
135
|
async acquireSchemaLock() {
|
|
115
|
-
return this.locks.
|
|
136
|
+
return this.locks.acquireLocks({ exclusive: core_common_1.IModel.repositoryModelId });
|
|
116
137
|
}
|
|
117
138
|
/** determine whether the schema lock is currently held for this iModel. */
|
|
118
139
|
get holdsSchemaLock() {
|
|
@@ -124,13 +145,17 @@ class IModelDb extends core_common_1.IModel {
|
|
|
124
145
|
this.onChangesetApplied.raiseEvent();
|
|
125
146
|
}
|
|
126
147
|
get fontMap() { var _a; return (_a = this._fontMap) !== null && _a !== void 0 ? _a : (this._fontMap = new core_common_1.FontMap(this.nativeDb.readFontMap())); }
|
|
148
|
+
/** @internal */
|
|
127
149
|
embedFont(prop) { this._fontMap = undefined; return this.nativeDb.embedFont(prop); }
|
|
128
150
|
/** Check if this iModel has been opened read-only or not. */
|
|
129
151
|
get isReadonly() { return this.openMode === core_bentley_1.OpenMode.Readonly; }
|
|
130
152
|
/** The Guid that identifies this iModel. */
|
|
131
|
-
get iModelId() {
|
|
153
|
+
get iModelId() {
|
|
154
|
+
(0, core_bentley_1.assert)(undefined !== super.iModelId);
|
|
155
|
+
return super.iModelId;
|
|
156
|
+
} // GuidString | undefined for the IModel superclass, but required for all IModelDb subclasses
|
|
132
157
|
/** @internal*/
|
|
133
|
-
get nativeDb() { return this._nativeDb; }
|
|
158
|
+
get nativeDb() { return this._nativeDb; } // eslint-disable-line @typescript-eslint/no-non-null-assertion
|
|
134
159
|
/** Get the full path fileName of this iModelDb
|
|
135
160
|
* @note this member is only valid while the iModel is opened.
|
|
136
161
|
*/
|
|
@@ -141,6 +166,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
141
166
|
return; // don't continue if already closed
|
|
142
167
|
this.beforeClose();
|
|
143
168
|
IModelDb._openDbs.delete(this._fileKey);
|
|
169
|
+
this._workspace.close();
|
|
144
170
|
this.locks.close();
|
|
145
171
|
this._locks = undefined;
|
|
146
172
|
this.nativeDb.closeIModel();
|
|
@@ -155,7 +181,6 @@ class IModelDb extends core_common_1.IModel {
|
|
|
155
181
|
beforeClose() {
|
|
156
182
|
this.onBeforeClose.raiseEvent();
|
|
157
183
|
this.clearCaches();
|
|
158
|
-
this._concurrentQueryStats.dispose();
|
|
159
184
|
}
|
|
160
185
|
/** @internal */
|
|
161
186
|
initializeIModelDb() {
|
|
@@ -274,7 +299,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
274
299
|
}
|
|
275
300
|
const executor = {
|
|
276
301
|
execute: async (request) => {
|
|
277
|
-
return ConcurrentQuery_1.ConcurrentQuery.executeQueryRequest(this.
|
|
302
|
+
return ConcurrentQuery_1.ConcurrentQuery.executeQueryRequest(this.nativeDb, request);
|
|
278
303
|
},
|
|
279
304
|
};
|
|
280
305
|
return new core_common_1.ECSqlReader(executor, ecsql, params, config);
|
|
@@ -289,20 +314,16 @@ class IModelDb extends core_common_1.IModel {
|
|
|
289
314
|
*
|
|
290
315
|
* @param ecsql The ECSQL statement to execute
|
|
291
316
|
* @param params The values to bind to the parameters (if the ECSQL has any).
|
|
292
|
-
* @param rowFormat Specify what format the row will be returned. It default to Array format though to make it compilable with previous version use *QueryRowFormat.UseJsPropertyNames*
|
|
293
317
|
* @param options Allow to specify certain flags which control how query is executed.
|
|
294
318
|
* @returns Returns the query result as an *AsyncIterableIterator<any>* which lazy load result as needed. The row format is determined by *rowFormat* parameter.
|
|
295
319
|
* See [ECSQL row format]($docs/learning/ECSQLRowFormat) for details about the format of the returned rows.
|
|
296
320
|
* @throws [IModelError]($common) If there was any error while submitting, preparing or stepping into query
|
|
297
321
|
*/
|
|
298
|
-
async *query(ecsql, params,
|
|
322
|
+
async *query(ecsql, params, options) {
|
|
299
323
|
const builder = new core_common_1.QueryOptionsBuilder(options);
|
|
300
|
-
if (rowFormat === core_common_1.QueryRowFormat.UseJsPropertyNames) {
|
|
301
|
-
builder.setConvertClassIdsToNames(true);
|
|
302
|
-
}
|
|
303
324
|
const reader = this.createQueryReader(ecsql, params, builder.getOptions());
|
|
304
325
|
while (await reader.step())
|
|
305
|
-
yield reader.formatCurrentRow(
|
|
326
|
+
yield reader.formatCurrentRow();
|
|
306
327
|
}
|
|
307
328
|
/** Compute number of rows that would be returned by the ECSQL.
|
|
308
329
|
*
|
|
@@ -312,7 +333,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
312
333
|
*
|
|
313
334
|
* @param ecsql The ECSQL statement to execute
|
|
314
335
|
* @param params The values to bind to the parameters (if the ECSQL has any).
|
|
315
|
-
* See "[
|
|
336
|
+
* See "[iTwin.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)" for details.
|
|
316
337
|
* @returns Return row count.
|
|
317
338
|
* @throws [IModelError]($common) If the statement is invalid
|
|
318
339
|
*/
|
|
@@ -334,14 +355,13 @@ class IModelDb extends core_common_1.IModel {
|
|
|
334
355
|
* @param token None empty restart token. The previous query with same token would be cancelled. This would cause
|
|
335
356
|
* exception which user code must handle.
|
|
336
357
|
* @param params The values to bind to the parameters (if the ECSQL has any).
|
|
337
|
-
* @param rowFormat Specify what format the row will be returned. It default to Array format though to make it compilable with previous version use *QueryRowFormat.UseJsPropertyNames*
|
|
338
358
|
* @param options Allow to specify certain flags which control how query is executed.
|
|
339
359
|
* @returns Returns the query result as an *AsyncIterableIterator<any>* which lazy load result as needed. The row format is determined by *rowFormat* parameter.
|
|
340
360
|
* See [ECSQL row format]($docs/learning/ECSQLRowFormat) for details about the format of the returned rows.
|
|
341
361
|
* @throws [IModelError]($common) If there was any error while submitting, preparing or stepping into query
|
|
342
362
|
*/
|
|
343
|
-
async *restartQuery(token, ecsql, params,
|
|
344
|
-
for await (const row of this.query(ecsql, params,
|
|
363
|
+
async *restartQuery(token, ecsql, params, options) {
|
|
364
|
+
for await (const row of this.query(ecsql, params, new core_common_1.QueryOptionsBuilder(options).setRestartToken(token).getOptions())) {
|
|
345
365
|
yield row;
|
|
346
366
|
}
|
|
347
367
|
}
|
|
@@ -762,6 +782,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
762
782
|
const val = this.nativeDb.getECClassMetaData(className[0], className[1]);
|
|
763
783
|
if (val.error)
|
|
764
784
|
throw new core_common_1.IModelError(val.error.status, `Error getting class meta data for: ${classFullName}`);
|
|
785
|
+
(0, core_bentley_1.assert)(undefined !== val.result);
|
|
765
786
|
const metaData = new core_common_1.EntityMetaData(JSON.parse(val.result));
|
|
766
787
|
this.classMetaDataRegistry.add(classFullName, metaData);
|
|
767
788
|
// Recursive, to make sure that base classes are cached.
|
|
@@ -917,7 +938,7 @@ class IModelDb extends core_common_1.IModel {
|
|
|
917
938
|
* that list.
|
|
918
939
|
* * The results of changing [ExportPartGraphicsOptions]($core-backend) during the
|
|
919
940
|
* [ExportPartGraphicsOptions.onPartGraphics]($core-backend) callback are not defined.
|
|
920
|
-
* * See export-gltf under test-apps in the
|
|
941
|
+
* * See export-gltf under test-apps in the iTwin.js monorepo for a working reference.
|
|
921
942
|
* @returns 0 is successful, status otherwise
|
|
922
943
|
* @public
|
|
923
944
|
*/
|
|
@@ -931,17 +952,9 @@ class IModelDb extends core_common_1.IModel {
|
|
|
931
952
|
elementGeometryRequest(requestProps) {
|
|
932
953
|
return this.nativeDb.processGeometryStream(requestProps);
|
|
933
954
|
}
|
|
934
|
-
/** Update the geometry stream for the supplied element from binary format data instead of json.
|
|
935
|
-
* @returns DbResult.BE_SQLITE_OK if successful
|
|
936
|
-
* @alpha
|
|
937
|
-
*/
|
|
938
|
-
elementGeometryUpdate(updateProps) {
|
|
939
|
-
return this.nativeDb.updateGeometryStream(updateProps);
|
|
940
|
-
}
|
|
941
955
|
/** Create brep geometry for inclusion in an element's geometry stream.
|
|
942
956
|
* @returns DbResult.BE_SQLITE_OK if successful
|
|
943
957
|
* @throws [[IModelError]] to report issues with input geometry or parameters
|
|
944
|
-
* @see [IModelDb.elementGeometryUpdate]($core-backend)
|
|
945
958
|
* @alpha
|
|
946
959
|
*/
|
|
947
960
|
createBRepGeometry(createProps) {
|
|
@@ -953,12 +966,61 @@ class IModelDb extends core_common_1.IModel {
|
|
|
953
966
|
async generateElementGraphics(request) {
|
|
954
967
|
return (0, ElementGraphics_1.generateElementGraphics)(request, this);
|
|
955
968
|
}
|
|
969
|
+
/** Save a `SettingDictionary` in this iModel that will be loaded into [[workspace.settings]] every time this iModel is opened in future sessions.
|
|
970
|
+
* @param name The name for the SettingDictionary. If a dictionary by that name already exists in the iModel, its value is replaced.
|
|
971
|
+
* @param dict The SettingDictionary object to stringify and save.
|
|
972
|
+
* @note All saved `SettingDictionary`s are loaded into [[workspace.settings]] every time an iModel is opened.
|
|
973
|
+
* @beta
|
|
974
|
+
*/
|
|
975
|
+
saveSettingDictionary(name, dict) {
|
|
976
|
+
this.withSqliteStatement("REPLACE INTO be_Prop(id,SubId,TxnMode,Namespace,Name,strData) VALUES(0,0,0,?,?,?)", (stmt) => {
|
|
977
|
+
stmt.bindString(1, IModelDb._settingPropNamespace);
|
|
978
|
+
stmt.bindString(2, name);
|
|
979
|
+
stmt.bindString(3, JSON.stringify(dict));
|
|
980
|
+
const rc = stmt.step();
|
|
981
|
+
if (rc !== core_bentley_1.DbResult.BE_SQLITE_DONE)
|
|
982
|
+
throw new core_common_1.IModelError(rc, "cannot save setting");
|
|
983
|
+
});
|
|
984
|
+
this.saveChanges("add settings");
|
|
985
|
+
}
|
|
986
|
+
/** Delete a SettingDictionary, previously added with [[saveSettingDictionary]], from this iModel.
|
|
987
|
+
* @param name The name of the dictionary to delete.
|
|
988
|
+
* @beta
|
|
989
|
+
*/
|
|
990
|
+
deleteSettingDictionary(name) {
|
|
991
|
+
this.withSqliteStatement("DELETE FROM be_Prop WHERE Namespace=? AND Name=?", (stmt) => {
|
|
992
|
+
stmt.bindString(1, IModelDb._settingPropNamespace);
|
|
993
|
+
stmt.bindString(2, name);
|
|
994
|
+
const rc = stmt.step();
|
|
995
|
+
if (rc !== core_bentley_1.DbResult.BE_SQLITE_DONE)
|
|
996
|
+
throw new core_common_1.IModelError(rc, "cannot delete setting");
|
|
997
|
+
});
|
|
998
|
+
this.saveChanges("delete settings");
|
|
999
|
+
}
|
|
1000
|
+
/** Load all setting dictionaries in this iModel into `this.workspace.settings` */
|
|
1001
|
+
loadSettingDictionaries() {
|
|
1002
|
+
if (!this.nativeDb.isOpen())
|
|
1003
|
+
return;
|
|
1004
|
+
this.withSqliteStatement("SELECT Name,StrData FROM be_Prop WHERE Namespace=?", (stmt) => {
|
|
1005
|
+
stmt.bindString(1, IModelDb._settingPropNamespace);
|
|
1006
|
+
while (stmt.step() === core_bentley_1.DbResult.BE_SQLITE_ROW) {
|
|
1007
|
+
try {
|
|
1008
|
+
const dict = JSON.parse(stmt.getValueString(1));
|
|
1009
|
+
this.workspace.settings.addDictionary(stmt.getValueString(0), Settings_1.SettingsPriority.iModel, dict);
|
|
1010
|
+
}
|
|
1011
|
+
catch (e) {
|
|
1012
|
+
core_bentley_1.UnexpectedErrors.handle(e);
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
});
|
|
1016
|
+
}
|
|
956
1017
|
}
|
|
957
1018
|
exports.IModelDb = IModelDb;
|
|
958
1019
|
/** Keep track of open imodels to support `tryFind` for RPC purposes */
|
|
959
1020
|
IModelDb._openDbs = new Map();
|
|
960
1021
|
IModelDb.defaultLimit = 1000; // default limit for batching queries
|
|
961
1022
|
IModelDb.maxLimit = 10000; // maximum limit for batching queries
|
|
1023
|
+
IModelDb._settingPropNamespace = "settings";
|
|
962
1024
|
/** @public */
|
|
963
1025
|
(function (IModelDb) {
|
|
964
1026
|
/** The collection of models in an [[IModelDb]].
|
|
@@ -1023,13 +1085,11 @@ IModelDb.maxLimit = 10000; // maximum limit for batching queries
|
|
|
1023
1085
|
*/
|
|
1024
1086
|
tryGetModel(modelId, modelClass) {
|
|
1025
1087
|
const modelProps = this.tryGetModelProps(modelId);
|
|
1026
|
-
if (undefined === modelProps)
|
|
1088
|
+
if (undefined === modelProps)
|
|
1027
1089
|
return undefined; // no Model with that modelId found
|
|
1028
|
-
}
|
|
1029
1090
|
const model = this._iModel.constructEntity(modelProps);
|
|
1030
|
-
if (undefined === modelClass)
|
|
1091
|
+
if (undefined === modelClass)
|
|
1031
1092
|
return model; // modelClass was not specified, cannot call instanceof to validate
|
|
1032
|
-
}
|
|
1033
1093
|
return model instanceof modelClass ? model : undefined;
|
|
1034
1094
|
}
|
|
1035
1095
|
/** Read the properties for a Model as a json string.
|
|
@@ -1068,7 +1128,7 @@ IModelDb.maxLimit = 10000; // maximum limit for batching queries
|
|
|
1068
1128
|
*/
|
|
1069
1129
|
getSubModel(modeledElementId, modelClass) {
|
|
1070
1130
|
const modeledElementProps = this._iModel.elements.getElementProps(modeledElementId);
|
|
1071
|
-
if (modeledElementProps.id === core_common_1.IModel.rootSubjectId)
|
|
1131
|
+
if (undefined === modeledElementProps.id || modeledElementProps.id === core_common_1.IModel.rootSubjectId)
|
|
1072
1132
|
throw new core_common_1.IModelError(core_bentley_1.IModelStatus.NotFound, "Root subject does not have a sub-model");
|
|
1073
1133
|
return this.getModel(modeledElementProps.id, modelClass);
|
|
1074
1134
|
}
|
|
@@ -1081,7 +1141,7 @@ IModelDb.maxLimit = 10000; // maximum limit for batching queries
|
|
|
1081
1141
|
*/
|
|
1082
1142
|
tryGetSubModel(modeledElementId, modelClass) {
|
|
1083
1143
|
const modeledElementProps = this._iModel.elements.tryGetElementProps(modeledElementId);
|
|
1084
|
-
if (
|
|
1144
|
+
if (undefined === (modeledElementProps === null || modeledElementProps === void 0 ? void 0 : modeledElementProps.id) || (core_common_1.IModel.rootSubjectId === modeledElementProps.id))
|
|
1085
1145
|
return undefined;
|
|
1086
1146
|
return this.tryGetModel(modeledElementProps.id, modelClass);
|
|
1087
1147
|
}
|
|
@@ -1098,7 +1158,7 @@ IModelDb.maxLimit = 10000; // maximum limit for batching queries
|
|
|
1098
1158
|
*/
|
|
1099
1159
|
insertModel(props) {
|
|
1100
1160
|
try {
|
|
1101
|
-
return props.id = this._iModel.nativeDb.insertModel(props
|
|
1161
|
+
return props.id = this._iModel.nativeDb.insertModel(props);
|
|
1102
1162
|
}
|
|
1103
1163
|
catch (err) {
|
|
1104
1164
|
throw new core_common_1.IModelError(err.errorNumber, `Error inserting model [${err.message}], class=${props.classFullName}`);
|
|
@@ -1110,7 +1170,7 @@ IModelDb.maxLimit = 10000; // maximum limit for batching queries
|
|
|
1110
1170
|
*/
|
|
1111
1171
|
updateModel(props) {
|
|
1112
1172
|
try {
|
|
1113
|
-
this._iModel.nativeDb.updateModel(props
|
|
1173
|
+
this._iModel.nativeDb.updateModel(props);
|
|
1114
1174
|
}
|
|
1115
1175
|
catch (err) {
|
|
1116
1176
|
throw new core_common_1.IModelError(err.errorNumber, `error updating model [${err.message}] id=${props.id}`);
|
|
@@ -1227,20 +1287,16 @@ IModelDb.maxLimit = 10000; // maximum limit for batching queries
|
|
|
1227
1287
|
* @see getElement
|
|
1228
1288
|
*/
|
|
1229
1289
|
tryGetElement(elementId, elementClass) {
|
|
1230
|
-
if (typeof elementId === "string")
|
|
1290
|
+
if (typeof elementId === "string")
|
|
1231
1291
|
elementId = core_bentley_1.Id64.isId64(elementId) ? { id: elementId } : { federationGuid: elementId };
|
|
1232
|
-
|
|
1233
|
-
else if (elementId instanceof core_common_1.Code) {
|
|
1292
|
+
else if (elementId instanceof core_common_1.Code)
|
|
1234
1293
|
elementId = { code: elementId };
|
|
1235
|
-
}
|
|
1236
1294
|
const elementProps = this.tryGetElementJson(elementId);
|
|
1237
|
-
if (undefined === elementProps)
|
|
1295
|
+
if (undefined === elementProps)
|
|
1238
1296
|
return undefined; // no Element with that elementId found
|
|
1239
|
-
}
|
|
1240
1297
|
const element = this._iModel.constructEntity(elementProps);
|
|
1241
|
-
if (undefined === elementClass)
|
|
1298
|
+
if (undefined === elementClass)
|
|
1242
1299
|
return element; // elementClass was not specified, cannot call instanceof to validate
|
|
1243
|
-
}
|
|
1244
1300
|
return element instanceof elementClass ? element : undefined;
|
|
1245
1301
|
}
|
|
1246
1302
|
/** Query for the Id of the element that has a specified code.
|
|
@@ -1292,7 +1348,7 @@ IModelDb.maxLimit = 10000; // maximum limit for batching queries
|
|
|
1292
1348
|
*/
|
|
1293
1349
|
insertElement(elProps) {
|
|
1294
1350
|
try {
|
|
1295
|
-
return elProps.id = this._iModel.nativeDb.insertElement(elProps
|
|
1351
|
+
return elProps.id = this._iModel.nativeDb.insertElement(elProps);
|
|
1296
1352
|
}
|
|
1297
1353
|
catch (err) {
|
|
1298
1354
|
throw new core_common_1.IModelError(err.errorNumber, `insertElement with class=${elProps.classFullName}: ${err.message}`);
|
|
@@ -1307,7 +1363,7 @@ IModelDb.maxLimit = 10000; // maximum limit for batching queries
|
|
|
1307
1363
|
*/
|
|
1308
1364
|
updateElement(elProps) {
|
|
1309
1365
|
try {
|
|
1310
|
-
this._iModel.nativeDb.updateElement(elProps
|
|
1366
|
+
this._iModel.nativeDb.updateElement(elProps);
|
|
1311
1367
|
}
|
|
1312
1368
|
catch (err) {
|
|
1313
1369
|
throw new core_common_1.IModelError(err.errorNumber, `Error updating element [${err.message}], id:${elProps.id}`);
|
|
@@ -1760,6 +1816,7 @@ IModelDb.maxLimit = 10000; // maximum limit for batching queries
|
|
|
1760
1816
|
if (undefined !== ret.error) {
|
|
1761
1817
|
throw new core_common_1.IModelError(ret.error.status, `TreeId=${treeId} TileId=${tileId}`);
|
|
1762
1818
|
}
|
|
1819
|
+
(0, core_bentley_1.assert)(undefined !== ret.result);
|
|
1763
1820
|
return ret.result;
|
|
1764
1821
|
}
|
|
1765
1822
|
}
|
|
@@ -1789,8 +1846,11 @@ class BriefcaseDb extends IModelDb {
|
|
|
1789
1846
|
const db = super.tryFindByKey(key);
|
|
1790
1847
|
return (db === null || db === void 0 ? void 0 : db.isBriefcaseDb()) ? db : undefined;
|
|
1791
1848
|
}
|
|
1792
|
-
/**
|
|
1793
|
-
|
|
1849
|
+
/**
|
|
1850
|
+
* The Guid that identifies the *context* that owns this iModel.
|
|
1851
|
+
* GuidString | undefined for the superclass, but required for BriefcaseDb
|
|
1852
|
+
* */
|
|
1853
|
+
get iTwinId() { return super.iTwinId; } // eslint-disable-line @typescript-eslint/no-non-null-assertion
|
|
1794
1854
|
/**
|
|
1795
1855
|
* Determine whether this BriefcaseDb should use a lock server.
|
|
1796
1856
|
* All must be true:
|
|
@@ -1919,6 +1979,7 @@ class DaemonReattach {
|
|
|
1919
1979
|
core_bentley_1.Logger.logInfo(BackendLoggerCategory_1.BackendLoggerCategory.Authorization, "attempting to reattach checkpoint");
|
|
1920
1980
|
try {
|
|
1921
1981
|
// this exchanges the supplied user accessToken for an expiring blob-store token to read the checkpoint.
|
|
1982
|
+
(0, core_bentley_1.assert)(undefined !== iModel.iTwinId);
|
|
1922
1983
|
const response = await CheckpointManager_1.V2CheckpointManager.attach({ accessToken, iTwinId: iModel.iTwinId, iModelId: iModel.iModelId, changeset: iModel.changeset });
|
|
1923
1984
|
core_bentley_1.Logger.logInfo(BackendLoggerCategory_1.BackendLoggerCategory.Authorization, "reattached checkpoint successfully");
|
|
1924
1985
|
this.setTimestamp(response.expiryTimestamp);
|
|
@@ -2012,6 +2073,7 @@ class SnapshotDb extends IModelDb {
|
|
|
2012
2073
|
static openForApplyChangesets(path, props) {
|
|
2013
2074
|
const file = { path, key: props === null || props === void 0 ? void 0 : props.key };
|
|
2014
2075
|
const nativeDb = this.openDgnDb(file, core_bentley_1.OpenMode.ReadWrite, undefined, props);
|
|
2076
|
+
(0, core_bentley_1.assert)(undefined !== file.key);
|
|
2015
2077
|
return new SnapshotDb(nativeDb, file.key);
|
|
2016
2078
|
}
|
|
2017
2079
|
/** Open a read-only iModel *snapshot*.
|
|
@@ -2023,6 +2085,7 @@ class SnapshotDb extends IModelDb {
|
|
|
2023
2085
|
static openFile(path, opts) {
|
|
2024
2086
|
const file = { path, key: opts === null || opts === void 0 ? void 0 : opts.key };
|
|
2025
2087
|
const nativeDb = this.openDgnDb(file, core_bentley_1.OpenMode.Readonly, undefined, opts);
|
|
2088
|
+
(0, core_bentley_1.assert)(undefined !== file.key);
|
|
2026
2089
|
return new SnapshotDb(nativeDb, file.key);
|
|
2027
2090
|
}
|
|
2028
2091
|
/** Open a previously downloaded V1 checkpoint file.
|
|
@@ -2149,6 +2212,7 @@ class StandaloneDb extends BriefcaseDb {
|
|
|
2149
2212
|
const iTwinId = nativeDb.getITwinId();
|
|
2150
2213
|
if (iTwinId !== core_bentley_1.Guid.empty) // a "standalone" iModel means it is not associated with an iTwin
|
|
2151
2214
|
throw new core_common_1.IModelError(core_bentley_1.IModelStatus.WrongIModel, `${filePath} is not a Standalone iModel. iTwinId=${iTwinId}`);
|
|
2215
|
+
(0, core_bentley_1.assert)(undefined !== file.key);
|
|
2152
2216
|
return new StandaloneDb({ nativeDb, key: file.key, openMode, briefcaseId: core_common_1.BriefcaseIdValue.Unassigned });
|
|
2153
2217
|
}
|
|
2154
2218
|
catch (error) {
|