@itwin/core-backend 5.7.0-dev.1 → 5.7.0-dev.11

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.
Files changed (52) hide show
  1. package/CHANGELOG.md +13 -1
  2. package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
  3. package/lib/cjs/BriefcaseManager.js +37 -14
  4. package/lib/cjs/BriefcaseManager.js.map +1 -1
  5. package/lib/cjs/IModelDb.d.ts +111 -23
  6. package/lib/cjs/IModelDb.d.ts.map +1 -1
  7. package/lib/cjs/IModelDb.js +108 -2
  8. package/lib/cjs/IModelDb.js.map +1 -1
  9. package/lib/cjs/StashManager.d.ts +1 -2
  10. package/lib/cjs/StashManager.d.ts.map +1 -1
  11. package/lib/cjs/StashManager.js.map +1 -1
  12. package/lib/cjs/TxnManager.d.ts +76 -55
  13. package/lib/cjs/TxnManager.d.ts.map +1 -1
  14. package/lib/cjs/TxnManager.js +116 -29
  15. package/lib/cjs/TxnManager.js.map +1 -1
  16. package/lib/cjs/internal/IntegrityCheck.d.ts +240 -0
  17. package/lib/cjs/internal/IntegrityCheck.d.ts.map +1 -0
  18. package/lib/cjs/internal/IntegrityCheck.js +193 -0
  19. package/lib/cjs/internal/IntegrityCheck.js.map +1 -0
  20. package/lib/esm/BriefcaseManager.d.ts.map +1 -1
  21. package/lib/esm/BriefcaseManager.js +37 -14
  22. package/lib/esm/BriefcaseManager.js.map +1 -1
  23. package/lib/esm/IModelDb.d.ts +111 -23
  24. package/lib/esm/IModelDb.d.ts.map +1 -1
  25. package/lib/esm/IModelDb.js +108 -2
  26. package/lib/esm/IModelDb.js.map +1 -1
  27. package/lib/esm/StashManager.d.ts +1 -2
  28. package/lib/esm/StashManager.d.ts.map +1 -1
  29. package/lib/esm/StashManager.js.map +1 -1
  30. package/lib/esm/TxnManager.d.ts +76 -55
  31. package/lib/esm/TxnManager.d.ts.map +1 -1
  32. package/lib/esm/TxnManager.js +116 -29
  33. package/lib/esm/TxnManager.js.map +1 -1
  34. package/lib/esm/internal/IntegrityCheck.d.ts +240 -0
  35. package/lib/esm/internal/IntegrityCheck.d.ts.map +1 -0
  36. package/lib/esm/internal/IntegrityCheck.js +187 -0
  37. package/lib/esm/internal/IntegrityCheck.js.map +1 -0
  38. package/lib/esm/test/hubaccess/Rebase.test.js +201 -12
  39. package/lib/esm/test/hubaccess/Rebase.test.js.map +1 -1
  40. package/lib/esm/test/schema/IModelSchemaContext.test.js +72 -2
  41. package/lib/esm/test/schema/IModelSchemaContext.test.js.map +1 -1
  42. package/lib/esm/test/standalone/ChangeMerge.test.js +9 -9
  43. package/lib/esm/test/standalone/ChangeMerge.test.js.map +1 -1
  44. package/lib/esm/test/standalone/ChangesetReader.test.js +173 -2
  45. package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -1
  46. package/lib/esm/test/standalone/ExportGraphics.test.js +89 -0
  47. package/lib/esm/test/standalone/ExportGraphics.test.js.map +1 -1
  48. package/lib/esm/test/standalone/IntegrityCheck.test.d.ts +2 -0
  49. package/lib/esm/test/standalone/IntegrityCheck.test.d.ts.map +1 -0
  50. package/lib/esm/test/standalone/IntegrityCheck.test.js +385 -0
  51. package/lib/esm/test/standalone/IntegrityCheck.test.js.map +1 -0
  52. package/package.json +14 -14
