@itwin/core-backend 4.8.0-dev.4 → 4.8.0-dev.41
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 +62 -1
- package/lib/cjs/BackendHubAccess.d.ts +18 -16
- package/lib/cjs/BackendHubAccess.d.ts.map +1 -1
- package/lib/cjs/BackendHubAccess.js +16 -15
- package/lib/cjs/BackendHubAccess.js.map +1 -1
- package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
- package/lib/cjs/BriefcaseManager.js +19 -11
- package/lib/cjs/BriefcaseManager.js.map +1 -1
- package/lib/cjs/Category.d.ts +0 -6
- package/lib/cjs/Category.d.ts.map +1 -1
- package/lib/cjs/Category.js +0 -6
- package/lib/cjs/Category.js.map +1 -1
- package/lib/cjs/ChangeSummaryManager.d.ts.map +1 -1
- package/lib/cjs/ChangeSummaryManager.js +11 -9
- package/lib/cjs/ChangeSummaryManager.js.map +1 -1
- package/lib/cjs/ChangedElementsDb.d.ts +1 -0
- package/lib/cjs/ChangedElementsDb.d.ts.map +1 -1
- package/lib/cjs/ChangedElementsDb.js +6 -4
- package/lib/cjs/ChangedElementsDb.js.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.d.ts.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.js +26 -21
- package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
- package/lib/cjs/ChannelControl.d.ts +4 -26
- package/lib/cjs/ChannelControl.d.ts.map +1 -1
- package/lib/cjs/ChannelControl.js +2 -101
- package/lib/cjs/ChannelControl.js.map +1 -1
- package/lib/cjs/CheckpointManager.d.ts.map +1 -1
- package/lib/cjs/CheckpointManager.js +5 -3
- package/lib/cjs/CheckpointManager.js.map +1 -1
- package/lib/cjs/ClassRegistry.d.ts.map +1 -1
- package/lib/cjs/ClassRegistry.js +3 -2
- package/lib/cjs/ClassRegistry.js.map +1 -1
- package/lib/cjs/CloudSqlite.d.ts +28 -11
- package/lib/cjs/CloudSqlite.d.ts.map +1 -1
- package/lib/cjs/CloudSqlite.js +42 -1
- package/lib/cjs/CloudSqlite.js.map +1 -1
- package/lib/cjs/DevTools.d.ts.map +1 -1
- package/lib/cjs/DevTools.js +2 -1
- package/lib/cjs/DevTools.js.map +1 -1
- package/lib/cjs/DisplayStyle.d.ts +0 -3
- package/lib/cjs/DisplayStyle.d.ts.map +1 -1
- package/lib/cjs/DisplayStyle.js +0 -3
- package/lib/cjs/DisplayStyle.js.map +1 -1
- package/lib/cjs/ECDb.d.ts +6 -1
- package/lib/cjs/ECDb.d.ts.map +1 -1
- package/lib/cjs/ECDb.js +19 -14
- package/lib/cjs/ECDb.js.map +1 -1
- package/lib/cjs/ECSchemaXmlContext.js +2 -2
- package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
- package/lib/cjs/ECSqlStatement.d.ts +6 -3
- package/lib/cjs/ECSqlStatement.d.ts.map +1 -1
- package/lib/cjs/ECSqlStatement.js +3 -3
- package/lib/cjs/ECSqlStatement.js.map +1 -1
- package/lib/cjs/Element.d.ts +3 -60
- package/lib/cjs/Element.d.ts.map +1 -1
- package/lib/cjs/Element.js +8 -64
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/ElementAspect.d.ts +0 -5
- package/lib/cjs/ElementAspect.d.ts.map +1 -1
- package/lib/cjs/ElementAspect.js +4 -8
- package/lib/cjs/ElementAspect.js.map +1 -1
- package/lib/cjs/ElementGraphics.d.ts.map +1 -1
- package/lib/cjs/ElementGraphics.js +2 -1
- package/lib/cjs/ElementGraphics.js.map +1 -1
- package/lib/cjs/ElementTreeWalker.d.ts +19 -0
- package/lib/cjs/ElementTreeWalker.d.ts.map +1 -1
- package/lib/cjs/ElementTreeWalker.js +23 -9
- package/lib/cjs/ElementTreeWalker.js.map +1 -1
- package/lib/cjs/GeoCoordConfig.d.ts.map +1 -1
- package/lib/cjs/GeoCoordConfig.js +2 -1
- package/lib/cjs/GeoCoordConfig.js.map +1 -1
- package/lib/cjs/GeographicCRSServices.js +2 -2
- package/lib/cjs/GeographicCRSServices.js.map +1 -1
- package/lib/cjs/GeometrySummary.d.ts.map +1 -1
- package/lib/cjs/GeometrySummary.js +2 -1
- package/lib/cjs/GeometrySummary.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +25 -95
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +192 -142
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/IModelElementCloneContext.d.ts.map +1 -1
- package/lib/cjs/IModelElementCloneContext.js +5 -4
- package/lib/cjs/IModelElementCloneContext.js.map +1 -1
- package/lib/cjs/IModelHost.d.ts +5 -3
- package/lib/cjs/IModelHost.d.ts.map +1 -1
- package/lib/cjs/IModelHost.js +16 -18
- package/lib/cjs/IModelHost.js.map +1 -1
- package/lib/cjs/IpcHost.d.ts.map +1 -1
- package/lib/cjs/IpcHost.js +15 -13
- package/lib/cjs/IpcHost.js.map +1 -1
- package/lib/cjs/LocalHub.d.ts +2 -2
- package/lib/cjs/LocalHub.d.ts.map +1 -1
- package/lib/cjs/LocalHub.js +17 -17
- package/lib/cjs/LocalHub.js.map +1 -1
- package/lib/cjs/LockControl.d.ts +73 -0
- package/lib/cjs/LockControl.d.ts.map +1 -0
- package/lib/cjs/LockControl.js +11 -0
- package/lib/cjs/LockControl.js.map +1 -0
- package/lib/cjs/Material.d.ts +2 -5
- package/lib/cjs/Material.d.ts.map +1 -1
- package/lib/cjs/Material.js +6 -4
- package/lib/cjs/Material.js.map +1 -1
- package/lib/cjs/Model.d.ts +0 -22
- package/lib/cjs/Model.d.ts.map +1 -1
- package/lib/cjs/Model.js +5 -26
- package/lib/cjs/Model.js.map +1 -1
- package/lib/cjs/Relationship.d.ts +0 -12
- package/lib/cjs/Relationship.d.ts.map +1 -1
- package/lib/cjs/Relationship.js +5 -16
- package/lib/cjs/Relationship.js.map +1 -1
- package/lib/cjs/SQLiteDb.d.ts +6 -1
- package/lib/cjs/SQLiteDb.d.ts.map +1 -1
- package/lib/cjs/SQLiteDb.js +23 -16
- package/lib/cjs/SQLiteDb.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 +24 -11
- package/lib/cjs/SchemaSync.js.map +1 -1
- package/lib/cjs/SchemaUtils.js +3 -3
- package/lib/cjs/SchemaUtils.js.map +1 -1
- package/lib/cjs/SqliteChangesetReader.d.ts.map +1 -1
- package/lib/cjs/SqliteChangesetReader.js +2 -2
- package/lib/cjs/SqliteChangesetReader.js.map +1 -1
- package/lib/cjs/SqliteStatement.js +2 -2
- package/lib/cjs/SqliteStatement.js.map +1 -1
- package/lib/cjs/TextAnnotationGeometry.d.ts +1 -1
- package/lib/cjs/TextAnnotationGeometry.d.ts.map +1 -1
- package/lib/cjs/TextAnnotationGeometry.js +9 -5
- package/lib/cjs/TextAnnotationGeometry.js.map +1 -1
- package/lib/cjs/TextAnnotationLayout.d.ts.map +1 -1
- package/lib/cjs/TextAnnotationLayout.js +18 -5
- package/lib/cjs/TextAnnotationLayout.js.map +1 -1
- package/lib/cjs/TxnManager.d.ts +2 -1
- package/lib/cjs/TxnManager.d.ts.map +1 -1
- package/lib/cjs/TxnManager.js +4 -2
- package/lib/cjs/TxnManager.js.map +1 -1
- package/lib/cjs/ViewDefinition.d.ts +1 -18
- package/lib/cjs/ViewDefinition.d.ts.map +1 -1
- package/lib/cjs/ViewDefinition.js +1 -18
- package/lib/cjs/ViewDefinition.js.map +1 -1
- package/lib/cjs/ViewStore.d.ts.map +1 -1
- package/lib/cjs/ViewStore.js +6 -5
- package/lib/cjs/ViewStore.js.map +1 -1
- package/lib/cjs/core-backend.d.ts +2 -1
- package/lib/cjs/core-backend.d.ts.map +1 -1
- package/lib/cjs/core-backend.js +3 -5
- package/lib/cjs/core-backend.js.map +1 -1
- package/lib/cjs/domains/FunctionalElements.d.ts +0 -10
- package/lib/cjs/domains/FunctionalElements.d.ts.map +1 -1
- package/lib/cjs/domains/FunctionalElements.js +0 -10
- package/lib/cjs/domains/FunctionalElements.js.map +1 -1
- package/lib/cjs/domains/FunctionalSchema.d.ts.map +1 -1
- package/lib/cjs/domains/FunctionalSchema.js +2 -1
- package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
- package/lib/cjs/domains/GenericElements.d.ts +0 -18
- package/lib/cjs/domains/GenericElements.d.ts.map +1 -1
- package/lib/cjs/domains/GenericElements.js +0 -18
- package/lib/cjs/domains/GenericElements.js.map +1 -1
- package/lib/cjs/internal/ChangesetConflictArgs.d.ts +24 -0
- package/lib/cjs/internal/ChangesetConflictArgs.d.ts.map +1 -0
- package/lib/cjs/internal/ChangesetConflictArgs.js +7 -0
- package/lib/cjs/internal/ChangesetConflictArgs.js.map +1 -0
- package/lib/cjs/internal/ChannelAdmin.d.ts +34 -0
- package/lib/cjs/internal/ChannelAdmin.d.ts.map +1 -0
- package/lib/cjs/internal/ChannelAdmin.js +117 -0
- package/lib/cjs/internal/ChannelAdmin.js.map +1 -0
- package/lib/cjs/internal/NativePlatform.d.ts +15 -0
- package/lib/cjs/internal/NativePlatform.d.ts.map +1 -0
- package/lib/cjs/internal/NativePlatform.js +49 -0
- package/lib/cjs/internal/NativePlatform.js.map +1 -0
- package/lib/cjs/internal/NoLocks.d.ts +6 -0
- package/lib/cjs/internal/NoLocks.d.ts.map +1 -0
- package/lib/cjs/internal/NoLocks.js +31 -0
- package/lib/cjs/internal/NoLocks.js.map +1 -0
- package/lib/cjs/{ServerBasedLocks.d.ts → internal/ServerBasedLocks.d.ts} +10 -16
- package/lib/cjs/internal/ServerBasedLocks.d.ts.map +1 -0
- package/lib/cjs/{ServerBasedLocks.js → internal/ServerBasedLocks.js} +29 -18
- package/lib/cjs/internal/ServerBasedLocks.js.map +1 -0
- package/lib/cjs/internal/Symbols.d.ts +11 -0
- package/lib/cjs/internal/Symbols.d.ts.map +1 -0
- package/lib/cjs/internal/Symbols.js +21 -0
- package/lib/cjs/internal/Symbols.js.map +1 -0
- package/lib/cjs/internal/cross-package.d.ts +4 -0
- package/lib/cjs/internal/cross-package.d.ts.map +1 -0
- package/lib/cjs/internal/cross-package.js +16 -0
- package/lib/cjs/internal/cross-package.js.map +1 -0
- package/lib/cjs/internal/workspace/SettingsImpl.d.ts +2 -2
- package/lib/cjs/internal/workspace/SettingsImpl.d.ts.map +1 -1
- package/lib/cjs/internal/workspace/SettingsImpl.js +3 -3
- package/lib/cjs/internal/workspace/SettingsImpl.js.map +1 -1
- package/lib/cjs/internal/workspace/SettingsSchemasImpl.js +2 -2
- package/lib/cjs/internal/workspace/SettingsSchemasImpl.js.map +1 -1
- package/lib/cjs/internal/workspace/WorkspaceImpl.js +14 -14
- 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/tracing.d.ts.map +1 -1
- package/lib/cjs/rpc/tracing.js +5 -2
- package/lib/cjs/rpc/tracing.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +1 -0
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +9 -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 +5 -3
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
- package/lib/cjs/workspace/Settings.d.ts +3 -3
- package/lib/cjs/workspace/Settings.d.ts.map +1 -1
- package/lib/cjs/workspace/Settings.js +1 -1
- package/lib/cjs/workspace/Settings.js.map +1 -1
- package/lib/cjs/workspace/SettingsSchemas.d.ts +2 -2
- package/lib/cjs/workspace/SettingsSchemas.d.ts.map +1 -1
- package/lib/cjs/workspace/SettingsSchemas.js +1 -1
- package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
- package/lib/cjs/workspace/Workspace.d.ts +4 -4
- package/lib/cjs/workspace/Workspace.d.ts.map +1 -1
- package/lib/cjs/workspace/Workspace.js +1 -1
- package/lib/cjs/workspace/Workspace.js.map +1 -1
- package/lib/cjs/workspace/WorkspaceEditor.d.ts +2 -2
- package/lib/cjs/workspace/WorkspaceEditor.d.ts.map +1 -1
- package/lib/cjs/workspace/WorkspaceEditor.js +1 -1
- package/lib/cjs/workspace/WorkspaceEditor.js.map +1 -1
- package/package.json +15 -14
- package/lib/cjs/ServerBasedLocks.d.ts.map +0 -1
- package/lib/cjs/ServerBasedLocks.js.map +0 -1
- package/lib/cjs/internal/ImplementationProhibited.d.ts +0 -44
- package/lib/cjs/internal/ImplementationProhibited.d.ts.map +0 -1
- package/lib/cjs/internal/ImplementationProhibited.js +0 -51
- package/lib/cjs/internal/ImplementationProhibited.js.map +0 -1
package/lib/cjs/ECDb.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { IModelJsNative } from "@bentley/imodeljs-native";
|
|
|
6
6
|
import { ECSchemaProps, ECSqlReader, QueryBinder, QueryOptions } from "@itwin/core-common";
|
|
7
7
|
import { ECSqlStatement } from "./ECSqlStatement";
|
|
8
8
|
import { SqliteStatement } from "./SqliteStatement";
|
|
9
|
+
import { _nativeDb } from "./internal/Symbols";
|
|
9
10
|
/** Modes for how to open [ECDb]($backend) files.
|
|
10
11
|
* @public
|
|
11
12
|
*/
|
|
@@ -139,8 +140,12 @@ export declare class ECDb implements IDisposable {
|
|
|
139
140
|
* @internal
|
|
140
141
|
*/
|
|
141
142
|
prepareSqliteStatement(sql: string, logErrors?: boolean): SqliteStatement;
|
|
142
|
-
/** @internal
|
|
143
|
+
/** @internal
|
|
144
|
+
* @deprecated in 4.8. This internal API will be removed in 5.0. Use ECDb's public API instead.
|
|
145
|
+
*/
|
|
143
146
|
get nativeDb(): IModelJsNative.ECDb;
|
|
147
|
+
/** @internal */
|
|
148
|
+
get [_nativeDb](): IModelJsNative.ECDb;
|
|
144
149
|
/** Allow to execute query and read results along with meta data. The result are streamed.
|
|
145
150
|
*
|
|
146
151
|
* See also:
|
package/lib/cjs/ECDb.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ECDb.d.ts","sourceRoot":"","sources":["../../src/ECDb.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,EAAoB,WAAW,EAAoB,MAAM,qBAAqB,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAkB,aAAa,EAAE,WAAW,EAAe,WAAW,EAAE,YAAY,EAAuB,MAAM,oBAAoB,CAAC;AAG7I,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,eAAe,EAAkB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"ECDb.d.ts","sourceRoot":"","sources":["../../src/ECDb.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,EAAoB,WAAW,EAAoB,MAAM,qBAAqB,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAkB,aAAa,EAAE,WAAW,EAAe,WAAW,EAAE,YAAY,EAAuB,MAAM,oBAAoB,CAAC;AAG7I,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,eAAe,EAAkB,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI/C;;GAEG;AACH,oBAAY,YAAY;IACtB,QAAQ,IAAA;IACR,SAAS,IAAA;IACT,sGAAsG;IACtG,WAAW,IAAA;CACZ;AAED;;GAEG;AACH,qBAAa,IAAK,YAAW,WAAW;IACtC,OAAO,CAAC,SA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C,IAAI,EAAE,eAAe,KAAK,CAAC,EAAE,SAAS,UAAO,GAAG,CAAC;IAiB/G;;;;;;;;;OASG;IACI,mBAAmB,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,CAAC,EAAE,SAAS,UAAO,GAAG,CAAC;IAiBvG;;;;;OAKG;IACI,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,UAAO,GAAG,eAAe;IAM7E;;OAEG;IACH,IAAW,QAAQ,IAAI,cAAc,CAAC,IAAI,CAA4B;IAEtE,gBAAgB;IAChB,IAAW,CAAC,SAAS,CAAC,IAAI,cAAc,CAAC,IAAI,CAG5C;IAED;;;;;;;;;;;SAWK;IACE,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,WAAW;IAYjG;;;;;;;;;;;;;;;OAeG;IACY,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,qBAAqB,CAAC,GAAG,CAAC;IAM7G;;;;;;;;;;;;OAYG;IACU,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IAOhF;;;;;;;;;;;;;;;;;OAiBG;IACY,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,qBAAqB,CAAC,GAAG,CAAC;CAKpI"}
|
package/lib/cjs/ECDb.js
CHANGED
|
@@ -13,8 +13,9 @@ const core_common_1 = require("@itwin/core-common");
|
|
|
13
13
|
const BackendLoggerCategory_1 = require("./BackendLoggerCategory");
|
|
14
14
|
const ConcurrentQuery_1 = require("./ConcurrentQuery");
|
|
15
15
|
const ECSqlStatement_1 = require("./ECSqlStatement");
|
|
16
|
-
const
|
|
16
|
+
const NativePlatform_1 = require("./internal/NativePlatform");
|
|
17
17
|
const SqliteStatement_1 = require("./SqliteStatement");
|
|
18
|
+
const Symbols_1 = require("./internal/Symbols");
|
|
18
19
|
const loggerCategory = BackendLoggerCategory_1.BackendLoggerCategory.ECDb;
|
|
19
20
|
/** Modes for how to open [ECDb]($backend) files.
|
|
20
21
|
* @public
|
|
@@ -40,7 +41,7 @@ class ECDb {
|
|
|
40
41
|
constructor() {
|
|
41
42
|
this._statementCache = new SqliteStatement_1.StatementCache();
|
|
42
43
|
this._sqliteStatementCache = new SqliteStatement_1.StatementCache();
|
|
43
|
-
this._nativeDb = new
|
|
44
|
+
this._nativeDb = new NativePlatform_1.IModelNative.platform.ECDb();
|
|
44
45
|
}
|
|
45
46
|
/** Call this function when finished with this ECDb object. This releases the native resources held by the
|
|
46
47
|
* ECDb object.
|
|
@@ -57,7 +58,7 @@ class ECDb {
|
|
|
57
58
|
* @throws [IModelError]($common) if the operation failed.
|
|
58
59
|
*/
|
|
59
60
|
createDb(pathName) {
|
|
60
|
-
const status = this.
|
|
61
|
+
const status = this[Symbols_1._nativeDb].createDb(pathName);
|
|
61
62
|
if (status !== core_bentley_1.DbResult.BE_SQLITE_OK)
|
|
62
63
|
throw new core_common_1.IModelError(status, "Failed to created ECDb");
|
|
63
64
|
}
|
|
@@ -69,19 +70,19 @@ class ECDb {
|
|
|
69
70
|
openDb(pathName, openMode = ECDbOpenMode.Readonly) {
|
|
70
71
|
const nativeOpenMode = openMode === ECDbOpenMode.Readonly ? core_bentley_1.OpenMode.Readonly : core_bentley_1.OpenMode.ReadWrite;
|
|
71
72
|
const tryUpgrade = openMode === ECDbOpenMode.FileUpgrade;
|
|
72
|
-
const status = this.
|
|
73
|
+
const status = this[Symbols_1._nativeDb].openDb(pathName, nativeOpenMode, tryUpgrade);
|
|
73
74
|
if (status !== core_bentley_1.DbResult.BE_SQLITE_OK)
|
|
74
75
|
throw new core_common_1.IModelError(status, "Failed to open ECDb");
|
|
75
76
|
}
|
|
76
77
|
/** Returns true if the ECDb is open */
|
|
77
|
-
get isOpen() { return this.
|
|
78
|
+
get isOpen() { return this[Symbols_1._nativeDb].isOpen(); }
|
|
78
79
|
/** Close the Db after saving any uncommitted changes.
|
|
79
80
|
* @throws [IModelError]($common) if the database is not open.
|
|
80
81
|
*/
|
|
81
82
|
closeDb() {
|
|
82
83
|
this._statementCache.clear();
|
|
83
84
|
this._sqliteStatementCache.clear();
|
|
84
|
-
this.
|
|
85
|
+
this[Symbols_1._nativeDb].closeDb();
|
|
85
86
|
}
|
|
86
87
|
/** @internal use to test statement caching */
|
|
87
88
|
clearStatementCache() {
|
|
@@ -96,7 +97,7 @@ class ECDb {
|
|
|
96
97
|
* @throws [IModelError]($common) if the database is not open or if the operation failed.
|
|
97
98
|
*/
|
|
98
99
|
saveChanges(changesetName) {
|
|
99
|
-
const status = this.
|
|
100
|
+
const status = this[Symbols_1._nativeDb].saveChanges(changesetName);
|
|
100
101
|
if (status !== core_bentley_1.DbResult.BE_SQLITE_OK)
|
|
101
102
|
throw new core_common_1.IModelError(status, "Failed to save changes");
|
|
102
103
|
}
|
|
@@ -104,7 +105,7 @@ class ECDb {
|
|
|
104
105
|
* @throws [IModelError]($common) if the database is not open or if the operation failed.
|
|
105
106
|
*/
|
|
106
107
|
abandonChanges() {
|
|
107
|
-
const status = this.
|
|
108
|
+
const status = this[Symbols_1._nativeDb].abandonChanges();
|
|
108
109
|
if (status !== core_bentley_1.DbResult.BE_SQLITE_OK)
|
|
109
110
|
throw new core_common_1.IModelError(status, "Failed to abandon changes");
|
|
110
111
|
}
|
|
@@ -115,7 +116,7 @@ class ECDb {
|
|
|
115
116
|
* @throws [IModelError]($common) if the database is not open or if the operation failed.
|
|
116
117
|
*/
|
|
117
118
|
importSchema(pathName) {
|
|
118
|
-
const status = this.
|
|
119
|
+
const status = this[Symbols_1._nativeDb].importSchema(pathName);
|
|
119
120
|
if (status !== core_bentley_1.DbResult.BE_SQLITE_OK) {
|
|
120
121
|
core_bentley_1.Logger.logError(loggerCategory, `Failed to import schema from '${pathName}'.`);
|
|
121
122
|
throw new core_common_1.IModelError(status, `Failed to import schema from '${pathName}'.`);
|
|
@@ -128,7 +129,7 @@ class ECDb {
|
|
|
128
129
|
* @throws if the schema can not be found or loaded.
|
|
129
130
|
*/
|
|
130
131
|
getSchemaProps(name) {
|
|
131
|
-
return this.
|
|
132
|
+
return this[Symbols_1._nativeDb].getSchemaProps(name);
|
|
132
133
|
}
|
|
133
134
|
/**
|
|
134
135
|
* Use a prepared ECSQL statement, potentially from the statement cache. If the requested statement doesn't exist
|
|
@@ -197,7 +198,7 @@ class ECDb {
|
|
|
197
198
|
*/
|
|
198
199
|
prepareStatement(ecsql, logErrors = true) {
|
|
199
200
|
const stmt = new ECSqlStatement_1.ECSqlStatement();
|
|
200
|
-
stmt.prepare(this.
|
|
201
|
+
stmt.prepare(this[Symbols_1._nativeDb], ecsql, logErrors);
|
|
201
202
|
return stmt;
|
|
202
203
|
}
|
|
203
204
|
/**
|
|
@@ -267,11 +268,15 @@ class ECDb {
|
|
|
267
268
|
*/
|
|
268
269
|
prepareSqliteStatement(sql, logErrors = true) {
|
|
269
270
|
const stmt = new SqliteStatement_1.SqliteStatement(sql);
|
|
270
|
-
stmt.prepare(this.
|
|
271
|
+
stmt.prepare(this[Symbols_1._nativeDb], logErrors);
|
|
271
272
|
return stmt;
|
|
272
273
|
}
|
|
274
|
+
/** @internal
|
|
275
|
+
* @deprecated in 4.8. This internal API will be removed in 5.0. Use ECDb's public API instead.
|
|
276
|
+
*/
|
|
277
|
+
get nativeDb() { return this[Symbols_1._nativeDb]; }
|
|
273
278
|
/** @internal */
|
|
274
|
-
get
|
|
279
|
+
get [Symbols_1._nativeDb]() {
|
|
275
280
|
(0, core_bentley_1.assert)(undefined !== this._nativeDb);
|
|
276
281
|
return this._nativeDb;
|
|
277
282
|
}
|
|
@@ -293,7 +298,7 @@ class ECDb {
|
|
|
293
298
|
}
|
|
294
299
|
const executor = {
|
|
295
300
|
execute: async (request) => {
|
|
296
|
-
return ConcurrentQuery_1.ConcurrentQuery.executeQueryRequest(this.
|
|
301
|
+
return ConcurrentQuery_1.ConcurrentQuery.executeQueryRequest(this[Symbols_1._nativeDb], request);
|
|
297
302
|
},
|
|
298
303
|
};
|
|
299
304
|
return new core_common_1.ECSqlReader(executor, ecsql, params, config);
|
package/lib/cjs/ECDb.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ECDb.js","sourceRoot":"","sources":["../../src/ECDb.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,sDAAsF;AAEtF,oDAA6I;AAC7I,mEAAgE;AAChE,uDAAoD;AACpD,qDAAkD;AAClD,6CAA0C;AAC1C,uDAAoE;AAEpE,MAAM,cAAc,GAAW,6CAAqB,CAAC,IAAI,CAAC;AAE1D;;GAEG;AACH,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,uDAAQ,CAAA;IACR,yDAAS,CAAA;IACT,sGAAsG;IACtG,6DAAW,CAAA;AACb,CAAC,EALW,YAAY,4BAAZ,YAAY,QAKvB;AAED;;GAEG;AACH,MAAa,IAAI;IAKf;;OAEG;IACI,gBAAgB,CAAC,IAAY;QAClC,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,CAAC;QACnC,IAAI,CAAC,qBAAqB,GAAG,IAAI,gCAAc,CAAkB,IAAI,CAAC,CAAC;IACzE,CAAC;IAED;QAXiB,oBAAe,GAAG,IAAI,gCAAc,EAAkB,CAAC;QAChE,0BAAqB,GAAG,IAAI,gCAAc,EAAmB,CAAC;QAWpE,IAAI,CAAC,SAAS,GAAG,IAAI,uBAAU,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;IAClD,CAAC;IACD;;OAEG;IACI,OAAO;QACZ,IAAI,CAAC,IAAI,CAAC,SAAS;YACjB,OAAO;QAET,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B,CAAC,OAAO,CAAC,CAAC;QACjD,MAAM,MAAM,GAAG,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;QAC3E,OAAO,MAAM,MAAM,CAAC,IAAI,EAAE;YACxB,MAAM,MAAM,CAAC,gBAAgB,EAAE,CAAC;IACpC,CAAC;IACD;;;;;;;;;;;;OAYG;IACI,KAAK,CAAC,aAAa,CAAC,KAAa,EAAE,MAAoB;QAC5D,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,IAAI,CAAC,iBAAiB,CAAC,yBAAyB,KAAK,GAAG,EAAE,MAAM,CAAC,EAAE,CAAC;YAC1F,OAAO,GAAG,CAAC,CAAC,CAAW,CAAC;QAC1B,CAAC;QACD,MAAM,IAAI,yBAAW,CAAC,uBAAQ,CAAC,eAAe,EAAE,yBAAyB,CAAC,CAAC;IAC7E,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACI,KAAK,CAAC,CAAE,YAAY,CAAC,KAAa,EAAE,KAAa,EAAE,MAAoB,EAAE,OAAsB;QACpG,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,iCAAmB,CAAC,OAAO,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,CAAC,EAAE,CAAC;YACpI,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;CACF;AA7VD,oBA6VC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module ECDb\r\n */\r\nimport { assert, DbResult, IDisposable, Logger, OpenMode } from \"@itwin/core-bentley\";\r\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\nimport { DbQueryRequest, ECSchemaProps, ECSqlReader, IModelError, QueryBinder, QueryOptions, QueryOptionsBuilder } from \"@itwin/core-common\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { ConcurrentQuery } from \"./ConcurrentQuery\";\r\nimport { ECSqlStatement } from \"./ECSqlStatement\";\r\nimport { IModelHost } from \"./IModelHost\";\r\nimport { SqliteStatement, StatementCache } from \"./SqliteStatement\";\r\n\r\nconst loggerCategory: string = BackendLoggerCategory.ECDb;\r\n\r\n/** Modes for how to open [ECDb]($backend) files.\r\n * @public\r\n */\r\nexport enum ECDbOpenMode {\r\n Readonly,\r\n ReadWrite,\r\n /** Opens the file read-write and upgrades the file if necessary to the latest file format version. */\r\n FileUpgrade,\r\n}\r\n\r\n/** An ECDb file\r\n * @public\r\n */\r\nexport class ECDb implements IDisposable {\r\n private _nativeDb?: IModelJsNative.ECDb;\r\n private readonly _statementCache = new StatementCache<ECSqlStatement>();\r\n private _sqliteStatementCache = new StatementCache<SqliteStatement>();\r\n\r\n /** only for tests\r\n * @internal\r\n */\r\n public resetSqliteCache(size: number) {\r\n this._sqliteStatementCache.clear();\r\n this._sqliteStatementCache = new StatementCache<SqliteStatement>(size);\r\n }\r\n\r\n constructor() {\r\n this._nativeDb = new IModelHost.platform.ECDb();\r\n }\r\n /** Call this function when finished with this ECDb object. This releases the native resources held by the\r\n * ECDb object.\r\n */\r\n public dispose(): void {\r\n if (!this._nativeDb)\r\n return;\r\n\r\n this.closeDb();\r\n this._nativeDb.dispose();\r\n this._nativeDb = undefined;\r\n }\r\n\r\n /** Create an ECDb\r\n * @param pathName The path to the ECDb file to create.\r\n * @throws [IModelError]($common) if the operation failed.\r\n */\r\n public createDb(pathName: string): void {\r\n const status: DbResult = this.nativeDb.createDb(pathName);\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to created ECDb\");\r\n }\r\n\r\n /** Open the ECDb.\r\n * @param pathName The path to the ECDb file to open\r\n * @param openMode Open mode\r\n * @throws [IModelError]($common) if the operation failed.\r\n */\r\n public openDb(pathName: string, openMode: ECDbOpenMode = ECDbOpenMode.Readonly): void {\r\n const nativeOpenMode: OpenMode = openMode === ECDbOpenMode.Readonly ? OpenMode.Readonly : OpenMode.ReadWrite;\r\n const tryUpgrade: boolean = openMode === ECDbOpenMode.FileUpgrade;\r\n const status: DbResult = this.nativeDb.openDb(pathName, nativeOpenMode, tryUpgrade);\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to open ECDb\");\r\n }\r\n\r\n /** Returns true if the ECDb is open */\r\n public get isOpen(): boolean { return this.nativeDb.isOpen(); }\r\n\r\n /** Close the Db after saving any uncommitted changes.\r\n * @throws [IModelError]($common) if the database is not open.\r\n */\r\n public closeDb(): void {\r\n this._statementCache.clear();\r\n this._sqliteStatementCache.clear();\r\n this.nativeDb.closeDb();\r\n }\r\n\r\n /** @internal use to test statement caching */\r\n public clearStatementCache() {\r\n this._statementCache.clear();\r\n }\r\n\r\n /** @internal use to test statement caching */\r\n public getCachedStatementCount() {\r\n return this._statementCache.size;\r\n }\r\n\r\n /** Commit the outermost transaction, writing changes to the file. Then, restart the transaction.\r\n * @param changesetName The name of the operation that generated these changes.\r\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\r\n */\r\n public saveChanges(changesetName?: string): void {\r\n const status: DbResult = this.nativeDb.saveChanges(changesetName);\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to save changes\");\r\n }\r\n\r\n /** Abandon (cancel) the outermost transaction, discarding all changes since last save. Then, restart the transaction.\r\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\r\n */\r\n public abandonChanges(): void {\r\n const status: DbResult = this.nativeDb.abandonChanges();\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to abandon changes\");\r\n }\r\n\r\n /** Import a schema.\r\n *\r\n * If the import was successful, the database is automatically saved to disk.\r\n * @param pathName Path to ECSchema XML file to import.\r\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\r\n */\r\n public importSchema(pathName: string): void {\r\n const status: DbResult = this.nativeDb.importSchema(pathName);\r\n if (status !== DbResult.BE_SQLITE_OK) {\r\n Logger.logError(loggerCategory, `Failed to import schema from '${pathName}'.`);\r\n throw new IModelError(status, `Failed to import schema from '${pathName}'.`);\r\n }\r\n }\r\n\r\n /**\r\n * Returns the full schema for the input name.\r\n * @param name The name of the schema e.g. 'ECDbMeta'\r\n * @returns The SchemaProps for the requested schema\r\n * @throws if the schema can not be found or loaded.\r\n */\r\n public getSchemaProps(name: string): ECSchemaProps {\r\n return this.nativeDb.getSchemaProps(name);\r\n }\r\n\r\n /**\r\n * Use a prepared ECSQL statement, potentially from the statement cache. If the requested statement doesn't exist\r\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\r\n * in the statement cache so it can be reused in the future. Use this method for ECSQL statements that will be\r\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\r\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withStatement]]\r\n * @public\r\n */\r\n public withPreparedStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors = true): T {\r\n const stmt = this._statementCache.findAndRemove(ecsql) ?? this.prepareStatement(ecsql, logErrors);\r\n const release = () => this._statementCache.addOrDispose(stmt);\r\n try {\r\n const val = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Prepared and execute a callback on an ECSQL statement. After the callback completes the statement is disposed.\r\n * Use this method for ECSQL statements are either not expected to be reused, or are not expensive to prepare.\r\n * For statements that will be reused often, instead use [[withPreparedStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withPreparedStatement]]\r\n * @public\r\n */\r\n public withStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors = true): T {\r\n const stmt = this.prepareStatement(ecsql, logErrors);\r\n const release = () => stmt.dispose();\r\n try {\r\n const val = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /** Prepare an ECSQL statement.\r\n * @param ecsql The ECSQL statement to prepare\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @throws [IModelError]($common) if there is a problem preparing the statement.\r\n */\r\n public prepareStatement(ecsql: string, logErrors = true): ECSqlStatement {\r\n const stmt = new ECSqlStatement();\r\n stmt.prepare(this.nativeDb, ecsql, logErrors);\r\n return stmt;\r\n }\r\n\r\n /**\r\n * Use a prepared SQL statement, potentially from the statement cache. If the requested statement doesn't exist\r\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\r\n * in the statement cache so it can be reused in the future. Use this method for SQL statements that will be\r\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\r\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withSqliteStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withPreparedStatement]]\r\n * @public\r\n */\r\n public withPreparedSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors = true): T {\r\n const stmt = this._sqliteStatementCache.findAndRemove(sql) ?? this.prepareSqliteStatement(sql, logErrors);\r\n const release = () => this._sqliteStatementCache.addOrDispose(stmt);\r\n try {\r\n const val: T = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Prepared and execute a callback on a SQL statement. After the callback completes the statement is disposed.\r\n * Use this method for SQL statements are either not expected to be reused, or are not expensive to prepare.\r\n * For statements that will be reused often, instead use [[withPreparedSqliteStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @public\r\n */\r\n public withSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors = true): T {\r\n const stmt = this.prepareSqliteStatement(sql, logErrors);\r\n const release = () => stmt.dispose();\r\n try {\r\n const val: T = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /** Prepare an SQL statement.\r\n * @param sql The SQLite SQL statement to prepare\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @throws [IModelError]($common) if there is a problem preparing the statement.\r\n * @internal\r\n */\r\n public prepareSqliteStatement(sql: string, logErrors = true): SqliteStatement {\r\n const stmt = new SqliteStatement(sql);\r\n stmt.prepare(this.nativeDb, logErrors);\r\n return stmt;\r\n }\r\n\r\n /** @internal */\r\n public get nativeDb(): IModelJsNative.ECDb {\r\n assert(undefined !== this._nativeDb);\r\n return this._nativeDb;\r\n }\r\n\r\n /** Allow to execute query and read results along with meta data. The result are streamed.\r\n *\r\n * See also:\r\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\r\n * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)\r\n * - [ECSQL Row Format]($docs/learning/ECSQLRowFormat)\r\n *\r\n * @param params The values to bind to the parameters (if the ECSQL has any).\r\n * @param config Allow to specify certain flags which control how query is executed.\r\n * @returns Returns an [ECSqlReader]($common) which helps iterate over the result set and also give access to metadata.\r\n * @public\r\n * */\r\n public createQueryReader(ecsql: string, params?: QueryBinder, config?: QueryOptions): ECSqlReader {\r\n if (!this._nativeDb || !this._nativeDb.isOpen()) {\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"db not open\");\r\n }\r\n const executor = {\r\n execute: async (request: DbQueryRequest) => {\r\n return ConcurrentQuery.executeQueryRequest(this.nativeDb, request);\r\n },\r\n };\r\n return new ECSqlReader(executor, ecsql, params, config);\r\n }\r\n\r\n /** Execute a query and stream its results\r\n * The result of the query is async iterator over the rows. The iterator will get next page automatically once rows in current page has been read.\r\n * [ECSQL row]($docs/learning/ECSQLRowFormat).\r\n *\r\n * See also:\r\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\r\n * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)\r\n *\r\n * @param ecsql The ECSQL statement to execute\r\n * @param params The values to bind to the parameters (if the ECSQL has any).\r\n * @param options Allow to specify certain flags which control how query is executed.\r\n * @returns Returns the query result as an *AsyncIterableIterator<any>* which lazy load result as needed. The row format is determined by *rowFormat* parameter.\r\n * See [ECSQL row format]($docs/learning/ECSQLRowFormat) for details about the format of the returned rows.\r\n * @throws [IModelError]($common) If there was any error while submitting, preparing or stepping into query\r\n * @deprecated in 3.7. Use [[createQueryReader]] instead; it accepts the same parameters.\r\n */\r\n public async * query(ecsql: string, params?: QueryBinder, options?: QueryOptions): AsyncIterableIterator<any> {\r\n const builder = new QueryOptionsBuilder(options);\r\n const reader = this.createQueryReader(ecsql, params, builder.getOptions());\r\n while (await reader.step())\r\n yield reader.formatCurrentRow();\r\n }\r\n /** Compute number of rows that would be returned by the ECSQL.\r\n *\r\n * See also:\r\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\r\n * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)\r\n *\r\n * @param ecsql The ECSQL statement to execute\r\n * @param params The values to bind to the parameters (if the ECSQL has any).\r\n * See \"[iTwin.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)\" for details.\r\n * @returns Return row count.\r\n * @throws [IModelError]($common) If the statement is invalid\r\n * @deprecated in 3.7. Count the number of results using `count(*)` where the original query is a subquery instead. E.g., `SELECT count(*) FROM (<query-whose-rows-to-count>)`.\r\n */\r\n public async queryRowCount(ecsql: string, params?: QueryBinder): Promise<number> {\r\n for await (const row of this.createQueryReader(`SELECT count(*) FROM (${ecsql})`, params)) {\r\n return row[0] as number;\r\n }\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Failed to get row count\");\r\n }\r\n\r\n /** Cancel any previous query with same token and run execute the current specified query.\r\n * The result of the query is async iterator over the rows. The iterator will get next page automatically once rows in current page has been read.\r\n * [ECSQL row]($docs/learning/ECSQLRowFormat).\r\n *\r\n * See also:\r\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\r\n * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)\r\n *\r\n * @param ecsql The ECSQL statement to execute\r\n * @param token None empty restart token. The previous query with same token would be cancelled. This would cause\r\n * exception which user code must handle.\r\n * @param params The values to bind to the parameters (if the ECSQL has any).\r\n * @param options Allow to specify certain flags which control how query is executed.\r\n * @returns Returns the query result as an *AsyncIterableIterator<any>* which lazy load result as needed. The row format is determined by *rowFormat* parameter.\r\n * See [ECSQL row format]($docs/learning/ECSQLRowFormat) for details about the format of the returned rows.\r\n * @throws [IModelError]($common) If there was any error while submitting, preparing or stepping into query\r\n * @deprecated in 3.7. Use [[createQueryReader]] instead. Pass in the restart token as part of the `config` argument; e.g., `{ restartToken: myToken }` or `new QueryOptionsBuilder().setRestartToken(myToken).getOptions()`.\r\n */\r\n public async * restartQuery(token: string, ecsql: string, params?: QueryBinder, options?: QueryOptions): AsyncIterableIterator<any> {\r\n for await (const row of this.createQueryReader(ecsql, params, new QueryOptionsBuilder(options).setRestartToken(token).getOptions())) {\r\n yield row;\r\n }\r\n }\r\n}\r\n"]}
|
|
1
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CAAC,IAAI,EAAE;YACxB,MAAM,MAAM,CAAC,gBAAgB,EAAE,CAAC;IACpC,CAAC;IACD;;;;;;;;;;;;OAYG;IACI,KAAK,CAAC,aAAa,CAAC,KAAa,EAAE,MAAoB;QAC5D,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,IAAI,CAAC,iBAAiB,CAAC,yBAAyB,KAAK,GAAG,EAAE,MAAM,CAAC,EAAE,CAAC;YAC1F,OAAO,GAAG,CAAC,CAAC,CAAW,CAAC;QAC1B,CAAC;QACD,MAAM,IAAI,yBAAW,CAAC,uBAAQ,CAAC,eAAe,EAAE,yBAAyB,CAAC,CAAC;IAC7E,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACI,KAAK,CAAC,CAAE,YAAY,CAAC,KAAa,EAAE,KAAa,EAAE,MAAoB,EAAE,OAAsB;QACpG,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,iCAAmB,CAAC,OAAO,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,CAAC,EAAE,CAAC;YACpI,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;CACF;AAlWD,oBAkWC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module ECDb\r\n */\r\nimport { assert, DbResult, IDisposable, Logger, OpenMode } from \"@itwin/core-bentley\";\r\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\nimport { DbQueryRequest, ECSchemaProps, ECSqlReader, IModelError, QueryBinder, QueryOptions, QueryOptionsBuilder } from \"@itwin/core-common\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { ConcurrentQuery } from \"./ConcurrentQuery\";\r\nimport { ECSqlStatement } from \"./ECSqlStatement\";\r\nimport { IModelNative } from \"./internal/NativePlatform\";\r\nimport { SqliteStatement, StatementCache } from \"./SqliteStatement\";\r\nimport { _nativeDb } from \"./internal/Symbols\";\r\n\r\nconst loggerCategory: string = BackendLoggerCategory.ECDb;\r\n\r\n/** Modes for how to open [ECDb]($backend) files.\r\n * @public\r\n */\r\nexport enum ECDbOpenMode {\r\n Readonly,\r\n ReadWrite,\r\n /** Opens the file read-write and upgrades the file if necessary to the latest file format version. */\r\n FileUpgrade,\r\n}\r\n\r\n/** An ECDb file\r\n * @public\r\n */\r\nexport class ECDb implements IDisposable {\r\n private _nativeDb?: IModelJsNative.ECDb;\r\n private readonly _statementCache = new StatementCache<ECSqlStatement>();\r\n private _sqliteStatementCache = new StatementCache<SqliteStatement>();\r\n\r\n /** only for tests\r\n * @internal\r\n */\r\n public resetSqliteCache(size: number) {\r\n this._sqliteStatementCache.clear();\r\n this._sqliteStatementCache = new StatementCache<SqliteStatement>(size);\r\n }\r\n\r\n constructor() {\r\n this._nativeDb = new IModelNative.platform.ECDb();\r\n }\r\n /** Call this function when finished with this ECDb object. This releases the native resources held by the\r\n * ECDb object.\r\n */\r\n public dispose(): void {\r\n if (!this._nativeDb)\r\n return;\r\n\r\n this.closeDb();\r\n this._nativeDb.dispose();\r\n this._nativeDb = undefined;\r\n }\r\n\r\n /** Create an ECDb\r\n * @param pathName The path to the ECDb file to create.\r\n * @throws [IModelError]($common) if the operation failed.\r\n */\r\n public createDb(pathName: string): void {\r\n const status: DbResult = this[_nativeDb].createDb(pathName);\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to created ECDb\");\r\n }\r\n\r\n /** Open the ECDb.\r\n * @param pathName The path to the ECDb file to open\r\n * @param openMode Open mode\r\n * @throws [IModelError]($common) if the operation failed.\r\n */\r\n public openDb(pathName: string, openMode: ECDbOpenMode = ECDbOpenMode.Readonly): void {\r\n const nativeOpenMode: OpenMode = openMode === ECDbOpenMode.Readonly ? OpenMode.Readonly : OpenMode.ReadWrite;\r\n const tryUpgrade: boolean = openMode === ECDbOpenMode.FileUpgrade;\r\n const status: DbResult = this[_nativeDb].openDb(pathName, nativeOpenMode, tryUpgrade);\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to open ECDb\");\r\n }\r\n\r\n /** Returns true if the ECDb is open */\r\n public get isOpen(): boolean { return this[_nativeDb].isOpen(); }\r\n\r\n /** Close the Db after saving any uncommitted changes.\r\n * @throws [IModelError]($common) if the database is not open.\r\n */\r\n public closeDb(): void {\r\n this._statementCache.clear();\r\n this._sqliteStatementCache.clear();\r\n this[_nativeDb].closeDb();\r\n }\r\n\r\n /** @internal use to test statement caching */\r\n public clearStatementCache() {\r\n this._statementCache.clear();\r\n }\r\n\r\n /** @internal use to test statement caching */\r\n public getCachedStatementCount() {\r\n return this._statementCache.size;\r\n }\r\n\r\n /** Commit the outermost transaction, writing changes to the file. Then, restart the transaction.\r\n * @param changesetName The name of the operation that generated these changes.\r\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\r\n */\r\n public saveChanges(changesetName?: string): void {\r\n const status: DbResult = this[_nativeDb].saveChanges(changesetName);\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to save changes\");\r\n }\r\n\r\n /** Abandon (cancel) the outermost transaction, discarding all changes since last save. Then, restart the transaction.\r\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\r\n */\r\n public abandonChanges(): void {\r\n const status: DbResult = this[_nativeDb].abandonChanges();\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to abandon changes\");\r\n }\r\n\r\n /** Import a schema.\r\n *\r\n * If the import was successful, the database is automatically saved to disk.\r\n * @param pathName Path to ECSchema XML file to import.\r\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\r\n */\r\n public importSchema(pathName: string): void {\r\n const status: DbResult = this[_nativeDb].importSchema(pathName);\r\n if (status !== DbResult.BE_SQLITE_OK) {\r\n Logger.logError(loggerCategory, `Failed to import schema from '${pathName}'.`);\r\n throw new IModelError(status, `Failed to import schema from '${pathName}'.`);\r\n }\r\n }\r\n\r\n /**\r\n * Returns the full schema for the input name.\r\n * @param name The name of the schema e.g. 'ECDbMeta'\r\n * @returns The SchemaProps for the requested schema\r\n * @throws if the schema can not be found or loaded.\r\n */\r\n public getSchemaProps(name: string): ECSchemaProps {\r\n return this[_nativeDb].getSchemaProps(name);\r\n }\r\n\r\n /**\r\n * Use a prepared ECSQL statement, potentially from the statement cache. If the requested statement doesn't exist\r\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\r\n * in the statement cache so it can be reused in the future. Use this method for ECSQL statements that will be\r\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\r\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withStatement]]\r\n * @public\r\n */\r\n public withPreparedStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors = true): T {\r\n const stmt = this._statementCache.findAndRemove(ecsql) ?? this.prepareStatement(ecsql, logErrors);\r\n const release = () => this._statementCache.addOrDispose(stmt);\r\n try {\r\n const val = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Prepared and execute a callback on an ECSQL statement. After the callback completes the statement is disposed.\r\n * Use this method for ECSQL statements are either not expected to be reused, or are not expensive to prepare.\r\n * For statements that will be reused often, instead use [[withPreparedStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withPreparedStatement]]\r\n * @public\r\n */\r\n public withStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors = true): T {\r\n const stmt = this.prepareStatement(ecsql, logErrors);\r\n const release = () => stmt.dispose();\r\n try {\r\n const val = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /** Prepare an ECSQL statement.\r\n * @param ecsql The ECSQL statement to prepare\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @throws [IModelError]($common) if there is a problem preparing the statement.\r\n */\r\n public prepareStatement(ecsql: string, logErrors = true): ECSqlStatement {\r\n const stmt = new ECSqlStatement();\r\n stmt.prepare(this[_nativeDb], ecsql, logErrors);\r\n return stmt;\r\n }\r\n\r\n /**\r\n * Use a prepared SQL statement, potentially from the statement cache. If the requested statement doesn't exist\r\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\r\n * in the statement cache so it can be reused in the future. Use this method for SQL statements that will be\r\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\r\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withSqliteStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withPreparedStatement]]\r\n * @public\r\n */\r\n public withPreparedSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors = true): T {\r\n const stmt = this._sqliteStatementCache.findAndRemove(sql) ?? this.prepareSqliteStatement(sql, logErrors);\r\n const release = () => this._sqliteStatementCache.addOrDispose(stmt);\r\n try {\r\n const val: T = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Prepared and execute a callback on a SQL statement. After the callback completes the statement is disposed.\r\n * Use this method for SQL statements are either not expected to be reused, or are not expensive to prepare.\r\n * For statements that will be reused often, instead use [[withPreparedSqliteStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @public\r\n */\r\n public withSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors = true): T {\r\n const stmt = this.prepareSqliteStatement(sql, logErrors);\r\n const release = () => stmt.dispose();\r\n try {\r\n const val: T = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /** Prepare an SQL statement.\r\n * @param sql The SQLite SQL statement to prepare\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @throws [IModelError]($common) if there is a problem preparing the statement.\r\n * @internal\r\n */\r\n public prepareSqliteStatement(sql: string, logErrors = true): SqliteStatement {\r\n const stmt = new SqliteStatement(sql);\r\n stmt.prepare(this[_nativeDb], logErrors);\r\n return stmt;\r\n }\r\n\r\n /** @internal\r\n * @deprecated in 4.8. This internal API will be removed in 5.0. Use ECDb's public API instead.\r\n */\r\n public get nativeDb(): IModelJsNative.ECDb { return this[_nativeDb]; }\r\n\r\n /** @internal */\r\n public get [_nativeDb](): IModelJsNative.ECDb {\r\n assert(undefined !== this._nativeDb);\r\n return this._nativeDb;\r\n }\r\n\r\n /** Allow to execute query and read results along with meta data. The result are streamed.\r\n *\r\n * See also:\r\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\r\n * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)\r\n * - [ECSQL Row Format]($docs/learning/ECSQLRowFormat)\r\n *\r\n * @param params The values to bind to the parameters (if the ECSQL has any).\r\n * @param config Allow to specify certain flags which control how query is executed.\r\n * @returns Returns an [ECSqlReader]($common) which helps iterate over the result set and also give access to metadata.\r\n * @public\r\n * */\r\n public createQueryReader(ecsql: string, params?: QueryBinder, config?: QueryOptions): ECSqlReader {\r\n if (!this._nativeDb || !this._nativeDb.isOpen()) {\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"db not open\");\r\n }\r\n const executor = {\r\n execute: async (request: DbQueryRequest) => {\r\n return ConcurrentQuery.executeQueryRequest(this[_nativeDb], request);\r\n },\r\n };\r\n return new ECSqlReader(executor, ecsql, params, config);\r\n }\r\n\r\n /** Execute a query and stream its results\r\n * The result of the query is async iterator over the rows. The iterator will get next page automatically once rows in current page has been read.\r\n * [ECSQL row]($docs/learning/ECSQLRowFormat).\r\n *\r\n * See also:\r\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\r\n * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)\r\n *\r\n * @param ecsql The ECSQL statement to execute\r\n * @param params The values to bind to the parameters (if the ECSQL has any).\r\n * @param options Allow to specify certain flags which control how query is executed.\r\n * @returns Returns the query result as an *AsyncIterableIterator<any>* which lazy load result as needed. The row format is determined by *rowFormat* parameter.\r\n * See [ECSQL row format]($docs/learning/ECSQLRowFormat) for details about the format of the returned rows.\r\n * @throws [IModelError]($common) If there was any error while submitting, preparing or stepping into query\r\n * @deprecated in 3.7. Use [[createQueryReader]] instead; it accepts the same parameters.\r\n */\r\n public async * query(ecsql: string, params?: QueryBinder, options?: QueryOptions): AsyncIterableIterator<any> {\r\n const builder = new QueryOptionsBuilder(options);\r\n const reader = this.createQueryReader(ecsql, params, builder.getOptions());\r\n while (await reader.step())\r\n yield reader.formatCurrentRow();\r\n }\r\n /** Compute number of rows that would be returned by the ECSQL.\r\n *\r\n * See also:\r\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\r\n * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)\r\n *\r\n * @param ecsql The ECSQL statement to execute\r\n * @param params The values to bind to the parameters (if the ECSQL has any).\r\n * See \"[iTwin.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)\" for details.\r\n * @returns Return row count.\r\n * @throws [IModelError]($common) If the statement is invalid\r\n * @deprecated in 3.7. Count the number of results using `count(*)` where the original query is a subquery instead. E.g., `SELECT count(*) FROM (<query-whose-rows-to-count>)`.\r\n */\r\n public async queryRowCount(ecsql: string, params?: QueryBinder): Promise<number> {\r\n for await (const row of this.createQueryReader(`SELECT count(*) FROM (${ecsql})`, params)) {\r\n return row[0] as number;\r\n }\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Failed to get row count\");\r\n }\r\n\r\n /** Cancel any previous query with same token and run execute the current specified query.\r\n * The result of the query is async iterator over the rows. The iterator will get next page automatically once rows in current page has been read.\r\n * [ECSQL row]($docs/learning/ECSQLRowFormat).\r\n *\r\n * See also:\r\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\r\n * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)\r\n *\r\n * @param ecsql The ECSQL statement to execute\r\n * @param token None empty restart token. The previous query with same token would be cancelled. This would cause\r\n * exception which user code must handle.\r\n * @param params The values to bind to the parameters (if the ECSQL has any).\r\n * @param options Allow to specify certain flags which control how query is executed.\r\n * @returns Returns the query result as an *AsyncIterableIterator<any>* which lazy load result as needed. The row format is determined by *rowFormat* parameter.\r\n * See [ECSQL row format]($docs/learning/ECSQLRowFormat) for details about the format of the returned rows.\r\n * @throws [IModelError]($common) If there was any error while submitting, preparing or stepping into query\r\n * @deprecated in 3.7. Use [[createQueryReader]] instead. Pass in the restart token as part of the `config` argument; e.g., `{ restartToken: myToken }` or `new QueryOptionsBuilder().setRestartToken(myToken).getOptions()`.\r\n */\r\n public async * restartQuery(token: string, ecsql: string, params?: QueryBinder, options?: QueryOptions): AsyncIterableIterator<any> {\r\n for await (const row of this.createQueryReader(ecsql, params, new QueryOptionsBuilder(options).setRestartToken(token).getOptions())) {\r\n yield row;\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.ECSchemaXmlContext = void 0;
|
|
11
11
|
const core_bentley_1 = require("@itwin/core-bentley");
|
|
12
12
|
const core_common_1 = require("@itwin/core-common");
|
|
13
|
-
const
|
|
13
|
+
const NativePlatform_1 = require("./internal/NativePlatform");
|
|
14
14
|
/** Context used when deserializing a [Schema]($ecschema-metadata) from an XML file.
|
|
15
15
|
* A schema may contain references to other schemas, which may reside elsewhere on the local disk than the referencing schema.
|
|
16
16
|
* The context maintains a list of directories ("search paths") to search for referenced schemas. Directories can be appended to the list via [[addSchemaPath]].
|
|
@@ -22,7 +22,7 @@ const IModelHost_1 = require("./IModelHost");
|
|
|
22
22
|
class ECSchemaXmlContext {
|
|
23
23
|
/** Construct a context with an empty list of search paths. */
|
|
24
24
|
constructor() {
|
|
25
|
-
this._nativeContext = new
|
|
25
|
+
this._nativeContext = new NativePlatform_1.IModelNative.platform.ECSchemaXmlContext();
|
|
26
26
|
}
|
|
27
27
|
/** @internal */
|
|
28
28
|
get nativeContext() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ECSchemaXmlContext.js","sourceRoot":"","sources":["../../src/ECSchemaXmlContext.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6C;AAC7C,oDAAiD;AAEjD,
|
|
1
|
+
{"version":3,"file":"ECSchemaXmlContext.js","sourceRoot":"","sources":["../../src/ECSchemaXmlContext.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6C;AAC7C,oDAAiD;AAEjD,8DAAyD;AAQzD;;;;;;;GAOG;AACH,MAAa,kBAAkB;IAG7B,8DAA8D;IAC9D;QACE,IAAI,CAAC,cAAc,GAAG,IAAI,6BAAY,CAAC,QAAQ,CAAC,kBAAkB,EAAE,CAAC;IACvE,CAAC;IAED,gBAAgB;IAChB,IAAW,aAAa;QACtB,IAAA,qBAAM,EAAC,SAAS,KAAK,IAAI,CAAC,cAAc,CAAC,CAAC;QAC1C,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED;;;OAGG;IACI,aAAa,CAAC,UAAkB;QACrC,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAC/C,CAAC;IAED;;;OAGG;IACI,gBAAgB,CAAC,OAAgE;QACtF,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC;IAED;;;;OAIG;IACI,qBAAqB,CAAC,OAAgE;QAC3F,IAAI,CAAC,aAAa,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC;IACpD,CAAC;IAED;;;;OAIG;IACI,qBAAqB,CAAC,QAAgB;QAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;QACpE,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;YACnB,MAAM,IAAI,yBAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACvE,CAAC;QAED,IAAA,qBAAM,EAAC,SAAS,KAAK,QAAQ,CAAC,MAAM,CAAC,CAAC;QACtC,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC;CACF;AArDD,gDAqDC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Schema\r\n */\r\n\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { IModelError } from \"@itwin/core-common\";\r\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\nimport { IModelNative } from \"./internal/NativePlatform\";\r\n\r\n/** @internal */\r\nexport type SchemaKey = IModelJsNative.ECSchemaXmlContext.SchemaKey;\r\n\r\n/** @internal */\r\nexport type SchemaMatchType = IModelJsNative.ECSchemaXmlContext.SchemaMatchType;\r\n\r\n/** Context used when deserializing a [Schema]($ecschema-metadata) from an XML file.\r\n * A schema may contain references to other schemas, which may reside elsewhere on the local disk than the referencing schema.\r\n * The context maintains a list of directories (\"search paths\") to search for referenced schemas. Directories can be appended to the list via [[addSchemaPath]].\r\n * When a referenced schema needs to be located, the list of directories is searched in the order in which each was added.\r\n * Once located, the schema is cached to avoid performing repeated lookups in the file system.\r\n * @see [[readSchemaFromXmlFile]] to deserialize a schema.\r\n * @beta\r\n */\r\nexport class ECSchemaXmlContext {\r\n private _nativeContext: IModelJsNative.ECSchemaXmlContext | undefined;\r\n\r\n /** Construct a context with an empty list of search paths. */\r\n constructor() {\r\n this._nativeContext = new IModelNative.platform.ECSchemaXmlContext();\r\n }\r\n\r\n /** @internal */\r\n public get nativeContext(): IModelJsNative.ECSchemaXmlContext {\r\n assert(undefined !== this._nativeContext);\r\n return this._nativeContext;\r\n }\r\n\r\n /** Append a directory to the list of directories that will be searched to locate referenced schemas.\r\n * The directories are searched in the order in which they were added to the list.\r\n * @param searchPath The absolute path to the directory to search.\r\n */\r\n public addSchemaPath(searchPath: string): void {\r\n this.nativeContext.addSchemaPath(searchPath);\r\n }\r\n\r\n /** Set the last locater to be used when trying to find a schema\r\n * @param locater Locater that should be used as the last locater when trying to find a schema\r\n * @internal\r\n */\r\n public setSchemaLocater(locater: IModelJsNative.ECSchemaXmlContext.SchemaLocaterCallback): void {\r\n this.nativeContext.setSchemaLocater(locater);\r\n }\r\n\r\n /** Adds a schema locator to the beginning of the list of locators used to search for schemas.\r\n * This schema locator will be prioritized over other locators when searching for schemas in the current context.\r\n * @param locater Locater to add to the current context\r\n * @internal\r\n */\r\n public setFirstSchemaLocater(locater: IModelJsNative.ECSchemaXmlContext.SchemaLocaterCallback): void {\r\n this.nativeContext.setFirstSchemaLocater(locater);\r\n }\r\n\r\n /** Deserialize a [Schema]($ecschema-metadata) from an ECSchemaXML-formatted file.\r\n * @param filePath The absolute path of the XML file.\r\n * @returns The JSON representation of the schema, as a [SchemaProps]($ecschema-metadata).\r\n * @throws [[IModelError]] if there is a problem reading schema from the XML file\r\n */\r\n public readSchemaFromXmlFile(filePath: string): any {\r\n const response = this.nativeContext.readSchemaFromXmlFile(filePath);\r\n if (response.error) {\r\n throw new IModelError(response.error.status, response.error.message);\r\n }\r\n\r\n assert(undefined !== response.result);\r\n return JSON.parse(response.result);\r\n }\r\n}\r\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module ECSQL
|
|
3
3
|
*/
|
|
4
|
-
import { DbResult, GuidString, Id64String, IDisposable
|
|
4
|
+
import { DbResult, GuidString, Id64String, IDisposable } from "@itwin/core-bentley";
|
|
5
5
|
import { LowAndHighXYZ, XAndY, XYAndZ } from "@itwin/core-geometry";
|
|
6
6
|
import { ECSqlValueType, NavigationBindingValue, NavigationValue } from "@itwin/core-common";
|
|
7
7
|
import { IModelJsNative } from "@bentley/imodeljs-native";
|
|
@@ -63,10 +63,13 @@ export declare class ECSqlStatement implements IterableIterator<any>, IDisposabl
|
|
|
63
63
|
* @param db The DgnDb or ECDb to prepare the statement against
|
|
64
64
|
* @param ecsql The ECSQL statement string to prepare
|
|
65
65
|
* @param logErrors Determine if errors are logged or not, its set to false by default for tryPrepare()
|
|
66
|
-
* @returns
|
|
66
|
+
* @returns An object with a `status` member equal to [DbResult.BE_SQLITE_OK]($bentley) on success. Upon error, the `message` member will provide details.
|
|
67
67
|
* @internal
|
|
68
68
|
*/
|
|
69
|
-
tryPrepare(db: IModelJsNative.DgnDb | IModelJsNative.ECDb, ecsql: string, logErrors?: boolean):
|
|
69
|
+
tryPrepare(db: IModelJsNative.DgnDb | IModelJsNative.ECDb, ecsql: string, logErrors?: boolean): {
|
|
70
|
+
status: DbResult;
|
|
71
|
+
message: string;
|
|
72
|
+
};
|
|
70
73
|
/** Reset this statement so that the next call to step will return the first row, if any. */
|
|
71
74
|
reset(): void;
|
|
72
75
|
/** Get the Native SQL statement
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ECSqlStatement.d.ts","sourceRoot":"","sources":["../../src/ECSqlStatement.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAU,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"ECSqlStatement.d.ts","sourceRoot":"","sources":["../../src/ECSqlStatement.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAU,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC5F,OAAO,EAAE,aAAa,EAAW,KAAK,EAAE,MAAM,EAAO,MAAM,sBAAsB,CAAC;AAClF,OAAO,EAAa,cAAc,EAAe,sBAAsB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAI1D;;;;;;;;;GASG;AACH,qBAAa,iBAAiB;IACF,MAAM,EAAE,QAAQ;IAAS,EAAE,CAAC;gBAA5B,MAAM,EAAE,QAAQ,EAAS,EAAE,CAAC,oBAAY;CACnE;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,cAAe,YAAW,gBAAgB,CAAC,GAAG,CAAC,EAAE,WAAW;IACvE,OAAO,CAAC,KAAK,CAA4C;IACzD,OAAO,CAAC,IAAI,CAAqB;IAEjC,IAAW,GAAG,WAAyB;IAEvC,oEAAoE;IACpE,IAAW,UAAU,IAAI,OAAO,CAAyB;IAEzD;;;;;;;OAOG;IACI,OAAO,CAAC,EAAE,EAAE,cAAc,CAAC,KAAK,GAAG,cAAc,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,UAAO,GA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11
|
const core_bentley_1 = require("@itwin/core-bentley");
|
|
12
12
|
const core_geometry_1 = require("@itwin/core-geometry");
|
|
13
13
|
const core_common_1 = require("@itwin/core-common");
|
|
14
|
-
const
|
|
14
|
+
const NativePlatform_1 = require("./internal/NativePlatform");
|
|
15
15
|
/** The result of an **ECSQL INSERT** statement as returned from [ECSqlStatement.stepForInsert]($backend).
|
|
16
16
|
*
|
|
17
17
|
* If the step was successful, the ECSqlInsertResult contains
|
|
@@ -75,14 +75,14 @@ class ECSqlStatement {
|
|
|
75
75
|
* @param db The DgnDb or ECDb to prepare the statement against
|
|
76
76
|
* @param ecsql The ECSQL statement string to prepare
|
|
77
77
|
* @param logErrors Determine if errors are logged or not, its set to false by default for tryPrepare()
|
|
78
|
-
* @returns
|
|
78
|
+
* @returns An object with a `status` member equal to [DbResult.BE_SQLITE_OK]($bentley) on success. Upon error, the `message` member will provide details.
|
|
79
79
|
* @internal
|
|
80
80
|
*/
|
|
81
81
|
tryPrepare(db, ecsql, logErrors = false) {
|
|
82
82
|
if (this.isPrepared)
|
|
83
83
|
throw new Error("ECSqlStatement is already prepared");
|
|
84
84
|
this._sql = ecsql;
|
|
85
|
-
this._stmt = new
|
|
85
|
+
this._stmt = new NativePlatform_1.IModelNative.platform.ECSqlStatement();
|
|
86
86
|
return this._stmt.prepare(db, ecsql, logErrors);
|
|
87
87
|
}
|
|
88
88
|
/** Reset this statement so that the next call to step will return the first row, if any. */
|