@itwin/core-backend 5.0.0-dev.4 → 5.0.0-dev.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +40 -1
- package/lib/cjs/BriefcaseManager.d.ts +10 -0
- package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
- package/lib/cjs/BriefcaseManager.js +49 -8
- package/lib/cjs/BriefcaseManager.js.map +1 -1
- package/lib/cjs/ChangeSummaryManager.js +1 -1
- package/lib/cjs/ChangeSummaryManager.js.map +1 -1
- package/lib/cjs/CheckpointManager.js +5 -5
- package/lib/cjs/CheckpointManager.js.map +1 -1
- package/lib/cjs/ClassRegistry.js +8 -14
- package/lib/cjs/ClassRegistry.js.map +1 -1
- package/lib/cjs/CloudSqlite.d.ts +2 -1
- package/lib/cjs/CloudSqlite.d.ts.map +1 -1
- package/lib/cjs/CloudSqlite.js +3 -3
- package/lib/cjs/CloudSqlite.js.map +1 -1
- package/lib/cjs/CodeService.d.ts +2 -0
- package/lib/cjs/CodeService.d.ts.map +1 -1
- package/lib/cjs/CodeService.js.map +1 -1
- package/lib/cjs/CodeSpecs.js +1 -1
- package/lib/cjs/CodeSpecs.js.map +1 -1
- package/lib/cjs/DevTools.js +16 -16
- package/lib/cjs/DevTools.js.map +1 -1
- package/lib/cjs/ECDb.d.ts +0 -4
- package/lib/cjs/ECDb.d.ts.map +1 -1
- package/lib/cjs/ECDb.js +0 -4
- package/lib/cjs/ECDb.js.map +1 -1
- package/lib/cjs/Element.js +23 -25
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/FontFile.d.ts +68 -0
- package/lib/cjs/FontFile.d.ts.map +1 -0
- package/lib/cjs/FontFile.js +36 -0
- package/lib/cjs/FontFile.js.map +1 -0
- package/lib/cjs/GeoCoordConfig.js +8 -8
- package/lib/cjs/GeoCoordConfig.js.map +1 -1
- package/lib/cjs/HubMock.js +1 -1
- package/lib/cjs/HubMock.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +91 -15
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +112 -56
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/IModelDbFonts.d.ts +54 -0
- package/lib/cjs/IModelDbFonts.d.ts.map +1 -0
- package/lib/cjs/IModelDbFonts.js +11 -0
- package/lib/cjs/IModelDbFonts.js.map +1 -0
- package/lib/cjs/IModelHost.d.ts +0 -7
- package/lib/cjs/IModelHost.d.ts.map +1 -1
- package/lib/cjs/IModelHost.js +19 -27
- package/lib/cjs/IModelHost.js.map +1 -1
- package/lib/cjs/IModelJsFs.d.ts.map +1 -1
- package/lib/cjs/IModelJsFs.js +8 -1
- package/lib/cjs/IModelJsFs.js.map +1 -1
- package/lib/cjs/IpcHost.js +2 -2
- package/lib/cjs/IpcHost.js.map +1 -1
- package/lib/cjs/LocalhostIpcHost.js +1 -1
- package/lib/cjs/LocalhostIpcHost.js.map +1 -1
- package/lib/cjs/NativeAppStorage.js +3 -3
- package/lib/cjs/NativeAppStorage.js.map +1 -1
- package/lib/cjs/NativeHost.js +3 -3
- package/lib/cjs/NativeHost.js.map +1 -1
- package/lib/cjs/NavigationRelationship.js +25 -25
- package/lib/cjs/NavigationRelationship.js.map +1 -1
- package/lib/cjs/Relationship.d.ts.map +1 -1
- package/lib/cjs/Relationship.js +1 -1
- package/lib/cjs/Relationship.js.map +1 -1
- package/lib/cjs/SQLiteDb.d.ts +6 -4
- package/lib/cjs/SQLiteDb.d.ts.map +1 -1
- package/lib/cjs/SQLiteDb.js +12 -6
- package/lib/cjs/SQLiteDb.js.map +1 -1
- package/lib/cjs/Schema.js +1 -1
- package/lib/cjs/Schema.js.map +1 -1
- package/lib/cjs/SqliteChangesetReader.d.ts +8 -0
- package/lib/cjs/SqliteChangesetReader.d.ts.map +1 -1
- package/lib/cjs/SqliteChangesetReader.js +15 -0
- package/lib/cjs/SqliteChangesetReader.js.map +1 -1
- package/lib/cjs/TextAnnotationLayout.d.ts +6 -3
- package/lib/cjs/TextAnnotationLayout.d.ts.map +1 -1
- package/lib/cjs/TextAnnotationLayout.js +3 -3
- package/lib/cjs/TextAnnotationLayout.js.map +1 -1
- package/lib/cjs/TxnManager.d.ts +37 -1
- package/lib/cjs/TxnManager.d.ts.map +1 -1
- package/lib/cjs/TxnManager.js +148 -2
- package/lib/cjs/TxnManager.js.map +1 -1
- package/lib/cjs/ViewDefinition.js +19 -22
- package/lib/cjs/ViewDefinition.js.map +1 -1
- package/lib/cjs/core-backend.d.ts +2 -0
- package/lib/cjs/core-backend.d.ts.map +1 -1
- package/lib/cjs/core-backend.js +2 -0
- package/lib/cjs/core-backend.js.map +1 -1
- package/lib/cjs/domains/FunctionalElements.js +1 -1
- package/lib/cjs/domains/FunctionalElements.js.map +1 -1
- package/lib/cjs/internal/ChangesetConflictArgs.d.ts +40 -2
- package/lib/cjs/internal/ChangesetConflictArgs.d.ts.map +1 -1
- package/lib/cjs/internal/ChangesetConflictArgs.js +99 -0
- package/lib/cjs/internal/ChangesetConflictArgs.js.map +1 -1
- package/lib/cjs/internal/ChannelAdmin.js +1 -1
- package/lib/cjs/internal/ChannelAdmin.js.map +1 -1
- package/lib/cjs/internal/FontFileImpl.d.ts +34 -0
- package/lib/cjs/internal/FontFileImpl.d.ts.map +1 -0
- package/lib/cjs/internal/FontFileImpl.js +142 -0
- package/lib/cjs/internal/FontFileImpl.js.map +1 -0
- package/lib/cjs/internal/IModelDbFontsImpl.d.ts +7 -0
- package/lib/cjs/internal/IModelDbFontsImpl.d.ts.map +1 -0
- package/lib/cjs/internal/IModelDbFontsImpl.js +188 -0
- package/lib/cjs/internal/IModelDbFontsImpl.js.map +1 -0
- package/lib/cjs/internal/Symbols.d.ts +3 -0
- package/lib/cjs/internal/Symbols.d.ts.map +1 -1
- package/lib/cjs/internal/Symbols.js +4 -1
- package/lib/cjs/internal/Symbols.js.map +1 -1
- package/lib/cjs/internal/workspace/SettingsImpl.js +2 -2
- package/lib/cjs/internal/workspace/SettingsImpl.js.map +1 -1
- package/lib/cjs/internal/workspace/SettingsSchemasImpl.js +1 -1
- package/lib/cjs/internal/workspace/SettingsSchemasImpl.js.map +1 -1
- package/lib/cjs/internal/workspace/WorkspaceImpl.js +5 -5
- package/lib/cjs/internal/workspace/WorkspaceImpl.js.map +1 -1
- package/lib/cjs/rpc/multipart.d.ts.map +1 -1
- package/lib/cjs/rpc/multipart.js +2 -1
- package/lib/cjs/rpc/multipart.js.map +1 -1
- package/lib/cjs/rpc/tracing.js +2 -2
- package/lib/cjs/rpc/tracing.js.map +1 -1
- package/lib/cjs/rpc/web/request.d.ts.map +1 -1
- package/lib/cjs/rpc/web/request.js +2 -1
- package/lib/cjs/rpc/web/request.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
- package/package.json +21 -19
- package/lib/cjs/ChangedElementsManager.d.ts +0 -42
- package/lib/cjs/ChangedElementsManager.d.ts.map +0 -1
- package/lib/cjs/ChangedElementsManager.js +0 -91
- package/lib/cjs/ChangedElementsManager.js.map +0 -1
- package/lib/cjs/rpc-impl/WipRpcImpl.d.ts +0 -17
- package/lib/cjs/rpc-impl/WipRpcImpl.d.ts.map +0 -1
- package/lib/cjs/rpc-impl/WipRpcImpl.js +0 -40
- package/lib/cjs/rpc-impl/WipRpcImpl.js.map +0 -1
package/lib/cjs/DevTools.js
CHANGED
|
@@ -17,6 +17,22 @@ const loggerCategory = BackendLoggerCategory_1.BackendLoggerCategory.DevTools;
|
|
|
17
17
|
* @internal
|
|
18
18
|
*/
|
|
19
19
|
class DevToolsStatsFormatter {
|
|
20
|
+
static { this._megaByteProps = ["totalmem", "freemem", "rss", "heapTotal", "heapUsed", "external"]; }
|
|
21
|
+
static { this._percentProps = ["user", "nice", "sys", "idle", "irq", "cpuUsage"]; }
|
|
22
|
+
static { this._mHzProps = ["speed"]; }
|
|
23
|
+
static { this._secondsProps = ["uptime"]; }
|
|
24
|
+
/** Replacer that includes units - can be used with JSON.stringify() */
|
|
25
|
+
static { this._replacer = (key, value) => {
|
|
26
|
+
if (DevToolsStatsFormatter._megaByteProps.includes(key))
|
|
27
|
+
return `${value.toFixed()} MB`;
|
|
28
|
+
if (DevToolsStatsFormatter._percentProps.includes(key))
|
|
29
|
+
return `${value.toFixed()}%`;
|
|
30
|
+
if (DevToolsStatsFormatter._mHzProps.includes(key))
|
|
31
|
+
return `${value.toString()} MHz`;
|
|
32
|
+
if (DevToolsStatsFormatter._secondsProps.includes(key))
|
|
33
|
+
return `${value.toFixed()} secs`;
|
|
34
|
+
return value;
|
|
35
|
+
}; }
|
|
20
36
|
/** Converts the input stats to another JSON object with the appropriate units setup for various fields */
|
|
21
37
|
static toFormattedJson(stats) {
|
|
22
38
|
// Serialize the stats to a string with a replacer that sets up units during the serialization
|
|
@@ -26,22 +42,6 @@ class DevToolsStatsFormatter {
|
|
|
26
42
|
}
|
|
27
43
|
}
|
|
28
44
|
exports.DevToolsStatsFormatter = DevToolsStatsFormatter;
|
|
29
|
-
DevToolsStatsFormatter._megaByteProps = ["totalmem", "freemem", "rss", "heapTotal", "heapUsed", "external"];
|
|
30
|
-
DevToolsStatsFormatter._percentProps = ["user", "nice", "sys", "idle", "irq", "cpuUsage"];
|
|
31
|
-
DevToolsStatsFormatter._mHzProps = ["speed"];
|
|
32
|
-
DevToolsStatsFormatter._secondsProps = ["uptime"];
|
|
33
|
-
/** Replacer that includes units - can be used with JSON.stringify() */
|
|
34
|
-
DevToolsStatsFormatter._replacer = (key, value) => {
|
|
35
|
-
if (DevToolsStatsFormatter._megaByteProps.includes(key))
|
|
36
|
-
return `${value.toFixed()} MB`;
|
|
37
|
-
if (DevToolsStatsFormatter._percentProps.includes(key))
|
|
38
|
-
return `${value.toFixed()}%`;
|
|
39
|
-
if (DevToolsStatsFormatter._mHzProps.includes(key))
|
|
40
|
-
return `${value.toString()} MHz`;
|
|
41
|
-
if (DevToolsStatsFormatter._secondsProps.includes(key))
|
|
42
|
-
return `${value.toFixed()} secs`;
|
|
43
|
-
return value;
|
|
44
|
-
};
|
|
45
45
|
/**
|
|
46
46
|
* Internal diagnostic utility
|
|
47
47
|
* @internal
|
package/lib/cjs/DevTools.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DevTools.js","sourceRoot":"","sources":["../../src/DevTools.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,yBAAyB;AACzB,mCAAmC;AACnC,sDAAuD;AACvD,mEAAgE;AAChE,6CAA0C;AAC1C,8DAAyD;AAGzD,0BAA0B;AAE1B,MAAM,cAAc,GAAW,6CAAqB,CAAC,QAAQ,CAAC;AAwC9D;;GAEG;AACH,MAAa,sBAAsB;IAmBjC,0GAA0G;IACnG,MAAM,CAAC,eAAe,CAAC,KAAU;QACtC,8FAA8F;QAC9F,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,sBAAsB,CAAC,SAAS,CAAC,CAAC;QAEzE,2BAA2B;QAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC;;AA1BH,wDA2BC;AA1ByB,qCAAc,GAAG,CAAC,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;AACrF,oCAAa,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;AACnE,gCAAS,GAAG,CAAC,OAAO,CAAC,CAAC;AACtB,oCAAa,GAAG,CAAC,QAAQ,CAAC,CAAC;AAEnD,wEAAwE;AACzD,gCAAS,GAAG,CAAC,GAAW,EAAE,KAAU,EAAE,EAAE;IACrD,IAAI,sBAAsB,CAAC,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC;QACrD,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esContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport * as os from \"os\";\nimport * as process from \"process\";\nimport { Logger, LogLevel } from \"@itwin/core-bentley\";\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\nimport { IModelHost } from \"./IModelHost\";\nimport { IModelNative } from \"./internal/NativePlatform\";\nimport { RpcInterfaceEndpoints } from \"@itwin/core-common\";\n\n// cspell:ignore ppid elap\n\nconst loggerCategory: string = BackendLoggerCategory.DevTools;\n\ninterface StringIndexedObject<T> {\n [index: string]: T;\n}\n\n/**\n * Performance and Memory statistics of backend\n * @internal\n */\nexport interface DevToolsStats {\n os: DevToolsOsStats;\n process: DevToolsProcessStats;\n}\n\n/**\n * OS stats of backend\n * @internal\n */\nexport interface DevToolsOsStats {\n platform: NodeJS.Platform;\n hostname: string;\n totalmem: number;\n freemem: number;\n uptime: number;\n cpus: os.CpuInfo[];\n cpuUsage: number;\n}\n\n/**\n * Process stats of backend\n * @internal\n */\nexport interface DevToolsProcessStats {\n uptime: number;\n pid: number;\n ppid: number;\n memoryUsage: NodeJS.MemoryUsage;\n}\n\n/** Utility to format the JSON created by DevTools.stats() to include the appropriate units\n * @internal\n */\nexport class DevToolsStatsFormatter {\n private static readonly _megaByteProps = [\"totalmem\", \"freemem\", \"rss\", \"heapTotal\", \"heapUsed\", \"external\"];\n private static readonly _percentProps = [\"user\", \"nice\", \"sys\", \"idle\", \"irq\", \"cpuUsage\"];\n private static readonly _mHzProps = [\"speed\"];\n private static readonly _secondsProps = [\"uptime\"];\n\n /** Replacer that includes units - can be used with JSON.stringify() */\n private static _replacer = (key: string, value: any) => {\n if (DevToolsStatsFormatter._megaByteProps.includes(key))\n return `${value.toFixed()} MB`;\n if (DevToolsStatsFormatter._percentProps.includes(key))\n return `${value.toFixed()}%`;\n if (DevToolsStatsFormatter._mHzProps.includes(key))\n return `${value.toString()} MHz`;\n if (DevToolsStatsFormatter._secondsProps.includes(key))\n return `${value.toFixed()} secs`;\n return value;\n };\n\n /** Converts the input stats to another JSON object with the appropriate units setup for various fields */\n public static toFormattedJson(stats: any) {\n // Serialize the stats to a string with a replacer that sets up units during the serialization\n const statsStr = JSON.stringify(stats, DevToolsStatsFormatter._replacer);\n\n // Deserialize back to JSON\n return JSON.parse(statsStr);\n }\n}\n\n/**\n * Internal diagnostic utility\n * @internal\n */\nexport class DevTools {\n\n /** Receives a ping and returns true */\n public static ping(): boolean {\n Logger.logInfo(loggerCategory, \"Received ping at backend\");\n return true;\n }\n\n private static hrtimeToMS(hrtime: any) {\n return hrtime[0] * 1000 + hrtime[1] / 1000000;\n }\n\n private static bytesToMegaBytes(bytes: number): number {\n const megaBytes = bytes / Math.pow(1024, 2);\n return Math.round(megaBytes * 100) / 100;\n }\n\n private static evaluateCpuUsage(): number {\n const NUMBER_OF_CPUS = os.cpus().length;\n const startTime = process.hrtime();\n const startUsage = process.cpuUsage();\n\n // spin the CPU for 500 milliseconds\n const now = Date.now();\n while (Date.now() - now < 500)\n ;\n\n const elapTime = process.hrtime(startTime);\n const elapUsage = process.cpuUsage(startUsage);\n\n const elapTimeMS = this.hrtimeToMS(elapTime);\n\n const elapUserMS = elapUsage.user / 1000; // microseconds to milliseconds\n const elapSystMS = elapUsage.system / 1000;\n const cpuPercent = Math.round((100 * (elapUserMS + elapSystMS) / elapTimeMS / NUMBER_OF_CPUS));\n\n return cpuPercent;\n }\n\n private static evaluateCpus(): os.CpuInfo[] {\n // Create a clone\n const srcCpus = os.cpus();\n const cpus = new Array<os.CpuInfo>(srcCpus.length);\n let ii = 0;\n for (const srcCpu of srcCpus)\n cpus[ii++] = { ...srcCpu };\n\n // Evaluate cpu usage as percentages\n for (const cpu of Object.values(cpus)) {\n const total = Object.values(cpu.times).reduce((_total: number, currValue) => _total += currValue, 0);\n const cpuTimes = cpu.times as StringIndexedObject<number>;\n for (const type of Object.keys(cpuTimes)) {\n const cpuPercent = Math.round(100 * cpuTimes[type] / total);\n cpuTimes[type] = cpuPercent;\n }\n }\n return cpus;\n }\n\n private static evaluateMemoryUsage() {\n // Create a clone\n const memUsage = { ...process.memoryUsage() } as NodeJS.MemoryUsage;\n const memUsageObj = (memUsage as any) as StringIndexedObject<number>;\n // Evaluate memory usage as mega bytes\n for (const type of Object.keys(memUsageObj)) {\n memUsageObj[type] = this.bytesToMegaBytes(memUsageObj[type]);\n }\n return memUsage;\n }\n\n private static evaluateProcessStats(): DevToolsProcessStats {\n return {\n uptime: process.uptime(),\n pid: process.pid,\n ppid: process.ppid,\n memoryUsage: this.evaluateMemoryUsage(),\n } as DevToolsProcessStats;\n }\n\n private static evaluateOsStats(): DevToolsOsStats {\n return {\n platform: os.platform(),\n hostname: os.hostname(),\n totalmem: this.bytesToMegaBytes(os.totalmem()),\n freemem: this.bytesToMegaBytes(os.freemem()),\n uptime: os.uptime(),\n cpus: this.evaluateCpus(),\n cpuUsage: this.evaluateCpuUsage(),\n } as DevToolsOsStats;\n }\n\n /** Returns JSON object with backend statistics */\n public static stats(): DevToolsStats {\n try {\n const stats = {\n os: this.evaluateOsStats(),\n process: this.evaluateProcessStats(),\n } as DevToolsStats;\n return stats;\n } catch (error) {\n Logger.logError(loggerCategory, \"Could not fetch stats at backend\");\n throw error;\n }\n }\n\n /** Sets up a log level at the backend and returns the old log level */\n public static setLogLevel(inLoggerCategory: string, newLevel: LogLevel): LogLevel | undefined {\n const oldLevel = Logger.getLevel(inLoggerCategory);\n Logger.logInfo(loggerCategory, `Setting log level`, () => ({ loggerCategory: inLoggerCategory, oldLevel, newLevel }));\n Logger.setLevel(inLoggerCategory, newLevel);\n IModelNative.platform.clearLogLevelCache();\n return oldLevel;\n }\n\n /** Obtains the backend application and iTwin.js Core versions */\n public static async versions() {\n const availableRpcs: RpcInterfaceEndpoints[] = [];\n return {\n application: IModelHost.applicationVersion,\n iTwinJs: require(\"../../package.json\").version, // eslint-disable-line @typescript-eslint/no-require-imports\n availableRpcs, // filled in on the frontend\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DevTools.js","sourceRoot":"","sources":["../../src/DevTools.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,yBAAyB;AACzB,mCAAmC;AACnC,sDAAuD;AACvD,mEAAgE;AAChE,6CAA0C;AAC1C,8DAAyD;AAGzD,0BAA0B;AAE1B,MAAM,cAAc,GAAW,6CAAqB,CAAC,QAAQ,CAAC;AAwC9D;;GAEG;AACH,MAAa,sBAAsB;aACT,mBAAc,GAAG,CAAC,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;aACrF,kBAAa,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;aACnE,cAAS,GAAG,CAAC,OAAO,CAAC,CAAC;aACtB,kBAAa,GAAG,CAAC,QAAQ,CAAC,CAAC;IAEnD,wEAAwE;aACzD,cAAS,GAAG,CAAC,GAAW,EAAE,KAAU,EAAE,EAAE;QACrD,IAAI,sBAAsB,CAAC,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC;YACrD,OAAO,GAAG,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC;QACjC,IAAI,sBAAsB,CAAC,aAAa,CAAC,QAAQ,CAAC,GAAG,CAAC;YACpD,OAAO,GAAG,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC;QAC/B,IAAI,sBAAsB,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC;YAChD,OAAO,GAAG,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC;QACnC,IAAI,sBAAsB,CAAC,aAAa,CAAC,QAAQ,CAAC,GAAG,CAAC;YACpD,OAAO,GAAG,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC;QACnC,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IAEF,0GAA0G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KAAK,GAAG;gBACZ,EAAE,EAAE,IAAI,CAAC,eAAe,EAAE;gBAC1B,OAAO,EAAE,IAAI,CAAC,oBAAoB,EAAE;aACpB,CAAC;YACnB,OAAO,KAAK,CAAC;QACf,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,qBAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,kCAAkC,CAAC,CAAC;YACpE,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED,uEAAuE;IAChE,MAAM,CAAC,WAAW,CAAC,gBAAwB,EAAE,QAAkB;QACpE,MAAM,QAAQ,GAAG,qBAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;QACnD,qBAAM,CAAC,OAAO,CAAC,cAAc,EAAE,mBAAmB,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,cAAc,EAAE,gBAAgB,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;QACtH,qBAAM,CAAC,QAAQ,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC;QAC5C,6BAAY,CAAC,QAAQ,CAAC,kBAAkB,EAAE,CAAC;QAC3C,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,iEAAiE;IAC1D,MAAM,CAAC,KAAK,CAAC,QAAQ;QAC1B,MAAM,aAAa,GAA4B,EAAE,CAAC;QAClD,OAAO;YACL,WAAW,EAAE,uBAAU,CAAC,kBAAkB;YAC1C,OAAO,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC,OAAO,EAAE,4DAA4D;YAC5G,aAAa,EAAE,4BAA4B;SAC5C,CAAC;IACJ,CAAC;CACF;AA3HD,4BA2HC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport * as os from \"os\";\nimport * as process from \"process\";\nimport { Logger, LogLevel } from \"@itwin/core-bentley\";\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\nimport { IModelHost } from \"./IModelHost\";\nimport { IModelNative } from \"./internal/NativePlatform\";\nimport { RpcInterfaceEndpoints } from \"@itwin/core-common\";\n\n// cspell:ignore ppid elap\n\nconst loggerCategory: string = BackendLoggerCategory.DevTools;\n\ninterface StringIndexedObject<T> {\n [index: string]: T;\n}\n\n/**\n * Performance and Memory statistics of backend\n * @internal\n */\nexport interface DevToolsStats {\n os: DevToolsOsStats;\n process: DevToolsProcessStats;\n}\n\n/**\n * OS stats of backend\n * @internal\n */\nexport interface DevToolsOsStats {\n platform: NodeJS.Platform;\n hostname: string;\n totalmem: number;\n freemem: number;\n uptime: number;\n cpus: os.CpuInfo[];\n cpuUsage: number;\n}\n\n/**\n * Process stats of backend\n * @internal\n */\nexport interface DevToolsProcessStats {\n uptime: number;\n pid: number;\n ppid: number;\n memoryUsage: NodeJS.MemoryUsage;\n}\n\n/** Utility to format the JSON created by DevTools.stats() to include the appropriate units\n * @internal\n */\nexport class DevToolsStatsFormatter {\n private static readonly _megaByteProps = [\"totalmem\", \"freemem\", \"rss\", \"heapTotal\", \"heapUsed\", \"external\"];\n private static readonly _percentProps = [\"user\", \"nice\", \"sys\", \"idle\", \"irq\", \"cpuUsage\"];\n private static readonly _mHzProps = [\"speed\"];\n private static readonly _secondsProps = [\"uptime\"];\n\n /** Replacer that includes units - can be used with JSON.stringify() */\n private static _replacer = (key: string, value: any) => {\n if (DevToolsStatsFormatter._megaByteProps.includes(key))\n return `${value.toFixed()} MB`;\n if (DevToolsStatsFormatter._percentProps.includes(key))\n return `${value.toFixed()}%`;\n if (DevToolsStatsFormatter._mHzProps.includes(key))\n return `${value.toString()} MHz`;\n if (DevToolsStatsFormatter._secondsProps.includes(key))\n return `${value.toFixed()} secs`;\n return value;\n };\n\n /** Converts the input stats to another JSON object with the appropriate units setup for various fields */\n public static toFormattedJson(stats: any) {\n // Serialize the stats to a string with a replacer that sets up units during the serialization\n const statsStr = JSON.stringify(stats, DevToolsStatsFormatter._replacer);\n\n // Deserialize back to JSON\n return JSON.parse(statsStr);\n }\n}\n\n/**\n * Internal diagnostic utility\n * @internal\n */\nexport class DevTools {\n\n /** Receives a ping and returns true */\n public static ping(): boolean {\n Logger.logInfo(loggerCategory, \"Received ping at backend\");\n return true;\n }\n\n private static hrtimeToMS(hrtime: any) {\n return hrtime[0] * 1000 + hrtime[1] / 1000000;\n }\n\n private static bytesToMegaBytes(bytes: number): number {\n const megaBytes = bytes / Math.pow(1024, 2);\n return Math.round(megaBytes * 100) / 100;\n }\n\n private static evaluateCpuUsage(): number {\n const NUMBER_OF_CPUS = os.cpus().length;\n const startTime = process.hrtime();\n const startUsage = process.cpuUsage();\n\n // spin the CPU for 500 milliseconds\n const now = Date.now();\n while (Date.now() - now < 500)\n ;\n\n const elapTime = process.hrtime(startTime);\n const elapUsage = process.cpuUsage(startUsage);\n\n const elapTimeMS = this.hrtimeToMS(elapTime);\n\n const elapUserMS = elapUsage.user / 1000; // microseconds to milliseconds\n const elapSystMS = elapUsage.system / 1000;\n const cpuPercent = Math.round((100 * (elapUserMS + elapSystMS) / elapTimeMS / NUMBER_OF_CPUS));\n\n return cpuPercent;\n }\n\n private static evaluateCpus(): os.CpuInfo[] {\n // Create a clone\n const srcCpus = os.cpus();\n const cpus = new Array<os.CpuInfo>(srcCpus.length);\n let ii = 0;\n for (const srcCpu of srcCpus)\n cpus[ii++] = { ...srcCpu };\n\n // Evaluate cpu usage as percentages\n for (const cpu of Object.values(cpus)) {\n const total = Object.values(cpu.times).reduce((_total: number, currValue) => _total += currValue, 0);\n const cpuTimes = cpu.times as StringIndexedObject<number>;\n for (const type of Object.keys(cpuTimes)) {\n const cpuPercent = Math.round(100 * cpuTimes[type] / total);\n cpuTimes[type] = cpuPercent;\n }\n }\n return cpus;\n }\n\n private static evaluateMemoryUsage() {\n // Create a clone\n const memUsage = { ...process.memoryUsage() } as NodeJS.MemoryUsage;\n const memUsageObj = (memUsage as any) as StringIndexedObject<number>;\n // Evaluate memory usage as mega bytes\n for (const type of Object.keys(memUsageObj)) {\n memUsageObj[type] = this.bytesToMegaBytes(memUsageObj[type]);\n }\n return memUsage;\n }\n\n private static evaluateProcessStats(): DevToolsProcessStats {\n return {\n uptime: process.uptime(),\n pid: process.pid,\n ppid: process.ppid,\n memoryUsage: this.evaluateMemoryUsage(),\n } as DevToolsProcessStats;\n }\n\n private static evaluateOsStats(): DevToolsOsStats {\n return {\n platform: os.platform(),\n hostname: os.hostname(),\n totalmem: this.bytesToMegaBytes(os.totalmem()),\n freemem: this.bytesToMegaBytes(os.freemem()),\n uptime: os.uptime(),\n cpus: this.evaluateCpus(),\n cpuUsage: this.evaluateCpuUsage(),\n } as DevToolsOsStats;\n }\n\n /** Returns JSON object with backend statistics */\n public static stats(): DevToolsStats {\n try {\n const stats = {\n os: this.evaluateOsStats(),\n process: this.evaluateProcessStats(),\n } as DevToolsStats;\n return stats;\n } catch (error) {\n Logger.logError(loggerCategory, \"Could not fetch stats at backend\");\n throw error;\n }\n }\n\n /** Sets up a log level at the backend and returns the old log level */\n public static setLogLevel(inLoggerCategory: string, newLevel: LogLevel): LogLevel | undefined {\n const oldLevel = Logger.getLevel(inLoggerCategory);\n Logger.logInfo(loggerCategory, `Setting log level`, () => ({ loggerCategory: inLoggerCategory, oldLevel, newLevel }));\n Logger.setLevel(inLoggerCategory, newLevel);\n IModelNative.platform.clearLogLevelCache();\n return oldLevel;\n }\n\n /** Obtains the backend application and iTwin.js Core versions */\n public static async versions() {\n const availableRpcs: RpcInterfaceEndpoints[] = [];\n return {\n application: IModelHost.applicationVersion,\n iTwinJs: require(\"../../package.json\").version, // eslint-disable-line @typescript-eslint/no-require-imports\n availableRpcs, // filled in on the frontend\n };\n }\n}\n"]}
|
package/lib/cjs/ECDb.d.ts
CHANGED
|
@@ -140,10 +140,6 @@ export declare class ECDb implements IDisposable {
|
|
|
140
140
|
* @internal
|
|
141
141
|
*/
|
|
142
142
|
prepareSqliteStatement(sql: string, logErrors?: boolean): SqliteStatement;
|
|
143
|
-
/** @internal
|
|
144
|
-
* @deprecated in 4.8. This internal API will be removed in 5.0. Use ECDb's public API instead.
|
|
145
|
-
*/
|
|
146
|
-
get nativeDb(): IModelJsNative.ECDb;
|
|
147
143
|
/** @internal */
|
|
148
144
|
get [_nativeDb](): IModelJsNative.ECDb;
|
|
149
145
|
/** Allow to execute query and read results along with meta data. The result are streamed.
|
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;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,SAAS,CAAC,CAAsB;IACxC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAwC;IACxE,OAAO,CAAC,qBAAqB,CAAyC;IAEtE;;OAEG;IACI,gBAAgB,CAAC,IAAI,EAAE,MAAM;;IAQpC;;OAEG;IACI,OAAO,IAAI,IAAI;IAStB;;;OAGG;IACI,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAMvC;;;;OAIG;IACI,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ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,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
|
@@ -271,10 +271,6 @@ class ECDb {
|
|
|
271
271
|
stmt.prepare(this[Symbols_1._nativeDb], logErrors);
|
|
272
272
|
return stmt;
|
|
273
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]; }
|
|
278
274
|
/** @internal */
|
|
279
275
|
get [Symbols_1._nativeDb]() {
|
|
280
276
|
(0, core_bentley_1.assert)(undefined !== this._nativeDb);
|
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,8DAAyD;AACzD,uDAAoE;AACpE,gDAA+C;AAE/C,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,YAA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;;;;;;;;;;;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":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ECDb\n */\nimport { assert, DbResult, IDisposable, Logger, OpenMode } from \"@itwin/core-bentley\";\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\nimport { DbQueryRequest, ECSchemaProps, ECSqlReader, IModelError, QueryBinder, QueryOptions, QueryOptionsBuilder } from \"@itwin/core-common\";\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\nimport { ConcurrentQuery } from \"./ConcurrentQuery\";\nimport { ECSqlStatement } from \"./ECSqlStatement\";\nimport { IModelNative } from \"./internal/NativePlatform\";\nimport { SqliteStatement, StatementCache } from \"./SqliteStatement\";\nimport { _nativeDb } from \"./internal/Symbols\";\n\nconst loggerCategory: string = BackendLoggerCategory.ECDb;\n\n/** Modes for how to open [ECDb]($backend) files.\n * @public\n */\nexport enum ECDbOpenMode {\n Readonly,\n ReadWrite,\n /** Opens the file read-write and upgrades the file if necessary to the latest file format version. */\n FileUpgrade,\n}\n\n/** An ECDb file\n * @public\n */\nexport class ECDb implements IDisposable {\n private _nativeDb?: IModelJsNative.ECDb;\n private readonly _statementCache = new StatementCache<ECSqlStatement>();\n private _sqliteStatementCache = new StatementCache<SqliteStatement>();\n\n /** only for tests\n * @internal\n */\n public resetSqliteCache(size: number) {\n this._sqliteStatementCache.clear();\n this._sqliteStatementCache = new StatementCache<SqliteStatement>(size);\n }\n\n constructor() {\n this._nativeDb = new IModelNative.platform.ECDb();\n }\n /** Call this function when finished with this ECDb object. This releases the native resources held by the\n * ECDb object.\n */\n public dispose(): void {\n if (!this._nativeDb)\n return;\n\n this.closeDb();\n this._nativeDb.dispose();\n this._nativeDb = undefined;\n }\n\n /** Create an ECDb\n * @param pathName The path to the ECDb file to create.\n * @throws [IModelError]($common) if the operation failed.\n */\n public createDb(pathName: string): void {\n const status: DbResult = this[_nativeDb].createDb(pathName);\n if (status !== DbResult.BE_SQLITE_OK)\n throw new IModelError(status, \"Failed to created ECDb\");\n }\n\n /** Open the ECDb.\n * @param pathName The path to the ECDb file to open\n * @param openMode Open mode\n * @throws [IModelError]($common) if the operation failed.\n */\n public openDb(pathName: string, openMode: ECDbOpenMode = ECDbOpenMode.Readonly): void {\n const nativeOpenMode: OpenMode = openMode === ECDbOpenMode.Readonly ? OpenMode.Readonly : OpenMode.ReadWrite;\n const tryUpgrade: boolean = openMode === ECDbOpenMode.FileUpgrade;\n const status: DbResult = this[_nativeDb].openDb(pathName, nativeOpenMode, tryUpgrade);\n if (status !== DbResult.BE_SQLITE_OK)\n throw new IModelError(status, \"Failed to open ECDb\");\n }\n\n /** Returns true if the ECDb is open */\n public get isOpen(): boolean { return this[_nativeDb].isOpen(); }\n\n /** Close the Db after saving any uncommitted changes.\n * @throws [IModelError]($common) if the database is not open.\n */\n public closeDb(): void {\n this._statementCache.clear();\n this._sqliteStatementCache.clear();\n this[_nativeDb].closeDb();\n }\n\n /** @internal use to test statement caching */\n public clearStatementCache() {\n this._statementCache.clear();\n }\n\n /** @internal use to test statement caching */\n public getCachedStatementCount() {\n return this._statementCache.size;\n }\n\n /** Commit the outermost transaction, writing changes to the file. Then, restart the transaction.\n * @param changesetName The name of the operation that generated these changes.\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\n */\n public saveChanges(changesetName?: string): void {\n const status: DbResult = this[_nativeDb].saveChanges(changesetName);\n if (status !== DbResult.BE_SQLITE_OK)\n throw new IModelError(status, \"Failed to save changes\");\n }\n\n /** Abandon (cancel) the outermost transaction, discarding all changes since last save. Then, restart the transaction.\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\n */\n public abandonChanges(): void {\n const status: DbResult = this[_nativeDb].abandonChanges();\n if (status !== DbResult.BE_SQLITE_OK)\n throw new IModelError(status, \"Failed to abandon changes\");\n }\n\n /** Import a schema.\n *\n * If the import was successful, the database is automatically saved to disk.\n * @param pathName Path to ECSchema XML file to import.\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\n */\n public importSchema(pathName: string): void {\n const status: DbResult = this[_nativeDb].importSchema(pathName);\n if (status !== DbResult.BE_SQLITE_OK) {\n Logger.logError(loggerCategory, `Failed to import schema from '${pathName}'.`);\n throw new IModelError(status, `Failed to import schema from '${pathName}'.`);\n }\n }\n\n /**\n * Returns the full schema for the input name.\n * @param name The name of the schema e.g. 'ECDbMeta'\n * @returns The SchemaProps for the requested schema\n * @throws if the schema can not be found or loaded.\n */\n public getSchemaProps(name: string): ECSchemaProps {\n return this[_nativeDb].getSchemaProps(name);\n }\n\n /**\n * Use a prepared ECSQL statement, potentially from the statement cache. If the requested statement doesn't exist\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\n * in the statement cache so it can be reused in the future. Use this method for ECSQL statements that will be\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withStatement]].\n * @param sql The SQLite SQL statement to execute\n * @param callback the callback to invoke on the prepared statement\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @returns the value returned by `callback`.\n * @see [[withStatement]]\n * @public\n */\n public withPreparedStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors = true): T {\n const stmt = this._statementCache.findAndRemove(ecsql) ?? this.prepareStatement(ecsql, logErrors);\n const release = () => this._statementCache.addOrDispose(stmt);\n try {\n const val = callback(stmt);\n if (val instanceof Promise) {\n val.then(release, release);\n } else {\n release();\n }\n return val;\n } catch (err) {\n release();\n throw err;\n }\n }\n\n /**\n * Prepared and execute a callback on an ECSQL statement. After the callback completes the statement is disposed.\n * Use this method for ECSQL statements are either not expected to be reused, or are not expensive to prepare.\n * For statements that will be reused often, instead use [[withPreparedStatement]].\n * @param sql The SQLite SQL statement to execute\n * @param callback the callback to invoke on the prepared statement\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @returns the value returned by `callback`.\n * @see [[withPreparedStatement]]\n * @public\n */\n public withStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors = true): T {\n const stmt = this.prepareStatement(ecsql, logErrors);\n const release = () => stmt.dispose();\n try {\n const val = callback(stmt);\n if (val instanceof Promise) {\n val.then(release, release);\n } else {\n release();\n }\n return val;\n } catch (err) {\n release();\n throw err;\n }\n }\n\n /** Prepare an ECSQL statement.\n * @param ecsql The ECSQL statement to prepare\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @throws [IModelError]($common) if there is a problem preparing the statement.\n */\n public prepareStatement(ecsql: string, logErrors = true): ECSqlStatement {\n const stmt = new ECSqlStatement();\n stmt.prepare(this[_nativeDb], ecsql, logErrors);\n return stmt;\n }\n\n /**\n * Use a prepared SQL statement, potentially from the statement cache. If the requested statement doesn't exist\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\n * in the statement cache so it can be reused in the future. Use this method for SQL statements that will be\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withSqliteStatement]].\n * @param sql The SQLite SQL statement to execute\n * @param callback the callback to invoke on the prepared statement\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @returns the value returned by `callback`.\n * @see [[withPreparedStatement]]\n * @public\n */\n public withPreparedSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors = true): T {\n const stmt = this._sqliteStatementCache.findAndRemove(sql) ?? this.prepareSqliteStatement(sql, logErrors);\n const release = () => this._sqliteStatementCache.addOrDispose(stmt);\n try {\n const val: T = callback(stmt);\n if (val instanceof Promise) {\n val.then(release, release);\n } else {\n release();\n }\n return val;\n } catch (err) {\n release();\n throw err;\n }\n }\n\n /**\n * Prepared and execute a callback on a SQL statement. After the callback completes the statement is disposed.\n * Use this method for SQL statements are either not expected to be reused, or are not expensive to prepare.\n * For statements that will be reused often, instead use [[withPreparedSqliteStatement]].\n * @param sql The SQLite SQL statement to execute\n * @param callback the callback to invoke on the prepared statement\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @returns the value returned by `callback`.\n * @public\n */\n public withSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors = true): T {\n const stmt = this.prepareSqliteStatement(sql, logErrors);\n const release = () => stmt.dispose();\n try {\n const val: T = callback(stmt);\n if (val instanceof Promise) {\n val.then(release, release);\n } else {\n release();\n }\n return val;\n } catch (err) {\n release();\n throw err;\n }\n }\n\n /** Prepare an SQL statement.\n * @param sql The SQLite SQL statement to prepare\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @throws [IModelError]($common) if there is a problem preparing the statement.\n * @internal\n */\n public prepareSqliteStatement(sql: string, logErrors = true): SqliteStatement {\n const stmt = new SqliteStatement(sql);\n stmt.prepare(this[_nativeDb], logErrors);\n return stmt;\n }\n\n /** @internal\n * @deprecated in 4.8. This internal API will be removed in 5.0. Use ECDb's public API instead.\n */\n public get nativeDb(): IModelJsNative.ECDb { return this[_nativeDb]; }\n\n /** @internal */\n public get [_nativeDb](): IModelJsNative.ECDb {\n assert(undefined !== this._nativeDb);\n return this._nativeDb;\n }\n\n /** Allow to execute query and read results along with meta data. The result are streamed.\n *\n * See also:\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\n * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)\n * - [ECSQL Row Format]($docs/learning/ECSQLRowFormat)\n *\n * @param params The values to bind to the parameters (if the ECSQL has any).\n * @param config Allow to specify certain flags which control how query is executed.\n * @returns Returns an [ECSqlReader]($common) which helps iterate over the result set and also give access to metadata.\n * @public\n * */\n public createQueryReader(ecsql: string, params?: QueryBinder, config?: QueryOptions): ECSqlReader {\n if (!this._nativeDb || !this._nativeDb.isOpen()) {\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"db not open\");\n }\n const executor = {\n execute: async (request: DbQueryRequest) => {\n return ConcurrentQuery.executeQueryRequest(this[_nativeDb], request);\n },\n };\n return new ECSqlReader(executor, ecsql, params, config);\n }\n\n /** Execute a query and stream its results\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.\n * [ECSQL row]($docs/learning/ECSQLRowFormat).\n *\n * See also:\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\n * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)\n *\n * @param ecsql The ECSQL statement to execute\n * @param params The values to bind to the parameters (if the ECSQL has any).\n * @param options Allow to specify certain flags which control how query is executed.\n * @returns Returns the query result as an *AsyncIterableIterator<any>* which lazy load result as needed. The row format is determined by *rowFormat* parameter.\n * See [ECSQL row format]($docs/learning/ECSQLRowFormat) for details about the format of the returned rows.\n * @throws [IModelError]($common) If there was any error while submitting, preparing or stepping into query\n * @deprecated in 3.7. Use [[createQueryReader]] instead; it accepts the same parameters.\n */\n public async * query(ecsql: string, params?: QueryBinder, options?: QueryOptions): AsyncIterableIterator<any> {\n const builder = new QueryOptionsBuilder(options);\n const reader = this.createQueryReader(ecsql, params, builder.getOptions());\n while (await reader.step())\n yield reader.formatCurrentRow();\n }\n /** Compute number of rows that would be returned by the ECSQL.\n *\n * See also:\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\n * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)\n *\n * @param ecsql The ECSQL statement to execute\n * @param params The values to bind to the parameters (if the ECSQL has any).\n * See \"[iTwin.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)\" for details.\n * @returns Return row count.\n * @throws [IModelError]($common) If the statement is invalid\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>)`.\n */\n public async queryRowCount(ecsql: string, params?: QueryBinder): Promise<number> {\n for await (const row of this.createQueryReader(`SELECT count(*) FROM (${ecsql})`, params)) {\n return row[0] as number;\n }\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Failed to get row count\");\n }\n\n /** Cancel any previous query with same token and run execute the current specified query.\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.\n * [ECSQL row]($docs/learning/ECSQLRowFormat).\n *\n * See also:\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\n * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)\n *\n * @param ecsql The ECSQL statement to execute\n * @param token None empty restart token. The previous query with same token would be cancelled. This would cause\n * exception which user code must handle.\n * @param params The values to bind to the parameters (if the ECSQL has any).\n * @param options Allow to specify certain flags which control how query is executed.\n * @returns Returns the query result as an *AsyncIterableIterator<any>* which lazy load result as needed. The row format is determined by *rowFormat* parameter.\n * See [ECSQL row format]($docs/learning/ECSQLRowFormat) for details about the format of the returned rows.\n * @throws [IModelError]($common) If there was any error while submitting, preparing or stepping into query\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()`.\n */\n public async * restartQuery(token: string, ecsql: string, params?: QueryBinder, options?: QueryOptions): AsyncIterableIterator<any> {\n for await (const row of this.createQueryReader(ecsql, params, new QueryOptionsBuilder(options).setRestartToken(token).getOptions())) {\n yield row;\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ECDb.js","sourceRoot":"","sources":["../../src/ECDb.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,sDAAsF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AAiB,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":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ECDb\n */\nimport { assert, DbResult, IDisposable, Logger, OpenMode } from \"@itwin/core-bentley\";\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\nimport { DbQueryRequest, ECSchemaProps, ECSqlReader, IModelError, QueryBinder, QueryOptions, QueryOptionsBuilder } from \"@itwin/core-common\";\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\nimport { ConcurrentQuery } from \"./ConcurrentQuery\";\nimport { ECSqlStatement } from \"./ECSqlStatement\";\nimport { IModelNative } from \"./internal/NativePlatform\";\nimport { SqliteStatement, StatementCache } from \"./SqliteStatement\";\nimport { _nativeDb } from \"./internal/Symbols\";\n\nconst loggerCategory: string = BackendLoggerCategory.ECDb;\n\n/** Modes for how to open [ECDb]($backend) files.\n * @public\n */\nexport enum ECDbOpenMode {\n Readonly,\n ReadWrite,\n /** Opens the file read-write and upgrades the file if necessary to the latest file format version. */\n FileUpgrade,\n}\n\n/** An ECDb file\n * @public\n */\nexport class ECDb implements IDisposable {\n private _nativeDb?: IModelJsNative.ECDb;\n private readonly _statementCache = new StatementCache<ECSqlStatement>();\n private _sqliteStatementCache = new StatementCache<SqliteStatement>();\n\n /** only for tests\n * @internal\n */\n public resetSqliteCache(size: number) {\n this._sqliteStatementCache.clear();\n this._sqliteStatementCache = new StatementCache<SqliteStatement>(size);\n }\n\n constructor() {\n this._nativeDb = new IModelNative.platform.ECDb();\n }\n /** Call this function when finished with this ECDb object. This releases the native resources held by the\n * ECDb object.\n */\n public dispose(): void {\n if (!this._nativeDb)\n return;\n\n this.closeDb();\n this._nativeDb.dispose();\n this._nativeDb = undefined;\n }\n\n /** Create an ECDb\n * @param pathName The path to the ECDb file to create.\n * @throws [IModelError]($common) if the operation failed.\n */\n public createDb(pathName: string): void {\n const status: DbResult = this[_nativeDb].createDb(pathName);\n if (status !== DbResult.BE_SQLITE_OK)\n throw new IModelError(status, \"Failed to created ECDb\");\n }\n\n /** Open the ECDb.\n * @param pathName The path to the ECDb file to open\n * @param openMode Open mode\n * @throws [IModelError]($common) if the operation failed.\n */\n public openDb(pathName: string, openMode: ECDbOpenMode = ECDbOpenMode.Readonly): void {\n const nativeOpenMode: OpenMode = openMode === ECDbOpenMode.Readonly ? OpenMode.Readonly : OpenMode.ReadWrite;\n const tryUpgrade: boolean = openMode === ECDbOpenMode.FileUpgrade;\n const status: DbResult = this[_nativeDb].openDb(pathName, nativeOpenMode, tryUpgrade);\n if (status !== DbResult.BE_SQLITE_OK)\n throw new IModelError(status, \"Failed to open ECDb\");\n }\n\n /** Returns true if the ECDb is open */\n public get isOpen(): boolean { return this[_nativeDb].isOpen(); }\n\n /** Close the Db after saving any uncommitted changes.\n * @throws [IModelError]($common) if the database is not open.\n */\n public closeDb(): void {\n this._statementCache.clear();\n this._sqliteStatementCache.clear();\n this[_nativeDb].closeDb();\n }\n\n /** @internal use to test statement caching */\n public clearStatementCache() {\n this._statementCache.clear();\n }\n\n /** @internal use to test statement caching */\n public getCachedStatementCount() {\n return this._statementCache.size;\n }\n\n /** Commit the outermost transaction, writing changes to the file. Then, restart the transaction.\n * @param changesetName The name of the operation that generated these changes.\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\n */\n public saveChanges(changesetName?: string): void {\n const status: DbResult = this[_nativeDb].saveChanges(changesetName);\n if (status !== DbResult.BE_SQLITE_OK)\n throw new IModelError(status, \"Failed to save changes\");\n }\n\n /** Abandon (cancel) the outermost transaction, discarding all changes since last save. Then, restart the transaction.\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\n */\n public abandonChanges(): void {\n const status: DbResult = this[_nativeDb].abandonChanges();\n if (status !== DbResult.BE_SQLITE_OK)\n throw new IModelError(status, \"Failed to abandon changes\");\n }\n\n /** Import a schema.\n *\n * If the import was successful, the database is automatically saved to disk.\n * @param pathName Path to ECSchema XML file to import.\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\n */\n public importSchema(pathName: string): void {\n const status: DbResult = this[_nativeDb].importSchema(pathName);\n if (status !== DbResult.BE_SQLITE_OK) {\n Logger.logError(loggerCategory, `Failed to import schema from '${pathName}'.`);\n throw new IModelError(status, `Failed to import schema from '${pathName}'.`);\n }\n }\n\n /**\n * Returns the full schema for the input name.\n * @param name The name of the schema e.g. 'ECDbMeta'\n * @returns The SchemaProps for the requested schema\n * @throws if the schema can not be found or loaded.\n */\n public getSchemaProps(name: string): ECSchemaProps {\n return this[_nativeDb].getSchemaProps(name);\n }\n\n /**\n * Use a prepared ECSQL statement, potentially from the statement cache. If the requested statement doesn't exist\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\n * in the statement cache so it can be reused in the future. Use this method for ECSQL statements that will be\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withStatement]].\n * @param sql The SQLite SQL statement to execute\n * @param callback the callback to invoke on the prepared statement\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @returns the value returned by `callback`.\n * @see [[withStatement]]\n * @public\n */\n public withPreparedStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors = true): T {\n const stmt = this._statementCache.findAndRemove(ecsql) ?? this.prepareStatement(ecsql, logErrors);\n const release = () => this._statementCache.addOrDispose(stmt);\n try {\n const val = callback(stmt);\n if (val instanceof Promise) {\n val.then(release, release);\n } else {\n release();\n }\n return val;\n } catch (err) {\n release();\n throw err;\n }\n }\n\n /**\n * Prepared and execute a callback on an ECSQL statement. After the callback completes the statement is disposed.\n * Use this method for ECSQL statements are either not expected to be reused, or are not expensive to prepare.\n * For statements that will be reused often, instead use [[withPreparedStatement]].\n * @param sql The SQLite SQL statement to execute\n * @param callback the callback to invoke on the prepared statement\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @returns the value returned by `callback`.\n * @see [[withPreparedStatement]]\n * @public\n */\n public withStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors = true): T {\n const stmt = this.prepareStatement(ecsql, logErrors);\n const release = () => stmt.dispose();\n try {\n const val = callback(stmt);\n if (val instanceof Promise) {\n val.then(release, release);\n } else {\n release();\n }\n return val;\n } catch (err) {\n release();\n throw err;\n }\n }\n\n /** Prepare an ECSQL statement.\n * @param ecsql The ECSQL statement to prepare\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @throws [IModelError]($common) if there is a problem preparing the statement.\n */\n public prepareStatement(ecsql: string, logErrors = true): ECSqlStatement {\n const stmt = new ECSqlStatement();\n stmt.prepare(this[_nativeDb], ecsql, logErrors);\n return stmt;\n }\n\n /**\n * Use a prepared SQL statement, potentially from the statement cache. If the requested statement doesn't exist\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\n * in the statement cache so it can be reused in the future. Use this method for SQL statements that will be\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withSqliteStatement]].\n * @param sql The SQLite SQL statement to execute\n * @param callback the callback to invoke on the prepared statement\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @returns the value returned by `callback`.\n * @see [[withPreparedStatement]]\n * @public\n */\n public withPreparedSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors = true): T {\n const stmt = this._sqliteStatementCache.findAndRemove(sql) ?? this.prepareSqliteStatement(sql, logErrors);\n const release = () => this._sqliteStatementCache.addOrDispose(stmt);\n try {\n const val: T = callback(stmt);\n if (val instanceof Promise) {\n val.then(release, release);\n } else {\n release();\n }\n return val;\n } catch (err) {\n release();\n throw err;\n }\n }\n\n /**\n * Prepared and execute a callback on a SQL statement. After the callback completes the statement is disposed.\n * Use this method for SQL statements are either not expected to be reused, or are not expensive to prepare.\n * For statements that will be reused often, instead use [[withPreparedSqliteStatement]].\n * @param sql The SQLite SQL statement to execute\n * @param callback the callback to invoke on the prepared statement\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @returns the value returned by `callback`.\n * @public\n */\n public withSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors = true): T {\n const stmt = this.prepareSqliteStatement(sql, logErrors);\n const release = () => stmt.dispose();\n try {\n const val: T = callback(stmt);\n if (val instanceof Promise) {\n val.then(release, release);\n } else {\n release();\n }\n return val;\n } catch (err) {\n release();\n throw err;\n }\n }\n\n /** Prepare an SQL statement.\n * @param sql The SQLite SQL statement to prepare\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @throws [IModelError]($common) if there is a problem preparing the statement.\n * @internal\n */\n public prepareSqliteStatement(sql: string, logErrors = true): SqliteStatement {\n const stmt = new SqliteStatement(sql);\n stmt.prepare(this[_nativeDb], logErrors);\n return stmt;\n }\n\n /** @internal */\n public get [_nativeDb](): IModelJsNative.ECDb {\n assert(undefined !== this._nativeDb);\n return this._nativeDb;\n }\n\n /** Allow to execute query and read results along with meta data. The result are streamed.\n *\n * See also:\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\n * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)\n * - [ECSQL Row Format]($docs/learning/ECSQLRowFormat)\n *\n * @param params The values to bind to the parameters (if the ECSQL has any).\n * @param config Allow to specify certain flags which control how query is executed.\n * @returns Returns an [ECSqlReader]($common) which helps iterate over the result set and also give access to metadata.\n * @public\n * */\n public createQueryReader(ecsql: string, params?: QueryBinder, config?: QueryOptions): ECSqlReader {\n if (!this._nativeDb || !this._nativeDb.isOpen()) {\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"db not open\");\n }\n const executor = {\n execute: async (request: DbQueryRequest) => {\n return ConcurrentQuery.executeQueryRequest(this[_nativeDb], request);\n },\n };\n return new ECSqlReader(executor, ecsql, params, config);\n }\n\n /** Execute a query and stream its results\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.\n * [ECSQL row]($docs/learning/ECSQLRowFormat).\n *\n * See also:\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\n * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)\n *\n * @param ecsql The ECSQL statement to execute\n * @param params The values to bind to the parameters (if the ECSQL has any).\n * @param options Allow to specify certain flags which control how query is executed.\n * @returns Returns the query result as an *AsyncIterableIterator<any>* which lazy load result as needed. The row format is determined by *rowFormat* parameter.\n * See [ECSQL row format]($docs/learning/ECSQLRowFormat) for details about the format of the returned rows.\n * @throws [IModelError]($common) If there was any error while submitting, preparing or stepping into query\n * @deprecated in 3.7. Use [[createQueryReader]] instead; it accepts the same parameters.\n */\n public async * query(ecsql: string, params?: QueryBinder, options?: QueryOptions): AsyncIterableIterator<any> {\n const builder = new QueryOptionsBuilder(options);\n const reader = this.createQueryReader(ecsql, params, builder.getOptions());\n while (await reader.step())\n yield reader.formatCurrentRow();\n }\n /** Compute number of rows that would be returned by the ECSQL.\n *\n * See also:\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\n * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)\n *\n * @param ecsql The ECSQL statement to execute\n * @param params The values to bind to the parameters (if the ECSQL has any).\n * See \"[iTwin.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)\" for details.\n * @returns Return row count.\n * @throws [IModelError]($common) If the statement is invalid\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>)`.\n */\n public async queryRowCount(ecsql: string, params?: QueryBinder): Promise<number> {\n for await (const row of this.createQueryReader(`SELECT count(*) FROM (${ecsql})`, params)) {\n return row[0] as number;\n }\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Failed to get row count\");\n }\n\n /** Cancel any previous query with same token and run execute the current specified query.\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.\n * [ECSQL row]($docs/learning/ECSQLRowFormat).\n *\n * See also:\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\n * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)\n *\n * @param ecsql The ECSQL statement to execute\n * @param token None empty restart token. The previous query with same token would be cancelled. This would cause\n * exception which user code must handle.\n * @param params The values to bind to the parameters (if the ECSQL has any).\n * @param options Allow to specify certain flags which control how query is executed.\n * @returns Returns the query result as an *AsyncIterableIterator<any>* which lazy load result as needed. The row format is determined by *rowFormat* parameter.\n * See [ECSQL row format]($docs/learning/ECSQLRowFormat) for details about the format of the returned rows.\n * @throws [IModelError]($common) If there was any error while submitting, preparing or stepping into query\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()`.\n */\n public async * restartQuery(token: string, ecsql: string, params?: QueryBinder, options?: QueryOptions): AsyncIterableIterator<any> {\n for await (const row of this.createQueryReader(ecsql, params, new QueryOptionsBuilder(options).setRestartToken(token).getOptions())) {\n yield row;\n }\n }\n}\n"]}
|
package/lib/cjs/Element.js
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
/** @packageDocumentation
|
|
7
7
|
* @module Elements
|
|
8
8
|
*/
|
|
9
|
-
var _a, _b;
|
|
10
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
10
|
exports.RepositoryLink = exports.FolderLink = exports.UrlLink = exports.LinkElement = exports.GroupInformationElement = exports.SheetIndexPartition = exports.SpatialLocationPartition = exports.PhysicalPartition = exports.LinkPartition = exports.InformationRecordPartition = exports.GraphicalPartition3d = exports.GroupInformationPartition = exports.DocumentPartition = exports.DefinitionPartition = exports.InformationPartitionElement = exports.TemplateRecipe2d = exports.GraphicalType2d = exports.TemplateRecipe3d = exports.SpatialLocationType = exports.PhysicalType = exports.RecipeDefinitionElement = exports.TypeDefinitionElement = exports.DefinitionGroup = exports.DefinitionContainer = exports.DefinitionSet = exports.DefinitionElement = exports.InformationRecordElement = exports.Sheet = exports.SheetTemplate = exports.SheetBorderTemplate = exports.SectionDrawing = exports.Drawing = exports.Document = exports.Subject = exports.InformationReferenceElement = exports.DriverBundleElement = exports.InformationContentElement = exports.SectionDrawingLocation = exports.VolumeElement = exports.SpatialLocationElement = exports.PhysicalElement = exports.SpatialElement = exports.DrawingGraphic = exports.AnnotationElement2d = exports.GraphicalElement2d = exports.GeometricElement2d = exports.GraphicalElement3d = exports.GeometricElement3d = exports.GeometricElement = exports.Element = void 0;
|
|
12
11
|
exports.RenderTimeline = exports.LineStyle = exports.GeometryPart = exports.RoleElement = exports.EmbeddedFileLink = void 0;
|
|
@@ -260,6 +259,21 @@ class Element extends Entity_1.Entity {
|
|
|
260
259
|
getPredecessorIds() {
|
|
261
260
|
return this.getReferenceIds();
|
|
262
261
|
}
|
|
262
|
+
/** A *required reference* is an element that had to be inserted before this element could have been inserted.
|
|
263
|
+
* This is the list of property keys on this element that store references to those elements
|
|
264
|
+
* @note This should be overridden (with `super` called) at each level of the class hierarchy that introduces required references.
|
|
265
|
+
* @note any property listed here must be added to the reference ids in [[collectReferenceIds]]
|
|
266
|
+
* @beta
|
|
267
|
+
*/
|
|
268
|
+
static { this.requiredReferenceKeys = ["parent", "model"]; }
|
|
269
|
+
/** A map of every [[requiredReferenceKeys]] on this class to their entity type.
|
|
270
|
+
* @note This should be overridden (with `super` called) at each level of the class hierarchy that introduces required references.
|
|
271
|
+
* @alpha
|
|
272
|
+
*/
|
|
273
|
+
static { this.requiredReferenceKeyTypeMap = {
|
|
274
|
+
parent: core_common_1.ConcreteEntityTypes.Element,
|
|
275
|
+
model: core_common_1.ConcreteEntityTypes.Model,
|
|
276
|
+
}; }
|
|
263
277
|
/** Get the class metadata for this element. */
|
|
264
278
|
getClassMetaData() { return this.iModel.classMetaDataRegistry.find(this.classFullName); }
|
|
265
279
|
getAllUserProperties() {
|
|
@@ -308,25 +322,10 @@ class Element extends Entity_1.Entity {
|
|
|
308
322
|
delete() { this.iModel.elements.deleteElement(this.id); }
|
|
309
323
|
}
|
|
310
324
|
exports.Element = Element;
|
|
311
|
-
/** A *required reference* is an element that had to be inserted before this element could have been inserted.
|
|
312
|
-
* This is the list of property keys on this element that store references to those elements
|
|
313
|
-
* @note This should be overridden (with `super` called) at each level of the class hierarchy that introduces required references.
|
|
314
|
-
* @note any property listed here must be added to the reference ids in [[collectReferenceIds]]
|
|
315
|
-
* @beta
|
|
316
|
-
*/
|
|
317
|
-
Element.requiredReferenceKeys = ["parent", "model"];
|
|
318
|
-
/** A map of every [[requiredReferenceKeys]] on this class to their entity type.
|
|
319
|
-
* @note This should be overridden (with `super` called) at each level of the class hierarchy that introduces required references.
|
|
320
|
-
* @alpha
|
|
321
|
-
*/
|
|
322
|
-
Element.requiredReferenceKeyTypeMap = {
|
|
323
|
-
parent: core_common_1.ConcreteEntityTypes.Element,
|
|
324
|
-
model: core_common_1.ConcreteEntityTypes.Model,
|
|
325
|
-
};
|
|
326
325
|
/** An abstract base class to model real world entities that intrinsically have geometry.
|
|
327
326
|
* @public
|
|
328
327
|
*/
|
|
329
|
-
class GeometricElement extends
|
|
328
|
+
class GeometricElement extends Element {
|
|
330
329
|
static get className() { return "GeometricElement"; }
|
|
331
330
|
constructor(props, iModel) {
|
|
332
331
|
super(props, iModel);
|
|
@@ -352,16 +351,15 @@ class GeometricElement extends (_b = Element) {
|
|
|
352
351
|
referenceIds.addElement(this.category);
|
|
353
352
|
// TODO: GeometryPartIds?
|
|
354
353
|
}
|
|
354
|
+
/** @beta */
|
|
355
|
+
static { this.requiredReferenceKeys = [...super.requiredReferenceKeys, "category"]; }
|
|
356
|
+
/** @alpha */
|
|
357
|
+
static { this.requiredReferenceKeyTypeMap = {
|
|
358
|
+
...super.requiredReferenceKeyTypeMap,
|
|
359
|
+
category: core_common_1.ConcreteEntityTypes.Element,
|
|
360
|
+
}; }
|
|
355
361
|
}
|
|
356
362
|
exports.GeometricElement = GeometricElement;
|
|
357
|
-
_a = GeometricElement;
|
|
358
|
-
/** @beta */
|
|
359
|
-
GeometricElement.requiredReferenceKeys = [...Reflect.get(_b, "requiredReferenceKeys", _a), "category"];
|
|
360
|
-
/** @alpha */
|
|
361
|
-
GeometricElement.requiredReferenceKeyTypeMap = {
|
|
362
|
-
...Reflect.get(_b, "requiredReferenceKeyTypeMap", _a),
|
|
363
|
-
category: core_common_1.ConcreteEntityTypes.Element,
|
|
364
|
-
};
|
|
365
363
|
/** An abstract base class to model real world entities that intrinsically have 3d geometry.
|
|
366
364
|
* See [how to create a GeometricElement3d]($docs/learning/backend/CreateElements.md#GeometricElement3d).
|
|
367
365
|
* @public
|