@@ -0,0 +1,193 @@
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.integrityCheckTypeMap = void 0;
8
+ exports.getIntegrityCheckName = getIntegrityCheckName;
9
+ exports.performQuickIntegrityCheck = performQuickIntegrityCheck;
10
+ exports.performSpecificIntegrityCheck = performSpecificIntegrityCheck;
11
+ const core_bentley_1 = require("@itwin/core-bentley");
12
+ const core_common_1 = require("@itwin/core-common");
13
+ /**
14
+ * Information about each integrity check type, including the name, expected result type, and SQL query to execute
15
+ * @internal
16
+ */
17
+ exports.integrityCheckTypeMap = {
18
+ checkDataColumns: {
19
+ name: "Check Data Columns",
20
+ resultType: "CheckDataColumnsResultRow",
21
+ sqlCommand: "check_data_columns",
22
+ sqlQuery: `PRAGMA integrity_check(check_data_columns) options enable_experimental_features`,
23
+ },
24
+ checkECProfile: {
25
+ name: "Check EC Profile",
26
+ resultType: "CheckECProfileResultRow",
27
+ sqlCommand: "check_ec_profile",
28
+ sqlQuery: `PRAGMA integrity_check(check_ec_profile) options enable_experimental_features`,
29
+ },
30
+ checkNavigationClassIds: {
31
+ name: "Check Navigation Class Ids",
32
+ resultType: "CheckNavClassIdsResultRow",
33
+ sqlCommand: "check_nav_class_ids",
34
+ sqlQuery: `PRAGMA integrity_check(check_nav_class_ids) options enable_experimental_features`,
35
+ },
36
+ checkNavigationIds: {
37
+ name: "Check Navigation Ids",
38
+ resultType: "CheckNavIdsResultRow",
39
+ sqlCommand: "check_nav_ids",
40
+ sqlQuery: `PRAGMA integrity_check(check_nav_ids) options enable_experimental_features`,
41
+ },
42
+ checkLinktableForeignKeyClassIds: {
43
+ name: "Check Link Table Foreign Key Class Ids",
44
+ resultType: "CheckLinkTableFkClassIdsResultRow",
45
+ sqlCommand: "check_linktable_fk_class_ids",
46
+ sqlQuery: `PRAGMA integrity_check(check_linktable_fk_class_ids) options enable_experimental_features`,
47
+ },
48
+ checkLinktableForeignKeyIds: {
49
+ name: "Check Link Table Foreign Key Ids",
50
+ resultType: "CheckLinkTableFkIdsResultRow",
51
+ sqlCommand: "check_linktable_fk_ids",
52
+ sqlQuery: `PRAGMA integrity_check(check_linktable_fk_ids) options enable_experimental_features`,
53
+ },
54
+ checkClassIds: {
55
+ name: "Check Class Ids",
56
+ resultType: "CheckClassIdsResultRow",
57
+ sqlCommand: "check_class_ids",
58
+ sqlQuery: `PRAGMA integrity_check(check_class_ids) options enable_experimental_features`,
59
+ },
60
+ checkDataSchema: {
61
+ name: "Check Data Schema",
62
+ resultType: "CheckDataSchemaResultRow",
63
+ sqlCommand: "check_data_schema",
64
+ sqlQuery: `PRAGMA integrity_check(check_data_schema) options enable_experimental_features`,
65
+ },
66
+ checkSchemaLoad: {
67
+ name: "Check Schema Load",
68
+ resultType: "CheckSchemaLoadResultRow",
69
+ sqlCommand: "check_schema_load",
70
+ sqlQuery: `PRAGMA integrity_check(check_schema_load) options enable_experimental_features`,
71
+ },
72
+ checkMissingChildRows: {
73
+ name: "Check Missing Child Rows",
74
+ resultType: "CheckMissingChildRowsResultRow",
75
+ sqlCommand: "check_missing_child_rows",
76
+ sqlQuery: `PRAGMA integrity_check(check_missing_child_rows) options enable_experimental_features`,
77
+ },
78
+ };
79
+ /**
80
+ * Gets the user-friendly name of an integrity check based on its key or SQL command.
81
+ * 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.
82
+ * If still not found, it returns the original check string.
83
+ * @param check - The integrity check key or SQL command to get the name of
84
+ * @returns The user-friendly name of the integrity check, or the original check string if no match is found
85
+ * @internal
86
+ */
87
+ function getIntegrityCheckName(check) {
88
+ // First try direct lookup by key
89
+ const directLookup = exports.integrityCheckTypeMap[check];
90
+ if (directLookup) {
91
+ return directLookup.name;
92
+ }
93
+ // If not found, search by sqlCommand
94
+ for (const [, value] of Object.entries(exports.integrityCheckTypeMap)) {
95
+ if (value.sqlCommand === check) {
96
+ return value.name;
97
+ }
98
+ }
99
+ // Fallback to the original check string
100
+ return check;
101
+ }
102
+ /**
103
+ * Performs a quick integrity check on the given iModel.
104
+ * @param iModel The IModelDb instance to perform the integrity check on
105
+ * @returns An array of results for each check performed, including the check name, whether it passed, and the elapsed time in seconds
106
+ * @internal
107
+ */
108
+ async function performQuickIntegrityCheck(iModel) {
109
+ const integrityCheckQuery = "PRAGMA integrity_check options enable_experimental_features";
110
+ const integrityCheckResults = [];
111
+ for await (const row of iModel.createQueryReader(integrityCheckQuery)) {
112
+ integrityCheckResults.push({ check: getIntegrityCheckName(row.check), passed: row.result, elapsedSeconds: row.elapsed_sec });
113
+ }
114
+ ;
115
+ return integrityCheckResults;
116
+ }
117
+ async function performSpecificIntegrityCheck(iModel, check) {
118
+ switch (check) {
119
+ case "checkDataColumns": {
120
+ const results = [];
121
+ for await (const row of iModel.createQueryReader(exports.integrityCheckTypeMap.checkDataColumns.sqlQuery)) {
122
+ results.push({ sno: row.sno, table: row.table, column: row.column });
123
+ }
124
+ return results;
125
+ }
126
+ case "checkECProfile": {
127
+ const results = [];
128
+ for await (const row of iModel.createQueryReader(exports.integrityCheckTypeMap.checkECProfile.sqlQuery)) {
129
+ results.push({ sno: row.sno, type: row.type, name: row.name, issue: row.issue });
130
+ }
131
+ return results;
132
+ }
133
+ case "checkNavigationClassIds": {
134
+ const results = [];
135
+ for await (const row of iModel.createQueryReader(exports.integrityCheckTypeMap.checkNavigationClassIds.sqlQuery)) {
136
+ results.push({ sno: row.sno, id: row.id, class: row.class, property: row.property, navId: row.nav_id, navClassId: row.nav_classId });
137
+ }
138
+ return results;
139
+ }
140
+ case "checkNavigationIds": {
141
+ const results = [];
142
+ for await (const row of iModel.createQueryReader(exports.integrityCheckTypeMap.checkNavigationIds.sqlQuery)) {
143
+ results.push({ sno: row.sno, id: row.id, class: row.class, property: row.property, navId: row.nav_id, primaryClass: row.primary_class });
144
+ }
145
+ return results;
146
+ }
147
+ case "checkLinktableForeignKeyClassIds": {
148
+ const results = [];
149
+ for await (const row of iModel.createQueryReader(exports.integrityCheckTypeMap.checkLinktableForeignKeyClassIds.sqlQuery)) {
150
+ results.push({ sno: row.sno, id: row.id, relationship: row.relationship, property: row.property, keyId: row.key_id, keyClassId: row.key_classId });
151
+ }
152
+ return results;
153
+ }
154
+ case "checkLinktableForeignKeyIds": {
155
+ const results = [];
156
+ for await (const row of iModel.createQueryReader(exports.integrityCheckTypeMap.checkLinktableForeignKeyIds.sqlQuery)) {
157
+ results.push({ sno: row.sno, id: row.id, relationship: row.relationship, property: row.property, keyId: row.key_id, primaryClass: row.primary_class });
158
+ }
159
+ return results;
160
+ }
161
+ case "checkClassIds": {
162
+ const results = [];
163
+ for await (const row of iModel.createQueryReader(exports.integrityCheckTypeMap.checkClassIds.sqlQuery)) {
164
+ results.push({ sno: row.sno, class: row.class, id: row.id, classId: row.class_id, type: row.type });
165
+ }
166
+ return results;
167
+ }
168
+ case "checkDataSchema": {
169
+ const results = [];
170
+ for await (const row of iModel.createQueryReader(exports.integrityCheckTypeMap.checkDataSchema.sqlQuery)) {
171
+ results.push({ sno: row.sno, type: row.type, name: row.name });
172
+ }
173
+ return results;
174
+ }
175
+ case "checkSchemaLoad": {
176
+ const results = [];
177
+ for await (const row of iModel.createQueryReader(exports.integrityCheckTypeMap.checkSchemaLoad.sqlQuery)) {
178
+ results.push({ sno: row.sno, schema: row.schema });
179
+ }
180
+ return results;
181
+ }
182
+ case "checkMissingChildRows": {
183
+ const results = [];
184
+ for await (const row of iModel.createQueryReader(exports.integrityCheckTypeMap.checkMissingChildRows.sqlQuery)) {
185
+ results.push({ sno: row.sno, class: row.class, id: row.id, classId: row.class_id, missingRowInTables: row.MissingRowInTables });
186
+ }
187
+ return results;
188
+ }
189
+ default:
190
+ throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadRequest, `Unknown integrity check type: ${check}`);
191
+ }
192
+ }
193
+ //# sourceMappingURL=IntegrityCheck.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IntegrityCheck.js","sourceRoot":"","sources":["../../../src/internal/IntegrityCheck.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAwO/F,sDAcC;AAQD,gEAOC;AAqBD,sEA2EC;AAnWD,sDAAmD;AACnD,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,iFAAiF;KAC5F;IACD,cAAc,EAAE;QAC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e,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACjG,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;YACrD,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,CAAC,EAAE,CAAC;gBACvG,OAAO,CAAC,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;YACE,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,UAAU,EAAE,iCAAiC,KAAK,EAAE,CAAC,CAAC;IAC7F,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 { 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) options 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) options 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) options 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) options 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) options 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) options 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) options 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) options 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) options 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) options 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}\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 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 options enable_experimental_features\";\r\n const integrityCheckResults: QuickIntegrityCheckResultRow[] = [];\r\n for await (const row of iModel.createQueryReader(integrityCheckQuery)) {\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<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)) {\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)) {\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)) {\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)) {\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)) {\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)) {\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)) {\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)) {\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)) {\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)) {\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 default:\r\n throw new IModelError(IModelStatus.BadRequest, `Unknown integrity check type: ${check}`);\r\n }\r\n}"]}
@@ -1 +1 @@
1
- {"version":3,"file":"BriefcaseManager.d.ts","sourceRoot":"","sources":["../../src/BriefcaseManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAMH,OAAO,EACL,WAAW,EAAE,UAAU,EAA6B,UAAU,EAAmD,QAAQ,EAC1H,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,WAAW,EAAoB,cAAc,EAAE,kBAAkB,EAAE,cAAc,EAAE,kBAAkB,EAAE,cAAc,EAAE,cAAc,EAA6C,mBAAmB,EACrM,YAAY,EAAE,aAAa,EAAE,wBAAwB,EACtD,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,yBAAyB,EAA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B,sBAAsB,CAAC,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAsH7F;;;;;;;OAOG;WACiB,kBAAkB,CAAC,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAW1F;;;;;;OAMG;WACW,gBAAgB,CAAC,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAanE;;;;;;;OAOG;WACW,oBAAoB,CAAC,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO;IAiB1E,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAOlC;;;;;;OAMG;WACiB,YAAY,CAAC,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAY9E,4EAA4E;mBACvD,WAAW;IAuDhC;;OAEG;WACiB,aAAa,CAAC,EAAE,EAAE,WAAW,EAAE,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;CAqBxF"}
@@ -417,6 +417,7 @@ export class BriefcaseManager {
417
417
  * @returns A promise that resolves when all required changesets have been applied.
418
418
  */
419
419
  static async pullAndApplyChangesets(db, arg) {
420
+ const briefcaseDb = db instanceof BriefcaseDb ? db : undefined;
420
421
  const nativeDb = db[_nativeDb];
421
422
  if (!db.isOpen || nativeDb.isReadonly()) // don't use db.isReadonly - we reopen the file writable just for this operation but db.isReadonly is still true
422
423
  throw new IModelError(ChangeSetStatus.ApplyError, "Briefcase must be open ReadWrite to process change sets");
@@ -424,9 +425,20 @@ export class BriefcaseManager {
424
425
  if (currentIndex === undefined)
425
426
  currentIndex = (await IModelHost[_hubAccess].queryChangeset({ accessToken: arg.accessToken, iModelId: db.iModelId, changeset: { id: db.changeset.id } })).index;
426
427
  const reverse = (arg.toIndex && arg.toIndex < currentIndex) ? true : false;
428
+ const isPullMerge = briefcaseDb && !reverse;
427
429
  if (nativeDb.hasPendingTxns() && reverse) {
428
430
  throw new IModelError(ChangeSetStatus.ApplyError, "Cannot reverse changesets when there are pending changes");
429
431
  }
432
+ if (isPullMerge) {
433
+ if (briefcaseDb.txns.rebaser.isRebasing) {
434
+ throw new IModelError(IModelStatus.BadRequest, "Cannot pull and apply changeset while rebasing");
435
+ }
436
+ if (briefcaseDb.txns.isIndirectChanges) {
437
+ throw new IModelError(IModelStatus.BadRequest, "Cannot pull and apply changeset while in an indirect change scope");
438
+ }
439
+ briefcaseDb.txns.rebaser.notifyPullMergeBegin(briefcaseDb.changeset);
440
+ briefcaseDb.txns.rebaser.notifyDownloadChangesetsBegin();
441
+ }
430
442
  // Download change sets
431
443
  const changesets = await IModelHost[_hubAccess].downloadChangesets({
432
444
  accessToken: arg.accessToken,
@@ -435,27 +447,35 @@ export class BriefcaseManager {
435
447
  targetDir: BriefcaseManager.getChangeSetsPath(db.iModelId),
436
448
  progressCallback: arg.onProgress,
437
449
  });
438
- if (changesets.length === 0)
450
+ if (isPullMerge) {
451
+ briefcaseDb.txns.rebaser.notifyDownloadChangesetsEnd();
452
+ }
453
+ if (changesets.length === 0) {
454
+ if (isPullMerge) {
455
+ briefcaseDb.txns.rebaser.notifyPullMergeEnd(briefcaseDb.changeset);
456
+ }
439
457
  return; // nothing to apply
458
+ }
440
459
  if (reverse)
441
460
  changesets.reverse();
442
- const briefcaseDb = db instanceof BriefcaseDb ? db : undefined;
443
- if (briefcaseDb) {
444
- if (briefcaseDb.txns.rebaser.isRebasing) {
445
- throw new IModelError(IModelStatus.BadRequest, "Cannot pull and apply changeset while rebasing");
446
- }
447
- if (briefcaseDb.txns.isIndirectChanges) {
448
- throw new IModelError(IModelStatus.BadRequest, "Cannot pull and apply changeset while in an indirect change scope");
449
- }
450
- }
451
- // create restore point if certain conditions are met
452
- if (briefcaseDb && briefcaseDb.txns.hasPendingTxns && !briefcaseDb.txns.hasPendingSchemaChanges && !reverse && !IModelHost.configuration?.disableRestorePointOnPullMerge) {
461
+ if (isPullMerge && briefcaseDb.txns.hasPendingTxns && !briefcaseDb.txns.hasPendingSchemaChanges && !IModelHost.configuration?.disableRestorePointOnPullMerge) {
453
462
  Logger.logInfo(loggerCategory, `Creating restore point ${this.PULL_MERGE_RESTORE_POINT_NAME}`);
454
463
  await this.createRestorePoint(briefcaseDb, this.PULL_MERGE_RESTORE_POINT_NAME);
455
464
  }
456
465
  if (!reverse) {
457
- const reversedTxns = nativeDb.pullMergeReverseLocalChanges();
458
- Logger.logInfo(loggerCategory, `Reversed ${reversedTxns.length} local changes`);
466
+ if (briefcaseDb) {
467
+ briefcaseDb.txns.rebaser.notifyReverseLocalChangesBegin();
468
+ const reversedTxns = nativeDb.pullMergeReverseLocalChanges();
469
+ const reversedTxnProps = reversedTxns.map((txn) => briefcaseDb.txns.getTxnProps(txn)).filter((props) => props !== undefined);
470
+ briefcaseDb.txns.rebaser.notifyReverseLocalChangesEnd(reversedTxnProps);
471
+ Logger.logInfo(loggerCategory, `Reversed ${reversedTxns.length} local changes`);
472
+ }
473
+ else {
474
+ nativeDb.pullMergeReverseLocalChanges();
475
+ }
476
+ }
477
+ if (isPullMerge) {
478
+ briefcaseDb.txns.rebaser.notifyApplyIncomingChangesBegin(changesets);
459
479
  }
460
480
  // apply incoming changes
461
481
  for (const changeset of changesets) {
@@ -473,6 +493,9 @@ export class BriefcaseManager {
473
493
  throw err;
474
494
  }
475
495
  }
496
+ if (isPullMerge) {
497
+ briefcaseDb.txns.rebaser.notifyApplyIncomingChangesEnd(changesets);
498
+ }
476
499
  if (!reverse) {
477
500
  if (briefcaseDb) {
478
501
  await briefcaseDb.txns.rebaser.resume();