@itwin/core-backend 5.14.0-dev.8 → 5.15.0-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -1
- package/lib/cjs/BriefcaseManager.d.ts +6 -0
- package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
- package/lib/cjs/BriefcaseManager.js +1 -1
- package/lib/cjs/BriefcaseManager.js.map +1 -1
- package/lib/cjs/ChangesetReader.d.ts +1 -1
- package/lib/cjs/ChangesetReader.js +2 -2
- package/lib/cjs/ChangesetReader.js.map +1 -1
- package/lib/cjs/ChangesetReaderTypes.d.ts +4 -1
- package/lib/cjs/ChangesetReaderTypes.d.ts.map +1 -1
- package/lib/cjs/ChangesetReaderTypes.js +3 -0
- package/lib/cjs/ChangesetReaderTypes.js.map +1 -1
- package/lib/cjs/ECDb.d.ts +63 -6
- package/lib/cjs/ECDb.d.ts.map +1 -1
- package/lib/cjs/ECDb.js +62 -6
- package/lib/cjs/ECDb.js.map +1 -1
- package/lib/cjs/ECSqlStatement.d.ts +2 -2
- package/lib/cjs/ECSqlStatement.js +2 -2
- package/lib/cjs/ECSqlStatement.js.map +1 -1
- package/lib/cjs/Element.d.ts.map +1 -1
- package/lib/cjs/Element.js +6 -3
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +53 -38
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +47 -27
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/IpcHost.d.ts.map +1 -1
- package/lib/cjs/IpcHost.js +51 -17
- package/lib/cjs/IpcHost.js.map +1 -1
- package/lib/cjs/SchemaSync.d.ts +2 -2
- package/lib/cjs/SchemaSync.d.ts.map +1 -1
- package/lib/cjs/SchemaSync.js +2 -2
- package/lib/cjs/SchemaSync.js.map +1 -1
- package/lib/cjs/SqliteChangesetReader.d.ts +16 -8
- package/lib/cjs/SqliteChangesetReader.d.ts.map +1 -1
- package/lib/cjs/SqliteChangesetReader.js +11 -1
- package/lib/cjs/SqliteChangesetReader.js.map +1 -1
- package/lib/cjs/TxnManager.d.ts.map +1 -1
- package/lib/cjs/TxnManager.js +4 -0
- package/lib/cjs/TxnManager.js.map +1 -1
- package/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts +90 -5
- package/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts.map +1 -1
- package/lib/cjs/annotations/ElementDrivesTextAnnotation.js +59 -1
- package/lib/cjs/annotations/ElementDrivesTextAnnotation.js.map +1 -1
- package/lib/cjs/internal/IntegrityCheck.d.ts +57 -0
- package/lib/cjs/internal/IntegrityCheck.d.ts.map +1 -1
- package/lib/cjs/internal/IntegrityCheck.js.map +1 -1
- package/lib/cjs/internal/annotations/fieldSpecs.d.ts +82 -0
- package/lib/cjs/internal/annotations/fieldSpecs.d.ts.map +1 -0
- package/lib/cjs/internal/annotations/fieldSpecs.js +187 -0
- package/lib/cjs/internal/annotations/fieldSpecs.js.map +1 -0
- package/lib/cjs/internal/annotations/fields.d.ts +39 -2
- package/lib/cjs/internal/annotations/fields.d.ts.map +1 -1
- package/lib/cjs/internal/annotations/fields.js +140 -13
- package/lib/cjs/internal/annotations/fields.js.map +1 -1
- package/lib/esm/BriefcaseManager.d.ts +6 -0
- package/lib/esm/BriefcaseManager.d.ts.map +1 -1
- package/lib/esm/BriefcaseManager.js +1 -1
- package/lib/esm/BriefcaseManager.js.map +1 -1
- package/lib/esm/ChangesetReader.d.ts +1 -1
- package/lib/esm/ChangesetReader.js +2 -2
- package/lib/esm/ChangesetReader.js.map +1 -1
- package/lib/esm/ChangesetReaderTypes.d.ts +4 -1
- package/lib/esm/ChangesetReaderTypes.d.ts.map +1 -1
- package/lib/esm/ChangesetReaderTypes.js +3 -0
- package/lib/esm/ChangesetReaderTypes.js.map +1 -1
- package/lib/esm/ECDb.d.ts +63 -6
- package/lib/esm/ECDb.d.ts.map +1 -1
- package/lib/esm/ECDb.js +62 -6
- package/lib/esm/ECDb.js.map +1 -1
- package/lib/esm/ECSqlStatement.d.ts +2 -2
- package/lib/esm/ECSqlStatement.js +2 -2
- package/lib/esm/ECSqlStatement.js.map +1 -1
- package/lib/esm/Element.d.ts.map +1 -1
- package/lib/esm/Element.js +6 -3
- package/lib/esm/Element.js.map +1 -1
- package/lib/esm/IModelDb.d.ts +53 -38
- package/lib/esm/IModelDb.d.ts.map +1 -1
- package/lib/esm/IModelDb.js +47 -27
- package/lib/esm/IModelDb.js.map +1 -1
- package/lib/esm/IpcHost.d.ts.map +1 -1
- package/lib/esm/IpcHost.js +52 -18
- package/lib/esm/IpcHost.js.map +1 -1
- package/lib/esm/SchemaSync.d.ts +2 -2
- package/lib/esm/SchemaSync.d.ts.map +1 -1
- package/lib/esm/SchemaSync.js +2 -2
- package/lib/esm/SchemaSync.js.map +1 -1
- package/lib/esm/SqliteChangesetReader.d.ts +16 -8
- package/lib/esm/SqliteChangesetReader.d.ts.map +1 -1
- package/lib/esm/SqliteChangesetReader.js +11 -1
- package/lib/esm/SqliteChangesetReader.js.map +1 -1
- package/lib/esm/TxnManager.d.ts.map +1 -1
- package/lib/esm/TxnManager.js +4 -0
- package/lib/esm/TxnManager.js.map +1 -1
- package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts +90 -5
- package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts.map +1 -1
- package/lib/esm/annotations/ElementDrivesTextAnnotation.js +60 -2
- package/lib/esm/annotations/ElementDrivesTextAnnotation.js.map +1 -1
- package/lib/esm/internal/IntegrityCheck.d.ts +57 -0
- package/lib/esm/internal/IntegrityCheck.d.ts.map +1 -1
- package/lib/esm/internal/IntegrityCheck.js.map +1 -1
- package/lib/esm/internal/annotations/fieldSpecs.d.ts +82 -0
- package/lib/esm/internal/annotations/fieldSpecs.d.ts.map +1 -0
- package/lib/esm/internal/annotations/fieldSpecs.js +179 -0
- package/lib/esm/internal/annotations/fieldSpecs.js.map +1 -0
- package/lib/esm/internal/annotations/fields.d.ts +39 -2
- package/lib/esm/internal/annotations/fields.d.ts.map +1 -1
- package/lib/esm/internal/annotations/fields.js +140 -13
- package/lib/esm/internal/annotations/fields.js.map +1 -1
- package/lib/esm/test/AnnotationTestUtils.d.ts +9 -0
- package/lib/esm/test/AnnotationTestUtils.d.ts.map +1 -1
- package/lib/esm/test/AnnotationTestUtils.js +17 -0
- package/lib/esm/test/AnnotationTestUtils.js.map +1 -1
- package/lib/esm/test/annotations/FieldFormat.test.d.ts +2 -0
- package/lib/esm/test/annotations/FieldFormat.test.d.ts.map +1 -0
- package/lib/esm/test/annotations/FieldFormat.test.js +738 -0
- package/lib/esm/test/annotations/FieldFormat.test.js.map +1 -0
- package/lib/esm/test/annotations/FieldFormattingLifecycle.test.d.ts +2 -0
- package/lib/esm/test/annotations/FieldFormattingLifecycle.test.d.ts.map +1 -0
- package/lib/esm/test/annotations/FieldFormattingLifecycle.test.js +323 -0
- package/lib/esm/test/annotations/FieldFormattingLifecycle.test.js.map +1 -0
- package/lib/esm/test/annotations/FieldSpecs.test.d.ts +2 -0
- package/lib/esm/test/annotations/FieldSpecs.test.d.ts.map +1 -0
- package/lib/esm/test/annotations/FieldSpecs.test.js +54 -0
- package/lib/esm/test/annotations/FieldSpecs.test.js.map +1 -0
- package/lib/esm/test/annotations/Fields.test.js +221 -27
- package/lib/esm/test/annotations/Fields.test.js.map +1 -1
- package/lib/esm/test/ecdb/CSVImport.test.d.ts +2 -0
- package/lib/esm/test/ecdb/CSVImport.test.d.ts.map +1 -0
- package/lib/esm/test/ecdb/CSVImport.test.js +186 -0
- package/lib/esm/test/ecdb/CSVImport.test.js.map +1 -0
- package/lib/esm/test/ecdb/ConcurrentQuery.test.js +19 -2
- package/lib/esm/test/ecdb/ConcurrentQuery.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECDb.test.js +207 -95
- package/lib/esm/test/ecdb/ECDb.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECSqlAst.test.js +2 -2
- package/lib/esm/test/ecdb/ECSqlAst.test.js.map +1 -1
- package/lib/esm/test/ecdb/QueryReaders.test.js +105 -30
- package/lib/esm/test/ecdb/QueryReaders.test.js.map +1 -1
- package/lib/esm/test/ecsql/dataset/ECSqlDatasets.d.ts.map +1 -1
- package/lib/esm/test/ecsql/dataset/ECSqlDatasets.js +7 -0
- package/lib/esm/test/ecsql/dataset/ECSqlDatasets.js.map +1 -1
- package/lib/esm/test/ecsql/src/ECSqlTestRunner.test.js +86 -7
- package/lib/esm/test/ecsql/src/ECSqlTestRunner.test.js.map +1 -1
- package/lib/esm/test/hubaccess/BriefcaseManager.test.js +65 -1
- package/lib/esm/test/hubaccess/BriefcaseManager.test.js.map +1 -1
- package/lib/esm/test/imodel/IModelElements.test.js +5 -0
- package/lib/esm/test/imodel/IModelElements.test.js.map +1 -1
- package/lib/esm/test/standalone/ChangesetReader.test.js +111 -2
- package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -1
- package/lib/esm/test/standalone/DgnDomainMergeConflict.test.js +61 -0
- package/lib/esm/test/standalone/DgnDomainMergeConflict.test.js.map +1 -1
- package/lib/esm/test/standalone/SQLiteDb.test.d.ts.map +1 -1
- package/lib/esm/test/standalone/SQLiteDb.test.js +116 -0
- package/lib/esm/test/standalone/SQLiteDb.test.js.map +1 -1
- package/package.json +16 -14
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntegrityCheck.js","sourceRoot":"","sources":["../../../src/internal/IntegrityCheck.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AA6P/F,sDAcC;AAQD,gEAOC;AAsBD,sEAkFC;AAhYD,sDAA+D;AAC/D,oDAAiD;AAGjD;;;GAGG;AACU,QAAA,qBAAqB,GAAG;IACnC,gBAAgB,EAAE;QAChB,IAAI,EAAE,oBAAoB;QAC1B,UAAU,EAAE,2BAA2B;QACvC,UAAU,EAAE,oBAAoB;QAChC,QAAQ,EAAE,sFAAsF;KACjG;IACD,cAAc,EAAE;QACd,I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,QAAQ,EAAE,kBAAkB,EAAE,GAAG,CAAC,kBAAkB,EAAE,CAAC,CAAC;YAClI,CAAC;YACD,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,KAAK,uBAAuB,CAAC,CAAC,CAAC;YAC7B,MAAM,OAAO,GAAqC,EAAE,CAAC;YACrD,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,MAAM,CAAC,iBAAiB,CAAC,6BAAqB,CAAC,qBAAqB,CAAC,QAAQ,EAAE,SAAS,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;gBAC5I,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,cAAc,EAAE,GAAG,CAAC,cAAc,EAAE,gBAAgB,EAAE,GAAG,CAAC,gBAAgB,EAAE,WAAW,EAAE,GAAG,CAAC,WAAW,EAAE,aAAa,EAAE,GAAG,CAAC,aAAa,EAAE,YAAY,EAAE,GAAG,CAAC,YAAY,EAAE,UAAU,EAAE,GAAG,CAAC,UAAU,EAAE,cAAc,EAAE,GAAG,CAAC,cAAc,EAAE,CAAC,CAAC;YAC7Q,CAAC;YACD,OAAO,OAAO,CAAC;QACjB,CAAC;QACD;YACE,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,UAAU,EAAE,8BAA8B,CAAC,CAAC;IACnF,CAAC;AACH,CAAC","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\r\nimport { Id64String, IModelStatus } from \"@itwin/core-bentley\";\r\nimport { IModelError } from \"@itwin/core-common\";\r\nimport { IModelDb } from \"../IModelDb\";\r\n\r\n/**\r\n * Information about each integrity check type, including the name, expected result type, and SQL query to execute\r\n * @internal\r\n */\r\nexport const integrityCheckTypeMap = {\r\n checkDataColumns: {\r\n name: \"Check Data Columns\",\r\n resultType: \"CheckDataColumnsResultRow\",\r\n sqlCommand: \"check_data_columns\",\r\n sqlQuery: `PRAGMA integrity_check(check_data_columns) ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES`,\r\n },\r\n checkECProfile: {\r\n name: \"Check EC Profile\",\r\n resultType: \"CheckECProfileResultRow\",\r\n sqlCommand: \"check_ec_profile\",\r\n sqlQuery: `PRAGMA integrity_check(check_ec_profile) ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES`,\r\n },\r\n checkNavigationClassIds: {\r\n name: \"Check Navigation Class Ids\",\r\n resultType: \"CheckNavClassIdsResultRow\",\r\n sqlCommand: \"check_nav_class_ids\",\r\n sqlQuery: `PRAGMA integrity_check(check_nav_class_ids) ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES`,\r\n },\r\n checkNavigationIds: {\r\n name: \"Check Navigation Ids\",\r\n resultType: \"CheckNavIdsResultRow\",\r\n sqlCommand: \"check_nav_ids\",\r\n sqlQuery: `PRAGMA integrity_check(check_nav_ids) ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES`,\r\n },\r\n checkLinktableForeignKeyClassIds: {\r\n name: \"Check Link Table Foreign Key Class Ids\",\r\n resultType: \"CheckLinkTableFkClassIdsResultRow\",\r\n sqlCommand: \"check_linktable_fk_class_ids\",\r\n sqlQuery: `PRAGMA integrity_check(check_linktable_fk_class_ids) ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES`,\r\n },\r\n checkLinktableForeignKeyIds: {\r\n name: \"Check Link Table Foreign Key Ids\",\r\n resultType: \"CheckLinkTableFkIdsResultRow\",\r\n sqlCommand: \"check_linktable_fk_ids\",\r\n sqlQuery: `PRAGMA integrity_check(check_linktable_fk_ids) ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES`,\r\n },\r\n checkClassIds: {\r\n name: \"Check Class Ids\",\r\n resultType: \"CheckClassIdsResultRow\",\r\n sqlCommand: \"check_class_ids\",\r\n sqlQuery: `PRAGMA integrity_check(check_class_ids) ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES`,\r\n },\r\n checkDataSchema: {\r\n name: \"Check Data Schema\",\r\n resultType: \"CheckDataSchemaResultRow\",\r\n sqlCommand: \"check_data_schema\",\r\n sqlQuery: `PRAGMA integrity_check(check_data_schema) ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES`,\r\n },\r\n checkSchemaLoad: {\r\n name: \"Check Schema Load\",\r\n resultType: \"CheckSchemaLoadResultRow\",\r\n sqlCommand: \"check_schema_load\",\r\n sqlQuery: `PRAGMA integrity_check(check_schema_load) ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES`,\r\n },\r\n checkMissingChildRows: {\r\n name: \"Check Missing Child Rows\",\r\n resultType: \"CheckMissingChildRowsResultRow\",\r\n sqlCommand: \"check_missing_child_rows\",\r\n sqlQuery: `PRAGMA integrity_check(check_missing_child_rows) ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES`,\r\n },\r\n checkDivergedPropMaps: {\r\n name: \"Check Diverged Property Maps\",\r\n resultType: \"CheckDivergedPropMapsResultRow\",\r\n sqlCommand: \"check_diverged_prop_maps\",\r\n sqlQuery: `PRAGMA integrity_check(check_diverged_prop_maps) ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES`,\r\n },\r\n} as const;\r\n\r\n/**\r\n * Type representing the keys of the integrityCheckType map, which correspond to the different types of integrity checks that can be performed.\r\n */\r\nexport type IntegrityCheckKey = keyof typeof integrityCheckTypeMap;\r\n\r\n/** Map of integrity check keys to their result row types */\r\ninterface IntegrityCheckResultTypeMap {\r\n checkDataColumns: CheckDataColumnsResultRow;\r\n checkECProfile: CheckECProfileResultRow;\r\n checkNavigationClassIds: CheckNavClassIdsResultRow;\r\n checkNavigationIds: CheckNavIdsResultRow;\r\n checkLinktableForeignKeyClassIds: CheckLinkTableFkClassIdsResultRow;\r\n checkLinktableForeignKeyIds: CheckLinkTableFkIdsResultRow;\r\n checkClassIds: CheckClassIdsResultRow;\r\n checkDataSchema: CheckDataSchemaResultRow;\r\n checkSchemaLoad: CheckSchemaLoadResultRow;\r\n checkMissingChildRows: CheckMissingChildRowsResultRow;\r\n checkDivergedPropMaps: CheckDivergedPropMapsResultRow;\r\n}\r\n\r\n/** Checks the Map to give the return type of a specific integrity check */\r\ntype IntegrityCheckResultRow<K extends IntegrityCheckKey> = IntegrityCheckResultTypeMap[K];\r\n\r\n/**\r\n * Return type for quick integrity check\r\n */\r\nexport interface QuickIntegrityCheckResultRow {\r\n check: string;\r\n passed: boolean;\r\n elapsedSeconds: string;\r\n}\r\n\r\n/**\r\n * Return type for Check Data Columns integrity check\r\n */\r\nexport interface CheckDataColumnsResultRow {\r\n sno: number;\r\n table: string;\r\n column: string;\r\n}\r\n\r\n/**\r\n * Return type for Check EC Profile integrity check\r\n */\r\nexport interface CheckECProfileResultRow {\r\n sno: number;\r\n type: string;\r\n name: string;\r\n issue: string;\r\n}\r\n\r\n/**\r\n * Return type for Check Navigation Class Ids integrity check\r\n */\r\nexport interface CheckNavClassIdsResultRow {\r\n sno: number;\r\n id: string;\r\n class: string;\r\n property: string;\r\n navId: string;\r\n navClassId: string;\r\n}\r\n\r\n/**\r\n * Return type for Check Navigation Ids integrity check\r\n */\r\nexport interface CheckNavIdsResultRow {\r\n sno: number;\r\n id: string;\r\n class: string;\r\n property: string;\r\n navId: string;\r\n primaryClass: string;\r\n}\r\n\r\n/**\r\n * Return type for Check Link Table Foreign Key Class Ids integrity check\r\n */\r\nexport interface CheckLinkTableFkClassIdsResultRow {\r\n sno: number;\r\n id: string;\r\n relationship: string;\r\n property: string;\r\n keyId: string;\r\n keyClassId: string;\r\n}\r\n\r\n/**\r\n * Return type for Check Link Table Foreign Key Ids integrity check\r\n */\r\nexport interface CheckLinkTableFkIdsResultRow {\r\n sno: number;\r\n id: string;\r\n relationship: string;\r\n property: string;\r\n keyId: string;\r\n primaryClass: string;\r\n}\r\n\r\n/**\r\n * Return type for Check Class Ids integrity check\r\n */\r\nexport interface CheckClassIdsResultRow {\r\n sno: number;\r\n class: string;\r\n id: string;\r\n classId: string;\r\n type: string;\r\n}\r\n\r\n/**\r\n * Return type for Check Data Schema integrity check\r\n */\r\nexport interface CheckDataSchemaResultRow {\r\n sno: number;\r\n type: string;\r\n name: string;\r\n}\r\n\r\n/**\r\n * Return type for Check Schema Load integrity check\r\n */\r\nexport interface CheckSchemaLoadResultRow {\r\n sno: number;\r\n schema: string;\r\n}\r\n\r\n/**\r\n * Return type for Check Missing Child Rows integrity check\r\n */\r\nexport interface CheckMissingChildRowsResultRow {\r\n sno: number;\r\n class: string;\r\n id: string;\r\n classId: string;\r\n missingRowInTables: string;\r\n}\r\n\r\n/**\r\n * Return type for Check Diverged Property Maps integrity check\r\n */\r\nexport interface CheckDivergedPropMapsResultRow {\r\n sno: number;\r\n derivedClassId: Id64String;\r\n derivedClassName: string;\r\n baseClassId: Id64String;\r\n baseClassName: string;\r\n propertyName: string;\r\n baseColumn: string;\r\n divergedColumn: string;\r\n}\r\n\r\n/**\r\n * Return type for integrity check results, including the check name, whether it passed, and the specific results (if any)\r\n */\r\nexport interface IntegrityCheckResult {\r\n /** The name of the integrity check that was performed */\r\n check: string;\r\n /** Whether the integrity check passed (i.e. no issues were found = true) */\r\n passed: boolean;\r\n /** The specific results returned by the integrity check, which may include details about any issues that were found.\r\n * In the case where issues are found, this will be an array of result rows specific to the type of check that was performed,\r\n * or an array of quick integrity check results if it was a quick check. */\r\n results: IntegrityCheckResultRow<IntegrityCheckKey>[] | QuickIntegrityCheckResultRow[];\r\n}\r\n\r\n/**\r\n * Gets the user-friendly name of an integrity check based on its key or SQL command.\r\n * It first attempts to find a direct match for the key in the integrityCheckTypeMap. If not found, it searches for a match based on the SQL command.\r\n * If still not found, it returns the original check string.\r\n * @param check - The integrity check key or SQL command to get the name of\r\n * @returns The user-friendly name of the integrity check, or the original check string if no match is found\r\n * @internal\r\n */\r\nexport function getIntegrityCheckName(check: string): string {\r\n // First try direct lookup by key\r\n const directLookup = integrityCheckTypeMap[check as IntegrityCheckKey];\r\n if (directLookup) {\r\n return directLookup.name;\r\n }\r\n // If not found, search by sqlCommand\r\n for (const [, value] of Object.entries(integrityCheckTypeMap)) {\r\n if (value.sqlCommand === check) {\r\n return value.name;\r\n }\r\n }\r\n // Fallback to the original check string\r\n return check;\r\n}\r\n\r\n/**\r\n * Performs a quick integrity check on the given iModel.\r\n * @param iModel The IModelDb instance to perform the integrity check on\r\n * @returns An array of results for each check performed, including the check name, whether it passed, and the elapsed time in seconds\r\n * @internal\r\n */\r\nexport async function performQuickIntegrityCheck(iModel: IModelDb): Promise<QuickIntegrityCheckResultRow[]> {\r\n const integrityCheckQuery = \"PRAGMA integrity_check ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES\";\r\n const integrityCheckResults: QuickIntegrityCheckResultRow[] = [];\r\n for await (const row of iModel.createQueryReader(integrityCheckQuery, undefined, { usePrimaryConn: true })) {\r\n integrityCheckResults.push({ check: getIntegrityCheckName(row.check), passed: row.result, elapsedSeconds: row.elapsed_sec });\r\n };\r\n return integrityCheckResults;\r\n}\r\n\r\n/**\r\n * Performs a specific integrity check on the given iModel based on the provided check key, and returns the results specific to that check type.\r\n * @param iModel The IModelDb instance to perform the integrity check on\r\n * @param check The key of the specific integrity check to perform\r\n * @return An array of results specific to the integrity check that was performed. The type of the result rows will depend on the check that was executed.\r\n * @throws IModelError with status BadRequest if an unknown integrity check key is provided\r\n * @internal\r\n */\r\nexport async function performSpecificIntegrityCheck(iModel: IModelDb, check: \"checkDataColumns\"): Promise<IntegrityCheckResultRow<\"checkDataColumns\">[]>;\r\nexport async function performSpecificIntegrityCheck(iModel: IModelDb, check: \"checkECProfile\"): Promise<IntegrityCheckResultRow<\"checkECProfile\">[]>;\r\nexport async function performSpecificIntegrityCheck(iModel: IModelDb, check: \"checkNavigationClassIds\"): Promise<IntegrityCheckResultRow<\"checkNavigationClassIds\">[]>;\r\nexport async function performSpecificIntegrityCheck(iModel: IModelDb, check: \"checkNavigationIds\"): Promise<IntegrityCheckResultRow<\"checkNavigationIds\">[]>;\r\nexport async function performSpecificIntegrityCheck(iModel: IModelDb, check: \"checkLinktableForeignKeyClassIds\"): Promise<IntegrityCheckResultRow<\"checkLinktableForeignKeyClassIds\">[]>;\r\nexport async function performSpecificIntegrityCheck(iModel: IModelDb, check: \"checkLinktableForeignKeyIds\"): Promise<IntegrityCheckResultRow<\"checkLinktableForeignKeyIds\">[]>;\r\nexport async function performSpecificIntegrityCheck(iModel: IModelDb, check: \"checkClassIds\"): Promise<IntegrityCheckResultRow<\"checkClassIds\">[]>;\r\nexport async function performSpecificIntegrityCheck(iModel: IModelDb, check: \"checkDataSchema\"): Promise<IntegrityCheckResultRow<\"checkDataSchema\">[]>;\r\nexport async function performSpecificIntegrityCheck(iModel: IModelDb, check: \"checkSchemaLoad\"): Promise<IntegrityCheckResultRow<\"checkSchemaLoad\">[]>;\r\nexport async function performSpecificIntegrityCheck(iModel: IModelDb, check: \"checkMissingChildRows\"): Promise<IntegrityCheckResultRow<\"checkMissingChildRows\">[]>;\r\nexport async function performSpecificIntegrityCheck(iModel: IModelDb, check: \"checkDivergedPropMaps\"): Promise<IntegrityCheckResultRow<\"checkDivergedPropMaps\">[]>;\r\nexport async function performSpecificIntegrityCheck<K extends IntegrityCheckKey>(iModel: IModelDb, check: K): Promise<IntegrityCheckResultRow<K>[]>;\r\nexport async function performSpecificIntegrityCheck(iModel: IModelDb, check: IntegrityCheckKey): Promise<IntegrityCheckResultRow<IntegrityCheckKey>[]> {\r\n switch (check) {\r\n case \"checkDataColumns\": {\r\n const results: CheckDataColumnsResultRow[] = [];\r\n for await (const row of iModel.createQueryReader(integrityCheckTypeMap.checkDataColumns.sqlQuery, undefined, { usePrimaryConn: true })) {\r\n results.push({ sno: row.sno, table: row.table, column: row.column });\r\n }\r\n return results;\r\n }\r\n case \"checkECProfile\": {\r\n const results: CheckECProfileResultRow[] = [];\r\n for await (const row of iModel.createQueryReader(integrityCheckTypeMap.checkECProfile.sqlQuery, undefined, { usePrimaryConn: true })) {\r\n results.push({ sno: row.sno, type: row.type, name: row.name, issue: row.issue });\r\n }\r\n return results;\r\n }\r\n case \"checkNavigationClassIds\": {\r\n const results: CheckNavClassIdsResultRow[] = [];\r\n for await (const row of iModel.createQueryReader(integrityCheckTypeMap.checkNavigationClassIds.sqlQuery, undefined, { usePrimaryConn: true })) {\r\n results.push({ sno: row.sno, id: row.id, class: row.class, property: row.property, navId: row.nav_id, navClassId: row.nav_classId });\r\n }\r\n return results;\r\n }\r\n case \"checkNavigationIds\": {\r\n const results: CheckNavIdsResultRow[] = [];\r\n for await (const row of iModel.createQueryReader(integrityCheckTypeMap.checkNavigationIds.sqlQuery, undefined, { usePrimaryConn: true })) {\r\n results.push({ sno: row.sno, id: row.id, class: row.class, property: row.property, navId: row.nav_id, primaryClass: row.primary_class });\r\n }\r\n return results;\r\n }\r\n case \"checkLinktableForeignKeyClassIds\": {\r\n const results: CheckLinkTableFkClassIdsResultRow[] = [];\r\n for await (const row of iModel.createQueryReader(integrityCheckTypeMap.checkLinktableForeignKeyClassIds.sqlQuery, undefined, { usePrimaryConn: true })) {\r\n results.push({ sno: row.sno, id: row.id, relationship: row.relationship, property: row.property, keyId: row.key_id, keyClassId: row.key_classId });\r\n }\r\n return results;\r\n }\r\n case \"checkLinktableForeignKeyIds\": {\r\n const results: CheckLinkTableFkIdsResultRow[] = [];\r\n for await (const row of iModel.createQueryReader(integrityCheckTypeMap.checkLinktableForeignKeyIds.sqlQuery, undefined, { usePrimaryConn: true })) {\r\n results.push({ sno: row.sno, id: row.id, relationship: row.relationship, property: row.property, keyId: row.key_id, primaryClass: row.primary_class });\r\n }\r\n return results;\r\n }\r\n case \"checkClassIds\": {\r\n const results: CheckClassIdsResultRow[] = [];\r\n for await (const row of iModel.createQueryReader(integrityCheckTypeMap.checkClassIds.sqlQuery, undefined, { usePrimaryConn: true })) {\r\n results.push({ sno: row.sno, class: row.class, id: row.id, classId: row.class_id, type: row.type });\r\n }\r\n return results;\r\n }\r\n case \"checkDataSchema\": {\r\n const results: CheckDataSchemaResultRow[] = [];\r\n for await (const row of iModel.createQueryReader(integrityCheckTypeMap.checkDataSchema.sqlQuery, undefined, { usePrimaryConn: true })) {\r\n results.push({ sno: row.sno, type: row.type, name: row.name });\r\n }\r\n return results;\r\n }\r\n case \"checkSchemaLoad\": {\r\n const results: CheckSchemaLoadResultRow[] = [];\r\n for await (const row of iModel.createQueryReader(integrityCheckTypeMap.checkSchemaLoad.sqlQuery, undefined, { usePrimaryConn: true })) {\r\n results.push({ sno: row.sno, schema: row.schema });\r\n }\r\n return results;\r\n }\r\n case \"checkMissingChildRows\": {\r\n const results: CheckMissingChildRowsResultRow[] = [];\r\n for await (const row of iModel.createQueryReader(integrityCheckTypeMap.checkMissingChildRows.sqlQuery, undefined, { usePrimaryConn: true })) {\r\n results.push({ sno: row.sno, class: row.class, id: row.id, classId: row.class_id, missingRowInTables: row.MissingRowInTables });\r\n }\r\n return results;\r\n }\r\n case \"checkDivergedPropMaps\": {\r\n const results: CheckDivergedPropMapsResultRow[] = [];\r\n for await (const row of iModel.createQueryReader(integrityCheckTypeMap.checkDivergedPropMaps.sqlQuery, undefined, { usePrimaryConn: true })) {\r\n results.push({ sno: row.sno, derivedClassId: row.derivedClassId, derivedClassName: row.derivedClassName, baseClassId: row.baseClassId, baseClassName: row.baseClassName, propertyName: row.propertyName, baseColumn: row.baseColumn, divergedColumn: row.divergedColumn });\r\n }\r\n return results;\r\n }\r\n default:\r\n throw new IModelError(IModelStatus.BadRequest, `Unknown integrity check type`);\r\n }\r\n}"]}
|
|
1
|
+
{"version":3,"file":"IntegrityCheck.js","sourceRoot":"","sources":["../../../src/internal/IntegrityCheck.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAsT/F,sDAcC;AAQD,gEAOC;AAsBD,sEAkFC;AAzbD,sDAA+D;AAC/D,oDAAiD;AAGjD;;;GAGG;AACU,QAAA,qBAAqB,GAAG;IACn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AAC,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,OAAO,EAAE,GAAG,CAAC,QAAQ,EAAE,kBAAkB,EAAE,GAAG,CAAC,kBAAkB,EAAE,CAAC,CAAC;YAClI,CAAC;YACD,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,KAAK,uBAAuB,CAAC,CAAC,CAAC;YAC7B,MAAM,OAAO,GAAqC,EAAE,CAAC;YACrD,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,MAAM,CAAC,iBAAiB,CAAC,6BAAqB,CAAC,qBAAqB,CAAC,QAAQ,EAAE,SAAS,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;gBAC5I,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,cAAc,EAAE,GAAG,CAAC,cAAc,EAAE,gBAAgB,EAAE,GAAG,CAAC,gBAAgB,EAAE,WAAW,EAAE,GAAG,CAAC,WAAW,EAAE,aAAa,EAAE,GAAG,CAAC,aAAa,EAAE,YAAY,EAAE,GAAG,CAAC,YAAY,EAAE,UAAU,EAAE,GAAG,CAAC,UAAU,EAAE,cAAc,EAAE,GAAG,CAAC,cAAc,EAAE,CAAC,CAAC;YAC7Q,CAAC;YACD,OAAO,OAAO,CAAC;QACjB,CAAC;QACD;YACE,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,UAAU,EAAE,8BAA8B,CAAC,CAAC;IACnF,CAAC;AACH,CAAC","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\r\nimport { Id64String, IModelStatus } from \"@itwin/core-bentley\";\r\nimport { IModelError } from \"@itwin/core-common\";\r\nimport { IModelDb } from \"../IModelDb\";\r\n\r\n/**\r\n * Information about each integrity check type, including the name, expected result type, and SQL query to execute\r\n * @internal\r\n */\r\nexport const integrityCheckTypeMap = {\r\n checkDataColumns: {\r\n name: \"Check Data Columns\",\r\n resultType: \"CheckDataColumnsResultRow\",\r\n sqlCommand: \"check_data_columns\",\r\n sqlQuery: `PRAGMA integrity_check(check_data_columns) ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES`,\r\n },\r\n checkECProfile: {\r\n name: \"Check EC Profile\",\r\n resultType: \"CheckECProfileResultRow\",\r\n sqlCommand: \"check_ec_profile\",\r\n sqlQuery: `PRAGMA integrity_check(check_ec_profile) ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES`,\r\n },\r\n checkNavigationClassIds: {\r\n name: \"Check Navigation Class Ids\",\r\n resultType: \"CheckNavClassIdsResultRow\",\r\n sqlCommand: \"check_nav_class_ids\",\r\n sqlQuery: `PRAGMA integrity_check(check_nav_class_ids) ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES`,\r\n },\r\n checkNavigationIds: {\r\n name: \"Check Navigation Ids\",\r\n resultType: \"CheckNavIdsResultRow\",\r\n sqlCommand: \"check_nav_ids\",\r\n sqlQuery: `PRAGMA integrity_check(check_nav_ids) ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES`,\r\n },\r\n checkLinktableForeignKeyClassIds: {\r\n name: \"Check Link Table Foreign Key Class Ids\",\r\n resultType: \"CheckLinkTableFkClassIdsResultRow\",\r\n sqlCommand: \"check_linktable_fk_class_ids\",\r\n sqlQuery: `PRAGMA integrity_check(check_linktable_fk_class_ids) ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES`,\r\n },\r\n checkLinktableForeignKeyIds: {\r\n name: \"Check Link Table Foreign Key Ids\",\r\n resultType: \"CheckLinkTableFkIdsResultRow\",\r\n sqlCommand: \"check_linktable_fk_ids\",\r\n sqlQuery: `PRAGMA integrity_check(check_linktable_fk_ids) ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES`,\r\n },\r\n checkClassIds: {\r\n name: \"Check Class Ids\",\r\n resultType: \"CheckClassIdsResultRow\",\r\n sqlCommand: \"check_class_ids\",\r\n sqlQuery: `PRAGMA integrity_check(check_class_ids) ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES`,\r\n },\r\n checkDataSchema: {\r\n name: \"Check Data Schema\",\r\n resultType: \"CheckDataSchemaResultRow\",\r\n sqlCommand: \"check_data_schema\",\r\n sqlQuery: `PRAGMA integrity_check(check_data_schema) ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES`,\r\n },\r\n checkSchemaLoad: {\r\n name: \"Check Schema Load\",\r\n resultType: \"CheckSchemaLoadResultRow\",\r\n sqlCommand: \"check_schema_load\",\r\n sqlQuery: `PRAGMA integrity_check(check_schema_load) ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES`,\r\n },\r\n checkMissingChildRows: {\r\n name: \"Check Missing Child Rows\",\r\n resultType: \"CheckMissingChildRowsResultRow\",\r\n sqlCommand: \"check_missing_child_rows\",\r\n sqlQuery: `PRAGMA integrity_check(check_missing_child_rows) ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES`,\r\n },\r\n checkDivergedPropMaps: {\r\n name: \"Check Diverged Property Maps\",\r\n resultType: \"CheckDivergedPropMapsResultRow\",\r\n sqlCommand: \"check_diverged_prop_maps\",\r\n sqlQuery: `PRAGMA integrity_check(check_diverged_prop_maps) ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES`,\r\n },\r\n} as const;\r\n\r\n/**\r\n * Type representing the keys of the integrityCheckType map, which correspond to the different types of integrity checks that can be performed.\r\n */\r\nexport type IntegrityCheckKey = keyof typeof integrityCheckTypeMap;\r\n\r\n/** Map of integrity check keys to their result row types */\r\ninterface IntegrityCheckResultTypeMap {\r\n checkDataColumns: CheckDataColumnsResultRow;\r\n checkECProfile: CheckECProfileResultRow;\r\n checkNavigationClassIds: CheckNavClassIdsResultRow;\r\n checkNavigationIds: CheckNavIdsResultRow;\r\n checkLinktableForeignKeyClassIds: CheckLinkTableFkClassIdsResultRow;\r\n checkLinktableForeignKeyIds: CheckLinkTableFkIdsResultRow;\r\n checkClassIds: CheckClassIdsResultRow;\r\n checkDataSchema: CheckDataSchemaResultRow;\r\n checkSchemaLoad: CheckSchemaLoadResultRow;\r\n checkMissingChildRows: CheckMissingChildRowsResultRow;\r\n checkDivergedPropMaps: CheckDivergedPropMapsResultRow;\r\n}\r\n\r\n/** Checks the Map to give the return type of a specific integrity check */\r\ntype IntegrityCheckResultRow<K extends IntegrityCheckKey> = IntegrityCheckResultTypeMap[K];\r\n\r\n/**\r\n * Return type for quick integrity check\r\n */\r\nexport interface QuickIntegrityCheckResultRow {\r\n /** Name of the integrity check. */\r\n check: string;\r\n /** Whether the check passed. Quick checks do not include problem details. */\r\n passed: boolean;\r\n /** Elapsed time for the check, in seconds. */\r\n elapsedSeconds: string;\r\n}\r\n\r\n/**\r\n * Return type for Check Data Columns integrity check\r\n */\r\nexport interface CheckDataColumnsResultRow {\r\n /** Sequential result row number. */\r\n sno: number;\r\n /** Mapped data table containing a missing column. */\r\n table: string;\r\n /** Name of the missing nonvirtual physical column. */\r\n column: string;\r\n}\r\n\r\n/**\r\n * Return type for Check EC Profile integrity check\r\n */\r\nexport interface CheckECProfileResultRow {\r\n /** Sequential result row number. */\r\n sno: number;\r\n /** Type of EC profile object, such as a table, index, or iModel trigger. */\r\n type: string;\r\n /** Name of the EC profile object. */\r\n name: string;\r\n /** Description of the missing or mismatching object definition. */\r\n issue: string;\r\n}\r\n\r\n/**\r\n * Return type for Check Navigation Class Ids integrity check\r\n */\r\nexport interface CheckNavClassIdsResultRow {\r\n /** Sequential result row number. */\r\n sno: number;\r\n /** ID of the source instance row containing the navigation property. */\r\n id: string;\r\n /** Declaring or scanned class for the source row; rows from derived classes may be included. */\r\n class: string;\r\n /** Name of the navigation property. */\r\n property: string;\r\n /** ID of the referenced instance stored by the navigation property. */\r\n navId: string;\r\n /** Relationship class ID stored by the navigation property, not the target instance class ID. */\r\n navClassId: string;\r\n}\r\n\r\n/**\r\n * Return type for Check Navigation Ids integrity check\r\n */\r\nexport interface CheckNavIdsResultRow {\r\n /** Sequential result row number. */\r\n sno: number;\r\n /** ID of the source instance row containing the navigation property. */\r\n id: string;\r\n /** Declaring or scanned class for the source row; rows from derived classes may be included. */\r\n class: string;\r\n /** Name of the navigation property. */\r\n property: string;\r\n /** ID of the referenced instance stored by the navigation property. */\r\n navId: string;\r\n /** Class queried for the referenced row: the first relationship constraint class in the navigation direction, including derived classes. */\r\n primaryClass: string;\r\n}\r\n\r\n/**\r\n * Return type for Check Link Table Foreign Key Class Ids integrity check\r\n */\r\nexport interface CheckLinkTableFkClassIdsResultRow {\r\n /** Sequential result row number. */\r\n sno: number;\r\n /** ID of the relationship row containing the foreign key. */\r\n id: string;\r\n /** Link-table relationship class. */\r\n relationship: string;\r\n /** Endpoint class-ID property: SourceECClassId or TargetECClassId. */\r\n property: string;\r\n /** Source or target endpoint instance ID stored in the link table. */\r\n keyId: string;\r\n /** Source or target endpoint class ID; the check verifies that the class exists. */\r\n keyClassId: string;\r\n}\r\n\r\n/**\r\n * Return type for Check Link Table Foreign Key Ids integrity check\r\n */\r\nexport interface CheckLinkTableFkIdsResultRow {\r\n /** Sequential result row number. */\r\n sno: number;\r\n /** ID of the relationship row containing the foreign key. */\r\n id: string;\r\n /** Link-table relationship class. */\r\n relationship: string;\r\n /** Endpoint instance-ID property: SourceECInstanceId or TargetECInstanceId. */\r\n property: string;\r\n /** Source or target endpoint instance ID stored in the link table. */\r\n keyId: string;\r\n /** Class queried for the referenced endpoint row: the first endpoint constraint class, including derived classes. */\r\n primaryClass: string;\r\n}\r\n\r\n/**\r\n * Return type for Check Class Ids integrity check\r\n */\r\nexport interface CheckClassIdsResultRow {\r\n /** Sequential result row number. */\r\n sno: number;\r\n /** Declaring or scanned class for the row; rows from derived classes may be included. */\r\n class: string;\r\n /** ECInstanceId for primary/joined results, or the physical RowId for overflow results. */\r\n id: string;\r\n /** Persisted ECClassId value with no matching class definition. */\r\n classId: string;\r\n /** Check category: \"primary\", \"joined\", or \"overflow\". */\r\n type: string;\r\n}\r\n\r\n/**\r\n * Return type for Check Data Schema integrity check\r\n */\r\nexport interface CheckDataSchemaResultRow {\r\n /** Sequential result row number. */\r\n sno: number;\r\n /** Type of missing mapped schema object, such as a table or index. */\r\n type: string;\r\n /** Name of the missing mapped schema object. */\r\n name: string;\r\n}\r\n\r\n/**\r\n * Return type for Check Schema Load integrity check\r\n */\r\nexport interface CheckSchemaLoadResultRow {\r\n /** Sequential result row number. */\r\n sno: number;\r\n /** Name of the schema that the schema manager could not load. */\r\n schema: string;\r\n}\r\n\r\n/**\r\n * Return type for Check Missing Child Rows integrity check\r\n */\r\nexport interface CheckMissingChildRowsResultRow {\r\n /** Sequential result row number. */\r\n sno: number;\r\n /** Class used to identify the checked rows: \"BisCore:Element\". */\r\n class: string;\r\n /** ID of the existing bis_Element row missing a required child row. */\r\n id: string;\r\n /** Persisted ECClassId of the existing element row. */\r\n classId: string;\r\n /** Comma-separated names of all child tables checked for the row, not only tables with a missing child row. */\r\n missingRowInTables: string;\r\n}\r\n\r\n/**\r\n * Return type for Check Diverged Property Maps integrity check\r\n */\r\nexport interface CheckDivergedPropMapsResultRow {\r\n /** Sequential result row number. */\r\n sno: number;\r\n /** ID of the derived class whose inherited property map diverges. */\r\n derivedClassId: Id64String;\r\n /** Name of the derived class whose inherited property map diverges. */\r\n derivedClassName: string;\r\n /** ID of the base class whose mapping was compared with the derived class. */\r\n baseClassId: Id64String;\r\n /** Name of the base class whose mapping was compared with the derived class. */\r\n baseClassName: string;\r\n /** Access path of the inherited property with different column mappings. */\r\n propertyName: string;\r\n /** Base class mapping, formatted as table.column. */\r\n baseColumn: string;\r\n /** Derived class mapping, formatted as table.column. */\r\n divergedColumn: string;\r\n}\r\n\r\n/**\r\n * Return type for integrity check results, including the check name, whether it passed, and the specific results (if any)\r\n */\r\nexport interface IntegrityCheckResult {\r\n /** The name of the integrity check that was performed */\r\n check: string;\r\n /** Whether the integrity check passed (i.e. no issues were found = true) */\r\n passed: boolean;\r\n /** The specific results returned by the integrity check, which may include details about any issues that were found.\r\n * In the case where issues are found, this will be an array of result rows specific to the type of check that was performed,\r\n * or an array of quick integrity check results if it was a quick check. */\r\n results: IntegrityCheckResultRow<IntegrityCheckKey>[] | QuickIntegrityCheckResultRow[];\r\n}\r\n\r\n/**\r\n * Gets the user-friendly name of an integrity check based on its key or SQL command.\r\n * It first attempts to find a direct match for the key in the integrityCheckTypeMap. If not found, it searches for a match based on the SQL command.\r\n * If still not found, it returns the original check string.\r\n * @param check - The integrity check key or SQL command to get the name of\r\n * @returns The user-friendly name of the integrity check, or the original check string if no match is found\r\n * @internal\r\n */\r\nexport function getIntegrityCheckName(check: string): string {\r\n // First try direct lookup by key\r\n const directLookup = integrityCheckTypeMap[check as IntegrityCheckKey];\r\n if (directLookup) {\r\n return directLookup.name;\r\n }\r\n // If not found, search by sqlCommand\r\n for (const [, value] of Object.entries(integrityCheckTypeMap)) {\r\n if (value.sqlCommand === check) {\r\n return value.name;\r\n }\r\n }\r\n // Fallback to the original check string\r\n return check;\r\n}\r\n\r\n/**\r\n * Performs a quick integrity check on the given iModel.\r\n * @param iModel The IModelDb instance to perform the integrity check on\r\n * @returns An array of results for each check performed, including the check name, whether it passed, and the elapsed time in seconds\r\n * @internal\r\n */\r\nexport async function performQuickIntegrityCheck(iModel: IModelDb): Promise<QuickIntegrityCheckResultRow[]> {\r\n const integrityCheckQuery = \"PRAGMA integrity_check ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES\";\r\n const integrityCheckResults: QuickIntegrityCheckResultRow[] = [];\r\n for await (const row of iModel.createQueryReader(integrityCheckQuery, undefined, { usePrimaryConn: true })) {\r\n integrityCheckResults.push({ check: getIntegrityCheckName(row.check), passed: row.result, elapsedSeconds: row.elapsed_sec });\r\n };\r\n return integrityCheckResults;\r\n}\r\n\r\n/**\r\n * Performs a specific integrity check on the given iModel based on the provided check key, and returns the results specific to that check type.\r\n * @param iModel The IModelDb instance to perform the integrity check on\r\n * @param check The key of the specific integrity check to perform\r\n * @return An array of results specific to the integrity check that was performed. The type of the result rows will depend on the check that was executed.\r\n * @throws IModelError with status BadRequest if an unknown integrity check key is provided\r\n * @internal\r\n */\r\nexport async function performSpecificIntegrityCheck(iModel: IModelDb, check: \"checkDataColumns\"): Promise<IntegrityCheckResultRow<\"checkDataColumns\">[]>;\r\nexport async function performSpecificIntegrityCheck(iModel: IModelDb, check: \"checkECProfile\"): Promise<IntegrityCheckResultRow<\"checkECProfile\">[]>;\r\nexport async function performSpecificIntegrityCheck(iModel: IModelDb, check: \"checkNavigationClassIds\"): Promise<IntegrityCheckResultRow<\"checkNavigationClassIds\">[]>;\r\nexport async function performSpecificIntegrityCheck(iModel: IModelDb, check: \"checkNavigationIds\"): Promise<IntegrityCheckResultRow<\"checkNavigationIds\">[]>;\r\nexport async function performSpecificIntegrityCheck(iModel: IModelDb, check: \"checkLinktableForeignKeyClassIds\"): Promise<IntegrityCheckResultRow<\"checkLinktableForeignKeyClassIds\">[]>;\r\nexport async function performSpecificIntegrityCheck(iModel: IModelDb, check: \"checkLinktableForeignKeyIds\"): Promise<IntegrityCheckResultRow<\"checkLinktableForeignKeyIds\">[]>;\r\nexport async function performSpecificIntegrityCheck(iModel: IModelDb, check: \"checkClassIds\"): Promise<IntegrityCheckResultRow<\"checkClassIds\">[]>;\r\nexport async function performSpecificIntegrityCheck(iModel: IModelDb, check: \"checkDataSchema\"): Promise<IntegrityCheckResultRow<\"checkDataSchema\">[]>;\r\nexport async function performSpecificIntegrityCheck(iModel: IModelDb, check: \"checkSchemaLoad\"): Promise<IntegrityCheckResultRow<\"checkSchemaLoad\">[]>;\r\nexport async function performSpecificIntegrityCheck(iModel: IModelDb, check: \"checkMissingChildRows\"): Promise<IntegrityCheckResultRow<\"checkMissingChildRows\">[]>;\r\nexport async function performSpecificIntegrityCheck(iModel: IModelDb, check: \"checkDivergedPropMaps\"): Promise<IntegrityCheckResultRow<\"checkDivergedPropMaps\">[]>;\r\nexport async function performSpecificIntegrityCheck<K extends IntegrityCheckKey>(iModel: IModelDb, check: K): Promise<IntegrityCheckResultRow<K>[]>;\r\nexport async function performSpecificIntegrityCheck(iModel: IModelDb, check: IntegrityCheckKey): Promise<IntegrityCheckResultRow<IntegrityCheckKey>[]> {\r\n switch (check) {\r\n case \"checkDataColumns\": {\r\n const results: CheckDataColumnsResultRow[] = [];\r\n for await (const row of iModel.createQueryReader(integrityCheckTypeMap.checkDataColumns.sqlQuery, undefined, { usePrimaryConn: true })) {\r\n results.push({ sno: row.sno, table: row.table, column: row.column });\r\n }\r\n return results;\r\n }\r\n case \"checkECProfile\": {\r\n const results: CheckECProfileResultRow[] = [];\r\n for await (const row of iModel.createQueryReader(integrityCheckTypeMap.checkECProfile.sqlQuery, undefined, { usePrimaryConn: true })) {\r\n results.push({ sno: row.sno, type: row.type, name: row.name, issue: row.issue });\r\n }\r\n return results;\r\n }\r\n case \"checkNavigationClassIds\": {\r\n const results: CheckNavClassIdsResultRow[] = [];\r\n for await (const row of iModel.createQueryReader(integrityCheckTypeMap.checkNavigationClassIds.sqlQuery, undefined, { usePrimaryConn: true })) {\r\n results.push({ sno: row.sno, id: row.id, class: row.class, property: row.property, navId: row.nav_id, navClassId: row.nav_classId });\r\n }\r\n return results;\r\n }\r\n case \"checkNavigationIds\": {\r\n const results: CheckNavIdsResultRow[] = [];\r\n for await (const row of iModel.createQueryReader(integrityCheckTypeMap.checkNavigationIds.sqlQuery, undefined, { usePrimaryConn: true })) {\r\n results.push({ sno: row.sno, id: row.id, class: row.class, property: row.property, navId: row.nav_id, primaryClass: row.primary_class });\r\n }\r\n return results;\r\n }\r\n case \"checkLinktableForeignKeyClassIds\": {\r\n const results: CheckLinkTableFkClassIdsResultRow[] = [];\r\n for await (const row of iModel.createQueryReader(integrityCheckTypeMap.checkLinktableForeignKeyClassIds.sqlQuery, undefined, { usePrimaryConn: true })) {\r\n results.push({ sno: row.sno, id: row.id, relationship: row.relationship, property: row.property, keyId: row.key_id, keyClassId: row.key_classId });\r\n }\r\n return results;\r\n }\r\n case \"checkLinktableForeignKeyIds\": {\r\n const results: CheckLinkTableFkIdsResultRow[] = [];\r\n for await (const row of iModel.createQueryReader(integrityCheckTypeMap.checkLinktableForeignKeyIds.sqlQuery, undefined, { usePrimaryConn: true })) {\r\n results.push({ sno: row.sno, id: row.id, relationship: row.relationship, property: row.property, keyId: row.key_id, primaryClass: row.primary_class });\r\n }\r\n return results;\r\n }\r\n case \"checkClassIds\": {\r\n const results: CheckClassIdsResultRow[] = [];\r\n for await (const row of iModel.createQueryReader(integrityCheckTypeMap.checkClassIds.sqlQuery, undefined, { usePrimaryConn: true })) {\r\n results.push({ sno: row.sno, class: row.class, id: row.id, classId: row.class_id, type: row.type });\r\n }\r\n return results;\r\n }\r\n case \"checkDataSchema\": {\r\n const results: CheckDataSchemaResultRow[] = [];\r\n for await (const row of iModel.createQueryReader(integrityCheckTypeMap.checkDataSchema.sqlQuery, undefined, { usePrimaryConn: true })) {\r\n results.push({ sno: row.sno, type: row.type, name: row.name });\r\n }\r\n return results;\r\n }\r\n case \"checkSchemaLoad\": {\r\n const results: CheckSchemaLoadResultRow[] = [];\r\n for await (const row of iModel.createQueryReader(integrityCheckTypeMap.checkSchemaLoad.sqlQuery, undefined, { usePrimaryConn: true })) {\r\n results.push({ sno: row.sno, schema: row.schema });\r\n }\r\n return results;\r\n }\r\n case \"checkMissingChildRows\": {\r\n const results: CheckMissingChildRowsResultRow[] = [];\r\n for await (const row of iModel.createQueryReader(integrityCheckTypeMap.checkMissingChildRows.sqlQuery, undefined, { usePrimaryConn: true })) {\r\n results.push({ sno: row.sno, class: row.class, id: row.id, classId: row.class_id, missingRowInTables: row.MissingRowInTables });\r\n }\r\n return results;\r\n }\r\n case \"checkDivergedPropMaps\": {\r\n const results: CheckDivergedPropMapsResultRow[] = [];\r\n for await (const row of iModel.createQueryReader(integrityCheckTypeMap.checkDivergedPropMaps.sqlQuery, undefined, { usePrimaryConn: true })) {\r\n results.push({ sno: row.sno, derivedClassId: row.derivedClassId, derivedClassName: row.derivedClassName, baseClassId: row.baseClassId, baseClassName: row.baseClassName, propertyName: row.propertyName, baseColumn: row.baseColumn, divergedColumn: row.divergedColumn });\r\n }\r\n return results;\r\n }\r\n default:\r\n throw new IModelError(IModelStatus.BadRequest, `Unknown integrity check type`);\r\n }\r\n}"]}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { FieldValue, QuantityFieldFormatOptions } from "@itwin/core-common";
|
|
2
|
+
import { FormatterSpec, FormattingSpecArgs, SyncFormatsProvider, SyncUnitsProvider } from "@itwin/core-quantity";
|
|
3
|
+
import { SchemaContext } from "@itwin/ecschema-metadata";
|
|
4
|
+
import type { FieldFormattingArgs } from "../../annotations/ElementDrivesTextAnnotation";
|
|
5
|
+
import type { IModelDb } from "../../IModelDb";
|
|
6
|
+
/** A [FieldValue]($common) as the backend resolves it: the primitive value plus, for
|
|
7
|
+
* `"quantity"` and `"coordinate"` types, the KindOfQuantity and persistence unit of the EC
|
|
8
|
+
* property it was read from. These serve as the fallback when the field's own
|
|
9
|
+
* [QuantityFieldFormatOptions]($common) do not resolve.
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export interface ResolvedFieldValue extends FieldValue {
|
|
13
|
+
/** EC full name of the property's KindOfQuantity, e.g. `"AecUnits.LENGTH"`, if it has one. */
|
|
14
|
+
kindOfQuantityFullName?: string;
|
|
15
|
+
/** EC full name of the unit the stored magnitude is expressed in, e.g. `"Units.M"`. */
|
|
16
|
+
persistenceUnitFullName?: string;
|
|
17
|
+
}
|
|
18
|
+
/** The formats an iModel's fields resolve through, as configured by
|
|
19
|
+
* [ElementDrivesTextAnnotation.registerFieldFormatting]($backend) or defaulted from the iModel's
|
|
20
|
+
* schemas. Holds only providers; every [FormatterSpec]($core-quantity) is built on demand by
|
|
21
|
+
* [[lookupFieldSpec]] and discarded after the field is formatted. Building one costs on the order
|
|
22
|
+
* of a microsecond, so nothing is cached.
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
export interface FieldFormatting {
|
|
26
|
+
readonly schemaContext: SchemaContext;
|
|
27
|
+
readonly unitsProvider: SyncUnitsProvider;
|
|
28
|
+
/** The adopted FormatSet layered over the iModel's schema formats, or the schema formats alone. */
|
|
29
|
+
readonly defaultFormats: SyncFormatsProvider;
|
|
30
|
+
/** Per-field FormatSets by id, each falling through to [[defaultFormats]]. */
|
|
31
|
+
readonly formatSets: ReadonlyMap<string, SyncFormatsProvider>;
|
|
32
|
+
}
|
|
33
|
+
/** Returns the formats `iModel`'s fields resolve through, creating the schema-only default on
|
|
34
|
+
* first use.
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
export declare function getFieldFormatting(iModel: IModelDb): FieldFormatting;
|
|
38
|
+
/** Replaces the formats `iModel`'s fields resolve through.
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
export declare function setFieldFormatting(iModel: IModelDb, formatting: FieldFormatting): void;
|
|
42
|
+
/** @internal */
|
|
43
|
+
export declare function createFieldFormatting(args: FieldFormattingArgs): FieldFormatting;
|
|
44
|
+
/** Builds the [FormatterSpec]($core-quantity) for `args`, or `undefined` when the
|
|
45
|
+
* format fails to resolve, the persistence unit is not a bundled BIS unit, the format names a
|
|
46
|
+
* unit that is not, or the two cannot be converted between -- leaving the caller on the same
|
|
47
|
+
* fallback as any other unresolved override.
|
|
48
|
+
* @internal
|
|
49
|
+
*/
|
|
50
|
+
export declare function buildFieldFormatterSpec(args: FormattingSpecArgs, formatsProvider: SyncFormatsProvider, formatting: FieldFormatting): FormatterSpec | undefined;
|
|
51
|
+
/** Builds the (KindOfQuantity, persistence unit) pairs a quantity/coordinate value may format
|
|
52
|
+
* through, in priority order: the field's override pair first, then the property's own pair.
|
|
53
|
+
* Names are compared exactly, so callers pass override names already normalized to the schema's
|
|
54
|
+
* spelling.
|
|
55
|
+
*
|
|
56
|
+
* The two halves fall back differently. `kindOfQuantity` only chooses how the magnitude is
|
|
57
|
+
* displayed, so the override wins and the property's is the fallback. `persistenceUnit` states
|
|
58
|
+
* what the stored magnitude *means*, so the property's own unit is authoritative when it has one;
|
|
59
|
+
* the override only supplies a unit for a property that lacks one (a coordinate, a plain double,
|
|
60
|
+
* a JSON leaf). See [[lookupFieldSpec]] for reporting an override that was ignored this way.
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
export declare function collectFieldQuantityPairs(args: {
|
|
64
|
+
overrideName?: string;
|
|
65
|
+
overridePersistence?: string;
|
|
66
|
+
propertyName?: string;
|
|
67
|
+
propertyPersistence?: string;
|
|
68
|
+
}): FormattingSpecArgs[];
|
|
69
|
+
/** Builds the first [FormatterSpec]($core-quantity) that resolves for `value` among the formats
|
|
70
|
+
* of the FormatSet named by `quantityOptions.formatSet` -- or the adopted FormatSet and schema
|
|
71
|
+
* formats when it names none, or one that was never registered -- along with the pairs that were
|
|
72
|
+
* tried, so the caller can report when none resolved. `ignoredPersistenceUnit` is set when the
|
|
73
|
+
* field's `persistenceUnit` named a unit other than the property's own and was therefore not
|
|
74
|
+
* used, so the caller can report the likely authoring mistake.
|
|
75
|
+
* @internal
|
|
76
|
+
*/
|
|
77
|
+
export declare function lookupFieldSpec(quantityOptions: QuantityFieldFormatOptions | undefined, value: ResolvedFieldValue, formatting: FieldFormatting): {
|
|
78
|
+
spec?: FormatterSpec;
|
|
79
|
+
candidates: FormattingSpecArgs[];
|
|
80
|
+
ignoredPersistenceUnit?: string;
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=fieldSpecs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fieldSpecs.d.ts","sourceRoot":"","sources":["../../../../src/internal/annotations/fieldSpecs.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,E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C,IAAI,EAAE;IAC9C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,GAAG,kBAAkB,EAAE,CAevB;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,eAAe,EAAE,0BAA0B,GAAG,SAAS,EACvD,KAAK,EAAE,kBAAkB,EACzB,UAAU,EAAE,eAAe,GAC1B;IAAE,IAAI,CAAC,EAAE,aAAa,CAAC;IAAC,UAAU,EAAE,kBAAkB,EAAE,CAAC;IAAC,sBAAsB,CAAC,EAAE,MAAM,CAAA;CAAE,CAoB7F"}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.getFieldFormatting = getFieldFormatting;
|
|
8
|
+
exports.setFieldFormatting = setFieldFormatting;
|
|
9
|
+
exports.createFieldFormatting = createFieldFormatting;
|
|
10
|
+
exports.buildFieldFormatterSpec = buildFieldFormatterSpec;
|
|
11
|
+
exports.collectFieldQuantityPairs = collectFieldQuantityPairs;
|
|
12
|
+
exports.lookupFieldSpec = lookupFieldSpec;
|
|
13
|
+
const core_quantity_1 = require("@itwin/core-quantity");
|
|
14
|
+
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
15
|
+
/** Per-iModel [[FieldFormatting]], as configured by the last
|
|
16
|
+
* [ElementDrivesTextAnnotation.registerFieldFormatting]($backend) call, or the schema-only default
|
|
17
|
+
* created the first time one of the iModel's fields was evaluated. Weakly keyed so a closed iModel
|
|
18
|
+
* takes its entry with it.
|
|
19
|
+
*/
|
|
20
|
+
const fieldFormattings = new WeakMap();
|
|
21
|
+
/** Returns the formats `iModel`'s fields resolve through, creating the schema-only default on
|
|
22
|
+
* first use.
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
function getFieldFormatting(iModel) {
|
|
26
|
+
let formatting = fieldFormattings.get(iModel);
|
|
27
|
+
if (!formatting) {
|
|
28
|
+
formatting = createFieldFormatting({ iModel });
|
|
29
|
+
fieldFormattings.set(iModel, formatting);
|
|
30
|
+
}
|
|
31
|
+
return formatting;
|
|
32
|
+
}
|
|
33
|
+
/** Replaces the formats `iModel`'s fields resolve through.
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
function setFieldFormatting(iModel, formatting) {
|
|
37
|
+
fieldFormattings.set(iModel, formatting);
|
|
38
|
+
}
|
|
39
|
+
/** @internal */
|
|
40
|
+
function createFieldFormatting(args) {
|
|
41
|
+
// An adopted FormatSet declares the unit system it was authored for; honor it unless the
|
|
42
|
+
// caller says otherwise.
|
|
43
|
+
const unitSystem = args.unitSystem ?? args.formatSet?.unitSystem ?? "metric";
|
|
44
|
+
const schemaContext = args.iModel.schemaContext;
|
|
45
|
+
const schemaFormats = new ecschema_metadata_1.SchemaFormatsProvider(schemaContext, unitSystem);
|
|
46
|
+
// Every per-field FormatSet falls through to this same chain, so a field naming a FormatSet
|
|
47
|
+
// that has no entry for its KindOfQuantity still sees the adopted presentation before the
|
|
48
|
+
// schema's, matching the documented resolution order.
|
|
49
|
+
const defaultFormats = args.formatSet ? new ecschema_metadata_1.FormatSetFormatsProvider({ formatSet: args.formatSet, fallbackProvider: schemaFormats }) : schemaFormats;
|
|
50
|
+
const formatSets = new Map();
|
|
51
|
+
for (const { id, formatSet } of args.formatSets ?? []) {
|
|
52
|
+
formatSets.set(id, new ecschema_metadata_1.FormatSetFormatsProvider({ formatSet, fallbackProvider: defaultFormats }));
|
|
53
|
+
}
|
|
54
|
+
return { schemaContext, unitsProvider: new core_quantity_1.BasicUnitsProvider(), defaultFormats, formatSets };
|
|
55
|
+
}
|
|
56
|
+
/** [SchemaFormatsProvider.getFormatSync]($ecschema-metadata) reads only schemas already in the
|
|
57
|
+
* context's cache; it never asks a locater to load one. The backend locater *can* load
|
|
58
|
+
* synchronously, so ask the context for the schema first. That pulls it -- and the `Formats` and
|
|
59
|
+
* `Units` schemas it references -- into the cache. A name whose schema the iModel lacks (a key
|
|
60
|
+
* defined only by a FormatSet, say) is left for the formats provider to resolve or reject.
|
|
61
|
+
*/
|
|
62
|
+
function ensureSchemaLoaded(context, fullName) {
|
|
63
|
+
const [schemaName] = ecschema_metadata_1.SchemaItem.parseFullName(fullName);
|
|
64
|
+
if (!schemaName) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
context.getSchemaSync(new ecschema_metadata_1.SchemaKey(schemaName));
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
// Not a schema this iModel knows.
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/** Builds the [FormatterSpec]($core-quantity) for `args`, or `undefined` when the
|
|
75
|
+
* format fails to resolve, the persistence unit is not a bundled BIS unit, the format names a
|
|
76
|
+
* unit that is not, or the two cannot be converted between -- leaving the caller on the same
|
|
77
|
+
* fallback as any other unresolved override.
|
|
78
|
+
* @internal
|
|
79
|
+
*/
|
|
80
|
+
function buildFieldFormatterSpec(args, formatsProvider, formatting) {
|
|
81
|
+
const { unitsProvider, schemaContext } = formatting;
|
|
82
|
+
ensureSchemaLoaded(schemaContext, args.name);
|
|
83
|
+
const formatProps = formatsProvider.getFormatSync(args.name, args.system);
|
|
84
|
+
if (!formatProps) {
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
// BasicUnitsProvider reports an unknown unit as an invalid BadUnit rather than throwing.
|
|
88
|
+
const persistenceUnit = unitsProvider.findUnitByNameSync(args.persistenceUnitName);
|
|
89
|
+
if (!persistenceUnit.isValid) {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
let formatterSpec;
|
|
93
|
+
try {
|
|
94
|
+
const format = core_quantity_1.Format.createFromJSONSync("fieldFormat", unitsProvider, formatProps);
|
|
95
|
+
formatterSpec = core_quantity_1.FormatterSpec.createSync("fieldFormat", format, unitsProvider, persistenceUnit);
|
|
96
|
+
}
|
|
97
|
+
catch (err) {
|
|
98
|
+
// A format naming a unit the bundled provider lacks can't be resolved.
|
|
99
|
+
if (err instanceof core_quantity_1.QuantityError) {
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
throw err;
|
|
103
|
+
}
|
|
104
|
+
// Reject a format whose units belong to a different phenomenon than the persisted value.
|
|
105
|
+
// SyncUnitsProvider.getConversionSync reports this by returning the identity conversion tagged
|
|
106
|
+
// `error: true`, and its contract requires callers to check that flag before applying the
|
|
107
|
+
// result. FormatterSpec.createSync only logs a warning and keeps the identity conversion, so
|
|
108
|
+
// without this check a length persisted in meters would render through an angle format as
|
|
109
|
+
// "2.5 deg" -- relabelled rather than converted.
|
|
110
|
+
if (formatterSpec.unitConversions.some((conversion) => conversion.conversion.error)) {
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
113
|
+
return formatterSpec;
|
|
114
|
+
}
|
|
115
|
+
/** Returns `name` as the iModel's schemas spell it (`Units.M` for `units:m`), so later lookups
|
|
116
|
+
* and comparisons can be exact: [BasicUnitsProvider.findUnitByNameSync]($core-quantity) only
|
|
117
|
+
* recognizes the canonical spelling. An empty name counts as unset. A name no schema defines,
|
|
118
|
+
* such as a KindOfQuantity only a FormatSet declares, is returned unchanged.
|
|
119
|
+
*/
|
|
120
|
+
function normalizeToSchemaName(context, name) {
|
|
121
|
+
if (!name) {
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
try {
|
|
125
|
+
return context.getSchemaItemSync(name)?.fullName ?? name;
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
// Not a schema this iModel knows.
|
|
129
|
+
return name;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/** Builds the (KindOfQuantity, persistence unit) pairs a quantity/coordinate value may format
|
|
133
|
+
* through, in priority order: the field's override pair first, then the property's own pair.
|
|
134
|
+
* Names are compared exactly, so callers pass override names already normalized to the schema's
|
|
135
|
+
* spelling.
|
|
136
|
+
*
|
|
137
|
+
* The two halves fall back differently. `kindOfQuantity` only chooses how the magnitude is
|
|
138
|
+
* displayed, so the override wins and the property's is the fallback. `persistenceUnit` states
|
|
139
|
+
* what the stored magnitude *means*, so the property's own unit is authoritative when it has one;
|
|
140
|
+
* the override only supplies a unit for a property that lacks one (a coordinate, a plain double,
|
|
141
|
+
* a JSON leaf). See [[lookupFieldSpec]] for reporting an override that was ignored this way.
|
|
142
|
+
* @internal
|
|
143
|
+
*/
|
|
144
|
+
function collectFieldQuantityPairs(args) {
|
|
145
|
+
const { overrideName, overridePersistence, propertyName, propertyPersistence } = args;
|
|
146
|
+
const name = overrideName ?? propertyName;
|
|
147
|
+
const persistenceUnitName = propertyPersistence ?? overridePersistence;
|
|
148
|
+
const pairs = [];
|
|
149
|
+
if (name && persistenceUnitName) {
|
|
150
|
+
pairs.push({ name, persistenceUnitName });
|
|
151
|
+
}
|
|
152
|
+
// Fall back to the property's own pair unless the pair above already is it.
|
|
153
|
+
if (propertyName && propertyPersistence && name !== propertyName) {
|
|
154
|
+
pairs.push({ name: propertyName, persistenceUnitName: propertyPersistence });
|
|
155
|
+
}
|
|
156
|
+
return pairs;
|
|
157
|
+
}
|
|
158
|
+
/** Builds the first [FormatterSpec]($core-quantity) that resolves for `value` among the formats
|
|
159
|
+
* of the FormatSet named by `quantityOptions.formatSet` -- or the adopted FormatSet and schema
|
|
160
|
+
* formats when it names none, or one that was never registered -- along with the pairs that were
|
|
161
|
+
* tried, so the caller can report when none resolved. `ignoredPersistenceUnit` is set when the
|
|
162
|
+
* field's `persistenceUnit` named a unit other than the property's own and was therefore not
|
|
163
|
+
* used, so the caller can report the likely authoring mistake.
|
|
164
|
+
* @internal
|
|
165
|
+
*/
|
|
166
|
+
function lookupFieldSpec(quantityOptions, value, formatting) {
|
|
167
|
+
const overridePersistence = normalizeToSchemaName(formatting.schemaContext, quantityOptions?.persistenceUnit);
|
|
168
|
+
const propertyPersistence = value.persistenceUnitFullName;
|
|
169
|
+
const ignoredPersistenceUnit = overridePersistence && propertyPersistence && overridePersistence !== propertyPersistence
|
|
170
|
+
? overridePersistence : undefined;
|
|
171
|
+
const candidates = collectFieldQuantityPairs({
|
|
172
|
+
overrideName: normalizeToSchemaName(formatting.schemaContext, quantityOptions?.kindOfQuantity),
|
|
173
|
+
overridePersistence,
|
|
174
|
+
propertyName: value.kindOfQuantityFullName,
|
|
175
|
+
propertyPersistence,
|
|
176
|
+
});
|
|
177
|
+
const formatSet = quantityOptions?.formatSet;
|
|
178
|
+
const formats = (formatSet ? formatting.formatSets.get(formatSet) : undefined) ?? formatting.defaultFormats;
|
|
179
|
+
for (const candidate of candidates) {
|
|
180
|
+
const spec = buildFieldFormatterSpec(candidate, formats, formatting);
|
|
181
|
+
if (spec) {
|
|
182
|
+
return { spec, candidates, ignoredPersistenceUnit };
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return { candidates, ignoredPersistenceUnit };
|
|
186
|
+
}
|
|
187
|
+
//# sourceMappingURL=fieldSpecs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fieldSpecs.js","sourceRoot":"","sources":["../../../../src/internal/annotations/fieldSpecs.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;AAkD/F,gDAQC;AAKD,gDAEC;AAGD,sDAgBC;AA2BD,0DAqCC;AAgCD,8DAoBC;AAUD,0CAwBC;AAvOD,wDAE8B;AAC9B,gEAAiI;AAiCjI;;;;GAIG;AACH,MAAM,gBAAgB,GAAG,IAAI,OAAO,EAA6B,CAAC;AAElE;;;GAGG;AACH,SAAgB,kBAAkB,CAAC,MAAgB;IACjD,IAA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AAC;IACH,CAAC;IACD,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,CAAC;AAChD,CAAC","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\r\nimport { FieldValue, QuantityFieldFormatOptions } from \"@itwin/core-common\";\r\nimport {\r\n BasicUnitsProvider, Format, FormatterSpec, FormattingSpecArgs, QuantityError, SyncFormatsProvider, SyncUnitsProvider,\r\n} from \"@itwin/core-quantity\";\r\nimport { FormatSetFormatsProvider, SchemaContext, SchemaFormatsProvider, SchemaItem, SchemaKey } from \"@itwin/ecschema-metadata\";\r\nimport type { FieldFormattingArgs } from \"../../annotations/ElementDrivesTextAnnotation\";\r\nimport type { IModelDb } from \"../../IModelDb\";\r\n\r\n/** A [FieldValue]($common) as the backend resolves it: the primitive value plus, for\r\n * `\"quantity\"` and `\"coordinate\"` types, the KindOfQuantity and persistence unit of the EC\r\n * property it was read from. These serve as the fallback when the field's own\r\n * [QuantityFieldFormatOptions]($common) do not resolve.\r\n * @internal\r\n */\r\nexport interface ResolvedFieldValue extends FieldValue {\r\n /** EC full name of the property's KindOfQuantity, e.g. `\"AecUnits.LENGTH\"`, if it has one. */\r\n kindOfQuantityFullName?: string;\r\n /** EC full name of the unit the stored magnitude is expressed in, e.g. `\"Units.M\"`. */\r\n persistenceUnitFullName?: string;\r\n}\r\n\r\n/** The formats an iModel's fields resolve through, as configured by\r\n * [ElementDrivesTextAnnotation.registerFieldFormatting]($backend) or defaulted from the iModel's\r\n * schemas. Holds only providers; every [FormatterSpec]($core-quantity) is built on demand by\r\n * [[lookupFieldSpec]] and discarded after the field is formatted. Building one costs on the order\r\n * of a microsecond, so nothing is cached.\r\n * @internal\r\n */\r\nexport interface FieldFormatting {\r\n readonly schemaContext: SchemaContext;\r\n readonly unitsProvider: SyncUnitsProvider;\r\n /** The adopted FormatSet layered over the iModel's schema formats, or the schema formats alone. */\r\n readonly defaultFormats: SyncFormatsProvider;\r\n /** Per-field FormatSets by id, each falling through to [[defaultFormats]]. */\r\n readonly formatSets: ReadonlyMap<string, SyncFormatsProvider>;\r\n}\r\n\r\n/** Per-iModel [[FieldFormatting]], as configured by the last\r\n * [ElementDrivesTextAnnotation.registerFieldFormatting]($backend) call, or the schema-only default\r\n * created the first time one of the iModel's fields was evaluated. Weakly keyed so a closed iModel\r\n * takes its entry with it.\r\n */\r\nconst fieldFormattings = new WeakMap<IModelDb, FieldFormatting>();\r\n\r\n/** Returns the formats `iModel`'s fields resolve through, creating the schema-only default on\r\n * first use.\r\n * @internal\r\n */\r\nexport function getFieldFormatting(iModel: IModelDb): FieldFormatting {\r\n let formatting = fieldFormattings.get(iModel);\r\n if (!formatting) {\r\n formatting = createFieldFormatting({ iModel });\r\n fieldFormattings.set(iModel, formatting);\r\n }\r\n\r\n return formatting;\r\n}\r\n\r\n/** Replaces the formats `iModel`'s fields resolve through.\r\n * @internal\r\n */\r\nexport function setFieldFormatting(iModel: IModelDb, formatting: FieldFormatting): void {\r\n fieldFormattings.set(iModel, formatting);\r\n}\r\n\r\n/** @internal */\r\nexport function createFieldFormatting(args: FieldFormattingArgs): FieldFormatting {\r\n // An adopted FormatSet declares the unit system it was authored for; honor it unless the\r\n // caller says otherwise.\r\n const unitSystem = args.unitSystem ?? args.formatSet?.unitSystem ?? \"metric\";\r\n const schemaContext = args.iModel.schemaContext;\r\n const schemaFormats = new SchemaFormatsProvider(schemaContext, unitSystem);\r\n // Every per-field FormatSet falls through to this same chain, so a field naming a FormatSet\r\n // that has no entry for its KindOfQuantity still sees the adopted presentation before the\r\n // schema's, matching the documented resolution order.\r\n const defaultFormats = args.formatSet ? new FormatSetFormatsProvider({ formatSet: args.formatSet, fallbackProvider: schemaFormats }) : schemaFormats;\r\n const formatSets = new Map<string, SyncFormatsProvider>();\r\n for (const { id, formatSet } of args.formatSets ?? []) {\r\n formatSets.set(id, new FormatSetFormatsProvider({ formatSet, fallbackProvider: defaultFormats }));\r\n }\r\n\r\n return { schemaContext, unitsProvider: new BasicUnitsProvider(), defaultFormats, formatSets };\r\n}\r\n\r\n/** [SchemaFormatsProvider.getFormatSync]($ecschema-metadata) reads only schemas already in the\r\n * context's cache; it never asks a locater to load one. The backend locater *can* load\r\n * synchronously, so ask the context for the schema first. That pulls it -- and the `Formats` and\r\n * `Units` schemas it references -- into the cache. A name whose schema the iModel lacks (a key\r\n * defined only by a FormatSet, say) is left for the formats provider to resolve or reject.\r\n */\r\nfunction ensureSchemaLoaded(context: SchemaContext, fullName: string): void {\r\n const [schemaName] = SchemaItem.parseFullName(fullName);\r\n if (!schemaName) {\r\n return;\r\n }\r\n\r\n try {\r\n context.getSchemaSync(new SchemaKey(schemaName));\r\n } catch {\r\n // Not a schema this iModel knows.\r\n }\r\n}\r\n\r\n/** Builds the [FormatterSpec]($core-quantity) for `args`, or `undefined` when the\r\n * format fails to resolve, the persistence unit is not a bundled BIS unit, the format names a\r\n * unit that is not, or the two cannot be converted between -- leaving the caller on the same\r\n * fallback as any other unresolved override.\r\n * @internal\r\n */\r\nexport function buildFieldFormatterSpec(args: FormattingSpecArgs, formatsProvider: SyncFormatsProvider, formatting: FieldFormatting): FormatterSpec | undefined {\r\n const { unitsProvider, schemaContext } = formatting;\r\n ensureSchemaLoaded(schemaContext, args.name);\r\n const formatProps = formatsProvider.getFormatSync(args.name, args.system);\r\n if (!formatProps) {\r\n return undefined;\r\n }\r\n\r\n // BasicUnitsProvider reports an unknown unit as an invalid BadUnit rather than throwing.\r\n const persistenceUnit = unitsProvider.findUnitByNameSync(args.persistenceUnitName);\r\n if (!persistenceUnit.isValid) {\r\n return undefined;\r\n }\r\n\r\n let formatterSpec: FormatterSpec;\r\n try {\r\n const format = Format.createFromJSONSync(\"fieldFormat\", unitsProvider, formatProps);\r\n formatterSpec = FormatterSpec.createSync(\"fieldFormat\", format, unitsProvider, persistenceUnit);\r\n } catch (err) {\r\n // A format naming a unit the bundled provider lacks can't be resolved.\r\n if (err instanceof QuantityError) {\r\n return undefined;\r\n }\r\n throw err;\r\n }\r\n\r\n // Reject a format whose units belong to a different phenomenon than the persisted value.\r\n // SyncUnitsProvider.getConversionSync reports this by returning the identity conversion tagged\r\n // `error: true`, and its contract requires callers to check that flag before applying the\r\n // result. FormatterSpec.createSync only logs a warning and keeps the identity conversion, so\r\n // without this check a length persisted in meters would render through an angle format as\r\n // \"2.5 deg\" -- relabelled rather than converted.\r\n if (formatterSpec.unitConversions.some((conversion) => conversion.conversion.error)) {\r\n return undefined;\r\n }\r\n\r\n return formatterSpec;\r\n}\r\n\r\n/** Returns `name` as the iModel's schemas spell it (`Units.M` for `units:m`), so later lookups\r\n * and comparisons can be exact: [BasicUnitsProvider.findUnitByNameSync]($core-quantity) only\r\n * recognizes the canonical spelling. An empty name counts as unset. A name no schema defines,\r\n * such as a KindOfQuantity only a FormatSet declares, is returned unchanged.\r\n */\r\nfunction normalizeToSchemaName(context: SchemaContext, name: string | undefined): string | undefined {\r\n if (!name) {\r\n return undefined;\r\n }\r\n\r\n try {\r\n return context.getSchemaItemSync(name)?.fullName ?? name;\r\n } catch {\r\n // Not a schema this iModel knows.\r\n return name;\r\n }\r\n}\r\n\r\n/** Builds the (KindOfQuantity, persistence unit) pairs a quantity/coordinate value may format\r\n * through, in priority order: the field's override pair first, then the property's own pair.\r\n * Names are compared exactly, so callers pass override names already normalized to the schema's\r\n * spelling.\r\n *\r\n * The two halves fall back differently. `kindOfQuantity` only chooses how the magnitude is\r\n * displayed, so the override wins and the property's is the fallback. `persistenceUnit` states\r\n * what the stored magnitude *means*, so the property's own unit is authoritative when it has one;\r\n * the override only supplies a unit for a property that lacks one (a coordinate, a plain double,\r\n * a JSON leaf). See [[lookupFieldSpec]] for reporting an override that was ignored this way.\r\n * @internal\r\n */\r\nexport function collectFieldQuantityPairs(args: {\r\n overrideName?: string;\r\n overridePersistence?: string;\r\n propertyName?: string;\r\n propertyPersistence?: string;\r\n}): FormattingSpecArgs[] {\r\n const { overrideName, overridePersistence, propertyName, propertyPersistence } = args;\r\n const name = overrideName ?? propertyName;\r\n const persistenceUnitName = propertyPersistence ?? overridePersistence;\r\n const pairs: FormattingSpecArgs[] = [];\r\n if (name && persistenceUnitName) {\r\n pairs.push({ name, persistenceUnitName });\r\n }\r\n\r\n // Fall back to the property's own pair unless the pair above already is it.\r\n if (propertyName && propertyPersistence && name !== propertyName) {\r\n pairs.push({ name: propertyName, persistenceUnitName: propertyPersistence });\r\n }\r\n\r\n return pairs;\r\n}\r\n\r\n/** Builds the first [FormatterSpec]($core-quantity) that resolves for `value` among the formats\r\n * of the FormatSet named by `quantityOptions.formatSet` -- or the adopted FormatSet and schema\r\n * formats when it names none, or one that was never registered -- along with the pairs that were\r\n * tried, so the caller can report when none resolved. `ignoredPersistenceUnit` is set when the\r\n * field's `persistenceUnit` named a unit other than the property's own and was therefore not\r\n * used, so the caller can report the likely authoring mistake.\r\n * @internal\r\n */\r\nexport function lookupFieldSpec(\r\n quantityOptions: QuantityFieldFormatOptions | undefined,\r\n value: ResolvedFieldValue,\r\n formatting: FieldFormatting,\r\n): { spec?: FormatterSpec, candidates: FormattingSpecArgs[], ignoredPersistenceUnit?: string } {\r\n const overridePersistence = normalizeToSchemaName(formatting.schemaContext, quantityOptions?.persistenceUnit);\r\n const propertyPersistence = value.persistenceUnitFullName;\r\n const ignoredPersistenceUnit = overridePersistence && propertyPersistence && overridePersistence !== propertyPersistence\r\n ? overridePersistence : undefined;\r\n const candidates = collectFieldQuantityPairs({\r\n overrideName: normalizeToSchemaName(formatting.schemaContext, quantityOptions?.kindOfQuantity),\r\n overridePersistence,\r\n propertyName: value.kindOfQuantityFullName,\r\n propertyPersistence,\r\n });\r\n const formatSet = quantityOptions?.formatSet;\r\n const formats = (formatSet ? formatting.formatSets.get(formatSet) : undefined) ?? formatting.defaultFormats;\r\n for (const candidate of candidates) {\r\n const spec = buildFieldFormatterSpec(candidate, formats, formatting);\r\n if (spec) {\r\n return { spec, candidates, ignoredPersistenceUnit };\r\n }\r\n }\r\n return { candidates, ignoredPersistenceUnit };\r\n}\r\n"]}
|
|
@@ -1,14 +1,51 @@
|
|
|
1
|
-
import { FieldRun,
|
|
1
|
+
import { FieldRun, RelationshipProps, TextBlock } from "@itwin/core-common";
|
|
2
2
|
import { IModelDb } from "../../IModelDb";
|
|
3
3
|
import { Id64String } from "@itwin/core-bentley";
|
|
4
|
+
import { FieldFormatting, ResolvedFieldValue } from "./fieldSpecs";
|
|
4
5
|
import type { EditTxn } from "../../EditTxn";
|
|
6
|
+
/** The per-evaluation state [[updateField]] needs: which element's fields to recompute, how to
|
|
7
|
+
* read a field's property value, and how to format quantities.
|
|
8
|
+
*/
|
|
5
9
|
export interface UpdateFieldsContext {
|
|
10
|
+
/** When set, only fields whose [FieldPropertyHost.elementId]($common) matches are recomputed —
|
|
11
|
+
* an edit to one source element leaves the annotation's other fields untouched.
|
|
12
|
+
*/
|
|
6
13
|
readonly hostElementId: Id64String | undefined;
|
|
7
|
-
|
|
14
|
+
/** Reads the value a field points at, or `undefined` if it cannot be resolved — including
|
|
15
|
+
* every field when the source element was deleted.
|
|
16
|
+
*/
|
|
17
|
+
getProperty(field: FieldRun): ResolvedFieldValue | undefined;
|
|
18
|
+
/** The formats `"quantity"` and `"coordinate"` values resolve through. [[updateField]] builds
|
|
19
|
+
* a [FormatterSpec]($core-quantity) per field from the FormatSet named by
|
|
20
|
+
* [QuantityFieldFormatOptions.formatSet]($common), falling back to the adopted FormatSet and
|
|
21
|
+
* the schemas; a value none of them can format falls back to `value.toString()`.
|
|
22
|
+
* [[createUpdateContext]] always supplies the iModel's formatting; only hand-built contexts in
|
|
23
|
+
* tests that never format a quantity leave it out.
|
|
24
|
+
*/
|
|
25
|
+
readonly formatting?: FieldFormatting;
|
|
8
26
|
}
|
|
9
27
|
export declare function createUpdateContext(hostElementId: string | undefined, iModel: IModelDb, deleted: boolean): UpdateFieldsContext;
|
|
28
|
+
/** Recomputes a single field's cached display string synchronously. Returns true iff
|
|
29
|
+
* cachedContent changed.
|
|
30
|
+
*
|
|
31
|
+
* Resolving the property value and formatting it are both fallible. A failure of either is
|
|
32
|
+
* logged and degrades *this* field to [FieldRun.invalidContentIndicator]($common); other
|
|
33
|
+
* fields in the same block are unaffected.
|
|
34
|
+
*/
|
|
10
35
|
export declare function updateField(field: FieldRun, context: UpdateFieldsContext): boolean;
|
|
36
|
+
/** Re-evaluates every [FieldRun]($common) in `textBlock` synchronously and returns the number
|
|
37
|
+
* whose cached display string changed. Fields targeting an element other than
|
|
38
|
+
* `context.hostElementId` (when set) are skipped.
|
|
39
|
+
*/
|
|
11
40
|
export declare function updateFields(textBlock: TextBlock, context: UpdateFieldsContext): number;
|
|
41
|
+
/** Re-evaluates the fields of the `props.targetId` annotation in response to a source-element
|
|
42
|
+
* change (`deleted=false`) or delete (`deleted=true`). Invoked from
|
|
43
|
+
* [[ElementDrivesTextAnnotation.onRootChangedArg]] / `onDeletedDependencyArg`.
|
|
44
|
+
*/
|
|
12
45
|
export declare function updateElementFields(props: RelationshipProps, txn: EditTxn, deleted: boolean): void;
|
|
46
|
+
/** Re-evaluates every field of the given annotation element against its current property
|
|
47
|
+
* values. Invoked from [[ElementDrivesTextAnnotation.updateFieldDependencies]] when
|
|
48
|
+
* establishing / refreshing relationships.
|
|
49
|
+
*/
|
|
13
50
|
export declare function updateAllFields(annotationElementId: Id64String, txn: EditTxn): void;
|
|
14
51
|
//# sourceMappingURL=fields.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../../../src/internal/annotations/fields.ts"],"names":[],"mappings":"AAKA,OAAO,EAA0C,QAAQ,
|
|
1
|
+
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../../../src/internal/annotations/fields.ts"],"names":[],"mappings":"AAKA,OAAO,EAA0C,QAAQ,EAA8E,iBAAiB,EAAE,SAAS,EAA8B,MAAM,oBA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