@itwin/ecschema-metadata 5.2.0-dev.7 → 5.3.0-dev.1
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 +36 -1
- package/lib/cjs/Deserialization/JsonProps.d.ts +9 -2
- package/lib/cjs/Deserialization/JsonProps.d.ts.map +1 -1
- package/lib/cjs/Deserialization/JsonProps.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/ECSqlSchemaLocater.d.ts +18 -24
- package/lib/cjs/IncrementalLoading/ECSqlSchemaLocater.d.ts.map +1 -1
- package/lib/cjs/IncrementalLoading/ECSqlSchemaLocater.js +62 -34
- package/lib/cjs/IncrementalLoading/ECSqlSchemaLocater.js.map +1 -1
- package/lib/cjs/IncrementalLoading/FullSchemaQueries.d.ts.map +1 -1
- package/lib/cjs/IncrementalLoading/FullSchemaQueries.js +1 -0
- package/lib/cjs/IncrementalLoading/FullSchemaQueries.js.map +1 -1
- package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.d.ts +20 -3
- package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.d.ts.map +1 -1
- package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.js +7 -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 +17 -17
- package/lib/cjs/IncrementalLoading/SchemaItemParsers.js.map +1 -1
- package/lib/cjs/IncrementalLoading/SchemaItemQueries.js +4 -4
- 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.d.ts.map +1 -1
- package/lib/cjs/IncrementalLoading/SchemaStubQueries.js +7 -24
- package/lib/cjs/IncrementalLoading/SchemaStubQueries.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/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/Schema.d.ts +2 -0
- package/lib/cjs/Metadata/Schema.d.ts.map +1 -1
- package/lib/cjs/Metadata/Schema.js +4 -0
- package/lib/cjs/Metadata/Schema.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/esm/Deserialization/JsonProps.d.ts +9 -2
- package/lib/esm/Deserialization/JsonProps.d.ts.map +1 -1
- package/lib/esm/Deserialization/JsonProps.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/ECSqlSchemaLocater.d.ts +18 -24
- package/lib/esm/IncrementalLoading/ECSqlSchemaLocater.d.ts.map +1 -1
- package/lib/esm/IncrementalLoading/ECSqlSchemaLocater.js +61 -33
- package/lib/esm/IncrementalLoading/ECSqlSchemaLocater.js.map +1 -1
- package/lib/esm/IncrementalLoading/FullSchemaQueries.d.ts.map +1 -1
- package/lib/esm/IncrementalLoading/FullSchemaQueries.js +1 -0
- package/lib/esm/IncrementalLoading/FullSchemaQueries.js.map +1 -1
- package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.d.ts +20 -3
- package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.d.ts.map +1 -1
- package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js +7 -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 +17 -17
- package/lib/esm/IncrementalLoading/SchemaItemParsers.js.map +1 -1
- package/lib/esm/IncrementalLoading/SchemaItemQueries.js +4 -4
- 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.d.ts.map +1 -1
- package/lib/esm/IncrementalLoading/SchemaStubQueries.js +7 -24
- package/lib/esm/IncrementalLoading/SchemaStubQueries.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/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/Schema.d.ts +2 -0
- package/lib/esm/Metadata/Schema.d.ts.map +1 -1
- package/lib/esm/Metadata/Schema.js +4 -0
- package/lib/esm/Metadata/Schema.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/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,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Contains the properties needed to track load times
|
|
3
|
-
* for SchemaItem queries.
|
|
4
|
-
* @internal
|
|
5
|
-
*/
|
|
6
|
-
export interface SchemaItemLoadData {
|
|
7
|
-
loadTime: number;
|
|
8
|
-
itemCount: number;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Contains the properties needed to track load times
|
|
12
|
-
* for Schema queries.
|
|
13
|
-
* @internal
|
|
14
|
-
*/
|
|
15
|
-
export interface SchemaLoadData {
|
|
16
|
-
loadTime?: number;
|
|
17
|
-
schemaItemMap: Map<string, SchemaItemLoadData>;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Utility class used to log query load times for Schema and
|
|
21
|
-
* SchemaItem queries.
|
|
22
|
-
* @internal
|
|
23
|
-
*/
|
|
24
|
-
export declare class PerformanceLogger {
|
|
25
|
-
private _iModelItems;
|
|
26
|
-
private _label;
|
|
27
|
-
disableLogging: boolean;
|
|
28
|
-
/**
|
|
29
|
-
* Initializes a new PerformanceLogger instance.
|
|
30
|
-
* @param label Arbitrary label used to tag this logging session (ex. IModel name)
|
|
31
|
-
*/
|
|
32
|
-
constructor(label?: string);
|
|
33
|
-
/**
|
|
34
|
-
* Gets the Map of logged Schema entries. The Map key is the iModel name. The Map
|
|
35
|
-
* value is a second Map whose key is a Schema name and value is a SchemaLoadData
|
|
36
|
-
* object.
|
|
37
|
-
*/
|
|
38
|
-
get logItems(): Map<string, Map<string, SchemaLoadData>>;
|
|
39
|
-
/**
|
|
40
|
-
* Adds a new log entry to the Schema Map.
|
|
41
|
-
* @param startTime The start time of the entry to be logged (end time/duration is handled in this method).
|
|
42
|
-
* @param schemaName The Schema being queried.
|
|
43
|
-
*/
|
|
44
|
-
logSchema(startTime: number, schemaName: string): void;
|
|
45
|
-
/**
|
|
46
|
-
* Adds a new log entry to the SchemaItem Map.
|
|
47
|
-
* @param startTime The start time of the entry to be logged (end time/duration is handled in this method).
|
|
48
|
-
* @param schemaName The name of the Schema being queried.
|
|
49
|
-
* @param schemaItemType The SchemaItemType name of the type being queried.
|
|
50
|
-
* @param itemCount The number of items retrieved in the query.
|
|
51
|
-
*/
|
|
52
|
-
logSchemaItem(startTime: number, schemaName: string, schemaItemType: string, itemCount: number): void;
|
|
53
|
-
/**
|
|
54
|
-
* Clears all log entries from the Map.
|
|
55
|
-
*/
|
|
56
|
-
clearLogs(): void;
|
|
57
|
-
private getSchemaMap;
|
|
58
|
-
private getSchemaLoadData;
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=PerformanceLogger.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PerformanceLogger.d.ts","sourceRoot":"","sources":["../../../src/IncrementalLoading/PerformanceLogger.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;CAChD;AAED;;;;GAIG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,YAAY,CAAuD;IAC3E,OAAO,CAAC,MAAM,CAAS;IAGhB,cAAc,UAAS;IAE9B;;;OAGG;gBACS,KAAK,CAAC,EAAE,MAAM;IAI1B;;;;OAIG;IACH,IAAW,QAAQ,IAAI,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAE9D;IAED;;;;OAIG;IACI,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAYtD;;;;;;OAMG;IACI,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;IAerG;;OAEG;IACI,SAAS;IAIhB,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,iBAAiB;CAM1B"}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
/**
|
|
6
|
-
* Utility class used to log query load times for Schema and
|
|
7
|
-
* SchemaItem queries.
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
export class PerformanceLogger {
|
|
11
|
-
_iModelItems = new Map();
|
|
12
|
-
_label;
|
|
13
|
-
// flag that controls if logging is enabled.
|
|
14
|
-
disableLogging = false;
|
|
15
|
-
/**
|
|
16
|
-
* Initializes a new PerformanceLogger instance.
|
|
17
|
-
* @param label Arbitrary label used to tag this logging session (ex. IModel name)
|
|
18
|
-
*/
|
|
19
|
-
constructor(label) {
|
|
20
|
-
this._label = label || "";
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Gets the Map of logged Schema entries. The Map key is the iModel name. The Map
|
|
24
|
-
* value is a second Map whose key is a Schema name and value is a SchemaLoadData
|
|
25
|
-
* object.
|
|
26
|
-
*/
|
|
27
|
-
get logItems() {
|
|
28
|
-
return this._iModelItems;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Adds a new log entry to the Schema Map.
|
|
32
|
-
* @param startTime The start time of the entry to be logged (end time/duration is handled in this method).
|
|
33
|
-
* @param schemaName The Schema being queried.
|
|
34
|
-
*/
|
|
35
|
-
logSchema(startTime, schemaName) {
|
|
36
|
-
if (this.disableLogging)
|
|
37
|
-
return;
|
|
38
|
-
const loadTime = new Date().getTime() - startTime;
|
|
39
|
-
const schemaMap = this.getSchemaMap(this._label);
|
|
40
|
-
const schemaLoadData = this.getSchemaLoadData(schemaMap, schemaName);
|
|
41
|
-
schemaLoadData.loadTime = loadTime;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Adds a new log entry to the SchemaItem Map.
|
|
45
|
-
* @param startTime The start time of the entry to be logged (end time/duration is handled in this method).
|
|
46
|
-
* @param schemaName The name of the Schema being queried.
|
|
47
|
-
* @param schemaItemType The SchemaItemType name of the type being queried.
|
|
48
|
-
* @param itemCount The number of items retrieved in the query.
|
|
49
|
-
*/
|
|
50
|
-
logSchemaItem(startTime, schemaName, schemaItemType, itemCount) {
|
|
51
|
-
if (this.disableLogging)
|
|
52
|
-
return;
|
|
53
|
-
const loadTime = new Date().getTime() - startTime;
|
|
54
|
-
const schemaMap = this.getSchemaMap(this._label);
|
|
55
|
-
const schemaLoadData = this.getSchemaLoadData(schemaMap, schemaName);
|
|
56
|
-
if (schemaLoadData.schemaItemMap.has(schemaItemType))
|
|
57
|
-
throw new Error("There should not be a multiple load times for a given iModel, Schema, SchemaItemType combination.");
|
|
58
|
-
schemaLoadData.schemaItemMap.set(schemaItemType, { loadTime, itemCount });
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Clears all log entries from the Map.
|
|
62
|
-
*/
|
|
63
|
-
clearLogs() {
|
|
64
|
-
this._iModelItems.clear();
|
|
65
|
-
}
|
|
66
|
-
getSchemaMap(iModel) {
|
|
67
|
-
if (!this._iModelItems.has(iModel)) {
|
|
68
|
-
this._iModelItems.set(iModel, new Map());
|
|
69
|
-
}
|
|
70
|
-
return this._iModelItems.get(iModel);
|
|
71
|
-
}
|
|
72
|
-
getSchemaLoadData(schemaMap, schemaName) {
|
|
73
|
-
if (!schemaMap.has(schemaName))
|
|
74
|
-
schemaMap.set(schemaName, { schemaItemMap: new Map() });
|
|
75
|
-
return schemaMap.get(schemaName);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
//# sourceMappingURL=PerformanceLogger.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PerformanceLogger.js","sourceRoot":"","sources":["../../../src/IncrementalLoading/PerformanceLogger.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAsBhG;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IACpB,YAAY,GAA6C,IAAI,GAAG,EAAE,CAAC;IACnE,MAAM,CAAS;IAEvB,4CAA4C;IACrC,cAAc,GAAG,KAAK,CAAC;IAE9B;;;OAGG;IACH,YAAY,KAAc;QACxB,IAAI,CAAC,MAAM,GAAG,KAAK,IAAI,EAAE,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACH,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACI,SAAS,CAAC,SAAiB,EAAE,UAAkB;QACpD,IAAI,IAAI,CAAC,cAAc;YACrB,OAAO;QAET,MAAM,QAAQ,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,SAAS,CAAC;QAElD,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACjD,MAAM,cAAc,GAAG,IAAI,CAAC,iBAAiB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QAErE,cAAc,CAAC,QAAQ,GAAG,QAAQ,CAAC;IACrC,CAAC;IAED;;;;;;OAMG;IACI,aAAa,CAAC,SAAiB,EAAE,UAAkB,EAAE,cAAsB,EAAE,SAAiB;QACnG,IAAI,IAAI,CAAC,cAAc;YACrB,OAAO;QAET,MAAM,QAAQ,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,SAAS,CAAC;QAElD,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACjD,MAAM,cAAc,GAAG,IAAI,CAAC,iBAAiB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QAErE,IAAI,cAAc,CAAC,aAAa,CAAC,GAAG,CAAC,cAAc,CAAC;YAClD,MAAM,IAAI,KAAK,CAAC,mGAAmG,CAAC,CAAC;QAEvH,cAAc,CAAC,aAAa,CAAC,GAAG,CAAC,cAAc,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC;IAC5E,CAAC;IAED;;OAEG;IACI,SAAS;QACd,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC;IAEO,YAAY,CAAC,MAAc;QACjC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YACnC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;QAC3C,CAAC;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAgC,CAAC;IACtE,CAAC;IAEO,iBAAiB,CAAC,SAAsC,EAAE,UAAkB;QAClF,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC;YAC5B,SAAS,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,aAAa,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC,CAAA;QAEzD,OAAO,SAAS,CAAC,GAAG,CAAC,UAAU,CAAmB,CAAC;IACrD,CAAC;CACF","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\n/**\n * Contains the properties needed to track load times\n * for SchemaItem queries.\n * @internal\n */\nexport interface SchemaItemLoadData {\n loadTime: number,\n itemCount: number\n}\n\n/**\n * Contains the properties needed to track load times\n * for Schema queries.\n * @internal\n */\nexport interface SchemaLoadData {\n loadTime?: number,\n schemaItemMap: Map<string, SchemaItemLoadData>;\n}\n\n/**\n * Utility class used to log query load times for Schema and\n * SchemaItem queries.\n * @internal\n */\nexport class PerformanceLogger {\n private _iModelItems: Map<string, Map<string, SchemaLoadData>> = new Map();\n private _label: string;\n\n // flag that controls if logging is enabled.\n public disableLogging = false;\n\n /**\n * Initializes a new PerformanceLogger instance.\n * @param label Arbitrary label used to tag this logging session (ex. IModel name)\n */\n constructor(label?: string) {\n this._label = label || \"\";\n }\n\n /**\n * Gets the Map of logged Schema entries. The Map key is the iModel name. The Map\n * value is a second Map whose key is a Schema name and value is a SchemaLoadData\n * object.\n */\n public get logItems(): Map<string, Map<string, SchemaLoadData>> {\n return this._iModelItems;\n }\n\n /**\n * Adds a new log entry to the Schema Map.\n * @param startTime The start time of the entry to be logged (end time/duration is handled in this method).\n * @param schemaName The Schema being queried.\n */\n public logSchema(startTime: number, schemaName: string) {\n if (this.disableLogging)\n return;\n\n const loadTime = new Date().getTime() - startTime;\n\n const schemaMap = this.getSchemaMap(this._label);\n const schemaLoadData = this.getSchemaLoadData(schemaMap, schemaName);\n\n schemaLoadData.loadTime = loadTime;\n }\n\n /**\n * Adds a new log entry to the SchemaItem Map.\n * @param startTime The start time of the entry to be logged (end time/duration is handled in this method).\n * @param schemaName The name of the Schema being queried.\n * @param schemaItemType The SchemaItemType name of the type being queried.\n * @param itemCount The number of items retrieved in the query.\n */\n public logSchemaItem(startTime: number, schemaName: string, schemaItemType: string, itemCount: number) {\n if (this.disableLogging)\n return;\n\n const loadTime = new Date().getTime() - startTime;\n\n const schemaMap = this.getSchemaMap(this._label);\n const schemaLoadData = this.getSchemaLoadData(schemaMap, schemaName);\n\n if (schemaLoadData.schemaItemMap.has(schemaItemType))\n throw new Error(\"There should not be a multiple load times for a given iModel, Schema, SchemaItemType combination.\");\n\n schemaLoadData.schemaItemMap.set(schemaItemType, { loadTime, itemCount });\n }\n\n /**\n * Clears all log entries from the Map.\n */\n public clearLogs() {\n this._iModelItems.clear();\n }\n\n private getSchemaMap(iModel: string): Map<string, SchemaLoadData> {\n if (!this._iModelItems.has(iModel)) {\n this._iModelItems.set(iModel, new Map());\n }\n\n return this._iModelItems.get(iModel) as Map<string, SchemaLoadData>;\n }\n\n private getSchemaLoadData(schemaMap: Map<string, SchemaLoadData>, schemaName: string): SchemaLoadData {\n if (!schemaMap.has(schemaName))\n schemaMap.set(schemaName, { schemaItemMap: new Map() })\n\n return schemaMap.get(schemaName) as SchemaLoadData;\n }\n}"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaFormatsProvider.d.ts","sourceRoot":"","sources":["../../src/SchemaFormatsProvider.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAK1D,OAAO,EAAE,OAAO,EAAU,MAAM,qBAAqB,CAAC;AAGtD,OAAO,EAAE,gBAAgB,EAAe,kBAAkB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAMzH;;;GAGG;AACH,qBAAa,qBAAsB,YAAW,eAAe;IAC3D,OAAO,CAAC,QAAQ,CAAgB;IAChC,OAAO,CAAC,WAAW,CAAgB;IACnC,OAAO,CAAC,iBAAiB,CAA0B;IAC5C,gBAAgB,iBAAsB,kBAAkB,KAAK,IAAI,EAAI;IAC5E;;;;;;OAMG;gBACS,gBAAgB,EAAE,cAAc,EAAE,UAAU,EAAE,aAAa;IAUvE,IAAW,OAAO,kBAA4B;IAC9C,IAAW,UAAU,IAEa,aAAa,CAFK;IAEpD,IAAW,UAAU,CAAC,UAAU,EAAE,aAAa,EAG9C;IAED,OAAO,CAAC,KAAK;IAMb,0HAA0H;IAC1H,OAAO,CAAC,yBAAyB;YAenB,iCAAiC;IAmD/C;;;;;;OAMG;IACU,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,S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AAS,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IACnF,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,6BAA6B,CAAC,eAAoC;IACzE,oDAAoD;IACpD,OAAO;QACL,YAAY,EAAE,CAAC,gBAAgB,EAAE,kBAAkB,EAAE,eAAe,CAAC;QACrE,SAAS,EAAE,CAAC;QACZ,IAAI,EAAE,SAAS;QACf,SAAS,EAAE;YACT,KAAK,EAAE;gBACL;oBACE,IAAI,EAAE,eAAe,CAAC,QAAQ;oBAC9B,KAAK,EAAE,eAAe,CAAC,KAAK;iBAC7B;aACF;SACF;KACF,CAAC;AACJ,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/** @packageDocumentation\n * @module Metadata\n */\n\nimport { ISchemaLocater, SchemaContext } from \"./Context\";\nimport { SchemaItemKey, SchemaKey } from \"./SchemaKey\";\nimport { SchemaItem } from \"./Metadata/SchemaItem\";\nimport { Format } from \"./Metadata/Format\";\nimport { SchemaItemFormatProps } from \"./Deserialization/JsonProps\";\nimport { BeEvent, Logger } from \"@itwin/core-bentley\";\nimport { KindOfQuantity } from \"./Metadata/KindOfQuantity\";\nimport { getFormatProps } from \"./Metadata/OverrideFormat\";\nimport { FormatDefinition, FormatProps, FormatsChangedArgs, FormatsProvider, UnitSystemKey } from \"@itwin/core-quantity\";\nimport { Unit } from \"./Metadata/Unit\";\nimport { InvertedUnit } from \"./Metadata/InvertedUnit\";\nimport { Schema } from \"./Metadata/Schema\";\nimport { UnitSystem } from \"./Metadata/UnitSystem\";\nconst loggerCategory = \"SchemaFormatsProvider\";\n/**\n * Provides default formats and kind of quantities from a given SchemaContext or SchemaLocater.\n * @beta\n */\nexport class SchemaFormatsProvider implements FormatsProvider {\n private _context: SchemaContext;\n private _unitSystem: UnitSystemKey;\n private _formatsRetrieved: Set<string> = new Set();\n public onFormatsChanged = new BeEvent<(args: FormatsChangedArgs) => void>();\n /**\n *\n * @param contextOrLocater The SchemaContext or a different ISchemaLocater implementation used to retrieve the schema. The SchemaContext\n * class implements the ISchemaLocater interface. If the provided locater is not a SchemaContext instance a new SchemaContext will be\n * created and the locater will be added.\n * @param unitSystem Used to lookup a default format through a schema specific algorithm, when the format retrieved is associated with a KindOfQuantity.\n */\n constructor(contextOrLocater: ISchemaLocater, unitSystem: UnitSystemKey) {\n if (contextOrLocater instanceof SchemaContext) {\n this._context = contextOrLocater;\n } else {\n this._context = new SchemaContext();\n this._context.addLocater(contextOrLocater);\n }\n this._unitSystem = unitSystem;\n }\n\n public get context() { return this._context; }\n public get unitSystem() { return this._unitSystem; }\n\n public set unitSystem(unitSystem: UnitSystemKey) {\n this._unitSystem = unitSystem;\n this.clear();\n }\n\n private clear(): void {\n const formatsChanged = Array.from(this._formatsRetrieved);\n this._formatsRetrieved.clear();\n this.onFormatsChanged.raiseEvent({ formatsChanged });\n }\n\n /** When using a presentation unit from a KindOfQuantity, the label and description should come from the KindOfQuantity */\n private convertToFormatDefinition(format: SchemaItemFormatProps, kindOfQuantity: KindOfQuantity): FormatDefinition {\n // Destructure all properties except 'rest'\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { name, label, description, $schema, schema, schemaVersion, schemaItemType,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n customAttributes, originalECSpecMajorVersion, originalECSpecMinorVersion, ...rest } = format;\n\n return {\n ...rest,\n name: kindOfQuantity.fullName,\n label: kindOfQuantity.label ?? format.label,\n description: kindOfQuantity.description ?? format.description,\n }\n }\n\n private async getKindOfQuantityFormatFromSchema(itemKey: SchemaItemKey): Promise<FormatDefinition | undefined> {\n let kindOfQuantity: KindOfQuantity | undefined;\n try {\n kindOfQuantity = await this._context.getSchemaItem(itemKey, KindOfQuantity);\n } catch {\n Logger.logError(loggerCategory, `Failed to find KindOfQuantity ${itemKey.fullName}`);\n return undefined;\n }\n\n if (!kindOfQuantity) {\n return undefined;\n }\n\n // Find the first presentation format that matches the provided unit system.\n const unitSystemMatchers = getUnitSystemGroupMatchers(this._unitSystem);\n const presentationFormats = kindOfQuantity.presentationFormats;\n for (const matcher of unitSystemMatchers) {\n for (const lazyFormat of presentationFormats) {\n const format = await lazyFormat;\n const unit = await (format.units && format.units[0][0]);\n if (!unit) {\n continue;\n }\n const currentUnitSystem = await unit.unitSystem;\n if (currentUnitSystem && matcher(currentUnitSystem)) {\n this._formatsRetrieved.add(itemKey.fullName);\n const props = getFormatProps(format);\n return this.convertToFormatDefinition(props, kindOfQuantity);\n }\n }\n }\n\n // If no matching presentation format was found, use persistence unit format if it matches unit system.\n const persistenceUnit = await kindOfQuantity.persistenceUnit;\n const persistenceUnitSystem = await persistenceUnit?.unitSystem;\n if (persistenceUnitSystem && unitSystemMatchers.some((matcher) => matcher(persistenceUnitSystem))) {\n this._formatsRetrieved.add(itemKey.fullName);\n const props = getPersistenceUnitFormatProps(persistenceUnit!);\n return this.convertToFormatDefinition(props, kindOfQuantity);\n }\n\n const defaultFormat = kindOfQuantity.defaultPresentationFormat;\n if (!defaultFormat) {\n return undefined;\n }\n this._formatsRetrieved.add(itemKey.fullName);\n const defaultProps = getFormatProps(await defaultFormat);\n return this.convertToFormatDefinition(defaultProps, kindOfQuantity);\n }\n\n\n /**\n * Retrieves a Format from a SchemaContext. If the format is part of a KindOfQuantity, the first presentation format in the KindOfQuantity that matches the current unit system will be retrieved.\n * If no presentation format matches the current unit system, the persistence unit format will be retrieved if it matches the current unit system.\n * Else, the default presentation format will be retrieved.\n * @param name The full name of the Format or KindOfQuantity.\n * @returns\n */\n public async getFormat(name: string): Promise<FormatDefinition | undefined> {\n const [schemaName, schemaItemName] = SchemaItem.parseFullName(name);\n const schemaKey = new SchemaKey(schemaName);\n let schema: Schema | undefined;\n try {\n schema = await this._context.getSchema(schemaKey);\n } catch {\n Logger.logError(loggerCategory, `Failed to find schema ${schemaName}`);\n return undefined;\n }\n if (!schema) {\n return undefined;\n }\n const itemKey = new SchemaItemKey(schemaItemName, schema.schemaKey);\n\n if (schema.name === \"Formats\") {\n let format: Format | undefined;\n try {\n format = await this._context.getSchemaItem(itemKey, Format);\n } catch {\n Logger.logError(loggerCategory, `Failed to find Format ${itemKey.fullName}`);\n return undefined;\n }\n if (!format) {\n return undefined;\n }\n return format.toJSON(true);\n }\n return this.getKindOfQuantityFormatFromSchema(itemKey);\n }\n}\n\nfunction getUnitSystemGroupMatchers(groupKey?: UnitSystemKey) {\n function createMatcher(name: string | string[]) {\n const names = Array.isArray(name) ? name : [name];\n return (unitSystem: UnitSystem) => names.some((n) => n === unitSystem.name.toUpperCase());\n }\n switch (groupKey) {\n case \"imperial\":\n return [\"IMPERIAL\", \"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"].map(createMatcher);\n case \"metric\":\n return [[\"SI\", \"METRIC\"], \"INTERNATIONAL\", \"FINANCE\"].map(createMatcher);\n case \"usCustomary\":\n return [\"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"].map(createMatcher);\n case \"usSurvey\":\n return [\"USSURVEY\", \"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"].map(createMatcher);\n }\n return [];\n}\n\nfunction getPersistenceUnitFormatProps(persistenceUnit: Unit | InvertedUnit): FormatProps {\n // Same as Format \"DefaultRealU\" in Formats ecschema\n return {\n formatTraits: [\"keepSingleZero\", \"keepDecimalPoint\", \"showUnitLabel\"],\n precision: 6,\n type: \"Decimal\",\n composite: {\n units: [\n {\n name: persistenceUnit.fullName,\n label: persistenceUnit.label,\n },\n ],\n },\n };\n}"]}
|