@itwin/core-backend 3.0.0-dev.84 → 3.0.0-dev.85

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":"ECDb.js","sourceRoot":"","sources":["../../src/ECDb.ts"],"names":[],"mappings":";;;AAKA;;GAEG;AACH,sDAA8E;AAC9E,oDAA8I;AAC9I,mEAAgE;AAChE,uDAAoD;AACpD,qDAAkD;AAClD,6CAA0C;AAC1C,uDAAoE;AAEpE,MAAM,cAAc,GAAW,6CAAqB,CAAC,IAAI,CAAC;AAE1D;;GAEG;AACH,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,uDAAQ,CAAA;IACR,yDAAS,CAAA;IACT,sGAAsG;IACtG,6DAAW,CAAA;AACb,CAAC,EALW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAKvB;AAED;;GAEG;AACH,MAAa,IAAI;IAef;QAbQ,gCAA2B,GAAY,KAAK,CAAC;QACpC,oBAAe,GAAG,IAAI,gCAAc,EAAkB,CAAC;QAChE,0BAAqB,GAAG,IAAI,gCAAc,EAAmB,CAAC;QAC9D,0BAAqB,GAAG,EAAE,gBAAgB,EAAG,IAAY,EAAE,cAAc,EAAG,IAAY,EAAE,gBAAgB,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;QAWnJ,IAAI,CAAC,SAAS,GAAG,IAAI,uBAAU,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;IAClD,CAAC;IAVD;;OAEG;IACI,gBAAgB,CAAC,IAAY;QAClC,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,CAAC;QACnC,IAAI,CAAC,qBAAqB,GAAG,IAAI,gCAAc,CAAkB,IAAI,CAAC,CAAC;IACzE,CAAC;IAKD;;OAEG;IACI,OAAO;QACZ,IAAI,CAAC,IAAI,CAAC,SAAS;YACjB,OAAO;QAET,IA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C,gBAAgB,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;IACD;;;;;;;;;;;OAWG;IACI,KAAK,CAAC,aAAa,CAAC,KAAa,EAAE,MAAoB;QAC5D,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,yBAAyB,KAAK,GAAG,EAAE,MAAM,CAAC,EAAE;YAC7E,OAAO,GAAG,CAAC,CAAC,CAAW,CAAC;SACzB;QACD,MAAM,IAAI,yBAAW,CAAC,uBAAQ,CAAC,eAAe,EAAE,yBAAyB,CAAC,CAAC;IAC7E,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACI,KAAK,CAAC,CAAE,YAAY,CAAC,KAAa,EAAE,KAAa,EAAE,MAAoB,EAAE,SAAS,GAAG,4BAAc,CAAC,eAAe,EAAE,OAAsB;QAChJ,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,iCAAmB,CAAC,OAAO,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,CAAC,EAAE;YAClI,MAAM,GAAG,CAAC;SACX;IACH,CAAC;CACF;AAjVD,oBAiVC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\n/** @packageDocumentation\n * @module ECDb\n */\nimport { DbResult, IDisposable, Logger, OpenMode } from \"@itwin/core-bentley\";\nimport { DbQueryRequest, ECSqlReader, IModelError, QueryBinder, QueryOptions, QueryOptionsBuilder, QueryRowFormat } from \"@itwin/core-common\";\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\nimport { ConcurrentQuery } from \"./ConcurrentQuery\";\nimport { ECSqlStatement } from \"./ECSqlStatement\";\nimport { IModelHost } from \"./IModelHost\";\nimport { SqliteStatement, StatementCache } from \"./SqliteStatement\";\n\nconst loggerCategory: string = BackendLoggerCategory.ECDb;\n\n/** Modes for how to open [ECDb]($backend) files.\n * @public\n */\nexport enum ECDbOpenMode {\n Readonly,\n ReadWrite,\n /** Opens the file read-write and upgrades the file if necessary to the latest file format version. */\n FileUpgrade,\n}\n\n/** An ECDb file\n * @public\n */\nexport class ECDb implements IDisposable {\n private _nativeDb?: IModelJsNative.ECDb;\n private _concurrentQueryInitialized: boolean = false;\n private readonly _statementCache = new StatementCache<ECSqlStatement>();\n private _sqliteStatementCache = new StatementCache<SqliteStatement>();\n private _concurrentQueryStats = { resetTimerHandle: (null as any), logTimerHandle: (null as any), lastActivityTime: Date.now(), dispose: () => { } };\n\n /** only for tests\n * @internal\n */\n public resetSqliteCache(size: number) {\n this._sqliteStatementCache.clear();\n this._sqliteStatementCache = new StatementCache<SqliteStatement>(size);\n }\n\n constructor() {\n this._nativeDb = new IModelHost.platform.ECDb();\n }\n /** Call this function when finished with this ECDb object. This releases the native resources held by the\n * ECDb object.\n */\n public dispose(): void {\n if (!this._nativeDb)\n return;\n\n this.closeDb();\n this._nativeDb.dispose();\n this._nativeDb = undefined;\n }\n\n /** Create an ECDb\n * @param pathName The path to the ECDb file to create.\n * @throws [IModelError]($common) if the operation failed.\n */\n public createDb(pathName: string): void {\n const status: DbResult = this.nativeDb.createDb(pathName);\n if (status !== DbResult.BE_SQLITE_OK)\n throw new IModelError(status, \"Failed to created ECDb\");\n }\n\n /** Open the ECDb.\n * @param pathName The path to the ECDb file to open\n * @param openMode Open mode\n * @throws [IModelError]($common) if the operation failed.\n */\n public openDb(pathName: string, openMode: ECDbOpenMode = ECDbOpenMode.Readonly): void {\n const nativeOpenMode: OpenMode = openMode === ECDbOpenMode.Readonly ? OpenMode.Readonly : OpenMode.ReadWrite;\n const tryUpgrade: boolean = openMode === ECDbOpenMode.FileUpgrade;\n const status: DbResult = this.nativeDb.openDb(pathName, nativeOpenMode, tryUpgrade);\n if (status !== DbResult.BE_SQLITE_OK)\n throw new IModelError(status, \"Failed to open ECDb\");\n }\n\n /** Returns true if the ECDb is open */\n public get isOpen(): boolean { return this.nativeDb.isOpen(); }\n\n /** Close the Db after saving any uncommitted changes.\n * @throws [IModelError]($common) if the database is not open.\n */\n public closeDb(): void {\n this._statementCache.clear();\n this._sqliteStatementCache.clear();\n this.nativeDb.closeDb();\n this._concurrentQueryStats.dispose();\n }\n\n /** @internal use to test statement caching */\n public clearStatementCache() {\n this._statementCache.clear();\n }\n\n /** @internal use to test statement caching */\n public getCachedStatementCount() {\n return this._statementCache.size;\n }\n\n /** Commit the outermost transaction, writing changes to the file. Then, restart the transaction.\n * @param changeSetName The name of the operation that generated these changes.\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\n */\n public saveChanges(changeSetName?: string): void {\n const status: DbResult = this.nativeDb.saveChanges(changeSetName);\n if (status !== DbResult.BE_SQLITE_OK)\n throw new IModelError(status, \"Failed to save changes\");\n }\n\n /** Abandon (cancel) the outermost transaction, discarding all changes since last save. Then, restart the transaction.\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\n */\n public abandonChanges(): void {\n const status: DbResult = this.nativeDb.abandonChanges();\n if (status !== DbResult.BE_SQLITE_OK)\n throw new IModelError(status, \"Failed to abandon changes\");\n }\n\n /** Import a schema.\n *\n * If the import was successful, the database is automatically saved to disk.\n * @param pathName Path to ECSchema XML file to import.\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\n */\n public importSchema(pathName: string): void {\n const status: DbResult = this.nativeDb.importSchema(pathName);\n if (status !== DbResult.BE_SQLITE_OK) {\n Logger.logError(loggerCategory, `Failed to import schema from '${pathName}'.`);\n throw new IModelError(status, `Failed to import schema from '${pathName}'.`);\n }\n }\n\n /**\n * Use a prepared ECSQL statement, potentially from the statement cache. If the requested statement doesn't exist\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\n * in the statement cache so it can be reused in the future. Use this method for ECSQL statements that will be\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withStatement]].\n * @param sql The SQLite SQL statement to execute\n * @param callback the callback to invoke on the prepared statement\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @returns the value returned by `callback`.\n * @see [[withStatement]]\n * @public\n */\n public withPreparedStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors = true): T {\n const stmt = this._statementCache.findAndRemove(ecsql) ?? this.prepareStatement(ecsql, logErrors);\n const release = () => this._statementCache.addOrDispose(stmt);\n try {\n const val = callback(stmt);\n if (val instanceof Promise) {\n val.then(release, release);\n } else {\n release();\n }\n return val;\n } catch (err) {\n release();\n throw err;\n }\n }\n\n /**\n * Prepared and execute a callback on an ECSQL statement. After the callback completes the statement is disposed.\n * Use this method for ECSQL statements are either not expected to be reused, or are not expensive to prepare.\n * For statements that will be reused often, instead use [[withPreparedStatement]].\n * @param sql The SQLite SQL statement to execute\n * @param callback the callback to invoke on the prepared statement\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @returns the value returned by `callback`.\n * @see [[withPreparedStatement]]\n * @public\n */\n public withStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors = true): T {\n const stmt = this.prepareStatement(ecsql, logErrors);\n const release = () => stmt.dispose();\n try {\n const val = callback(stmt);\n if (val instanceof Promise) {\n val.then(release, release);\n } else {\n release();\n }\n return val;\n } catch (err) {\n release();\n throw err;\n }\n }\n\n /** Prepare an ECSQL statement.\n * @param ecsql The ECSQL statement to prepare\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @throws [IModelError]($common) if there is a problem preparing the statement.\n */\n public prepareStatement(ecsql: string, logErrors = true): ECSqlStatement {\n const stmt = new ECSqlStatement();\n stmt.prepare(this.nativeDb, ecsql, logErrors);\n return stmt;\n }\n\n /**\n * Use a prepared SQL statement, potentially from the statement cache. If the requested statement doesn't exist\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\n * in the statement cache so it can be reused in the future. Use this method for SQL statements that will be\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withSqliteStatement]].\n * @param sql The SQLite SQL statement to execute\n * @param callback the callback to invoke on the prepared statement\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @returns the value returned by `callback`.\n * @see [[withPreparedStatement]]\n * @public\n */\n public withPreparedSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors = true): T {\n const stmt = this._sqliteStatementCache.findAndRemove(sql) ?? this.prepareSqliteStatement(sql, logErrors);\n const release = () => this._sqliteStatementCache.addOrDispose(stmt);\n try {\n const val: T = callback(stmt);\n if (val instanceof Promise) {\n val.then(release, release);\n } else {\n release();\n }\n return val;\n } catch (err) {\n release();\n throw err;\n }\n }\n\n /**\n * Prepared and execute a callback on a SQL statement. After the callback completes the statement is disposed.\n * Use this method for SQL statements are either not expected to be reused, or are not expensive to prepare.\n * For statements that will be reused often, instead use [[withPreparedSqliteStatement]].\n * @param sql The SQLite SQL statement to execute\n * @param callback the callback to invoke on the prepared statement\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @returns the value returned by `callback`.\n * @public\n */\n public withSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors = true): T {\n const stmt = this.prepareSqliteStatement(sql, logErrors);\n const release = () => stmt.dispose();\n try {\n const val: T = callback(stmt);\n if (val instanceof Promise) {\n val.then(release, release);\n } else {\n release();\n }\n return val;\n } catch (err) {\n release();\n throw err;\n }\n }\n\n /** Prepare an SQL statement.\n * @param sql The SQLite SQL statement to prepare\n * @param logErrors Determines if error will be logged if statement fail to prepare\n * @throws [IModelError]($common) if there is a problem preparing the statement.\n * @internal\n */\n public prepareSqliteStatement(sql: string, logErrors = true): SqliteStatement {\n const stmt = new SqliteStatement(sql);\n stmt.prepare(this.nativeDb, logErrors);\n return stmt;\n }\n\n /** @internal */\n public get nativeDb(): IModelJsNative.ECDb {\n return this._nativeDb!;\n }\n\n /** Allow to execute query and read results along with meta data. The result are streamed.\n * @param params The values to bind to the parameters (if the ECSQL has any).\n * @param config Allow to specify certain flags which control how query is executed.\n * @returns Returns *ECSqlQueryReader* which help iterate over result set and also give access to meta data.\n * @beta\n * */\n public createQueryReader(ecsql: string, params?: QueryBinder, config?: QueryOptions): ECSqlReader {\n if (!this._nativeDb || !this._nativeDb.isOpen()) {\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"db not open\");\n }\n const executor = {\n execute: async (request: DbQueryRequest) => {\n return ConcurrentQuery.executeQueryRequest(this._nativeDb!, request);\n },\n };\n return new ECSqlReader(executor, ecsql, params, config);\n }\n\n /** Execute a query and stream its results\n * The result of the query is async iterator over the rows. The iterator will get next page automatically once rows in current page has been read.\n * [ECSQL row]($docs/learning/ECSQLRowFormat).\n *\n * See also:\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\n * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)\n *\n * @param ecsql The ECSQL statement to execute\n * @param params The values to bind to the parameters (if the ECSQL has any).\n * @param rowFormat Specify what format the row will be returned. It default to Array format though to make it compilable with previous version use *QueryRowFormat.UseJsPropertyNames*\n * @param options Allow to specify certain flags which control how query is executed.\n * @returns Returns the query result as an *AsyncIterableIterator<any>* which lazy load result as needed. The row format is determined by *rowFormat* parameter.\n * See [ECSQL row format]($docs/learning/ECSQLRowFormat) for details about the format of the returned rows.\n * @throws [IModelError]($common) If there was any error while submitting, preparing or stepping into query\n */\n public async * query(ecsql: string, params?: QueryBinder, rowFormat = QueryRowFormat.UseArrayIndexes, options?: QueryOptions): AsyncIterableIterator<any> {\n const builder = new QueryOptionsBuilder(options);\n if (rowFormat === QueryRowFormat.UseJsPropertyNames) {\n builder.setConvertClassIdsToNames(true);\n }\n const reader = this.createQueryReader(ecsql, params, builder.getOptions());\n while (await reader.step())\n yield reader.formatCurrentRow(rowFormat);\n }\n /** Compute number of rows that would be returned by the ECSQL.\n *\n * See also:\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\n * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)\n *\n * @param ecsql The ECSQL statement to execute\n * @param params The values to bind to the parameters (if the ECSQL has any).\n * See \"[iModel.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)\" for details.\n * @returns Return row count.\n * @throws [IModelError]($common) If the statement is invalid\n */\n public async queryRowCount(ecsql: string, params?: QueryBinder): Promise<number> {\n for await (const row of this.query(`select count(*) from (${ecsql})`, params)) {\n return row[0] as number;\n }\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Failed to get row count\");\n }\n\n /** Cancel any previous query with same token and run execute the current specified query.\n * The result of the query is async iterator over the rows. The iterator will get next page automatically once rows in current page has been read.\n * [ECSQL row]($docs/learning/ECSQLRowFormat).\n *\n * See also:\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\n * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)\n *\n * @param ecsql The ECSQL statement to execute\n * @param token None empty restart token. The previous query with same token would be cancelled. This would cause\n * exception which user code must handle.\n * @param params The values to bind to the parameters (if the ECSQL has any).\n * @param rowFormat Specify what format the row will be returned. It default to Array format though to make it compilable with previous version use *QueryRowFormat.UseJsPropertyNames*\n * @param options Allow to specify certain flags which control how query is executed.\n * @returns Returns the query result as an *AsyncIterableIterator<any>* which lazy load result as needed. The row format is determined by *rowFormat* parameter.\n * See [ECSQL row format]($docs/learning/ECSQLRowFormat) for details about the format of the returned rows.\n * @throws [IModelError]($common) If there was any error while submitting, preparing or stepping into query\n */\n public async * restartQuery(token: string, ecsql: string, params?: QueryBinder, rowFormat = QueryRowFormat.UseArrayIndexes, options?: QueryOptions): AsyncIterableIterator<any> {\n for await (const row of this.query(ecsql, params, rowFormat, new QueryOptionsBuilder(options).setRestartToken(token).getOptions())) {\n yield row;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"ECDb.js","sourceRoot":"","sources":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AK,CAAC,yBAAyB,KAAK,GAAG,EAAE,MAAM,CAAC,EAAE;YAC7E,OAAO,GAAG,CAAC,CAAC,CAAW,CAAC;SACzB;QACD,MAAM,IAAI,yBAAW,CAAC,uBAAQ,CAAC,eAAe,EAAE,yBAAyB,CAAC,CAAC;IAC7E,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACI,KAAK,CAAC,CAAE,YAAY,CAAC,KAAa,EAAE,KAAa,EAAE,MAAoB,EAAE,SAAS,GAAG,4BAAc,CAAC,eAAe,EAAE,OAAsB;QAChJ,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,iCAAmB,CAAC,OAAO,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,CAAC,EAAE;YAClI,MAAM,GAAG,CAAC;SACX;IACH,CAAC;CACF;AAjVD,oBAiVC","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\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\n/** @packageDocumentation\r\n * @module ECDb\r\n */\r\nimport { DbResult, IDisposable, Logger, OpenMode } from \"@itwin/core-bentley\";\r\nimport { DbQueryRequest, ECSqlReader, IModelError, QueryBinder, QueryOptions, QueryOptionsBuilder, QueryRowFormat } from \"@itwin/core-common\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { ConcurrentQuery } from \"./ConcurrentQuery\";\r\nimport { ECSqlStatement } from \"./ECSqlStatement\";\r\nimport { IModelHost } from \"./IModelHost\";\r\nimport { SqliteStatement, StatementCache } from \"./SqliteStatement\";\r\n\r\nconst loggerCategory: string = BackendLoggerCategory.ECDb;\r\n\r\n/** Modes for how to open [ECDb]($backend) files.\r\n * @public\r\n */\r\nexport enum ECDbOpenMode {\r\n Readonly,\r\n ReadWrite,\r\n /** Opens the file read-write and upgrades the file if necessary to the latest file format version. */\r\n FileUpgrade,\r\n}\r\n\r\n/** An ECDb file\r\n * @public\r\n */\r\nexport class ECDb implements IDisposable {\r\n private _nativeDb?: IModelJsNative.ECDb;\r\n private _concurrentQueryInitialized: boolean = false;\r\n private readonly _statementCache = new StatementCache<ECSqlStatement>();\r\n private _sqliteStatementCache = new StatementCache<SqliteStatement>();\r\n private _concurrentQueryStats = { resetTimerHandle: (null as any), logTimerHandle: (null as any), lastActivityTime: Date.now(), dispose: () => { } };\r\n\r\n /** only for tests\r\n * @internal\r\n */\r\n public resetSqliteCache(size: number) {\r\n this._sqliteStatementCache.clear();\r\n this._sqliteStatementCache = new StatementCache<SqliteStatement>(size);\r\n }\r\n\r\n constructor() {\r\n this._nativeDb = new IModelHost.platform.ECDb();\r\n }\r\n /** Call this function when finished with this ECDb object. This releases the native resources held by the\r\n * ECDb object.\r\n */\r\n public dispose(): void {\r\n if (!this._nativeDb)\r\n return;\r\n\r\n this.closeDb();\r\n this._nativeDb.dispose();\r\n this._nativeDb = undefined;\r\n }\r\n\r\n /** Create an ECDb\r\n * @param pathName The path to the ECDb file to create.\r\n * @throws [IModelError]($common) if the operation failed.\r\n */\r\n public createDb(pathName: string): void {\r\n const status: DbResult = this.nativeDb.createDb(pathName);\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to created ECDb\");\r\n }\r\n\r\n /** Open the ECDb.\r\n * @param pathName The path to the ECDb file to open\r\n * @param openMode Open mode\r\n * @throws [IModelError]($common) if the operation failed.\r\n */\r\n public openDb(pathName: string, openMode: ECDbOpenMode = ECDbOpenMode.Readonly): void {\r\n const nativeOpenMode: OpenMode = openMode === ECDbOpenMode.Readonly ? OpenMode.Readonly : OpenMode.ReadWrite;\r\n const tryUpgrade: boolean = openMode === ECDbOpenMode.FileUpgrade;\r\n const status: DbResult = this.nativeDb.openDb(pathName, nativeOpenMode, tryUpgrade);\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to open ECDb\");\r\n }\r\n\r\n /** Returns true if the ECDb is open */\r\n public get isOpen(): boolean { return this.nativeDb.isOpen(); }\r\n\r\n /** Close the Db after saving any uncommitted changes.\r\n * @throws [IModelError]($common) if the database is not open.\r\n */\r\n public closeDb(): void {\r\n this._statementCache.clear();\r\n this._sqliteStatementCache.clear();\r\n this.nativeDb.closeDb();\r\n this._concurrentQueryStats.dispose();\r\n }\r\n\r\n /** @internal use to test statement caching */\r\n public clearStatementCache() {\r\n this._statementCache.clear();\r\n }\r\n\r\n /** @internal use to test statement caching */\r\n public getCachedStatementCount() {\r\n return this._statementCache.size;\r\n }\r\n\r\n /** Commit the outermost transaction, writing changes to the file. Then, restart the transaction.\r\n * @param changeSetName The name of the operation that generated these changes.\r\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\r\n */\r\n public saveChanges(changeSetName?: string): void {\r\n const status: DbResult = this.nativeDb.saveChanges(changeSetName);\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to save changes\");\r\n }\r\n\r\n /** Abandon (cancel) the outermost transaction, discarding all changes since last save. Then, restart the transaction.\r\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\r\n */\r\n public abandonChanges(): void {\r\n const status: DbResult = this.nativeDb.abandonChanges();\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to abandon changes\");\r\n }\r\n\r\n /** Import a schema.\r\n *\r\n * If the import was successful, the database is automatically saved to disk.\r\n * @param pathName Path to ECSchema XML file to import.\r\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\r\n */\r\n public importSchema(pathName: string): void {\r\n const status: DbResult = this.nativeDb.importSchema(pathName);\r\n if (status !== DbResult.BE_SQLITE_OK) {\r\n Logger.logError(loggerCategory, `Failed to import schema from '${pathName}'.`);\r\n throw new IModelError(status, `Failed to import schema from '${pathName}'.`);\r\n }\r\n }\r\n\r\n /**\r\n * Use a prepared ECSQL statement, potentially from the statement cache. If the requested statement doesn't exist\r\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\r\n * in the statement cache so it can be reused in the future. Use this method for ECSQL statements that will be\r\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\r\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withStatement]]\r\n * @public\r\n */\r\n public withPreparedStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors = true): T {\r\n const stmt = this._statementCache.findAndRemove(ecsql) ?? this.prepareStatement(ecsql, logErrors);\r\n const release = () => this._statementCache.addOrDispose(stmt);\r\n try {\r\n const val = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Prepared and execute a callback on an ECSQL statement. After the callback completes the statement is disposed.\r\n * Use this method for ECSQL statements are either not expected to be reused, or are not expensive to prepare.\r\n * For statements that will be reused often, instead use [[withPreparedStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withPreparedStatement]]\r\n * @public\r\n */\r\n public withStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors = true): T {\r\n const stmt = this.prepareStatement(ecsql, logErrors);\r\n const release = () => stmt.dispose();\r\n try {\r\n const val = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /** Prepare an ECSQL statement.\r\n * @param ecsql The ECSQL statement to prepare\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @throws [IModelError]($common) if there is a problem preparing the statement.\r\n */\r\n public prepareStatement(ecsql: string, logErrors = true): ECSqlStatement {\r\n const stmt = new ECSqlStatement();\r\n stmt.prepare(this.nativeDb, ecsql, logErrors);\r\n return stmt;\r\n }\r\n\r\n /**\r\n * Use a prepared SQL statement, potentially from the statement cache. If the requested statement doesn't exist\r\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\r\n * in the statement cache so it can be reused in the future. Use this method for SQL statements that will be\r\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\r\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withSqliteStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withPreparedStatement]]\r\n * @public\r\n */\r\n public withPreparedSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors = true): T {\r\n const stmt = this._sqliteStatementCache.findAndRemove(sql) ?? this.prepareSqliteStatement(sql, logErrors);\r\n const release = () => this._sqliteStatementCache.addOrDispose(stmt);\r\n try {\r\n const val: T = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Prepared and execute a callback on a SQL statement. After the callback completes the statement is disposed.\r\n * Use this method for SQL statements are either not expected to be reused, or are not expensive to prepare.\r\n * For statements that will be reused often, instead use [[withPreparedSqliteStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @public\r\n */\r\n public withSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors = true): T {\r\n const stmt = this.prepareSqliteStatement(sql, logErrors);\r\n const release = () => stmt.dispose();\r\n try {\r\n const val: T = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /** Prepare an SQL statement.\r\n * @param sql The SQLite SQL statement to prepare\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @throws [IModelError]($common) if there is a problem preparing the statement.\r\n * @internal\r\n */\r\n public prepareSqliteStatement(sql: string, logErrors = true): SqliteStatement {\r\n const stmt = new SqliteStatement(sql);\r\n stmt.prepare(this.nativeDb, logErrors);\r\n return stmt;\r\n }\r\n\r\n /** @internal */\r\n public get nativeDb(): IModelJsNative.ECDb {\r\n return this._nativeDb!;\r\n }\r\n\r\n /** Allow to execute query and read results along with meta data. The result are streamed.\r\n * @param params The values to bind to the parameters (if the ECSQL has any).\r\n * @param config Allow to specify certain flags which control how query is executed.\r\n * @returns Returns *ECSqlQueryReader* which help iterate over result set and also give access to meta data.\r\n * @beta\r\n * */\r\n public createQueryReader(ecsql: string, params?: QueryBinder, config?: QueryOptions): ECSqlReader {\r\n if (!this._nativeDb || !this._nativeDb.isOpen()) {\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"db not open\");\r\n }\r\n const executor = {\r\n execute: async (request: DbQueryRequest) => {\r\n return ConcurrentQuery.executeQueryRequest(this._nativeDb!, request);\r\n },\r\n };\r\n return new ECSqlReader(executor, ecsql, params, config);\r\n }\r\n\r\n /** Execute a query and stream its results\r\n * The result of the query is async iterator over the rows. The iterator will get next page automatically once rows in current page has been read.\r\n * [ECSQL row]($docs/learning/ECSQLRowFormat).\r\n *\r\n * See also:\r\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\r\n * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)\r\n *\r\n * @param ecsql The ECSQL statement to execute\r\n * @param params The values to bind to the parameters (if the ECSQL has any).\r\n * @param rowFormat Specify what format the row will be returned. It default to Array format though to make it compilable with previous version use *QueryRowFormat.UseJsPropertyNames*\r\n * @param options Allow to specify certain flags which control how query is executed.\r\n * @returns Returns the query result as an *AsyncIterableIterator<any>* which lazy load result as needed. The row format is determined by *rowFormat* parameter.\r\n * See [ECSQL row format]($docs/learning/ECSQLRowFormat) for details about the format of the returned rows.\r\n * @throws [IModelError]($common) If there was any error while submitting, preparing or stepping into query\r\n */\r\n public async * query(ecsql: string, params?: QueryBinder, rowFormat = QueryRowFormat.UseArrayIndexes, options?: QueryOptions): AsyncIterableIterator<any> {\r\n const builder = new QueryOptionsBuilder(options);\r\n if (rowFormat === QueryRowFormat.UseJsPropertyNames) {\r\n builder.setConvertClassIdsToNames(true);\r\n }\r\n const reader = this.createQueryReader(ecsql, params, builder.getOptions());\r\n while (await reader.step())\r\n yield reader.formatCurrentRow(rowFormat);\r\n }\r\n /** Compute number of rows that would be returned by the ECSQL.\r\n *\r\n * See also:\r\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\r\n * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)\r\n *\r\n * @param ecsql The ECSQL statement to execute\r\n * @param params The values to bind to the parameters (if the ECSQL has any).\r\n * See \"[iModel.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)\" for details.\r\n * @returns Return row count.\r\n * @throws [IModelError]($common) If the statement is invalid\r\n */\r\n public async queryRowCount(ecsql: string, params?: QueryBinder): Promise<number> {\r\n for await (const row of this.query(`select count(*) from (${ecsql})`, params)) {\r\n return row[0] as number;\r\n }\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Failed to get row count\");\r\n }\r\n\r\n /** Cancel any previous query with same token and run execute the current specified query.\r\n * The result of the query is async iterator over the rows. The iterator will get next page automatically once rows in current page has been read.\r\n * [ECSQL row]($docs/learning/ECSQLRowFormat).\r\n *\r\n * See also:\r\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\r\n * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)\r\n *\r\n * @param ecsql The ECSQL statement to execute\r\n * @param token None empty restart token. The previous query with same token would be cancelled. This would cause\r\n * exception which user code must handle.\r\n * @param params The values to bind to the parameters (if the ECSQL has any).\r\n * @param rowFormat Specify what format the row will be returned. It default to Array format though to make it compilable with previous version use *QueryRowFormat.UseJsPropertyNames*\r\n * @param options Allow to specify certain flags which control how query is executed.\r\n * @returns Returns the query result as an *AsyncIterableIterator<any>* which lazy load result as needed. The row format is determined by *rowFormat* parameter.\r\n * See [ECSQL row format]($docs/learning/ECSQLRowFormat) for details about the format of the returned rows.\r\n * @throws [IModelError]($common) If there was any error while submitting, preparing or stepping into query\r\n */\r\n public async * restartQuery(token: string, ecsql: string, params?: QueryBinder, rowFormat = QueryRowFormat.UseArrayIndexes, options?: QueryOptions): AsyncIterableIterator<any> {\r\n for await (const row of this.query(ecsql, params, rowFormat, new QueryOptionsBuilder(options).setRestartToken(token).getOptions())) {\r\n yield row;\r\n }\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ECSchemaXmlContext.js","sourceRoot":"","sources":["../../src/ECSchemaXmlContext.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAAiD;AAEjD,6CAA0C;AAQ1C,gBAAgB;AAChB,MAAa,kBAAkB;IAG7B;QACE,IAAI,CAAC,cAAc,GAAG,IAAI,uBAAU,CAAC,QAAQ,CAAC,kBAAkB,EAAE,CAAC;IACrE,CAAC;IAEM,aAAa,CAAC,UAAkB;QACrC,IAAI,CAAC,cAAe,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IACjD,CAAC;IAEM,gBAAgB,CAAC,OAAgE;QACtF,IAAI,CAAC,cAAe,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;IAEM,qBAAqB,CAAC,OAAgE;QAC3F,IAAI,CAAC,cAAe,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC;IACtD,CAAC;IAEM,qBAAqB,CAAC,QAAgB;QAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAe,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;QACtE,IAAI,QAAQ,CAAC,KAAK,EAAE;YAClB,MAAM,IAAI,yBAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;SACtE;QAED,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAO,CAAC,CAAC;IACtC,CAAC;CACF;AA3BD,gDA2BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Schema\n */\n\nimport { IModelError } from \"@itwin/core-common\";\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\nimport { IModelHost } from \"./IModelHost\";\n\n/** @internal */\nexport type SchemaKey = IModelJsNative.ECSchemaXmlContext.SchemaKey;\n\n/** @internal */\nexport type SchemaMatchType = IModelJsNative.ECSchemaXmlContext.SchemaMatchType;\n\n/** @internal */\nexport class ECSchemaXmlContext {\n private _nativeContext: IModelJsNative.ECSchemaXmlContext | undefined;\n\n constructor() {\n this._nativeContext = new IModelHost.platform.ECSchemaXmlContext();\n }\n\n public addSchemaPath(searchPath: string): void {\n this._nativeContext!.addSchemaPath(searchPath);\n }\n\n public setSchemaLocater(locater: IModelJsNative.ECSchemaXmlContext.SchemaLocaterCallback): void {\n this._nativeContext!.setSchemaLocater(locater);\n }\n\n public setFirstSchemaLocater(locater: IModelJsNative.ECSchemaXmlContext.SchemaLocaterCallback): void {\n this._nativeContext!.setFirstSchemaLocater(locater);\n }\n\n public readSchemaFromXmlFile(filePath: string): any {\n const response = this._nativeContext!.readSchemaFromXmlFile(filePath);\n if (response.error) {\n throw new IModelError(response.error.status, response.error.message);\n }\n\n return JSON.parse(response.result!);\n }\n}\n"]}
1
+ {"version":3,"file":"ECSchemaXmlContext.js","sourceRoot":"","sources":["../../src/ECSchemaXmlContext.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAAiD;AAEjD,6CAA0C;AAQ1C,gBAAgB;AAChB,MAAa,kBAAkB;IAG7B;QACE,IAAI,CAAC,cAAc,GAAG,IAAI,uBAAU,CAAC,QAAQ,CAAC,kBAAkB,EAAE,CAAC;IACrE,CAAC;IAEM,aAAa,CAAC,UAAkB;QACrC,IAAI,CAAC,cAAe,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IACjD,CAAC;IAEM,gBAAgB,CAAC,OAAgE;QACtF,IAAI,CAAC,cAAe,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;IAEM,qBAAqB,CAAC,OAAgE;QAC3F,IAAI,CAAC,cAAe,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC;IACtD,CAAC;IAEM,qBAAqB,CAAC,QAAgB;QAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAe,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;QACtE,IAAI,QAAQ,CAAC,KAAK,EAAE;YAClB,MAAM,IAAI,yBAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;SACtE;QAED,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAO,CAAC,CAAC;IACtC,CAAC;CACF;AA3BD,gDA2BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Schema\r\n */\r\n\r\nimport { IModelError } from \"@itwin/core-common\";\r\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\nimport { IModelHost } from \"./IModelHost\";\r\n\r\n/** @internal */\r\nexport type SchemaKey = IModelJsNative.ECSchemaXmlContext.SchemaKey;\r\n\r\n/** @internal */\r\nexport type SchemaMatchType = IModelJsNative.ECSchemaXmlContext.SchemaMatchType;\r\n\r\n/** @internal */\r\nexport class ECSchemaXmlContext {\r\n private _nativeContext: IModelJsNative.ECSchemaXmlContext | undefined;\r\n\r\n constructor() {\r\n this._nativeContext = new IModelHost.platform.ECSchemaXmlContext();\r\n }\r\n\r\n public addSchemaPath(searchPath: string): void {\r\n this._nativeContext!.addSchemaPath(searchPath);\r\n }\r\n\r\n public setSchemaLocater(locater: IModelJsNative.ECSchemaXmlContext.SchemaLocaterCallback): void {\r\n this._nativeContext!.setSchemaLocater(locater);\r\n }\r\n\r\n public setFirstSchemaLocater(locater: IModelJsNative.ECSchemaXmlContext.SchemaLocaterCallback): void {\r\n this._nativeContext!.setFirstSchemaLocater(locater);\r\n }\r\n\r\n public readSchemaFromXmlFile(filePath: string): any {\r\n const response = this._nativeContext!.readSchemaFromXmlFile(filePath);\r\n if (response.error) {\r\n throw new IModelError(response.error.status, response.error.message);\r\n }\r\n\r\n return JSON.parse(response.result!);\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ECSqlStatement.js","sourceRoot":"","sources":["../../src/ECSqlStatement.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA2G;AAC3G,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,KAA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GAAQ,IAAuB,OAAO,GAAG,YAAY,UAAU,CAAC,CAAC,CAAC;IAEhF,MAAM,CAAC,OAAO,CAAC,GAAQ,IAAkB,OAAO,mBAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACnE,MAAM,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":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ECSQL\n */\n\nimport { DbResult, GuidString, Id64String, IDisposable, StatusCodeWithMessage } from \"@itwin/core-bentley\";\nimport { LowAndHighXYZ, Range3d, XAndY, XYAndZ, XYZ } from \"@itwin/core-geometry\";\nimport { ECJsNames, ECSqlValueType, IModelError, NavigationBindingValue, NavigationValue } from \"@itwin/core-common\";\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\nimport { ECDb } from \"./ECDb\";\nimport { IModelHost } from \"./IModelHost\";\n\n/** The result of an **ECSQL INSERT** statement as returned from [ECSqlStatement.stepForInsert]($backend).\n *\n * If the step was successful, the ECSqlInsertResult contains\n * [DbResult.BE_SQLITE_DONE]($core-bentley)\n * and the ECInstanceId of the newly created instance.\n * In case of failure it contains the [DbResult]($core-bentley) error code.\n *\n * > Insert statements can be used with ECDb only, not with IModelDb.\n * @public\n */\nexport class ECSqlInsertResult {\n public constructor(public status: DbResult, public id?: Id64String) { }\n}\n\n/** Executes ECSQL statements.\n *\n * A statement must be prepared before it can be executed, and it must be released when no longer needed.\n * See [IModelDb.withPreparedStatement]($backend) or\n * [ECDb.withPreparedStatement]($backend) for a convenient and\n * reliable way to prepare, execute, and then release a statement.\n *\n * A statement may contain parameters that must be filled in before use by the **bind** methods.\n *\n * Once prepared (and parameters are bound, if any), the statement is executed by calling [ECSqlStatement.step]($backend).\n * In case of an **ECSQL SELECT** statement, the current row can be retrieved with [ECSqlStatement.getRow]($backend) as\n * a whole, or with [ECSqlStatement.getValue]($backend) when individual values are needed.\n * Alternatively, query results of an **ECSQL SELECT** statement can be stepped through by using\n * standard iteration syntax, such as `for of`.\n *\n * > Preparing a statement can be time-consuming. The best way to reduce the effect of this overhead is to cache and reuse prepared\n * > statements. A cached prepared statement may be used in different places in an app, as long as the statement is general enough.\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.\n *\n * See also\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.\n * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples) illustrate the use of the iModel.js API for executing and working with ECSQL\n * @public\n */\nexport class ECSqlStatement implements IterableIterator<any>, IDisposable {\n private _stmt: IModelJsNative.ECSqlStatement | undefined;\n private _sql: string | undefined;\n\n public get sql() { return this._sql!; }\n /** Check if this statement has been prepared successfully or not */\n public get isPrepared(): boolean { return !!this._stmt; }\n\n /** Prepare this statement prior to first use.\n * @param db The DgnDb or ECDb to prepare the statement against\n * @param ecsql The ECSQL statement string to prepare\n * @param logErrors Determine if errors are logged or not\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.\n * The error.message property will provide details.\n * @internal\n */\n public prepare(db: IModelJsNative.DgnDb | IModelJsNative.ECDb, ecsql: string, logErrors = true): void {\n const stat = this.tryPrepare(db, ecsql, logErrors);\n if (stat.status !== DbResult.BE_SQLITE_OK) {\n throw new IModelError(stat.status, stat.message);\n }\n }\n\n /** Prepare this statement prior to first use.\n * @param db The DgnDb or ECDb to prepare the statement against\n * @param ecsql The ECSQL statement string to prepare\n * @param logErrors Determine if errors are logged or not, its set to false by default for tryPrepare()\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.\n * @internal\n */\n public tryPrepare(db: IModelJsNative.DgnDb | IModelJsNative.ECDb, ecsql: string, logErrors = false): StatusCodeWithMessage<DbResult> {\n if (this.isPrepared)\n throw new Error(\"ECSqlStatement is already prepared\");\n this._sql = ecsql;\n this._stmt = new IModelHost.platform.ECSqlStatement();\n return this._stmt.prepare(db, ecsql, logErrors);\n }\n\n /** Reset this statement so that the next call to step will return the first row, if any. */\n public reset(): void {\n this._stmt!.reset();\n }\n\n /** Get the Native SQL statement\n * @internal\n */\n public getNativeSql(): string {\n return this._stmt!.getNativeSql();\n }\n\n /** Call this function when finished with this statement. This releases the native resources held by the statement.\n *\n * > Do not call this method directly on a statement that is being managed by a statement cache.\n */\n public dispose(): void {\n if (this._stmt) {\n this._stmt.dispose(); // free native statement\n this._stmt = undefined;\n }\n }\n\n /** Binds the specified value to the specified ECSQL parameter.\n * The section \"[iModel.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)\" describes the\n * iModel.js types to be used for the different ECSQL parameter types.\n * @param parameter Index (1-based) or name of the parameter\n */\n public bindValue(parameter: number | string, val: any): void { this.getBinder(parameter).bind(val); }\n\n /** Binds null to the specified ECSQL parameter.\n * @param parameter Index (1-based) or name of the parameter\n */\n public bindNull(parameter: number | string): void { this.getBinder(parameter).bindNull(); }\n\n /** Binds a BLOB value to the specified ECSQL parameter.\n * @param parameter Index (1-based) or name of the parameter\n * @param BLOB value as either a Uint8Array, ArrayBuffer or a Base64 string\n */\n public bindBlob(parameter: number | string, blob: string | Uint8Array | ArrayBuffer | SharedArrayBuffer): void { this.getBinder(parameter).bindBlob(blob); }\n\n /** Binds a boolean value to the specified ECSQL parameter.\n * @param parameter Index (1-based) or name of the parameter\n * @param val Boolean value\n */\n public bindBoolean(parameter: number | string, val: boolean): void { this.getBinder(parameter).bindBoolean(val); }\n\n /** Binds a DateTime value to the specified ECSQL parameter.\n * @param parameter Index (1-based) or name of the parameter\n * @param isoDateTimeString DateTime value as ISO8601 string\n */\n public bindDateTime(parameter: number | string, isoDateTimeString: string): void { this.getBinder(parameter).bindDateTime(isoDateTimeString); }\n\n /** Binds a double value to the specified ECSQL parameter.\n * @param parameter Index (1-based) or name of the parameter\n * @param val Double value\n */\n public bindDouble(parameter: number | string, val: number): void { this.getBinder(parameter).bindDouble(val); }\n\n /** Binds an GUID value to the specified ECSQL parameter.\n * @param parameter Index (1-based) or name of the parameter\n * @param val GUID value\n */\n public bindGuid(parameter: number | string, val: GuidString): void { this.getBinder(parameter).bindGuid(val); }\n\n /** Binds an Id value to the specified ECSQL parameter.\n * @param parameter Index (1-based) or name of the parameter\n * @param val Id value\n */\n public bindId(parameter: number | string, val: Id64String): void { this.getBinder(parameter).bindId(val); }\n\n /** Binds an integer value to the specified ECSQL parameter.\n * @param parameter Index (1-based) or name of the parameter\n * @param val Integer value as number, decimal string or hexadecimal string.\n */\n public bindInteger(parameter: number | string, val: number | string): void { this.getBinder(parameter).bindInteger(val); }\n\n /** Binds an Point2d value to the specified ECSQL parameter.\n * @param parameter Index (1-based) or name of the parameter\n * @param val Point2d value\n */\n public bindPoint2d(parameter: number | string, val: XAndY): void { this.getBinder(parameter).bindPoint2d(val); }\n\n /** Binds an Point3d value to the specified ECSQL parameter.\n * @param parameter Index (1-based) or name of the parameter\n * @param val Point3d value\n */\n public bindPoint3d(parameter: number | string, val: XYAndZ): void { this.getBinder(parameter).bindPoint3d(val); }\n\n /** Binds a Range3d as a blob to the specified ECSQL parameter\n * @param parameter Index(1-based) or name of the parameter\n * @param val Range3d value\n */\n public bindRange3d(parameter: number | string, val: LowAndHighXYZ): void { this.getBinder(parameter).bindRange3d(val); }\n\n /** Binds an string to the specified ECSQL parameter.\n * @param parameter Index (1-based) or name of the parameter\n * @param val String value\n */\n public bindString(parameter: number | string, val: string): void { this.getBinder(parameter).bindString(val); }\n\n /** Binds a navigation property value to the specified ECSQL parameter.\n * @param parameter Index (1-based) or name of the parameter\n * @param val Navigation property value\n */\n public bindNavigation(parameter: number | string, val: NavigationBindingValue): void { this.getBinder(parameter).bindNavigation(val); }\n\n /** Binds a struct property value to the specified ECSQL parameter.\n * @param parameter Index (1-based) or name of the parameter\n * @param val Struct value. The struct value is an object composed of pairs of a struct member property name and its value\n * (of one of the supported types)\n */\n public bindStruct(parameter: number | string, val: object): void { this.getBinder(parameter).bindStruct(val); }\n\n /** Binds an array value to the specified ECSQL parameter.\n * @param parameter Index (1-based) or name of the parameter\n * @param val Array value. The array value is an array of values of the supported types\n */\n public bindArray(parameter: number | string, val: any[]): void { this.getBinder(parameter).bindArray(val); }\n\n public bindIdSet(parameter: number | string, val: Id64String[]): void { this.getBinder(parameter).bindIdSet(val); }\n /**\n * Gets a binder to bind a value for an ECSQL parameter\n * > This is the most low-level API to bind a value to a specific parameter. Alternatively you can use the ECSqlStatement.bindXX methods\n * > or [ECSqlStatement.bindValues]($backend).\n * @param parameter Index (1-based) or name of the parameter\n */\n public getBinder(parameter: string | number): ECSqlBinder { return new ECSqlBinder(this._stmt!.getBinder(parameter)); }\n\n /** Bind values to all parameters in the statement.\n * @param values The values to bind to the parameters.\n * Pass an *array* of values if the parameters are *positional*.\n * Pass an *object of the values keyed on the parameter name* for *named parameters*.\n * The values in either the array or object must match the respective types of the parameter.\n *\n * The section \"[iModel.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)\" describes the\n * iModel.js types to be used for the different ECSQL parameter types.\n *\n * See also these [Code Samples]($docs/learning/backend/ECSQLCodeExamples#binding-to-all-parameters-at-once)\n */\n public bindValues(values: any[] | object): void {\n if (Array.isArray(values)) {\n for (let i = 0; i < values.length; i++) {\n const paramIndex: number = i + 1;\n const paramValue: any = values[i];\n if (paramValue === undefined || paramValue === null)\n continue;\n\n this.bindValue(paramIndex, paramValue);\n }\n return;\n }\n\n for (const entry of Object.entries(values)) {\n const paramName: string = entry[0];\n const paramValue: any = entry[1];\n if (paramValue === undefined || paramValue === null)\n continue;\n\n this.bindValue(paramName, paramValue);\n }\n }\n\n /** Clear any bindings that were previously set on this statement.\n * @throws [IModelError]($common) in case of errors\n */\n public clearBindings(): void {\n if (this._stmt) {\n const stat: DbResult = this._stmt.clearBindings();\n if (stat !== DbResult.BE_SQLITE_OK)\n throw new IModelError(stat, \"Error clearing bindings\");\n }\n }\n\n /** Step this statement to the next row.\n *\n * For **ECSQL SELECT** statements the method returns\n * - [DbResult.BE_SQLITE_ROW]($core-bentley) if the statement now points successfully to the next row.\n * - [DbResult.BE_SQLITE_DONE]($core-bentley) if the statement has no more rows.\n * - Error status in case of errors.\n *\n * For **ECSQL INSERT, UPDATE, DELETE** statements the method returns\n * - [DbResult.BE_SQLITE_DONE]($core-bentley) if the statement has been executed successfully.\n * - Error status in case of errors.\n *\n * > Insert statements can be used with ECDb only, not with IModelDb.\n *\n * See also: [Code Samples]($docs/learning/backend/ECSQLCodeExamples)\n */\n public step(): DbResult { return this._stmt!.step(); }\n\n /** @internal added this back in for testing purposes */\n public async stepAsync(): Promise<DbResult> {\n return new Promise((resolve, _reject) => {\n this._stmt!.stepAsync(resolve);\n });\n }\n\n /** Step this INSERT statement and returns status and the ECInstanceId of the newly\n * created instance.\n *\n * > Insert statements can be used with ECDb only, not with IModelDb.\n *\n * @returns Returns the generated ECInstanceId in case of success and the status of the step\n * call. In case of error, the respective error code is returned.\n */\n public stepForInsert(): ECSqlInsertResult {\n const r: { status: DbResult, id: string } = this._stmt!.stepForInsert();\n if (r.status === DbResult.BE_SQLITE_DONE)\n return new ECSqlInsertResult(r.status, r.id);\n\n return new ECSqlInsertResult(r.status);\n }\n\n /** Get the query result's column count (only for ECSQL SELECT statements). */\n public getColumnCount(): number { return this._stmt!.getColumnCount(); }\n\n /** Get the current row.\n * The returned row is formatted as JavaScript object where every SELECT clause item becomes a property in the JavaScript object.\n *\n * See also:\n * - [ECSQL row format]($docs/learning/ECSQLRowFormat) for details about the format of the returned row.\n * - [Code Samples]($docs/learning/backend/ECSQLCodeExamples#working-with-the-query-result)\n */\n public getRow(): any {\n const colCount: number = this.getColumnCount();\n const row: object = {};\n const duplicatePropNames = new Map<string, number>();\n for (let i = 0; i < colCount; i++) {\n const ecsqlValue = this.getValue(i);\n if (!ecsqlValue.isNull) {\n const propName: string = ECSqlStatement.determineResultRowPropertyName(duplicatePropNames, ecsqlValue);\n const val: any = ecsqlValue.value;\n Object.defineProperty(row, propName, { enumerable: true, configurable: true, writable: true, value: val });\n }\n }\n return row;\n }\n\n private static determineResultRowPropertyName(duplicatePropNames: Map<string, number>, ecsqlValue: ECSqlValue): string {\n const colInfo: ECSqlColumnInfo = ecsqlValue.columnInfo;\n let jsName: string = ECJsNames.toJsName(colInfo.getAccessString(), colInfo.isSystemProperty());\n\n // now check duplicates. If there are, append a numeric suffix to the duplicates\n let suffix: number | undefined = duplicatePropNames.get(jsName);\n if (suffix === undefined)\n duplicatePropNames.set(jsName, 0);\n else {\n suffix++;\n duplicatePropNames.set(jsName, suffix);\n jsName += `_${suffix}`;\n }\n\n return jsName;\n }\n\n /** Calls step when called as an iterator.\n *\n * Each iteration returns an [ECSQL row format]($docs/learning/ECSQLRowFormat) as returned\n * from [ECSqlStatement.getRow]($backend).\n */\n public next(): IteratorResult<any> {\n if (DbResult.BE_SQLITE_ROW === this.step()) {\n return {\n done: false,\n value: this.getRow(),\n };\n } else {\n return {\n done: true,\n value: undefined,\n };\n }\n }\n\n /** The iterator that will step through the results of this statement. */\n public [Symbol.iterator](): IterableIterator<any> { return this; }\n\n /** Get the value for the column at the given index in the query result.\n * @param columnIx Index of ECSQL column in query result (0-based)\n *\n * See also: [Code Samples]($docs/learning/backend/ECSQLCodeExamples#working-with-the-query-result)\n */\n public getValue(columnIx: number): ECSqlValue { return new ECSqlValue(this._stmt!.getValue(columnIx)); }\n}\n\n/** Binds a value to an ECSQL parameter.\n *\n * See also:\n *\n * - [ECSqlStatement]($backend)\n * - [ECSqlStatement.getBinder]($backend)\n * - [Executing ECSQL]($docs/learning/backend/ExecutingECSQL)\n * @public\n */\nexport class ECSqlBinder {\n private _binder: IModelJsNative.ECSqlBinder;\n\n /** @internal */\n public constructor(binder: IModelJsNative.ECSqlBinder) { this._binder = binder; }\n\n /** Binds the specified value to the ECSQL parameter.\n * The section \"[iModel.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)\" describes the\n * iModel.js types to be used for the different ECSQL parameter types.\n * @param val Value to bind\n */\n public bind(val: any): void {\n ECSqlBindingHelper.bindValue(this, val);\n }\n\n /** Binds null to the ECSQL parameter. */\n public bindNull(): void {\n const stat: DbResult = this._binder.bindNull();\n if (stat !== DbResult.BE_SQLITE_OK)\n throw new IModelError(stat, \"Error binding null\");\n }\n\n /** Binds a BLOB value to the ECSQL parameter.\n * @param BLOB value as either a UInt8Array, ArrayBuffer or a Base64 string\n */\n public bindBlob(blob: string | Uint8Array | ArrayBuffer | SharedArrayBuffer): void {\n const stat: DbResult = this._binder.bindBlob(blob);\n if (stat !== DbResult.BE_SQLITE_OK)\n throw new IModelError(stat, \"Error binding blob\");\n }\n\n /** Binds a boolean value to the ECSQL parameter.\n * @param val Boolean value\n */\n public bindBoolean(val: boolean): void {\n const stat: DbResult = this._binder.bindBoolean(val);\n if (stat !== DbResult.BE_SQLITE_OK)\n throw new IModelError(stat, \"Error binding boolean\");\n }\n\n /** Binds a DateTime value to the ECSQL parameter.\n * @param isoDateTimeString DateTime value as ISO8601 string\n */\n public bindDateTime(isoDateTimeString: string): void {\n const stat: DbResult = this._binder.bindDateTime(isoDateTimeString);\n if (stat !== DbResult.BE_SQLITE_OK)\n throw new IModelError(stat, \"Error binding DateTime\");\n }\n\n /** Binds a double value to the ECSQL parameter.\n * @param val Double value\n */\n public bindDouble(val: number): void {\n const stat: DbResult = this._binder.bindDouble(val);\n if (stat !== DbResult.BE_SQLITE_OK)\n throw new IModelError(stat, \"Error binding double\");\n }\n\n /** Binds an GUID value to the ECSQL parameter.\n * @param val GUID value. If passed as string, it must be formatted as described in [GuidString]($core-bentley).\n */\n public bindGuid(val: GuidString): void {\n const stat: DbResult = this._binder.bindGuid(val);\n if (stat !== DbResult.BE_SQLITE_OK)\n throw new IModelError(stat, \"Error binding GUID\");\n }\n\n /** Binds an Id value to the ECSQL parameter.\n * @param val Id value. If passed as string it must be the hexadecimal representation of the Id.\n */\n public bindId(val: Id64String): void {\n const stat: DbResult = this._binder.bindId(val);\n if (stat !== DbResult.BE_SQLITE_OK)\n throw new IModelError(stat, \"Error binding Id\");\n }\n\n /** Binds an integer value to the ECSQL parameter.\n * @param val Integer value as number, decimal string or hexadecimal string.\n */\n public bindInteger(val: number | string): void {\n const stat: DbResult = this._binder.bindInteger(val);\n if (stat !== DbResult.BE_SQLITE_OK)\n throw new IModelError(stat, \"Error binding integer\");\n }\n\n /** Binds an Point2d value to the ECSQL parameter.\n * @param val Point2d value\n */\n public bindPoint2d(val: XAndY): void {\n const stat: DbResult = this._binder.bindPoint2d(val.x, val.y);\n if (stat !== DbResult.BE_SQLITE_OK)\n throw new IModelError(stat, \"Error binding Point2d\");\n }\n\n /** Binds an Point3d value to the ECSQL parameter.\n * @param val Point3d value\n */\n public bindPoint3d(val: XYAndZ): void {\n const stat: DbResult = this._binder.bindPoint3d(val.x, val.y, val.z);\n if (stat !== DbResult.BE_SQLITE_OK)\n throw new IModelError(stat, \"Error binding Point3d\");\n }\n\n /** Binds a Range3d as a blob to the ECSQL parameter.\n * @param val Range3d value\n */\n public bindRange3d(val: LowAndHighXYZ): void {\n const stat: DbResult = this._binder.bindBlob(Range3d.toFloat64Array(val).buffer);\n if (stat !== DbResult.BE_SQLITE_OK)\n throw new IModelError(stat, \"Error binding Range3d\");\n }\n\n /** Binds an string to the ECSQL parameter.\n * @param val String value\n */\n public bindString(val: string): void {\n const stat: DbResult = this._binder.bindString(val);\n if (stat !== DbResult.BE_SQLITE_OK)\n throw new IModelError(stat, \"Error binding string\");\n }\n\n /** Binds a navigation property value to the ECSQL parameter.\n * @param val Navigation property value\n */\n public bindNavigation(val: NavigationBindingValue): void {\n const stat: DbResult = this._binder.bindNavigation(val.id, val.relClassName, val.relClassTableSpace);\n if (stat !== DbResult.BE_SQLITE_OK)\n throw new IModelError(stat, \"Error binding navigation property\");\n }\n\n /** Binds a struct property value to the ECSQL parameter.\n * @param val Struct value. The struct value is an object composed of pairs of a struct member property name and its value\n * (of one of the supported types)\n */\n public bindStruct(val: object): void { ECSqlBindingHelper.bindStruct(this, val); }\n\n /** Gets the binder for the specified member of a struct parameter\n *\n * > This is the most low-level way to bind struct parameters with most flexibility. A simpler alternative is\n * > to just call [ECSqlBinder.bindStruct]($backend).\n */\n public bindMember(memberName: string): ECSqlBinder { return new ECSqlBinder(this._binder.bindMember(memberName)); }\n\n /** Binds a set of Id strings to the ECSQL parameter.\n * @param val array of Id values. If passed as string they must be the hexadecimal representation of the Ids.\n */\n public bindIdSet(vector: Id64String[]): void {\n const stat: DbResult = this._binder.bindIdSet(vector);\n if (stat !== DbResult.BE_SQLITE_OK)\n throw new IModelError(stat, \"Error binding id set\");\n }\n\n /** Binds an array value to the ECSQL parameter.\n * @param val Array value. The array value is an array of values of the supported types\n */\n public bindArray(val: any[]): void { ECSqlBindingHelper.bindArray(this, val); }\n\n /** Adds a new array element to the array parameter and returns the binder for the new array element\n *\n * > This is the most low-level way to bind array parameters with most flexibility. A simpler alternative is\n * > to just call [ECSqlBinder.bindArray]($backend).\n */\n public addArrayElement(): ECSqlBinder { return new ECSqlBinder(this._binder.addArrayElement()); }\n}\n\n/** Represents the value of an ECEnumeration.\n *\n * See also:\n * - [[ECSqlValue.getEnum]]\n * - [[ECSqlStatement]]\n * - [[ECSqlStatement.getValue]]\n * - [Code Samples]($docs/learning/backend/ECSQLCodeExamples#working-with-the-query-result)\n * @public\n */\nexport interface ECEnumValue {\n schema: string;\n name: string;\n key: string;\n value: number | string;\n}\n\n/** Value of a column in a row of an ECSQL query result.\n *\n * See also:\n * - [ECSqlStatement]($backend)\n * - [ECSqlStatement.getValue]($backend)\n * - [Code Samples]($docs/learning/backend/ECSQLCodeExamples#working-with-the-query-result)\n * @public\n */\nexport class ECSqlValue {\n private _val: IModelJsNative.ECSqlValue;\n\n /** @internal */\n public constructor(val: IModelJsNative.ECSqlValue) { this._val = val; }\n\n /** Get information about the query result's column this value refers to. */\n public get columnInfo(): ECSqlColumnInfo { return this._val.getColumnInfo() as ECSqlColumnInfo; }\n\n /** Get the value of this ECSQL value */\n public get value(): any { return ECSqlValueHelper.getValue(this); }\n\n /** Indicates whether the value is NULL or not. */\n public get isNull(): boolean { return this._val.isNull(); }\n /** Get the value as BLOB */\n public getBlob(): Uint8Array { return this._val.getBlob(); }\n /** Get the value as a boolean value */\n public getBoolean(): boolean { return this._val.getBoolean(); }\n /** Get the value as a DateTime value (formatted as ISO8601 string) */\n public getDateTime(): string { return this._val.getDateTime(); }\n /** Get the value as a double value */\n public getDouble(): number { return this._val.getDouble(); }\n /** Get the value as a IGeometry value (as ECJSON IGeometry) */\n public getGeometry(): any { return JSON.parse(this._val.getGeometry()); }\n /** Get the value as a GUID (formatted as GUID string).\n * See [GuidString]($core-bentley)\n */\n public getGuid(): GuidString { return this._val.getGuid(); }\n /** Get the value as a Id (formatted as hexadecimal string). */\n public getId(): Id64String { return this._val.getId(); }\n /** Get the ClassId value formatted as fully qualified class name. */\n public getClassNameForClassId(): string { return this._val.getClassNameForClassId(); }\n /** Get the value as a integer value */\n public getInteger(): number { return this._val.getInt64(); }\n /** Get the value as a string value */\n public getString(): string { return this._val.getString(); }\n /** Get the value as [XAndY]($core-geometry) */\n public getXAndY(): XAndY { return this._val.getPoint2d(); }\n /** Get the value as [XYAndZ]($core-geometry) */\n public getXYAndZ(): XYAndZ { return this._val.getPoint3d(); }\n /** Get the value as ECEnumeration value\n * Note: This method is optional. Using [[ECSqlValue.getInteger]] for integral enums and\n * [[ECSqlValue.getString]] for string enums respectively are the usual way to get\n * enum values. This method can be used if the context of the underlying ECEnumeration\n * is required.\n * The value is broken down into the ECEnumerators that make it up, if the value\n * is a combination of ECEnumerators. If the value is not a strict match of an ECEnumerator\n * or a combination of them, undefined is returned.\n * > Note: You can call [[ECSqlValue.columnInfo.isEnum]] to find out whether\n * > this method can be called or not.\n * @return ECEnumeration value(s) or undefined if the ECSqlValue does not represent an ECEnumeration.\n * or is not a strict match of an ECEnumerator or a combination of them.\n */\n public getEnum(): ECEnumValue[] | undefined { return this._val.getEnum(); }\n\n /** Get the value as [NavigationValue]($common) */\n public getNavigation(): NavigationValue { return this._val.getNavigation(); }\n\n /** Get an iterator for iterating the struct members of this struct value. */\n public getStructIterator(): ECSqlValueIterator { return new ECSqlValueIterator(this._val.getStructIterator()); }\n\n /** Get this struct value's content as object literal */\n public getStruct(): any { return ECSqlValueHelper.getStruct(this); }\n\n /** Get an iterator for iterating the array elements of this array value. */\n public getArrayIterator(): ECSqlValueIterator { return new ECSqlValueIterator(this._val.getArrayIterator()); }\n\n /** Get this array value as JavaScript array */\n public getArray(): any[] { return ECSqlValueHelper.getArray(this); }\n}\n\n/** Iterator over members of a struct [ECSqlValue]($backend) or the elements of an array [ECSqlValue]($backend).\n * See [ECSqlValue.getStructIterator]($backend) or [ECSqlValue.getArrayIterator]($backend).\n * @public\n */\nexport class ECSqlValueIterator implements IterableIterator<ECSqlValue> {\n private _it: IModelJsNative.ECSqlValueIterator;\n\n /** @internal */\n public constructor(it: IModelJsNative.ECSqlValueIterator) { this._it = it; }\n\n public next(): IteratorResult<ECSqlValue> {\n if (this._it.moveNext())\n return { done: false, value: new ECSqlValue(this._it.getCurrent()) };\n\n return { done: true, value: undefined };\n }\n\n public [Symbol.iterator](): IterableIterator<ECSqlValue> { return this; }\n}\n\n/** Information about an ECSQL column in an ECSQL query result.\n * See [ECSqlValue.columnInfo]($backend), [ECSqlStatement.getValue]($backend), [ECSqlStatement]($backend)\n * @public\n */\nexport interface ECSqlColumnInfo {\n /** Gets the data type of the column.\n */\n getType(): ECSqlValueType;\n\n /** Gets the name of the property backing the column.\n * > If this column is backed by a generated property, i.e. it represents ECSQL expression,\n * > the access string consists of the name of the generated property.\n */\n getPropertyName(): string;\n\n /** Gets the full access string to the corresponding ECSqlValue starting from the root class.\n * > If this column is backed by a generated property, i.e. it represents ECSQL expression,\n * > the access string consists of the ECSQL expression.\n */\n getAccessString(): string;\n\n /** Indicates whether the column refers to an ECEnumeration property. */\n isEnum(): boolean;\n\n /** Indicates whether the column refers to a system property (e.g. id, className). */\n isSystemProperty(): boolean;\n\n /** Indicates whether the column is backed by a generated property or not. For SELECT clause items that are expressions other\n * than simply a reference to an ECProperty, a property is generated containing the expression name.\n */\n isGeneratedProperty(): boolean;\n\n /** Gets the table space in which this root class is persisted.\n * > For classes in the primary file the table space is MAIN. For classes in attached\n * > files, the table space is the name by which the file was attached. For generated properties the table space is empty.\n */\n getRootClassTableSpace(): string;\n\n /** Gets the fully qualified name of the ECClass of the top-level ECProperty backing this column. */\n getRootClassName(): string;\n\n /** Gets the class alias of the root class to which the column refers to.\n * > Returns an empty string if no class alias was specified in the select clause.\n */\n getRootClassAlias(): string;\n}\n\nclass ECSqlBindingHelper {\n\n /** Binds the specified value to the specified binder\n * @param binder Parameter Binder to bind to\n * @param val Value to be bound. (See [iModel.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes))\n * @throws IModelError in case of errors\n */\n public static bindValue(binder: ECSqlBinder, val: any): void {\n // returns false if val is no primitive and returns true if it is primitive and a binding call was done\n if (ECSqlBindingHelper.tryBindPrimitiveTypes(binder, val))\n return;\n\n if (Array.isArray(val)) {\n ECSqlBindingHelper.bindArray(binder, val);\n return;\n }\n\n if (typeof (val) === \"object\") {\n ECSqlBindingHelper.bindStruct(binder, val);\n return;\n }\n\n throw new Error(`Bound value is of an unsupported type: ${val}`);\n }\n\n /** Binds the specified primitive value to the specified binder\n * @param binder Parameter Binder to bind to\n * @param val Primitive value to be bound. Must be of one of these types described here:\n * [ECSQL Binding types]($docs/learning/ECSQLParameterTypes)\n * @throws IModelError in case of errors\n */\n public static bindPrimitive(binder: ECSqlBinder, val: any): void {\n if (!ECSqlBindingHelper.tryBindPrimitiveTypes(binder, val))\n throw new IModelError(DbResult.BE_SQLITE_ERROR, `Binding value is of an unsupported primitive type: ${val}`);\n }\n\n /** Binds the specified object to the specified struct binder\n * @param binder Struct parameter binder to bind to\n * @param val Value to be bound. Must be an Object with members of the supported types\n * @throws IModelError in case of errors\n */\n public static bindStruct(binder: ECSqlBinder, val: object): void {\n if (val === null || val === undefined) {\n binder.bindNull();\n return;\n }\n\n for (const member of Object.entries(val)) {\n const memberName: string = member[0];\n const memberVal: any = member[1];\n ECSqlBindingHelper.bindValue(binder.bindMember(memberName), memberVal);\n }\n }\n\n /** Binds the specified array to the specified array binder\n * @param binder Array parameter binder to bind to\n * @param val Value to be bound. Must be an Array with elements of the supported types\n * @throws IModelError in case of errors\n */\n public static bindArray(binder: ECSqlBinder, val: any[]): void {\n if (val === null || val === undefined) {\n binder.bindNull();\n return;\n }\n\n for (const element of val) {\n ECSqlBindingHelper.bindValue(binder.addArrayElement(), element);\n }\n }\n\n /** tries to interpret the passed value as known leaf types (primitives and navigation values).\n * @returns Returns undefined if the value wasn't a primitive. DbResult if it was a primitive and was bound to the binder\n */\n private static tryBindPrimitiveTypes(binder: ECSqlBinder, val: any): boolean {\n if (val === undefined || val === null) {\n binder.bindNull();\n return true;\n }\n\n if (typeof (val) === \"number\") {\n if (Number.isInteger(val))\n binder.bindInteger(val);\n else\n binder.bindDouble(val);\n\n return true;\n }\n\n if (typeof (val) === \"boolean\") {\n binder.bindBoolean(val);\n return true;\n }\n\n if (typeof (val) === \"string\") {\n binder.bindString(val);\n return true;\n }\n\n if (ECSqlTypeHelper.isBlob(val)) {\n binder.bindBlob(val);\n return true;\n }\n\n if (ECSqlTypeHelper.isXYAndZ(val)) {\n binder.bindPoint3d(val);\n return true;\n }\n\n if (ECSqlTypeHelper.isXAndY(val)) {\n binder.bindPoint2d(val);\n return true;\n }\n\n if (ECSqlTypeHelper.isLowAndHighXYZ(val)) {\n binder.bindRange3d(val);\n return true;\n }\n\n if (ECSqlTypeHelper.isNavigationBindingValue(val)) {\n binder.bindNavigation(val);\n return true;\n }\n\n return false;\n }\n}\n\nclass ECSqlValueHelper {\n public static getValue(ecsqlValue: ECSqlValue): any {\n if (ecsqlValue.isNull)\n return undefined;\n\n const dataType: ECSqlValueType = ecsqlValue.columnInfo.getType();\n switch (dataType) {\n case ECSqlValueType.Struct:\n return ECSqlValueHelper.getStruct(ecsqlValue);\n\n case ECSqlValueType.Navigation:\n return ecsqlValue.getNavigation();\n\n case ECSqlValueType.PrimitiveArray:\n case ECSqlValueType.StructArray:\n return ECSqlValueHelper.getArray(ecsqlValue);\n\n default:\n return ECSqlValueHelper.getPrimitiveValue(ecsqlValue);\n }\n }\n\n public static getStruct(ecsqlValue: ECSqlValue): any {\n if (ecsqlValue.isNull)\n return undefined;\n\n const structVal = {};\n const it = ecsqlValue.getStructIterator();\n try {\n for (const memberECSqlVal of it) {\n if (memberECSqlVal.isNull)\n continue;\n\n const memberName: string = ECJsNames.toJsName(memberECSqlVal.columnInfo.getPropertyName());\n const memberVal = ECSqlValueHelper.getValue(memberECSqlVal);\n Object.defineProperty(structVal, memberName, { enumerable: true, configurable: true, writable: true, value: memberVal });\n }\n } finally {\n }\n\n return structVal;\n }\n\n public static getArray(ecsqlValue: ECSqlValue): any[] {\n const arrayVal: any[] = [];\n const it = ecsqlValue.getArrayIterator();\n try {\n for (const elementECSqlVal of it) {\n const memberVal = ECSqlValueHelper.getValue(elementECSqlVal);\n arrayVal.push(memberVal);\n }\n } finally {\n }\n return arrayVal;\n }\n\n private static getPrimitiveValue(ecsqlValue: ECSqlValue): any {\n if (ecsqlValue.isNull)\n return undefined;\n\n const colInfo: ECSqlColumnInfo = ecsqlValue.columnInfo;\n switch (colInfo.getType()) {\n case ECSqlValueType.Blob:\n return ecsqlValue.getBlob();\n case ECSqlValueType.Boolean:\n return ecsqlValue.getBoolean();\n case ECSqlValueType.DateTime:\n return ecsqlValue.getDateTime();\n case ECSqlValueType.Double:\n return ecsqlValue.getDouble();\n case ECSqlValueType.Geometry:\n return ecsqlValue.getGeometry();\n case ECSqlValueType.Guid:\n return ecsqlValue.getGuid();\n case ECSqlValueType.Id: {\n if (colInfo.isSystemProperty() && colInfo.getPropertyName().endsWith(\"ECClassId\"))\n return ecsqlValue.getClassNameForClassId();\n\n return ecsqlValue.getId();\n }\n case ECSqlValueType.Int:\n case ECSqlValueType.Int64:\n return ecsqlValue.getInteger();\n case ECSqlValueType.Point2d:\n return ecsqlValue.getXAndY();\n case ECSqlValueType.Point3d:\n return ecsqlValue.getXYAndZ();\n case ECSqlValueType.String:\n return ecsqlValue.getString();\n default:\n throw new IModelError(DbResult.BE_SQLITE_ERROR, `Unsupported type ${ecsqlValue.columnInfo.getType()} of the ECSQL Value`);\n }\n }\n\n public static queryClassName(ecdb: ECDb, classId: Id64String, tableSpace?: string): string {\n if (!tableSpace)\n tableSpace = \"main\";\n\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=?`,\n (stmt: ECSqlStatement) => {\n stmt.bindId(1, classId);\n if (stmt.step() !== DbResult.BE_SQLITE_ROW)\n throw new IModelError(DbResult.BE_SQLITE_ERROR, `No class found with ECClassId ${classId} in table space ${tableSpace}.`);\n\n return `${stmt.getValue(0).getString()}.${stmt.getValue(1).getString()}`;\n });\n }\n}\n\nclass ECSqlTypeHelper {\n public static isBlob(val: any): val is Uint8Array { return val instanceof Uint8Array; }\n\n public static isXAndY(val: any): val is XAndY { return XYZ.isXAndY(val); }\n public static isXYAndZ(val: any): val is XYAndZ { return XYZ.isXYAndZ(val); }\n public static isLowAndHighXYZ(arg: any): arg is LowAndHighXYZ { return arg.low !== undefined && ECSqlTypeHelper.isXYAndZ(arg.low) && arg.high !== undefined && ECSqlTypeHelper.isXYAndZ(arg.high); }\n\n public static isNavigationBindingValue(val: any): val is NavigationBindingValue { return val.id !== undefined && typeof (val.id) === \"string\"; }\n}\n"]}
1
+ {"version":3,"file":"ECSqlStatement.js","sourceRoot":"","sources":["../../src/ECSqlStatement.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA2G;AAC3G,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;IACvC,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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,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 { 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!; }\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 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 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 { return new ECSqlBinder(this._stmt!.getBinder(parameter)); }\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(); }\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);\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 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(); }\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 { return new ECSqlValue(this._stmt!.getValue(columnIx)); }\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 +1 @@
1
- {"version":3,"file":"ElementAspect.js","sourceRoot":"","sources":["../../src/ElementAspect.ts"],"names":[],"mappings":";AAAA;;;+F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AC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QACjC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACrB,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC7B,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC3B,GAAG,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;QACzC,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AAhED,oDAgEC;AAED,cAAc;AACd,WAAiB,oBAAoB;IACnC;;OAEG;IACH,IAAY,IASX;IATD,WAAY,IAAI;QACd,oFAAoF;QACpF,2BAAmB,CAAA;QACnB,yFAAyF;QACzF,qCAA6B,CAAA;QAC7B;;WAEG;QACH,uBAAe,CAAA;IACjB,CAAC,EATW,IAAI,GAAJ,yBAAI,KAAJ,yBAAI,QASf;AACH,CAAC,EAdgB,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QAcpC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ElementAspects\n */\n\nimport { ChannelRootAspectProps, ElementAspectProps, ExternalSourceAspectProps, RelatedElement } from \"@itwin/core-common\";\nimport { Entity } from \"./Entity\";\nimport { IModelDb } from \"./IModelDb\";\nimport { ECSqlStatement } from \"./ECSqlStatement\";\nimport { DbResult, Id64String } from \"@itwin/core-bentley\";\n\n/** Argument for the `ElementAspect.onXxx` static methods\n * @beta\n */\nexport interface OnAspectArg {\n /** The iModel for the aspect affected by this event. */\n iModel: IModelDb;\n}\n/** Argument for the `ElementAspect.onXxx` static methods that supply the properties of an aspect to be inserted or updated.\n * @beta\n */\nexport interface OnAspectPropsArg extends OnAspectArg {\n /** The new properties of the aspect affected by this event. */\n props: Readonly<ElementAspectProps>;\n}\n/** Argument for the `ElementAspect.onXxx` static methods that only supply the Id of the affected aspect.\n * @beta\n */\nexport interface OnAspectIdArg extends OnAspectArg {\n /** The Id of the aspect affected by this event */\n aspectId: Id64String;\n}\n\n/** An Element Aspect is a class that defines a set of properties that are related to (and owned by) a single element.\n * Semantically, an ElementAspect can be considered part of the Element. Thus, an ElementAspect is deleted if its owning Element is deleted.\n * BIS Guideline: Subclass ElementUniqueAspect or ElementMultiAspect rather than subclassing ElementAspect directly.\n * @public\n */\nexport class ElementAspect extends Entity implements ElementAspectProps {\n /** @internal */\n public static override get className(): string { return \"ElementAspect\"; }\n public element: RelatedElement;\n\n /** @internal */\n constructor(props: ElementAspectProps, iModel: IModelDb) {\n super(props, iModel);\n this.element = RelatedElement.fromJSON(props.element)!;\n }\n\n /** @internal */\n public override toJSON(): ElementAspectProps {\n const val = super.toJSON() as ElementAspectProps;\n val.element = this.element;\n return val;\n }\n\n /** Called before a new ElementAspect is inserted.\n * @note throw an exception to disallow the insert\n * @note If you override this method, you must call super.\n * @beta\n */\n protected static onInsert(_arg: OnAspectPropsArg): void { }\n\n /** Called after a new ElementAspect was inserted.\n * @note If you override this method, you must call super.\n * @beta\n */\n protected static onInserted(_arg: OnAspectPropsArg): void { }\n\n /** Called before an ElementAspect is updated.\n * @note throw an exception to disallow the update\n * @note If you override this method, you must call super.\n * @beta\n */\n protected static onUpdate(_arg: OnAspectPropsArg): void { }\n\n /** Called after an ElementAspect was updated.\n * @note If you override this method, you must call super.\n * @beta\n */\n protected static onUpdated(_arg: OnAspectPropsArg): void { }\n\n /** Called before an ElementAspect is deleted.\n * @note throw an exception to disallow the delete\n * @note If you override this method, you must call super.\n * @beta\n */\n protected static onDelete(_arg: OnAspectIdArg): void { }\n\n /** Called after an ElementAspect was deleted.\n * @note If you override this method, you must call super.\n * @beta\n */\n protected static onDeleted(_arg: OnAspectIdArg): void { }\n}\n\n/** An Element Unique Aspect is an ElementAspect where there can be only zero or one instance of the Element Aspect class per Element.\n * @public\n */\nexport class ElementUniqueAspect extends ElementAspect {\n /** @internal */\n public static override get className(): string { return \"ElementUniqueAspect\"; }\n}\n\n/** An Element Multi-Aspect is an ElementAspect where there can be **n** instances of the Element Aspect class per Element.\n * @public\n */\nexport class ElementMultiAspect extends ElementAspect {\n /** @internal */\n public static override get className(): string { return \"ElementMultiAspect\"; }\n}\n\n/** A ChannelRootAspect identifies an Element as the root of a *channel* which is a subset of the overall iModel hierarchy that is independently maintained.\n * @note The associated ECClass was added to the BisCore schema in version 1.0.10\n * @public\n */\nexport class ChannelRootAspect extends ElementUniqueAspect {\n /** @internal */\n public static override get className(): string { return \"ChannelRootAspect\"; }\n\n /** The owner of the channel */\n public owner: string;\n\n /** @internal */\n constructor(props: ChannelRootAspectProps, iModel: IModelDb) {\n super(props, iModel);\n this.owner = props.owner;\n }\n\n /** @internal */\n public override toJSON(): ChannelRootAspectProps {\n const val = super.toJSON() as ChannelRootAspectProps;\n val.owner = this.owner;\n return val;\n }\n\n /** Insert a ChannelRootAspect on the specified element. */\n public static insert(iModel: IModelDb, ownerId: Id64String, ownerDescription: string) {\n const props: ChannelRootAspectProps = {\n classFullName: ChannelRootAspect.classFullName,\n element: { id: ownerId },\n owner: ownerDescription,\n };\n iModel.elements.insertAspect(props);\n }\n}\n\n/** An ElementMultiAspect that stores synchronization information for an Element originating from an external source.\n * @note The associated ECClass was added to the BisCore schema in version 1.0.2\n * @public\n */\nexport class ExternalSourceAspect extends ElementMultiAspect implements ExternalSourceAspectProps {\n /** @internal */\n public static override get className(): string { return \"ExternalSourceAspect\"; }\n\n /** An element that scopes the combination of `kind` and `identifier` to uniquely identify the object from the external source. */\n public scope: RelatedElement;\n /** The identifier of the object in the source repository. */\n public identifier: string;\n /** The kind of object within the source repository. */\n public kind: string;\n /** The cryptographic hash (any algorithm) of the source object's content. If defined, it must be guaranteed to change when the source object's content changes. */\n public checksum?: string;\n /** An optional value that is typically a version number or a pseudo version number like last modified time.\n * It will be used by the synchronization process to detect that a source object is unchanged so that computing a cryptographic hash can be avoided.\n * If present, this value must be guaranteed to change when any of the source object's content changes.\n */\n public version?: string;\n /** A place where additional JSON properties can be stored. For example, provenance information or properties relating to the synchronization process. */\n public jsonProperties?: string;\n /** The source of the imported/synchronized object. Should point to an instance of [ExternalSource]($backend). */\n public source?: RelatedElement;\n\n /** @internal */\n constructor(props: ExternalSourceAspectProps, iModel: IModelDb) {\n super(props, iModel);\n this.scope = RelatedElement.fromJSON(props.scope)!;\n this.source = RelatedElement.fromJSON(props.source);\n this.identifier = props.identifier;\n this.kind = props.kind;\n this.checksum = props.checksum;\n this.version = props.version;\n this.jsonProperties = props.jsonProperties;\n }\n\n /** Look up the ElementId of the element that contains an aspect with the specified Scope, Kind, and Identifier\n */\n public static findBySource(iModelDb: IModelDb, scope: Id64String, kind: string, identifier: string): { elementId?: Id64String, aspectId?: Id64String } {\n const sql = `SELECT Element.Id, ECInstanceId FROM ${ExternalSourceAspect.classFullName} WHERE (Scope.Id=:scope AND Kind=:kind AND Identifier=:identifier)`;\n let elementId: Id64String | undefined;\n let aspectId: Id64String | undefined;\n iModelDb.withPreparedStatement(sql, (statement: ECSqlStatement) => {\n statement.bindId(\"scope\", scope);\n statement.bindString(\"kind\", kind);\n statement.bindString(\"identifier\", identifier);\n if (DbResult.BE_SQLITE_ROW === statement.step()) {\n elementId = statement.getValue(0).getId();\n aspectId = statement.getValue(1).getId();\n }\n });\n return { elementId, aspectId };\n }\n\n /** @internal */\n public override toJSON(): ExternalSourceAspectProps {\n const val = super.toJSON() as ExternalSourceAspectProps;\n val.scope = this.scope;\n val.source = this.source;\n val.identifier = this.identifier;\n val.kind = this.kind;\n val.checksum = this.checksum;\n val.version = this.version;\n val.jsonProperties = this.jsonProperties;\n return val;\n }\n}\n\n/** @public */\nexport namespace ExternalSourceAspect { // eslint-disable-line no-redeclare\n /** Standard values for the `Kind` property of `ExternalSourceAspect`.\n * @public\n */\n export enum Kind {\n /** Indicates that the [[ExternalSourceAspect]] is storing [[Element]] provenance */\n Element = \"Element\",\n /** Indicates that the [[ExternalSourceAspect]] is storing [[Relationship]] provenance */\n Relationship = \"Relationship\",\n /** Indicates that the [[ExternalSourceAspect]] is storing *scope* provenance\n * @see [[ExternalSourceAspect.scope]]\n */\n Scope = \"Scope\",\n }\n}\n"]}
1
+ {"version":3,"file":"ElementAspect.js","sourceRoot":"","sources":["../../src/ElementAspect.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAA2H;AAC3H,qCAAkC;AAGlC,sDAA2D;AAwB3D;;;;GAIG;AACH,MAAa,aAAc,SAAQ,eAAM;IAKvC,gBAAgB;IAChB,YAAY,KAAyB,EAAE,MAAgB;QACrD,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,4BAAc,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAE,CAAC;IACzD,CAAC;IARD,gBAAgB;IACT,MAAM,KAAc,SAAS,KAAa,OAAO,eAAe,CAAC,CAAC,CAAC;IAS1E,gBAAgB;IACA,MAAM;QACpB,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,EAAwB,CAAC;QACjD,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC3B,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;;;OAIG;IACO,MAAM,CAAC,QAAQ,CAAC,IAAsB,IAAU,CAAC;IAE3D;;;OAGG;IACO,MAAM,CAAC,UAAU,CAAC,IAAsB,IAAU,CAAC;IAE7D;;;;OAIG;IACO,MAAM,CAAC,QAAQ,CAAC,IAAsB,IAAU,CAAC;IAE3D;;;OAGG;IACO,MAAM,CAAC,SAAS,CAAC,IAAsB,IAAU,CAAC;IAE5D;;;;OAIG;IACO,MAAM,CAAC,QAAQ,CAAC,IAAmB,IAAU,CAAC;IAExD;;;OAGG;IACO,MAAM,CAAC,SAAS,CAAC,IAAmB,IAAU,CAAC;CAC1D;AAxDD,sCAwDC;AAED;;GAEG;AACH,MAAa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SAAS,EAAE,QAAQ,EAAE,CAAC;IACjC,CAAC;IAED,gBAAgB;IACA,MAAM;QACpB,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,EAA+B,CAAC;QACxD,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACvB,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QACzB,GAAG,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QACjC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACrB,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC7B,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC3B,GAAG,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;QACzC,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AAhED,oDAgEC;AAED,cAAc;AACd,WAAiB,oBAAoB;IACnC;;OAEG;IACH,IAAY,IASX;IATD,WAAY,IAAI;QACd,oFAAoF;QACpF,2BAAmB,CAAA;QACnB,yFAAyF;QACzF,qCAA6B,CAAA;QAC7B;;WAEG;QACH,uBAAe,CAAA;IACjB,CAAC,EATW,IAAI,GAAJ,yBAAI,KAAJ,yBAAI,QASf;AACH,CAAC,EAdgB,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QAcpC","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 ElementAspects\r\n */\r\n\r\nimport { ChannelRootAspectProps, ElementAspectProps, ExternalSourceAspectProps, RelatedElement } from \"@itwin/core-common\";\r\nimport { Entity } from \"./Entity\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { ECSqlStatement } from \"./ECSqlStatement\";\r\nimport { DbResult, Id64String } from \"@itwin/core-bentley\";\r\n\r\n/** Argument for the `ElementAspect.onXxx` static methods\r\n * @beta\r\n */\r\nexport interface OnAspectArg {\r\n /** The iModel for the aspect affected by this event. */\r\n iModel: IModelDb;\r\n}\r\n/** Argument for the `ElementAspect.onXxx` static methods that supply the properties of an aspect to be inserted or updated.\r\n * @beta\r\n */\r\nexport interface OnAspectPropsArg extends OnAspectArg {\r\n /** The new properties of the aspect affected by this event. */\r\n props: Readonly<ElementAspectProps>;\r\n}\r\n/** Argument for the `ElementAspect.onXxx` static methods that only supply the Id of the affected aspect.\r\n * @beta\r\n */\r\nexport interface OnAspectIdArg extends OnAspectArg {\r\n /** The Id of the aspect affected by this event */\r\n aspectId: Id64String;\r\n}\r\n\r\n/** An Element Aspect is a class that defines a set of properties that are related to (and owned by) a single element.\r\n * Semantically, an ElementAspect can be considered part of the Element. Thus, an ElementAspect is deleted if its owning Element is deleted.\r\n * BIS Guideline: Subclass ElementUniqueAspect or ElementMultiAspect rather than subclassing ElementAspect directly.\r\n * @public\r\n */\r\nexport class ElementAspect extends Entity implements ElementAspectProps {\r\n /** @internal */\r\n public static override get className(): string { return \"ElementAspect\"; }\r\n public element: RelatedElement;\r\n\r\n /** @internal */\r\n constructor(props: ElementAspectProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.element = RelatedElement.fromJSON(props.element)!;\r\n }\r\n\r\n /** @internal */\r\n public override toJSON(): ElementAspectProps {\r\n const val = super.toJSON() as ElementAspectProps;\r\n val.element = this.element;\r\n return val;\r\n }\r\n\r\n /** Called before a new ElementAspect is inserted.\r\n * @note throw an exception to disallow the insert\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onInsert(_arg: OnAspectPropsArg): void { }\r\n\r\n /** Called after a new ElementAspect was inserted.\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onInserted(_arg: OnAspectPropsArg): void { }\r\n\r\n /** Called before an ElementAspect is updated.\r\n * @note throw an exception to disallow the update\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onUpdate(_arg: OnAspectPropsArg): void { }\r\n\r\n /** Called after an ElementAspect was updated.\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onUpdated(_arg: OnAspectPropsArg): void { }\r\n\r\n /** Called before an ElementAspect is deleted.\r\n * @note throw an exception to disallow the delete\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onDelete(_arg: OnAspectIdArg): void { }\r\n\r\n /** Called after an ElementAspect was deleted.\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onDeleted(_arg: OnAspectIdArg): void { }\r\n}\r\n\r\n/** An Element Unique Aspect is an ElementAspect where there can be only zero or one instance of the Element Aspect class per Element.\r\n * @public\r\n */\r\nexport class ElementUniqueAspect extends ElementAspect {\r\n /** @internal */\r\n public static override get className(): string { return \"ElementUniqueAspect\"; }\r\n}\r\n\r\n/** An Element Multi-Aspect is an ElementAspect where there can be **n** instances of the Element Aspect class per Element.\r\n * @public\r\n */\r\nexport class ElementMultiAspect extends ElementAspect {\r\n /** @internal */\r\n public static override get className(): string { return \"ElementMultiAspect\"; }\r\n}\r\n\r\n/** A ChannelRootAspect identifies an Element as the root of a *channel* which is a subset of the overall iModel hierarchy that is independently maintained.\r\n * @note The associated ECClass was added to the BisCore schema in version 1.0.10\r\n * @public\r\n */\r\nexport class ChannelRootAspect extends ElementUniqueAspect {\r\n /** @internal */\r\n public static override get className(): string { return \"ChannelRootAspect\"; }\r\n\r\n /** The owner of the channel */\r\n public owner: string;\r\n\r\n /** @internal */\r\n constructor(props: ChannelRootAspectProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.owner = props.owner;\r\n }\r\n\r\n /** @internal */\r\n public override toJSON(): ChannelRootAspectProps {\r\n const val = super.toJSON() as ChannelRootAspectProps;\r\n val.owner = this.owner;\r\n return val;\r\n }\r\n\r\n /** Insert a ChannelRootAspect on the specified element. */\r\n public static insert(iModel: IModelDb, ownerId: Id64String, ownerDescription: string) {\r\n const props: ChannelRootAspectProps = {\r\n classFullName: ChannelRootAspect.classFullName,\r\n element: { id: ownerId },\r\n owner: ownerDescription,\r\n };\r\n iModel.elements.insertAspect(props);\r\n }\r\n}\r\n\r\n/** An ElementMultiAspect that stores synchronization information for an Element originating from an external source.\r\n * @note The associated ECClass was added to the BisCore schema in version 1.0.2\r\n * @public\r\n */\r\nexport class ExternalSourceAspect extends ElementMultiAspect implements ExternalSourceAspectProps {\r\n /** @internal */\r\n public static override get className(): string { return \"ExternalSourceAspect\"; }\r\n\r\n /** An element that scopes the combination of `kind` and `identifier` to uniquely identify the object from the external source. */\r\n public scope: RelatedElement;\r\n /** The identifier of the object in the source repository. */\r\n public identifier: string;\r\n /** The kind of object within the source repository. */\r\n public kind: string;\r\n /** The cryptographic hash (any algorithm) of the source object's content. If defined, it must be guaranteed to change when the source object's content changes. */\r\n public checksum?: string;\r\n /** An optional value that is typically a version number or a pseudo version number like last modified time.\r\n * It will be used by the synchronization process to detect that a source object is unchanged so that computing a cryptographic hash can be avoided.\r\n * If present, this value must be guaranteed to change when any of the source object's content changes.\r\n */\r\n public version?: string;\r\n /** A place where additional JSON properties can be stored. For example, provenance information or properties relating to the synchronization process. */\r\n public jsonProperties?: string;\r\n /** The source of the imported/synchronized object. Should point to an instance of [ExternalSource]($backend). */\r\n public source?: RelatedElement;\r\n\r\n /** @internal */\r\n constructor(props: ExternalSourceAspectProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.scope = RelatedElement.fromJSON(props.scope)!;\r\n this.source = RelatedElement.fromJSON(props.source);\r\n this.identifier = props.identifier;\r\n this.kind = props.kind;\r\n this.checksum = props.checksum;\r\n this.version = props.version;\r\n this.jsonProperties = props.jsonProperties;\r\n }\r\n\r\n /** Look up the ElementId of the element that contains an aspect with the specified Scope, Kind, and Identifier\r\n */\r\n public static findBySource(iModelDb: IModelDb, scope: Id64String, kind: string, identifier: string): { elementId?: Id64String, aspectId?: Id64String } {\r\n const sql = `SELECT Element.Id, ECInstanceId FROM ${ExternalSourceAspect.classFullName} WHERE (Scope.Id=:scope AND Kind=:kind AND Identifier=:identifier)`;\r\n let elementId: Id64String | undefined;\r\n let aspectId: Id64String | undefined;\r\n iModelDb.withPreparedStatement(sql, (statement: ECSqlStatement) => {\r\n statement.bindId(\"scope\", scope);\r\n statement.bindString(\"kind\", kind);\r\n statement.bindString(\"identifier\", identifier);\r\n if (DbResult.BE_SQLITE_ROW === statement.step()) {\r\n elementId = statement.getValue(0).getId();\r\n aspectId = statement.getValue(1).getId();\r\n }\r\n });\r\n return { elementId, aspectId };\r\n }\r\n\r\n /** @internal */\r\n public override toJSON(): ExternalSourceAspectProps {\r\n const val = super.toJSON() as ExternalSourceAspectProps;\r\n val.scope = this.scope;\r\n val.source = this.source;\r\n val.identifier = this.identifier;\r\n val.kind = this.kind;\r\n val.checksum = this.checksum;\r\n val.version = this.version;\r\n val.jsonProperties = this.jsonProperties;\r\n return val;\r\n }\r\n}\r\n\r\n/** @public */\r\nexport namespace ExternalSourceAspect { // eslint-disable-line no-redeclare\r\n /** Standard values for the `Kind` property of `ExternalSourceAspect`.\r\n * @public\r\n */\r\n export enum Kind {\r\n /** Indicates that the [[ExternalSourceAspect]] is storing [[Element]] provenance */\r\n Element = \"Element\",\r\n /** Indicates that the [[ExternalSourceAspect]] is storing [[Relationship]] provenance */\r\n Relationship = \"Relationship\",\r\n /** Indicates that the [[ExternalSourceAspect]] is storing *scope* provenance\r\n * @see [[ExternalSourceAspect.scope]]\r\n */\r\n Scope = \"Scope\",\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ElementGraphics.js","sourceRoot":"","sources":["../../src/ElementGraphics.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA2D;AAC3D,oDAA8E;AAI9E;;GAEG;AACI,KAAK,UAAU,uBAAuB,CAAC,OAAoC,EAAE,MAAgB;IAClG,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;IAEtE,IAAI,KAAyB,CAAC;IAC9B,QAAQ,MAAM,CAAC,MAAM,EAAE;QACrB,wBAAsC;QACtC;YACE,OAAO,SAAS,CAAC;QACnB;YACE,OAAO,MAAM,CAAC,OAAO,CAAC;QACxB;YACE,KAAK,GAAG,cAAc,CAAC;YACvB,MAAM;QACR;YACE,KAAK,GAAG,8BAA8B,CAAC;YACvC,MAAM;QACR;YACE,KAAK,GAAG,cAAc,OAAO,CAAC,SAAS,YAAY,CAAC;YACpD,MAAM;QACR;YACE,KAAK,GAAG,yBAAyB,OAAO,CAAC,EAAE,GAAG,CAAC;YAC/C,MAAM;KACT;IAED,IAAA,qBAAM,EAAC,SAAS,KAAK,KAAK,CAAC,CAAC;IAC5B,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;AACxD,CAAC;AA1BD,0DA0BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tiles\n */\n\nimport { assert, IModelStatus } from \"@itwin/core-bentley\";\nimport { ElementGraphicsRequestProps, IModelError } from \"@itwin/core-common\";\nimport { ElementGraphicsStatus } from \"@bentley/imodeljs-native\";\nimport { IModelDb } from \"./IModelDb\";\n\n/** See [[IModelDb.generateElementGraphics]] and IModelTileRpcImpl.requestElementGraphics.\n * @internal\n */\nexport async function generateElementGraphics(request: ElementGraphicsRequestProps, iModel: IModelDb): Promise<Uint8Array | undefined> {\n const result = await iModel.nativeDb.generateElementGraphics(request);\n\n let error: string | undefined;\n switch (result.status) {\n case ElementGraphicsStatus.NoGeometry:\n case ElementGraphicsStatus.Canceled:\n return undefined;\n case ElementGraphicsStatus.Success:\n return result.content;\n case ElementGraphicsStatus.InvalidJson:\n error = \"Invalid JSON\";\n break;\n case ElementGraphicsStatus.UnknownMajorFormatVersion:\n error = \"Unknown major format version\";\n break;\n case ElementGraphicsStatus.ElementNotFound:\n error = `Element Id ${request.elementId} not found`;\n break;\n case ElementGraphicsStatus.DuplicateRequestId:\n error = `Duplicate request Id \"${request.id}\"`;\n break;\n }\n\n assert(undefined !== error);\n throw new IModelError(IModelStatus.BadRequest, error);\n}\n"]}
1
+ {"version":3,"file":"ElementGraphics.js","sourceRoot":"","sources":["../../src/ElementGraphics.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA2D;AAC3D,oDAA8E;AAI9E;;GAEG;AACI,KAAK,UAAU,uBAAuB,CAAC,OAAoC,EAAE,MAAgB;IAClG,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;IAEtE,IAAI,KAAyB,CAAC;IAC9B,QAAQ,MAAM,CAAC,MAAM,EAAE;QACrB,wBAAsC;QACtC;YACE,OAAO,SAAS,CAAC;QACnB;YACE,OAAO,MAAM,CAAC,OAAO,CAAC;QACxB;YACE,KAAK,GAAG,cAAc,CAAC;YACvB,MAAM;QACR;YACE,KAAK,GAAG,8BAA8B,CAAC;YACvC,MAAM;QACR;YACE,KAAK,GAAG,cAAc,OAAO,CAAC,SAAS,YAAY,CAAC;YACpD,MAAM;QACR;YACE,KAAK,GAAG,yBAAyB,OAAO,CAAC,EAAE,GAAG,CAAC;YAC/C,MAAM;KACT;IAED,IAAA,qBAAM,EAAC,SAAS,KAAK,KAAK,CAAC,CAAC;IAC5B,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;AACxD,CAAC;AA1BD,0DA0BC","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 Tiles\r\n */\r\n\r\nimport { assert, IModelStatus } from \"@itwin/core-bentley\";\r\nimport { ElementGraphicsRequestProps, IModelError } from \"@itwin/core-common\";\r\nimport { ElementGraphicsStatus } from \"@bentley/imodeljs-native\";\r\nimport { IModelDb } from \"./IModelDb\";\r\n\r\n/** See [[IModelDb.generateElementGraphics]] and IModelTileRpcImpl.requestElementGraphics.\r\n * @internal\r\n */\r\nexport async function generateElementGraphics(request: ElementGraphicsRequestProps, iModel: IModelDb): Promise<Uint8Array | undefined> {\r\n const result = await iModel.nativeDb.generateElementGraphics(request);\r\n\r\n let error: string | undefined;\r\n switch (result.status) {\r\n case ElementGraphicsStatus.NoGeometry:\r\n case ElementGraphicsStatus.Canceled:\r\n return undefined;\r\n case ElementGraphicsStatus.Success:\r\n return result.content;\r\n case ElementGraphicsStatus.InvalidJson:\r\n error = \"Invalid JSON\";\r\n break;\r\n case ElementGraphicsStatus.UnknownMajorFormatVersion:\r\n error = \"Unknown major format version\";\r\n break;\r\n case ElementGraphicsStatus.ElementNotFound:\r\n error = `Element Id ${request.elementId} not found`;\r\n break;\r\n case ElementGraphicsStatus.DuplicateRequestId:\r\n error = `Duplicate request Id \"${request.id}\"`;\r\n break;\r\n }\r\n\r\n assert(undefined !== error);\r\n throw new IModelError(IModelStatus.BadRequest, error);\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Entity.js","sourceRoot":"","sources":["../../src/Entity.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAuD;AAEvD,yCAAsC;AAGtC;;GAEG;AACH,MAAa,MAAM;IA+BjB,gBAAgB;IAChB,YAAY,KAAkB,EAAE,MAAgB;QAC9C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,EAAE,GAAG,mBAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAClC,8EAA8E;QAC9E,IAAI,CAAC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K,aAAa,KAAa,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;IAEnG,6EAA6E;IAC7E,IAAW,aAAa,KAAa,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;IAEvE,gBAAgB;IACT,MAAM,KAAK,mBAAmB,KAAe,OAAO,EAAE,CAAC,CAAC,CAAC;CACjE;AAhED,wBAgEC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Schema\n */\n\nimport { Id64, Id64String } from \"@itwin/core-bentley\";\nimport { EntityProps, PropertyCallback, PropertyMetaData } from \"@itwin/core-common\";\nimport { IModelDb } from \"./IModelDb\";\nimport { Schema } from \"./Schema\";\n\n/** Base class for all Entities in an iModel. Every subclass of Entity handles one BIS class.\n * @public\n */\nexport class Entity implements EntityProps {\n /** The Schema that defines this class. */\n public static schema: typeof Schema;\n\n private get _ctor(): typeof Entity { return this.constructor as typeof Entity; }\n\n /** The name of the BIS class associated with this class.\n * @note Every subclass of Entity **MUST** override this method to identify its BIS class.\n * Failure to do so will ordinarily result in an error when the class is registered, since there may only\n * be one JavaScript class for a given BIS class (usually the errant class will collide with its superclass.)\n */\n public static get className(): string { return \"Entity\"; }\n\n /** When working with an Entity it can be useful to set property values directly, bypassing the compiler's type checking.\n * This property makes such code slightly less tedious to read and write.\n * @internal\n */\n public get asAny(): any { return this; }\n\n /** The name of the BIS Schema that defines this class */\n public get schemaName(): string { return this._ctor.schema.schemaName; }\n\n /** The name of the BIS class associated with this class. */\n public get className(): string { return this._ctor.className; }\n\n /** The [[IModelDb]] that contains this Entity */\n public iModel: IModelDb;\n\n /** The Id of this Entity. May be invalid if the Entity has not yet been saved in the database. */\n public id: Id64String;\n\n /** @internal */\n constructor(props: EntityProps, iModel: IModelDb) {\n this.iModel = iModel;\n this.id = Id64.fromJSON(props.id);\n // copy all auto-handled properties from input to the object being constructed\n this.forEachProperty((propName: string, meta: PropertyMetaData) => (this as any)[propName] = meta.createProperty((props as any)[propName]), false);\n }\n\n /** @internal */\n public toJSON(): EntityProps {\n const val: any = {};\n val.classFullName = this.classFullName;\n if (Id64.isValid(this.id))\n val.id = this.id;\n this.forEachProperty((propName: string) => val[propName] = (this as any)[propName], false);\n return val;\n }\n\n /** Call a function for each property of this Entity.\n * @param func The callback to be invoked on each property\n * @param includeCustom If true (default), include custom-handled properties in the iteration. Otherwise, skip custom-handled properties.\n * @note Custom-handled properties are core properties that have behavior enforced by C++ handlers.\n */\n public forEachProperty(func: PropertyCallback, includeCustom: boolean = true) { IModelDb.forEachMetaData(this.iModel, this.classFullName, true, func, includeCustom); }\n\n /** Get the full BIS class name of this Entity in the form \"schema:class\" */\n public static get classFullName(): string { return `${this.schema.schemaName}:${this.className}`; }\n\n /** Get the full BIS class name of this Entity in the form \"schema:class\". */\n public get classFullName(): string { return this._ctor.classFullName; }\n\n /** @internal */\n public static get protectedOperations(): string[] { return []; }\n}\n\n/** Parameter type that can accept both abstract constructor types and non-abstract constructor types for `instanceof` to test.\n * @public\n */\nexport type EntityClassType<T> = Function & { prototype: T };\n"]}
1
+ {"version":3,"file":"Entity.js","sourceRoot":"","sources":["../../src/Entity.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAuD;AAEvD,yCAAsC;AAGtC;;GAEG;AACH,MAAa,MAAM;IA+BjB,gBAAgB;IAChB,YAAY,KAAkB,EAAE,MAAgB;QAC9C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,EAAE,GAAG,mBAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAClC,8EAA8E;QAC9E,IAAI,CAAC,eAAe,CAAC,CAAC,QAAgB,EAAE,IAAsB,E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AM,CAAC,UAAU,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;IAEnG,6EAA6E;IAC7E,IAAW,aAAa,KAAa,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;IAEvE,gBAAgB;IACT,MAAM,KAAK,mBAAmB,KAAe,OAAO,EAAE,CAAC,CAAC,CAAC;CACjE;AAhED,wBAgEC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Schema\r\n */\r\n\r\nimport { Id64, Id64String } from \"@itwin/core-bentley\";\r\nimport { EntityProps, PropertyCallback, PropertyMetaData } from \"@itwin/core-common\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { Schema } from \"./Schema\";\r\n\r\n/** Base class for all Entities in an iModel. Every subclass of Entity handles one BIS class.\r\n * @public\r\n */\r\nexport class Entity implements EntityProps {\r\n /** The Schema that defines this class. */\r\n public static schema: typeof Schema;\r\n\r\n private get _ctor(): typeof Entity { return this.constructor as typeof Entity; }\r\n\r\n /** The name of the BIS class associated with this class.\r\n * @note Every subclass of Entity **MUST** override this method to identify its BIS class.\r\n * Failure to do so will ordinarily result in an error when the class is registered, since there may only\r\n * be one JavaScript class for a given BIS class (usually the errant class will collide with its superclass.)\r\n */\r\n public static get className(): string { return \"Entity\"; }\r\n\r\n /** When working with an Entity it can be useful to set property values directly, bypassing the compiler's type checking.\r\n * This property makes such code slightly less tedious to read and write.\r\n * @internal\r\n */\r\n public get asAny(): any { return this; }\r\n\r\n /** The name of the BIS Schema that defines this class */\r\n public get schemaName(): string { return this._ctor.schema.schemaName; }\r\n\r\n /** The name of the BIS class associated with this class. */\r\n public get className(): string { return this._ctor.className; }\r\n\r\n /** The [[IModelDb]] that contains this Entity */\r\n public iModel: IModelDb;\r\n\r\n /** The Id of this Entity. May be invalid if the Entity has not yet been saved in the database. */\r\n public id: Id64String;\r\n\r\n /** @internal */\r\n constructor(props: EntityProps, iModel: IModelDb) {\r\n this.iModel = iModel;\r\n this.id = Id64.fromJSON(props.id);\r\n // copy all auto-handled properties from input to the object being constructed\r\n this.forEachProperty((propName: string, meta: PropertyMetaData) => (this as any)[propName] = meta.createProperty((props as any)[propName]), false);\r\n }\r\n\r\n /** @internal */\r\n public toJSON(): EntityProps {\r\n const val: any = {};\r\n val.classFullName = this.classFullName;\r\n if (Id64.isValid(this.id))\r\n val.id = this.id;\r\n this.forEachProperty((propName: string) => val[propName] = (this as any)[propName], false);\r\n return val;\r\n }\r\n\r\n /** Call a function for each property of this Entity.\r\n * @param func The callback to be invoked on each property\r\n * @param includeCustom If true (default), include custom-handled properties in the iteration. Otherwise, skip custom-handled properties.\r\n * @note Custom-handled properties are core properties that have behavior enforced by C++ handlers.\r\n */\r\n public forEachProperty(func: PropertyCallback, includeCustom: boolean = true) { IModelDb.forEachMetaData(this.iModel, this.classFullName, true, func, includeCustom); }\r\n\r\n /** Get the full BIS class name of this Entity in the form \"schema:class\" */\r\n public static get classFullName(): string { return `${this.schema.schemaName}:${this.className}`; }\r\n\r\n /** Get the full BIS class name of this Entity in the form \"schema:class\". */\r\n public get classFullName(): string { return this._ctor.classFullName; }\r\n\r\n /** @internal */\r\n public static get protectedOperations(): string[] { return []; }\r\n}\r\n\r\n/** Parameter type that can accept both abstract constructor types and non-abstract constructor types for `instanceof` to test.\r\n * @public\r\n */\r\nexport type EntityClassType<T> = Function & { prototype: T };\r\n"]}