@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.
- package/CHANGELOG.md +13 -1
- package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
- package/lib/cjs/BriefcaseManager.js +37 -14
- package/lib/cjs/BriefcaseManager.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +111 -23
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +108 -2
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/StashManager.d.ts +1 -2
- package/lib/cjs/StashManager.d.ts.map +1 -1
- package/lib/cjs/StashManager.js.map +1 -1
- package/lib/cjs/TxnManager.d.ts +76 -55
- package/lib/cjs/TxnManager.d.ts.map +1 -1
- package/lib/cjs/TxnManager.js +116 -29
- package/lib/cjs/TxnManager.js.map +1 -1
- package/lib/cjs/internal/IntegrityCheck.d.ts +240 -0
- package/lib/cjs/internal/IntegrityCheck.d.ts.map +1 -0
- package/lib/cjs/internal/IntegrityCheck.js +193 -0
- package/lib/cjs/internal/IntegrityCheck.js.map +1 -0
- package/lib/esm/BriefcaseManager.d.ts.map +1 -1
- package/lib/esm/BriefcaseManager.js +37 -14
- package/lib/esm/BriefcaseManager.js.map +1 -1
- package/lib/esm/IModelDb.d.ts +111 -23
- package/lib/esm/IModelDb.d.ts.map +1 -1
- package/lib/esm/IModelDb.js +108 -2
- package/lib/esm/IModelDb.js.map +1 -1
- package/lib/esm/StashManager.d.ts +1 -2
- package/lib/esm/StashManager.d.ts.map +1 -1
- package/lib/esm/StashManager.js.map +1 -1
- package/lib/esm/TxnManager.d.ts +76 -55
- package/lib/esm/TxnManager.d.ts.map +1 -1
- package/lib/esm/TxnManager.js +116 -29
- package/lib/esm/TxnManager.js.map +1 -1
- package/lib/esm/internal/IntegrityCheck.d.ts +240 -0
- package/lib/esm/internal/IntegrityCheck.d.ts.map +1 -0
- package/lib/esm/internal/IntegrityCheck.js +187 -0
- package/lib/esm/internal/IntegrityCheck.js.map +1 -0
- package/lib/esm/test/hubaccess/Rebase.test.js +201 -12
- package/lib/esm/test/hubaccess/Rebase.test.js.map +1 -1
- package/lib/esm/test/schema/IModelSchemaContext.test.js +72 -2
- package/lib/esm/test/schema/IModelSchemaContext.test.js.map +1 -1
- package/lib/esm/test/standalone/ChangeMerge.test.js +9 -9
- package/lib/esm/test/standalone/ChangeMerge.test.js.map +1 -1
- package/lib/esm/test/standalone/ChangesetReader.test.js +173 -2
- package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -1
- package/lib/esm/test/standalone/ExportGraphics.test.js +89 -0
- package/lib/esm/test/standalone/ExportGraphics.test.js.map +1 -1
- package/lib/esm/test/standalone/IntegrityCheck.test.d.ts +2 -0
- package/lib/esm/test/standalone/IntegrityCheck.test.d.ts.map +1 -0
- package/lib/esm/test/standalone/IntegrityCheck.test.js +385 -0
- package/lib/esm/test/standalone/IntegrityCheck.test.js.map +1 -0
- package/package.json +14 -14
package/lib/esm/IModelDb.js
CHANGED
|
@@ -49,6 +49,7 @@ import { ECVersion, SchemaContext, SchemaJsonLocater } from "@itwin/ecschema-met
|
|
|
49
49
|
import { SchemaMap } from "./Schema";
|
|
50
50
|
import { ElementLRUCache, InstanceKeyLRUCache } from "./internal/ElementLRUCache";
|
|
51
51
|
import { IModelIncrementalSchemaLocater } from "./IModelIncrementalSchemaLocater";
|
|
52
|
+
import { integrityCheckTypeMap, performQuickIntegrityCheck, performSpecificIntegrityCheck } from "./internal/IntegrityCheck";
|
|
52
53
|
// spell:ignore fontid fontmap
|
|
53
54
|
const loggerCategory = BackendLoggerCategory.IModelDb;
|
|
54
55
|
/** @internal */
|
|
@@ -330,6 +331,56 @@ export class IModelDb extends IModel {
|
|
|
330
331
|
throw new IModelError(IModelStatus.BadRequest, "IModel is not open or is read-only");
|
|
331
332
|
this[_nativeDb].analyze();
|
|
332
333
|
}
|
|
334
|
+
/**
|
|
335
|
+
* Performs integrity checks on this iModel.
|
|
336
|
+
* Types of integrity checks that can be performed are:
|
|
337
|
+
*
|
|
338
|
+
* Default Check:
|
|
339
|
+
* - Quick Check: Runs all integrity checks below and returns whether each check passed or failed, without detailed results.
|
|
340
|
+
*
|
|
341
|
+
* Specific Checks:
|
|
342
|
+
* - Data Columns Check: Checks if all the required columns exist in data tables. Issues are returned as a list of those tables/columns.
|
|
343
|
+
* - EC Profile Check: Checks if the profile table, indexes, and triggers are present. Does not check be_* tables. Issues are returned as a list of tables/indexes/triggers which were not found or have different DDL.
|
|
344
|
+
* - Navigation Class Ids Check: Checks if RelClassId of a Navigation property is a valid ECClassId. It does not check the value to match the relationship class.
|
|
345
|
+
* - Navigation Ids Check: Checks if Id of a Navigation property matches a valid row primary class.
|
|
346
|
+
* - Linktable Foreign Key Class Ids Check: Checks if SourceECClassId or TargetECClassId of a link table matches a valid ECClassId.
|
|
347
|
+
* - Linktable Foreign Key Ids Check: Checks if SourceECInstanceId or TargetECInstanceId of a link table matches a valid row in primary class.
|
|
348
|
+
* - Class Ids Check: Checks persisted ECClassId in all data tables and makes sure they are valid.
|
|
349
|
+
* - Data Schema Check: Checks if all the required data tables and indexes exist for mapped classes. Issues are returned as a list of tables/columns which were not found or have different DDL.
|
|
350
|
+
* - Schema Load Check: Checks if all schemas can be loaded into memory.
|
|
351
|
+
* - Missing Child Rows Check: Checks if all child rows have a corresponding parent row.
|
|
352
|
+
*
|
|
353
|
+
* @param options Options specifying which integrity checks to perform. If no options are provided or all options are false, a quick check will be performed by default.
|
|
354
|
+
* @returns An array of integrity check results.
|
|
355
|
+
* @throws [[IModelError]] if the iModel is not open.
|
|
356
|
+
* @beta
|
|
357
|
+
*/
|
|
358
|
+
async integrityCheck(options) {
|
|
359
|
+
if (!this.isOpen)
|
|
360
|
+
throw new IModelError(IModelStatus.BadRequest, "IModel is not open");
|
|
361
|
+
// Default to quick check if no options provided at all, or if not explicitly set and no specific checks are enabled
|
|
362
|
+
if (!options || (!options.quickCheck && (!options.specificChecks || !Object.values(options.specificChecks).some(Boolean)))) {
|
|
363
|
+
options = { ...options, quickCheck: true };
|
|
364
|
+
}
|
|
365
|
+
const integrityCheckResults = [];
|
|
366
|
+
// Perform a quick check if requested
|
|
367
|
+
if (options.quickCheck) {
|
|
368
|
+
const results = await performQuickIntegrityCheck(this);
|
|
369
|
+
const passed = results.every((result) => result.passed);
|
|
370
|
+
integrityCheckResults.push({ check: "Quick Check", passed, results });
|
|
371
|
+
}
|
|
372
|
+
// Perform all specific checks requested
|
|
373
|
+
if (options.specificChecks) {
|
|
374
|
+
for (const [checkKey, checkParams] of Object.entries(integrityCheckTypeMap)) {
|
|
375
|
+
if (options.specificChecks[checkKey]) {
|
|
376
|
+
const results = await performSpecificIntegrityCheck(this, checkKey);
|
|
377
|
+
const passed = results.length === 0;
|
|
378
|
+
integrityCheckResults.push({ check: checkParams.name, passed, results });
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
return integrityCheckResults;
|
|
383
|
+
}
|
|
333
384
|
/** @internal */
|
|
334
385
|
async refreshContainerForRpc(_userAccessToken) { }
|
|
335
386
|
/** Event called when the iModel is about to be closed. */
|
|
@@ -1457,7 +1508,7 @@ export class IModelDb extends IModel {
|
|
|
1457
1508
|
}
|
|
1458
1509
|
/** Export meshes suitable for graphics APIs from arbitrary geometry in elements in this IModelDb.
|
|
1459
1510
|
* * Requests can be slow when processing many elements so it is expected that this function be used on a dedicated backend,
|
|
1460
|
-
* or that shared backends export a limited number of elements at a time.
|
|
1511
|
+
* or that shared backends export a limited number of elements at a time. Consider using exportGraphicsAsync instead.
|
|
1461
1512
|
* * Vertices are exported in the IModelDb's world coordinate system, which is right-handed with Z pointing up.
|
|
1462
1513
|
* * The results of changing [ExportGraphicsOptions]($core-backend) during the [ExportGraphicsOptions.onGraphics]($core-backend) callback are not defined.
|
|
1463
1514
|
*
|
|
@@ -1490,12 +1541,50 @@ export class IModelDb extends IModel {
|
|
|
1490
1541
|
exportGraphics(exportProps) {
|
|
1491
1542
|
return this[_nativeDb].exportGraphics(exportProps);
|
|
1492
1543
|
}
|
|
1544
|
+
/** Export meshes suitable for graphics APIs from arbitrary geometry in elements in this IModelDb.
|
|
1545
|
+
* * This function queues an export task to the thread pool for each provided element ID, and returns
|
|
1546
|
+
* a Promise that resolves when all elements have been exported. The onGraphics and onLineGraphics
|
|
1547
|
+
* callbacks are invoked in the main thread as each element's export completes. This allows large
|
|
1548
|
+
* exports to be performed without blocking the main thread.
|
|
1549
|
+
* * Vertices are exported in the IModelDb's world coordinate system, which is right-handed with Z pointing up.
|
|
1550
|
+
* * The results of changing [ExportGraphicsOptions]($core-backend) during the [ExportGraphicsOptions.onGraphics]($core-backend)
|
|
1551
|
+
* callback are not defined.
|
|
1552
|
+
*
|
|
1553
|
+
* Example that prints the mesh for element 1 to stdout in [OBJ format](https://en.wikipedia.org/wiki/Wavefront_.obj_file)
|
|
1554
|
+
* ```ts
|
|
1555
|
+
* const onGraphics: ExportGraphicsFunction = (info: ExportGraphicsInfo) => {
|
|
1556
|
+
* const mesh: ExportGraphicsMesh = info.mesh;
|
|
1557
|
+
* for (let i = 0; i < mesh.points.length; i += 3) {
|
|
1558
|
+
* process.stdout.write(`v ${mesh.points[i]} ${mesh.points[i + 1]} ${mesh.points[i + 2]}\n`);
|
|
1559
|
+
* process.stdout.write(`vn ${mesh.normals[i]} ${mesh.normals[i + 1]} ${mesh.normals[i + 2]}\n`);
|
|
1560
|
+
* }
|
|
1561
|
+
*
|
|
1562
|
+
* for (let i = 0; i < mesh.params.length; i += 2) {
|
|
1563
|
+
* process.stdout.write(`vt ${mesh.params[i]} ${mesh.params[i + 1]}\n`);
|
|
1564
|
+
* }
|
|
1565
|
+
*
|
|
1566
|
+
* for (let i = 0; i < mesh.indices.length; i += 3) {
|
|
1567
|
+
* const p1 = mesh.indices[i];
|
|
1568
|
+
* const p2 = mesh.indices[i + 1];
|
|
1569
|
+
* const p3 = mesh.indices[i + 2];
|
|
1570
|
+
* process.stdout.write(`f ${p1}/${p1}/${p1} ${p2}/${p2}/${p2} ${p3}/${p3}/${p3}\n`);
|
|
1571
|
+
* }
|
|
1572
|
+
* };
|
|
1573
|
+
*
|
|
1574
|
+
* await iModel.exportGraphicsAsync(({ onGraphics, elementIdArray: ["0x1"] }));
|
|
1575
|
+
* ```
|
|
1576
|
+
* @returns A Promise that resolves when the export is complete, or rejects in the case of an error.
|
|
1577
|
+
* @public
|
|
1578
|
+
*/
|
|
1579
|
+
async exportGraphicsAsync(exportProps) {
|
|
1580
|
+
return this[_nativeDb].exportGraphicsAsync(exportProps);
|
|
1581
|
+
}
|
|
1493
1582
|
/**
|
|
1494
1583
|
* Exports meshes suitable for graphics APIs from a specified [GeometryPart]($core-backend)
|
|
1495
1584
|
* in this IModelDb.
|
|
1496
1585
|
* The expected use case is to call [IModelDb.exportGraphics]($core-backend) and supply the
|
|
1497
1586
|
* optional partInstanceArray argument, then call this function for each unique GeometryPart from
|
|
1498
|
-
* that list.
|
|
1587
|
+
* that list. Consider using exportPartGraphicsAsync instead.
|
|
1499
1588
|
* * The results of changing [ExportPartGraphicsOptions]($core-backend) during the
|
|
1500
1589
|
* [ExportPartGraphicsOptions.onPartGraphics]($core-backend) callback are not defined.
|
|
1501
1590
|
* * See export-gltf under test-apps in the iTwin.js monorepo for a working reference.
|
|
@@ -1505,6 +1594,23 @@ export class IModelDb extends IModel {
|
|
|
1505
1594
|
exportPartGraphics(exportProps) {
|
|
1506
1595
|
return this[_nativeDb].exportPartGraphics(exportProps);
|
|
1507
1596
|
}
|
|
1597
|
+
/**
|
|
1598
|
+
* Exports meshes suitable for graphics APIs from a specified [GeometryPart]($core-backend)
|
|
1599
|
+
* in this IModelDb.
|
|
1600
|
+
* The expected use case is to call [IModelDb.exportGraphicsAsync]($core-backend) and supply the
|
|
1601
|
+
* optional partInstanceArray argument, then call this function for each unique GeometryPart from
|
|
1602
|
+
* that list. Each export queues a task to the thread pool, allowing multiple parts to be exported
|
|
1603
|
+
* in parallel and without blocking the main thread. The onPartGraphics and onPartLineGraphics
|
|
1604
|
+
* callbacks are invoked in the main thread.
|
|
1605
|
+
* * The results of changing [ExportPartGraphicsOptions]($core-backend) during the
|
|
1606
|
+
* [ExportPartGraphicsOptions.onPartGraphics]($core-backend) callback are not defined.
|
|
1607
|
+
* * See export-gltf under test-apps in the iTwin.js monorepo for a working reference.
|
|
1608
|
+
* @returns A Promise that resolves when the export is complete, or rejects in the case of an error.
|
|
1609
|
+
* @public
|
|
1610
|
+
*/
|
|
1611
|
+
async exportPartGraphicsAsync(exportProps) {
|
|
1612
|
+
return this[_nativeDb].exportPartGraphicsAsync(exportProps);
|
|
1613
|
+
}
|
|
1508
1614
|
/** Request geometry stream information from an element in binary format instead of json.
|
|
1509
1615
|
* @returns IModelStatus.Success if successful
|
|
1510
1616
|
* @beta
|