@itwin/ecschema-metadata 5.2.0-dev.2 → 5.2.0-dev.21
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 +40 -1
- package/lib/cjs/Constants.js.map +1 -1
- package/lib/cjs/DelayedPromise.js.map +1 -1
- package/lib/cjs/Deserialization/AbstractParser.js.map +1 -1
- package/lib/cjs/Deserialization/Helper.js.map +1 -1
- package/lib/cjs/Deserialization/JsonParser.js.map +1 -1
- package/lib/cjs/Deserialization/JsonProps.d.ts +7 -2
- package/lib/cjs/Deserialization/JsonProps.d.ts.map +1 -1
- package/lib/cjs/Deserialization/JsonProps.js.map +1 -1
- package/lib/cjs/Deserialization/SchemaGraphUtil.js.map +1 -1
- package/lib/cjs/Deserialization/XmlParser.js.map +1 -1
- package/lib/cjs/Deserialization/XmlSerializationUtils.js.map +1 -1
- package/lib/cjs/ECName.js.map +1 -1
- package/lib/cjs/ECObjects.js.map +1 -1
- package/lib/cjs/Exception.js.map +1 -1
- package/lib/cjs/Formatting/FormatSetFormatsProvider.d.ts +37 -0
- package/lib/cjs/Formatting/FormatSetFormatsProvider.d.ts.map +1 -0
- package/lib/cjs/Formatting/FormatSetFormatsProvider.js +58 -0
- package/lib/cjs/Formatting/FormatSetFormatsProvider.js.map +1 -0
- package/lib/cjs/{SchemaFormatsProvider.d.ts → Formatting/SchemaFormatsProvider.d.ts} +1 -1
- package/lib/cjs/Formatting/SchemaFormatsProvider.d.ts.map +1 -0
- package/lib/cjs/{SchemaFormatsProvider.js → Formatting/SchemaFormatsProvider.js} +6 -6
- package/lib/cjs/Formatting/SchemaFormatsProvider.js.map +1 -0
- package/lib/cjs/IncrementalLoading/ClassParsers.js.map +1 -1
- package/lib/cjs/IncrementalLoading/ECSqlSchemaLocater.d.ts +18 -24
- package/lib/cjs/IncrementalLoading/ECSqlSchemaLocater.d.ts.map +1 -1
- package/lib/cjs/IncrementalLoading/ECSqlSchemaLocater.js +52 -26
- package/lib/cjs/IncrementalLoading/ECSqlSchemaLocater.js.map +1 -1
- package/lib/cjs/IncrementalLoading/FullSchemaQueries.js +465 -465
- package/lib/cjs/IncrementalLoading/FullSchemaQueries.js.map +1 -1
- package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.d.ts +16 -3
- package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.d.ts.map +1 -1
- package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.js +5 -4
- package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.js.map +1 -1
- package/lib/cjs/IncrementalLoading/IncrementalSchemaReader.d.ts.map +1 -1
- package/lib/cjs/IncrementalLoading/IncrementalSchemaReader.js +2 -7
- package/lib/cjs/IncrementalLoading/IncrementalSchemaReader.js.map +1 -1
- package/lib/cjs/IncrementalLoading/SchemaItemParsers.d.ts +4 -4
- package/lib/cjs/IncrementalLoading/SchemaItemParsers.d.ts.map +1 -1
- package/lib/cjs/IncrementalLoading/SchemaItemParsers.js +16 -16
- package/lib/cjs/IncrementalLoading/SchemaItemParsers.js.map +1 -1
- package/lib/cjs/IncrementalLoading/SchemaItemQueries.js +235 -235
- package/lib/cjs/IncrementalLoading/SchemaItemQueries.js.map +1 -1
- package/lib/cjs/IncrementalLoading/SchemaParser.d.ts +10 -4
- package/lib/cjs/IncrementalLoading/SchemaParser.d.ts.map +1 -1
- package/lib/cjs/IncrementalLoading/SchemaParser.js +19 -19
- package/lib/cjs/IncrementalLoading/SchemaParser.js.map +1 -1
- package/lib/cjs/IncrementalLoading/SchemaStubQueries.js +326 -326
- package/lib/cjs/IncrementalLoading/SchemaStubQueries.js.map +1 -1
- package/lib/cjs/Interfaces.js.map +1 -1
- package/lib/cjs/Metadata/Class.js.map +1 -1
- package/lib/cjs/Metadata/Constant.js.map +1 -1
- package/lib/cjs/Metadata/CustomAttribute.js.map +1 -1
- package/lib/cjs/Metadata/CustomAttributeClass.js.map +1 -1
- package/lib/cjs/Metadata/EntityClass.js +1 -1
- package/lib/cjs/Metadata/EntityClass.js.map +1 -1
- package/lib/cjs/Metadata/Enumeration.js.map +1 -1
- package/lib/cjs/Metadata/Format.js.map +1 -1
- package/lib/cjs/Metadata/InvertedUnit.js.map +1 -1
- package/lib/cjs/Metadata/KindOfQuantity.d.ts.map +1 -1
- package/lib/cjs/Metadata/KindOfQuantity.js +9 -22
- package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
- package/lib/cjs/Metadata/Mixin.js.map +1 -1
- package/lib/cjs/Metadata/OverrideFormat.js.map +1 -1
- package/lib/cjs/Metadata/Phenomenon.js.map +1 -1
- package/lib/cjs/Metadata/Property.js.map +1 -1
- package/lib/cjs/Metadata/PropertyCategory.js.map +1 -1
- package/lib/cjs/Metadata/RelationshipClass.js.map +1 -1
- package/lib/cjs/Metadata/Schema.js.map +1 -1
- package/lib/cjs/Metadata/SchemaItem.js.map +1 -1
- package/lib/cjs/Metadata/UnitSystem.js.map +1 -1
- package/lib/cjs/PropertyTypes.js.map +1 -1
- package/lib/cjs/SchemaJsonLocater.js.map +1 -1
- package/lib/cjs/SchemaKey.js.map +1 -1
- package/lib/cjs/SchemaLoader.js.map +1 -1
- package/lib/cjs/SchemaPartVisitorDelegate.js.map +1 -1
- package/lib/cjs/UnitConversion/Graph.js.map +1 -1
- package/lib/cjs/UnitConversion/Parser.js.map +1 -1
- package/lib/cjs/UnitConversion/UnitConversion.js.map +1 -1
- package/lib/cjs/UnitConversion/UnitConverter.js.map +1 -1
- package/lib/cjs/UnitConversion/UnitTree.js.map +1 -1
- package/lib/cjs/UnitProvider/SchemaUnitProvider.js.map +1 -1
- package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
- package/lib/cjs/ecschema-metadata.d.ts +2 -1
- package/lib/cjs/ecschema-metadata.d.ts.map +1 -1
- package/lib/cjs/ecschema-metadata.js +2 -1
- package/lib/cjs/ecschema-metadata.js.map +1 -1
- package/lib/cjs/utils/SchemaGraph.js.map +1 -1
- package/lib/cjs/utils/SchemaLoadingController.js.map +1 -1
- package/lib/esm/Constants.js.map +1 -1
- package/lib/esm/DelayedPromise.js.map +1 -1
- package/lib/esm/Deserialization/AbstractParser.js.map +1 -1
- package/lib/esm/Deserialization/Helper.js.map +1 -1
- package/lib/esm/Deserialization/JsonParser.js.map +1 -1
- package/lib/esm/Deserialization/JsonProps.d.ts +7 -2
- package/lib/esm/Deserialization/JsonProps.d.ts.map +1 -1
- package/lib/esm/Deserialization/JsonProps.js.map +1 -1
- package/lib/esm/Deserialization/SchemaGraphUtil.js.map +1 -1
- package/lib/esm/Deserialization/XmlParser.js.map +1 -1
- package/lib/esm/Deserialization/XmlSerializationUtils.js.map +1 -1
- package/lib/esm/ECName.js.map +1 -1
- package/lib/esm/ECObjects.js.map +1 -1
- package/lib/esm/Exception.js.map +1 -1
- package/lib/esm/Formatting/FormatSetFormatsProvider.d.ts +37 -0
- package/lib/esm/Formatting/FormatSetFormatsProvider.d.ts.map +1 -0
- package/lib/esm/Formatting/FormatSetFormatsProvider.js +54 -0
- package/lib/esm/Formatting/FormatSetFormatsProvider.js.map +1 -0
- package/lib/esm/{SchemaFormatsProvider.d.ts → Formatting/SchemaFormatsProvider.d.ts} +1 -1
- package/lib/esm/Formatting/SchemaFormatsProvider.d.ts.map +1 -0
- package/lib/esm/{SchemaFormatsProvider.js → Formatting/SchemaFormatsProvider.js} +6 -6
- package/lib/esm/Formatting/SchemaFormatsProvider.js.map +1 -0
- package/lib/esm/IncrementalLoading/ClassParsers.js.map +1 -1
- package/lib/esm/IncrementalLoading/ECSqlSchemaLocater.d.ts +18 -24
- package/lib/esm/IncrementalLoading/ECSqlSchemaLocater.d.ts.map +1 -1
- package/lib/esm/IncrementalLoading/ECSqlSchemaLocater.js +51 -25
- package/lib/esm/IncrementalLoading/ECSqlSchemaLocater.js.map +1 -1
- package/lib/esm/IncrementalLoading/FullSchemaQueries.js +465 -465
- package/lib/esm/IncrementalLoading/FullSchemaQueries.js.map +1 -1
- package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.d.ts +16 -3
- package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.d.ts.map +1 -1
- package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js +5 -4
- package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js.map +1 -1
- package/lib/esm/IncrementalLoading/IncrementalSchemaReader.d.ts.map +1 -1
- package/lib/esm/IncrementalLoading/IncrementalSchemaReader.js +2 -7
- package/lib/esm/IncrementalLoading/IncrementalSchemaReader.js.map +1 -1
- package/lib/esm/IncrementalLoading/SchemaItemParsers.d.ts +4 -4
- package/lib/esm/IncrementalLoading/SchemaItemParsers.d.ts.map +1 -1
- package/lib/esm/IncrementalLoading/SchemaItemParsers.js +16 -16
- package/lib/esm/IncrementalLoading/SchemaItemParsers.js.map +1 -1
- package/lib/esm/IncrementalLoading/SchemaItemQueries.js +235 -235
- package/lib/esm/IncrementalLoading/SchemaItemQueries.js.map +1 -1
- package/lib/esm/IncrementalLoading/SchemaParser.d.ts +10 -4
- package/lib/esm/IncrementalLoading/SchemaParser.d.ts.map +1 -1
- package/lib/esm/IncrementalLoading/SchemaParser.js +19 -19
- package/lib/esm/IncrementalLoading/SchemaParser.js.map +1 -1
- package/lib/esm/IncrementalLoading/SchemaStubQueries.js +326 -326
- package/lib/esm/IncrementalLoading/SchemaStubQueries.js.map +1 -1
- package/lib/esm/Interfaces.js.map +1 -1
- package/lib/esm/Metadata/Class.js.map +1 -1
- package/lib/esm/Metadata/Constant.js.map +1 -1
- package/lib/esm/Metadata/CustomAttribute.js.map +1 -1
- package/lib/esm/Metadata/CustomAttributeClass.js.map +1 -1
- package/lib/esm/Metadata/EntityClass.js +1 -1
- package/lib/esm/Metadata/EntityClass.js.map +1 -1
- package/lib/esm/Metadata/Enumeration.js.map +1 -1
- package/lib/esm/Metadata/Format.js.map +1 -1
- package/lib/esm/Metadata/InvertedUnit.js.map +1 -1
- package/lib/esm/Metadata/KindOfQuantity.d.ts.map +1 -1
- package/lib/esm/Metadata/KindOfQuantity.js +9 -22
- package/lib/esm/Metadata/KindOfQuantity.js.map +1 -1
- package/lib/esm/Metadata/Mixin.js.map +1 -1
- package/lib/esm/Metadata/OverrideFormat.js.map +1 -1
- package/lib/esm/Metadata/Phenomenon.js.map +1 -1
- package/lib/esm/Metadata/Property.js.map +1 -1
- package/lib/esm/Metadata/PropertyCategory.js.map +1 -1
- package/lib/esm/Metadata/RelationshipClass.js.map +1 -1
- package/lib/esm/Metadata/Schema.js.map +1 -1
- package/lib/esm/Metadata/SchemaItem.js.map +1 -1
- package/lib/esm/Metadata/UnitSystem.js.map +1 -1
- package/lib/esm/PropertyTypes.js.map +1 -1
- package/lib/esm/SchemaJsonLocater.js.map +1 -1
- package/lib/esm/SchemaKey.js.map +1 -1
- package/lib/esm/SchemaLoader.js.map +1 -1
- package/lib/esm/SchemaPartVisitorDelegate.js.map +1 -1
- package/lib/esm/UnitConversion/Graph.js.map +1 -1
- package/lib/esm/UnitConversion/Parser.js.map +1 -1
- package/lib/esm/UnitConversion/UnitConversion.js.map +1 -1
- package/lib/esm/UnitConversion/UnitConverter.js.map +1 -1
- package/lib/esm/UnitConversion/UnitTree.js.map +1 -1
- package/lib/esm/UnitProvider/SchemaUnitProvider.js.map +1 -1
- package/lib/esm/Validation/SchemaWalker.js.map +1 -1
- package/lib/esm/ecschema-metadata.d.ts +2 -1
- package/lib/esm/ecschema-metadata.d.ts.map +1 -1
- package/lib/esm/ecschema-metadata.js +2 -1
- package/lib/esm/ecschema-metadata.js.map +1 -1
- package/lib/esm/utils/SchemaGraph.js.map +1 -1
- package/lib/esm/utils/SchemaLoadingController.js.map +1 -1
- package/package.json +6 -6
- package/lib/cjs/IncrementalLoading/PerformanceLogger.d.ts +0 -60
- package/lib/cjs/IncrementalLoading/PerformanceLogger.d.ts.map +0 -1
- package/lib/cjs/IncrementalLoading/PerformanceLogger.js +0 -82
- package/lib/cjs/IncrementalLoading/PerformanceLogger.js.map +0 -1
- package/lib/cjs/SchemaFormatsProvider.d.ts.map +0 -1
- package/lib/cjs/SchemaFormatsProvider.js.map +0 -1
- package/lib/esm/IncrementalLoading/PerformanceLogger.d.ts +0 -60
- package/lib/esm/IncrementalLoading/PerformanceLogger.d.ts.map +0 -1
- package/lib/esm/IncrementalLoading/PerformanceLogger.js +0 -78
- package/lib/esm/IncrementalLoading/PerformanceLogger.js.map +0 -1
- package/lib/esm/SchemaFormatsProvider.d.ts.map +0 -1
- package/lib/esm/SchemaFormatsProvider.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ECSqlSchemaLocater.d.ts","sourceRoot":"","sources":["../../../src/IncrementalLoading/ECSqlSchemaLocater.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,UAAU,EACvI,eAAe,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,qBAAqB,EAAmB,mBAAmB,EAAE,WAAW,EACxI,gBAAgB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE1E,OAAO,EAAE,UAAU,EAAiB,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"ECSqlSchemaLocater.d.ts","sourceRoot":"","sources":["../../../src/IncrementalLoading/ECSqlSchemaLocater.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,UAAU,EACvI,eAAe,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,qBAAqB,EAAmB,m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hG;;;;;;OAMG;cACa,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAItG;;;;;;OAMG;cACa,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAI9F;;;;;;OAMG;cACa,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAIlG;;;;;;OAMG;cACa,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAIjG;;;;;;OAMG;cACa,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAIpG;;;OAGG;cACa,eAAe,IAAI,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAWrE;;;;;;OAMG;cACa,iBAAiB,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,WAAW,CAAC,GAAG,SAAS,CAAC;YA8DlH,eAAe;YAuBf,aAAa;YAgBb,4BAA4B;CAmC3C"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ECSqlSchemaLocater = void 0;
|
|
2
4
|
/*---------------------------------------------------------------------------------------------
|
|
3
5
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
6
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
7
|
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
|
|
7
|
-
exports.ECSqlSchemaLocater = void 0;
|
|
8
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
8
9
|
const ECObjects_1 = require("../ECObjects");
|
|
9
10
|
const SchemaKey_1 = require("../SchemaKey");
|
|
10
11
|
const FullSchemaQueries_1 = require("./FullSchemaQueries");
|
|
@@ -12,6 +13,7 @@ const IncrementalSchemaLocater_1 = require("./IncrementalSchemaLocater");
|
|
|
12
13
|
const SchemaItemQueries_1 = require("./SchemaItemQueries");
|
|
13
14
|
const SchemaParser_1 = require("./SchemaParser");
|
|
14
15
|
const SchemaStubQueries_1 = require("./SchemaStubQueries");
|
|
16
|
+
const LOGGER_CATEGORY = "IncrementalSchemaLoading.Performance";
|
|
15
17
|
/**
|
|
16
18
|
* An abstract [[IncrementalSchemaLocater]] implementation for loading
|
|
17
19
|
* EC [Schema] instances from an iModelDb using ECSql queries.
|
|
@@ -44,17 +46,19 @@ class ECSqlSchemaLocater extends IncrementalSchemaLocater_1.IncrementalSchemaLoc
|
|
|
44
46
|
// to fetch the whole schema json.
|
|
45
47
|
if (!await this.supportPartialSchemaLoading(context))
|
|
46
48
|
return this.getSchemaProps(schemaKey);
|
|
47
|
-
const
|
|
49
|
+
const queryStart = Date.now();
|
|
48
50
|
const schemaProps = this.options.useMultipleQueries
|
|
49
51
|
? await this.getFullSchemaMultipleQueries(schemaKey, context)
|
|
50
52
|
: await this.getFullSchema(schemaKey, context);
|
|
51
|
-
|
|
53
|
+
const queryDuration = Date.now() - queryStart;
|
|
54
|
+
core_bentley_1.Logger.logTrace(LOGGER_CATEGORY, `Recieved SchemaProps for ${schemaKey.name} in ${queryDuration}ms`, {
|
|
55
|
+
schemaName: schemaKey.name,
|
|
56
|
+
queryMode: this.options.useMultipleQueries ? "parallel" : "single",
|
|
57
|
+
duration: queryDuration,
|
|
58
|
+
});
|
|
52
59
|
return schemaProps;
|
|
53
60
|
}
|
|
54
61
|
;
|
|
55
|
-
/**
|
|
56
|
-
* Gets the [[SchemaProps]] without schemaItems.
|
|
57
|
-
*/
|
|
58
62
|
/**
|
|
59
63
|
* Gets the [[SchemaProps]] without schemaItems for the given schema name.
|
|
60
64
|
* @param schemaName The name of the Schema.
|
|
@@ -68,7 +72,8 @@ class ECSqlSchemaLocater extends IncrementalSchemaLocater_1.IncrementalSchemaLoc
|
|
|
68
72
|
if (schemaRow === undefined)
|
|
69
73
|
return undefined;
|
|
70
74
|
const schema = JSON.parse(schemaRow.schema);
|
|
71
|
-
|
|
75
|
+
const schemaInfos = await this._schemaInfoCache.getSchemasByContext(context) ?? [];
|
|
76
|
+
return SchemaParser_1.SchemaParser.parse(schema, schemaInfos);
|
|
72
77
|
}
|
|
73
78
|
/**
|
|
74
79
|
* Checks if the [[SchemaContext]] has the right Meta Schema version to support the incremental schema loading.
|
|
@@ -246,10 +251,16 @@ class ECSqlSchemaLocater extends IncrementalSchemaLocater_1.IncrementalSchemaLoc
|
|
|
246
251
|
* @internal
|
|
247
252
|
*/
|
|
248
253
|
async getSchemaPartials(schemaKey, context) {
|
|
254
|
+
const queryStart = Date.now();
|
|
249
255
|
const [schemaRow] = await this.executeQuery(SchemaStubQueries_1.ecsqlQueries.schemaStubQuery, {
|
|
250
256
|
parameters: { schemaName: schemaKey.name },
|
|
251
257
|
limit: 1
|
|
252
258
|
});
|
|
259
|
+
const queryDuration = Date.now() - queryStart;
|
|
260
|
+
core_bentley_1.Logger.logTrace(LOGGER_CATEGORY, `Recieved PartialSchema for ${schemaKey.name} in ${queryDuration}ms`, {
|
|
261
|
+
schemaName: schemaKey.name,
|
|
262
|
+
duration: queryDuration,
|
|
263
|
+
});
|
|
253
264
|
if (!schemaRow)
|
|
254
265
|
return undefined;
|
|
255
266
|
const schemaPartials = [];
|
|
@@ -270,11 +281,12 @@ class ECSqlSchemaLocater extends IncrementalSchemaLocater_1.IncrementalSchemaLoc
|
|
|
270
281
|
if (!schemaStub) {
|
|
271
282
|
schemaStub = await addSchema(SchemaKey_1.SchemaKey.parseString(`${schemaName}.0.0.0`));
|
|
272
283
|
}
|
|
273
|
-
|
|
274
|
-
|
|
284
|
+
let items = schemaStub.items;
|
|
285
|
+
if (!items) {
|
|
286
|
+
Object.assign(schemaStub, items = { items: {} });
|
|
275
287
|
}
|
|
276
|
-
const existingItem =
|
|
277
|
-
Object.assign(
|
|
288
|
+
const existingItem = items[itemInfo.name] || {};
|
|
289
|
+
Object.assign(items, { [itemInfo.name]: Object.assign(existingItem, itemInfo) });
|
|
278
290
|
};
|
|
279
291
|
const reviver = (_key, value) => {
|
|
280
292
|
if (value === null) {
|
|
@@ -283,19 +295,27 @@ class ECSqlSchemaLocater extends IncrementalSchemaLocater_1.IncrementalSchemaLoc
|
|
|
283
295
|
return value;
|
|
284
296
|
};
|
|
285
297
|
await addSchema(schemaKey);
|
|
286
|
-
|
|
298
|
+
const schemaInfos = await this._schemaInfoCache.getSchemasByContext(context) ?? [];
|
|
299
|
+
await parseSchemaItemStubs(schemaKey.name, JSON.parse(schemaRow.items, reviver), addItems, schemaInfos);
|
|
287
300
|
return schemaPartials;
|
|
288
301
|
}
|
|
289
302
|
async querySchemaItem(context, schemaName, query, schemaType) {
|
|
290
303
|
const start = Date.now();
|
|
291
304
|
const itemRows = await this.executeQuery(query, { parameters: { schemaName } });
|
|
292
|
-
|
|
305
|
+
const queryDuration = Date.now() - start;
|
|
306
|
+
core_bentley_1.Logger.logTrace(LOGGER_CATEGORY, `Recieved rows of ${schemaType} items for ${schemaName} in ${queryDuration}ms`, {
|
|
307
|
+
schemaName,
|
|
308
|
+
itemCount: itemRows.length,
|
|
309
|
+
itemType: schemaType,
|
|
310
|
+
duration: queryDuration,
|
|
311
|
+
});
|
|
293
312
|
if (itemRows.length === 0)
|
|
294
313
|
return [];
|
|
295
314
|
const items = itemRows.map((itemRow) => {
|
|
296
315
|
return "string" === typeof itemRow.item ? JSON.parse(itemRow.item) : itemRow.item;
|
|
297
316
|
});
|
|
298
|
-
|
|
317
|
+
const schemaInfos = await this._schemaInfoCache.getSchemasByContext(context) ?? [];
|
|
318
|
+
return await SchemaParser_1.SchemaParser.parseSchemaItems(items, schemaName, schemaInfos) ?? [];
|
|
299
319
|
}
|
|
300
320
|
async getFullSchema(schemaKey, context) {
|
|
301
321
|
const schemaRows = await this.executeQuery(FullSchemaQueries_1.FullSchemaQueries.schemaQuery, { parameters: { schemaName: schemaKey.name } });
|
|
@@ -307,13 +327,14 @@ class ECSqlSchemaLocater extends IncrementalSchemaLocater_1.IncrementalSchemaLoc
|
|
|
307
327
|
if (schema.items) {
|
|
308
328
|
schema.items = schema.items.map((itemRow) => { return itemRow.item; });
|
|
309
329
|
}
|
|
310
|
-
|
|
330
|
+
const schemaInfos = await this._schemaInfoCache.getSchemasByContext(context) ?? [];
|
|
331
|
+
return SchemaParser_1.SchemaParser.parse(schema, schemaInfos);
|
|
311
332
|
}
|
|
312
333
|
async getFullSchemaMultipleQueries(schemaKey, context) {
|
|
313
334
|
const schema = await this.getSchemaNoItems(schemaKey.name, context);
|
|
314
335
|
if (!schema)
|
|
315
336
|
return undefined;
|
|
316
|
-
schema.items = {};
|
|
337
|
+
const items = schema.items || (schema.items = {});
|
|
317
338
|
await Promise.all([
|
|
318
339
|
this.getEntities(schemaKey.name, context),
|
|
319
340
|
this.getMixins(schemaKey.name, context),
|
|
@@ -330,9 +351,14 @@ class ECSqlSchemaLocater extends IncrementalSchemaLocater_1.IncrementalSchemaLoc
|
|
|
330
351
|
this.getPhenomenon(schemaKey.name, context),
|
|
331
352
|
this.getFormats(schemaKey.name, context)
|
|
332
353
|
]).then((itemResults) => {
|
|
333
|
-
const flatItemList = itemResults.reduce((acc,
|
|
354
|
+
const flatItemList = itemResults.reduce((acc, result) => acc.concat(result));
|
|
334
355
|
flatItemList.forEach((schemaItem) => {
|
|
335
|
-
|
|
356
|
+
if (!schemaItem.name) {
|
|
357
|
+
// This should never be happen, as we query the schema items by name from the database, but since the SchemaProps
|
|
358
|
+
// have name optional, we need the check here to make the compiler happy.
|
|
359
|
+
throw new Error(`SchemaItem with no name encountered in schema ${schemaKey.name}`);
|
|
360
|
+
}
|
|
361
|
+
items[schemaItem.name] = schemaItem;
|
|
336
362
|
});
|
|
337
363
|
});
|
|
338
364
|
return schema;
|
|
@@ -342,7 +368,7 @@ exports.ECSqlSchemaLocater = ECSqlSchemaLocater;
|
|
|
342
368
|
function parseSchemaReference(referenceName) {
|
|
343
369
|
return { schemaKey: SchemaKey_1.SchemaKey.parseString(referenceName) };
|
|
344
370
|
}
|
|
345
|
-
async function parseSchemaItemStubs(schemaName,
|
|
371
|
+
async function parseSchemaItemStubs(schemaName, itemRows, addItemsHandler, schemaInfos) {
|
|
346
372
|
if (!itemRows || itemRows.length === 0) {
|
|
347
373
|
return;
|
|
348
374
|
}
|
|
@@ -353,32 +379,32 @@ async function parseSchemaItemStubs(schemaName, context, itemRows, addItemsHandl
|
|
|
353
379
|
const currentItem = baseClasses[index--];
|
|
354
380
|
const baseClassItem = baseClasses[index];
|
|
355
381
|
const baseClassName = baseClassItem ? `${baseClassItem.schema}.${baseClassItem.name}` : undefined;
|
|
356
|
-
const schemaItem = await SchemaParser_1.SchemaParser.parseItem(currentItem, currentItem.schema,
|
|
382
|
+
const schemaItem = await SchemaParser_1.SchemaParser.parseItem(currentItem, currentItem.schema, schemaInfos);
|
|
357
383
|
await addItemsHandler(currentItem.schema, {
|
|
358
384
|
...schemaItem,
|
|
359
385
|
name: schemaItem.name,
|
|
360
|
-
schemaItemType:
|
|
386
|
+
schemaItemType: schemaItem.schemaItemType,
|
|
361
387
|
baseClass: baseClassName,
|
|
362
388
|
});
|
|
363
389
|
}
|
|
364
390
|
};
|
|
365
391
|
for (const itemRow of itemRows) {
|
|
366
|
-
const schemaItem = await SchemaParser_1.SchemaParser.parseItem(itemRow, schemaName,
|
|
392
|
+
const schemaItem = await SchemaParser_1.SchemaParser.parseItem(itemRow, schemaName, schemaInfos);
|
|
367
393
|
await addItemsHandler(schemaName, {
|
|
368
394
|
...schemaItem,
|
|
369
395
|
name: schemaItem.name,
|
|
370
|
-
schemaItemType:
|
|
396
|
+
schemaItemType: schemaItem.schemaItemType,
|
|
371
397
|
mixins: itemRow.mixins
|
|
372
398
|
? itemRow.mixins.map(mixin => { return `${mixin.schema}.${mixin.name}`; })
|
|
373
399
|
: undefined,
|
|
374
400
|
});
|
|
375
401
|
await parseBaseClasses(itemRow.baseClasses);
|
|
376
402
|
for (const mixinRow of itemRow.mixins || []) {
|
|
377
|
-
const mixinItem = await SchemaParser_1.SchemaParser.parseItem(mixinRow, mixinRow.schema,
|
|
403
|
+
const mixinItem = await SchemaParser_1.SchemaParser.parseItem(mixinRow, mixinRow.schema, schemaInfos);
|
|
378
404
|
await addItemsHandler(mixinRow.schema, {
|
|
379
405
|
...mixinItem,
|
|
380
406
|
name: mixinItem.name,
|
|
381
|
-
schemaItemType:
|
|
407
|
+
schemaItemType: mixinItem.schemaItemType,
|
|
382
408
|
});
|
|
383
409
|
await parseBaseClasses(mixinRow.baseClasses);
|
|
384
410
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ECSqlSchemaLocater.js","sourceRoot":"","sources":["../../../src/IncrementalLoading/ECSqlSchemaLocater.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAMhG,4CAAoF;AAEpF,4CAAyC;AACzC,2DAAwD;AACxD,yEAA4F;AAE5F,2DAAwD;AACxD,iDAA8C;AAC9C,2DAAmD;AAoFnD;;;;GAIG;AACH,MAAsB,kBAAmB,SAAQ,mDAAwB;IACvE;;OAEG;IACH,IAAuB,OAAO;QAC5B,OAAO,KAAK,CAAC,OAAoC,CAAC;IACpD,CAAC;IAED;;;OAGG;IACH,YAAY,OAAmC;QAC7C,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;IAgBD;;;;;;OAMG;IACI,KAAK,CAAC,aAAa,CAAC,SAAoB,EAAE,OAAsB;QACrE,gHAAgH;QAChH,gHAAgH;QAChH,kCAAkC;QAClC,IAAI,CAAC,MAAM,IAAI,CAAC,2BAA2B,CAAC,OAAO,CAAC;YAClD,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QAExC,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c,EAAE,IAAA,+BAAmB,EAAC,UAAU,CAAC,cAAe,CAAE;gBAChE,SAAS,EAAE,aAAa;aACzB,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC;IAEF,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,MAAM,UAAU,GAAG,MAAM,2BAAY,CAAC,SAAS,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;QAC9E,MAAM,eAAe,CAAC,UAAU,EAAE;YAChC,GAAG,UAAU;YACb,IAAI,EAAE,UAAU,CAAC,IAAK;YACtB,cAAc,EAAE,IAAA,+BAAmB,EAAC,UAAU,CAAC,cAAe,CAAE;YAChE,MAAM,EAAE,OAAO,CAAC,MAAM;gBACpB,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,GAAG,OAAO,GAAG,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;gBAC1E,CAAC,CAAC,SAAS;SACd,CAAC,CAAC;QAEH,MAAM,gBAAgB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAE5C,KAAK,MAAM,QAAQ,IAAI,OAAO,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;YAC5C,MAAM,SAAS,GAAG,MAAM,2BAAY,CAAC,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACnF,MAAM,eAAe,CAAC,QAAQ,CAAC,MAAM,EAAE;gBACrC,GAAG,SAAS;gBACZ,IAAI,EAAE,SAAS,CAAC,IAAK;gBACrB,cAAc,EAAE,IAAA,+BAAmB,EAAC,SAAS,CAAC,cAAe,CAAE;aAChE,CAAC,CAAC;YACH,MAAM,gBAAgB,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { SchemaContext } from \"../Context\";\nimport { ConstantProps, CustomAttributeClassProps, EntityClassProps, EnumerationProps, InvertedUnitProps, KindOfQuantityProps, MixinProps,\n PhenomenonProps, PropertyCategoryProps, RelationshipClassProps, SchemaItemFormatProps, SchemaItemProps, SchemaItemUnitProps, SchemaProps,\n StructClassProps, UnitSystemProps } from \"../Deserialization/JsonProps\";\nimport { parseSchemaItemType, SchemaItemType, SchemaMatchType } from \"../ECObjects\";\nimport { SchemaInfo, WithSchemaKey } from \"../Interfaces\";\nimport { SchemaKey } from \"../SchemaKey\";\nimport { FullSchemaQueries } from \"./FullSchemaQueries\";\nimport { IncrementalSchemaLocater, SchemaLocaterOptions } from \"./IncrementalSchemaLocater\";\nimport { PerformanceLogger } from \"./PerformanceLogger\";\nimport { SchemaItemQueries } from \"./SchemaItemQueries\";\nimport { SchemaParser } from \"./SchemaParser\";\nimport { ecsqlQueries } from \"./SchemaStubQueries\";\n\ninterface SchemaItemInfo {\n readonly name: string;\n readonly schemaItemType: SchemaItemType;\n}\n\ninterface SchemaInfoRow {\n readonly name: string;\n readonly version: string;\n readonly alias: string;\n readonly references: string;\n}\n\ninterface SchemaStubRow {\n readonly name: string;\n readonly version: string;\n readonly alias: string;\n readonly displayLabel: string;\n readonly description: string;\n readonly references: string;\n readonly items: string;\n}\n\ninterface BaseClassStubRow {\n readonly schema: string;\n readonly name: string;\n readonly schemaItemType: string;\n readonly modifier: number;\n}\n\ninterface SchemaItemStubRow {\n readonly name: string;\n readonly schemaItemType: string;\n readonly modifier?: number;\n readonly baseClasses?: Array<BaseClassStubRow>;\n readonly mixins?: Array<{\n readonly schema: string,\n readonly name: string;\n readonly schemaItemType: string;\n readonly modifier: number;\n readonly baseClasses?: Array<BaseClassStubRow>\n }>;\n}\n\ninterface SchemaRow {\n schema: string\n}\n\ninterface SchemaItemRow {\n item: string | SchemaItemProps;\n}\n\ntype AddSchemaItemHandler = <T extends SchemaItemInfo>(schemaName: string, itemStub: T) => Promise<void>;\n\ntype MutableSchemaProps = {\n -readonly [K in keyof SchemaProps]: SchemaProps[K]\n};\n\ninterface QueryParameters {\n [parameterName: string]: string | number;\n}\n\n/**\n * Query options used by the ECSqlSchemaLocater.\n * @internal\n */\nexport interface ECSqlQueryOptions {\n parameters?: QueryParameters;\n limit?: number;\n}\n\n/**\n * Defines the [[ECSqlSchemaLocater]] options which determine how each\n * schema is to be loaded. All options are optional.\n * @internal\n */\nexport interface ECSqlSchemaLocaterOptions extends SchemaLocaterOptions {\n /** Query for Schemas using multiple queries. Defaults to false. */\n readonly useMultipleQueries?: boolean;\n /** Collects query execution performance data. Defaults to false. */\n readonly performanceLogger?: PerformanceLogger;\n}\n\n/**\n * An abstract [[IncrementalSchemaLocater]] implementation for loading\n * EC [Schema] instances from an iModelDb using ECSql queries.\n * @internal\n */\nexport abstract class ECSqlSchemaLocater extends IncrementalSchemaLocater {\n /**\n * Gets the [[ECSqlSchemaLocaterOptions]] used by this locater.\n */\n protected override get options(): ECSqlSchemaLocaterOptions {\n return super.options as ECSqlSchemaLocaterOptions;\n }\n\n /**\n * Initializes a new ECSqlSchemaLocater instance.\n * @param options The options used by this Schema locater.\n */\n constructor(options?: ECSqlSchemaLocaterOptions) {\n super(options);\n }\n\n /**\n * Executes the given ECSql query and returns the resulting rows.\n * @param query The ECSql query to execute.\n * @param options Optional arguments to control the query result.\n * @returns A promise that resolves to the resulting rows.\n */\n protected abstract executeQuery<TRow>(query: string, options?: ECSqlQueryOptions): Promise<ReadonlyArray<TRow>>;\n\n /**\n * Gets the [[SchemaProps]] for the given schema key.\n * @param schemaKey The schema key of the schema to be resolved.\n */\n protected abstract getSchemaProps(schemaKey: SchemaKey): Promise<SchemaProps | undefined>\n\n /**\n * Gets the [[SchemaProps]] for the given schema key. This is the full schema json with all elements that are defined\n * in the schema. The schema locater calls this after the stub has been loaded to fully load the schema in the background.\n * @param schemaKey The [[SchemaKey]] of the schema to be resolved.\n * @param context The [[SchemaContext]] to use for resolving references.\n * @internal\n */\n public async getSchemaJson(schemaKey: SchemaKey, context: SchemaContext): Promise<SchemaProps | undefined> {\n // If the meta schema is an earlier version than 4.0.3, we can't use the ECSql query interface to get the schema\n // information required to load the schema entirely. In this case, we fallback to use the ECSchema RPC interface\n // to fetch the whole schema json.\n if (!await this.supportPartialSchemaLoading(context))\n return this.getSchemaProps(schemaKey);\n\n const start = Date.now();\n const schemaProps = this.options.useMultipleQueries\n ? await this.getFullSchemaMultipleQueries(schemaKey, context)\n : await this.getFullSchema(schemaKey, context);\n\n this.options.performanceLogger?.logSchema(start, schemaKey.name);\n\n return schemaProps;\n };\n\n /**\n * Gets the [[SchemaProps]] without schemaItems.\n */\n /**\n * Gets the [[SchemaProps]] without schemaItems for the given schema name.\n * @param schemaName The name of the Schema.\n * @param context The [[SchemaContext]] to use for resolving references.\n * @returns\n * @internal\n */\n public async getSchemaNoItems(schemaName: string, context: SchemaContext): Promise<SchemaProps | undefined> {\n const schemaRows = await this.executeQuery<SchemaRow>(FullSchemaQueries.schemaNoItemsQuery, { parameters: { schemaName } });\n const schemaRow = schemaRows[0];\n if (schemaRow === undefined)\n return undefined;\n\n const schema = JSON.parse(schemaRow.schema) as SchemaProps;\n return SchemaParser.parse(schema, context);\n }\n\n /**\n * Checks if the [[SchemaContext]] has the right Meta Schema version to support the incremental schema loading.\n * @param context The schema context to lookup the meta schema.\n * @returns true if the context has a supported meta schema version, false otherwise.\n */\n protected async supportPartialSchemaLoading(context: SchemaContext): Promise<boolean> {\n const metaSchemaKey = new SchemaKey(\"ECDbMeta\", 4, 0, 3);\n const metaSchemaInfo = await context.getSchemaInfo(metaSchemaKey, SchemaMatchType.LatestWriteCompatible);\n return metaSchemaInfo !== undefined;\n };\n\n /**\n * Gets all the Schema's Entity classes as [[EntityClassProps]] JSON objects.\n * @param schemaName The name of the Schema.\n * @param context The [[SchemaContext]] to which the schema belongs.\n * @returns A promise that resolves to a EntityClassProps array. Maybe empty of no entities are found.\n * @internal\n */\n public async getEntities(schema: string, context: SchemaContext, queryOverride?: string): Promise<EntityClassProps[]> {\n const query = queryOverride ?? FullSchemaQueries.entityQuery;\n return this.querySchemaItem<EntityClassProps>(context, schema, query, \"EntityClass\");\n }\n\n /**\n * Gets all the Schema's Mixin classes as [[MixinProps]] JSON objects.\n * @param schemaName The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a MixinProps array. Maybe empty of no entities are found.\n * @internal\n */\n public async getMixins(schema: string, context: SchemaContext, queryOverride?: string): Promise<MixinProps[]> {\n const query = queryOverride ?? FullSchemaQueries.mixinQuery;\n return this.querySchemaItem<MixinProps>(context, schema, query, \"Mixin\");\n }\n\n /**\n * Gets all the Schema's Relationship classes as [[RelationshipClassProps]] JSON objects.\n * @param schemaName The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a RelationshipClassProps array. Maybe empty if no items are found.\n * @internal\n */\n public async getRelationships(schema: string, context: SchemaContext, queryOverride?: string): Promise<RelationshipClassProps[]> {\n const query = queryOverride ?? FullSchemaQueries.relationshipClassQuery;\n return this.querySchemaItem<RelationshipClassProps>(context, schema, query, \"RelationshipClass\");\n }\n\n /**\n * Gets all the Schema's CustomAttributeClass items as [[CustomAttributeClassProps]] JSON objects.\n * @param schemaName The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a CustomAttributeClassProps array. Maybe empty if not items are found.\n * @internal\n */\n public async getCustomAttributeClasses(schema: string, context: SchemaContext, queryOverride?: string): Promise<CustomAttributeClassProps[]> {\n const query = queryOverride ?? FullSchemaQueries.customAttributeQuery;\n return this.querySchemaItem<CustomAttributeClassProps>(context, schema, query, \"CustomAttributeClass\");\n }\n\n\n /**\n * Gets all the Schema's StructClass items as [[StructClassProps]] JSON objects.\n * @param schemaName The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a StructClassProps array. Maybe empty if not items are found.\n * @internal\n */\n public async getStructs(schema: string, context: SchemaContext, queryOverride?: string): Promise<StructClassProps[]> {\n const query = queryOverride ?? FullSchemaQueries.structQuery;\n return this.querySchemaItem<StructClassProps>(context, schema, query, \"StructClass\");\n }\n\n /**\n * Gets all the Schema's KindOfQuantity items as [[KindOfQuantityProps]] JSON objects.\n * @param schema The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a KindOfQuantityProps array. Maybe empty if not items are found.\n * @internal\n */\n public async getKindOfQuantities(schema: string, context: SchemaContext): Promise<KindOfQuantityProps[]> {\n return this.querySchemaItem<KindOfQuantityProps>(context, schema, SchemaItemQueries.kindOfQuantity(true), \"KindOfQuantity\");\n }\n\n /**\n * Gets all the Schema's PropertyCategory items as [[PropertyCategoryProps]] JSON objects.\n * @param schema The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a PropertyCategoryProps array. Maybe empty if not items are found.\n * @internal\n */\n public async getPropertyCategories(schema: string, context: SchemaContext): Promise<PropertyCategoryProps[]> {\n return this.querySchemaItem<PropertyCategoryProps>(context, schema, SchemaItemQueries.propertyCategory(true), \"PropertyCategory\");\n }\n\n /**\n * Gets all the Schema's Enumeration items as [[EnumerationProps]] JSON objects.\n * @param schema The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a EnumerationProps array. Maybe empty if not items are found.\n * @internal\n */\n public async getEnumerations(schema: string, context: SchemaContext): Promise<EnumerationProps[]> {\n return this.querySchemaItem<EnumerationProps>(context, schema, SchemaItemQueries.enumeration(true), \"Enumeration\");\n }\n\n /**\n * Gets all the Schema's Unit items as [[SchemaItemUnitProps]] JSON objects.\n * @param schema The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a SchemaItemUnitProps array. Maybe empty if not items are found.\n * @internal\n */\n public async getUnits(schema: string, context: SchemaContext): Promise<SchemaItemUnitProps[]> {\n return this.querySchemaItem<SchemaItemUnitProps>(context, schema, SchemaItemQueries.unit(true), \"Unit\");\n }\n\n /**\n * Gets all the Schema's InvertedUnit items as [[InvertedUnitProps]] JSON objects.\n * @param schema The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a InvertedUnitProps array. Maybe empty if not items are found.\n * @internal\n */\n public async getInvertedUnits(schema: string, context: SchemaContext): Promise<InvertedUnitProps[]> {\n return this.querySchemaItem<InvertedUnitProps>(context, schema, SchemaItemQueries.invertedUnit(true), \"InvertedUnit\");\n }\n\n /**\n * Gets all the Schema's Constant items as [[ConstantProps]] JSON objects.\n * @param schema The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a ConstantProps array. Maybe empty if not items are found.\n * @internal\n */\n public async getConstants(schema: string, context: SchemaContext): Promise<ConstantProps[]> {\n return this.querySchemaItem<ConstantProps>(context, schema, SchemaItemQueries.constant(true), \"Constant\");\n }\n\n /**\n * Gets all the Schema's UnitSystem items as [[UnitSystemProps]] JSON objects.\n * @param schema The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a UnitSystemProps array. Maybe empty if not items are found.\n * @internal\n */\n public async getUnitSystems(schema: string, context: SchemaContext): Promise<UnitSystemProps[]> {\n return this.querySchemaItem<UnitSystemProps>(context, schema, SchemaItemQueries.unitSystem(true), \"UnitSystem\");\n }\n\n /**\n * Gets all the Schema's Phenomenon items as [[PhenomenonProps]] JSON objects.\n * @param schema The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a PhenomenonProps array. Maybe empty if not items are found.\n * @internal\n */\n public async getPhenomenon(schema: string, context: SchemaContext): Promise<PhenomenonProps[]> {\n return this.querySchemaItem<PhenomenonProps>(context, schema, SchemaItemQueries.phenomenon(true), \"Phenomenon\");\n }\n\n /**\n * Gets all the Schema's Format items as [[SchemaItemFormatProps]] JSON objects.\n * @param schema The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a SchemaItemFormatProps array. Maybe empty if not items are found.\n * @internal\n */\n public async getFormats(schema: string, context: SchemaContext): Promise<SchemaItemFormatProps[]> {\n return this.querySchemaItem<SchemaItemFormatProps>(context, schema, SchemaItemQueries.format(true), \"Format\");\n }\n\n /**\n * Gets [[SchemaInfo]] objects for all schemas including their direct schema references.\n * @internal\n */\n public async loadSchemaInfos(): Promise<ReadonlyArray<SchemaInfo>> {\n const schemaRows = await this.executeQuery<SchemaInfoRow>(ecsqlQueries.schemaInfoQuery);\n return schemaRows.map((schemaRow) => (\n {\n alias: schemaRow.alias,\n schemaKey: SchemaKey.parseString(`${schemaRow.name}.${schemaRow.version}`),\n references: Array.from(JSON.parse(schemaRow.references), parseSchemaReference),\n }\n ));\n }\n\n /**\n * Gets the [[SchemaProps]] to create the basic schema skeleton. Depending on which options are set, the schema items or class hierarchy\n * can be included in the initial fetch.\n * @param schemaKey The [[SchemaKey]] of the schema to be resolved.\n * @returns A promise that resolves to the schema partials, which is an array of [[SchemaProps]].\n * @internal\n */\n public async getSchemaPartials(schemaKey: SchemaKey, context: SchemaContext): Promise<ReadonlyArray<SchemaProps> | undefined> {\n const [schemaRow] = await this.executeQuery<SchemaStubRow>(ecsqlQueries.schemaStubQuery, {\n parameters: { schemaName: schemaKey.name },\n limit: 1\n });\n\n if (!schemaRow)\n return undefined;\n\n const schemaPartials: Array<SchemaProps> = [];\n const addSchema = async (key: SchemaKey) => {\n const stub = await this.createSchemaProps(key, context);\n schemaPartials.push(stub);\n\n if (stub.references) {\n for (const referenceProps of stub.references) {\n if (!schemaPartials.some((schema) => schema.name === referenceProps.name)) {\n await addSchema(SchemaKey.parseString(`${referenceProps.name}.${referenceProps.version}`));\n }\n }\n }\n\n return stub;\n };\n\n const addItems = async (schemaName: string, itemInfo: SchemaItemInfo) => {\n let schemaStub = schemaPartials.find((schema) => schema.name === schemaName);\n if (!schemaStub) {\n schemaStub = await addSchema(SchemaKey.parseString(`${schemaName}.0.0.0`));\n }\n\n if (!schemaStub.items) {\n Object.assign(schemaStub, { items: {} });\n }\n\n const existingItem = schemaStub.items![itemInfo.name] || {};\n Object.assign(schemaStub.items!, { [itemInfo.name]: Object.assign(existingItem, itemInfo) });\n };\n\n const reviver = (_key: string, value: any) => {\n if (value === null) {\n return undefined;\n }\n return value;\n };\n\n await addSchema(schemaKey);\n\n await parseSchemaItemStubs(schemaKey.name, context, JSON.parse(schemaRow.items, reviver), addItems);\n\n return schemaPartials;\n }\n\n private async querySchemaItem<TRow extends SchemaItemProps>(context: SchemaContext, schemaName: string, query: string, schemaType: string): Promise<Array<TRow>> {\n const start = Date.now();\n const itemRows = await this.executeQuery<SchemaItemRow>(query, { parameters: { schemaName } });\n this.options.performanceLogger?.logSchemaItem(start, schemaName, schemaType, itemRows.length);\n\n if (itemRows.length === 0)\n return [];\n\n const items = itemRows.map((itemRow: SchemaItemRow) => {\n return \"string\" === typeof itemRow.item ? JSON.parse(itemRow.item) : itemRow.item;\n });\n\n return await SchemaParser.parseSchemaItems(items, schemaName, context) as Array<TRow> ?? []\n }\n\n private async getFullSchema(schemaKey: SchemaKey, context: SchemaContext): Promise<SchemaProps | undefined> {\n const schemaRows = await this.executeQuery<SchemaRow>(FullSchemaQueries.schemaQuery, { parameters: { schemaName: schemaKey.name } });\n const schemaRow = schemaRows[0];\n if (schemaRow === undefined)\n return undefined;\n\n // Map SchemaItemRow array, [{item: SchemaItemProps}], to array of SchemaItemProps.\n const schema = JSON.parse(schemaRow.schema) as SchemaProps;\n if (schema.items) {\n (schema as any).items = (schema.items as any).map((itemRow: SchemaItemRow) => { return itemRow.item; });\n }\n\n return SchemaParser.parse(schema, context);\n }\n\n private async getFullSchemaMultipleQueries(schemaKey: SchemaKey, context: SchemaContext): Promise<SchemaProps | undefined> {\n const schema = await this.getSchemaNoItems(schemaKey.name, context) as MutableSchemaProps;\n if (!schema)\n return undefined;\n\n schema.items = {};\n await Promise.all([\n this.getEntities(schemaKey.name, context),\n this.getMixins(schemaKey.name, context),\n this.getStructs(schemaKey.name, context),\n this.getRelationships(schemaKey.name, context),\n this.getCustomAttributeClasses(schemaKey.name, context),\n this.getKindOfQuantities(schemaKey.name, context),\n this.getPropertyCategories(schemaKey.name, context),\n this.getEnumerations(schemaKey.name, context),\n this.getUnits(schemaKey.name, context),\n this.getInvertedUnits(schemaKey.name, context),\n this.getUnitSystems(schemaKey.name, context),\n this.getConstants(schemaKey.name, context),\n this.getPhenomenon(schemaKey.name, context),\n this.getFormats(schemaKey.name, context)\n ]).then((itemResults) => {\n const flatItemList = itemResults.reduce((acc, item) => acc.concat(item));\n flatItemList.forEach((schemaItem) => {\n schema.items![schemaItem.name!] = schemaItem;\n });\n });\n\n return schema;\n }\n}\n\nfunction parseSchemaReference(referenceName: string): WithSchemaKey {\n return { schemaKey: SchemaKey.parseString(referenceName) };\n}\n\nasync function parseSchemaItemStubs(schemaName: string, context: SchemaContext, itemRows: Array<SchemaItemStubRow>, addItemsHandler: AddSchemaItemHandler) {\n if (!itemRows || itemRows.length === 0) {\n return;\n }\n\n const parseBaseClasses = async (baseClasses: Array<BaseClassStubRow> | undefined) => {\n if (!baseClasses || baseClasses.length < 2)\n return;\n\n for (let index = baseClasses.length - 1; index >= 0;) {\n const currentItem = baseClasses[index--];\n const baseClassItem = baseClasses[index];\n const baseClassName = baseClassItem ? `${baseClassItem.schema}.${baseClassItem.name}` : undefined;\n\n const schemaItem = await SchemaParser.parseItem(currentItem, currentItem.schema, context);\n await addItemsHandler(currentItem.schema, {\n ...schemaItem,\n name: schemaItem.name!,\n schemaItemType: parseSchemaItemType(schemaItem.schemaItemType!)!,\n baseClass: baseClassName,\n });\n }\n };\n\n for (const itemRow of itemRows) {\n const schemaItem = await SchemaParser.parseItem(itemRow, schemaName, context);\n await addItemsHandler(schemaName, {\n ...schemaItem,\n name: schemaItem.name!,\n schemaItemType: parseSchemaItemType(schemaItem.schemaItemType!)!,\n mixins: itemRow.mixins\n ? itemRow.mixins.map(mixin => { return `${mixin.schema}.${mixin.name}`; })\n : undefined,\n });\n\n await parseBaseClasses(itemRow.baseClasses);\n\n for (const mixinRow of itemRow.mixins || []) {\n const mixinItem = await SchemaParser.parseItem(mixinRow, mixinRow.schema, context);\n await addItemsHandler(mixinRow.schema, {\n ...mixinItem,\n name: mixinItem.name!,\n schemaItemType: parseSchemaItemType(mixinItem.schemaItemType!)!,\n });\n await parseBaseClasses(mixinRow.baseClasses);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ECSqlSchemaLocater.js","sourceRoot":"","sources":["../../../src/IncrementalLoading/ECSqlSchemaLocater.ts"],"names":[],"mappings":";;;AAAA;;;gGAGgG;AAChG,sDAA6C;AAK7C,4CAA+D;AAE/D,4CAAyC;AACzC,2DAAwD;AACxD,yEAA4F;AAC5F,2DAAwD;AACxD,iDAA8C;AAC9C,2DAAmD;AA+DnD,MAAM,eAAe,GAAG,sCAAsC,CAAC;AAqB/D;;;;GAIG;AACH,MAAsB,kBAAmB,SAAQ,mDAAwB;IACvE;;OAEG;IACH,IAAuB,OAAO;QAC5B,OAAO,KAAK,CAAC,OAAoC,CAAC;IACpD,CAAC;IAED;;;OAGG;IACH,YAAY,OAAmC;QAC7C,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;IAgBD;;;;;;OAMG;IACO,KAAK,CAAC,aAAa,CAAC,SAAoB,EAAE,OAAsB;QACxE,gHAAgH;QAChH,gHAAgH;QAChH,kCAAkC;QAClC,IAAI,CAAC,MAAM,IAAI,CAAC,2BAA2B,CAAC,OAAO,CAAC;YAClD,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QAExC,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC9B,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,kBAAkB;YACjD,CAAC,CAAC,MAAM,IAAI,CAAC,4BAA4B,CAAC,SAAS,EAAE,OAAO,CAAC;YAC7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,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,MAAM,UAAU,GAAG,MAAM,2BAAY,CAAC,SAAS,CAAC,OAAO,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;QAClF,MAAM,eAAe,CAAC,UAAU,EAAE;YAChC,GAAG,UAAU;YACb,IAAI,EAAE,UAAU,CAAC,IAAI;YACrB,cAAc,EAAE,UAAU,CAAC,cAAc;YACzC,MAAM,EAAE,OAAO,CAAC,MAAM;gBACpB,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,GAAG,OAAO,GAAG,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;gBAC1E,CAAC,CAAC,SAAS;SACd,CAAC,CAAC;QAEH,MAAM,gBAAgB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAE5C,KAAK,MAAM,QAAQ,IAAI,OAAO,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;YAC5C,MAAM,SAAS,GAAG,MAAM,2BAAY,CAAC,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;YACvF,MAAM,eAAe,CAAC,QAAQ,CAAC,MAAM,EAAE;gBACrC,GAAG,SAAS;gBACZ,IAAI,EAAE,SAAS,CAAC,IAAI;gBACpB,cAAc,EAAE,SAAS,CAAC,cAAc;aACzC,CAAC,CAAC;YACH,MAAM,gBAAgB,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QAC/C,CAAC;IACH,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\nimport { Logger } from \"@itwin/core-bentley\";\r\nimport { SchemaContext } from \"../Context\";\r\nimport { ConstantProps, CustomAttributeClassProps, EntityClassProps, EnumerationProps, InvertedUnitProps, KindOfQuantityProps, MixinProps,\r\n PhenomenonProps, PropertyCategoryProps, RelationshipClassProps, SchemaItemFormatProps, SchemaItemProps, SchemaItemUnitProps, SchemaProps,\r\n StructClassProps, UnitSystemProps } from \"../Deserialization/JsonProps\";\r\nimport { SchemaItemType, SchemaMatchType } from \"../ECObjects\";\r\nimport { SchemaInfo, WithSchemaKey } from \"../Interfaces\";\r\nimport { SchemaKey } from \"../SchemaKey\";\r\nimport { FullSchemaQueries } from \"./FullSchemaQueries\";\r\nimport { IncrementalSchemaLocater, SchemaLocaterOptions } from \"./IncrementalSchemaLocater\";\r\nimport { SchemaItemQueries } from \"./SchemaItemQueries\";\r\nimport { SchemaParser } from \"./SchemaParser\";\r\nimport { ecsqlQueries } from \"./SchemaStubQueries\";\r\n\r\ninterface SchemaItemInfo {\r\n readonly name: string;\r\n readonly schemaItemType: SchemaItemType;\r\n}\r\n\r\ninterface SchemaInfoRow {\r\n readonly name: string;\r\n readonly version: string;\r\n readonly alias: string;\r\n readonly references: string;\r\n}\r\n\r\ninterface SchemaStubRow {\r\n readonly name: string;\r\n readonly version: string;\r\n readonly alias: string;\r\n readonly displayLabel: string;\r\n readonly description: string;\r\n readonly references: string;\r\n readonly items: string;\r\n}\r\n\r\ninterface BaseClassStubRow {\r\n readonly schema: string;\r\n readonly name: string;\r\n readonly schemaItemType: string;\r\n readonly modifier: number;\r\n}\r\n\r\ninterface SchemaItemStubRow {\r\n readonly name: string;\r\n readonly schemaItemType: string;\r\n readonly modifier?: number;\r\n readonly baseClasses?: Array<BaseClassStubRow>;\r\n readonly mixins?: Array<{\r\n readonly schema: string,\r\n readonly name: string;\r\n readonly schemaItemType: string;\r\n readonly modifier: number;\r\n readonly baseClasses?: Array<BaseClassStubRow>\r\n }>;\r\n}\r\n\r\ninterface SchemaRow {\r\n schema: string\r\n}\r\n\r\ninterface SchemaItemRow {\r\n item: string | SchemaItemProps;\r\n}\r\n\r\ntype AddSchemaItemHandler = <T extends SchemaItemInfo>(schemaName: string, itemStub: T) => Promise<void>;\r\n\r\ntype MutableSchemaProps = {\r\n -readonly [K in keyof SchemaProps]: SchemaProps[K];\r\n};\r\n\r\ninterface QueryParameters {\r\n [parameterName: string]: string | number;\r\n}\r\n\r\nconst LOGGER_CATEGORY = \"IncrementalSchemaLoading.Performance\";\r\n\r\n/**\r\n * Query options used by the ECSqlSchemaLocater.\r\n * @internal\r\n */\r\nexport interface ECSqlQueryOptions {\r\n parameters?: QueryParameters;\r\n limit?: number;\r\n}\r\n\r\n/**\r\n * Defines the [[ECSqlSchemaLocater]] options which determine how each\r\n * schema is to be loaded. All options are optional.\r\n * @internal\r\n */\r\nexport interface ECSqlSchemaLocaterOptions extends SchemaLocaterOptions {\r\n /** Query for Schemas using multiple queries. Defaults to false. */\r\n readonly useMultipleQueries?: boolean;\r\n}\r\n\r\n/**\r\n * An abstract [[IncrementalSchemaLocater]] implementation for loading\r\n * EC [Schema] instances from an iModelDb using ECSql queries.\r\n * @internal\r\n */\r\nexport abstract class ECSqlSchemaLocater extends IncrementalSchemaLocater {\r\n /**\r\n * Gets the [[ECSqlSchemaLocaterOptions]] used by this locater.\r\n */\r\n protected override get options(): ECSqlSchemaLocaterOptions {\r\n return super.options as ECSqlSchemaLocaterOptions;\r\n }\r\n\r\n /**\r\n * Initializes a new ECSqlSchemaLocater instance.\r\n * @param options The options used by this Schema locater.\r\n */\r\n constructor(options?: ECSqlSchemaLocaterOptions) {\r\n super(options);\r\n }\r\n\r\n /**\r\n * Executes the given ECSql query and returns the resulting rows.\r\n * @param query The ECSql query to execute.\r\n * @param options Optional arguments to control the query result.\r\n * @returns A promise that resolves to the resulting rows.\r\n */\r\n protected abstract executeQuery<TRow>(query: string, options?: ECSqlQueryOptions): Promise<ReadonlyArray<TRow>>;\r\n\r\n /**\r\n * Gets the [[SchemaProps]] for the given schema key.\r\n * @param schemaKey The schema key of the schema to be resolved.\r\n */\r\n protected abstract getSchemaProps(schemaKey: SchemaKey): Promise<SchemaProps | undefined>\r\n\r\n /**\r\n * Gets the [[SchemaProps]] for the given schema key. This is the full schema json with all elements that are defined\r\n * in the schema. The schema locater calls this after the stub has been loaded to fully load the schema in the background.\r\n * @param schemaKey The [[SchemaKey]] of the schema to be resolved.\r\n * @param context The [[SchemaContext]] to use for resolving references.\r\n * @internal\r\n */\r\n protected async getSchemaJson(schemaKey: SchemaKey, context: SchemaContext): Promise<SchemaProps | undefined> {\r\n // If the meta schema is an earlier version than 4.0.3, we can't use the ECSql query interface to get the schema\r\n // information required to load the schema entirely. In this case, we fallback to use the ECSchema RPC interface\r\n // to fetch the whole schema json.\r\n if (!await this.supportPartialSchemaLoading(context))\r\n return this.getSchemaProps(schemaKey);\r\n\r\n const queryStart = Date.now();\r\n const schemaProps = this.options.useMultipleQueries\r\n ? await this.getFullSchemaMultipleQueries(schemaKey, context)\r\n : await this.getFullSchema(schemaKey, context);\r\n\r\n const queryDuration = Date.now() - queryStart;\r\n Logger.logTrace(LOGGER_CATEGORY, `Recieved SchemaProps for ${schemaKey.name} in ${queryDuration}ms`, {\r\n schemaName: schemaKey.name,\r\n queryMode: this.options.useMultipleQueries ? \"parallel\" : \"single\",\r\n duration: queryDuration,\r\n });\r\n\r\n return schemaProps;\r\n };\r\n\r\n /**\r\n * Gets the [[SchemaProps]] without schemaItems for the given schema name.\r\n * @param schemaName The name of the Schema.\r\n * @param context The [[SchemaContext]] to use for resolving references.\r\n * @returns\r\n * @internal\r\n */\r\n private async getSchemaNoItems(schemaName: string, context: SchemaContext): Promise<SchemaProps | undefined> {\r\n const schemaRows = await this.executeQuery<SchemaRow>(FullSchemaQueries.schemaNoItemsQuery, { parameters: { schemaName } });\r\n const schemaRow = schemaRows[0];\r\n if (schemaRow === undefined)\r\n return undefined;\r\n\r\n const schema = JSON.parse(schemaRow.schema) as SchemaProps;\r\n const schemaInfos = await this._schemaInfoCache.getSchemasByContext(context) ?? [];\r\n return SchemaParser.parse(schema, schemaInfos);\r\n }\r\n\r\n /**\r\n * Checks if the [[SchemaContext]] has the right Meta Schema version to support the incremental schema loading.\r\n * @param context The schema context to lookup the meta schema.\r\n * @returns true if the context has a supported meta schema version, false otherwise.\r\n */\r\n protected async supportPartialSchemaLoading(context: SchemaContext): Promise<boolean> {\r\n const metaSchemaKey = new SchemaKey(\"ECDbMeta\", 4, 0, 3);\r\n const metaSchemaInfo = await context.getSchemaInfo(metaSchemaKey, SchemaMatchType.LatestWriteCompatible);\r\n return metaSchemaInfo !== undefined;\r\n };\r\n\r\n /**\r\n * Gets all the Schema's Entity classes as [[EntityClassProps]] JSON objects.\r\n * @param schemaName The name of the Schema.\r\n * @param context The [[SchemaContext]] to which the schema belongs.\r\n * @returns A promise that resolves to a EntityClassProps array. Maybe empty of no entities are found.\r\n * @internal\r\n */\r\n protected async getEntities(schema: string, context: SchemaContext, queryOverride?: string): Promise<EntityClassProps[]> {\r\n const query = queryOverride ?? FullSchemaQueries.entityQuery;\r\n return this.querySchemaItem<EntityClassProps>(context, schema, query, \"EntityClass\");\r\n }\r\n\r\n /**\r\n * Gets all the Schema's Mixin classes as [[MixinProps]] JSON objects.\r\n * @param schemaName The name of the Schema.\r\n * @param context The SchemaContext to which the schema belongs.\r\n * @returns A promise that resolves to a MixinProps array. Maybe empty of no entities are found.\r\n * @internal\r\n */\r\n protected async getMixins(schema: string, context: SchemaContext, queryOverride?: string): Promise<MixinProps[]> {\r\n const query = queryOverride ?? FullSchemaQueries.mixinQuery;\r\n return this.querySchemaItem<MixinProps>(context, schema, query, \"Mixin\");\r\n }\r\n\r\n /**\r\n * Gets all the Schema's Relationship classes as [[RelationshipClassProps]] JSON objects.\r\n * @param schemaName The name of the Schema.\r\n * @param context The SchemaContext to which the schema belongs.\r\n * @returns A promise that resolves to a RelationshipClassProps array. Maybe empty if no items are found.\r\n * @internal\r\n */\r\n protected async getRelationships(schema: string, context: SchemaContext, queryOverride?: string): Promise<RelationshipClassProps[]> {\r\n const query = queryOverride ?? FullSchemaQueries.relationshipClassQuery;\r\n return this.querySchemaItem<RelationshipClassProps>(context, schema, query, \"RelationshipClass\");\r\n }\r\n\r\n /**\r\n * Gets all the Schema's CustomAttributeClass items as [[CustomAttributeClassProps]] JSON objects.\r\n * @param schemaName The name of the Schema.\r\n * @param context The SchemaContext to which the schema belongs.\r\n * @returns A promise that resolves to a CustomAttributeClassProps array. Maybe empty if not items are found.\r\n * @internal\r\n */\r\n protected async getCustomAttributeClasses(schema: string, context: SchemaContext, queryOverride?: string): Promise<CustomAttributeClassProps[]> {\r\n const query = queryOverride ?? FullSchemaQueries.customAttributeQuery;\r\n return this.querySchemaItem<CustomAttributeClassProps>(context, schema, query, \"CustomAttributeClass\");\r\n }\r\n\r\n\r\n /**\r\n * Gets all the Schema's StructClass items as [[StructClassProps]] JSON objects.\r\n * @param schemaName The name of the Schema.\r\n * @param context The SchemaContext to which the schema belongs.\r\n * @returns A promise that resolves to a StructClassProps array. Maybe empty if not items are found.\r\n * @internal\r\n */\r\n protected async getStructs(schema: string, context: SchemaContext, queryOverride?: string): Promise<StructClassProps[]> {\r\n const query = queryOverride ?? FullSchemaQueries.structQuery;\r\n return this.querySchemaItem<StructClassProps>(context, schema, query, \"StructClass\");\r\n }\r\n\r\n /**\r\n * Gets all the Schema's KindOfQuantity items as [[KindOfQuantityProps]] JSON objects.\r\n * @param schema The name of the Schema.\r\n * @param context The SchemaContext to which the schema belongs.\r\n * @returns A promise that resolves to a KindOfQuantityProps array. Maybe empty if not items are found.\r\n * @internal\r\n */\r\n protected async getKindOfQuantities(schema: string, context: SchemaContext): Promise<KindOfQuantityProps[]> {\r\n return this.querySchemaItem<KindOfQuantityProps>(context, schema, SchemaItemQueries.kindOfQuantity(true), \"KindOfQuantity\");\r\n }\r\n\r\n /**\r\n * Gets all the Schema's PropertyCategory items as [[PropertyCategoryProps]] JSON objects.\r\n * @param schema The name of the Schema.\r\n * @param context The SchemaContext to which the schema belongs.\r\n * @returns A promise that resolves to a PropertyCategoryProps array. Maybe empty if not items are found.\r\n * @internal\r\n */\r\n protected async getPropertyCategories(schema: string, context: SchemaContext): Promise<PropertyCategoryProps[]> {\r\n return this.querySchemaItem<PropertyCategoryProps>(context, schema, SchemaItemQueries.propertyCategory(true), \"PropertyCategory\");\r\n }\r\n\r\n /**\r\n * Gets all the Schema's Enumeration items as [[EnumerationProps]] JSON objects.\r\n * @param schema The name of the Schema.\r\n * @param context The SchemaContext to which the schema belongs.\r\n * @returns A promise that resolves to a EnumerationProps array. Maybe empty if not items are found.\r\n * @internal\r\n */\r\n protected async getEnumerations(schema: string, context: SchemaContext): Promise<EnumerationProps[]> {\r\n return this.querySchemaItem<EnumerationProps>(context, schema, SchemaItemQueries.enumeration(true), \"Enumeration\");\r\n }\r\n\r\n /**\r\n * Gets all the Schema's Unit items as [[SchemaItemUnitProps]] JSON objects.\r\n * @param schema The name of the Schema.\r\n * @param context The SchemaContext to which the schema belongs.\r\n * @returns A promise that resolves to a SchemaItemUnitProps array. Maybe empty if not items are found.\r\n * @internal\r\n */\r\n protected async getUnits(schema: string, context: SchemaContext): Promise<SchemaItemUnitProps[]> {\r\n return this.querySchemaItem<SchemaItemUnitProps>(context, schema, SchemaItemQueries.unit(true), \"Unit\");\r\n }\r\n\r\n /**\r\n * Gets all the Schema's InvertedUnit items as [[InvertedUnitProps]] JSON objects.\r\n * @param schema The name of the Schema.\r\n * @param context The SchemaContext to which the schema belongs.\r\n * @returns A promise that resolves to a InvertedUnitProps array. Maybe empty if not items are found.\r\n * @internal\r\n */\r\n protected async getInvertedUnits(schema: string, context: SchemaContext): Promise<InvertedUnitProps[]> {\r\n return this.querySchemaItem<InvertedUnitProps>(context, schema, SchemaItemQueries.invertedUnit(true), \"InvertedUnit\");\r\n }\r\n\r\n /**\r\n * Gets all the Schema's Constant items as [[ConstantProps]] JSON objects.\r\n * @param schema The name of the Schema.\r\n * @param context The SchemaContext to which the schema belongs.\r\n * @returns A promise that resolves to a ConstantProps array. Maybe empty if not items are found.\r\n * @internal\r\n */\r\n protected async getConstants(schema: string, context: SchemaContext): Promise<ConstantProps[]> {\r\n return this.querySchemaItem<ConstantProps>(context, schema, SchemaItemQueries.constant(true), \"Constant\");\r\n }\r\n\r\n /**\r\n * Gets all the Schema's UnitSystem items as [[UnitSystemProps]] JSON objects.\r\n * @param schema The name of the Schema.\r\n * @param context The SchemaContext to which the schema belongs.\r\n * @returns A promise that resolves to a UnitSystemProps array. Maybe empty if not items are found.\r\n * @internal\r\n */\r\n protected async getUnitSystems(schema: string, context: SchemaContext): Promise<UnitSystemProps[]> {\r\n return this.querySchemaItem<UnitSystemProps>(context, schema, SchemaItemQueries.unitSystem(true), \"UnitSystem\");\r\n }\r\n\r\n /**\r\n * Gets all the Schema's Phenomenon items as [[PhenomenonProps]] JSON objects.\r\n * @param schema The name of the Schema.\r\n * @param context The SchemaContext to which the schema belongs.\r\n * @returns A promise that resolves to a PhenomenonProps array. Maybe empty if not items are found.\r\n * @internal\r\n */\r\n protected async getPhenomenon(schema: string, context: SchemaContext): Promise<PhenomenonProps[]> {\r\n return this.querySchemaItem<PhenomenonProps>(context, schema, SchemaItemQueries.phenomenon(true), \"Phenomenon\");\r\n }\r\n\r\n /**\r\n * Gets all the Schema's Format items as [[SchemaItemFormatProps]] JSON objects.\r\n * @param schema The name of the Schema.\r\n * @param context The SchemaContext to which the schema belongs.\r\n * @returns A promise that resolves to a SchemaItemFormatProps array. Maybe empty if not items are found.\r\n * @internal\r\n */\r\n protected async getFormats(schema: string, context: SchemaContext): Promise<SchemaItemFormatProps[]> {\r\n return this.querySchemaItem<SchemaItemFormatProps>(context, schema, SchemaItemQueries.format(true), \"Format\");\r\n }\r\n\r\n /**\r\n * Gets [[SchemaInfo]] objects for all schemas including their direct schema references.\r\n * @internal\r\n */\r\n protected async loadSchemaInfos(): Promise<ReadonlyArray<SchemaInfo>> {\r\n const schemaRows = await this.executeQuery<SchemaInfoRow>(ecsqlQueries.schemaInfoQuery);\r\n return schemaRows.map((schemaRow) => (\r\n {\r\n alias: schemaRow.alias,\r\n schemaKey: SchemaKey.parseString(`${schemaRow.name}.${schemaRow.version}`),\r\n references: Array.from(JSON.parse(schemaRow.references), parseSchemaReference),\r\n }\r\n ));\r\n }\r\n\r\n /**\r\n * Gets the [[SchemaProps]] to create the basic schema skeleton. Depending on which options are set, the schema items or class hierarchy\r\n * can be included in the initial fetch.\r\n * @param schemaKey The [[SchemaKey]] of the schema to be resolved.\r\n * @returns A promise that resolves to the schema partials, which is an array of [[SchemaProps]].\r\n * @internal\r\n */\r\n protected async getSchemaPartials(schemaKey: SchemaKey, context: SchemaContext): Promise<ReadonlyArray<SchemaProps> | undefined> {\r\n const queryStart = Date.now();\r\n const [schemaRow] = await this.executeQuery<SchemaStubRow>(ecsqlQueries.schemaStubQuery, {\r\n parameters: { schemaName: schemaKey.name },\r\n limit: 1\r\n });\r\n\r\n const queryDuration = Date.now() - queryStart;\r\n Logger.logTrace(LOGGER_CATEGORY, `Recieved PartialSchema for ${schemaKey.name} in ${queryDuration}ms`, {\r\n schemaName: schemaKey.name,\r\n duration: queryDuration,\r\n });\r\n\r\n if (!schemaRow)\r\n return undefined;\r\n\r\n const schemaPartials: Array<SchemaProps> = [];\r\n const addSchema = async (key: SchemaKey) => {\r\n const stub = await this.createSchemaProps(key, context);\r\n schemaPartials.push(stub);\r\n\r\n if (stub.references) {\r\n for (const referenceProps of stub.references) {\r\n if (!schemaPartials.some((schema) => schema.name === referenceProps.name)) {\r\n await addSchema(SchemaKey.parseString(`${referenceProps.name}.${referenceProps.version}`));\r\n }\r\n }\r\n }\r\n\r\n return stub;\r\n };\r\n\r\n const addItems = async (schemaName: string, itemInfo: SchemaItemInfo) => {\r\n let schemaStub = schemaPartials.find((schema) => schema.name === schemaName);\r\n if (!schemaStub) {\r\n schemaStub = await addSchema(SchemaKey.parseString(`${schemaName}.0.0.0`));\r\n }\r\n\r\n let items = schemaStub.items;\r\n if (!items) {\r\n Object.assign(schemaStub, items = { items: {} });\r\n }\r\n\r\n const existingItem = items[itemInfo.name] || {};\r\n Object.assign(items, { [itemInfo.name]: Object.assign(existingItem, itemInfo) });\r\n };\r\n\r\n const reviver = (_key: string, value: any) => {\r\n if (value === null) {\r\n return undefined;\r\n }\r\n return value;\r\n };\r\n\r\n await addSchema(schemaKey);\r\n\r\n const schemaInfos = await this._schemaInfoCache.getSchemasByContext(context) ?? [];\r\n await parseSchemaItemStubs(schemaKey.name, JSON.parse(schemaRow.items, reviver), addItems, schemaInfos);\r\n\r\n return schemaPartials;\r\n }\r\n\r\n private async querySchemaItem<TRow extends SchemaItemProps>(context: SchemaContext, schemaName: string, query: string, schemaType: string): Promise<Array<TRow>> {\r\n const start = Date.now();\r\n const itemRows = await this.executeQuery<SchemaItemRow>(query, { parameters: { schemaName } });\r\n\r\n const queryDuration = Date.now() - start;\r\n Logger.logTrace(LOGGER_CATEGORY, `Recieved rows of ${schemaType} items for ${schemaName} in ${queryDuration}ms`, {\r\n schemaName,\r\n itemCount: itemRows.length,\r\n itemType: schemaType,\r\n duration: queryDuration,\r\n });\r\n\r\n if (itemRows.length === 0)\r\n return [];\r\n\r\n const items = itemRows.map((itemRow: SchemaItemRow) => {\r\n return \"string\" === typeof itemRow.item ? JSON.parse(itemRow.item) : itemRow.item;\r\n });\r\n\r\n const schemaInfos = await this._schemaInfoCache.getSchemasByContext(context) ?? [];\r\n return await SchemaParser.parseSchemaItems(items, schemaName, schemaInfos) as Array<TRow> ?? []\r\n }\r\n\r\n private async getFullSchema(schemaKey: SchemaKey, context: SchemaContext): Promise<SchemaProps | undefined> {\r\n const schemaRows = await this.executeQuery<SchemaRow>(FullSchemaQueries.schemaQuery, { parameters: { schemaName: schemaKey.name } });\r\n const schemaRow = schemaRows[0];\r\n if (schemaRow === undefined)\r\n return undefined;\r\n\r\n // Map SchemaItemRow array, [{item: SchemaItemProps}], to array of SchemaItemProps.\r\n const schema = JSON.parse(schemaRow.schema) as SchemaProps;\r\n if (schema.items) {\r\n (schema as any).items = (schema.items as any).map((itemRow: SchemaItemRow) => { return itemRow.item; });\r\n }\r\n\r\n const schemaInfos = await this._schemaInfoCache.getSchemasByContext(context) ?? [];\r\n return SchemaParser.parse(schema, schemaInfos);\r\n }\r\n\r\n private async getFullSchemaMultipleQueries(schemaKey: SchemaKey, context: SchemaContext): Promise<SchemaProps | undefined> {\r\n const schema = await this.getSchemaNoItems(schemaKey.name, context) as MutableSchemaProps;\r\n if (!schema)\r\n return undefined;\r\n\r\n const items = schema.items || (schema.items = {});\r\n await Promise.all([\r\n this.getEntities(schemaKey.name, context),\r\n this.getMixins(schemaKey.name, context),\r\n this.getStructs(schemaKey.name, context),\r\n this.getRelationships(schemaKey.name, context),\r\n this.getCustomAttributeClasses(schemaKey.name, context),\r\n this.getKindOfQuantities(schemaKey.name, context),\r\n this.getPropertyCategories(schemaKey.name, context),\r\n this.getEnumerations(schemaKey.name, context),\r\n this.getUnits(schemaKey.name, context),\r\n this.getInvertedUnits(schemaKey.name, context),\r\n this.getUnitSystems(schemaKey.name, context),\r\n this.getConstants(schemaKey.name, context),\r\n this.getPhenomenon(schemaKey.name, context),\r\n this.getFormats(schemaKey.name, context)\r\n ]).then((itemResults) => {\r\n const flatItemList = itemResults.reduce((acc, result) => acc.concat(result));\r\n flatItemList.forEach((schemaItem) => {\r\n if(!schemaItem.name) {\r\n // This should never be happen, as we query the schema items by name from the database, but since the SchemaProps\r\n // have name optional, we need the check here to make the compiler happy.\r\n throw new Error(`SchemaItem with no name encountered in schema ${schemaKey.name}`);\r\n }\r\n items[schemaItem.name] = schemaItem;\r\n });\r\n });\r\n\r\n return schema;\r\n }\r\n}\r\n\r\nfunction parseSchemaReference(referenceName: string): WithSchemaKey {\r\n return { schemaKey: SchemaKey.parseString(referenceName) };\r\n}\r\n\r\nasync function parseSchemaItemStubs(schemaName: string, itemRows: Array<SchemaItemStubRow>, addItemsHandler: AddSchemaItemHandler, schemaInfos: Iterable<SchemaInfo>) {\r\n if (!itemRows || itemRows.length === 0) {\r\n return;\r\n }\r\n\r\n const parseBaseClasses = async (baseClasses: Array<BaseClassStubRow> | undefined) => {\r\n if (!baseClasses || baseClasses.length < 2)\r\n return;\r\n\r\n for (let index = baseClasses.length - 1; index >= 0;) {\r\n const currentItem = baseClasses[index--];\r\n const baseClassItem = baseClasses[index];\r\n const baseClassName = baseClassItem ? `${baseClassItem.schema}.${baseClassItem.name}` : undefined;\r\n\r\n const schemaItem = await SchemaParser.parseItem(currentItem, currentItem.schema, schemaInfos);\r\n await addItemsHandler(currentItem.schema, {\r\n ...schemaItem,\r\n name: schemaItem.name,\r\n schemaItemType: schemaItem.schemaItemType,\r\n baseClass: baseClassName,\r\n });\r\n }\r\n };\r\n\r\n for (const itemRow of itemRows) {\r\n const schemaItem = await SchemaParser.parseItem(itemRow, schemaName, schemaInfos);\r\n await addItemsHandler(schemaName, {\r\n ...schemaItem,\r\n name: schemaItem.name,\r\n schemaItemType: schemaItem.schemaItemType,\r\n mixins: itemRow.mixins\r\n ? itemRow.mixins.map(mixin => { return `${mixin.schema}.${mixin.name}`; })\r\n : undefined,\r\n });\r\n\r\n await parseBaseClasses(itemRow.baseClasses);\r\n\r\n for (const mixinRow of itemRow.mixins || []) {\r\n const mixinItem = await SchemaParser.parseItem(mixinRow, mixinRow.schema, schemaInfos);\r\n await addItemsHandler(mixinRow.schema, {\r\n ...mixinItem,\r\n name: mixinItem.name,\r\n schemaItemType: mixinItem.schemaItemType,\r\n });\r\n await parseBaseClasses(mixinRow.baseClasses);\r\n }\r\n }\r\n}\r\n"]}
|