UNPKG

@itwin/core-backend

Version:
240 lines • 10.8 kB
import { IModelDb } from "../IModelDb"; /** * Information about each integrity check type, including the name, expected result type, and SQL query to execute * @internal */ export declare const integrityCheckTypeMap: { readonly checkDataColumns: { readonly name: "Check Data Columns"; readonly resultType: "CheckDataColumnsResultRow"; readonly sqlCommand: "check_data_columns"; readonly sqlQuery: "PRAGMA integrity_check(check_data_columns) ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES"; }; readonly checkECProfile: { readonly name: "Check EC Profile"; readonly resultType: "CheckECProfileResultRow"; readonly sqlCommand: "check_ec_profile"; readonly sqlQuery: "PRAGMA integrity_check(check_ec_profile) ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES"; }; readonly checkNavigationClassIds: { readonly name: "Check Navigation Class Ids"; readonly resultType: "CheckNavClassIdsResultRow"; readonly sqlCommand: "check_nav_class_ids"; readonly sqlQuery: "PRAGMA integrity_check(check_nav_class_ids) ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES"; }; readonly checkNavigationIds: { readonly name: "Check Navigation Ids"; readonly resultType: "CheckNavIdsResultRow"; readonly sqlCommand: "check_nav_ids"; readonly sqlQuery: "PRAGMA integrity_check(check_nav_ids) ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES"; }; readonly checkLinktableForeignKeyClassIds: { readonly name: "Check Link Table Foreign Key Class Ids"; readonly resultType: "CheckLinkTableFkClassIdsResultRow"; readonly sqlCommand: "check_linktable_fk_class_ids"; readonly sqlQuery: "PRAGMA integrity_check(check_linktable_fk_class_ids) ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES"; }; readonly checkLinktableForeignKeyIds: { readonly name: "Check Link Table Foreign Key Ids"; readonly resultType: "CheckLinkTableFkIdsResultRow"; readonly sqlCommand: "check_linktable_fk_ids"; readonly sqlQuery: "PRAGMA integrity_check(check_linktable_fk_ids) ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES"; }; readonly checkClassIds: { readonly name: "Check Class Ids"; readonly resultType: "CheckClassIdsResultRow"; readonly sqlCommand: "check_class_ids"; readonly sqlQuery: "PRAGMA integrity_check(check_class_ids) ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES"; }; readonly checkDataSchema: { readonly name: "Check Data Schema"; readonly resultType: "CheckDataSchemaResultRow"; readonly sqlCommand: "check_data_schema"; readonly sqlQuery: "PRAGMA integrity_check(check_data_schema) ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES"; }; readonly checkSchemaLoad: { readonly name: "Check Schema Load"; readonly resultType: "CheckSchemaLoadResultRow"; readonly sqlCommand: "check_schema_load"; readonly sqlQuery: "PRAGMA integrity_check(check_schema_load) ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES"; }; readonly checkMissingChildRows: { readonly name: "Check Missing Child Rows"; readonly resultType: "CheckMissingChildRowsResultRow"; readonly sqlCommand: "check_missing_child_rows"; readonly sqlQuery: "PRAGMA integrity_check(check_missing_child_rows) ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES"; }; }; /** * Type representing the keys of the integrityCheckType map, which correspond to the different types of integrity checks that can be performed. */ export type IntegrityCheckKey = keyof typeof integrityCheckTypeMap; /** Map of integrity check keys to their result row types */ interface IntegrityCheckResultTypeMap { checkDataColumns: CheckDataColumnsResultRow; checkECProfile: CheckECProfileResultRow; checkNavigationClassIds: CheckNavClassIdsResultRow; checkNavigationIds: CheckNavIdsResultRow; checkLinktableForeignKeyClassIds: CheckLinkTableFkClassIdsResultRow; checkLinktableForeignKeyIds: CheckLinkTableFkIdsResultRow; checkClassIds: CheckClassIdsResultRow; checkDataSchema: CheckDataSchemaResultRow; checkSchemaLoad: CheckSchemaLoadResultRow; checkMissingChildRows: CheckMissingChildRowsResultRow; } /** Checks the Map to give the return type of a specific integrity check */ type IntegrityCheckResultRow<K extends IntegrityCheckKey> = IntegrityCheckResultTypeMap[K]; /** * Return type for quick integrity check */ export interface QuickIntegrityCheckResultRow { check: string; passed: boolean; elapsedSeconds: string; } /** * Return type for Check Data Columns integrity check */ export interface CheckDataColumnsResultRow { sno: number; table: string; column: string; } /** * Return type for Check EC Profile integrity check */ export interface CheckECProfileResultRow { sno: number; type: string; name: string; issue: string; } /** * Return type for Check Navigation Class Ids integrity check */ export interface CheckNavClassIdsResultRow { sno: number; id: string; class: string; property: string; navId: string; navClassId: string; } /** * Return type for Check Navigation Ids integrity check */ export interface CheckNavIdsResultRow { sno: number; id: string; class: string; property: string; navId: string; primaryClass: string; } /** * Return type for Check Link Table Foreign Key Class Ids integrity check */ export interface CheckLinkTableFkClassIdsResultRow { sno: number; id: string; relationship: string; property: string; keyId: string; keyClassId: string; } /** * Return type for Check Link Table Foreign Key Ids integrity check */ export interface CheckLinkTableFkIdsResultRow { sno: number; id: string; relationship: string; property: string; keyId: string; primaryClass: string; } /** * Return type for Check Class Ids integrity check */ export interface CheckClassIdsResultRow { sno: number; class: string; id: string; classId: string; type: string; } /** * Return type for Check Data Schema integrity check */ export interface CheckDataSchemaResultRow { sno: number; type: string; name: string; } /** * Return type for Check Schema Load integrity check */ export interface CheckSchemaLoadResultRow { sno: number; schema: string; } /** * Return type for Check Missing Child Rows integrity check */ export interface CheckMissingChildRowsResultRow { sno: number; class: string; id: string; classId: string; missingRowInTables: string; } /** * Return type for integrity check results, including the check name, whether it passed, and the specific results (if any) */ export interface IntegrityCheckResult { /** The name of the integrity check that was performed */ check: string; /** Whether the integrity check passed (i.e. no issues were found = true) */ passed: boolean; /** The specific results returned by the integrity check, which may include details about any issues that were found. * In the case where issues are found, this will be an array of result rows specific to the type of check that was performed, * or an array of quick integrity check results if it was a quick check. */ results: IntegrityCheckResultRow<IntegrityCheckKey>[] | QuickIntegrityCheckResultRow[]; } /** * Gets the user-friendly name of an integrity check based on its key or SQL command. * 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. * If still not found, it returns the original check string. * @param check - The integrity check key or SQL command to get the name of * @returns The user-friendly name of the integrity check, or the original check string if no match is found * @internal */ export declare function getIntegrityCheckName(check: string): string; /** * Performs a quick integrity check on the given iModel. * @param iModel The IModelDb instance to perform the integrity check on * @returns An array of results for each check performed, including the check name, whether it passed, and the elapsed time in seconds * @internal */ export declare function performQuickIntegrityCheck(iModel: IModelDb): Promise<QuickIntegrityCheckResultRow[]>; /** * Performs a specific integrity check on the given iModel based on the provided check key, and returns the results specific to that check type. * @param iModel The IModelDb instance to perform the integrity check on * @param check The key of the specific integrity check to perform * @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. * @throws IModelError with status BadRequest if an unknown integrity check key is provided * @internal */ export declare function performSpecificIntegrityCheck(iModel: IModelDb, check: "checkDataColumns"): Promise<IntegrityCheckResultRow<"checkDataColumns">[]>; export declare function performSpecificIntegrityCheck(iModel: IModelDb, check: "checkECProfile"): Promise<IntegrityCheckResultRow<"checkECProfile">[]>; export declare function performSpecificIntegrityCheck(iModel: IModelDb, check: "checkNavigationClassIds"): Promise<IntegrityCheckResultRow<"checkNavigationClassIds">[]>; export declare function performSpecificIntegrityCheck(iModel: IModelDb, check: "checkNavigationIds"): Promise<IntegrityCheckResultRow<"checkNavigationIds">[]>; export declare function performSpecificIntegrityCheck(iModel: IModelDb, check: "checkLinktableForeignKeyClassIds"): Promise<IntegrityCheckResultRow<"checkLinktableForeignKeyClassIds">[]>; export declare function performSpecificIntegrityCheck(iModel: IModelDb, check: "checkLinktableForeignKeyIds"): Promise<IntegrityCheckResultRow<"checkLinktableForeignKeyIds">[]>; export declare function performSpecificIntegrityCheck(iModel: IModelDb, check: "checkClassIds"): Promise<IntegrityCheckResultRow<"checkClassIds">[]>; export declare function performSpecificIntegrityCheck(iModel: IModelDb, check: "checkDataSchema"): Promise<IntegrityCheckResultRow<"checkDataSchema">[]>; export declare function performSpecificIntegrityCheck(iModel: IModelDb, check: "checkSchemaLoad"): Promise<IntegrityCheckResultRow<"checkSchemaLoad">[]>; export declare function performSpecificIntegrityCheck(iModel: IModelDb, check: "checkMissingChildRows"): Promise<IntegrityCheckResultRow<"checkMissingChildRows">[]>; export declare function performSpecificIntegrityCheck<K extends IntegrityCheckKey>(iModel: IModelDb, check: K): Promise<IntegrityCheckResultRow<K>[]>; export {}; //# sourceMappingURL=IntegrityCheck.d.ts.map