@itwin/core-backend 5.6.0-dev.13 → 5.6.0-dev.14
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/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/SQLiteDb.d.ts.map +1 -1
- package/lib/cjs/SQLiteDb.js +0 -1
- package/lib/cjs/SQLiteDb.js.map +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
- package/lib/esm/IModelDb.d.ts.map +1 -1
- package/lib/esm/IModelDb.js.map +1 -1
- package/lib/esm/SQLiteDb.d.ts.map +1 -1
- package/lib/esm/SQLiteDb.js +0 -1
- package/lib/esm/SQLiteDb.js.map +1 -1
- package/lib/esm/rpc-impl/RpcBriefcaseUtility.d.ts.map +1 -1
- package/lib/esm/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
- package/lib/esm/test/hubaccess/Rebase.test.js +247 -9
- package/lib/esm/test/hubaccess/Rebase.test.js.map +1 -1
- package/lib/esm/test/imodel/SchemaXmlImport.test.js +87 -44
- package/lib/esm/test/imodel/SchemaXmlImport.test.js.map +1 -1
- package/package.json +13 -13
|
@@ -9,65 +9,108 @@ import { PhysicalElement, SnapshotDb } from "../../core-backend";
|
|
|
9
9
|
import { IModelTestUtils } from "../IModelTestUtils";
|
|
10
10
|
import { Logger, LogLevel } from "@itwin/core-bentley";
|
|
11
11
|
import { KnownTestLocations } from "../KnownTestLocations";
|
|
12
|
-
import { EntityClass } from "@itwin/ecschema-metadata";
|
|
12
|
+
import { EntityClass, Format } from "@itwin/ecschema-metadata";
|
|
13
13
|
describe("Schema XML Import Tests", () => {
|
|
14
|
-
let imodel;
|
|
15
14
|
before(() => {
|
|
16
15
|
// initialize logging
|
|
17
16
|
if (false) {
|
|
18
17
|
Logger.initializeToConsole();
|
|
19
18
|
Logger.setLevelDefault(LogLevel.Error);
|
|
20
19
|
}
|
|
21
|
-
const testFileName = IModelTestUtils.prepareOutputFile("SchemaXMLImport", "SchemaXMLImport.bim");
|
|
22
|
-
imodel = SnapshotDb.createEmpty(testFileName, { rootSubject: { name: "SchemaXMLImportTest" } }); // IModelTestUtils.createSnapshotFromSeed(testFileName, seedFileName);
|
|
23
|
-
assert.exists(imodel);
|
|
24
|
-
});
|
|
25
|
-
after(() => {
|
|
26
|
-
if (imodel)
|
|
27
|
-
imodel.close();
|
|
28
20
|
});
|
|
29
21
|
it("should import schema XML", async () => {
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
22
|
+
const testFileName = IModelTestUtils.prepareOutputFile("SchemaXMLImport", "SchemaXMLImport.bim");
|
|
23
|
+
const imodel = SnapshotDb.createEmpty(testFileName, { rootSubject: { name: "SchemaXMLImportTest" } });
|
|
24
|
+
try {
|
|
25
|
+
const schemaFilePath = path.join(KnownTestLocations.assetsDir, "Test3.ecschema.xml");
|
|
26
|
+
const schemaString = fs.readFileSync(schemaFilePath, "utf8");
|
|
27
|
+
await imodel.importSchemaStrings([schemaString]); // will throw an exception if import fails
|
|
28
|
+
const testDomainClass = await imodel.schemaContext.getSchemaItem("Test3.Test3Element", EntityClass);
|
|
29
|
+
assert.isDefined(testDomainClass);
|
|
30
|
+
assert.isDefined(testDomainClass?.baseClass);
|
|
31
|
+
assert.equal(testDomainClass?.baseClass?.fullName, PhysicalElement.classFullName.replace(":", "."));
|
|
32
|
+
}
|
|
33
|
+
finally {
|
|
34
|
+
imodel.close();
|
|
35
|
+
}
|
|
37
36
|
});
|
|
38
37
|
it("Schema import for newer ECXml Versions", async () => {
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
const testFileName = IModelTestUtils.prepareOutputFile("SchemaXMLImport", "SchemaVersionTest.bim");
|
|
39
|
+
const imodel = SnapshotDb.createEmpty(testFileName, { rootSubject: { name: "SchemaVersionTest" } });
|
|
40
|
+
try {
|
|
41
|
+
const helperFunction = async (imodelDb, xmlSchema, importSchema) => {
|
|
42
|
+
try {
|
|
43
|
+
// ECObjects is expected to throw for schemas that fail to import
|
|
44
|
+
if (importSchema)
|
|
45
|
+
await imodelDb.importSchemaStrings(xmlSchema);
|
|
46
|
+
else
|
|
47
|
+
imodelDb.getSchemaProps(xmlSchema[0]);
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
return true;
|
|
53
|
+
};
|
|
54
|
+
// Incrementing major ECXml version is not supported
|
|
55
|
+
for (const testCase of [`4.1`, `5.10`]) {
|
|
56
|
+
assert(!(await helperFunction(imodel, [`<ECSchema schemaName="TestSchema" alias="ts" version="1.0.0" xmlns="http://www.bentley.com/schemas/Bentley.ECXML.${testCase}"/>`], true)), `Schema ${testCase} import should not have succeeded.`);
|
|
57
|
+
assert(!(await helperFunction(imodel, [`TestSchema`], false)), `Schema ${testCase} test should not have succeeded.`);
|
|
58
|
+
}
|
|
59
|
+
// Importing a set of schemas should all fail if any one of them fails
|
|
60
|
+
{
|
|
61
|
+
const schemaXmls = [`<ECSchema schemaName="TestSchema1" alias="ts1" version="1.0.0" xmlns="http://www.bentley.com/schemas/Bentley.ECXML.3.2"/>`,
|
|
62
|
+
`<ECSchema schemaName="TestSchema2" alias="ts2" version="1.0.0" xmlns="http://www.bentley.com/schemas/Bentley.ECXML.3.8"/>`,
|
|
63
|
+
`<ECSchema schemaName="TestSchema3" alias="ts3" version="1.0.0" xmlns="http://www.bentley.com/schemas/Bentley.ECXML.4.5"/>`];
|
|
64
|
+
assert(!(await helperFunction(imodel, schemaXmls, true)), `Schema import should not have succeeded.`);
|
|
65
|
+
assert(!(await helperFunction(imodel, [`TestSchema1`], false)), `Schema TestSchema1 import should not have succeeded.`);
|
|
66
|
+
assert(!(await helperFunction(imodel, [`TestSchema2`], false)), `Schema TestSchema2 import should not have succeeded.`);
|
|
67
|
+
assert(!(await helperFunction(imodel, [`TestSchema3`], false)), `Schema TestSchema3 import should not have succeeded.`);
|
|
46
68
|
}
|
|
47
|
-
|
|
48
|
-
|
|
69
|
+
// Schema should be imported successfully
|
|
70
|
+
for (const testCase of [`3.2`, `3.5`]) {
|
|
71
|
+
assert(await helperFunction(imodel, [`<ECSchema schemaName="TestSchema" alias="ts" version="1.0.0" xmlns="http://www.bentley.com/schemas/Bentley.ECXML.${testCase}"/>`], true), `Schema ${testCase} import should have succeeded.`);
|
|
72
|
+
assert(await helperFunction(imodel, [`TestSchema`], false), `Schema ${testCase} test should have succeeded.`);
|
|
49
73
|
}
|
|
50
|
-
return true;
|
|
51
|
-
};
|
|
52
|
-
// Incrementing major ECXml version is not supported
|
|
53
|
-
for (const testCase of [`4.1`, `5.10`]) {
|
|
54
|
-
assert(!(await helperFunction(imodel, [`<ECSchema schemaName="TestSchema" alias="ts" version="1.0.0" xmlns="http://www.bentley.com/schemas/Bentley.ECXML.${testCase}"/>`], true)), `Schema ${testCase} import should not have succeeded.`);
|
|
55
|
-
assert(!(await helperFunction(imodel, [`TestSchema`], false)), `Schema ${testCase} test should not have succeeded.`);
|
|
56
74
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
75
|
+
finally {
|
|
76
|
+
imodel.close();
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
it.skip("should roundtrip ratio format properties", async () => {
|
|
80
|
+
// Create a separate iModel for this test
|
|
81
|
+
const testFileName = IModelTestUtils.prepareOutputFile("SchemaXMLImport", "RatioFormatRoundtrip.bim");
|
|
82
|
+
const testIModel = SnapshotDb.createEmpty(testFileName, { rootSubject: { name: "RatioFormatTest" } });
|
|
83
|
+
try {
|
|
84
|
+
const schemaXml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
85
|
+
<ECSchema schemaName="RatioFormatTest" alias="rft" version="01.00.00" xmlns="http://www.bentley.com/schemas/Bentley.ECXML.3.2">
|
|
86
|
+
<ECSchemaReference name="Units" version="01.00.09" alias="u"/>
|
|
87
|
+
<Format typeName="TestRatioFormat" type="Ratio" ratioType="OneToN" ratioSeparator=":" ratioFormatType="Decimal" precision="4" formatTraits="trailZeroes|showUnitLabel">
|
|
88
|
+
<Composite>
|
|
89
|
+
<Unit>u:M</Unit>
|
|
90
|
+
</Composite>
|
|
91
|
+
</Format>
|
|
92
|
+
<Format typeName="TestRatioFormat2" type="Ratio" ratioType="NToOne" ratioSeparator="=" ratioFormatType="Fractional" precision="8" formatTraits="keepSingleZero">
|
|
93
|
+
<Composite>
|
|
94
|
+
<Unit>u:M</Unit>
|
|
95
|
+
</Composite>
|
|
96
|
+
</Format>
|
|
97
|
+
</ECSchema>`;
|
|
98
|
+
// Import schema into iModel
|
|
99
|
+
await testIModel.importSchemaStrings([schemaXml]);
|
|
100
|
+
// Read back the format from the iModel's schema context
|
|
101
|
+
const format1 = await testIModel.schemaContext.getSchemaItem("RatioFormatTest.TestRatioFormat", Format);
|
|
102
|
+
assert.isDefined(format1);
|
|
103
|
+
assert.strictEqual(format1?.ratioType, "OneToN");
|
|
104
|
+
assert.strictEqual(format1?.ratioSeparator, ":");
|
|
105
|
+
assert.strictEqual(format1?.ratioFormatType, "Decimal");
|
|
106
|
+
const format2 = await testIModel.schemaContext.getSchemaItem("RatioFormatTest.TestRatioFormat2", Format);
|
|
107
|
+
assert.isDefined(format2);
|
|
108
|
+
assert.strictEqual(format2?.ratioType, "NToOne");
|
|
109
|
+
assert.strictEqual(format2?.ratioSeparator, "=");
|
|
110
|
+
assert.strictEqual(format2?.ratioFormatType, "Fractional");
|
|
66
111
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
assert(await helperFunction(imodel, [`<ECSchema schemaName="TestSchema" alias="ts" version="1.0.0" xmlns="http://www.bentley.com/schemas/Bentley.ECXML.${testCase}"/>`], true), `Schema ${testCase} import should have succeeded.`);
|
|
70
|
-
assert(await helperFunction(imodel, [`TestSchema`], false), `Schema ${testCase} test should have succeeded.`);
|
|
112
|
+
finally {
|
|
113
|
+
testIModel.close();
|
|
71
114
|
}
|
|
72
115
|
});
|
|
73
116
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaXmlImport.test.js","sourceRoot":"","sources":["../../../../src/test/imodel/SchemaXmlImport.test.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACvC,IAAI,MAAkB,CAAC;IAEvB,MAAM,CAAC,GAAG,EAAE;QACV,qBAAqB;QACrB,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,CAAC,mBAAmB,EAAE,CAAC;YAC7B,MAAM,CAAC,eAAe,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACzC,CAAC;QACD,MAAM,YAAY,GAAG,eAAe,CAAC,iBAAiB,CAAC,iBAAiB,EAAE,qBAAqB,CAAC,CAAC;QACjG,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,YAAY,EAAE,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,qBAAqB,E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MAAM,EAAE,CAAC,oHAAoH,QAAQ,KAAK,CAAC,EAAE,IAAI,CAAC,EAAE,UAAU,QAAQ,gCAAgC,CAAC,CAAC;YACpO,MAAM,CAAC,MAAM,cAAc,CAAC,MAAM,EAAE,CAAC,YAAY,CAAC,EAAE,KAAK,CAAC,EAAE,UAAU,QAAQ,8BAA8B,CAAC,CAAC;QAChH,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,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\nimport { assert } from \"chai\";\r\nimport * as fs from \"fs\";\r\nimport * as path from \"path\";\r\nimport { PhysicalElement, SnapshotDb } from \"../../core-backend\";\r\nimport { IModelTestUtils } from \"../IModelTestUtils\";\r\nimport { Logger, LogLevel } from \"@itwin/core-bentley\";\r\nimport { KnownTestLocations } from \"../KnownTestLocations\";\r\nimport { EntityClass } from \"@itwin/ecschema-metadata\";\r\n\r\ndescribe(\"Schema XML Import Tests\", () => {\r\n let imodel: SnapshotDb;\r\n\r\n before(() => {\r\n // initialize logging\r\n if (false) {\r\n Logger.initializeToConsole();\r\n Logger.setLevelDefault(LogLevel.Error);\r\n }\r\n const testFileName = IModelTestUtils.prepareOutputFile(\"SchemaXMLImport\", \"SchemaXMLImport.bim\");\r\n imodel = SnapshotDb.createEmpty(testFileName, { rootSubject: { name: \"SchemaXMLImportTest\" } }); // IModelTestUtils.createSnapshotFromSeed(testFileName, seedFileName);\r\n assert.exists(imodel);\r\n });\r\n\r\n after(() => {\r\n if (imodel)\r\n imodel.close();\r\n });\r\n\r\n it(\"should import schema XML\", async () => {\r\n const schemaFilePath = path.join(KnownTestLocations.assetsDir, \"Test3.ecschema.xml\");\r\n const schemaString = fs.readFileSync(schemaFilePath, \"utf8\");\r\n\r\n await imodel.importSchemaStrings([schemaString]); // will throw an exception if import fails\r\n\r\n const testDomainClass = await imodel.schemaContext.getSchemaItem(\"Test3.Test3Element\", EntityClass);\r\n assert.isDefined(testDomainClass);\r\n\r\n assert.isDefined(testDomainClass?.baseClass);\r\n\r\n assert.equal(testDomainClass?.baseClass?.fullName, PhysicalElement.classFullName.replace(\":\", \".\"));\r\n });\r\n\r\n it(\"Schema import for newer ECXml Versions\", async () => {\r\n const helperFunction = async (imodelDb: SnapshotDb, xmlSchema: string[], importSchema: boolean) => {\r\n try {\r\n // ECObjects is expected to throw for schemas that fail to import\r\n if (importSchema)\r\n await imodelDb.importSchemaStrings(xmlSchema);\r\n else\r\n imodelDb.getSchemaProps(xmlSchema[0]);\r\n } catch {\r\n return false;\r\n }\r\n return true;\r\n };\r\n\r\n // Incrementing major ECXml version is not supported\r\n for (const testCase of [`4.1`, `5.10`]) {\r\n assert(!(await helperFunction(imodel, [`<ECSchema schemaName=\"TestSchema\" alias=\"ts\" version=\"1.0.0\" xmlns=\"http://www.bentley.com/schemas/Bentley.ECXML.${testCase}\"/>`], true)), `Schema ${testCase} import should not have succeeded.`);\r\n assert(!(await helperFunction(imodel, [`TestSchema`], false)), `Schema ${testCase} test should not have succeeded.`);\r\n }\r\n\r\n // Importing a set of schemas should all fail if any one of them fails\r\n {\r\n const schemaXmls = [`<ECSchema schemaName=\"TestSchema1\" alias=\"ts1\" version=\"1.0.0\" xmlns=\"http://www.bentley.com/schemas/Bentley.ECXML.3.2\"/>`,\r\n `<ECSchema schemaName=\"TestSchema2\" alias=\"ts2\" version=\"1.0.0\" xmlns=\"http://www.bentley.com/schemas/Bentley.ECXML.3.8\"/>`,\r\n `<ECSchema schemaName=\"TestSchema3\" alias=\"ts3\" version=\"1.0.0\" xmlns=\"http://www.bentley.com/schemas/Bentley.ECXML.4.5\"/>`];\r\n\r\n assert(!(await helperFunction(imodel, schemaXmls, true)), `Schema import should not have succeeded.`);\r\n assert(!(await helperFunction(imodel, [`TestSchema1`], false)), `Schema TestSchema1 import should not have succeeded.`);\r\n assert(!(await helperFunction(imodel, [`TestSchema2`], false)), `Schema TestSchema2 import should not have succeeded.`);\r\n assert(!(await helperFunction(imodel, [`TestSchema3`], false)), `Schema TestSchema3 import should not have succeeded.`);\r\n }\r\n\r\n // Schema should be imported successfully\r\n for (const testCase of [`3.2`, `3.5`]) {\r\n assert(await helperFunction(imodel, [`<ECSchema schemaName=\"TestSchema\" alias=\"ts\" version=\"1.0.0\" xmlns=\"http://www.bentley.com/schemas/Bentley.ECXML.${testCase}\"/>`], true), `Schema ${testCase} import should have succeeded.`);\r\n assert(await helperFunction(imodel, [`TestSchema`], false), `Schema ${testCase} test should have succeeded.`);\r\n }\r\n });\r\n});\r\n"]}
|
|
1
|
+
{"version":3,"file":"SchemaXmlImport.test.js","sourceRoot":"","sources":["../../../../src/test/imodel/SchemaXmlImport.test.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAE/D,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACvC,MAAM,CAAC,GAAG,EAAE;QACV,qBAAqB;QACrB,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,CAAC,mBAAmB,EAAE,CAAC;YAC7B,MAAM,CAAC,eAAe,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACzC,CAAC;IACH,CAAC,CAAC,CAAC;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xG,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;YAC1B,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;YACjD,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,cAAc,EAAE,GAAG,CAAC,CAAC;YACjD,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;YAExD,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,aAAa,CAAC,aAAa,CAAC,kCAAkC,EAAE,MAAM,CAAC,CAAC;YACzG,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;YAC1B,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;YACjD,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,cAAc,EAAE,GAAG,CAAC,CAAC;YACjD,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,eAAe,EAAE,YAAY,CAAC,CAAC;QAC7D,CAAC;gBAAS,CAAC;YACT,UAAU,CAAC,KAAK,EAAE,CAAC;QACrB,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,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\nimport { assert } from \"chai\";\r\nimport * as fs from \"fs\";\r\nimport * as path from \"path\";\r\nimport { PhysicalElement, SnapshotDb } from \"../../core-backend\";\r\nimport { IModelTestUtils } from \"../IModelTestUtils\";\r\nimport { Logger, LogLevel } from \"@itwin/core-bentley\";\r\nimport { KnownTestLocations } from \"../KnownTestLocations\";\r\nimport { EntityClass, Format } from \"@itwin/ecschema-metadata\";\r\n\r\ndescribe(\"Schema XML Import Tests\", () => {\r\n before(() => {\r\n // initialize logging\r\n if (false) {\r\n Logger.initializeToConsole();\r\n Logger.setLevelDefault(LogLevel.Error);\r\n }\r\n });\r\n\r\n it(\"should import schema XML\", async () => {\r\n const testFileName = IModelTestUtils.prepareOutputFile(\"SchemaXMLImport\", \"SchemaXMLImport.bim\");\r\n const imodel = SnapshotDb.createEmpty(testFileName, { rootSubject: { name: \"SchemaXMLImportTest\" } });\r\n\r\n try {\r\n const schemaFilePath = path.join(KnownTestLocations.assetsDir, \"Test3.ecschema.xml\");\r\n const schemaString = fs.readFileSync(schemaFilePath, \"utf8\");\r\n\r\n await imodel.importSchemaStrings([schemaString]); // will throw an exception if import fails\r\n\r\n const testDomainClass = await imodel.schemaContext.getSchemaItem(\"Test3.Test3Element\", EntityClass);\r\n assert.isDefined(testDomainClass);\r\n\r\n assert.isDefined(testDomainClass?.baseClass);\r\n\r\n assert.equal(testDomainClass?.baseClass?.fullName, PhysicalElement.classFullName.replace(\":\", \".\"));\r\n } finally {\r\n imodel.close();\r\n }\r\n });\r\n\r\n it(\"Schema import for newer ECXml Versions\", async () => {\r\n const testFileName = IModelTestUtils.prepareOutputFile(\"SchemaXMLImport\", \"SchemaVersionTest.bim\");\r\n const imodel = SnapshotDb.createEmpty(testFileName, { rootSubject: { name: \"SchemaVersionTest\" } });\r\n\r\n try {\r\n const helperFunction = async (imodelDb: SnapshotDb, xmlSchema: string[], importSchema: boolean) => {\r\n try {\r\n // ECObjects is expected to throw for schemas that fail to import\r\n if (importSchema)\r\n await imodelDb.importSchemaStrings(xmlSchema);\r\n else\r\n imodelDb.getSchemaProps(xmlSchema[0]);\r\n } catch {\r\n return false;\r\n }\r\n return true;\r\n };\r\n\r\n // Incrementing major ECXml version is not supported\r\n for (const testCase of [`4.1`, `5.10`]) {\r\n assert(!(await helperFunction(imodel, [`<ECSchema schemaName=\"TestSchema\" alias=\"ts\" version=\"1.0.0\" xmlns=\"http://www.bentley.com/schemas/Bentley.ECXML.${testCase}\"/>`], true)), `Schema ${testCase} import should not have succeeded.`);\r\n assert(!(await helperFunction(imodel, [`TestSchema`], false)), `Schema ${testCase} test should not have succeeded.`);\r\n }\r\n\r\n // Importing a set of schemas should all fail if any one of them fails\r\n {\r\n const schemaXmls = [`<ECSchema schemaName=\"TestSchema1\" alias=\"ts1\" version=\"1.0.0\" xmlns=\"http://www.bentley.com/schemas/Bentley.ECXML.3.2\"/>`,\r\n `<ECSchema schemaName=\"TestSchema2\" alias=\"ts2\" version=\"1.0.0\" xmlns=\"http://www.bentley.com/schemas/Bentley.ECXML.3.8\"/>`,\r\n `<ECSchema schemaName=\"TestSchema3\" alias=\"ts3\" version=\"1.0.0\" xmlns=\"http://www.bentley.com/schemas/Bentley.ECXML.4.5\"/>`];\r\n\r\n assert(!(await helperFunction(imodel, schemaXmls, true)), `Schema import should not have succeeded.`);\r\n assert(!(await helperFunction(imodel, [`TestSchema1`], false)), `Schema TestSchema1 import should not have succeeded.`);\r\n assert(!(await helperFunction(imodel, [`TestSchema2`], false)), `Schema TestSchema2 import should not have succeeded.`);\r\n assert(!(await helperFunction(imodel, [`TestSchema3`], false)), `Schema TestSchema3 import should not have succeeded.`);\r\n }\r\n\r\n // Schema should be imported successfully\r\n for (const testCase of [`3.2`, `3.5`]) {\r\n assert(await helperFunction(imodel, [`<ECSchema schemaName=\"TestSchema\" alias=\"ts\" version=\"1.0.0\" xmlns=\"http://www.bentley.com/schemas/Bentley.ECXML.${testCase}\"/>`], true), `Schema ${testCase} import should have succeeded.`);\r\n assert(await helperFunction(imodel, [`TestSchema`], false), `Schema ${testCase} test should have succeeded.`);\r\n }\r\n } finally {\r\n imodel.close();\r\n }\r\n });\r\n\r\n it.skip(\"should roundtrip ratio format properties\", async () => {\r\n // Create a separate iModel for this test\r\n const testFileName = IModelTestUtils.prepareOutputFile(\"SchemaXMLImport\", \"RatioFormatRoundtrip.bim\");\r\n const testIModel = SnapshotDb.createEmpty(testFileName, { rootSubject: { name: \"RatioFormatTest\" } });\r\n\r\n try {\r\n const schemaXml = `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n <ECSchema schemaName=\"RatioFormatTest\" alias=\"rft\" version=\"01.00.00\" xmlns=\"http://www.bentley.com/schemas/Bentley.ECXML.3.2\">\r\n <ECSchemaReference name=\"Units\" version=\"01.00.09\" alias=\"u\"/>\r\n <Format typeName=\"TestRatioFormat\" type=\"Ratio\" ratioType=\"OneToN\" ratioSeparator=\":\" ratioFormatType=\"Decimal\" precision=\"4\" formatTraits=\"trailZeroes|showUnitLabel\">\r\n <Composite>\r\n <Unit>u:M</Unit>\r\n </Composite>\r\n </Format>\r\n <Format typeName=\"TestRatioFormat2\" type=\"Ratio\" ratioType=\"NToOne\" ratioSeparator=\"=\" ratioFormatType=\"Fractional\" precision=\"8\" formatTraits=\"keepSingleZero\">\r\n <Composite>\r\n <Unit>u:M</Unit>\r\n </Composite>\r\n </Format>\r\n </ECSchema>`;\r\n\r\n // Import schema into iModel\r\n await testIModel.importSchemaStrings([schemaXml]);\r\n\r\n // Read back the format from the iModel's schema context\r\n const format1 = await testIModel.schemaContext.getSchemaItem(\"RatioFormatTest.TestRatioFormat\", Format);\r\n assert.isDefined(format1);\r\n assert.strictEqual(format1?.ratioType, \"OneToN\");\r\n assert.strictEqual(format1?.ratioSeparator, \":\");\r\n assert.strictEqual(format1?.ratioFormatType, \"Decimal\");\r\n\r\n const format2 = await testIModel.schemaContext.getSchemaItem(\"RatioFormatTest.TestRatioFormat2\", Format);\r\n assert.isDefined(format2);\r\n assert.strictEqual(format2?.ratioType, \"NToOne\");\r\n assert.strictEqual(format2?.ratioSeparator, \"=\");\r\n assert.strictEqual(format2?.ratioFormatType, \"Fractional\");\r\n } finally {\r\n testIModel.close();\r\n }\r\n });\r\n});\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/core-backend",
|
|
3
|
-
"version": "5.6.0-dev.
|
|
3
|
+
"version": "5.6.0-dev.14",
|
|
4
4
|
"description": "iTwin.js backend components",
|
|
5
5
|
"main": "lib/cjs/core-backend.js",
|
|
6
6
|
"module": "lib/esm/core-backend.js",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"@opentelemetry/api": "^1.0.4",
|
|
30
|
-
"@itwin/core-bentley": "5.6.0-dev.
|
|
31
|
-
"@itwin/core-common": "5.6.0-dev.
|
|
32
|
-
"@itwin/
|
|
33
|
-
"@itwin/
|
|
30
|
+
"@itwin/core-bentley": "5.6.0-dev.14",
|
|
31
|
+
"@itwin/core-common": "5.6.0-dev.14",
|
|
32
|
+
"@itwin/core-geometry": "5.6.0-dev.14",
|
|
33
|
+
"@itwin/ecschema-metadata": "5.6.0-dev.14"
|
|
34
34
|
},
|
|
35
35
|
"peerDependenciesMeta": {
|
|
36
36
|
"@opentelemetry/api": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"NOTE: All tools used by scripts in this package must be listed as devDependencies"
|
|
43
43
|
],
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@itwin/eslint-plugin": "
|
|
45
|
+
"@itwin/eslint-plugin": "^6.0.0",
|
|
46
46
|
"@itwin/object-storage-core": "^3.0.4",
|
|
47
47
|
"@opentelemetry/api": "1.0.4",
|
|
48
48
|
"@types/chai": "4.3.1",
|
|
@@ -77,14 +77,14 @@
|
|
|
77
77
|
"marked": "^14.1.3",
|
|
78
78
|
"sql-formatter": "^15.4.6",
|
|
79
79
|
"webpack": "^5.97.1",
|
|
80
|
-
"@itwin/build-tools": "5.6.0-dev.
|
|
81
|
-
"@itwin/
|
|
82
|
-
"@itwin/core-
|
|
83
|
-
"@itwin/
|
|
80
|
+
"@itwin/build-tools": "5.6.0-dev.14",
|
|
81
|
+
"@itwin/ecschema-locaters": "5.6.0-dev.14",
|
|
82
|
+
"@itwin/core-bentley": "5.6.0-dev.14",
|
|
83
|
+
"@itwin/ecsql-common": "5.6.0-dev.14",
|
|
84
|
+
"@itwin/core-common": "5.6.0-dev.14",
|
|
85
|
+
"@itwin/core-geometry": "5.6.0-dev.14",
|
|
84
86
|
"internal-tools": "3.0.0-dev.69",
|
|
85
|
-
"@itwin/
|
|
86
|
-
"@itwin/ecschema-locaters": "5.6.0-dev.13",
|
|
87
|
-
"@itwin/ecschema-metadata": "5.6.0-dev.13"
|
|
87
|
+
"@itwin/ecschema-metadata": "5.6.0-dev.14"
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
90
|
"@bentley/imodeljs-native": "5.6.8",
|