@itwin/core-backend 3.0.0-dev.136 → 3.0.0-dev.138

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.
@@ -1 +1 @@
1
- {"version":3,"file":"ECSqlStatement.js","sourceRoot":"","sources":["../../src/ECSqlStatement.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAmH;AACnH,wDAAkF;AAClF,oDAAqH;AAGrH,6CAA0C;AAE1C;;;;;;;;;GASG;AACH,MAAa,iBAAiB;IAC5B,YAA0B,MAAgB,EAAS,EAAe;QAAxC,WAAM,GAAN,MAAM,CAAU;QAAS,OAAE,GAAF,EAAE,CAAa;IAAI,CAAC;CACxE;AAFD,8CAEC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAa,cAAc;IAIzB,IAAW,GAAG,KAAK,OAAO,IAAI,CAAC,IAAK,CAAC,CAAC,CAAC,CAAC,+DAA+D;IAEvG,oEAAoE;IACpE,IAAW,UAAU,KAAc,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAEzD;;;;;;;OAOG;IACI,OAAO,CAAC,EAA8C,EAAE,KAAa,EAAE,SAAS,GAAG,IAAI;QAC5F,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;QACnD,IAAI,IAAI,CAAC,MAAM,KAAK,uBAAQ,CAAC,YAAY,EAAE;YACzC,MAAM,IAAI,yBAAW,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;SAClD;IACH,CAAC;IAED;;;;;;OAMG;IACI,UAAU,CAAC,EAA8C,EAAE,KAAa,EAAE,SAAS,GAAG,KAAK;QAChG,IAAI,IAAI,CAAC,UAAU;YACjB,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;QACxD,IAAI,CAAC,IAAI,GAAG,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AAC,eAAe,CAAC,GAAQ,IAA0B,OAAO,GAAG,CAAC,GAAG,KAAK,SAAS,IAAI,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS,IAAI,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAE7L,MAAM,CAAC,wBAAwB,CAAC,GAAQ,IAAmC,OAAO,GAAG,CAAC,EAAE,KAAK,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC;CACjJ","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 ECSQL\r\n */\r\n\r\nimport { assert, DbResult, GuidString, Id64String, IDisposable, StatusCodeWithMessage } from \"@itwin/core-bentley\";\r\nimport { LowAndHighXYZ, Range3d, XAndY, XYAndZ, XYZ } from \"@itwin/core-geometry\";\r\nimport { ECJsNames, ECSqlValueType, IModelError, NavigationBindingValue, NavigationValue } from \"@itwin/core-common\";\r\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\nimport { ECDb } from \"./ECDb\";\r\nimport { IModelHost } from \"./IModelHost\";\r\n\r\n/** The result of an **ECSQL INSERT** statement as returned from [ECSqlStatement.stepForInsert]($backend).\r\n *\r\n * If the step was successful, the ECSqlInsertResult contains\r\n * [DbResult.BE_SQLITE_DONE]($core-bentley)\r\n * and the ECInstanceId of the newly created instance.\r\n * In case of failure it contains the [DbResult]($core-bentley) error code.\r\n *\r\n * > Insert statements can be used with ECDb only, not with IModelDb.\r\n * @public\r\n */\r\nexport class ECSqlInsertResult {\r\n public constructor(public status: DbResult, public id?: Id64String) { }\r\n}\r\n\r\n/** Executes ECSQL statements.\r\n *\r\n * A statement must be prepared before it can be executed, and it must be released when no longer needed.\r\n * See [IModelDb.withPreparedStatement]($backend) or\r\n * [ECDb.withPreparedStatement]($backend) for a convenient and\r\n * reliable way to prepare, execute, and then release a statement.\r\n *\r\n * A statement may contain parameters that must be filled in before use by the **bind** methods.\r\n *\r\n * Once prepared (and parameters are bound, if any), the statement is executed by calling [ECSqlStatement.step]($backend).\r\n * In case of an **ECSQL SELECT** statement, the current row can be retrieved with [ECSqlStatement.getRow]($backend) as\r\n * a whole, or with [ECSqlStatement.getValue]($backend) when individual values are needed.\r\n * Alternatively, query results of an **ECSQL SELECT** statement can be stepped through by using\r\n * standard iteration syntax, such as `for of`.\r\n *\r\n * > Preparing a statement can be time-consuming. The best way to reduce the effect of this overhead is to cache and reuse prepared\r\n * > statements. A cached prepared statement may be used in different places in an app, as long as the statement is general enough.\r\n * > The key to making this strategy work is to phrase a statement in a general way and use placeholders to represent parameters that will vary on each use.\r\n *\r\n * See also\r\n * - [Executing ECSQL]($docs/learning/backend/ExecutingECSQL) provides more background on ECSQL and an introduction on how to execute ECSQL with the iModel.js API.\r\n * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples) illustrate the use of the iModel.js API for executing and working with ECSQL\r\n * @public\r\n */\r\nexport class ECSqlStatement implements IterableIterator<any>, IDisposable {\r\n private _stmt: IModelJsNative.ECSqlStatement | undefined;\r\n private _sql: string | undefined;\r\n\r\n public get sql() { return this._sql!; } // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n\r\n /** Check if this statement has been prepared successfully or not */\r\n public get isPrepared(): boolean { return !!this._stmt; }\r\n\r\n /** Prepare this statement prior to first use.\r\n * @param db The DgnDb or ECDb to prepare the statement against\r\n * @param ecsql The ECSQL statement string to prepare\r\n * @param logErrors Determine if errors are logged or not\r\n * @throws [IModelError]($common) if the ECSQL statement cannot be prepared. Normally, prepare fails due to ECSQL syntax errors or references to tables or properties that do not exist.\r\n * The error.message property will provide details.\r\n * @internal\r\n */\r\n public prepare(db: IModelJsNative.DgnDb | IModelJsNative.ECDb, ecsql: string, logErrors = true): void {\r\n const stat = this.tryPrepare(db, ecsql, logErrors);\r\n if (stat.status !== DbResult.BE_SQLITE_OK) {\r\n throw new IModelError(stat.status, stat.message);\r\n }\r\n }\r\n\r\n /** Prepare this statement prior to first use.\r\n * @param db The DgnDb or ECDb to prepare the statement against\r\n * @param ecsql The ECSQL statement string to prepare\r\n * @param logErrors Determine if errors are logged or not, its set to false by default for tryPrepare()\r\n * @returns A [StatusCodeWithMessage]($bentley) object with a `status` member equal to [DbResult.BE_SQLITE_OK]($bentley) on success. Upon error, the `message` member will provide details.\r\n * @internal\r\n */\r\n public tryPrepare(db: IModelJsNative.DgnDb | IModelJsNative.ECDb, ecsql: string, logErrors = false): StatusCodeWithMessage<DbResult> {\r\n if (this.isPrepared)\r\n throw new Error(\"ECSqlStatement is already prepared\");\r\n this._sql = ecsql;\r\n this._stmt = new IModelHost.platform.ECSqlStatement();\r\n return this._stmt.prepare(db, ecsql, logErrors);\r\n }\r\n\r\n /** Reset this statement so that the next call to step will return the first row, if any. */\r\n public reset(): void {\r\n assert(undefined !== this._stmt);\r\n this._stmt.reset();\r\n }\r\n\r\n /** Get the Native SQL statement\r\n * @internal\r\n */\r\n public getNativeSql(): string {\r\n assert(undefined !== this._stmt);\r\n return this._stmt.getNativeSql();\r\n }\r\n\r\n /** Call this function when finished with this statement. This releases the native resources held by the statement.\r\n *\r\n * > Do not call this method directly on a statement that is being managed by a statement cache.\r\n */\r\n public dispose(): void {\r\n if (this._stmt) {\r\n this._stmt.dispose(); // free native statement\r\n this._stmt = undefined;\r\n }\r\n }\r\n\r\n /** Binds the specified value to the specified ECSQL parameter.\r\n * The section \"[iModel.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)\" describes the\r\n * iModel.js types to be used for the different ECSQL parameter types.\r\n * @param parameter Index (1-based) or name of the parameter\r\n */\r\n public bindValue(parameter: number | string, val: any): void { this.getBinder(parameter).bind(val); }\r\n\r\n /** Binds null to the specified ECSQL parameter.\r\n * @param parameter Index (1-based) or name of the parameter\r\n */\r\n public bindNull(parameter: number | string): void { this.getBinder(parameter).bindNull(); }\r\n\r\n /** Binds a BLOB value to the specified ECSQL parameter.\r\n * @param parameter Index (1-based) or name of the parameter\r\n * @param BLOB value as either a Uint8Array, ArrayBuffer or a Base64 string\r\n */\r\n public bindBlob(parameter: number | string, blob: string | Uint8Array | ArrayBuffer | SharedArrayBuffer): void { this.getBinder(parameter).bindBlob(blob); }\r\n\r\n /** Binds a boolean value to the specified ECSQL parameter.\r\n * @param parameter Index (1-based) or name of the parameter\r\n * @param val Boolean value\r\n */\r\n public bindBoolean(parameter: number | string, val: boolean): void { this.getBinder(parameter).bindBoolean(val); }\r\n\r\n /** Binds a DateTime value to the specified ECSQL parameter.\r\n * @param parameter Index (1-based) or name of the parameter\r\n * @param isoDateTimeString DateTime value as ISO8601 string\r\n */\r\n public bindDateTime(parameter: number | string, isoDateTimeString: string): void { this.getBinder(parameter).bindDateTime(isoDateTimeString); }\r\n\r\n /** Binds a double value to the specified ECSQL parameter.\r\n * @param parameter Index (1-based) or name of the parameter\r\n * @param val Double value\r\n */\r\n public bindDouble(parameter: number | string, val: number): void { this.getBinder(parameter).bindDouble(val); }\r\n\r\n /** Binds an GUID value to the specified ECSQL parameter.\r\n * @param parameter Index (1-based) or name of the parameter\r\n * @param val GUID value\r\n */\r\n public bindGuid(parameter: number | string, val: GuidString): void { this.getBinder(parameter).bindGuid(val); }\r\n\r\n /** Binds an Id value to the specified ECSQL parameter.\r\n * @param parameter Index (1-based) or name of the parameter\r\n * @param val Id value\r\n */\r\n public bindId(parameter: number | string, val: Id64String): void { this.getBinder(parameter).bindId(val); }\r\n\r\n /** Binds an integer value to the specified ECSQL parameter.\r\n * @param parameter Index (1-based) or name of the parameter\r\n * @param val Integer value as number, decimal string or hexadecimal string.\r\n */\r\n public bindInteger(parameter: number | string, val: number | string): void { this.getBinder(parameter).bindInteger(val); }\r\n\r\n /** Binds an Point2d value to the specified ECSQL parameter.\r\n * @param parameter Index (1-based) or name of the parameter\r\n * @param val Point2d value\r\n */\r\n public bindPoint2d(parameter: number | string, val: XAndY): void { this.getBinder(parameter).bindPoint2d(val); }\r\n\r\n /** Binds an Point3d value to the specified ECSQL parameter.\r\n * @param parameter Index (1-based) or name of the parameter\r\n * @param val Point3d value\r\n */\r\n public bindPoint3d(parameter: number | string, val: XYAndZ): void { this.getBinder(parameter).bindPoint3d(val); }\r\n\r\n /** Binds a Range3d as a blob to the specified ECSQL parameter\r\n * @param parameter Index(1-based) or name of the parameter\r\n * @param val Range3d value\r\n */\r\n public bindRange3d(parameter: number | string, val: LowAndHighXYZ): void { this.getBinder(parameter).bindRange3d(val); }\r\n\r\n /** Binds an string to the specified ECSQL parameter.\r\n * @param parameter Index (1-based) or name of the parameter\r\n * @param val String value\r\n */\r\n public bindString(parameter: number | string, val: string): void { this.getBinder(parameter).bindString(val); }\r\n\r\n /** Binds a navigation property value to the specified ECSQL parameter.\r\n * @param parameter Index (1-based) or name of the parameter\r\n * @param val Navigation property value\r\n */\r\n public bindNavigation(parameter: number | string, val: NavigationBindingValue): void { this.getBinder(parameter).bindNavigation(val); }\r\n\r\n /** Binds a struct property value to the specified ECSQL parameter.\r\n * @param parameter Index (1-based) or name of the parameter\r\n * @param val Struct value. The struct value is an object composed of pairs of a struct member property name and its value\r\n * (of one of the supported types)\r\n */\r\n public bindStruct(parameter: number | string, val: object): void { this.getBinder(parameter).bindStruct(val); }\r\n\r\n /** Binds an array value to the specified ECSQL parameter.\r\n * @param parameter Index (1-based) or name of the parameter\r\n * @param val Array value. The array value is an array of values of the supported types\r\n */\r\n public bindArray(parameter: number | string, val: any[]): void { this.getBinder(parameter).bindArray(val); }\r\n\r\n public bindIdSet(parameter: number | string, val: Id64String[]): void { this.getBinder(parameter).bindIdSet(val); }\r\n /**\r\n * Gets a binder to bind a value for an ECSQL parameter\r\n * > This is the most low-level API to bind a value to a specific parameter. Alternatively you can use the ECSqlStatement.bindXX methods\r\n * > or [ECSqlStatement.bindValues]($backend).\r\n * @param parameter Index (1-based) or name of the parameter\r\n */\r\n public getBinder(parameter: string | number): ECSqlBinder {\r\n assert(undefined !== this._stmt);\r\n return new ECSqlBinder(this._stmt.getBinder(parameter));\r\n }\r\n\r\n /** Bind values to all parameters in the statement.\r\n * @param values The values to bind to the parameters.\r\n * Pass an *array* of values if the parameters are *positional*.\r\n * Pass an *object of the values keyed on the parameter name* for *named parameters*.\r\n * The values in either the array or object must match the respective types of the parameter.\r\n *\r\n * The section \"[iModel.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)\" describes the\r\n * iModel.js types to be used for the different ECSQL parameter types.\r\n *\r\n * See also these [Code Samples]($docs/learning/backend/ECSQLCodeExamples#binding-to-all-parameters-at-once)\r\n */\r\n public bindValues(values: any[] | object): void {\r\n if (Array.isArray(values)) {\r\n for (let i = 0; i < values.length; i++) {\r\n const paramIndex: number = i + 1;\r\n const paramValue: any = values[i];\r\n if (paramValue === undefined || paramValue === null)\r\n continue;\r\n\r\n this.bindValue(paramIndex, paramValue);\r\n }\r\n return;\r\n }\r\n\r\n for (const entry of Object.entries(values)) {\r\n const paramName: string = entry[0];\r\n const paramValue: any = entry[1];\r\n if (paramValue === undefined || paramValue === null)\r\n continue;\r\n\r\n this.bindValue(paramName, paramValue);\r\n }\r\n }\r\n\r\n /** Clear any bindings that were previously set on this statement.\r\n * @throws [IModelError]($common) in case of errors\r\n */\r\n public clearBindings(): void {\r\n if (this._stmt) {\r\n const stat: DbResult = this._stmt.clearBindings();\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, \"Error clearing bindings\");\r\n }\r\n }\r\n\r\n /** Step this statement to the next row.\r\n *\r\n * For **ECSQL SELECT** statements the method returns\r\n * - [DbResult.BE_SQLITE_ROW]($core-bentley) if the statement now points successfully to the next row.\r\n * - [DbResult.BE_SQLITE_DONE]($core-bentley) if the statement has no more rows.\r\n * - Error status in case of errors.\r\n *\r\n * For **ECSQL INSERT, UPDATE, DELETE** statements the method returns\r\n * - [DbResult.BE_SQLITE_DONE]($core-bentley) if the statement has been executed successfully.\r\n * - Error status in case of errors.\r\n *\r\n * > Insert statements can be used with ECDb only, not with IModelDb.\r\n *\r\n * See also: [Code Samples]($docs/learning/backend/ECSQLCodeExamples)\r\n */\r\n public step(): DbResult { return this._stmt!.step(); } // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n\r\n /** @internal added this back in for testing purposes */\r\n public async stepAsync(): Promise<DbResult> {\r\n return new Promise((resolve, _reject) => {\r\n this._stmt!.stepAsync(resolve); // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n });\r\n }\r\n\r\n /** Step this INSERT statement and returns status and the ECInstanceId of the newly\r\n * created instance.\r\n *\r\n * > Insert statements can be used with ECDb only, not with IModelDb.\r\n *\r\n * @returns Returns the generated ECInstanceId in case of success and the status of the step\r\n * call. In case of error, the respective error code is returned.\r\n */\r\n public stepForInsert(): ECSqlInsertResult {\r\n assert(undefined !== this._stmt);\r\n const r: { status: DbResult, id: string } = this._stmt.stepForInsert();\r\n if (r.status === DbResult.BE_SQLITE_DONE)\r\n return new ECSqlInsertResult(r.status, r.id);\r\n\r\n return new ECSqlInsertResult(r.status);\r\n }\r\n\r\n /** Get the query result's column count (only for ECSQL SELECT statements). */\r\n public getColumnCount(): number { return this._stmt!.getColumnCount(); } // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n\r\n /** Get the current row.\r\n * The returned row is formatted as JavaScript object where every SELECT clause item becomes a property in the JavaScript object.\r\n *\r\n * See also:\r\n * - [ECSQL row format]($docs/learning/ECSQLRowFormat) for details about the format of the returned row.\r\n * - [Code Samples]($docs/learning/backend/ECSQLCodeExamples#working-with-the-query-result)\r\n */\r\n public getRow(): any {\r\n const colCount: number = this.getColumnCount();\r\n const row: object = {};\r\n const duplicatePropNames = new Map<string, number>();\r\n for (let i = 0; i < colCount; i++) {\r\n const ecsqlValue = this.getValue(i);\r\n if (!ecsqlValue.isNull) {\r\n const propName: string = ECSqlStatement.determineResultRowPropertyName(duplicatePropNames, ecsqlValue);\r\n const val: any = ecsqlValue.value;\r\n Object.defineProperty(row, propName, { enumerable: true, configurable: true, writable: true, value: val });\r\n }\r\n }\r\n return row;\r\n }\r\n\r\n private static determineResultRowPropertyName(duplicatePropNames: Map<string, number>, ecsqlValue: ECSqlValue): string {\r\n const colInfo: ECSqlColumnInfo = ecsqlValue.columnInfo;\r\n let jsName: string = ECJsNames.toJsName(colInfo.getAccessString(), colInfo.isSystemProperty());\r\n\r\n // now check duplicates. If there are, append a numeric suffix to the duplicates\r\n let suffix: number | undefined = duplicatePropNames.get(jsName);\r\n if (suffix === undefined)\r\n duplicatePropNames.set(jsName, 0);\r\n else {\r\n suffix++;\r\n duplicatePropNames.set(jsName, suffix);\r\n jsName += `_${suffix}`;\r\n }\r\n\r\n return jsName;\r\n }\r\n\r\n /** Calls step when called as an iterator.\r\n *\r\n * Each iteration returns an [ECSQL row format]($docs/learning/ECSQLRowFormat) as returned\r\n * from [ECSqlStatement.getRow]($backend).\r\n */\r\n public next(): IteratorResult<any> {\r\n if (DbResult.BE_SQLITE_ROW === this.step()) {\r\n return {\r\n done: false,\r\n value: this.getRow(),\r\n };\r\n } else {\r\n return {\r\n done: true,\r\n value: undefined,\r\n };\r\n }\r\n }\r\n\r\n /** The iterator that will step through the results of this statement. */\r\n public [Symbol.iterator](): IterableIterator<any> { return this; }\r\n\r\n /** Get the value for the column at the given index in the query result.\r\n * @param columnIx Index of ECSQL column in query result (0-based)\r\n *\r\n * See also: [Code Samples]($docs/learning/backend/ECSQLCodeExamples#working-with-the-query-result)\r\n */\r\n public getValue(columnIx: number): ECSqlValue {\r\n assert(undefined !== this._stmt);\r\n return new ECSqlValue(this._stmt.getValue(columnIx));\r\n }\r\n}\r\n\r\n/** Binds a value to an ECSQL parameter.\r\n *\r\n * See also:\r\n *\r\n * - [ECSqlStatement]($backend)\r\n * - [ECSqlStatement.getBinder]($backend)\r\n * - [Executing ECSQL]($docs/learning/backend/ExecutingECSQL)\r\n * @public\r\n */\r\nexport class ECSqlBinder {\r\n private _binder: IModelJsNative.ECSqlBinder;\r\n\r\n /** @internal */\r\n public constructor(binder: IModelJsNative.ECSqlBinder) { this._binder = binder; }\r\n\r\n /** Binds the specified value to the ECSQL parameter.\r\n * The section \"[iModel.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)\" describes the\r\n * iModel.js types to be used for the different ECSQL parameter types.\r\n * @param val Value to bind\r\n */\r\n public bind(val: any): void {\r\n ECSqlBindingHelper.bindValue(this, val);\r\n }\r\n\r\n /** Binds null to the ECSQL parameter. */\r\n public bindNull(): void {\r\n const stat: DbResult = this._binder.bindNull();\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, \"Error binding null\");\r\n }\r\n\r\n /** Binds a BLOB value to the ECSQL parameter.\r\n * @param BLOB value as either a UInt8Array, ArrayBuffer or a Base64 string\r\n */\r\n public bindBlob(blob: string | Uint8Array | ArrayBuffer | SharedArrayBuffer): void {\r\n const stat: DbResult = this._binder.bindBlob(blob);\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, \"Error binding blob\");\r\n }\r\n\r\n /** Binds a boolean value to the ECSQL parameter.\r\n * @param val Boolean value\r\n */\r\n public bindBoolean(val: boolean): void {\r\n const stat: DbResult = this._binder.bindBoolean(val);\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, \"Error binding boolean\");\r\n }\r\n\r\n /** Binds a DateTime value to the ECSQL parameter.\r\n * @param isoDateTimeString DateTime value as ISO8601 string\r\n */\r\n public bindDateTime(isoDateTimeString: string): void {\r\n const stat: DbResult = this._binder.bindDateTime(isoDateTimeString);\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, \"Error binding DateTime\");\r\n }\r\n\r\n /** Binds a double value to the ECSQL parameter.\r\n * @param val Double value\r\n */\r\n public bindDouble(val: number): void {\r\n const stat: DbResult = this._binder.bindDouble(val);\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, \"Error binding double\");\r\n }\r\n\r\n /** Binds an GUID value to the ECSQL parameter.\r\n * @param val GUID value. If passed as string, it must be formatted as described in [GuidString]($core-bentley).\r\n */\r\n public bindGuid(val: GuidString): void {\r\n const stat: DbResult = this._binder.bindGuid(val);\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, \"Error binding GUID\");\r\n }\r\n\r\n /** Binds an Id value to the ECSQL parameter.\r\n * @param val Id value. If passed as string it must be the hexadecimal representation of the Id.\r\n */\r\n public bindId(val: Id64String): void {\r\n const stat: DbResult = this._binder.bindId(val);\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, \"Error binding Id\");\r\n }\r\n\r\n /** Binds an integer value to the ECSQL parameter.\r\n * @param val Integer value as number, decimal string or hexadecimal string.\r\n */\r\n public bindInteger(val: number | string): void {\r\n const stat: DbResult = this._binder.bindInteger(val);\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, \"Error binding integer\");\r\n }\r\n\r\n /** Binds an Point2d value to the ECSQL parameter.\r\n * @param val Point2d value\r\n */\r\n public bindPoint2d(val: XAndY): void {\r\n const stat: DbResult = this._binder.bindPoint2d(val.x, val.y);\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, \"Error binding Point2d\");\r\n }\r\n\r\n /** Binds an Point3d value to the ECSQL parameter.\r\n * @param val Point3d value\r\n */\r\n public bindPoint3d(val: XYAndZ): void {\r\n const stat: DbResult = this._binder.bindPoint3d(val.x, val.y, val.z);\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, \"Error binding Point3d\");\r\n }\r\n\r\n /** Binds a Range3d as a blob to the ECSQL parameter.\r\n * @param val Range3d value\r\n */\r\n public bindRange3d(val: LowAndHighXYZ): void {\r\n const stat: DbResult = this._binder.bindBlob(Range3d.toFloat64Array(val).buffer);\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, \"Error binding Range3d\");\r\n }\r\n\r\n /** Binds an string to the ECSQL parameter.\r\n * @param val String value\r\n */\r\n public bindString(val: string): void {\r\n const stat: DbResult = this._binder.bindString(val);\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, \"Error binding string\");\r\n }\r\n\r\n /** Binds a navigation property value to the ECSQL parameter.\r\n * @param val Navigation property value\r\n */\r\n public bindNavigation(val: NavigationBindingValue): void {\r\n const stat: DbResult = this._binder.bindNavigation(val.id, val.relClassName, val.relClassTableSpace);\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, \"Error binding navigation property\");\r\n }\r\n\r\n /** Binds a struct property value to the ECSQL parameter.\r\n * @param val Struct value. The struct value is an object composed of pairs of a struct member property name and its value\r\n * (of one of the supported types)\r\n */\r\n public bindStruct(val: object): void { ECSqlBindingHelper.bindStruct(this, val); }\r\n\r\n /** Gets the binder for the specified member of a struct parameter\r\n *\r\n * > This is the most low-level way to bind struct parameters with most flexibility. A simpler alternative is\r\n * > to just call [ECSqlBinder.bindStruct]($backend).\r\n */\r\n public bindMember(memberName: string): ECSqlBinder { return new ECSqlBinder(this._binder.bindMember(memberName)); }\r\n\r\n /** Binds a set of Id strings to the ECSQL parameter.\r\n * @param val array of Id values. If passed as string they must be the hexadecimal representation of the Ids.\r\n */\r\n public bindIdSet(vector: Id64String[]): void {\r\n const stat: DbResult = this._binder.bindIdSet(vector);\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, \"Error binding id set\");\r\n }\r\n\r\n /** Binds an array value to the ECSQL parameter.\r\n * @param val Array value. The array value is an array of values of the supported types\r\n */\r\n public bindArray(val: any[]): void { ECSqlBindingHelper.bindArray(this, val); }\r\n\r\n /** Adds a new array element to the array parameter and returns the binder for the new array element\r\n *\r\n * > This is the most low-level way to bind array parameters with most flexibility. A simpler alternative is\r\n * > to just call [ECSqlBinder.bindArray]($backend).\r\n */\r\n public addArrayElement(): ECSqlBinder { return new ECSqlBinder(this._binder.addArrayElement()); }\r\n}\r\n\r\n/** Represents the value of an ECEnumeration.\r\n *\r\n * See also:\r\n * - [[ECSqlValue.getEnum]]\r\n * - [[ECSqlStatement]]\r\n * - [[ECSqlStatement.getValue]]\r\n * - [Code Samples]($docs/learning/backend/ECSQLCodeExamples#working-with-the-query-result)\r\n * @public\r\n */\r\nexport interface ECEnumValue {\r\n schema: string;\r\n name: string;\r\n key: string;\r\n value: number | string;\r\n}\r\n\r\n/** Value of a column in a row of an ECSQL query result.\r\n *\r\n * See also:\r\n * - [ECSqlStatement]($backend)\r\n * - [ECSqlStatement.getValue]($backend)\r\n * - [Code Samples]($docs/learning/backend/ECSQLCodeExamples#working-with-the-query-result)\r\n * @public\r\n */\r\nexport class ECSqlValue {\r\n private _val: IModelJsNative.ECSqlValue;\r\n\r\n /** @internal */\r\n public constructor(val: IModelJsNative.ECSqlValue) { this._val = val; }\r\n\r\n /** Get information about the query result's column this value refers to. */\r\n public get columnInfo(): ECSqlColumnInfo { return this._val.getColumnInfo() as ECSqlColumnInfo; }\r\n\r\n /** Get the value of this ECSQL value */\r\n public get value(): any { return ECSqlValueHelper.getValue(this); }\r\n\r\n /** Indicates whether the value is NULL or not. */\r\n public get isNull(): boolean { return this._val.isNull(); }\r\n /** Get the value as BLOB */\r\n public getBlob(): Uint8Array { return this._val.getBlob(); }\r\n /** Get the value as a boolean value */\r\n public getBoolean(): boolean { return this._val.getBoolean(); }\r\n /** Get the value as a DateTime value (formatted as ISO8601 string) */\r\n public getDateTime(): string { return this._val.getDateTime(); }\r\n /** Get the value as a double value */\r\n public getDouble(): number { return this._val.getDouble(); }\r\n /** Get the value as a IGeometry value (as ECJSON IGeometry) */\r\n public getGeometry(): any { return JSON.parse(this._val.getGeometry()); }\r\n /** Get the value as a GUID (formatted as GUID string).\r\n * See [GuidString]($core-bentley)\r\n */\r\n public getGuid(): GuidString { return this._val.getGuid(); }\r\n /** Get the value as a Id (formatted as hexadecimal string). */\r\n public getId(): Id64String { return this._val.getId(); }\r\n /** Get the ClassId value formatted as fully qualified class name. */\r\n public getClassNameForClassId(): string { return this._val.getClassNameForClassId(); }\r\n /** Get the value as a integer value */\r\n public getInteger(): number { return this._val.getInt64(); }\r\n /** Get the value as a string value */\r\n public getString(): string { return this._val.getString(); }\r\n /** Get the value as [XAndY]($core-geometry) */\r\n public getXAndY(): XAndY { return this._val.getPoint2d(); }\r\n /** Get the value as [XYAndZ]($core-geometry) */\r\n public getXYAndZ(): XYAndZ { return this._val.getPoint3d(); }\r\n /** Get the value as ECEnumeration value\r\n * Note: This method is optional. Using [[ECSqlValue.getInteger]] for integral enums and\r\n * [[ECSqlValue.getString]] for string enums respectively are the usual way to get\r\n * enum values. This method can be used if the context of the underlying ECEnumeration\r\n * is required.\r\n * The value is broken down into the ECEnumerators that make it up, if the value\r\n * is a combination of ECEnumerators. If the value is not a strict match of an ECEnumerator\r\n * or a combination of them, undefined is returned.\r\n * > Note: You can call [[ECSqlValue.columnInfo.isEnum]] to find out whether\r\n * > this method can be called or not.\r\n * @return ECEnumeration value(s) or undefined if the ECSqlValue does not represent an ECEnumeration.\r\n * or is not a strict match of an ECEnumerator or a combination of them.\r\n */\r\n public getEnum(): ECEnumValue[] | undefined { return this._val.getEnum(); }\r\n\r\n /** Get the value as [NavigationValue]($common) */\r\n public getNavigation(): NavigationValue { return this._val.getNavigation(); }\r\n\r\n /** Get an iterator for iterating the struct members of this struct value. */\r\n public getStructIterator(): ECSqlValueIterator { return new ECSqlValueIterator(this._val.getStructIterator()); }\r\n\r\n /** Get this struct value's content as object literal */\r\n public getStruct(): any { return ECSqlValueHelper.getStruct(this); }\r\n\r\n /** Get an iterator for iterating the array elements of this array value. */\r\n public getArrayIterator(): ECSqlValueIterator { return new ECSqlValueIterator(this._val.getArrayIterator()); }\r\n\r\n /** Get this array value as JavaScript array */\r\n public getArray(): any[] { return ECSqlValueHelper.getArray(this); }\r\n}\r\n\r\n/** Iterator over members of a struct [ECSqlValue]($backend) or the elements of an array [ECSqlValue]($backend).\r\n * See [ECSqlValue.getStructIterator]($backend) or [ECSqlValue.getArrayIterator]($backend).\r\n * @public\r\n */\r\nexport class ECSqlValueIterator implements IterableIterator<ECSqlValue> {\r\n private _it: IModelJsNative.ECSqlValueIterator;\r\n\r\n /** @internal */\r\n public constructor(it: IModelJsNative.ECSqlValueIterator) { this._it = it; }\r\n\r\n public next(): IteratorResult<ECSqlValue> {\r\n if (this._it.moveNext())\r\n return { done: false, value: new ECSqlValue(this._it.getCurrent()) };\r\n\r\n return { done: true, value: undefined };\r\n }\r\n\r\n public [Symbol.iterator](): IterableIterator<ECSqlValue> { return this; }\r\n}\r\n\r\n/** Information about an ECSQL column in an ECSQL query result.\r\n * See [ECSqlValue.columnInfo]($backend), [ECSqlStatement.getValue]($backend), [ECSqlStatement]($backend)\r\n * @public\r\n */\r\nexport interface ECSqlColumnInfo {\r\n /** Gets the data type of the column.\r\n */\r\n getType(): ECSqlValueType;\r\n\r\n /** Gets the name of the property backing the column.\r\n * > If this column is backed by a generated property, i.e. it represents ECSQL expression,\r\n * > the access string consists of the name of the generated property.\r\n */\r\n getPropertyName(): string;\r\n\r\n /** Gets the full access string to the corresponding ECSqlValue starting from the root class.\r\n * > If this column is backed by a generated property, i.e. it represents ECSQL expression,\r\n * > the access string consists of the ECSQL expression.\r\n */\r\n getAccessString(): string;\r\n\r\n /** Indicates whether the column refers to an ECEnumeration property. */\r\n isEnum(): boolean;\r\n\r\n /** Indicates whether the column refers to a system property (e.g. id, className). */\r\n isSystemProperty(): boolean;\r\n\r\n /** Indicates whether the column is backed by a generated property or not. For SELECT clause items that are expressions other\r\n * than simply a reference to an ECProperty, a property is generated containing the expression name.\r\n */\r\n isGeneratedProperty(): boolean;\r\n\r\n /** Gets the table space in which this root class is persisted.\r\n * > For classes in the primary file the table space is MAIN. For classes in attached\r\n * > files, the table space is the name by which the file was attached. For generated properties the table space is empty.\r\n */\r\n getRootClassTableSpace(): string;\r\n\r\n /** Gets the fully qualified name of the ECClass of the top-level ECProperty backing this column. */\r\n getRootClassName(): string;\r\n\r\n /** Gets the class alias of the root class to which the column refers to.\r\n * > Returns an empty string if no class alias was specified in the select clause.\r\n */\r\n getRootClassAlias(): string;\r\n}\r\n\r\nclass ECSqlBindingHelper {\r\n\r\n /** Binds the specified value to the specified binder\r\n * @param binder Parameter Binder to bind to\r\n * @param val Value to be bound. (See [iModel.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes))\r\n * @throws IModelError in case of errors\r\n */\r\n public static bindValue(binder: ECSqlBinder, val: any): void {\r\n // returns false if val is no primitive and returns true if it is primitive and a binding call was done\r\n if (ECSqlBindingHelper.tryBindPrimitiveTypes(binder, val))\r\n return;\r\n\r\n if (Array.isArray(val)) {\r\n ECSqlBindingHelper.bindArray(binder, val);\r\n return;\r\n }\r\n\r\n if (typeof (val) === \"object\") {\r\n ECSqlBindingHelper.bindStruct(binder, val);\r\n return;\r\n }\r\n\r\n throw new Error(`Bound value is of an unsupported type: ${val}`);\r\n }\r\n\r\n /** Binds the specified primitive value to the specified binder\r\n * @param binder Parameter Binder to bind to\r\n * @param val Primitive value to be bound. Must be of one of these types described here:\r\n * [ECSQL Binding types]($docs/learning/ECSQLParameterTypes)\r\n * @throws IModelError in case of errors\r\n */\r\n public static bindPrimitive(binder: ECSqlBinder, val: any): void {\r\n if (!ECSqlBindingHelper.tryBindPrimitiveTypes(binder, val))\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, `Binding value is of an unsupported primitive type: ${val}`);\r\n }\r\n\r\n /** Binds the specified object to the specified struct binder\r\n * @param binder Struct parameter binder to bind to\r\n * @param val Value to be bound. Must be an Object with members of the supported types\r\n * @throws IModelError in case of errors\r\n */\r\n public static bindStruct(binder: ECSqlBinder, val: object): void {\r\n if (val === null || val === undefined) {\r\n binder.bindNull();\r\n return;\r\n }\r\n\r\n for (const member of Object.entries(val)) {\r\n const memberName: string = member[0];\r\n const memberVal: any = member[1];\r\n ECSqlBindingHelper.bindValue(binder.bindMember(memberName), memberVal);\r\n }\r\n }\r\n\r\n /** Binds the specified array to the specified array binder\r\n * @param binder Array parameter binder to bind to\r\n * @param val Value to be bound. Must be an Array with elements of the supported types\r\n * @throws IModelError in case of errors\r\n */\r\n public static bindArray(binder: ECSqlBinder, val: any[]): void {\r\n if (val === null || val === undefined) {\r\n binder.bindNull();\r\n return;\r\n }\r\n\r\n for (const element of val) {\r\n ECSqlBindingHelper.bindValue(binder.addArrayElement(), element);\r\n }\r\n }\r\n\r\n /** tries to interpret the passed value as known leaf types (primitives and navigation values).\r\n * @returns Returns undefined if the value wasn't a primitive. DbResult if it was a primitive and was bound to the binder\r\n */\r\n private static tryBindPrimitiveTypes(binder: ECSqlBinder, val: any): boolean {\r\n if (val === undefined || val === null) {\r\n binder.bindNull();\r\n return true;\r\n }\r\n\r\n if (typeof (val) === \"number\") {\r\n if (Number.isInteger(val))\r\n binder.bindInteger(val);\r\n else\r\n binder.bindDouble(val);\r\n\r\n return true;\r\n }\r\n\r\n if (typeof (val) === \"boolean\") {\r\n binder.bindBoolean(val);\r\n return true;\r\n }\r\n\r\n if (typeof (val) === \"string\") {\r\n binder.bindString(val);\r\n return true;\r\n }\r\n\r\n if (ECSqlTypeHelper.isBlob(val)) {\r\n binder.bindBlob(val);\r\n return true;\r\n }\r\n\r\n if (ECSqlTypeHelper.isXYAndZ(val)) {\r\n binder.bindPoint3d(val);\r\n return true;\r\n }\r\n\r\n if (ECSqlTypeHelper.isXAndY(val)) {\r\n binder.bindPoint2d(val);\r\n return true;\r\n }\r\n\r\n if (ECSqlTypeHelper.isLowAndHighXYZ(val)) {\r\n binder.bindRange3d(val);\r\n return true;\r\n }\r\n\r\n if (ECSqlTypeHelper.isNavigationBindingValue(val)) {\r\n binder.bindNavigation(val);\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n}\r\n\r\nclass ECSqlValueHelper {\r\n public static getValue(ecsqlValue: ECSqlValue): any {\r\n if (ecsqlValue.isNull)\r\n return undefined;\r\n\r\n const dataType: ECSqlValueType = ecsqlValue.columnInfo.getType();\r\n switch (dataType) {\r\n case ECSqlValueType.Struct:\r\n return ECSqlValueHelper.getStruct(ecsqlValue);\r\n\r\n case ECSqlValueType.Navigation:\r\n return ecsqlValue.getNavigation();\r\n\r\n case ECSqlValueType.PrimitiveArray:\r\n case ECSqlValueType.StructArray:\r\n return ECSqlValueHelper.getArray(ecsqlValue);\r\n\r\n default:\r\n return ECSqlValueHelper.getPrimitiveValue(ecsqlValue);\r\n }\r\n }\r\n\r\n public static getStruct(ecsqlValue: ECSqlValue): any {\r\n if (ecsqlValue.isNull)\r\n return undefined;\r\n\r\n const structVal = {};\r\n const it = ecsqlValue.getStructIterator();\r\n try {\r\n for (const memberECSqlVal of it) {\r\n if (memberECSqlVal.isNull)\r\n continue;\r\n\r\n const memberName: string = ECJsNames.toJsName(memberECSqlVal.columnInfo.getPropertyName());\r\n const memberVal = ECSqlValueHelper.getValue(memberECSqlVal);\r\n Object.defineProperty(structVal, memberName, { enumerable: true, configurable: true, writable: true, value: memberVal });\r\n }\r\n } finally {\r\n }\r\n\r\n return structVal;\r\n }\r\n\r\n public static getArray(ecsqlValue: ECSqlValue): any[] {\r\n const arrayVal: any[] = [];\r\n const it = ecsqlValue.getArrayIterator();\r\n try {\r\n for (const elementECSqlVal of it) {\r\n const memberVal = ECSqlValueHelper.getValue(elementECSqlVal);\r\n arrayVal.push(memberVal);\r\n }\r\n } finally {\r\n }\r\n return arrayVal;\r\n }\r\n\r\n private static getPrimitiveValue(ecsqlValue: ECSqlValue): any {\r\n if (ecsqlValue.isNull)\r\n return undefined;\r\n\r\n const colInfo: ECSqlColumnInfo = ecsqlValue.columnInfo;\r\n switch (colInfo.getType()) {\r\n case ECSqlValueType.Blob:\r\n return ecsqlValue.getBlob();\r\n case ECSqlValueType.Boolean:\r\n return ecsqlValue.getBoolean();\r\n case ECSqlValueType.DateTime:\r\n return ecsqlValue.getDateTime();\r\n case ECSqlValueType.Double:\r\n return ecsqlValue.getDouble();\r\n case ECSqlValueType.Geometry:\r\n return ecsqlValue.getGeometry();\r\n case ECSqlValueType.Guid:\r\n return ecsqlValue.getGuid();\r\n case ECSqlValueType.Id: {\r\n if (colInfo.isSystemProperty() && colInfo.getPropertyName().endsWith(\"ECClassId\"))\r\n return ecsqlValue.getClassNameForClassId();\r\n\r\n return ecsqlValue.getId();\r\n }\r\n case ECSqlValueType.Int:\r\n case ECSqlValueType.Int64:\r\n return ecsqlValue.getInteger();\r\n case ECSqlValueType.Point2d:\r\n return ecsqlValue.getXAndY();\r\n case ECSqlValueType.Point3d:\r\n return ecsqlValue.getXYAndZ();\r\n case ECSqlValueType.String:\r\n return ecsqlValue.getString();\r\n default:\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, `Unsupported type ${ecsqlValue.columnInfo.getType()} of the ECSQL Value`);\r\n }\r\n }\r\n\r\n public static queryClassName(ecdb: ECDb, classId: Id64String, tableSpace?: string): string {\r\n if (!tableSpace)\r\n tableSpace = \"main\";\r\n\r\n return ecdb.withPreparedStatement(`SELECT s.Name, c.Name FROM [${tableSpace}].meta.ECSchemaDef s, JOIN [${tableSpace}].meta.ECClassDef c ON s.ECInstanceId=c.SchemaId WHERE c.ECInstanceId=?`,\r\n (stmt: ECSqlStatement) => {\r\n stmt.bindId(1, classId);\r\n if (stmt.step() !== DbResult.BE_SQLITE_ROW)\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, `No class found with ECClassId ${classId} in table space ${tableSpace}.`);\r\n\r\n return `${stmt.getValue(0).getString()}.${stmt.getValue(1).getString()}`;\r\n });\r\n }\r\n}\r\n\r\nclass ECSqlTypeHelper {\r\n public static isBlob(val: any): val is Uint8Array { return val instanceof Uint8Array; }\r\n\r\n public static isXAndY(val: any): val is XAndY { return XYZ.isXAndY(val); }\r\n public static isXYAndZ(val: any): val is XYAndZ { return XYZ.isXYAndZ(val); }\r\n public static isLowAndHighXYZ(arg: any): arg is LowAndHighXYZ { return arg.low !== undefined && ECSqlTypeHelper.isXYAndZ(arg.low) && arg.high !== undefined && ECSqlTypeHelper.isXYAndZ(arg.high); }\r\n\r\n public static isNavigationBindingValue(val: any): val is NavigationBindingValue { return val.id !== undefined && typeof (val.id) === \"string\"; }\r\n}\r\n"]}
1
+ {"version":3,"file":"ECSqlStatement.js","sourceRoot":"","sources":["../../src/ECSqlStatement.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAmH;AACnH,wDAAkF;AAClF,oDAAqH;AAGrH,6CAA0C;AAE1C;;;;;;;;;GASG;AACH,MAAa,iBAAiB;IAC5B,YAA0B,MAAgB,EAAS,EAAe;QAAxC,WAAM,GAAN,MAAM,CAAU;QAAS,OAAE,GAAF,EAAE,CAAa;IAAI,CAAC;CACxE;AAFD,8CAEC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAa,cAAc;IAIzB,IAAW,GAAG,KAAK,OAAO,IAAI,CAAC,IAAK,CAAC,CAAC,CAAC,CAAC,+DAA+D;IAEvG,oEAAoE;IACpE,IAAW,UAAU,KAAc,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAEzD;;;;;;;OAOG;IACI,OAAO,CAAC,EAA8C,EAAE,KAAa,EAAE,SAAS,GAAG,IAAI;QAC5F,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;QACnD,IAAI,IAAI,CAAC,MAAM,KAAK,uBAAQ,CAAC,YAAY,EAAE;YACzC,MAAM,IAAI,yBAAW,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;SAClD;IACH,CAAC;IAED;;;;;;OAMG;IACI,UAAU,CAAC,EAA8C,EAAE,KAAa,EAAE,SAAS,GAAG,KAA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AM,CAAC,QAAQ,CAAC,GAAQ,IAAmB,OAAO,mBAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACtE,MAAM,CAAC,eAAe,CAAC,GAAQ,IAA0B,OAAO,GAAG,CAAC,GAAG,KAAK,SAAS,IAAI,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS,IAAI,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAE7L,MAAM,CAAC,wBAAwB,CAAC,GAAQ,IAAmC,OAAO,GAAG,CAAC,EAAE,KAAK,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC;CACjJ","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 ECSQL\r\n */\r\n\r\nimport { assert, DbResult, GuidString, Id64String, IDisposable, StatusCodeWithMessage } from \"@itwin/core-bentley\";\r\nimport { LowAndHighXYZ, Range3d, XAndY, XYAndZ, XYZ } from \"@itwin/core-geometry\";\r\nimport { ECJsNames, ECSqlValueType, IModelError, NavigationBindingValue, NavigationValue } from \"@itwin/core-common\";\r\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\nimport { ECDb } from \"./ECDb\";\r\nimport { IModelHost } from \"./IModelHost\";\r\n\r\n/** The result of an **ECSQL INSERT** statement as returned from [ECSqlStatement.stepForInsert]($backend).\r\n *\r\n * If the step was successful, the ECSqlInsertResult contains\r\n * [DbResult.BE_SQLITE_DONE]($core-bentley)\r\n * and the ECInstanceId of the newly created instance.\r\n * In case of failure it contains the [DbResult]($core-bentley) error code.\r\n *\r\n * > Insert statements can be used with ECDb only, not with IModelDb.\r\n * @public\r\n */\r\nexport class ECSqlInsertResult {\r\n public constructor(public status: DbResult, public id?: Id64String) { }\r\n}\r\n\r\n/** Executes ECSQL statements.\r\n *\r\n * A statement must be prepared before it can be executed, and it must be released when no longer needed.\r\n * See [IModelDb.withPreparedStatement]($backend) or\r\n * [ECDb.withPreparedStatement]($backend) for a convenient and\r\n * reliable way to prepare, execute, and then release a statement.\r\n *\r\n * A statement may contain parameters that must be filled in before use by the **bind** methods.\r\n *\r\n * Once prepared (and parameters are bound, if any), the statement is executed by calling [ECSqlStatement.step]($backend).\r\n * In case of an **ECSQL SELECT** statement, the current row can be retrieved with [ECSqlStatement.getRow]($backend) as\r\n * a whole, or with [ECSqlStatement.getValue]($backend) when individual values are needed.\r\n * Alternatively, query results of an **ECSQL SELECT** statement can be stepped through by using\r\n * standard iteration syntax, such as `for of`.\r\n *\r\n * > Preparing a statement can be time-consuming. The best way to reduce the effect of this overhead is to cache and reuse prepared\r\n * > statements. A cached prepared statement may be used in different places in an app, as long as the statement is general enough.\r\n * > The key to making this strategy work is to phrase a statement in a general way and use placeholders to represent parameters that will vary on each use.\r\n *\r\n * See also\r\n * - [Executing ECSQL]($docs/learning/backend/ExecutingECSQL) provides more background on ECSQL and an introduction on how to execute ECSQL with the iTwin.js API.\r\n * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples) illustrate the use of the iTwin.js API for executing and working with ECSQL\r\n * @public\r\n */\r\nexport class ECSqlStatement implements IterableIterator<any>, IDisposable {\r\n private _stmt: IModelJsNative.ECSqlStatement | undefined;\r\n private _sql: string | undefined;\r\n\r\n public get sql() { return this._sql!; } // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n\r\n /** Check if this statement has been prepared successfully or not */\r\n public get isPrepared(): boolean { return !!this._stmt; }\r\n\r\n /** Prepare this statement prior to first use.\r\n * @param db The DgnDb or ECDb to prepare the statement against\r\n * @param ecsql The ECSQL statement string to prepare\r\n * @param logErrors Determine if errors are logged or not\r\n * @throws [IModelError]($common) if the ECSQL statement cannot be prepared. Normally, prepare fails due to ECSQL syntax errors or references to tables or properties that do not exist.\r\n * The error.message property will provide details.\r\n * @internal\r\n */\r\n public prepare(db: IModelJsNative.DgnDb | IModelJsNative.ECDb, ecsql: string, logErrors = true): void {\r\n const stat = this.tryPrepare(db, ecsql, logErrors);\r\n if (stat.status !== DbResult.BE_SQLITE_OK) {\r\n throw new IModelError(stat.status, stat.message);\r\n }\r\n }\r\n\r\n /** Prepare this statement prior to first use.\r\n * @param db The DgnDb or ECDb to prepare the statement against\r\n * @param ecsql The ECSQL statement string to prepare\r\n * @param logErrors Determine if errors are logged or not, its set to false by default for tryPrepare()\r\n * @returns A [StatusCodeWithMessage]($bentley) object with a `status` member equal to [DbResult.BE_SQLITE_OK]($bentley) on success. Upon error, the `message` member will provide details.\r\n * @internal\r\n */\r\n public tryPrepare(db: IModelJsNative.DgnDb | IModelJsNative.ECDb, ecsql: string, logErrors = false): StatusCodeWithMessage<DbResult> {\r\n if (this.isPrepared)\r\n throw new Error(\"ECSqlStatement is already prepared\");\r\n this._sql = ecsql;\r\n this._stmt = new IModelHost.platform.ECSqlStatement();\r\n return this._stmt.prepare(db, ecsql, logErrors);\r\n }\r\n\r\n /** Reset this statement so that the next call to step will return the first row, if any. */\r\n public reset(): void {\r\n assert(undefined !== this._stmt);\r\n this._stmt.reset();\r\n }\r\n\r\n /** Get the Native SQL statement\r\n * @internal\r\n */\r\n public getNativeSql(): string {\r\n assert(undefined !== this._stmt);\r\n return this._stmt.getNativeSql();\r\n }\r\n\r\n /** Call this function when finished with this statement. This releases the native resources held by the statement.\r\n *\r\n * > Do not call this method directly on a statement that is being managed by a statement cache.\r\n */\r\n public dispose(): void {\r\n if (this._stmt) {\r\n this._stmt.dispose(); // free native statement\r\n this._stmt = undefined;\r\n }\r\n }\r\n\r\n /** Binds the specified value to the specified ECSQL parameter.\r\n * The section \"[iTwin.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)\" describes the\r\n * iTwin.js types to be used for the different ECSQL parameter types.\r\n * @param parameter Index (1-based) or name of the parameter\r\n */\r\n public bindValue(parameter: number | string, val: any): void { this.getBinder(parameter).bind(val); }\r\n\r\n /** Binds null to the specified ECSQL parameter.\r\n * @param parameter Index (1-based) or name of the parameter\r\n */\r\n public bindNull(parameter: number | string): void { this.getBinder(parameter).bindNull(); }\r\n\r\n /** Binds a BLOB value to the specified ECSQL parameter.\r\n * @param parameter Index (1-based) or name of the parameter\r\n * @param BLOB value as either a Uint8Array, ArrayBuffer or a Base64 string\r\n */\r\n public bindBlob(parameter: number | string, blob: string | Uint8Array | ArrayBuffer | SharedArrayBuffer): void { this.getBinder(parameter).bindBlob(blob); }\r\n\r\n /** Binds a boolean value to the specified ECSQL parameter.\r\n * @param parameter Index (1-based) or name of the parameter\r\n * @param val Boolean value\r\n */\r\n public bindBoolean(parameter: number | string, val: boolean): void { this.getBinder(parameter).bindBoolean(val); }\r\n\r\n /** Binds a DateTime value to the specified ECSQL parameter.\r\n * @param parameter Index (1-based) or name of the parameter\r\n * @param isoDateTimeString DateTime value as ISO8601 string\r\n */\r\n public bindDateTime(parameter: number | string, isoDateTimeString: string): void { this.getBinder(parameter).bindDateTime(isoDateTimeString); }\r\n\r\n /** Binds a double value to the specified ECSQL parameter.\r\n * @param parameter Index (1-based) or name of the parameter\r\n * @param val Double value\r\n */\r\n public bindDouble(parameter: number | string, val: number): void { this.getBinder(parameter).bindDouble(val); }\r\n\r\n /** Binds an GUID value to the specified ECSQL parameter.\r\n * @param parameter Index (1-based) or name of the parameter\r\n * @param val GUID value\r\n */\r\n public bindGuid(parameter: number | string, val: GuidString): void { this.getBinder(parameter).bindGuid(val); }\r\n\r\n /** Binds an Id value to the specified ECSQL parameter.\r\n * @param parameter Index (1-based) or name of the parameter\r\n * @param val Id value\r\n */\r\n public bindId(parameter: number | string, val: Id64String): void { this.getBinder(parameter).bindId(val); }\r\n\r\n /** Binds an integer value to the specified ECSQL parameter.\r\n * @param parameter Index (1-based) or name of the parameter\r\n * @param val Integer value as number, decimal string or hexadecimal string.\r\n */\r\n public bindInteger(parameter: number | string, val: number | string): void { this.getBinder(parameter).bindInteger(val); }\r\n\r\n /** Binds an Point2d value to the specified ECSQL parameter.\r\n * @param parameter Index (1-based) or name of the parameter\r\n * @param val Point2d value\r\n */\r\n public bindPoint2d(parameter: number | string, val: XAndY): void { this.getBinder(parameter).bindPoint2d(val); }\r\n\r\n /** Binds an Point3d value to the specified ECSQL parameter.\r\n * @param parameter Index (1-based) or name of the parameter\r\n * @param val Point3d value\r\n */\r\n public bindPoint3d(parameter: number | string, val: XYAndZ): void { this.getBinder(parameter).bindPoint3d(val); }\r\n\r\n /** Binds a Range3d as a blob to the specified ECSQL parameter\r\n * @param parameter Index(1-based) or name of the parameter\r\n * @param val Range3d value\r\n */\r\n public bindRange3d(parameter: number | string, val: LowAndHighXYZ): void { this.getBinder(parameter).bindRange3d(val); }\r\n\r\n /** Binds an string to the specified ECSQL parameter.\r\n * @param parameter Index (1-based) or name of the parameter\r\n * @param val String value\r\n */\r\n public bindString(parameter: number | string, val: string): void { this.getBinder(parameter).bindString(val); }\r\n\r\n /** Binds a navigation property value to the specified ECSQL parameter.\r\n * @param parameter Index (1-based) or name of the parameter\r\n * @param val Navigation property value\r\n */\r\n public bindNavigation(parameter: number | string, val: NavigationBindingValue): void { this.getBinder(parameter).bindNavigation(val); }\r\n\r\n /** Binds a struct property value to the specified ECSQL parameter.\r\n * @param parameter Index (1-based) or name of the parameter\r\n * @param val Struct value. The struct value is an object composed of pairs of a struct member property name and its value\r\n * (of one of the supported types)\r\n */\r\n public bindStruct(parameter: number | string, val: object): void { this.getBinder(parameter).bindStruct(val); }\r\n\r\n /** Binds an array value to the specified ECSQL parameter.\r\n * @param parameter Index (1-based) or name of the parameter\r\n * @param val Array value. The array value is an array of values of the supported types\r\n */\r\n public bindArray(parameter: number | string, val: any[]): void { this.getBinder(parameter).bindArray(val); }\r\n\r\n public bindIdSet(parameter: number | string, val: Id64String[]): void { this.getBinder(parameter).bindIdSet(val); }\r\n /**\r\n * Gets a binder to bind a value for an ECSQL parameter\r\n * > This is the most low-level API to bind a value to a specific parameter. Alternatively you can use the ECSqlStatement.bindXX methods\r\n * > or [ECSqlStatement.bindValues]($backend).\r\n * @param parameter Index (1-based) or name of the parameter\r\n */\r\n public getBinder(parameter: string | number): ECSqlBinder {\r\n assert(undefined !== this._stmt);\r\n return new ECSqlBinder(this._stmt.getBinder(parameter));\r\n }\r\n\r\n /** Bind values to all parameters in the statement.\r\n * @param values The values to bind to the parameters.\r\n * Pass an *array* of values if the parameters are *positional*.\r\n * Pass an *object of the values keyed on the parameter name* for *named parameters*.\r\n * The values in either the array or object must match the respective types of the parameter.\r\n *\r\n * The section \"[iTwin.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)\" describes the\r\n * iTwin.js types to be used for the different ECSQL parameter types.\r\n *\r\n * See also these [Code Samples]($docs/learning/backend/ECSQLCodeExamples#binding-to-all-parameters-at-once)\r\n */\r\n public bindValues(values: any[] | object): void {\r\n if (Array.isArray(values)) {\r\n for (let i = 0; i < values.length; i++) {\r\n const paramIndex: number = i + 1;\r\n const paramValue: any = values[i];\r\n if (paramValue === undefined || paramValue === null)\r\n continue;\r\n\r\n this.bindValue(paramIndex, paramValue);\r\n }\r\n return;\r\n }\r\n\r\n for (const entry of Object.entries(values)) {\r\n const paramName: string = entry[0];\r\n const paramValue: any = entry[1];\r\n if (paramValue === undefined || paramValue === null)\r\n continue;\r\n\r\n this.bindValue(paramName, paramValue);\r\n }\r\n }\r\n\r\n /** Clear any bindings that were previously set on this statement.\r\n * @throws [IModelError]($common) in case of errors\r\n */\r\n public clearBindings(): void {\r\n if (this._stmt) {\r\n const stat: DbResult = this._stmt.clearBindings();\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, \"Error clearing bindings\");\r\n }\r\n }\r\n\r\n /** Step this statement to the next row.\r\n *\r\n * For **ECSQL SELECT** statements the method returns\r\n * - [DbResult.BE_SQLITE_ROW]($core-bentley) if the statement now points successfully to the next row.\r\n * - [DbResult.BE_SQLITE_DONE]($core-bentley) if the statement has no more rows.\r\n * - Error status in case of errors.\r\n *\r\n * For **ECSQL INSERT, UPDATE, DELETE** statements the method returns\r\n * - [DbResult.BE_SQLITE_DONE]($core-bentley) if the statement has been executed successfully.\r\n * - Error status in case of errors.\r\n *\r\n * > Insert statements can be used with ECDb only, not with IModelDb.\r\n *\r\n * See also: [Code Samples]($docs/learning/backend/ECSQLCodeExamples)\r\n */\r\n public step(): DbResult { return this._stmt!.step(); } // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n\r\n /** @internal added this back in for testing purposes */\r\n public async stepAsync(): Promise<DbResult> {\r\n return new Promise((resolve, _reject) => {\r\n this._stmt!.stepAsync(resolve); // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n });\r\n }\r\n\r\n /** Step this INSERT statement and returns status and the ECInstanceId of the newly\r\n * created instance.\r\n *\r\n * > Insert statements can be used with ECDb only, not with IModelDb.\r\n *\r\n * @returns Returns the generated ECInstanceId in case of success and the status of the step\r\n * call. In case of error, the respective error code is returned.\r\n */\r\n public stepForInsert(): ECSqlInsertResult {\r\n assert(undefined !== this._stmt);\r\n const r: { status: DbResult, id: string } = this._stmt.stepForInsert();\r\n if (r.status === DbResult.BE_SQLITE_DONE)\r\n return new ECSqlInsertResult(r.status, r.id);\r\n\r\n return new ECSqlInsertResult(r.status);\r\n }\r\n\r\n /** Get the query result's column count (only for ECSQL SELECT statements). */\r\n public getColumnCount(): number { return this._stmt!.getColumnCount(); } // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n\r\n /** Get the current row.\r\n * The returned row is formatted as JavaScript object where every SELECT clause item becomes a property in the JavaScript object.\r\n *\r\n * See also:\r\n * - [ECSQL row format]($docs/learning/ECSQLRowFormat) for details about the format of the returned row.\r\n * - [Code Samples]($docs/learning/backend/ECSQLCodeExamples#working-with-the-query-result)\r\n */\r\n public getRow(): any {\r\n const colCount: number = this.getColumnCount();\r\n const row: object = {};\r\n const duplicatePropNames = new Map<string, number>();\r\n for (let i = 0; i < colCount; i++) {\r\n const ecsqlValue = this.getValue(i);\r\n if (!ecsqlValue.isNull) {\r\n const propName: string = ECSqlStatement.determineResultRowPropertyName(duplicatePropNames, ecsqlValue);\r\n const val: any = ecsqlValue.value;\r\n Object.defineProperty(row, propName, { enumerable: true, configurable: true, writable: true, value: val });\r\n }\r\n }\r\n return row;\r\n }\r\n\r\n private static determineResultRowPropertyName(duplicatePropNames: Map<string, number>, ecsqlValue: ECSqlValue): string {\r\n const colInfo: ECSqlColumnInfo = ecsqlValue.columnInfo;\r\n let jsName: string = ECJsNames.toJsName(colInfo.getAccessString(), colInfo.isSystemProperty());\r\n\r\n // now check duplicates. If there are, append a numeric suffix to the duplicates\r\n let suffix: number | undefined = duplicatePropNames.get(jsName);\r\n if (suffix === undefined)\r\n duplicatePropNames.set(jsName, 0);\r\n else {\r\n suffix++;\r\n duplicatePropNames.set(jsName, suffix);\r\n jsName += `_${suffix}`;\r\n }\r\n\r\n return jsName;\r\n }\r\n\r\n /** Calls step when called as an iterator.\r\n *\r\n * Each iteration returns an [ECSQL row format]($docs/learning/ECSQLRowFormat) as returned\r\n * from [ECSqlStatement.getRow]($backend).\r\n */\r\n public next(): IteratorResult<any> {\r\n if (DbResult.BE_SQLITE_ROW === this.step()) {\r\n return {\r\n done: false,\r\n value: this.getRow(),\r\n };\r\n } else {\r\n return {\r\n done: true,\r\n value: undefined,\r\n };\r\n }\r\n }\r\n\r\n /** The iterator that will step through the results of this statement. */\r\n public [Symbol.iterator](): IterableIterator<any> { return this; }\r\n\r\n /** Get the value for the column at the given index in the query result.\r\n * @param columnIx Index of ECSQL column in query result (0-based)\r\n *\r\n * See also: [Code Samples]($docs/learning/backend/ECSQLCodeExamples#working-with-the-query-result)\r\n */\r\n public getValue(columnIx: number): ECSqlValue {\r\n assert(undefined !== this._stmt);\r\n return new ECSqlValue(this._stmt.getValue(columnIx));\r\n }\r\n}\r\n\r\n/** Binds a value to an ECSQL parameter.\r\n *\r\n * See also:\r\n *\r\n * - [ECSqlStatement]($backend)\r\n * - [ECSqlStatement.getBinder]($backend)\r\n * - [Executing ECSQL]($docs/learning/backend/ExecutingECSQL)\r\n * @public\r\n */\r\nexport class ECSqlBinder {\r\n private _binder: IModelJsNative.ECSqlBinder;\r\n\r\n /** @internal */\r\n public constructor(binder: IModelJsNative.ECSqlBinder) { this._binder = binder; }\r\n\r\n /** Binds the specified value to the ECSQL parameter.\r\n * The section \"[iTwin.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)\" describes the\r\n * iTwin.js types to be used for the different ECSQL parameter types.\r\n * @param val Value to bind\r\n */\r\n public bind(val: any): void {\r\n ECSqlBindingHelper.bindValue(this, val);\r\n }\r\n\r\n /** Binds null to the ECSQL parameter. */\r\n public bindNull(): void {\r\n const stat: DbResult = this._binder.bindNull();\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, \"Error binding null\");\r\n }\r\n\r\n /** Binds a BLOB value to the ECSQL parameter.\r\n * @param BLOB value as either a UInt8Array, ArrayBuffer or a Base64 string\r\n */\r\n public bindBlob(blob: string | Uint8Array | ArrayBuffer | SharedArrayBuffer): void {\r\n const stat: DbResult = this._binder.bindBlob(blob);\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, \"Error binding blob\");\r\n }\r\n\r\n /** Binds a boolean value to the ECSQL parameter.\r\n * @param val Boolean value\r\n */\r\n public bindBoolean(val: boolean): void {\r\n const stat: DbResult = this._binder.bindBoolean(val);\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, \"Error binding boolean\");\r\n }\r\n\r\n /** Binds a DateTime value to the ECSQL parameter.\r\n * @param isoDateTimeString DateTime value as ISO8601 string\r\n */\r\n public bindDateTime(isoDateTimeString: string): void {\r\n const stat: DbResult = this._binder.bindDateTime(isoDateTimeString);\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, \"Error binding DateTime\");\r\n }\r\n\r\n /** Binds a double value to the ECSQL parameter.\r\n * @param val Double value\r\n */\r\n public bindDouble(val: number): void {\r\n const stat: DbResult = this._binder.bindDouble(val);\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, \"Error binding double\");\r\n }\r\n\r\n /** Binds an GUID value to the ECSQL parameter.\r\n * @param val GUID value. If passed as string, it must be formatted as described in [GuidString]($core-bentley).\r\n */\r\n public bindGuid(val: GuidString): void {\r\n const stat: DbResult = this._binder.bindGuid(val);\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, \"Error binding GUID\");\r\n }\r\n\r\n /** Binds an Id value to the ECSQL parameter.\r\n * @param val Id value. If passed as string it must be the hexadecimal representation of the Id.\r\n */\r\n public bindId(val: Id64String): void {\r\n const stat: DbResult = this._binder.bindId(val);\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, \"Error binding Id\");\r\n }\r\n\r\n /** Binds an integer value to the ECSQL parameter.\r\n * @param val Integer value as number, decimal string or hexadecimal string.\r\n */\r\n public bindInteger(val: number | string): void {\r\n const stat: DbResult = this._binder.bindInteger(val);\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, \"Error binding integer\");\r\n }\r\n\r\n /** Binds an Point2d value to the ECSQL parameter.\r\n * @param val Point2d value\r\n */\r\n public bindPoint2d(val: XAndY): void {\r\n const stat: DbResult = this._binder.bindPoint2d(val.x, val.y);\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, \"Error binding Point2d\");\r\n }\r\n\r\n /** Binds an Point3d value to the ECSQL parameter.\r\n * @param val Point3d value\r\n */\r\n public bindPoint3d(val: XYAndZ): void {\r\n const stat: DbResult = this._binder.bindPoint3d(val.x, val.y, val.z);\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, \"Error binding Point3d\");\r\n }\r\n\r\n /** Binds a Range3d as a blob to the ECSQL parameter.\r\n * @param val Range3d value\r\n */\r\n public bindRange3d(val: LowAndHighXYZ): void {\r\n const stat: DbResult = this._binder.bindBlob(Range3d.toFloat64Array(val).buffer);\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, \"Error binding Range3d\");\r\n }\r\n\r\n /** Binds an string to the ECSQL parameter.\r\n * @param val String value\r\n */\r\n public bindString(val: string): void {\r\n const stat: DbResult = this._binder.bindString(val);\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, \"Error binding string\");\r\n }\r\n\r\n /** Binds a navigation property value to the ECSQL parameter.\r\n * @param val Navigation property value\r\n */\r\n public bindNavigation(val: NavigationBindingValue): void {\r\n const stat: DbResult = this._binder.bindNavigation(val.id, val.relClassName, val.relClassTableSpace);\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, \"Error binding navigation property\");\r\n }\r\n\r\n /** Binds a struct property value to the ECSQL parameter.\r\n * @param val Struct value. The struct value is an object composed of pairs of a struct member property name and its value\r\n * (of one of the supported types)\r\n */\r\n public bindStruct(val: object): void { ECSqlBindingHelper.bindStruct(this, val); }\r\n\r\n /** Gets the binder for the specified member of a struct parameter\r\n *\r\n * > This is the most low-level way to bind struct parameters with most flexibility. A simpler alternative is\r\n * > to just call [ECSqlBinder.bindStruct]($backend).\r\n */\r\n public bindMember(memberName: string): ECSqlBinder { return new ECSqlBinder(this._binder.bindMember(memberName)); }\r\n\r\n /** Binds a set of Id strings to the ECSQL parameter.\r\n * @param val array of Id values. If passed as string they must be the hexadecimal representation of the Ids.\r\n */\r\n public bindIdSet(vector: Id64String[]): void {\r\n const stat: DbResult = this._binder.bindIdSet(vector);\r\n if (stat !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(stat, \"Error binding id set\");\r\n }\r\n\r\n /** Binds an array value to the ECSQL parameter.\r\n * @param val Array value. The array value is an array of values of the supported types\r\n */\r\n public bindArray(val: any[]): void { ECSqlBindingHelper.bindArray(this, val); }\r\n\r\n /** Adds a new array element to the array parameter and returns the binder for the new array element\r\n *\r\n * > This is the most low-level way to bind array parameters with most flexibility. A simpler alternative is\r\n * > to just call [ECSqlBinder.bindArray]($backend).\r\n */\r\n public addArrayElement(): ECSqlBinder { return new ECSqlBinder(this._binder.addArrayElement()); }\r\n}\r\n\r\n/** Represents the value of an ECEnumeration.\r\n *\r\n * See also:\r\n * - [[ECSqlValue.getEnum]]\r\n * - [[ECSqlStatement]]\r\n * - [[ECSqlStatement.getValue]]\r\n * - [Code Samples]($docs/learning/backend/ECSQLCodeExamples#working-with-the-query-result)\r\n * @public\r\n */\r\nexport interface ECEnumValue {\r\n schema: string;\r\n name: string;\r\n key: string;\r\n value: number | string;\r\n}\r\n\r\n/** Value of a column in a row of an ECSQL query result.\r\n *\r\n * See also:\r\n * - [ECSqlStatement]($backend)\r\n * - [ECSqlStatement.getValue]($backend)\r\n * - [Code Samples]($docs/learning/backend/ECSQLCodeExamples#working-with-the-query-result)\r\n * @public\r\n */\r\nexport class ECSqlValue {\r\n private _val: IModelJsNative.ECSqlValue;\r\n\r\n /** @internal */\r\n public constructor(val: IModelJsNative.ECSqlValue) { this._val = val; }\r\n\r\n /** Get information about the query result's column this value refers to. */\r\n public get columnInfo(): ECSqlColumnInfo { return this._val.getColumnInfo() as ECSqlColumnInfo; }\r\n\r\n /** Get the value of this ECSQL value */\r\n public get value(): any { return ECSqlValueHelper.getValue(this); }\r\n\r\n /** Indicates whether the value is NULL or not. */\r\n public get isNull(): boolean { return this._val.isNull(); }\r\n /** Get the value as BLOB */\r\n public getBlob(): Uint8Array { return this._val.getBlob(); }\r\n /** Get the value as a boolean value */\r\n public getBoolean(): boolean { return this._val.getBoolean(); }\r\n /** Get the value as a DateTime value (formatted as ISO8601 string) */\r\n public getDateTime(): string { return this._val.getDateTime(); }\r\n /** Get the value as a double value */\r\n public getDouble(): number { return this._val.getDouble(); }\r\n /** Get the value as a IGeometry value (as ECJSON IGeometry) */\r\n public getGeometry(): any { return JSON.parse(this._val.getGeometry()); }\r\n /** Get the value as a GUID (formatted as GUID string).\r\n * See [GuidString]($core-bentley)\r\n */\r\n public getGuid(): GuidString { return this._val.getGuid(); }\r\n /** Get the value as a Id (formatted as hexadecimal string). */\r\n public getId(): Id64String { return this._val.getId(); }\r\n /** Get the ClassId value formatted as fully qualified class name. */\r\n public getClassNameForClassId(): string { return this._val.getClassNameForClassId(); }\r\n /** Get the value as a integer value */\r\n public getInteger(): number { return this._val.getInt64(); }\r\n /** Get the value as a string value */\r\n public getString(): string { return this._val.getString(); }\r\n /** Get the value as [XAndY]($core-geometry) */\r\n public getXAndY(): XAndY { return this._val.getPoint2d(); }\r\n /** Get the value as [XYAndZ]($core-geometry) */\r\n public getXYAndZ(): XYAndZ { return this._val.getPoint3d(); }\r\n /** Get the value as ECEnumeration value\r\n * Note: This method is optional. Using [[ECSqlValue.getInteger]] for integral enums and\r\n * [[ECSqlValue.getString]] for string enums respectively are the usual way to get\r\n * enum values. This method can be used if the context of the underlying ECEnumeration\r\n * is required.\r\n * The value is broken down into the ECEnumerators that make it up, if the value\r\n * is a combination of ECEnumerators. If the value is not a strict match of an ECEnumerator\r\n * or a combination of them, undefined is returned.\r\n * > Note: You can call [[ECSqlValue.columnInfo.isEnum]] to find out whether\r\n * > this method can be called or not.\r\n * @return ECEnumeration value(s) or undefined if the ECSqlValue does not represent an ECEnumeration.\r\n * or is not a strict match of an ECEnumerator or a combination of them.\r\n */\r\n public getEnum(): ECEnumValue[] | undefined { return this._val.getEnum(); }\r\n\r\n /** Get the value as [NavigationValue]($common) */\r\n public getNavigation(): NavigationValue { return this._val.getNavigation(); }\r\n\r\n /** Get an iterator for iterating the struct members of this struct value. */\r\n public getStructIterator(): ECSqlValueIterator { return new ECSqlValueIterator(this._val.getStructIterator()); }\r\n\r\n /** Get this struct value's content as object literal */\r\n public getStruct(): any { return ECSqlValueHelper.getStruct(this); }\r\n\r\n /** Get an iterator for iterating the array elements of this array value. */\r\n public getArrayIterator(): ECSqlValueIterator { return new ECSqlValueIterator(this._val.getArrayIterator()); }\r\n\r\n /** Get this array value as JavaScript array */\r\n public getArray(): any[] { return ECSqlValueHelper.getArray(this); }\r\n}\r\n\r\n/** Iterator over members of a struct [ECSqlValue]($backend) or the elements of an array [ECSqlValue]($backend).\r\n * See [ECSqlValue.getStructIterator]($backend) or [ECSqlValue.getArrayIterator]($backend).\r\n * @public\r\n */\r\nexport class ECSqlValueIterator implements IterableIterator<ECSqlValue> {\r\n private _it: IModelJsNative.ECSqlValueIterator;\r\n\r\n /** @internal */\r\n public constructor(it: IModelJsNative.ECSqlValueIterator) { this._it = it; }\r\n\r\n public next(): IteratorResult<ECSqlValue> {\r\n if (this._it.moveNext())\r\n return { done: false, value: new ECSqlValue(this._it.getCurrent()) };\r\n\r\n return { done: true, value: undefined };\r\n }\r\n\r\n public [Symbol.iterator](): IterableIterator<ECSqlValue> { return this; }\r\n}\r\n\r\n/** Information about an ECSQL column in an ECSQL query result.\r\n * See [ECSqlValue.columnInfo]($backend), [ECSqlStatement.getValue]($backend), [ECSqlStatement]($backend)\r\n * @public\r\n */\r\nexport interface ECSqlColumnInfo {\r\n /** Gets the data type of the column.\r\n */\r\n getType(): ECSqlValueType;\r\n\r\n /** Gets the name of the property backing the column.\r\n * > If this column is backed by a generated property, i.e. it represents ECSQL expression,\r\n * > the access string consists of the name of the generated property.\r\n */\r\n getPropertyName(): string;\r\n\r\n /** Gets the full access string to the corresponding ECSqlValue starting from the root class.\r\n * > If this column is backed by a generated property, i.e. it represents ECSQL expression,\r\n * > the access string consists of the ECSQL expression.\r\n */\r\n getAccessString(): string;\r\n\r\n /** Indicates whether the column refers to an ECEnumeration property. */\r\n isEnum(): boolean;\r\n\r\n /** Indicates whether the column refers to a system property (e.g. id, className). */\r\n isSystemProperty(): boolean;\r\n\r\n /** Indicates whether the column is backed by a generated property or not. For SELECT clause items that are expressions other\r\n * than simply a reference to an ECProperty, a property is generated containing the expression name.\r\n */\r\n isGeneratedProperty(): boolean;\r\n\r\n /** Gets the table space in which this root class is persisted.\r\n * > For classes in the primary file the table space is MAIN. For classes in attached\r\n * > files, the table space is the name by which the file was attached. For generated properties the table space is empty.\r\n */\r\n getRootClassTableSpace(): string;\r\n\r\n /** Gets the fully qualified name of the ECClass of the top-level ECProperty backing this column. */\r\n getRootClassName(): string;\r\n\r\n /** Gets the class alias of the root class to which the column refers to.\r\n * > Returns an empty string if no class alias was specified in the select clause.\r\n */\r\n getRootClassAlias(): string;\r\n}\r\n\r\nclass ECSqlBindingHelper {\r\n\r\n /** Binds the specified value to the specified binder\r\n * @param binder Parameter Binder to bind to\r\n * @param val Value to be bound. (See [iTwin.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes))\r\n * @throws IModelError in case of errors\r\n */\r\n public static bindValue(binder: ECSqlBinder, val: any): void {\r\n // returns false if val is no primitive and returns true if it is primitive and a binding call was done\r\n if (ECSqlBindingHelper.tryBindPrimitiveTypes(binder, val))\r\n return;\r\n\r\n if (Array.isArray(val)) {\r\n ECSqlBindingHelper.bindArray(binder, val);\r\n return;\r\n }\r\n\r\n if (typeof (val) === \"object\") {\r\n ECSqlBindingHelper.bindStruct(binder, val);\r\n return;\r\n }\r\n\r\n throw new Error(`Bound value is of an unsupported type: ${val}`);\r\n }\r\n\r\n /** Binds the specified primitive value to the specified binder\r\n * @param binder Parameter Binder to bind to\r\n * @param val Primitive value to be bound. Must be of one of these types described here:\r\n * [ECSQL Binding types]($docs/learning/ECSQLParameterTypes)\r\n * @throws IModelError in case of errors\r\n */\r\n public static bindPrimitive(binder: ECSqlBinder, val: any): void {\r\n if (!ECSqlBindingHelper.tryBindPrimitiveTypes(binder, val))\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, `Binding value is of an unsupported primitive type: ${val}`);\r\n }\r\n\r\n /** Binds the specified object to the specified struct binder\r\n * @param binder Struct parameter binder to bind to\r\n * @param val Value to be bound. Must be an Object with members of the supported types\r\n * @throws IModelError in case of errors\r\n */\r\n public static bindStruct(binder: ECSqlBinder, val: object): void {\r\n if (val === null || val === undefined) {\r\n binder.bindNull();\r\n return;\r\n }\r\n\r\n for (const member of Object.entries(val)) {\r\n const memberName: string = member[0];\r\n const memberVal: any = member[1];\r\n ECSqlBindingHelper.bindValue(binder.bindMember(memberName), memberVal);\r\n }\r\n }\r\n\r\n /** Binds the specified array to the specified array binder\r\n * @param binder Array parameter binder to bind to\r\n * @param val Value to be bound. Must be an Array with elements of the supported types\r\n * @throws IModelError in case of errors\r\n */\r\n public static bindArray(binder: ECSqlBinder, val: any[]): void {\r\n if (val === null || val === undefined) {\r\n binder.bindNull();\r\n return;\r\n }\r\n\r\n for (const element of val) {\r\n ECSqlBindingHelper.bindValue(binder.addArrayElement(), element);\r\n }\r\n }\r\n\r\n /** tries to interpret the passed value as known leaf types (primitives and navigation values).\r\n * @returns Returns undefined if the value wasn't a primitive. DbResult if it was a primitive and was bound to the binder\r\n */\r\n private static tryBindPrimitiveTypes(binder: ECSqlBinder, val: any): boolean {\r\n if (val === undefined || val === null) {\r\n binder.bindNull();\r\n return true;\r\n }\r\n\r\n if (typeof (val) === \"number\") {\r\n if (Number.isInteger(val))\r\n binder.bindInteger(val);\r\n else\r\n binder.bindDouble(val);\r\n\r\n return true;\r\n }\r\n\r\n if (typeof (val) === \"boolean\") {\r\n binder.bindBoolean(val);\r\n return true;\r\n }\r\n\r\n if (typeof (val) === \"string\") {\r\n binder.bindString(val);\r\n return true;\r\n }\r\n\r\n if (ECSqlTypeHelper.isBlob(val)) {\r\n binder.bindBlob(val);\r\n return true;\r\n }\r\n\r\n if (ECSqlTypeHelper.isXYAndZ(val)) {\r\n binder.bindPoint3d(val);\r\n return true;\r\n }\r\n\r\n if (ECSqlTypeHelper.isXAndY(val)) {\r\n binder.bindPoint2d(val);\r\n return true;\r\n }\r\n\r\n if (ECSqlTypeHelper.isLowAndHighXYZ(val)) {\r\n binder.bindRange3d(val);\r\n return true;\r\n }\r\n\r\n if (ECSqlTypeHelper.isNavigationBindingValue(val)) {\r\n binder.bindNavigation(val);\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n}\r\n\r\nclass ECSqlValueHelper {\r\n public static getValue(ecsqlValue: ECSqlValue): any {\r\n if (ecsqlValue.isNull)\r\n return undefined;\r\n\r\n const dataType: ECSqlValueType = ecsqlValue.columnInfo.getType();\r\n switch (dataType) {\r\n case ECSqlValueType.Struct:\r\n return ECSqlValueHelper.getStruct(ecsqlValue);\r\n\r\n case ECSqlValueType.Navigation:\r\n return ecsqlValue.getNavigation();\r\n\r\n case ECSqlValueType.PrimitiveArray:\r\n case ECSqlValueType.StructArray:\r\n return ECSqlValueHelper.getArray(ecsqlValue);\r\n\r\n default:\r\n return ECSqlValueHelper.getPrimitiveValue(ecsqlValue);\r\n }\r\n }\r\n\r\n public static getStruct(ecsqlValue: ECSqlValue): any {\r\n if (ecsqlValue.isNull)\r\n return undefined;\r\n\r\n const structVal = {};\r\n const it = ecsqlValue.getStructIterator();\r\n try {\r\n for (const memberECSqlVal of it) {\r\n if (memberECSqlVal.isNull)\r\n continue;\r\n\r\n const memberName: string = ECJsNames.toJsName(memberECSqlVal.columnInfo.getPropertyName());\r\n const memberVal = ECSqlValueHelper.getValue(memberECSqlVal);\r\n Object.defineProperty(structVal, memberName, { enumerable: true, configurable: true, writable: true, value: memberVal });\r\n }\r\n } finally {\r\n }\r\n\r\n return structVal;\r\n }\r\n\r\n public static getArray(ecsqlValue: ECSqlValue): any[] {\r\n const arrayVal: any[] = [];\r\n const it = ecsqlValue.getArrayIterator();\r\n try {\r\n for (const elementECSqlVal of it) {\r\n const memberVal = ECSqlValueHelper.getValue(elementECSqlVal);\r\n arrayVal.push(memberVal);\r\n }\r\n } finally {\r\n }\r\n return arrayVal;\r\n }\r\n\r\n private static getPrimitiveValue(ecsqlValue: ECSqlValue): any {\r\n if (ecsqlValue.isNull)\r\n return undefined;\r\n\r\n const colInfo: ECSqlColumnInfo = ecsqlValue.columnInfo;\r\n switch (colInfo.getType()) {\r\n case ECSqlValueType.Blob:\r\n return ecsqlValue.getBlob();\r\n case ECSqlValueType.Boolean:\r\n return ecsqlValue.getBoolean();\r\n case ECSqlValueType.DateTime:\r\n return ecsqlValue.getDateTime();\r\n case ECSqlValueType.Double:\r\n return ecsqlValue.getDouble();\r\n case ECSqlValueType.Geometry:\r\n return ecsqlValue.getGeometry();\r\n case ECSqlValueType.Guid:\r\n return ecsqlValue.getGuid();\r\n case ECSqlValueType.Id: {\r\n if (colInfo.isSystemProperty() && colInfo.getPropertyName().endsWith(\"ECClassId\"))\r\n return ecsqlValue.getClassNameForClassId();\r\n\r\n return ecsqlValue.getId();\r\n }\r\n case ECSqlValueType.Int:\r\n case ECSqlValueType.Int64:\r\n return ecsqlValue.getInteger();\r\n case ECSqlValueType.Point2d:\r\n return ecsqlValue.getXAndY();\r\n case ECSqlValueType.Point3d:\r\n return ecsqlValue.getXYAndZ();\r\n case ECSqlValueType.String:\r\n return ecsqlValue.getString();\r\n default:\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, `Unsupported type ${ecsqlValue.columnInfo.getType()} of the ECSQL Value`);\r\n }\r\n }\r\n\r\n public static queryClassName(ecdb: ECDb, classId: Id64String, tableSpace?: string): string {\r\n if (!tableSpace)\r\n tableSpace = \"main\";\r\n\r\n return ecdb.withPreparedStatement(`SELECT s.Name, c.Name FROM [${tableSpace}].meta.ECSchemaDef s, JOIN [${tableSpace}].meta.ECClassDef c ON s.ECInstanceId=c.SchemaId WHERE c.ECInstanceId=?`,\r\n (stmt: ECSqlStatement) => {\r\n stmt.bindId(1, classId);\r\n if (stmt.step() !== DbResult.BE_SQLITE_ROW)\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, `No class found with ECClassId ${classId} in table space ${tableSpace}.`);\r\n\r\n return `${stmt.getValue(0).getString()}.${stmt.getValue(1).getString()}`;\r\n });\r\n }\r\n}\r\n\r\nclass ECSqlTypeHelper {\r\n public static isBlob(val: any): val is Uint8Array { return val instanceof Uint8Array; }\r\n\r\n public static isXAndY(val: any): val is XAndY { return XYZ.isXAndY(val); }\r\n public static isXYAndZ(val: any): val is XYAndZ { return XYZ.isXYAndZ(val); }\r\n public static isLowAndHighXYZ(arg: any): arg is LowAndHighXYZ { return arg.low !== undefined && ECSqlTypeHelper.isXYAndZ(arg.low) && arg.high !== undefined && ECSqlTypeHelper.isXYAndZ(arg.high); }\r\n\r\n public static isNavigationBindingValue(val: any): val is NavigationBindingValue { return val.id !== undefined && typeof (val.id) === \"string\"; }\r\n}\r\n"]}
@@ -101,7 +101,7 @@ export interface ExportPartInstanceInfo {
101
101
  /** The base display properties when the [GeometryPart]($core-backend) was referenced. */
102
102
  displayProps: ExportPartDisplayInfo;
103
103
  /** A row-major storage 4x3 transform for this instance.
104
- * See export-gltf under test-apps in the iModel.js monorepo for a working reference.
104
+ * See export-gltf under test-apps in the iTwin.js monorepo for a working reference.
105
105
  */
106
106
  transform?: Float64Array;
107
107
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ExportGraphics.js","sourceRoot":"","sources":["../../src/ExportGraphics.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAoE;AACpE,wDAAgG;AAkPhG;;GAEG;AACH,IAAiB,cAAc,CAkD9B;AAlDD,WAAiB,cAAc;IAC7B;;OAEG;IACH,SAAgB,wBAAwB,CAAC,GAA0B,EAAE,GAA0B;QAC7F,IAAI,GAAG,CAAC,UAAU,KAAK,GAAG,CAAC,UAAU;YAAE,OAAO,KAAK,CAAC;QACpD,IAAI,GAAG,CAAC,aAAa,KAAK,GAAG,CAAC,aAAa;YAAE,OAAO,KAAK,CAAC;QAC1D,IAAI,GAAG,CAAC,UAAU,KAAK,GAAG,CAAC,UAAU;YAAE,OAAO,KAAK,CAAC;QACpD,IAAI,GAAG,CAAC,eAAe,KAAK,GAAG,CAAC,eAAe;YAAE,OAAO,KAAK,CAAC;QAC9D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C,KAAK,EAAE,KAAK,CAAC,CAAC;QACzD,IAAI,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM;YAC5D,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC9D,CAAC;CAEF;AA5ID,8DA4IC","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 iModels\r\n */\r\n\r\nimport { assert, Id64Array, Id64String } from \"@itwin/core-bentley\";\r\nimport { IndexedPolyface, Polyface, PolyfaceData, PolyfaceVisitor } from \"@itwin/core-geometry\";\r\nimport { GeometryClass } from \"@itwin/core-common\";\r\n\r\n/** A collection of line segments, suitable for direct use with graphics APIs.\r\n * The structure of this data matches GL_LINES in OpenGL.\r\n * See [IModelDb.exportGraphics]($core-backend)\r\n * @public\r\n */\r\nexport interface ExportGraphicsLines {\r\n /** Zero-based vertex indices, every two indices represent a line segment */\r\n indices: Int32Array;\r\n /** Vertices for these lines, laid out in the pattern XYZXYZ */\r\n points: Float64Array;\r\n}\r\n\r\n/** Info provided to ExportLinesFunction about linework graphics.\r\n * See [IModelDb.exportGraphics]($core-backend)\r\n * @public\r\n */\r\nexport interface ExportLinesInfo {\r\n /** The element ID for the element the graphics originated from */\r\n elementId: Id64String;\r\n /** ID for the [SubCategory]($core-backend) for these graphics */\r\n subCategory: Id64String;\r\n /** The color and transparency for these graphics, laid out in TBGR format, see [ColorDef]($core-common) */\r\n color: number;\r\n /** GeometryClass for these graphics */\r\n geometryClass: GeometryClass;\r\n /** The linework for these graphics */\r\n lines: ExportGraphicsLines;\r\n}\r\n\r\n/** A callback function that receives generated line graphics.\r\n * See [IModelDb.exportGraphics]($core-backend)\r\n * @public\r\n */\r\nexport type ExportLinesFunction = (info: ExportLinesInfo) => void;\r\n\r\n/** A triangulated mesh with unified indices, suitable for direct use with graphics APIs.\r\n * See [IModelDb.exportGraphics]($core-backend)\r\n * @public\r\n */\r\nexport interface ExportGraphicsMesh {\r\n /** Zero-based vertex indices, every three indices represent a triangle */\r\n indices: Int32Array;\r\n /** Vertices for this mesh, laid out in the pattern XYZXYZ */\r\n points: Float64Array;\r\n /** Normals for this mesh, laid out in the pattern XYZXYZ */\r\n normals: Float32Array;\r\n /** Parameters (uvs) for this mesh, laid out in the pattern XYXY */\r\n params: Float32Array;\r\n /** If true, clients should assume both sides of the mesh are visible and not cull backfaces. */\r\n isTwoSided: boolean;\r\n}\r\n\r\n/** Info provided to ExportGraphicsFunction about graphics.\r\n * See [IModelDb.exportGraphics]($core-backend)\r\n * @public\r\n */\r\nexport interface ExportGraphicsInfo {\r\n /** The element ID for the element the graphics originated from */\r\n elementId: Id64String;\r\n /** ID for the [SubCategory]($core-backend) for these graphics */\r\n subCategory: Id64String;\r\n /** The color and transparency for these graphics, laid out in TBGR format, see [ColorDef]($core-common) */\r\n color: number;\r\n /** GeometryClass for these graphics */\r\n geometryClass: GeometryClass;\r\n /** If defined, ID for the [RenderMaterialElement]($core-backend) for these graphics */\r\n materialId?: Id64String;\r\n /** If defined, ID for the [Texture]($core-backend) for these graphics */\r\n textureId?: Id64String;\r\n /** The mesh for these graphics */\r\n mesh: ExportGraphicsMesh;\r\n}\r\n\r\n/** Information about the base display properties when a [GeometryPart]($core-backend) was\r\n * referenced. This is intended to be used with [IModelDb.exportPartGraphics]($core-backend).\r\n * * If two ExportPartInstanceInfo have the same ExportPartDisplayInfos, they will result in the\r\n * same graphics (with a different transform).\r\n * * If two ExportPartInstanceInfo have different ExportPartDisplayInfos, they may result in different\r\n * graphics.\r\n * @public\r\n */\r\nexport interface ExportPartDisplayInfo {\r\n categoryId: Id64String;\r\n subCategoryId: Id64String;\r\n geometryClass: GeometryClass;\r\n materialId: Id64String;\r\n elmTransparency: number;\r\n lineColor: number;\r\n}\r\n\r\n/** Information about references to [GeometryPart]($core-backend) elements found during\r\n * a call to [IModelDb.exportGraphics]($core-backend).\r\n * See [IModelDb.exportPartGraphics]($core-backend) for the intended use case.\r\n * @public\r\n */\r\nexport interface ExportPartInstanceInfo {\r\n /** ID for the [GeometryPart]($core-backend) */\r\n partId: Id64String;\r\n /** ID for the element that contained the reference to the [GeometryPart]($core-backend) */\r\n partInstanceId: Id64String;\r\n /** The base display properties when the [GeometryPart]($core-backend) was referenced. */\r\n displayProps: ExportPartDisplayInfo;\r\n /** A row-major storage 4x3 transform for this instance.\r\n * See export-gltf under test-apps in the iModel.js monorepo for a working reference.\r\n */\r\n transform?: Float64Array;\r\n}\r\n\r\n/** A callback function that receives generated graphics.\r\n * See [IModelDb.exportGraphics]($core-backend)\r\n * @public\r\n */\r\nexport type ExportGraphicsFunction = (info: ExportGraphicsInfo) => void;\r\n\r\n/** Parameters for [IModelDb.exportGraphics]($core-backend)\r\n * @public\r\n */\r\nexport interface ExportGraphicsOptions {\r\n /** The source elements for the exported graphics */\r\n elementIdArray: Id64Array;\r\n /** A function to call for each unique element ID, color and texture combination */\r\n onGraphics: ExportGraphicsFunction;\r\n /** An optional function to call if line graphics are desired. */\r\n onLineGraphics?: ExportLinesFunction;\r\n /** If supplied, any references to [GeometryPart]($core-backend) elements found will be\r\n * recorded in this array. In this case, graphics that would result from the GeometryPart\r\n * will not be supplied via onGraphics. See [IModelDb.exportPartGraphics]($core-backend)\r\n */\r\n partInstanceArray?: ExportPartInstanceInfo[];\r\n /** Max distance from a face to the original geometry, see [StrokeOptions]($core-geometry) */\r\n chordTol?: number;\r\n /** Max angle difference in radians for approximated face, see [StrokeOptions]($core-geometry) */\r\n angleTol?: number;\r\n /** Max length of any edge in generated faces, see [StrokeOptions]($core-geometry) */\r\n maxEdgeLength?: number;\r\n /** The longest dimension of a line style's largest component must be at least this size in order for\r\n * exportGraphics to evaluate and generate its graphics. If undefined, this defaults to 0.1.\r\n * Line styles can evaluate to 3D geometry that clients expect to receive from exportGraphics, but they\r\n * can also generate gigabytes of mesh data when line styles with small components are applied to long\r\n * line strings.\r\n */\r\n minLineStyleComponentSize?: number;\r\n /** Max distance between mesh vertices for them to be collapsed.\r\n * Meshes stored in GeometryStreams are unaffected by StrokeOptions settings. If decimationTol is undefined,\r\n * they are output from exportGraphics without any reduction in quality and can be too detailed for\r\n * some uses. However, decimation is a destructive operation that can introduce gaps and other visual\r\n * anomalies so it is important to choose an appropriate setting for your use case.\r\n */\r\n decimationTol?: number;\r\n /** BRep features with bounding boxes smaller than this size will not generate graphics.\r\n * This option can be used to ignore expensive details from [BRepEntity.DataProps]($core-common)\r\n * like screws and screw holes.\r\n */\r\n minBRepFeatureSize?: number;\r\n}\r\n\r\n/** Info provided to ExportPartFunction about graphics.\r\n * See [IModelDb.exportPartGraphics]($core-backend)\r\n * @public\r\n */\r\nexport interface ExportPartInfo {\r\n /** The color and transparency for these graphics, laid out in TBGR format, see [ColorDef]($core-common) */\r\n color: number;\r\n /** GeometryClass for these graphics */\r\n geometryClass: GeometryClass;\r\n /** If defined, ID for the [RenderMaterialElement]($core-backend) for these graphics */\r\n materialId?: Id64String;\r\n /** If defined, ID for the [Texture]($core-backend) for these graphics */\r\n textureId?: Id64String;\r\n /** The mesh for these graphics */\r\n mesh: ExportGraphicsMesh;\r\n}\r\n\r\n/** A callback function that receives generated graphics for a [GeometryPart]($core-backend).\r\n * See [IModelDb.exportPartGraphics]($core-backend)\r\n * @public\r\n */\r\nexport type ExportPartFunction = (info: ExportPartInfo) => void;\r\n\r\n/** Info provided to ExportPartFunction about line graphics.\r\n * See [IModelDb.exportPartGraphics]($core-backend)\r\n * @public\r\n */\r\nexport interface ExportPartLinesInfo {\r\n /** The color and transparency for these graphics, laid out in TBGR format, see [ColorDef]($core-common) */\r\n color: number;\r\n /** GeometryClass for these graphics */\r\n geometryClass: GeometryClass;\r\n /** The linework for these graphics */\r\n lines: ExportGraphicsLines;\r\n}\r\n\r\n/** A callback function that receives generated line graphics for a [GeometryPart]($core-backend).\r\n * See [IModelDb.exportPartGraphics]($core-backend)\r\n * @public\r\n */\r\nexport type ExportPartLinesFunction = (info: ExportPartLinesInfo) => void;\r\n\r\n/** Parameters for [IModelDb.exportPartGraphics]($core-backend)\r\n * @public\r\n */\r\nexport interface ExportPartGraphicsOptions {\r\n /** The ID for the source [GeometryPart]($core-backend) */\r\n elementId: Id64String;\r\n /** The base display properties to use for generating the graphics. This should come from an\r\n * ExportPartInstanceProps generated by [IModelDb.exportGraphics]($core-backend)\r\n */\r\n displayProps: ExportPartDisplayInfo;\r\n /** A function to call for each unique color and texture combination. */\r\n onPartGraphics: ExportPartFunction;\r\n /** An optional function to call if line graphics are desired. */\r\n onPartLineGraphics?: ExportPartLinesFunction;\r\n /** Max distance from a face to the original geometry, see [StrokeOptions]($core-geometry) */\r\n chordTol?: number;\r\n /** Max angle difference in radians for approximated face, see [StrokeOptions]($core-geometry) */\r\n angleTol?: number;\r\n /** Max length of any edge in generated faces, see [StrokeOptions]($core-geometry) */\r\n maxEdgeLength?: number;\r\n /** The longest dimension of a line style's largest component must be at least this size in order for\r\n * exportGraphics to evaluate and generate its graphics. If undefined, this defaults to 0.1.\r\n * Line styles can evaluate to 3D geometry that clients expect to receive from exportGraphics, but they\r\n * can also generate gigabytes of mesh data when line styles with small components are applied to long\r\n * line strings.\r\n */\r\n minLineStyleComponentSize?: number;\r\n /** Max distance between mesh vertices for them to be collapsed.\r\n * Meshes stored in GeometryStreams are unaffected by StrokeOptions settings. If decimationTol is undefined,\r\n * they are output from exportGraphics without any reduction in quality and can be too detailed for\r\n * some uses. However, decimation is a destructive operation that can introduce gaps and other visual\r\n * anomalies so it is important to choose an appropriate setting for your use case.\r\n */\r\n decimationTol?: number;\r\n /** BRep features with bounding boxes smaller than this size will not generate graphics.\r\n * This option can be used to ignore expensive details from [BRepEntity.DataProps]($core-common)\r\n * like screws and screw holes.\r\n */\r\n minBRepFeatureSize?: number;\r\n}\r\n\r\n/** Provides utility functions for working with data generated by [IModelDb.exportGraphics]($core-backend)\r\n * @public\r\n */\r\nexport namespace ExportGraphics {\r\n /** Test if ExportPartDisplayInfos have exactly the same values.\r\n * @public\r\n */\r\n export function arePartDisplayInfosEqual(lhs: ExportPartDisplayInfo, rhs: ExportPartDisplayInfo): boolean {\r\n if (lhs.categoryId !== rhs.categoryId) return false;\r\n if (lhs.subCategoryId !== rhs.subCategoryId) return false;\r\n if (lhs.materialId !== rhs.materialId) return false;\r\n if (lhs.elmTransparency !== rhs.elmTransparency) return false;\r\n if (lhs.lineColor !== rhs.lineColor) return false;\r\n return true;\r\n }\r\n\r\n /**\r\n * Convert an ExportGraphicsMesh to an IndexedPolyface usable by the geometry API.\r\n * @note The resulting IndexedPolyface may have duplicate points, normals and params. If problematic, call [PolyfaceData.compress]($core-geometry)\r\n * @public\r\n */\r\n export function convertToIndexedPolyface(mesh: ExportGraphicsMesh): IndexedPolyface {\r\n const polyface = IndexedPolyface.create(true, true, false, mesh.isTwoSided);\r\n\r\n const p: Float64Array = mesh.points;\r\n for (let i = 0; i < p.length; i += 3)\r\n polyface.data.point.pushXYZ(p[i], p[i + 1], p[i + 2]);\r\n\r\n const n: Float32Array = mesh.normals;\r\n assert(undefined !== polyface.data.normal);\r\n for (let i = 0; i < n.length; i += 3)\r\n polyface.data.normal.pushXYZ(n[i], n[i + 1], n[i + 2]);\r\n\r\n const uv: Float32Array = mesh.params;\r\n assert(undefined !== polyface.data.param);\r\n for (let i = 0; i < uv.length; i += 2)\r\n polyface.data.param.pushXY(uv[i], uv[i + 1]);\r\n\r\n const indices = mesh.indices;\r\n const addIndex = (idx: number) => {\r\n polyface.addPointIndex(idx, true);\r\n polyface.addNormalIndex(idx);\r\n polyface.addParamIndex(idx);\r\n };\r\n for (let i = 0; i < indices.length; i += 3) {\r\n addIndex(indices[i]);\r\n addIndex(indices[i + 1]);\r\n addIndex(indices[i + 2]);\r\n polyface.terminateFacet(false);\r\n }\r\n\r\n return polyface;\r\n }\r\n}\r\n/**\r\n * * Iterator to walk the facets of an ExportGraphicsMesh and present them to the world as if visiting a Polyface.\r\n * * Because the ExportGraphicsMesh has limited data:\r\n * * There is no auxData in this visitor.\r\n * * There is no color in this visitor.\r\n * * All edgeVisible are true.\r\n * @public\r\n */\r\nexport class ExportGraphicsMeshVisitor extends PolyfaceData implements PolyfaceVisitor {\r\n private _currentFacetIndex: number;\r\n private _nextFacetIndex: number;\r\n private _numWrap: number;\r\n private _polyface: ExportGraphicsMesh;\r\n // to be called from static factory method that validates the polyface ...\r\n private constructor(facets: ExportGraphicsMesh, numWrap: number) {\r\n super(facets.normals.length > 0, facets.params.length > 0, false, facets.isTwoSided);\r\n this._polyface = facets;\r\n this._numWrap = numWrap;\r\n\r\n this._nextFacetIndex = 0;\r\n this._currentFacetIndex = -1;\r\n this.twoSided = facets.isTwoSided;\r\n this.reset();\r\n }\r\n /** Create a visitor for iterating the facets of `polyface`, with indicated number of points to be added to each facet to produce closed point arrays\r\n * Typical wrap counts are:\r\n * * 0 -- leave the point arrays with \"missing final edge\"\r\n * * 1 -- add point 0 as closure point\r\n * * 2 -- add points 0 and 1 as closure and wrap point. This is useful when vertex visit requires two adjacent vectors, e.g. for cross products.\r\n */\r\n public static create(polyface: ExportGraphicsMesh, numWrap: number): ExportGraphicsMeshVisitor {\r\n return new ExportGraphicsMeshVisitor(polyface, numWrap);\r\n }\r\n /** Reset the iterator to start at the first facet of the polyface. */\r\n public reset(): void {\r\n this.moveToReadIndex(0);\r\n this._nextFacetIndex = 0; // so immediate moveToNextFacet stays here.\r\n }\r\n /** Select a facet by simple index. */\r\n public moveToReadIndex(facetIndex: number): boolean {\r\n if (facetIndex < 0 || 2 + facetIndex * 3 >= this._polyface.indices.length)\r\n return false;\r\n this._currentFacetIndex = facetIndex;\r\n this._nextFacetIndex = facetIndex + 1;\r\n this.point.length = 0;\r\n const points = this.point;\r\n points.length = 0;\r\n this.pointIndex.length = 0;\r\n this.point.length = 0;\r\n this.edgeVisible.length = 0;\r\n const sourcePoints = this._polyface.points;\r\n const indices = this._polyface.indices;\r\n const i0 = 3 * facetIndex;\r\n for (let i = i0; i < i0 + 3; i++) {\r\n const k = 3 * indices[i];\r\n this.pointIndex.push(indices[i]);\r\n this.point.pushXYZ(sourcePoints[k], sourcePoints[k + 1], sourcePoints[k + 2]);\r\n this.edgeVisible.push(true);\r\n }\r\n for (let i = 0; i < this._numWrap; i++) {\r\n this.point.pushFromGrowableXYZArray(this.point, i);\r\n }\r\n\r\n const sourceParams = this._polyface.params;\r\n if (sourceParams.length > 0 && this.paramIndex && this.param) {\r\n this.paramIndex.length = 0;\r\n this.param.length = 0;\r\n for (let i = i0; i < i0 + 3; i++) {\r\n const k = 2 * indices[i];\r\n this.paramIndex.push(indices[i]);\r\n this.param.pushXY(sourceParams[k], sourceParams[k + 1]);\r\n }\r\n for (let i = 0; i < this._numWrap; i++) {\r\n this.param.pushFromGrowableXYArray(this.param, i);\r\n }\r\n }\r\n\r\n const sourceNormals = this._polyface.normals;\r\n if (sourceNormals.length > 0 && this.normalIndex && this.normal) {\r\n this.normalIndex.length = 0;\r\n this.normal.length = 0;\r\n for (let i = i0; i < i0 + 3; i++) {\r\n const k = 3 * indices[i];\r\n this.normalIndex.push(indices[i]);\r\n this.normal.pushXYZ(sourceNormals[k], sourceNormals[k + 1], sourceNormals[k + 2]);\r\n }\r\n for (let i = 0; i < this._numWrap; i++) {\r\n this.normal.pushFromGrowableXYZArray(this.normal, i);\r\n }\r\n }\r\n return true;\r\n }\r\n public moveToNextFacet(): boolean {\r\n return this.moveToReadIndex(this._nextFacetIndex);\r\n }\r\n /** Set the number of vertices to replicate in visitor arrays. */\r\n public setNumWrap(numWrap: number): void { this._numWrap = numWrap; }\r\n\r\n /** Return the index (in the client polyface) of the current facet */\r\n public currentReadIndex(): number { return this._currentFacetIndex; }\r\n /** Return the point index of vertex i within the currently loaded facet */\r\n public clientPointIndex(i: number): number { return this.pointIndex[i]; }\r\n /** Return the param index of vertex i within the currently loaded facet.\r\n * Use the artificial paramIndex, which matches pointIndex.\r\n */\r\n public clientParamIndex(i: number): number { return this.paramIndex ? this.paramIndex[i] : -1; }\r\n /** Return the normal index of vertex i within the currently loaded facet.\r\n * Use the artificial paramIndex, which matches pointIndex.\r\n */\r\n public clientNormalIndex(i: number): number { return this.normalIndex ? this.normalIndex[i] : -1; }\r\n /** Return the color index of vertex i within the currently loaded facet */\r\n public clientColorIndex(_i: number): number { return 1; }\r\n /** Return the aux data index of vertex i within the currently loaded facet */\r\n public clientAuxIndex(_i: number): number { return -1; }\r\n\r\n /** return the client polyface */\r\n public clientPolyface(): Polyface { return (undefined as unknown) as Polyface; }\r\n /** clear the contents of all arrays. Use this along with transferDataFrom methods to build up new facets */\r\n public clearArrays(): void {\r\n if (this.point !== undefined)\r\n this.point.length = 0;\r\n if (this.param !== undefined)\r\n this.param.length = 0;\r\n if (this.normal !== undefined)\r\n this.normal.length = 0;\r\n // ignore color and aux -- they never exist.\r\n }\r\n /** transfer interpolated data from the other visitor.\r\n * * all data values are interpolated at `fraction` between `other` values at index0 and index1.\r\n */\r\n public pushInterpolatedDataFrom(other: PolyfaceVisitor, index0: number, fraction: number, index1: number): void {\r\n this.point.pushInterpolatedFromGrowableXYZArray(other.point, index0, fraction, index1);\r\n if (this.param && other.param && index0 < other.param.length && index1 < other.param.length)\r\n this.param.pushInterpolatedFromGrowableXYArray(other.param, index0, fraction, index1);\r\n if (this.normal && other.normal && index0 < other.normal.length && index1 < other.normal.length)\r\n this.normal.pushInterpolatedFromGrowableXYZArray(other.normal, index0, fraction, index1);\r\n }\r\n /** transfer data from a specified index of the other visitor as new data in this visitor. */\r\n public pushDataFrom(other: PolyfaceVisitor, index: number): void {\r\n this.point.pushFromGrowableXYZArray(other.point, index);\r\n if (this.color && other.color && index < other.color.length)\r\n this.color.push(other.color[index]);\r\n if (this.param && other.param && index < other.param.length)\r\n this.param.pushFromGrowableXYArray(other.param, index);\r\n if (this.normal && other.normal && index < other.normal.length)\r\n this.normal.pushFromGrowableXYZArray(other.normal, index);\r\n }\r\n\r\n}\r\n"]}
1
+ {"version":3,"file":"ExportGraphics.js","sourceRoot":"","sources":["../../src/ExportGraphics.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAoE;AACpE,wDAAgG;AAkPhG;;GAEG;AACH,IAAiB,cAAc,CAkD9B;AAlDD,WAAiB,cAAc;IAC7B;;OAEG;IACH,SAAgB,wBAAwB,CAAC,GAA0B,EAAE,GAA0B;QAC7F,IAAI,GAAG,CAAC,UAAU,KAAK,GAAG,CAAC,UAAU;YAAE,OAAO,KAAK,CAAC;QACpD,IAAI,GAAG,CAAC,aAAa,KAAK,GAAG,CAAC,aAAa;YAAE,OAAO,KAAK,CAAC;QAC1D,IAAI,GAAG,CAAC,UAAU,KAAK,GAAG,CAAC,UAAU;YAAE,OAAO,KAAK,CAAC;QACpD,IAAI,GAAG,CAAC,eAAe,KAAK,GAAG,CAAC,eAAe;YAAE,OAAO,KAAK,CAAC;QAC9D,IAAI,GAAG,CAAC,SAAS,KAAK,GAAG,CAAC,SAAS;YAAE,OAAO,KAAK,CAAC;QAClD,OAAO,IAAI,CAAC;IACd,CAAC;IAPe,uCAAwB,2BAOvC,CAAA;IAED;;;;OAIG;IACH,SAAgB,wBAAwB,CAAC,IAAwB;QAC/D,MAAM,QAAQ,GAAG,+BAAe,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAE5E,MAAM,CAAC,GAAiB,IAAI,CAAC,MAAM,CAAC;QACpC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC;YAClC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAA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C,MAAM,IAAI,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM;YAC7F,IAAI,CAAC,MAAM,CAAC,oCAAoC,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC7F,CAAC;IACD,6FAA6F;IACtF,YAAY,CAAC,KAAsB,EAAE,KAAa;QACvD,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACxD,IAAI,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,IAAI,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM;YACzD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;QACtC,IAAI,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,IAAI,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM;YACzD,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACzD,IAAI,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM;YAC5D,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC9D,CAAC;CAEF;AA5ID,8DA4IC","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 iModels\r\n */\r\n\r\nimport { assert, Id64Array, Id64String } from \"@itwin/core-bentley\";\r\nimport { IndexedPolyface, Polyface, PolyfaceData, PolyfaceVisitor } from \"@itwin/core-geometry\";\r\nimport { GeometryClass } from \"@itwin/core-common\";\r\n\r\n/** A collection of line segments, suitable for direct use with graphics APIs.\r\n * The structure of this data matches GL_LINES in OpenGL.\r\n * See [IModelDb.exportGraphics]($core-backend)\r\n * @public\r\n */\r\nexport interface ExportGraphicsLines {\r\n /** Zero-based vertex indices, every two indices represent a line segment */\r\n indices: Int32Array;\r\n /** Vertices for these lines, laid out in the pattern XYZXYZ */\r\n points: Float64Array;\r\n}\r\n\r\n/** Info provided to ExportLinesFunction about linework graphics.\r\n * See [IModelDb.exportGraphics]($core-backend)\r\n * @public\r\n */\r\nexport interface ExportLinesInfo {\r\n /** The element ID for the element the graphics originated from */\r\n elementId: Id64String;\r\n /** ID for the [SubCategory]($core-backend) for these graphics */\r\n subCategory: Id64String;\r\n /** The color and transparency for these graphics, laid out in TBGR format, see [ColorDef]($core-common) */\r\n color: number;\r\n /** GeometryClass for these graphics */\r\n geometryClass: GeometryClass;\r\n /** The linework for these graphics */\r\n lines: ExportGraphicsLines;\r\n}\r\n\r\n/** A callback function that receives generated line graphics.\r\n * See [IModelDb.exportGraphics]($core-backend)\r\n * @public\r\n */\r\nexport type ExportLinesFunction = (info: ExportLinesInfo) => void;\r\n\r\n/** A triangulated mesh with unified indices, suitable for direct use with graphics APIs.\r\n * See [IModelDb.exportGraphics]($core-backend)\r\n * @public\r\n */\r\nexport interface ExportGraphicsMesh {\r\n /** Zero-based vertex indices, every three indices represent a triangle */\r\n indices: Int32Array;\r\n /** Vertices for this mesh, laid out in the pattern XYZXYZ */\r\n points: Float64Array;\r\n /** Normals for this mesh, laid out in the pattern XYZXYZ */\r\n normals: Float32Array;\r\n /** Parameters (uvs) for this mesh, laid out in the pattern XYXY */\r\n params: Float32Array;\r\n /** If true, clients should assume both sides of the mesh are visible and not cull backfaces. */\r\n isTwoSided: boolean;\r\n}\r\n\r\n/** Info provided to ExportGraphicsFunction about graphics.\r\n * See [IModelDb.exportGraphics]($core-backend)\r\n * @public\r\n */\r\nexport interface ExportGraphicsInfo {\r\n /** The element ID for the element the graphics originated from */\r\n elementId: Id64String;\r\n /** ID for the [SubCategory]($core-backend) for these graphics */\r\n subCategory: Id64String;\r\n /** The color and transparency for these graphics, laid out in TBGR format, see [ColorDef]($core-common) */\r\n color: number;\r\n /** GeometryClass for these graphics */\r\n geometryClass: GeometryClass;\r\n /** If defined, ID for the [RenderMaterialElement]($core-backend) for these graphics */\r\n materialId?: Id64String;\r\n /** If defined, ID for the [Texture]($core-backend) for these graphics */\r\n textureId?: Id64String;\r\n /** The mesh for these graphics */\r\n mesh: ExportGraphicsMesh;\r\n}\r\n\r\n/** Information about the base display properties when a [GeometryPart]($core-backend) was\r\n * referenced. This is intended to be used with [IModelDb.exportPartGraphics]($core-backend).\r\n * * If two ExportPartInstanceInfo have the same ExportPartDisplayInfos, they will result in the\r\n * same graphics (with a different transform).\r\n * * If two ExportPartInstanceInfo have different ExportPartDisplayInfos, they may result in different\r\n * graphics.\r\n * @public\r\n */\r\nexport interface ExportPartDisplayInfo {\r\n categoryId: Id64String;\r\n subCategoryId: Id64String;\r\n geometryClass: GeometryClass;\r\n materialId: Id64String;\r\n elmTransparency: number;\r\n lineColor: number;\r\n}\r\n\r\n/** Information about references to [GeometryPart]($core-backend) elements found during\r\n * a call to [IModelDb.exportGraphics]($core-backend).\r\n * See [IModelDb.exportPartGraphics]($core-backend) for the intended use case.\r\n * @public\r\n */\r\nexport interface ExportPartInstanceInfo {\r\n /** ID for the [GeometryPart]($core-backend) */\r\n partId: Id64String;\r\n /** ID for the element that contained the reference to the [GeometryPart]($core-backend) */\r\n partInstanceId: Id64String;\r\n /** The base display properties when the [GeometryPart]($core-backend) was referenced. */\r\n displayProps: ExportPartDisplayInfo;\r\n /** A row-major storage 4x3 transform for this instance.\r\n * See export-gltf under test-apps in the iTwin.js monorepo for a working reference.\r\n */\r\n transform?: Float64Array;\r\n}\r\n\r\n/** A callback function that receives generated graphics.\r\n * See [IModelDb.exportGraphics]($core-backend)\r\n * @public\r\n */\r\nexport type ExportGraphicsFunction = (info: ExportGraphicsInfo) => void;\r\n\r\n/** Parameters for [IModelDb.exportGraphics]($core-backend)\r\n * @public\r\n */\r\nexport interface ExportGraphicsOptions {\r\n /** The source elements for the exported graphics */\r\n elementIdArray: Id64Array;\r\n /** A function to call for each unique element ID, color and texture combination */\r\n onGraphics: ExportGraphicsFunction;\r\n /** An optional function to call if line graphics are desired. */\r\n onLineGraphics?: ExportLinesFunction;\r\n /** If supplied, any references to [GeometryPart]($core-backend) elements found will be\r\n * recorded in this array. In this case, graphics that would result from the GeometryPart\r\n * will not be supplied via onGraphics. See [IModelDb.exportPartGraphics]($core-backend)\r\n */\r\n partInstanceArray?: ExportPartInstanceInfo[];\r\n /** Max distance from a face to the original geometry, see [StrokeOptions]($core-geometry) */\r\n chordTol?: number;\r\n /** Max angle difference in radians for approximated face, see [StrokeOptions]($core-geometry) */\r\n angleTol?: number;\r\n /** Max length of any edge in generated faces, see [StrokeOptions]($core-geometry) */\r\n maxEdgeLength?: number;\r\n /** The longest dimension of a line style's largest component must be at least this size in order for\r\n * exportGraphics to evaluate and generate its graphics. If undefined, this defaults to 0.1.\r\n * Line styles can evaluate to 3D geometry that clients expect to receive from exportGraphics, but they\r\n * can also generate gigabytes of mesh data when line styles with small components are applied to long\r\n * line strings.\r\n */\r\n minLineStyleComponentSize?: number;\r\n /** Max distance between mesh vertices for them to be collapsed.\r\n * Meshes stored in GeometryStreams are unaffected by StrokeOptions settings. If decimationTol is undefined,\r\n * they are output from exportGraphics without any reduction in quality and can be too detailed for\r\n * some uses. However, decimation is a destructive operation that can introduce gaps and other visual\r\n * anomalies so it is important to choose an appropriate setting for your use case.\r\n */\r\n decimationTol?: number;\r\n /** BRep features with bounding boxes smaller than this size will not generate graphics.\r\n * This option can be used to ignore expensive details from [BRepEntity.DataProps]($core-common)\r\n * like screws and screw holes.\r\n */\r\n minBRepFeatureSize?: number;\r\n}\r\n\r\n/** Info provided to ExportPartFunction about graphics.\r\n * See [IModelDb.exportPartGraphics]($core-backend)\r\n * @public\r\n */\r\nexport interface ExportPartInfo {\r\n /** The color and transparency for these graphics, laid out in TBGR format, see [ColorDef]($core-common) */\r\n color: number;\r\n /** GeometryClass for these graphics */\r\n geometryClass: GeometryClass;\r\n /** If defined, ID for the [RenderMaterialElement]($core-backend) for these graphics */\r\n materialId?: Id64String;\r\n /** If defined, ID for the [Texture]($core-backend) for these graphics */\r\n textureId?: Id64String;\r\n /** The mesh for these graphics */\r\n mesh: ExportGraphicsMesh;\r\n}\r\n\r\n/** A callback function that receives generated graphics for a [GeometryPart]($core-backend).\r\n * See [IModelDb.exportPartGraphics]($core-backend)\r\n * @public\r\n */\r\nexport type ExportPartFunction = (info: ExportPartInfo) => void;\r\n\r\n/** Info provided to ExportPartFunction about line graphics.\r\n * See [IModelDb.exportPartGraphics]($core-backend)\r\n * @public\r\n */\r\nexport interface ExportPartLinesInfo {\r\n /** The color and transparency for these graphics, laid out in TBGR format, see [ColorDef]($core-common) */\r\n color: number;\r\n /** GeometryClass for these graphics */\r\n geometryClass: GeometryClass;\r\n /** The linework for these graphics */\r\n lines: ExportGraphicsLines;\r\n}\r\n\r\n/** A callback function that receives generated line graphics for a [GeometryPart]($core-backend).\r\n * See [IModelDb.exportPartGraphics]($core-backend)\r\n * @public\r\n */\r\nexport type ExportPartLinesFunction = (info: ExportPartLinesInfo) => void;\r\n\r\n/** Parameters for [IModelDb.exportPartGraphics]($core-backend)\r\n * @public\r\n */\r\nexport interface ExportPartGraphicsOptions {\r\n /** The ID for the source [GeometryPart]($core-backend) */\r\n elementId: Id64String;\r\n /** The base display properties to use for generating the graphics. This should come from an\r\n * ExportPartInstanceProps generated by [IModelDb.exportGraphics]($core-backend)\r\n */\r\n displayProps: ExportPartDisplayInfo;\r\n /** A function to call for each unique color and texture combination. */\r\n onPartGraphics: ExportPartFunction;\r\n /** An optional function to call if line graphics are desired. */\r\n onPartLineGraphics?: ExportPartLinesFunction;\r\n /** Max distance from a face to the original geometry, see [StrokeOptions]($core-geometry) */\r\n chordTol?: number;\r\n /** Max angle difference in radians for approximated face, see [StrokeOptions]($core-geometry) */\r\n angleTol?: number;\r\n /** Max length of any edge in generated faces, see [StrokeOptions]($core-geometry) */\r\n maxEdgeLength?: number;\r\n /** The longest dimension of a line style's largest component must be at least this size in order for\r\n * exportGraphics to evaluate and generate its graphics. If undefined, this defaults to 0.1.\r\n * Line styles can evaluate to 3D geometry that clients expect to receive from exportGraphics, but they\r\n * can also generate gigabytes of mesh data when line styles with small components are applied to long\r\n * line strings.\r\n */\r\n minLineStyleComponentSize?: number;\r\n /** Max distance between mesh vertices for them to be collapsed.\r\n * Meshes stored in GeometryStreams are unaffected by StrokeOptions settings. If decimationTol is undefined,\r\n * they are output from exportGraphics without any reduction in quality and can be too detailed for\r\n * some uses. However, decimation is a destructive operation that can introduce gaps and other visual\r\n * anomalies so it is important to choose an appropriate setting for your use case.\r\n */\r\n decimationTol?: number;\r\n /** BRep features with bounding boxes smaller than this size will not generate graphics.\r\n * This option can be used to ignore expensive details from [BRepEntity.DataProps]($core-common)\r\n * like screws and screw holes.\r\n */\r\n minBRepFeatureSize?: number;\r\n}\r\n\r\n/** Provides utility functions for working with data generated by [IModelDb.exportGraphics]($core-backend)\r\n * @public\r\n */\r\nexport namespace ExportGraphics {\r\n /** Test if ExportPartDisplayInfos have exactly the same values.\r\n * @public\r\n */\r\n export function arePartDisplayInfosEqual(lhs: ExportPartDisplayInfo, rhs: ExportPartDisplayInfo): boolean {\r\n if (lhs.categoryId !== rhs.categoryId) return false;\r\n if (lhs.subCategoryId !== rhs.subCategoryId) return false;\r\n if (lhs.materialId !== rhs.materialId) return false;\r\n if (lhs.elmTransparency !== rhs.elmTransparency) return false;\r\n if (lhs.lineColor !== rhs.lineColor) return false;\r\n return true;\r\n }\r\n\r\n /**\r\n * Convert an ExportGraphicsMesh to an IndexedPolyface usable by the geometry API.\r\n * @note The resulting IndexedPolyface may have duplicate points, normals and params. If problematic, call [PolyfaceData.compress]($core-geometry)\r\n * @public\r\n */\r\n export function convertToIndexedPolyface(mesh: ExportGraphicsMesh): IndexedPolyface {\r\n const polyface = IndexedPolyface.create(true, true, false, mesh.isTwoSided);\r\n\r\n const p: Float64Array = mesh.points;\r\n for (let i = 0; i < p.length; i += 3)\r\n polyface.data.point.pushXYZ(p[i], p[i + 1], p[i + 2]);\r\n\r\n const n: Float32Array = mesh.normals;\r\n assert(undefined !== polyface.data.normal);\r\n for (let i = 0; i < n.length; i += 3)\r\n polyface.data.normal.pushXYZ(n[i], n[i + 1], n[i + 2]);\r\n\r\n const uv: Float32Array = mesh.params;\r\n assert(undefined !== polyface.data.param);\r\n for (let i = 0; i < uv.length; i += 2)\r\n polyface.data.param.pushXY(uv[i], uv[i + 1]);\r\n\r\n const indices = mesh.indices;\r\n const addIndex = (idx: number) => {\r\n polyface.addPointIndex(idx, true);\r\n polyface.addNormalIndex(idx);\r\n polyface.addParamIndex(idx);\r\n };\r\n for (let i = 0; i < indices.length; i += 3) {\r\n addIndex(indices[i]);\r\n addIndex(indices[i + 1]);\r\n addIndex(indices[i + 2]);\r\n polyface.terminateFacet(false);\r\n }\r\n\r\n return polyface;\r\n }\r\n}\r\n/**\r\n * * Iterator to walk the facets of an ExportGraphicsMesh and present them to the world as if visiting a Polyface.\r\n * * Because the ExportGraphicsMesh has limited data:\r\n * * There is no auxData in this visitor.\r\n * * There is no color in this visitor.\r\n * * All edgeVisible are true.\r\n * @public\r\n */\r\nexport class ExportGraphicsMeshVisitor extends PolyfaceData implements PolyfaceVisitor {\r\n private _currentFacetIndex: number;\r\n private _nextFacetIndex: number;\r\n private _numWrap: number;\r\n private _polyface: ExportGraphicsMesh;\r\n // to be called from static factory method that validates the polyface ...\r\n private constructor(facets: ExportGraphicsMesh, numWrap: number) {\r\n super(facets.normals.length > 0, facets.params.length > 0, false, facets.isTwoSided);\r\n this._polyface = facets;\r\n this._numWrap = numWrap;\r\n\r\n this._nextFacetIndex = 0;\r\n this._currentFacetIndex = -1;\r\n this.twoSided = facets.isTwoSided;\r\n this.reset();\r\n }\r\n /** Create a visitor for iterating the facets of `polyface`, with indicated number of points to be added to each facet to produce closed point arrays\r\n * Typical wrap counts are:\r\n * * 0 -- leave the point arrays with \"missing final edge\"\r\n * * 1 -- add point 0 as closure point\r\n * * 2 -- add points 0 and 1 as closure and wrap point. This is useful when vertex visit requires two adjacent vectors, e.g. for cross products.\r\n */\r\n public static create(polyface: ExportGraphicsMesh, numWrap: number): ExportGraphicsMeshVisitor {\r\n return new ExportGraphicsMeshVisitor(polyface, numWrap);\r\n }\r\n /** Reset the iterator to start at the first facet of the polyface. */\r\n public reset(): void {\r\n this.moveToReadIndex(0);\r\n this._nextFacetIndex = 0; // so immediate moveToNextFacet stays here.\r\n }\r\n /** Select a facet by simple index. */\r\n public moveToReadIndex(facetIndex: number): boolean {\r\n if (facetIndex < 0 || 2 + facetIndex * 3 >= this._polyface.indices.length)\r\n return false;\r\n this._currentFacetIndex = facetIndex;\r\n this._nextFacetIndex = facetIndex + 1;\r\n this.point.length = 0;\r\n const points = this.point;\r\n points.length = 0;\r\n this.pointIndex.length = 0;\r\n this.point.length = 0;\r\n this.edgeVisible.length = 0;\r\n const sourcePoints = this._polyface.points;\r\n const indices = this._polyface.indices;\r\n const i0 = 3 * facetIndex;\r\n for (let i = i0; i < i0 + 3; i++) {\r\n const k = 3 * indices[i];\r\n this.pointIndex.push(indices[i]);\r\n this.point.pushXYZ(sourcePoints[k], sourcePoints[k + 1], sourcePoints[k + 2]);\r\n this.edgeVisible.push(true);\r\n }\r\n for (let i = 0; i < this._numWrap; i++) {\r\n this.point.pushFromGrowableXYZArray(this.point, i);\r\n }\r\n\r\n const sourceParams = this._polyface.params;\r\n if (sourceParams.length > 0 && this.paramIndex && this.param) {\r\n this.paramIndex.length = 0;\r\n this.param.length = 0;\r\n for (let i = i0; i < i0 + 3; i++) {\r\n const k = 2 * indices[i];\r\n this.paramIndex.push(indices[i]);\r\n this.param.pushXY(sourceParams[k], sourceParams[k + 1]);\r\n }\r\n for (let i = 0; i < this._numWrap; i++) {\r\n this.param.pushFromGrowableXYArray(this.param, i);\r\n }\r\n }\r\n\r\n const sourceNormals = this._polyface.normals;\r\n if (sourceNormals.length > 0 && this.normalIndex && this.normal) {\r\n this.normalIndex.length = 0;\r\n this.normal.length = 0;\r\n for (let i = i0; i < i0 + 3; i++) {\r\n const k = 3 * indices[i];\r\n this.normalIndex.push(indices[i]);\r\n this.normal.pushXYZ(sourceNormals[k], sourceNormals[k + 1], sourceNormals[k + 2]);\r\n }\r\n for (let i = 0; i < this._numWrap; i++) {\r\n this.normal.pushFromGrowableXYZArray(this.normal, i);\r\n }\r\n }\r\n return true;\r\n }\r\n public moveToNextFacet(): boolean {\r\n return this.moveToReadIndex(this._nextFacetIndex);\r\n }\r\n /** Set the number of vertices to replicate in visitor arrays. */\r\n public setNumWrap(numWrap: number): void { this._numWrap = numWrap; }\r\n\r\n /** Return the index (in the client polyface) of the current facet */\r\n public currentReadIndex(): number { return this._currentFacetIndex; }\r\n /** Return the point index of vertex i within the currently loaded facet */\r\n public clientPointIndex(i: number): number { return this.pointIndex[i]; }\r\n /** Return the param index of vertex i within the currently loaded facet.\r\n * Use the artificial paramIndex, which matches pointIndex.\r\n */\r\n public clientParamIndex(i: number): number { return this.paramIndex ? this.paramIndex[i] : -1; }\r\n /** Return the normal index of vertex i within the currently loaded facet.\r\n * Use the artificial paramIndex, which matches pointIndex.\r\n */\r\n public clientNormalIndex(i: number): number { return this.normalIndex ? this.normalIndex[i] : -1; }\r\n /** Return the color index of vertex i within the currently loaded facet */\r\n public clientColorIndex(_i: number): number { return 1; }\r\n /** Return the aux data index of vertex i within the currently loaded facet */\r\n public clientAuxIndex(_i: number): number { return -1; }\r\n\r\n /** return the client polyface */\r\n public clientPolyface(): Polyface { return (undefined as unknown) as Polyface; }\r\n /** clear the contents of all arrays. Use this along with transferDataFrom methods to build up new facets */\r\n public clearArrays(): void {\r\n if (this.point !== undefined)\r\n this.point.length = 0;\r\n if (this.param !== undefined)\r\n this.param.length = 0;\r\n if (this.normal !== undefined)\r\n this.normal.length = 0;\r\n // ignore color and aux -- they never exist.\r\n }\r\n /** transfer interpolated data from the other visitor.\r\n * * all data values are interpolated at `fraction` between `other` values at index0 and index1.\r\n */\r\n public pushInterpolatedDataFrom(other: PolyfaceVisitor, index0: number, fraction: number, index1: number): void {\r\n this.point.pushInterpolatedFromGrowableXYZArray(other.point, index0, fraction, index1);\r\n if (this.param && other.param && index0 < other.param.length && index1 < other.param.length)\r\n this.param.pushInterpolatedFromGrowableXYArray(other.param, index0, fraction, index1);\r\n if (this.normal && other.normal && index0 < other.normal.length && index1 < other.normal.length)\r\n this.normal.pushInterpolatedFromGrowableXYZArray(other.normal, index0, fraction, index1);\r\n }\r\n /** transfer data from a specified index of the other visitor as new data in this visitor. */\r\n public pushDataFrom(other: PolyfaceVisitor, index: number): void {\r\n this.point.pushFromGrowableXYZArray(other.point, index);\r\n if (this.color && other.color && index < other.color.length)\r\n this.color.push(other.color[index]);\r\n if (this.param && other.param && index < other.param.length)\r\n this.param.pushFromGrowableXYArray(other.param, index);\r\n if (this.normal && other.normal && index < other.normal.length)\r\n this.normal.pushFromGrowableXYZArray(other.normal, index);\r\n }\r\n\r\n}\r\n"]}
@@ -279,7 +279,7 @@ export declare abstract class IModelDb extends IModel {
279
279
  *
280
280
  * @param ecsql The ECSQL statement to execute
281
281
  * @param params The values to bind to the parameters (if the ECSQL has any).
282
- * See "[iModel.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)" for details.
282
+ * See "[iTwin.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)" for details.
283
283
  * @returns Return row count.
284
284
  * @throws [IModelError]($common) If the statement is invalid
285
285
  */
@@ -564,7 +564,7 @@ export declare abstract class IModelDb extends IModel {
564
564
  * that list.
565
565
  * * The results of changing [ExportPartGraphicsOptions]($core-backend) during the
566
566
  * [ExportPartGraphicsOptions.onPartGraphics]($core-backend) callback are not defined.
567
- * * See export-gltf under test-apps in the iModel.js monorepo for a working reference.
567
+ * * See export-gltf under test-apps in the iTwin.js monorepo for a working reference.
568
568
  * @returns 0 is successful, status otherwise
569
569
  * @public
570
570
  */
@@ -334,7 +334,7 @@ class IModelDb extends core_common_1.IModel {
334
334
  *
335
335
  * @param ecsql The ECSQL statement to execute
336
336
  * @param params The values to bind to the parameters (if the ECSQL has any).
337
- * See "[iModel.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)" for details.
337
+ * See "[iTwin.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)" for details.
338
338
  * @returns Return row count.
339
339
  * @throws [IModelError]($common) If the statement is invalid
340
340
  */
@@ -939,7 +939,7 @@ class IModelDb extends core_common_1.IModel {
939
939
  * that list.
940
940
  * * The results of changing [ExportPartGraphicsOptions]($core-backend) during the
941
941
  * [ExportPartGraphicsOptions.onPartGraphics]($core-backend) callback are not defined.
942
- * * See export-gltf under test-apps in the iModel.js monorepo for a working reference.
942
+ * * See export-gltf under test-apps in the iTwin.js monorepo for a working reference.
943
943
  * @returns 0 is successful, status otherwise
944
944
  * @public
945
945
  */