@itwin/presentation-core-interop 1.4.0-alpha.8 → 2.0.0-alpha.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 +25 -0
- package/README.md +7 -7
- package/lib/cjs/core-interop/Formatting.d.ts.map +1 -1
- package/lib/cjs/core-interop/Formatting.js +4 -12
- package/lib/cjs/core-interop/Formatting.js.map +1 -1
- package/lib/cjs/core-interop/Metadata.d.ts.map +1 -1
- package/lib/cjs/core-interop/Metadata.js +1 -0
- package/lib/cjs/core-interop/Metadata.js.map +1 -1
- package/lib/cjs/core-interop/MetadataInternal.d.ts +2 -1
- package/lib/cjs/core-interop/MetadataInternal.d.ts.map +1 -1
- package/lib/cjs/core-interop/MetadataInternal.js +2 -44
- package/lib/cjs/core-interop/MetadataInternal.js.map +1 -1
- package/lib/cjs/core-interop/QueryExecutor.d.ts.map +1 -1
- package/lib/cjs/core-interop/QueryExecutor.js +1 -4
- package/lib/cjs/core-interop/QueryExecutor.js.map +1 -1
- package/lib/esm/core-interop/Formatting.d.ts.map +1 -1
- package/lib/esm/core-interop/Formatting.js +5 -13
- package/lib/esm/core-interop/Formatting.js.map +1 -1
- package/lib/esm/core-interop/Metadata.d.ts.map +1 -1
- package/lib/esm/core-interop/Metadata.js +1 -0
- package/lib/esm/core-interop/Metadata.js.map +1 -1
- package/lib/esm/core-interop/MetadataInternal.d.ts +2 -1
- package/lib/esm/core-interop/MetadataInternal.d.ts.map +1 -1
- package/lib/esm/core-interop/MetadataInternal.js +3 -12
- package/lib/esm/core-interop/MetadataInternal.js.map +1 -1
- package/lib/esm/core-interop/QueryExecutor.d.ts.map +1 -1
- package/lib/esm/core-interop/QueryExecutor.js +1 -4
- package/lib/esm/core-interop/QueryExecutor.js.map +1 -1
- package/package.json +21 -29
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @itwin/presentation-core-interop
|
|
2
2
|
|
|
3
|
+
## 2.0.0-alpha.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies:
|
|
8
|
+
- @itwin/presentation-shared@2.0.0-alpha.10
|
|
9
|
+
|
|
10
|
+
## 2.0.0-alpha.0
|
|
11
|
+
|
|
12
|
+
### Major Changes
|
|
13
|
+
|
|
14
|
+
- [#1262](https://github.com/iTwin/presentation/pull/1262): Drop support for iTwin.js Core v4.
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [#1256](https://github.com/iTwin/presentation/pull/1256): Fix `alpha` dependencies being specified with a range (`^`), allowing package manager to use higher versions, possibly with breaking changes.
|
|
19
|
+
|
|
3
20
|
## 1.4.0-alpha.8
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -82,6 +99,14 @@
|
|
|
82
99
|
- Updated dependencies:
|
|
83
100
|
- @itwin/presentation-shared@2.0.0-alpha.0
|
|
84
101
|
|
|
102
|
+
## 1.3.11
|
|
103
|
+
|
|
104
|
+
### Patch Changes
|
|
105
|
+
|
|
106
|
+
- [#1286](https://github.com/iTwin/presentation/pull/1286): Bump dependencies.
|
|
107
|
+
- Updated dependencies:
|
|
108
|
+
- @itwin/presentation-shared@1.2.11
|
|
109
|
+
|
|
85
110
|
## 1.3.10
|
|
86
111
|
|
|
87
112
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -84,12 +84,12 @@ Example:
|
|
|
84
84
|
<!-- BEGIN EXTRACTION -->
|
|
85
85
|
|
|
86
86
|
```ts
|
|
87
|
-
import {
|
|
87
|
+
import { SchemaContext } from "@itwin/ecschema-metadata";
|
|
88
88
|
import { createValueFormatter } from "@itwin/presentation-core-interop";
|
|
89
89
|
|
|
90
|
-
const
|
|
91
|
-
const metricFormatter = createValueFormatter({ schemaContext
|
|
92
|
-
const imperialFormatter = createValueFormatter({ schemaContext
|
|
90
|
+
const schemaContext: SchemaContext = getIModelConnection().schemaContext;
|
|
91
|
+
const metricFormatter = createValueFormatter({ schemaContext, unitSystem: "metric" });
|
|
92
|
+
const imperialFormatter = createValueFormatter({ schemaContext, unitSystem: "imperial" });
|
|
93
93
|
|
|
94
94
|
// Define the raw value to be formatted
|
|
95
95
|
const value = 1.234;
|
|
@@ -105,13 +105,13 @@ const value = 1.234;
|
|
|
105
105
|
const koqName = `${KOQ_SCHEMA_NAME}.FlowRate`;
|
|
106
106
|
|
|
107
107
|
// Not passing `koqName` formats the value without units using the default formatter:
|
|
108
|
-
expect(await metricFormatter({ type: "Double", value })).
|
|
108
|
+
expect(await metricFormatter({ type: "Double", value })).toBe("1.23");
|
|
109
109
|
|
|
110
110
|
// Metric formatter formats the value in liters per minute:
|
|
111
|
-
expect(await metricFormatter({ type: "Double", value, koqName })).
|
|
111
|
+
expect(await metricFormatter({ type: "Double", value, koqName })).toBe("74040.0 L/min");
|
|
112
112
|
|
|
113
113
|
// Imperial formatter formats the value in gallons per minute:
|
|
114
|
-
expect(await imperialFormatter({ type: "Double", value, koqName })).
|
|
114
|
+
expect(await imperialFormatter({ type: "Double", value, koqName })).toBe("19559.2988 gal/min");
|
|
115
115
|
```
|
|
116
116
|
|
|
117
117
|
<!-- END EXTRACTION -->
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Formatting.d.ts","sourceRoot":"","sources":["../../../src/core-interop/Formatting.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Formatting.d.ts","sourceRoot":"","sources":["../../../src/core-interop/Formatting.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAA8B,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACtF,OAAO,KAAK,EAA0C,aAAa,EAAQ,MAAM,0BAA0B,CAAC;AAC5G,OAAO,KAAK,EAAE,wBAAwB,EAAuB,MAAM,4BAA4B,CAAC;AAEhG;;;GAGG;AACH,UAAU,yBAAyB;IACjC;;;OAGG;IACH,aAAa,EAAE,aAAa,CAAC;IAE7B;;;;OAIG;IACH,UAAU,CAAC,EAAE,aAAa,CAAC;IAE3B;;;OAGG;IACH,aAAa,CAAC,EAAE,wBAAwB,CAAC;CAC1C;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,GAAG,wBAAwB,CAe/F"}
|
|
@@ -27,7 +27,8 @@ const presentation_shared_1 = require("@itwin/presentation-shared");
|
|
|
27
27
|
*/
|
|
28
28
|
function createValueFormatter(props) {
|
|
29
29
|
const { schemaContext, unitSystem } = props;
|
|
30
|
-
|
|
30
|
+
/* v8 ignore next -- @preserve */
|
|
31
|
+
const baseFormatter = props.baseFormatter ?? (0, presentation_shared_1.createDefaultValueFormatter)();
|
|
31
32
|
const unitsProvider = new ecschema_metadata_1.SchemaUnitProvider(schemaContext);
|
|
32
33
|
return async function (value) {
|
|
33
34
|
if (value.type === "Double" && !!value.koqName) {
|
|
@@ -46,8 +47,7 @@ async function getKindOfQuantity(schemas, fullName) {
|
|
|
46
47
|
if (!schema) {
|
|
47
48
|
throw new Error(`Invalid schema "${schemaName}" specified in KoQ full name "${fullName}"`);
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
-
const koq = await schema.getItem(koqName);
|
|
50
|
+
const koq = await schema.getItem(koqName, ecschema_metadata_1.KindOfQuantity);
|
|
51
51
|
if (!koq) {
|
|
52
52
|
throw new Error(`Invalid kind of quantity "${koqName}" specified in KoQ full name "${fullName}" - it does not exist in schema "${schemaName}"`);
|
|
53
53
|
}
|
|
@@ -65,7 +65,6 @@ async function getFormatterSpec(unitsProvider, koq, unitSystem) {
|
|
|
65
65
|
}
|
|
66
66
|
async function getFormattingProps(koq, unitSystem) {
|
|
67
67
|
const persistenceUnit = await koq.persistenceUnit;
|
|
68
|
-
/* c8 ignore next 3 */
|
|
69
68
|
if (!persistenceUnit) {
|
|
70
69
|
return undefined;
|
|
71
70
|
}
|
|
@@ -118,14 +117,7 @@ function getPersistenceUnitFormatProps(persistenceUnit) {
|
|
|
118
117
|
type: "Decimal",
|
|
119
118
|
uomSeparator: " ",
|
|
120
119
|
decimalSeparator: ".",
|
|
121
|
-
composite: {
|
|
122
|
-
units: [
|
|
123
|
-
{
|
|
124
|
-
name: persistenceUnit.fullName,
|
|
125
|
-
label: persistenceUnit.label,
|
|
126
|
-
},
|
|
127
|
-
],
|
|
128
|
-
},
|
|
120
|
+
composite: { units: [{ name: persistenceUnit.fullName, label: persistenceUnit.label }] },
|
|
129
121
|
};
|
|
130
122
|
}
|
|
131
123
|
function getUnitSystemGroupNames(unitSystem) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Formatting.js","sourceRoot":"","sources":["../../../src/core-interop/Formatting.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AAoDhG,oDAcC;AAhED,wDAA+E;AAC/E,gEAA0G;AAC1G,oEAA6F;AA+B7F;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,oBAAoB,CAAC,KAAgC;IACnE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;IAC5C,MAAM,aAAa,GAAG,KAAK,CAAC,aAAa,IAAI,oBAAoB,CAAC,IAAA,iDAA2B,GAAE,CAAC;IAChG,MAAM,aAAa,GAAG,IAAI,sCAAkB,CAAC,aAAa,CAAC,CAAC;IAC5D,OAAO,KAAK,WAAW,KAA0B;QAC/C,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;YAC/C,MAAM,GAAG,GAAG,MAAM,iBAAiB,CAAC,aAAa,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;YAClE,MAAM,IAAI,GAAG,MAAM,gBAAgB,CAAC,aAAa,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC;YACpE,IAAI,IAAI,EAAE,CAAC;gBACT,OAAO,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC;QACD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AED,SAAS,uBAAuB,CAAC,UAA0B;IACzD,QAAQ,UAAU,EAAE,CAAC;QACnB,KAAK,UAAU;YACb,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;QAC9D,KAAK,QAAQ;YACX,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;QACtD,KAAK,aAAa;YAChB,OAAO,CAAC,UAAU,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;QAClD,KAAK,UAAU;YACb,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,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 { FormatterSpec, Format as QuantityFormat } from \"@itwin/core-quantity\";\nimport { OverrideFormat, SchemaKey, SchemaMatchType, SchemaUnitProvider } from \"@itwin/ecschema-metadata\";\nimport { createDefaultValueFormatter, parseFullClassName } from \"@itwin/presentation-shared\";\n\nimport type { FormatProps, UnitsProvider, UnitSystemKey } from \"@itwin/core-quantity\";\nimport type { Format, InvertedUnit, KindOfQuantity, LazyLoadedFormat, SchemaContext, Unit } from \"@itwin/ecschema-metadata\";\nimport type { IPrimitiveValueFormatter, TypedPrimitiveValue } from \"@itwin/presentation-shared\";\n\n/**\n * Props for `createValueFormatter` function.\n * @public\n */\ninterface CreateValueFormatterProps {\n /**\n * An instance of [SchemaContext](https://www.itwinjs.org/reference/ecschema-metadata/context/schemacontext/) for\n * getting units information. Generally, retrieved directly from `IModelDb` or `IModelConnection` using the `schemaContext` accessor.\n */\n schemaContext: SchemaContext;\n\n /**\n * An optional unit system to use for formatting property values. If not provided, default presentation units are used. If a property\n * doesn't have a default presentation unit, then persistence unit is used. Finally, if a property doesn't have a unit assigned at all,\n * `baseFormatter` is used to format the property value.\n */\n unitSystem?: UnitSystemKey;\n\n /**\n * Base primitive value formatter for cases when a property doesn't have any units' information. Defaults to the result of `createDefaultValueFormatter`\n * from `@itwin/presentation-shared` package.\n */\n baseFormatter?: IPrimitiveValueFormatter;\n}\n\n/**\n * Creates an instance of `IPrimitiveValueFormatter` that knows how to format values of properties with assigned kind of quantity. In\n * case the property does not have an assigned kind of quantity, the base formatter is used.\n *\n * Usage example:\n *\n * ```ts\n * import { IModelConnection } from \"@itwin/core-frontend\";\n * import { createValueFormatter } from \"@itwin/presentation-core-interop\";\n *\n * const imodel: IModelConnection = getIModel();\n * const formatter = createValueFormatter({ schemaContext: imodel.schemaContext, unitSystem: \"metric\" });\n * const formattedValue = await formatter({ type: \"Double\", value: 1.234, koqName: \"MySchema.LengthKindOfQuantity\" });\n * ```\n *\n * @public\n */\nexport function createValueFormatter(props: CreateValueFormatterProps): IPrimitiveValueFormatter {\n const { schemaContext, unitSystem } = props;\n const baseFormatter = props.baseFormatter ?? /* c8 ignore next */ createDefaultValueFormatter();\n const unitsProvider = new SchemaUnitProvider(schemaContext);\n return async function (value: TypedPrimitiveValue): Promise<string> {\n if (value.type === \"Double\" && !!value.koqName) {\n const koq = await getKindOfQuantity(schemaContext, value.koqName);\n const spec = await getFormatterSpec(unitsProvider, koq, unitSystem);\n if (spec) {\n return spec.applyFormatting(value.value);\n }\n }\n return baseFormatter(value);\n };\n}\n\nasync function getKindOfQuantity(schemas: SchemaContext, fullName: string) {\n const { schemaName, className: koqName } = parseFullClassName(fullName);\n const schema = await schemas.getSchema(new SchemaKey(schemaName), SchemaMatchType.Latest);\n if (!schema) {\n throw new Error(`Invalid schema \"${schemaName}\" specified in KoQ full name \"${fullName}\"`);\n }\n // TODO: replace with `schema.getItem(koqName, KindOfQuantity)` when itwinjs-core 4.x is dropped\n const koq = await schema.getItem(koqName);\n if (!koq) {\n throw new Error(`Invalid kind of quantity \"${koqName}\" specified in KoQ full name \"${fullName}\" - it does not exist in schema \"${schemaName}\"`);\n }\n return koq as KindOfQuantity;\n}\n\nasync function getFormatterSpec(unitsProvider: UnitsProvider, koq: KindOfQuantity, unitSystem?: UnitSystemKey) {\n const formattingProps = await getFormattingProps(koq, unitSystem);\n if (!formattingProps) {\n return undefined;\n }\n const { formatProps, persistenceUnitName } = formattingProps;\n const persistenceUnit = await unitsProvider.findUnitByName(persistenceUnitName);\n const format = await QuantityFormat.createFromJSON(\"\", unitsProvider, formatProps);\n return FormatterSpec.create(\"\", format, unitsProvider, persistenceUnit);\n}\n\ninterface FormattingProps {\n formatProps: FormatProps;\n persistenceUnitName: string;\n}\n\nasync function getFormattingProps(koq: KindOfQuantity, unitSystem?: UnitSystemKey): Promise<FormattingProps | undefined> {\n const persistenceUnit = await koq.persistenceUnit;\n /* c8 ignore next 3 */\n if (!persistenceUnit) {\n return undefined;\n }\n const formatProps = await getKoqFormatProps(koq, persistenceUnit, unitSystem);\n if (!formatProps) {\n return undefined;\n }\n return { formatProps, persistenceUnitName: persistenceUnit.fullName };\n}\n\nasync function getKoqFormatProps(koq: KindOfQuantity, persistenceUnit: Unit | InvertedUnit, unitSystem?: UnitSystemKey) {\n const unitSystems = getUnitSystemGroupNames(unitSystem);\n // use one of KOQ presentation format that matches requested unit system\n const presentationFormat = await getKoqPresentationFormat(koq, unitSystems);\n if (presentationFormat) {\n return getFormatProps(presentationFormat);\n }\n\n // use persistence unit format if it matches requested unit system and matching presentation format was not found\n const persistenceUnitSystem = await persistenceUnit.unitSystem;\n if (persistenceUnitSystem && unitSystems.includes(persistenceUnitSystem.name.toUpperCase())) {\n return getPersistenceUnitFormatProps(persistenceUnit);\n }\n\n // use default presentation format if persistence unit does not match requested unit system\n if (koq.defaultPresentationFormat) {\n return getFormatProps(koq.defaultPresentationFormat);\n }\n\n return undefined;\n}\n\nasync function getKoqPresentationFormat(koq: KindOfQuantity, unitSystems: string[]) {\n const presentationFormats = koq.presentationFormats;\n for (const system of unitSystems) {\n for (const format of presentationFormats) {\n const units = format instanceof OverrideFormat ? format.units : (await format).units;\n const lazyUnit = units && units[0][0];\n const currentUnitSystem = lazyUnit && (await lazyUnit).unitSystem;\n if (currentUnitSystem && currentUnitSystem.name.toUpperCase() === system) {\n return format;\n }\n }\n }\n return undefined;\n}\n\nasync function getFormatProps(format: LazyLoadedFormat | OverrideFormat | Format): Promise<FormatProps> {\n return format instanceof OverrideFormat ? format.getFormatProps() : (await format).toJSON();\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 uomSeparator: \" \",\n decimalSeparator: \".\",\n composite: {\n units: [\n {\n name: persistenceUnit.fullName,\n label: persistenceUnit.label,\n },\n ],\n },\n };\n}\n\nfunction getUnitSystemGroupNames(unitSystem?: UnitSystemKey) {\n switch (unitSystem) {\n case \"imperial\":\n return [\"IMPERIAL\", \"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"];\n case \"metric\":\n return [\"SI\", \"METRIC\", \"INTERNATIONAL\", \"FINANCE\"];\n case \"usCustomary\":\n return [\"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"];\n case \"usSurvey\":\n return [\"USSURVEY\", \"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"];\n }\n return [];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Formatting.js","sourceRoot":"","sources":["../../../src/core-interop/Formatting.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AA0DhG,oDAeC;AAvED,wDAA+E;AAC/E,gEAMkC;AAClC,oEAA6F;AA+B7F;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,oBAAoB,CAAC,KAAgC;IACnE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;IAC5C,iCAAiC;IACjC,MAAM,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IAC9E,OAAO,MAAM,YAAY,kCAAc,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;AAC9F,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,YAAY,EAAE,GAAG;QACjB,gBAAgB,EAAE,GAAG;QACrB,SAAS,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,eAAe,CAAC,QAAQ,EAAE,KAAK,EAAE,eAAe,CAAC,KAAK,EAAE,CAAC,EAAE;KACzF,CAAC;AACJ,CAAC;AAED,SAAS,uBAAuB,CAAC,UAA0B;IACzD,QAAQ,UAAU,EAAE,CAAC;QACnB,KAAK,UAAU;YACb,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;QAC9D,KAAK,QAAQ;YACX,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;QACtD,KAAK,aAAa;YAChB,OAAO,CAAC,UAAU,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;QAClD,KAAK,UAAU;YACb,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,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 { FormatterSpec, Format as QuantityFormat } from \"@itwin/core-quantity\";\nimport {\n KindOfQuantity,\n OverrideFormat,\n SchemaKey,\n SchemaMatchType,\n SchemaUnitProvider,\n} from \"@itwin/ecschema-metadata\";\nimport { createDefaultValueFormatter, parseFullClassName } from \"@itwin/presentation-shared\";\n\nimport type { FormatProps, UnitsProvider, UnitSystemKey } from \"@itwin/core-quantity\";\nimport type { Format, InvertedUnit, LazyLoadedFormat, SchemaContext, Unit } from \"@itwin/ecschema-metadata\";\nimport type { IPrimitiveValueFormatter, TypedPrimitiveValue } from \"@itwin/presentation-shared\";\n\n/**\n * Props for `createValueFormatter` function.\n * @public\n */\ninterface CreateValueFormatterProps {\n /**\n * An instance of [SchemaContext](https://www.itwinjs.org/reference/ecschema-metadata/context/schemacontext/) for\n * getting units information. Generally, retrieved directly from `IModelDb` or `IModelConnection` using the `schemaContext` accessor.\n */\n schemaContext: SchemaContext;\n\n /**\n * An optional unit system to use for formatting property values. If not provided, default presentation units are used. If a property\n * doesn't have a default presentation unit, then persistence unit is used. Finally, if a property doesn't have a unit assigned at all,\n * `baseFormatter` is used to format the property value.\n */\n unitSystem?: UnitSystemKey;\n\n /**\n * Base primitive value formatter for cases when a property doesn't have any units' information. Defaults to the result of `createDefaultValueFormatter`\n * from `@itwin/presentation-shared` package.\n */\n baseFormatter?: IPrimitiveValueFormatter;\n}\n\n/**\n * Creates an instance of `IPrimitiveValueFormatter` that knows how to format values of properties with assigned kind of quantity. In\n * case the property does not have an assigned kind of quantity, the base formatter is used.\n *\n * Usage example:\n *\n * ```ts\n * import { IModelConnection } from \"@itwin/core-frontend\";\n * import { createValueFormatter } from \"@itwin/presentation-core-interop\";\n *\n * const imodel: IModelConnection = getIModel();\n * const formatter = createValueFormatter({ schemaContext: imodel.schemaContext, unitSystem: \"metric\" });\n * const formattedValue = await formatter({ type: \"Double\", value: 1.234, koqName: \"MySchema.LengthKindOfQuantity\" });\n * ```\n *\n * @public\n */\nexport function createValueFormatter(props: CreateValueFormatterProps): IPrimitiveValueFormatter {\n const { schemaContext, unitSystem } = props;\n /* v8 ignore next -- @preserve */\n const baseFormatter = props.baseFormatter ?? createDefaultValueFormatter();\n const unitsProvider = new SchemaUnitProvider(schemaContext);\n return async function (value: TypedPrimitiveValue): Promise<string> {\n if (value.type === \"Double\" && !!value.koqName) {\n const koq = await getKindOfQuantity(schemaContext, value.koqName);\n const spec = await getFormatterSpec(unitsProvider, koq, unitSystem);\n if (spec) {\n return spec.applyFormatting(value.value);\n }\n }\n return baseFormatter(value);\n };\n}\n\nasync function getKindOfQuantity(schemas: SchemaContext, fullName: string) {\n const { schemaName, className: koqName } = parseFullClassName(fullName);\n const schema = await schemas.getSchema(new SchemaKey(schemaName), SchemaMatchType.Latest);\n if (!schema) {\n throw new Error(`Invalid schema \"${schemaName}\" specified in KoQ full name \"${fullName}\"`);\n }\n const koq = await schema.getItem(koqName, KindOfQuantity);\n if (!koq) {\n throw new Error(\n `Invalid kind of quantity \"${koqName}\" specified in KoQ full name \"${fullName}\" - it does not exist in schema \"${schemaName}\"`,\n );\n }\n return koq;\n}\n\nasync function getFormatterSpec(unitsProvider: UnitsProvider, koq: KindOfQuantity, unitSystem?: UnitSystemKey) {\n const formattingProps = await getFormattingProps(koq, unitSystem);\n if (!formattingProps) {\n return undefined;\n }\n const { formatProps, persistenceUnitName } = formattingProps;\n const persistenceUnit = await unitsProvider.findUnitByName(persistenceUnitName);\n const format = await QuantityFormat.createFromJSON(\"\", unitsProvider, formatProps);\n return FormatterSpec.create(\"\", format, unitsProvider, persistenceUnit);\n}\n\ninterface FormattingProps {\n formatProps: FormatProps;\n persistenceUnitName: string;\n}\n\nasync function getFormattingProps(\n koq: KindOfQuantity,\n unitSystem?: UnitSystemKey,\n): Promise<FormattingProps | undefined> {\n const persistenceUnit = await koq.persistenceUnit;\n if (!persistenceUnit) {\n return undefined;\n }\n const formatProps = await getKoqFormatProps(koq, persistenceUnit, unitSystem);\n if (!formatProps) {\n return undefined;\n }\n return { formatProps, persistenceUnitName: persistenceUnit.fullName };\n}\n\nasync function getKoqFormatProps(\n koq: KindOfQuantity,\n persistenceUnit: Unit | InvertedUnit,\n unitSystem?: UnitSystemKey,\n) {\n const unitSystems = getUnitSystemGroupNames(unitSystem);\n // use one of KOQ presentation format that matches requested unit system\n const presentationFormat = await getKoqPresentationFormat(koq, unitSystems);\n if (presentationFormat) {\n return getFormatProps(presentationFormat);\n }\n\n // use persistence unit format if it matches requested unit system and matching presentation format was not found\n const persistenceUnitSystem = await persistenceUnit.unitSystem;\n if (persistenceUnitSystem && unitSystems.includes(persistenceUnitSystem.name.toUpperCase())) {\n return getPersistenceUnitFormatProps(persistenceUnit);\n }\n\n // use default presentation format if persistence unit does not match requested unit system\n if (koq.defaultPresentationFormat) {\n return getFormatProps(koq.defaultPresentationFormat);\n }\n\n return undefined;\n}\n\nasync function getKoqPresentationFormat(koq: KindOfQuantity, unitSystems: string[]) {\n const presentationFormats = koq.presentationFormats;\n for (const system of unitSystems) {\n for (const format of presentationFormats) {\n const units = format instanceof OverrideFormat ? format.units : (await format).units;\n const lazyUnit = units && units[0][0];\n const currentUnitSystem = lazyUnit && (await lazyUnit).unitSystem;\n if (currentUnitSystem && currentUnitSystem.name.toUpperCase() === system) {\n return format;\n }\n }\n }\n return undefined;\n}\n\nasync function getFormatProps(format: LazyLoadedFormat | OverrideFormat | Format): Promise<FormatProps> {\n return format instanceof OverrideFormat ? format.getFormatProps() : (await format).toJSON();\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 uomSeparator: \" \",\n decimalSeparator: \".\",\n composite: { units: [{ name: persistenceUnit.fullName, label: persistenceUnit.label }] },\n };\n}\n\nfunction getUnitSystemGroupNames(unitSystem?: UnitSystemKey) {\n switch (unitSystem) {\n case \"imperial\":\n return [\"IMPERIAL\", \"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"];\n case \"metric\":\n return [\"SI\", \"METRIC\", \"INTERNATIONAL\", \"FINANCE\"];\n case \"usCustomary\":\n return [\"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"];\n case \"usSurvey\":\n return [\"USSURVEY\", \"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"];\n }\n return [];\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Metadata.d.ts","sourceRoot":"","sources":["../../../src/core-interop/Metadata.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAGtE,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EAAM,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEvE;;;;GAIG;AACH,UAAU,iBAAiB;IACzB,SAAS,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;CAChE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CAAC,aAAa,EAAE,iBAAiB,GAAG,gBAAgB,
|
|
1
|
+
{"version":3,"file":"Metadata.d.ts","sourceRoot":"","sources":["../../../src/core-interop/Metadata.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAGtE,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EAAM,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEvE;;;;GAIG;AACH,UAAU,iBAAiB;IACzB,SAAS,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;CAChE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CAAC,aAAa,EAAE,iBAAiB,GAAG,gBAAgB,CAkCzF"}
|
|
@@ -35,6 +35,7 @@ function createECSchemaProvider(schemaContext) {
|
|
|
35
35
|
return await getSchemaUnprotected(schemaName);
|
|
36
36
|
}
|
|
37
37
|
catch (e) {
|
|
38
|
+
/* v8 ignore else -- @preserve */
|
|
38
39
|
if (e instanceof Error) {
|
|
39
40
|
if (e.message.includes("already exists within this cache") && !handledExistingSchemaErrors.has(schemaName)) {
|
|
40
41
|
handledExistingSchemaErrors.add(schemaName);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Metadata.js","sourceRoot":"","sources":["../../../src/core-interop/Metadata.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AAiChG,
|
|
1
|
+
{"version":3,"file":"Metadata.js","sourceRoot":"","sources":["../../../src/core-interop/Metadata.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AAiChG,wDAkCC;AAjED,gEAAsE;AACtE,+DAAuD;AAcvD;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,sBAAsB,CAAC,aAAgC;IACrE,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAA0C,CAAC;IAC9E,KAAK,UAAU,oBAAoB,CAAC,UAAkB;QACpD,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC,SAAS,CAAC,IAAI,6BAAa,CAAC,UAAU,CAAC,CAAC,CAAC;QAChF,OAAO,UAAU,CAAC,CAAC,CAAC,IAAA,oCAAc,EAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC7D,CAAC;IACD,KAAK,UAAU,kBAAkB,CAAC,UAAkB,EAAE,2BAAwC;QAC5F,mEAAmE;QACnE,IAAI,CAAC;YACH,OAAO,MAAM,oBAAoB,CAAC,UAAU,CAAC,CAAC;QAChD,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,iCAAiC;YACjC,IAAI,CAAC,YAAY,KAAK,EAAE,CAAC;gBACvB,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,kCAAkC,CAAC,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;oBAC3G,2BAA2B,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;oBAC5C,OAAO,kBAAkB,CAAC,UAAU,EAAE,2BAA2B,CAAC,CAAC;gBACrE,CAAC;gBACD,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;oBAC3C,OAAO,SAAS,CAAC;gBACnB,CAAC;YACH,CAAC;YACD,MAAM,CAAC,CAAC;QACV,CAAC;IACH,CAAC;IACD,OAAO;QACL,KAAK,CAAC,SAAS,CAAC,IAAI;YAClB,IAAI,OAAO,GAAG,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC5C,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,OAAO,GAAG,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;gBAC9C,mBAAmB,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACzC,CAAC;YACD,OAAO,OAAO,CAAC;QACjB,CAAC;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\nimport { SchemaKey as CoreSchemaKey } from \"@itwin/ecschema-metadata\";\nimport { createECSchema } from \"./MetadataInternal.js\";\n\nimport type { Schema as CoreSchema } from \"@itwin/ecschema-metadata\";\nimport type { EC, ECSchemaProvider } from \"@itwin/presentation-shared\";\n\n/**\n * Defines input for `createECSchemaProvider`. Generally, this is an instance of [SchemaContext](https://www.itwinjs.org/reference/ecschema-metadata/context/schemacontext/)\n * class from `@itwin/ecschema-metadata` package.\n * @public\n */\ninterface CoreSchemaContext {\n getSchema(key: CoreSchemaKey): Promise<CoreSchema | undefined>;\n}\n\n/**\n * Creates an `ECSchemaProvider` for given [SchemaContext](https://www.itwinjs.org/reference/ecschema-metadata/context/schemacontext/).\n *\n * Usage example:\n *\n * ```ts\n * import { IModelConnection } from \"@itwin/core-frontend\";\n * import { createECSchemaProvider } from \"@itwin/presentation-core-interop\";\n *\n * const imodel: IModelConnection = getIModel();\n * const schemaProvider = createECSchemaProvider(imodel.schemaContext);\n * // the created schema provider may be used in `@itwin/presentation-hierarchies` and other Presentation packages\n * ```\n *\n * @public\n */\nexport function createECSchemaProvider(schemaContext: CoreSchemaContext): ECSchemaProvider {\n const schemaRequestsCache = new Map<string, Promise<EC.Schema | undefined>>();\n async function getSchemaUnprotected(schemaName: string) {\n const coreSchema = await schemaContext.getSchema(new CoreSchemaKey(schemaName));\n return coreSchema ? createECSchema(coreSchema) : undefined;\n }\n async function getSchemaProtected(schemaName: string, handledExistingSchemaErrors: Set<string>) {\n // workaround for https://github.com/iTwin/itwinjs-core/issues/6542\n try {\n return await getSchemaUnprotected(schemaName);\n } catch (e) {\n /* v8 ignore else -- @preserve */\n if (e instanceof Error) {\n if (e.message.includes(\"already exists within this cache\") && !handledExistingSchemaErrors.has(schemaName)) {\n handledExistingSchemaErrors.add(schemaName);\n return getSchemaProtected(schemaName, handledExistingSchemaErrors);\n }\n if (e.message.includes(\"schema not found\")) {\n return undefined;\n }\n }\n throw e;\n }\n }\n return {\n async getSchema(name) {\n let promise = schemaRequestsCache.get(name);\n if (!promise) {\n promise = getSchemaProtected(name, new Set());\n schemaRequestsCache.set(name, promise);\n }\n return promise;\n },\n };\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ECClass as CoreClass } from "@itwin/ecschema-metadata";
|
|
2
|
+
import type { Property as CoreProperty, Schema as CoreSchema } from "@itwin/ecschema-metadata";
|
|
2
3
|
import type { EC } from "@itwin/presentation-shared";
|
|
3
4
|
/** @internal */
|
|
4
5
|
export declare function createECSchema(schema: CoreSchema): EC.Schema;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MetadataInternal.d.ts","sourceRoot":"","sources":["../../../src/core-interop/MetadataInternal.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MetadataInternal.d.ts","sourceRoot":"","sources":["../../../src/core-interop/MetadataInternal.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAoD,MAAM,0BAA0B,CAAC;AAGlH,OAAO,KAAK,EAUV,QAAQ,IAAI,YAAY,EAGxB,MAAM,IAAI,UAAU,EAMrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,4BAA4B,CAAC;AAErD,gBAAgB;AAChB,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,EAAE,CAAC,MAAM,CAW5D;AAwBD,gBAAgB;AAChB,wBAAgB,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,MAAM,GAAG,EAAE,CAAC,KAAK,CAYhF;AAoGD,gBAAgB;AAChB,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,EAAE,CAAC,KAAK,GAAG,EAAE,CAAC,QAAQ,CAqB3F"}
|
|
@@ -3,54 +3,19 @@
|
|
|
3
3
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
4
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
-
if (k2 === undefined) k2 = k;
|
|
8
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
-
}
|
|
12
|
-
Object.defineProperty(o, k2, desc);
|
|
13
|
-
}) : (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
o[k2] = m[k];
|
|
16
|
-
}));
|
|
17
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
-
}) : function(o, v) {
|
|
20
|
-
o["default"] = v;
|
|
21
|
-
});
|
|
22
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
-
var ownKeys = function(o) {
|
|
24
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
-
var ar = [];
|
|
26
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
-
return ar;
|
|
28
|
-
};
|
|
29
|
-
return ownKeys(o);
|
|
30
|
-
};
|
|
31
|
-
return function (mod) {
|
|
32
|
-
if (mod && mod.__esModule) return mod;
|
|
33
|
-
var result = {};
|
|
34
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
-
__setModuleDefault(result, mod);
|
|
36
|
-
return result;
|
|
37
|
-
};
|
|
38
|
-
})();
|
|
39
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
7
|
exports.createECSchema = createECSchema;
|
|
41
8
|
exports.createECClass = createECClass;
|
|
42
9
|
exports.createECProperty = createECProperty;
|
|
43
10
|
const core_bentley_1 = require("@itwin/core-bentley");
|
|
44
11
|
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
45
|
-
const ecschemaMetadata = __importStar(require("@itwin/ecschema-metadata"));
|
|
46
12
|
const presentation_shared_1 = require("@itwin/presentation-shared");
|
|
47
13
|
/** @internal */
|
|
48
14
|
function createECSchema(schema) {
|
|
49
15
|
return {
|
|
50
16
|
name: schema.name,
|
|
51
17
|
async getClass(name) {
|
|
52
|
-
|
|
53
|
-
const item = await schema.getItem(name);
|
|
18
|
+
const item = await schema.getItem(name, ecschema_metadata_1.ECClass);
|
|
54
19
|
return item ? createECClass(item, this) : undefined;
|
|
55
20
|
},
|
|
56
21
|
async getCustomAttributes() {
|
|
@@ -118,14 +83,7 @@ class ECClassImpl extends ECSchemaItemImpl {
|
|
|
118
83
|
return this._coreSchemaItem.is(classOrClassName.name, classOrClassName.schema.name);
|
|
119
84
|
}
|
|
120
85
|
async getProperty(name) {
|
|
121
|
-
const coreProperty = await this._coreSchemaItem.getProperty(name,
|
|
122
|
-
// TODO: remove this when itwinjs-core 4.x support is dropped.
|
|
123
|
-
// `SchemaFormatsProvider` was introduced around the same time the meaning of this second argument was changed
|
|
124
|
-
// from `includeInherited` to `excludeInherited` - we're using its existence to determine what we need to pass to get
|
|
125
|
-
// inherited properties.
|
|
126
|
-
/* c8 ignore next 2 */
|
|
127
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
128
|
-
ecschemaMetadata.SchemaFormatsProvider ? false : true);
|
|
86
|
+
const coreProperty = await this._coreSchemaItem.getProperty(name, false);
|
|
129
87
|
return coreProperty ? createECProperty(coreProperty, this) : undefined;
|
|
130
88
|
}
|
|
131
89
|
async getProperties() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MetadataInternal.js","sourceRoot":"","sources":["../../../src/core-interop/MetadataInternal.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BhG,wCAYC;AAyBD,sCAYC;AA4GD,4CAqBC;AA/MD,sDAA6C;AAC7C,gEAA4F;AAC5F,2EAA6D;AAC7D,oEAAoE;AAyBpE,gBAAgB;AAChB,SAAgB,cAAc,CAAC,MAAkB;IAC/C,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,KAAK,CAAC,QAAQ,CAAC,IAAI;YACjB,wFAAwF;YACxF,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACxC,OAAO,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,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E,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAChJ,CAAC;CACF;AAED,MAAM,oBAAqB,SAAQ,gBAAoC;IACrE,YAAY,kBAAsC;QAChD,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAC5B,CAAC;CACF;AAED,MAAM,iBAAkB,SAAQ,gBAAiC;IAC/D,YAAY,eAAgC;QAC1C,KAAK,CAAC,eAAe,CAAC,CAAC;IACzB,CAAC;IACD,IAAW,WAAW;QACpB,OAAO,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,cAAc,EAAE,CAAC,CAAC,CAAC;IAC3F,CAAC;IACD,IAAW,IAAI;QACb,QAAQ,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;YAClC,KAAK,iCAAa,CAAC,MAAM;gBACvB,OAAO,QAAQ,CAAC;YAClB,KAAK,iCAAa,CAAC,OAAO,CAAC;YAC3B;gBACE,OAAO,QAAQ,CAAC;QACpB,CAAC;IACH,CAAC;IACD,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC;IACvC,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\nimport { assert } from \"@itwin/core-bentley\";\nimport { PrimitiveType, SchemaItemType, StrengthDirection } from \"@itwin/ecschema-metadata\";\nimport * as ecschemaMetadata from \"@itwin/ecschema-metadata\";\nimport { normalizeFullClassName } from \"@itwin/presentation-shared\";\n\nimport type {\n ECClass as CoreClass,\n EntityClass as CoreEntityClass,\n Enumeration as CoreEnumeration,\n EnumerationArrayProperty as CoreEnumerationArrayProperty,\n EnumerationProperty as CoreEnumerationProperty,\n KindOfQuantity as CoreKindOfQuantity,\n Mixin as CoreMixin,\n NavigationProperty as CoreNavigationProperty,\n PrimitiveArrayProperty as CorePrimitiveArrayProperty,\n PrimitiveProperty as CorePrimitiveProperty,\n Property as CoreProperty,\n RelationshipClass as CoreRelationshipClass,\n RelationshipConstraint as CoreRelationshipConstraint,\n Schema as CoreSchema,\n SchemaItem as CoreSchemaItem,\n StructArrayProperty as CoreStructArrayProperty,\n StructClass as CoreStructClass,\n StructProperty as CoreStructProperty,\n LazyLoadedSchemaItem,\n} from \"@itwin/ecschema-metadata\";\nimport type { EC } from \"@itwin/presentation-shared\";\n\n/** @internal */\nexport function createECSchema(schema: CoreSchema): EC.Schema {\n return {\n name: schema.name,\n async getClass(name) {\n // TODO: replace with `schema.getItem(name, CoreClass)` when itwinjs-core 4.x is dropped\n const item = await schema.getItem(name);\n return item ? createECClass(item as CoreClass, this) : undefined;\n },\n async getCustomAttributes() {\n return createCustomAttributesSet(schema.customAttributes);\n },\n };\n}\n\nabstract class ECSchemaItemImpl<TCoreSchemaItem extends CoreSchemaItem> implements EC.SchemaItem {\n private _schema: EC.Schema;\n protected constructor(\n protected _coreSchemaItem: TCoreSchemaItem,\n schema?: EC.Schema,\n ) {\n this._schema = schema ?? createECSchema(this._coreSchemaItem.schema);\n }\n public get schema() {\n return this._schema;\n }\n public get fullName() {\n return normalizeFullClassName(this._coreSchemaItem.fullName);\n }\n public get name() {\n return this._coreSchemaItem.name;\n }\n public get label() {\n return this._coreSchemaItem.label;\n }\n}\n\n/** @internal */\nexport function createECClass(coreClass: CoreClass, schema?: EC.Schema): EC.Class {\n switch (coreClass.schemaItemType) {\n case SchemaItemType.EntityClass:\n return new ECEntityClassImpl(coreClass as CoreEntityClass, schema);\n case SchemaItemType.RelationshipClass:\n return new ECRelationshipClassImpl(coreClass as CoreRelationshipClass, schema);\n case SchemaItemType.StructClass:\n return new ECStructClassImpl(coreClass as CoreStructClass, schema);\n case SchemaItemType.Mixin:\n return new ECMixinImpl(coreClass as CoreMixin, schema);\n }\n throw new Error(`Invalid class type \"${coreClass.schemaItemType}\" for class ${coreClass.fullName}`);\n}\n\nabstract class ECClassImpl<TCoreClass extends CoreClass> extends ECSchemaItemImpl<TCoreClass> implements EC.Class {\n protected constructor(coreClass: TCoreClass, schema?: EC.Schema) {\n super(coreClass, schema);\n }\n public isEntityClass(): this is EC.EntityClass {\n return false;\n }\n public isRelationshipClass(): this is EC.RelationshipClass {\n return false;\n }\n public isStructClass(): this is EC.StructClass {\n return false;\n }\n public isMixin(): this is EC.Mixin {\n return false;\n }\n public get baseClass(): Promise<EC.Class | undefined> {\n return createFromOptionalLazyLoaded(this._coreSchemaItem.baseClass, (coreBaseClass) => createECClass(coreBaseClass, this.schema));\n }\n public async is(classOrClassName: EC.Class | string, schemaName?: string) {\n if (typeof classOrClassName === \"string\") {\n return this._coreSchemaItem.is(classOrClassName, schemaName!);\n }\n return this._coreSchemaItem.is(classOrClassName.name, classOrClassName.schema.name);\n }\n public async getProperty(name: string): Promise<EC.Property | undefined> {\n const coreProperty = await this._coreSchemaItem.getProperty(\n name,\n // TODO: remove this when itwinjs-core 4.x support is dropped.\n // `SchemaFormatsProvider` was introduced around the same time the meaning of this second argument was changed\n // from `includeInherited` to `excludeInherited` - we're using its existence to determine what we need to pass to get\n // inherited properties.\n /* c8 ignore next 2 */\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n ecschemaMetadata.SchemaFormatsProvider ? false : true,\n );\n return coreProperty ? createECProperty(coreProperty, this) : undefined;\n }\n public async getProperties(): Promise<Array<EC.Property>> {\n const coreProperties = await this._coreSchemaItem.getProperties();\n const result = new Array<EC.Property>();\n for (const coreProperty of coreProperties) {\n result.push(createECProperty(coreProperty, this));\n }\n return result;\n }\n public async getDerivedClasses(): Promise<EC.Class[]> {\n const coreDerivedClasses = await this._coreSchemaItem.getDerivedClasses();\n return coreDerivedClasses ? coreDerivedClasses.map((coreClass) => createECClass(coreClass, this.schema)) : [];\n }\n public async getCustomAttributes(): Promise<EC.CustomAttributeSet> {\n return createCustomAttributesSet(this._coreSchemaItem.customAttributes);\n }\n}\n\nclass ECEntityClassImpl extends ECClassImpl<CoreEntityClass> implements EC.EntityClass {\n constructor(coreClass: CoreEntityClass, schema?: EC.Schema) {\n super(coreClass, schema);\n }\n public override isEntityClass(): this is EC.EntityClass {\n return true;\n }\n}\n\nclass ECRelationshipClassImpl extends ECClassImpl<CoreRelationshipClass> implements EC.RelationshipClass {\n constructor(coreClass: CoreRelationshipClass, schema?: EC.Schema) {\n super(coreClass, schema);\n }\n public override isRelationshipClass(): this is EC.RelationshipClass {\n return true;\n }\n public get direction() {\n switch (this._coreSchemaItem.strengthDirection) {\n case StrengthDirection.Forward:\n return \"Forward\";\n case StrengthDirection.Backward:\n return \"Backward\";\n }\n }\n public get source() {\n return new ECRelationshipConstraintImpl(this._coreSchemaItem.source, this.schema);\n }\n public get target() {\n return new ECRelationshipConstraintImpl(this._coreSchemaItem.target, this.schema);\n }\n}\n\nclass ECStructClassImpl extends ECClassImpl<CoreStructClass> implements EC.StructClass {\n constructor(coreClass: CoreStructClass, schema?: EC.Schema) {\n super(coreClass, schema);\n }\n public override isStructClass(): this is EC.StructClass {\n return true;\n }\n}\n\nclass ECMixinImpl extends ECClassImpl<CoreMixin> implements EC.Mixin {\n constructor(coreClass: CoreMixin, schema?: EC.Schema) {\n super(coreClass, schema);\n }\n public override isMixin(): this is EC.Mixin {\n return true;\n }\n}\n\n/** @internal */\nexport function createECProperty(coreProperty: CoreProperty, ecClass: EC.Class): EC.Property {\n if (coreProperty.isArray()) {\n if (coreProperty.isPrimitive()) {\n return new ECPrimitivesArrayPropertyImpl(coreProperty, ecClass);\n }\n if (coreProperty.isEnumeration()) {\n return new ECEnumerationArrayPropertyImpl(coreProperty, ecClass);\n }\n return new ECStructArrayPropertyImpl(coreProperty, ecClass);\n }\n if (coreProperty.isStruct()) {\n return new ECStructPropertyImpl(coreProperty, ecClass);\n }\n if (coreProperty.isEnumeration()) {\n return new ECEnumerationPropertyImpl(coreProperty, ecClass);\n }\n if (coreProperty.isNavigation()) {\n return new ECNavigationPropertyImpl(coreProperty, ecClass);\n }\n assert(coreProperty.isPrimitive());\n return new ECPrimitivePropertyImpl(coreProperty, ecClass);\n}\n\nabstract class ECPropertyImpl<TCoreProperty extends CoreProperty> implements EC.Property {\n protected constructor(\n protected _coreProperty: TCoreProperty,\n protected _class: EC.Class,\n ) {}\n public isArray(): this is EC.ArrayProperty {\n return false;\n }\n public isStruct(): this is EC.StructProperty {\n return false;\n }\n public isPrimitive(): this is EC.PrimitiveProperty {\n return false;\n }\n public isEnumeration(): this is EC.EnumerationProperty {\n return false;\n }\n public isNavigation(): this is EC.NavigationProperty {\n return false;\n }\n public get class() {\n return this._class;\n }\n public get name() {\n return this._coreProperty.name;\n }\n public get label() {\n return this._coreProperty.label;\n }\n public get kindOfQuantity(): Promise<EC.KindOfQuantity | undefined> {\n return createFromOptionalLazyLoaded(this._coreProperty.kindOfQuantity, (coreKindOfQuantity) => new ECKindOfQuantityImpl(coreKindOfQuantity));\n }\n public async getCustomAttributes(): Promise<EC.CustomAttributeSet> {\n return createCustomAttributesSet(this._coreProperty.customAttributes);\n }\n}\n\nclass ECPrimitivePropertyImpl<TCoreProperty extends CorePrimitiveProperty> extends ECPropertyImpl<TCoreProperty> implements EC.PrimitiveProperty {\n constructor(coreProperty: TCoreProperty, c: EC.Class) {\n super(coreProperty, c);\n }\n public override isPrimitive(): this is EC.PrimitiveProperty {\n return true;\n }\n public get extendedTypeName() {\n return this._coreProperty.extendedTypeName;\n }\n public get primitiveType() {\n switch (this._coreProperty.primitiveType) {\n case PrimitiveType.Binary:\n return \"Binary\";\n case PrimitiveType.Boolean:\n return \"Boolean\";\n case PrimitiveType.DateTime:\n return \"DateTime\";\n case PrimitiveType.Double:\n return \"Double\";\n case PrimitiveType.IGeometry:\n return \"IGeometry\";\n case PrimitiveType.Integer:\n return \"Integer\";\n case PrimitiveType.Long:\n return \"Long\";\n case PrimitiveType.Point2d:\n return \"Point2d\";\n case PrimitiveType.Point3d:\n return \"Point3d\";\n case PrimitiveType.String:\n return \"String\";\n }\n throw new Error(\"Primitive property is not initialized\");\n }\n}\n\nclass ECNavigationPropertyImpl extends ECPropertyImpl<CoreNavigationProperty> implements EC.NavigationProperty {\n constructor(coreProperty: CoreNavigationProperty, c: EC.Class) {\n super(coreProperty, c);\n }\n public override isNavigation(): this is EC.NavigationProperty {\n return true;\n }\n public get relationshipClass() {\n return createFromLazyLoaded(this._coreProperty.relationshipClass, (r) => new ECRelationshipClassImpl(r));\n }\n public get direction() {\n switch (this._coreProperty.direction) {\n case StrengthDirection.Backward:\n return \"Backward\";\n case StrengthDirection.Forward:\n return \"Forward\";\n }\n }\n}\n\nclass ECEnumerationPropertyImpl<TCoreProperty extends CoreEnumerationProperty> extends ECPropertyImpl<TCoreProperty> implements EC.EnumerationProperty {\n constructor(coreProperty: TCoreProperty, c: EC.Class) {\n super(coreProperty, c);\n }\n public override isEnumeration(): this is EC.EnumerationProperty {\n return true;\n }\n public get enumeration() {\n return createFromOptionalLazyLoaded(this._coreProperty.enumeration, (coreEnumeration) => new ECEnumerationImpl(coreEnumeration));\n }\n public get extendedTypeName() {\n return this._coreProperty.extendedTypeName;\n }\n}\n\nclass ECStructPropertyImpl<TCoreProperty extends CoreStructProperty> extends ECPropertyImpl<TCoreProperty> implements EC.StructProperty {\n constructor(coreProperty: TCoreProperty, c: EC.Class) {\n super(coreProperty, c);\n }\n public override isStruct(): this is EC.StructProperty {\n return true;\n }\n public get structClass(): EC.StructClass {\n return new ECStructClassImpl(this._coreProperty.structClass);\n }\n}\n\nclass ECPrimitivesArrayPropertyImpl extends ECPrimitivePropertyImpl<CorePrimitiveArrayProperty> implements EC.PrimitiveArrayProperty {\n constructor(coreProperty: CorePrimitiveArrayProperty, c: EC.Class) {\n super(coreProperty, c);\n }\n public override isArray(): this is EC.ArrayProperty {\n return true;\n }\n public get minOccurs() {\n return this._coreProperty.minOccurs;\n }\n public get maxOccurs() {\n return this._coreProperty.maxOccurs;\n }\n}\n\nclass ECEnumerationArrayPropertyImpl extends ECEnumerationPropertyImpl<CoreEnumerationArrayProperty> implements EC.EnumerationArrayProperty {\n constructor(coreProperty: CoreEnumerationArrayProperty, c: EC.Class) {\n super(coreProperty, c);\n }\n public override isArray(): this is EC.ArrayProperty {\n return true;\n }\n public get minOccurs() {\n return this._coreProperty.minOccurs;\n }\n public get maxOccurs() {\n return this._coreProperty.maxOccurs;\n }\n}\n\nclass ECStructArrayPropertyImpl extends ECStructPropertyImpl<CoreStructArrayProperty> implements EC.StructArrayProperty {\n constructor(coreProperty: CoreStructArrayProperty, c: EC.Class) {\n super(coreProperty, c);\n }\n public override isArray(): this is EC.ArrayProperty {\n return true;\n }\n public get minOccurs() {\n return this._coreProperty.minOccurs;\n }\n public get maxOccurs() {\n return this._coreProperty.maxOccurs;\n }\n}\n\nasync function createFromLazyLoaded<TSource extends CoreSchemaItem, TTarget>(\n source: LazyLoadedSchemaItem<TSource>,\n convert: (source: TSource) => TTarget,\n): Promise<TTarget> {\n return source.then(convert);\n}\n\nasync function createFromOptionalLazyLoaded<TSource extends CoreSchemaItem, TTarget>(\n source: LazyLoadedSchemaItem<TSource> | undefined,\n convert: (source: TSource) => TTarget,\n): Promise<TTarget | undefined> {\n if (!source) {\n return undefined;\n }\n return source.then(convert);\n}\n\nconst EMPTY_MAP: ReadonlyMap<EC.FullClassName, EC.CustomAttribute> = new Map();\nasync function createCustomAttributesSet(coreCustomAttributes: CoreClass[\"customAttributes\"]): Promise<EC.CustomAttributeSet> {\n if (!coreCustomAttributes) {\n return EMPTY_MAP;\n }\n return {\n *[Symbol.iterator]() {\n for (const [className, ca] of coreCustomAttributes) {\n const normalizedClassName = normalizeFullClassName(className);\n yield [normalizedClassName, { ...ca, className: normalizedClassName }];\n }\n },\n get(className: EC.FullClassName) {\n const normalizedClassName = normalizeFullClassName(className);\n const coreCustomAttribute = coreCustomAttributes.get(normalizedClassName);\n return coreCustomAttribute ? { ...coreCustomAttribute, className: normalizedClassName } : undefined;\n },\n };\n}\n\nclass ECRelationshipConstraintImpl implements EC.RelationshipConstraint {\n constructor(\n private _coreConstraint: CoreRelationshipConstraint,\n private _schema: EC.Schema,\n ) {}\n public get multiplicity() {\n return this._coreConstraint.multiplicity;\n }\n public get polymorphic() {\n return this._coreConstraint.polymorphic;\n }\n public get abstractConstraint(): Promise<EC.EntityClass | EC.Mixin | EC.RelationshipClass | undefined> {\n return createFromOptionalLazyLoaded(this._coreConstraint.abstractConstraint, (coreConstraint) => createECClass(coreConstraint, this._schema));\n }\n}\n\nclass ECKindOfQuantityImpl extends ECSchemaItemImpl<CoreKindOfQuantity> implements EC.KindOfQuantity {\n constructor(coreKindOfQuantity: CoreKindOfQuantity) {\n super(coreKindOfQuantity);\n }\n}\n\nclass ECEnumerationImpl extends ECSchemaItemImpl<CoreEnumeration> implements EC.Enumeration {\n constructor(coreEnumeration: CoreEnumeration) {\n super(coreEnumeration);\n }\n public get enumerators() {\n return this._coreSchemaItem.enumerators.map((coreEnumerator) => ({ ...coreEnumerator }));\n }\n public get type() {\n switch (this._coreSchemaItem.type) {\n case PrimitiveType.String:\n return \"String\";\n case PrimitiveType.Integer:\n default:\n return \"Number\";\n }\n }\n public get isStrict() {\n return this._coreSchemaItem.isStrict;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"MetadataInternal.js","sourceRoot":"","sources":["../../../src/core-interop/MetadataInternal.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AA6BhG,wCAWC;AAyBD,sCAYC;AAqGD,4CAqBC;AArMD,sDAA6C;AAC7C,gEAAkH;AAClH,oEAAoE;AAwBpE,gBAAgB;AAChB,SAAgB,cAAc,CAAC,MAAkB;IAC/C,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,KAAK,CAAC,QAAQ,CAAC,IAAI;YACjB,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,2BAAS,CAAC,CAAC;YACnD,OAAO,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC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AC5B,CAAC;CACF;AAED,MAAM,iBAAkB,SAAQ,gBAAiC;IAC/D,YAAY,eAAgC;QAC1C,KAAK,CAAC,eAAe,CAAC,CAAC;IACzB,CAAC;IACD,IAAW,WAAW;QACpB,OAAO,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,cAAc,EAAE,CAAC,CAAC,CAAC;IAC3F,CAAC;IACD,IAAW,IAAI;QACb,QAAQ,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;YAClC,KAAK,iCAAa,CAAC,MAAM;gBACvB,OAAO,QAAQ,CAAC;YAClB,KAAK,iCAAa,CAAC,OAAO,CAAC;YAC3B;gBACE,OAAO,QAAQ,CAAC;QACpB,CAAC;IACH,CAAC;IACD,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC;IACvC,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\nimport { assert } from \"@itwin/core-bentley\";\nimport { ECClass as CoreClass, PrimitiveType, SchemaItemType, StrengthDirection } from \"@itwin/ecschema-metadata\";\nimport { normalizeFullClassName } from \"@itwin/presentation-shared\";\n\nimport type {\n EntityClass as CoreEntityClass,\n Enumeration as CoreEnumeration,\n EnumerationArrayProperty as CoreEnumerationArrayProperty,\n EnumerationProperty as CoreEnumerationProperty,\n KindOfQuantity as CoreKindOfQuantity,\n Mixin as CoreMixin,\n NavigationProperty as CoreNavigationProperty,\n PrimitiveArrayProperty as CorePrimitiveArrayProperty,\n PrimitiveProperty as CorePrimitiveProperty,\n Property as CoreProperty,\n RelationshipClass as CoreRelationshipClass,\n RelationshipConstraint as CoreRelationshipConstraint,\n Schema as CoreSchema,\n SchemaItem as CoreSchemaItem,\n StructArrayProperty as CoreStructArrayProperty,\n StructClass as CoreStructClass,\n StructProperty as CoreStructProperty,\n LazyLoadedSchemaItem,\n} from \"@itwin/ecschema-metadata\";\nimport type { EC } from \"@itwin/presentation-shared\";\n\n/** @internal */\nexport function createECSchema(schema: CoreSchema): EC.Schema {\n return {\n name: schema.name,\n async getClass(name) {\n const item = await schema.getItem(name, CoreClass);\n return item ? createECClass(item, this) : undefined;\n },\n async getCustomAttributes() {\n return createCustomAttributesSet(schema.customAttributes);\n },\n };\n}\n\nabstract class ECSchemaItemImpl<TCoreSchemaItem extends CoreSchemaItem> implements EC.SchemaItem {\n private _schema: EC.Schema;\n protected constructor(\n protected _coreSchemaItem: TCoreSchemaItem,\n schema?: EC.Schema,\n ) {\n this._schema = schema ?? createECSchema(this._coreSchemaItem.schema);\n }\n public get schema() {\n return this._schema;\n }\n public get fullName() {\n return normalizeFullClassName(this._coreSchemaItem.fullName);\n }\n public get name() {\n return this._coreSchemaItem.name;\n }\n public get label() {\n return this._coreSchemaItem.label;\n }\n}\n\n/** @internal */\nexport function createECClass(coreClass: CoreClass, schema?: EC.Schema): EC.Class {\n switch (coreClass.schemaItemType) {\n case SchemaItemType.EntityClass:\n return new ECEntityClassImpl(coreClass as CoreEntityClass, schema);\n case SchemaItemType.RelationshipClass:\n return new ECRelationshipClassImpl(coreClass as CoreRelationshipClass, schema);\n case SchemaItemType.StructClass:\n return new ECStructClassImpl(coreClass as CoreStructClass, schema);\n case SchemaItemType.Mixin:\n return new ECMixinImpl(coreClass as CoreMixin, schema);\n }\n throw new Error(`Invalid class type \"${coreClass.schemaItemType}\" for class ${coreClass.fullName}`);\n}\n\nabstract class ECClassImpl<TCoreClass extends CoreClass> extends ECSchemaItemImpl<TCoreClass> implements EC.Class {\n protected constructor(coreClass: TCoreClass, schema?: EC.Schema) {\n super(coreClass, schema);\n }\n public isEntityClass(): this is EC.EntityClass {\n return false;\n }\n public isRelationshipClass(): this is EC.RelationshipClass {\n return false;\n }\n public isStructClass(): this is EC.StructClass {\n return false;\n }\n public isMixin(): this is EC.Mixin {\n return false;\n }\n public get baseClass(): Promise<EC.Class | undefined> {\n return createFromOptionalLazyLoaded(this._coreSchemaItem.baseClass, (coreBaseClass) =>\n createECClass(coreBaseClass, this.schema),\n );\n }\n public async is(classOrClassName: EC.Class | string, schemaName?: string) {\n if (typeof classOrClassName === \"string\") {\n return this._coreSchemaItem.is(classOrClassName, schemaName!);\n }\n return this._coreSchemaItem.is(classOrClassName.name, classOrClassName.schema.name);\n }\n public async getProperty(name: string): Promise<EC.Property | undefined> {\n const coreProperty = await this._coreSchemaItem.getProperty(name, false);\n return coreProperty ? createECProperty(coreProperty, this) : undefined;\n }\n public async getProperties(): Promise<Array<EC.Property>> {\n const coreProperties = await this._coreSchemaItem.getProperties();\n const result = new Array<EC.Property>();\n for (const coreProperty of coreProperties) {\n result.push(createECProperty(coreProperty, this));\n }\n return result;\n }\n public async getDerivedClasses(): Promise<EC.Class[]> {\n const coreDerivedClasses = await this._coreSchemaItem.getDerivedClasses();\n return coreDerivedClasses ? coreDerivedClasses.map((coreClass) => createECClass(coreClass, this.schema)) : [];\n }\n public async getCustomAttributes(): Promise<EC.CustomAttributeSet> {\n return createCustomAttributesSet(this._coreSchemaItem.customAttributes);\n }\n}\n\nclass ECEntityClassImpl extends ECClassImpl<CoreEntityClass> implements EC.EntityClass {\n constructor(coreClass: CoreEntityClass, schema?: EC.Schema) {\n super(coreClass, schema);\n }\n public override isEntityClass(): this is EC.EntityClass {\n return true;\n }\n}\n\nclass ECRelationshipClassImpl extends ECClassImpl<CoreRelationshipClass> implements EC.RelationshipClass {\n constructor(coreClass: CoreRelationshipClass, schema?: EC.Schema) {\n super(coreClass, schema);\n }\n public override isRelationshipClass(): this is EC.RelationshipClass {\n return true;\n }\n public get direction() {\n switch (this._coreSchemaItem.strengthDirection) {\n case StrengthDirection.Forward:\n return \"Forward\";\n case StrengthDirection.Backward:\n return \"Backward\";\n }\n }\n public get source() {\n return new ECRelationshipConstraintImpl(this._coreSchemaItem.source, this.schema);\n }\n public get target() {\n return new ECRelationshipConstraintImpl(this._coreSchemaItem.target, this.schema);\n }\n}\n\nclass ECStructClassImpl extends ECClassImpl<CoreStructClass> implements EC.StructClass {\n constructor(coreClass: CoreStructClass, schema?: EC.Schema) {\n super(coreClass, schema);\n }\n public override isStructClass(): this is EC.StructClass {\n return true;\n }\n}\n\nclass ECMixinImpl extends ECClassImpl<CoreMixin> implements EC.Mixin {\n constructor(coreClass: CoreMixin, schema?: EC.Schema) {\n super(coreClass, schema);\n }\n public override isMixin(): this is EC.Mixin {\n return true;\n }\n}\n\n/** @internal */\nexport function createECProperty(coreProperty: CoreProperty, ecClass: EC.Class): EC.Property {\n if (coreProperty.isArray()) {\n if (coreProperty.isPrimitive()) {\n return new ECPrimitivesArrayPropertyImpl(coreProperty, ecClass);\n }\n if (coreProperty.isEnumeration()) {\n return new ECEnumerationArrayPropertyImpl(coreProperty, ecClass);\n }\n return new ECStructArrayPropertyImpl(coreProperty, ecClass);\n }\n if (coreProperty.isStruct()) {\n return new ECStructPropertyImpl(coreProperty, ecClass);\n }\n if (coreProperty.isEnumeration()) {\n return new ECEnumerationPropertyImpl(coreProperty, ecClass);\n }\n if (coreProperty.isNavigation()) {\n return new ECNavigationPropertyImpl(coreProperty, ecClass);\n }\n assert(coreProperty.isPrimitive());\n return new ECPrimitivePropertyImpl(coreProperty, ecClass);\n}\n\nabstract class ECPropertyImpl<TCoreProperty extends CoreProperty> implements EC.Property {\n protected constructor(\n protected _coreProperty: TCoreProperty,\n protected _class: EC.Class,\n ) {}\n public isArray(): this is EC.ArrayProperty {\n return false;\n }\n public isStruct(): this is EC.StructProperty {\n return false;\n }\n public isPrimitive(): this is EC.PrimitiveProperty {\n return false;\n }\n public isEnumeration(): this is EC.EnumerationProperty {\n return false;\n }\n public isNavigation(): this is EC.NavigationProperty {\n return false;\n }\n public get class() {\n return this._class;\n }\n public get name() {\n return this._coreProperty.name;\n }\n public get label() {\n return this._coreProperty.label;\n }\n public get kindOfQuantity(): Promise<EC.KindOfQuantity | undefined> {\n return createFromOptionalLazyLoaded(\n this._coreProperty.kindOfQuantity,\n (coreKindOfQuantity) => new ECKindOfQuantityImpl(coreKindOfQuantity),\n );\n }\n public async getCustomAttributes(): Promise<EC.CustomAttributeSet> {\n return createCustomAttributesSet(this._coreProperty.customAttributes);\n }\n}\n\nclass ECPrimitivePropertyImpl<TCoreProperty extends CorePrimitiveProperty>\n extends ECPropertyImpl<TCoreProperty>\n implements EC.PrimitiveProperty\n{\n constructor(coreProperty: TCoreProperty, c: EC.Class) {\n super(coreProperty, c);\n }\n public override isPrimitive(): this is EC.PrimitiveProperty {\n return true;\n }\n public get extendedTypeName() {\n return this._coreProperty.extendedTypeName;\n }\n public get primitiveType() {\n switch (this._coreProperty.primitiveType) {\n case PrimitiveType.Binary:\n return \"Binary\";\n case PrimitiveType.Boolean:\n return \"Boolean\";\n case PrimitiveType.DateTime:\n return \"DateTime\";\n case PrimitiveType.Double:\n return \"Double\";\n case PrimitiveType.IGeometry:\n return \"IGeometry\";\n case PrimitiveType.Integer:\n return \"Integer\";\n case PrimitiveType.Long:\n return \"Long\";\n case PrimitiveType.Point2d:\n return \"Point2d\";\n case PrimitiveType.Point3d:\n return \"Point3d\";\n case PrimitiveType.String:\n return \"String\";\n }\n throw new Error(\"Primitive property is not initialized\");\n }\n}\n\nclass ECNavigationPropertyImpl extends ECPropertyImpl<CoreNavigationProperty> implements EC.NavigationProperty {\n constructor(coreProperty: CoreNavigationProperty, c: EC.Class) {\n super(coreProperty, c);\n }\n public override isNavigation(): this is EC.NavigationProperty {\n return true;\n }\n public get relationshipClass() {\n return createFromLazyLoaded(this._coreProperty.relationshipClass, (r) => new ECRelationshipClassImpl(r));\n }\n public get direction() {\n switch (this._coreProperty.direction) {\n case StrengthDirection.Backward:\n return \"Backward\";\n case StrengthDirection.Forward:\n return \"Forward\";\n }\n }\n}\n\nclass ECEnumerationPropertyImpl<TCoreProperty extends CoreEnumerationProperty>\n extends ECPropertyImpl<TCoreProperty>\n implements EC.EnumerationProperty\n{\n constructor(coreProperty: TCoreProperty, c: EC.Class) {\n super(coreProperty, c);\n }\n public override isEnumeration(): this is EC.EnumerationProperty {\n return true;\n }\n public get enumeration() {\n return createFromOptionalLazyLoaded(\n this._coreProperty.enumeration,\n (coreEnumeration) => new ECEnumerationImpl(coreEnumeration),\n );\n }\n public get extendedTypeName() {\n return this._coreProperty.extendedTypeName;\n }\n}\n\nclass ECStructPropertyImpl<TCoreProperty extends CoreStructProperty>\n extends ECPropertyImpl<TCoreProperty>\n implements EC.StructProperty\n{\n constructor(coreProperty: TCoreProperty, c: EC.Class) {\n super(coreProperty, c);\n }\n public override isStruct(): this is EC.StructProperty {\n return true;\n }\n public get structClass(): EC.StructClass {\n return new ECStructClassImpl(this._coreProperty.structClass);\n }\n}\n\nclass ECPrimitivesArrayPropertyImpl\n extends ECPrimitivePropertyImpl<CorePrimitiveArrayProperty>\n implements EC.PrimitiveArrayProperty\n{\n constructor(coreProperty: CorePrimitiveArrayProperty, c: EC.Class) {\n super(coreProperty, c);\n }\n public override isArray(): this is EC.ArrayProperty {\n return true;\n }\n public get minOccurs() {\n return this._coreProperty.minOccurs;\n }\n public get maxOccurs() {\n return this._coreProperty.maxOccurs;\n }\n}\n\nclass ECEnumerationArrayPropertyImpl\n extends ECEnumerationPropertyImpl<CoreEnumerationArrayProperty>\n implements EC.EnumerationArrayProperty\n{\n constructor(coreProperty: CoreEnumerationArrayProperty, c: EC.Class) {\n super(coreProperty, c);\n }\n public override isArray(): this is EC.ArrayProperty {\n return true;\n }\n public get minOccurs() {\n return this._coreProperty.minOccurs;\n }\n public get maxOccurs() {\n return this._coreProperty.maxOccurs;\n }\n}\n\nclass ECStructArrayPropertyImpl\n extends ECStructPropertyImpl<CoreStructArrayProperty>\n implements EC.StructArrayProperty\n{\n constructor(coreProperty: CoreStructArrayProperty, c: EC.Class) {\n super(coreProperty, c);\n }\n public override isArray(): this is EC.ArrayProperty {\n return true;\n }\n public get minOccurs() {\n return this._coreProperty.minOccurs;\n }\n public get maxOccurs() {\n return this._coreProperty.maxOccurs;\n }\n}\n\nasync function createFromLazyLoaded<TSource extends CoreSchemaItem, TTarget>(\n source: LazyLoadedSchemaItem<TSource>,\n convert: (source: TSource) => TTarget,\n): Promise<TTarget> {\n return source.then(convert);\n}\n\nasync function createFromOptionalLazyLoaded<TSource extends CoreSchemaItem, TTarget>(\n source: LazyLoadedSchemaItem<TSource> | undefined,\n convert: (source: TSource) => TTarget,\n): Promise<TTarget | undefined> {\n if (!source) {\n return undefined;\n }\n return source.then(convert);\n}\n\nconst EMPTY_MAP: ReadonlyMap<EC.FullClassName, EC.CustomAttribute> = new Map();\nasync function createCustomAttributesSet(\n coreCustomAttributes: CoreClass[\"customAttributes\"],\n): Promise<EC.CustomAttributeSet> {\n if (!coreCustomAttributes) {\n return EMPTY_MAP;\n }\n return {\n *[Symbol.iterator]() {\n for (const [className, ca] of coreCustomAttributes) {\n const normalizedClassName = normalizeFullClassName(className);\n yield [normalizedClassName, { ...ca, className: normalizedClassName }];\n }\n },\n get(className: EC.FullClassName) {\n const normalizedClassName = normalizeFullClassName(className);\n const coreCustomAttribute = coreCustomAttributes.get(normalizedClassName);\n return coreCustomAttribute ? { ...coreCustomAttribute, className: normalizedClassName } : undefined;\n },\n };\n}\n\nclass ECRelationshipConstraintImpl implements EC.RelationshipConstraint {\n constructor(\n private _coreConstraint: CoreRelationshipConstraint,\n private _schema: EC.Schema,\n ) {}\n public get multiplicity() {\n return this._coreConstraint.multiplicity;\n }\n public get polymorphic() {\n return this._coreConstraint.polymorphic;\n }\n public get abstractConstraint(): Promise<EC.EntityClass | EC.Mixin | EC.RelationshipClass | undefined> {\n return createFromOptionalLazyLoaded(this._coreConstraint.abstractConstraint, (coreConstraint) =>\n createECClass(coreConstraint, this._schema),\n );\n }\n}\n\nclass ECKindOfQuantityImpl extends ECSchemaItemImpl<CoreKindOfQuantity> implements EC.KindOfQuantity {\n constructor(coreKindOfQuantity: CoreKindOfQuantity) {\n super(coreKindOfQuantity);\n }\n}\n\nclass ECEnumerationImpl extends ECSchemaItemImpl<CoreEnumeration> implements EC.Enumeration {\n constructor(coreEnumeration: CoreEnumeration) {\n super(coreEnumeration);\n }\n public get enumerators() {\n return this._coreSchemaItem.enumerators.map((coreEnumerator) => ({ ...coreEnumerator }));\n }\n public get type() {\n switch (this._coreSchemaItem.type) {\n case PrimitiveType.String:\n return \"String\";\n case PrimitiveType.Integer:\n default:\n return \"Number\";\n }\n }\n public get isStrict() {\n return this._coreSchemaItem.isStrict;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryExecutor.d.ts","sourceRoot":"","sources":["../../../src/core-interop/QueryExecutor.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAuC,MAAM,oBAAoB,CAAC;AAItF,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"QueryExecutor.d.ts","sourceRoot":"","sources":["../../../src/core-interop/QueryExecutor.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAuC,MAAM,oBAAoB,CAAC;AAItF,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,KAAK,EAGV,kBAAkB,EAGnB,MAAM,4BAA4B,CAAC;AAEpC;;;;GAIG;AACH,UAAU,sBAAsB;IAC9B,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,WAAW,CAAC;CAC7F;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,sBAAsB,GAAG,kBAAkB,CAsB3F"}
|
|
@@ -63,10 +63,7 @@ class ECSqlQueryReaderImpl {
|
|
|
63
63
|
if (res.done) {
|
|
64
64
|
return { done: true, value: undefined };
|
|
65
65
|
}
|
|
66
|
-
return {
|
|
67
|
-
done: false,
|
|
68
|
-
value: this._format === "array" ? res.value.toArray() : res.value.toRow(),
|
|
69
|
-
};
|
|
66
|
+
return { done: false, value: this._format === "array" ? res.value.toArray() : res.value.toRow() };
|
|
70
67
|
}
|
|
71
68
|
}
|
|
72
69
|
function bind(bindings) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryExecutor.js","sourceRoot":"","sources":["../../../src/core-interop/QueryExecutor.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;
|
|
1
|
+
{"version":3,"file":"QueryExecutor.js","sourceRoot":"","sources":["../../../src/core-interop/QueryExecutor.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AA4ChG,4DAsBC;AAhED,sDAA0D;AAC1D,oDAAsF;AACtF,wDAAwD;AACxD,oEAA4D;AAoB5D;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,wBAAwB,CAAC,MAA8B;IACrE,OAAO;QACL,iBAAiB,CAAC,KAAoB,EAAE,MAAgC;YACtE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;YACxC,MAAM,IAAI,GAAG,IAAI,iCAAmB,EAAE,CAAC;YACvC,QAAQ,MAAM,EAAE,SAAS,EAAE,CAAC;gBAC1B,KAAK,oBAAoB;oBACvB,IAAI,CAAC,YAAY,CAAC,4BAAc,CAAC,qBAAqB,CAAC,CAAC;oBACxD,MAAM;gBACR,KAAK,SAAS;oBACZ,IAAI,CAAC,YAAY,CAAC,4BAAc,CAAC,uBAAuB,CAAC,CAAC;oBAC1D,MAAM;YACV,CAAC;YACD,IAAI,MAAM,EAAE,YAAY,EAAE,CAAC;gBACzB,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;YAC5C,CAAC;YACD,OAAO,IAAI,oBAAoB,CAC7B,MAAM,CAAC,iBA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C;AAED,SAAS,OAAO,CAAC,KAAa,EAAE,IAA0B;IACxD,MAAM,UAAU,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,kBAAkB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5E,OAAO,GAAG,UAAU,GAAG,KAAK,EAAE,CAAC;AACjC,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 { OrderedId64Iterable } from \"@itwin/core-bentley\";\nimport { QueryBinder, QueryOptionsBuilder, QueryRowFormat } from \"@itwin/core-common\";\nimport { Point2d, Point3d } from \"@itwin/core-geometry\";\nimport { trimWhitespace } from \"@itwin/presentation-shared\";\n\nimport type { ECSqlReader, QueryOptions } from \"@itwin/core-common\";\nimport type {\n ECSqlBinding,\n ECSqlQueryDef,\n ECSqlQueryExecutor,\n ECSqlQueryReaderOptions,\n ECSqlQueryRow,\n} from \"@itwin/presentation-shared\";\n\n/**\n * Defines input for `createECSqlQueryExecutor`. Generally, this is an instance of either [IModelDb](https://www.itwinjs.org/reference/core-backend/imodels/imodeldb/)\n * or [IModelConnection](https://www.itwinjs.org/reference/core-frontend/imodelconnection/imodelconnection/).\n * @public\n */\ninterface CoreECSqlReaderFactory {\n createQueryReader(ecsql: string, binder?: QueryBinder, options?: QueryOptions): ECSqlReader;\n}\n\n/**\n * Creates an `ECSqlQueryExecutor` from either [IModelDb](https://www.itwinjs.org/reference/core-backend/imodels/imodeldb/) or\n * [IModelConnection](https://www.itwinjs.org/reference/core-frontend/imodelconnection/imodelconnection/).\n *\n * Usage example:\n *\n * ```ts\n * import { IModelDb } from \"@itwin/core-backend\";\n * import { createECSqlQueryExecutor } from \"@itwin/presentation-core-interop\";\n *\n * const imodel: IModelDb = getIModelDb();\n * const executor = createECSqlQueryExecutor(imodel);\n * for await (const row of executor.createQueryReader(MY_QUERY)) {\n * // TODO: do something with `row`\n * }\n * ```\n *\n * @public\n */\nexport function createECSqlQueryExecutor(imodel: CoreECSqlReaderFactory): ECSqlQueryExecutor {\n return {\n createQueryReader(query: ECSqlQueryDef, config?: ECSqlQueryReaderOptions) {\n const { ctes, ecsql, bindings } = query;\n const opts = new QueryOptionsBuilder();\n switch (config?.rowFormat) {\n case \"ECSqlPropertyNames\":\n opts.setRowFormat(QueryRowFormat.UseECSqlPropertyNames);\n break;\n case \"Indexes\":\n opts.setRowFormat(QueryRowFormat.UseECSqlPropertyIndexes);\n break;\n }\n if (config?.restartToken) {\n opts.setRestartToken(config.restartToken);\n }\n return new ECSqlQueryReaderImpl(\n imodel.createQueryReader(trimWhitespace(addCTEs(ecsql, ctes)), bind(bindings ?? []), opts.getOptions()),\n config?.rowFormat === \"Indexes\" ? \"array\" : \"object\",\n );\n },\n };\n}\n\nclass ECSqlQueryReaderImpl implements ReturnType<ECSqlQueryExecutor[\"createQueryReader\"]> {\n public constructor(\n private _coreReader: ECSqlReader,\n private _format: \"array\" | \"object\",\n ) {}\n public [Symbol.asyncIterator](): AsyncIterableIterator<ECSqlQueryRow> {\n return this;\n }\n public async next(): Promise<IteratorResult<ECSqlQueryRow>> {\n const res = await this._coreReader.next();\n if (res.done) {\n return { done: true, value: undefined };\n }\n return { done: false, value: this._format === \"array\" ? res.value.toArray() : res.value.toRow() };\n }\n}\n\nfunction bind(bindings: ECSqlBinding[]): QueryBinder {\n const binder = new QueryBinder();\n bindings.forEach((b, i) => {\n if (b.value === undefined) {\n binder.bindNull(i + 1);\n return;\n }\n switch (b.type) {\n case \"boolean\":\n binder.bindBoolean(i + 1, b.value);\n break;\n case \"double\":\n binder.bindDouble(i + 1, b.value);\n break;\n case \"id\":\n binder.bindId(i + 1, b.value);\n break;\n case \"idset\":\n binder.bindIdSet(i + 1, OrderedId64Iterable.sortArray(b.value));\n break;\n case \"int\":\n binder.bindInt(i + 1, b.value);\n break;\n case \"long\":\n binder.bindLong(i + 1, b.value);\n break;\n case \"point2d\":\n binder.bindPoint2d(i + 1, Point2d.fromJSON(b.value));\n break;\n case \"point3d\":\n binder.bindPoint3d(i + 1, Point3d.fromJSON(b.value));\n break;\n case \"string\":\n binder.bindString(i + 1, b.value);\n break;\n }\n });\n return binder;\n}\n\nfunction addCTEs(ecsql: string, ctes: string[] | undefined) {\n const ctesPrefix = ctes?.length ? `WITH RECURSIVE ${ctes.join(\", \")} ` : \"\";\n return `${ctesPrefix}${ecsql}`;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Formatting.d.ts","sourceRoot":"","sources":["../../../src/core-interop/Formatting.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Formatting.d.ts","sourceRoot":"","sources":["../../../src/core-interop/Formatting.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAA8B,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACtF,OAAO,KAAK,EAA0C,aAAa,EAAQ,MAAM,0BAA0B,CAAC;AAC5G,OAAO,KAAK,EAAE,wBAAwB,EAAuB,MAAM,4BAA4B,CAAC;AAEhG;;;GAGG;AACH,UAAU,yBAAyB;IACjC;;;OAGG;IACH,aAAa,EAAE,aAAa,CAAC;IAE7B;;;;OAIG;IACH,UAAU,CAAC,EAAE,aAAa,CAAC;IAE3B;;;OAGG;IACH,aAAa,CAAC,EAAE,wBAAwB,CAAC;CAC1C;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,GAAG,wBAAwB,CAe/F"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { FormatterSpec, Format as QuantityFormat } from "@itwin/core-quantity";
|
|
6
|
-
import { OverrideFormat, SchemaKey, SchemaMatchType, SchemaUnitProvider } from "@itwin/ecschema-metadata";
|
|
6
|
+
import { KindOfQuantity, OverrideFormat, SchemaKey, SchemaMatchType, SchemaUnitProvider, } from "@itwin/ecschema-metadata";
|
|
7
7
|
import { createDefaultValueFormatter, parseFullClassName } from "@itwin/presentation-shared";
|
|
8
8
|
/**
|
|
9
9
|
* Creates an instance of `IPrimitiveValueFormatter` that knows how to format values of properties with assigned kind of quantity. In
|
|
@@ -24,7 +24,8 @@ import { createDefaultValueFormatter, parseFullClassName } from "@itwin/presenta
|
|
|
24
24
|
*/
|
|
25
25
|
export function createValueFormatter(props) {
|
|
26
26
|
const { schemaContext, unitSystem } = props;
|
|
27
|
-
|
|
27
|
+
/* v8 ignore next -- @preserve */
|
|
28
|
+
const baseFormatter = props.baseFormatter ?? createDefaultValueFormatter();
|
|
28
29
|
const unitsProvider = new SchemaUnitProvider(schemaContext);
|
|
29
30
|
return async function (value) {
|
|
30
31
|
if (value.type === "Double" && !!value.koqName) {
|
|
@@ -43,8 +44,7 @@ async function getKindOfQuantity(schemas, fullName) {
|
|
|
43
44
|
if (!schema) {
|
|
44
45
|
throw new Error(`Invalid schema "${schemaName}" specified in KoQ full name "${fullName}"`);
|
|
45
46
|
}
|
|
46
|
-
|
|
47
|
-
const koq = await schema.getItem(koqName);
|
|
47
|
+
const koq = await schema.getItem(koqName, KindOfQuantity);
|
|
48
48
|
if (!koq) {
|
|
49
49
|
throw new Error(`Invalid kind of quantity "${koqName}" specified in KoQ full name "${fullName}" - it does not exist in schema "${schemaName}"`);
|
|
50
50
|
}
|
|
@@ -62,7 +62,6 @@ async function getFormatterSpec(unitsProvider, koq, unitSystem) {
|
|
|
62
62
|
}
|
|
63
63
|
async function getFormattingProps(koq, unitSystem) {
|
|
64
64
|
const persistenceUnit = await koq.persistenceUnit;
|
|
65
|
-
/* c8 ignore next 3 */
|
|
66
65
|
if (!persistenceUnit) {
|
|
67
66
|
return undefined;
|
|
68
67
|
}
|
|
@@ -115,14 +114,7 @@ function getPersistenceUnitFormatProps(persistenceUnit) {
|
|
|
115
114
|
type: "Decimal",
|
|
116
115
|
uomSeparator: " ",
|
|
117
116
|
decimalSeparator: ".",
|
|
118
|
-
composite: {
|
|
119
|
-
units: [
|
|
120
|
-
{
|
|
121
|
-
name: persistenceUnit.fullName,
|
|
122
|
-
label: persistenceUnit.label,
|
|
123
|
-
},
|
|
124
|
-
],
|
|
125
|
-
},
|
|
117
|
+
composite: { units: [{ name: persistenceUnit.fullName, label: persistenceUnit.label }] },
|
|
126
118
|
};
|
|
127
119
|
}
|
|
128
120
|
function getUnitSystemGroupNames(unitSystem) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Formatting.js","sourceRoot":"","sources":["../../../src/core-interop/Formatting.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,aAAa,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC1G,OAAO,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AA+B7F;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAgC;IACnE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;IAC5C,MAAM,aAAa,GAAG,KAAK,CAAC,aAAa,IAAI,oBAAoB,CAAC,2BAA2B,EAAE,CAAC;IAChG,MAAM,aAAa,GAAG,IAAI,kBAAkB,CAAC,aAAa,CAAC,CAAC;IAC5D,OAAO,KAAK,WAAW,KAA0B;QAC/C,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;YAC/C,MAAM,GAAG,GAAG,MAAM,iBAAiB,CAAC,aAAa,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;YAClE,MAAM,IAAI,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gBAAgB,EAAE,GAAG;QACrB,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;AAED,SAAS,uBAAuB,CAAC,UAA0B;IACzD,QAAQ,UAAU,EAAE,CAAC;QACnB,KAAK,UAAU;YACb,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;QAC9D,KAAK,QAAQ;YACX,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;QACtD,KAAK,aAAa;YAChB,OAAO,CAAC,UAAU,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;QAClD,KAAK,UAAU;YACb,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,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 { FormatterSpec, Format as QuantityFormat } from \"@itwin/core-quantity\";\nimport { OverrideFormat, SchemaKey, SchemaMatchType, SchemaUnitProvider } from \"@itwin/ecschema-metadata\";\nimport { createDefaultValueFormatter, parseFullClassName } from \"@itwin/presentation-shared\";\n\nimport type { FormatProps, UnitsProvider, UnitSystemKey } from \"@itwin/core-quantity\";\nimport type { Format, InvertedUnit, KindOfQuantity, LazyLoadedFormat, SchemaContext, Unit } from \"@itwin/ecschema-metadata\";\nimport type { IPrimitiveValueFormatter, TypedPrimitiveValue } from \"@itwin/presentation-shared\";\n\n/**\n * Props for `createValueFormatter` function.\n * @public\n */\ninterface CreateValueFormatterProps {\n /**\n * An instance of [SchemaContext](https://www.itwinjs.org/reference/ecschema-metadata/context/schemacontext/) for\n * getting units information. Generally, retrieved directly from `IModelDb` or `IModelConnection` using the `schemaContext` accessor.\n */\n schemaContext: SchemaContext;\n\n /**\n * An optional unit system to use for formatting property values. If not provided, default presentation units are used. If a property\n * doesn't have a default presentation unit, then persistence unit is used. Finally, if a property doesn't have a unit assigned at all,\n * `baseFormatter` is used to format the property value.\n */\n unitSystem?: UnitSystemKey;\n\n /**\n * Base primitive value formatter for cases when a property doesn't have any units' information. Defaults to the result of `createDefaultValueFormatter`\n * from `@itwin/presentation-shared` package.\n */\n baseFormatter?: IPrimitiveValueFormatter;\n}\n\n/**\n * Creates an instance of `IPrimitiveValueFormatter` that knows how to format values of properties with assigned kind of quantity. In\n * case the property does not have an assigned kind of quantity, the base formatter is used.\n *\n * Usage example:\n *\n * ```ts\n * import { IModelConnection } from \"@itwin/core-frontend\";\n * import { createValueFormatter } from \"@itwin/presentation-core-interop\";\n *\n * const imodel: IModelConnection = getIModel();\n * const formatter = createValueFormatter({ schemaContext: imodel.schemaContext, unitSystem: \"metric\" });\n * const formattedValue = await formatter({ type: \"Double\", value: 1.234, koqName: \"MySchema.LengthKindOfQuantity\" });\n * ```\n *\n * @public\n */\nexport function createValueFormatter(props: CreateValueFormatterProps): IPrimitiveValueFormatter {\n const { schemaContext, unitSystem } = props;\n const baseFormatter = props.baseFormatter ?? /* c8 ignore next */ createDefaultValueFormatter();\n const unitsProvider = new SchemaUnitProvider(schemaContext);\n return async function (value: TypedPrimitiveValue): Promise<string> {\n if (value.type === \"Double\" && !!value.koqName) {\n const koq = await getKindOfQuantity(schemaContext, value.koqName);\n const spec = await getFormatterSpec(unitsProvider, koq, unitSystem);\n if (spec) {\n return spec.applyFormatting(value.value);\n }\n }\n return baseFormatter(value);\n };\n}\n\nasync function getKindOfQuantity(schemas: SchemaContext, fullName: string) {\n const { schemaName, className: koqName } = parseFullClassName(fullName);\n const schema = await schemas.getSchema(new SchemaKey(schemaName), SchemaMatchType.Latest);\n if (!schema) {\n throw new Error(`Invalid schema \"${schemaName}\" specified in KoQ full name \"${fullName}\"`);\n }\n // TODO: replace with `schema.getItem(koqName, KindOfQuantity)` when itwinjs-core 4.x is dropped\n const koq = await schema.getItem(koqName);\n if (!koq) {\n throw new Error(`Invalid kind of quantity \"${koqName}\" specified in KoQ full name \"${fullName}\" - it does not exist in schema \"${schemaName}\"`);\n }\n return koq as KindOfQuantity;\n}\n\nasync function getFormatterSpec(unitsProvider: UnitsProvider, koq: KindOfQuantity, unitSystem?: UnitSystemKey) {\n const formattingProps = await getFormattingProps(koq, unitSystem);\n if (!formattingProps) {\n return undefined;\n }\n const { formatProps, persistenceUnitName } = formattingProps;\n const persistenceUnit = await unitsProvider.findUnitByName(persistenceUnitName);\n const format = await QuantityFormat.createFromJSON(\"\", unitsProvider, formatProps);\n return FormatterSpec.create(\"\", format, unitsProvider, persistenceUnit);\n}\n\ninterface FormattingProps {\n formatProps: FormatProps;\n persistenceUnitName: string;\n}\n\nasync function getFormattingProps(koq: KindOfQuantity, unitSystem?: UnitSystemKey): Promise<FormattingProps | undefined> {\n const persistenceUnit = await koq.persistenceUnit;\n /* c8 ignore next 3 */\n if (!persistenceUnit) {\n return undefined;\n }\n const formatProps = await getKoqFormatProps(koq, persistenceUnit, unitSystem);\n if (!formatProps) {\n return undefined;\n }\n return { formatProps, persistenceUnitName: persistenceUnit.fullName };\n}\n\nasync function getKoqFormatProps(koq: KindOfQuantity, persistenceUnit: Unit | InvertedUnit, unitSystem?: UnitSystemKey) {\n const unitSystems = getUnitSystemGroupNames(unitSystem);\n // use one of KOQ presentation format that matches requested unit system\n const presentationFormat = await getKoqPresentationFormat(koq, unitSystems);\n if (presentationFormat) {\n return getFormatProps(presentationFormat);\n }\n\n // use persistence unit format if it matches requested unit system and matching presentation format was not found\n const persistenceUnitSystem = await persistenceUnit.unitSystem;\n if (persistenceUnitSystem && unitSystems.includes(persistenceUnitSystem.name.toUpperCase())) {\n return getPersistenceUnitFormatProps(persistenceUnit);\n }\n\n // use default presentation format if persistence unit does not match requested unit system\n if (koq.defaultPresentationFormat) {\n return getFormatProps(koq.defaultPresentationFormat);\n }\n\n return undefined;\n}\n\nasync function getKoqPresentationFormat(koq: KindOfQuantity, unitSystems: string[]) {\n const presentationFormats = koq.presentationFormats;\n for (const system of unitSystems) {\n for (const format of presentationFormats) {\n const units = format instanceof OverrideFormat ? format.units : (await format).units;\n const lazyUnit = units && units[0][0];\n const currentUnitSystem = lazyUnit && (await lazyUnit).unitSystem;\n if (currentUnitSystem && currentUnitSystem.name.toUpperCase() === system) {\n return format;\n }\n }\n }\n return undefined;\n}\n\nasync function getFormatProps(format: LazyLoadedFormat | OverrideFormat | Format): Promise<FormatProps> {\n return format instanceof OverrideFormat ? format.getFormatProps() : (await format).toJSON();\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 uomSeparator: \" \",\n decimalSeparator: \".\",\n composite: {\n units: [\n {\n name: persistenceUnit.fullName,\n label: persistenceUnit.label,\n },\n ],\n },\n };\n}\n\nfunction getUnitSystemGroupNames(unitSystem?: UnitSystemKey) {\n switch (unitSystem) {\n case \"imperial\":\n return [\"IMPERIAL\", \"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"];\n case \"metric\":\n return [\"SI\", \"METRIC\", \"INTERNATIONAL\", \"FINANCE\"];\n case \"usCustomary\":\n return [\"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"];\n case \"usSurvey\":\n return [\"USSURVEY\", \"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"];\n }\n return [];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Formatting.js","sourceRoot":"","sources":["../../../src/core-interop/Formatting.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,aAAa,EAAE,MAAM,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UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,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 { FormatterSpec, Format as QuantityFormat } from \"@itwin/core-quantity\";\nimport {\n KindOfQuantity,\n OverrideFormat,\n SchemaKey,\n SchemaMatchType,\n SchemaUnitProvider,\n} from \"@itwin/ecschema-metadata\";\nimport { createDefaultValueFormatter, parseFullClassName } from \"@itwin/presentation-shared\";\n\nimport type { FormatProps, UnitsProvider, UnitSystemKey } from \"@itwin/core-quantity\";\nimport type { Format, InvertedUnit, LazyLoadedFormat, SchemaContext, Unit } from \"@itwin/ecschema-metadata\";\nimport type { IPrimitiveValueFormatter, TypedPrimitiveValue } from \"@itwin/presentation-shared\";\n\n/**\n * Props for `createValueFormatter` function.\n * @public\n */\ninterface CreateValueFormatterProps {\n /**\n * An instance of [SchemaContext](https://www.itwinjs.org/reference/ecschema-metadata/context/schemacontext/) for\n * getting units information. Generally, retrieved directly from `IModelDb` or `IModelConnection` using the `schemaContext` accessor.\n */\n schemaContext: SchemaContext;\n\n /**\n * An optional unit system to use for formatting property values. If not provided, default presentation units are used. If a property\n * doesn't have a default presentation unit, then persistence unit is used. Finally, if a property doesn't have a unit assigned at all,\n * `baseFormatter` is used to format the property value.\n */\n unitSystem?: UnitSystemKey;\n\n /**\n * Base primitive value formatter for cases when a property doesn't have any units' information. Defaults to the result of `createDefaultValueFormatter`\n * from `@itwin/presentation-shared` package.\n */\n baseFormatter?: IPrimitiveValueFormatter;\n}\n\n/**\n * Creates an instance of `IPrimitiveValueFormatter` that knows how to format values of properties with assigned kind of quantity. In\n * case the property does not have an assigned kind of quantity, the base formatter is used.\n *\n * Usage example:\n *\n * ```ts\n * import { IModelConnection } from \"@itwin/core-frontend\";\n * import { createValueFormatter } from \"@itwin/presentation-core-interop\";\n *\n * const imodel: IModelConnection = getIModel();\n * const formatter = createValueFormatter({ schemaContext: imodel.schemaContext, unitSystem: \"metric\" });\n * const formattedValue = await formatter({ type: \"Double\", value: 1.234, koqName: \"MySchema.LengthKindOfQuantity\" });\n * ```\n *\n * @public\n */\nexport function createValueFormatter(props: CreateValueFormatterProps): IPrimitiveValueFormatter {\n const { schemaContext, unitSystem } = props;\n /* v8 ignore next -- @preserve */\n const baseFormatter = props.baseFormatter ?? createDefaultValueFormatter();\n const unitsProvider = new SchemaUnitProvider(schemaContext);\n return async function (value: TypedPrimitiveValue): Promise<string> {\n if (value.type === \"Double\" && !!value.koqName) {\n const koq = await getKindOfQuantity(schemaContext, value.koqName);\n const spec = await getFormatterSpec(unitsProvider, koq, unitSystem);\n if (spec) {\n return spec.applyFormatting(value.value);\n }\n }\n return baseFormatter(value);\n };\n}\n\nasync function getKindOfQuantity(schemas: SchemaContext, fullName: string) {\n const { schemaName, className: koqName } = parseFullClassName(fullName);\n const schema = await schemas.getSchema(new SchemaKey(schemaName), SchemaMatchType.Latest);\n if (!schema) {\n throw new Error(`Invalid schema \"${schemaName}\" specified in KoQ full name \"${fullName}\"`);\n }\n const koq = await schema.getItem(koqName, KindOfQuantity);\n if (!koq) {\n throw new Error(\n `Invalid kind of quantity \"${koqName}\" specified in KoQ full name \"${fullName}\" - it does not exist in schema \"${schemaName}\"`,\n );\n }\n return koq;\n}\n\nasync function getFormatterSpec(unitsProvider: UnitsProvider, koq: KindOfQuantity, unitSystem?: UnitSystemKey) {\n const formattingProps = await getFormattingProps(koq, unitSystem);\n if (!formattingProps) {\n return undefined;\n }\n const { formatProps, persistenceUnitName } = formattingProps;\n const persistenceUnit = await unitsProvider.findUnitByName(persistenceUnitName);\n const format = await QuantityFormat.createFromJSON(\"\", unitsProvider, formatProps);\n return FormatterSpec.create(\"\", format, unitsProvider, persistenceUnit);\n}\n\ninterface FormattingProps {\n formatProps: FormatProps;\n persistenceUnitName: string;\n}\n\nasync function getFormattingProps(\n koq: KindOfQuantity,\n unitSystem?: UnitSystemKey,\n): Promise<FormattingProps | undefined> {\n const persistenceUnit = await koq.persistenceUnit;\n if (!persistenceUnit) {\n return undefined;\n }\n const formatProps = await getKoqFormatProps(koq, persistenceUnit, unitSystem);\n if (!formatProps) {\n return undefined;\n }\n return { formatProps, persistenceUnitName: persistenceUnit.fullName };\n}\n\nasync function getKoqFormatProps(\n koq: KindOfQuantity,\n persistenceUnit: Unit | InvertedUnit,\n unitSystem?: UnitSystemKey,\n) {\n const unitSystems = getUnitSystemGroupNames(unitSystem);\n // use one of KOQ presentation format that matches requested unit system\n const presentationFormat = await getKoqPresentationFormat(koq, unitSystems);\n if (presentationFormat) {\n return getFormatProps(presentationFormat);\n }\n\n // use persistence unit format if it matches requested unit system and matching presentation format was not found\n const persistenceUnitSystem = await persistenceUnit.unitSystem;\n if (persistenceUnitSystem && unitSystems.includes(persistenceUnitSystem.name.toUpperCase())) {\n return getPersistenceUnitFormatProps(persistenceUnit);\n }\n\n // use default presentation format if persistence unit does not match requested unit system\n if (koq.defaultPresentationFormat) {\n return getFormatProps(koq.defaultPresentationFormat);\n }\n\n return undefined;\n}\n\nasync function getKoqPresentationFormat(koq: KindOfQuantity, unitSystems: string[]) {\n const presentationFormats = koq.presentationFormats;\n for (const system of unitSystems) {\n for (const format of presentationFormats) {\n const units = format instanceof OverrideFormat ? format.units : (await format).units;\n const lazyUnit = units && units[0][0];\n const currentUnitSystem = lazyUnit && (await lazyUnit).unitSystem;\n if (currentUnitSystem && currentUnitSystem.name.toUpperCase() === system) {\n return format;\n }\n }\n }\n return undefined;\n}\n\nasync function getFormatProps(format: LazyLoadedFormat | OverrideFormat | Format): Promise<FormatProps> {\n return format instanceof OverrideFormat ? format.getFormatProps() : (await format).toJSON();\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 uomSeparator: \" \",\n decimalSeparator: \".\",\n composite: { units: [{ name: persistenceUnit.fullName, label: persistenceUnit.label }] },\n };\n}\n\nfunction getUnitSystemGroupNames(unitSystem?: UnitSystemKey) {\n switch (unitSystem) {\n case \"imperial\":\n return [\"IMPERIAL\", \"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"];\n case \"metric\":\n return [\"SI\", \"METRIC\", \"INTERNATIONAL\", \"FINANCE\"];\n case \"usCustomary\":\n return [\"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"];\n case \"usSurvey\":\n return [\"USSURVEY\", \"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"];\n }\n return [];\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Metadata.d.ts","sourceRoot":"","sources":["../../../src/core-interop/Metadata.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAGtE,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EAAM,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEvE;;;;GAIG;AACH,UAAU,iBAAiB;IACzB,SAAS,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;CAChE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CAAC,aAAa,EAAE,iBAAiB,GAAG,gBAAgB,
|
|
1
|
+
{"version":3,"file":"Metadata.d.ts","sourceRoot":"","sources":["../../../src/core-interop/Metadata.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAGtE,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EAAM,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEvE;;;;GAIG;AACH,UAAU,iBAAiB;IACzB,SAAS,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;CAChE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CAAC,aAAa,EAAE,iBAAiB,GAAG,gBAAgB,CAkCzF"}
|
|
@@ -32,6 +32,7 @@ export function createECSchemaProvider(schemaContext) {
|
|
|
32
32
|
return await getSchemaUnprotected(schemaName);
|
|
33
33
|
}
|
|
34
34
|
catch (e) {
|
|
35
|
+
/* v8 ignore else -- @preserve */
|
|
35
36
|
if (e instanceof Error) {
|
|
36
37
|
if (e.message.includes("already exists within this cache") && !handledExistingSchemaErrors.has(schemaName)) {
|
|
37
38
|
handledExistingSchemaErrors.add(schemaName);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Metadata.js","sourceRoot":"","sources":["../../../src/core-interop/Metadata.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAcvD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,sBAAsB,CAAC,aAAgC;IACrE,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAA0C,CAAC;IAC9E,KAAK,UAAU,oBAAoB,CAAC,UAAkB;QACpD,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC,SAAS,CAAC,IAAI,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC;QAChF,OAAO,UAAU,CAAC,CAAC,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC7D,CAAC;IACD,KAAK,UAAU,kBAAkB,CAAC,UAAkB,EAAE,2BAAwC;QAC5F,mEAAmE;QACnE,IAAI,CAAC;YACH,OAAO,MAAM,oBAAoB,CAAC,UAAU,CAAC,CAAC;QAChD,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,CAAC,YAAY,KAAK,EAAE,CAAC;gBACvB,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,kCAAkC,CAAC,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;oBAC3G,2BAA2B,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;oBAC5C,OAAO,kBAAkB,CAAC,UAAU,EAAE,2BAA2B,CAAC,CAAC;gBACrE,CAAC;gBACD,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;oBAC3C,OAAO,SAAS,CAAC;gBACnB,CAAC;YACH,CAAC;YACD,MAAM,CAAC,CAAC;QACV,CAAC;IACH,CAAC;IACD,OAAO;QACL,KAAK,CAAC,SAAS,CAAC,IAAI;YAClB,IAAI,OAAO,GAAG,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC5C,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,OAAO,GAAG,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;gBAC9C,mBAAmB,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACzC,CAAC;YACD,OAAO,OAAO,CAAC;QACjB,CAAC;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\nimport { SchemaKey as CoreSchemaKey } from \"@itwin/ecschema-metadata\";\nimport { createECSchema } from \"./MetadataInternal.js\";\n\nimport type { Schema as CoreSchema } from \"@itwin/ecschema-metadata\";\nimport type { EC, ECSchemaProvider } from \"@itwin/presentation-shared\";\n\n/**\n * Defines input for `createECSchemaProvider`. Generally, this is an instance of [SchemaContext](https://www.itwinjs.org/reference/ecschema-metadata/context/schemacontext/)\n * class from `@itwin/ecschema-metadata` package.\n * @public\n */\ninterface CoreSchemaContext {\n getSchema(key: CoreSchemaKey): Promise<CoreSchema | undefined>;\n}\n\n/**\n * Creates an `ECSchemaProvider` for given [SchemaContext](https://www.itwinjs.org/reference/ecschema-metadata/context/schemacontext/).\n *\n * Usage example:\n *\n * ```ts\n * import { IModelConnection } from \"@itwin/core-frontend\";\n * import { createECSchemaProvider } from \"@itwin/presentation-core-interop\";\n *\n * const imodel: IModelConnection = getIModel();\n * const schemaProvider = createECSchemaProvider(imodel.schemaContext);\n * // the created schema provider may be used in `@itwin/presentation-hierarchies` and other Presentation packages\n * ```\n *\n * @public\n */\nexport function createECSchemaProvider(schemaContext: CoreSchemaContext): ECSchemaProvider {\n const schemaRequestsCache = new Map<string, Promise<EC.Schema | undefined>>();\n async function getSchemaUnprotected(schemaName: string) {\n const coreSchema = await schemaContext.getSchema(new CoreSchemaKey(schemaName));\n return coreSchema ? createECSchema(coreSchema) : undefined;\n }\n async function getSchemaProtected(schemaName: string, handledExistingSchemaErrors: Set<string>) {\n // workaround for https://github.com/iTwin/itwinjs-core/issues/6542\n try {\n return await getSchemaUnprotected(schemaName);\n } catch (e) {\n if (e instanceof Error) {\n if (e.message.includes(\"already exists within this cache\") && !handledExistingSchemaErrors.has(schemaName)) {\n handledExistingSchemaErrors.add(schemaName);\n return getSchemaProtected(schemaName, handledExistingSchemaErrors);\n }\n if (e.message.includes(\"schema not found\")) {\n return undefined;\n }\n }\n throw e;\n }\n }\n return {\n async getSchema(name) {\n let promise = schemaRequestsCache.get(name);\n if (!promise) {\n promise = getSchemaProtected(name, new Set());\n schemaRequestsCache.set(name, promise);\n }\n return promise;\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Metadata.js","sourceRoot":"","sources":["../../../src/core-interop/Metadata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O,GAAG,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC5C,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,OAAO,GAAG,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;gBAC9C,mBAAmB,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACzC,CAAC;YACD,OAAO,OAAO,CAAC;QACjB,CAAC;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\nimport { SchemaKey as CoreSchemaKey } from \"@itwin/ecschema-metadata\";\nimport { createECSchema } from \"./MetadataInternal.js\";\n\nimport type { Schema as CoreSchema } from \"@itwin/ecschema-metadata\";\nimport type { EC, ECSchemaProvider } from \"@itwin/presentation-shared\";\n\n/**\n * Defines input for `createECSchemaProvider`. Generally, this is an instance of [SchemaContext](https://www.itwinjs.org/reference/ecschema-metadata/context/schemacontext/)\n * class from `@itwin/ecschema-metadata` package.\n * @public\n */\ninterface CoreSchemaContext {\n getSchema(key: CoreSchemaKey): Promise<CoreSchema | undefined>;\n}\n\n/**\n * Creates an `ECSchemaProvider` for given [SchemaContext](https://www.itwinjs.org/reference/ecschema-metadata/context/schemacontext/).\n *\n * Usage example:\n *\n * ```ts\n * import { IModelConnection } from \"@itwin/core-frontend\";\n * import { createECSchemaProvider } from \"@itwin/presentation-core-interop\";\n *\n * const imodel: IModelConnection = getIModel();\n * const schemaProvider = createECSchemaProvider(imodel.schemaContext);\n * // the created schema provider may be used in `@itwin/presentation-hierarchies` and other Presentation packages\n * ```\n *\n * @public\n */\nexport function createECSchemaProvider(schemaContext: CoreSchemaContext): ECSchemaProvider {\n const schemaRequestsCache = new Map<string, Promise<EC.Schema | undefined>>();\n async function getSchemaUnprotected(schemaName: string) {\n const coreSchema = await schemaContext.getSchema(new CoreSchemaKey(schemaName));\n return coreSchema ? createECSchema(coreSchema) : undefined;\n }\n async function getSchemaProtected(schemaName: string, handledExistingSchemaErrors: Set<string>) {\n // workaround for https://github.com/iTwin/itwinjs-core/issues/6542\n try {\n return await getSchemaUnprotected(schemaName);\n } catch (e) {\n /* v8 ignore else -- @preserve */\n if (e instanceof Error) {\n if (e.message.includes(\"already exists within this cache\") && !handledExistingSchemaErrors.has(schemaName)) {\n handledExistingSchemaErrors.add(schemaName);\n return getSchemaProtected(schemaName, handledExistingSchemaErrors);\n }\n if (e.message.includes(\"schema not found\")) {\n return undefined;\n }\n }\n throw e;\n }\n }\n return {\n async getSchema(name) {\n let promise = schemaRequestsCache.get(name);\n if (!promise) {\n promise = getSchemaProtected(name, new Set());\n schemaRequestsCache.set(name, promise);\n }\n return promise;\n },\n };\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ECClass as CoreClass } from "@itwin/ecschema-metadata";
|
|
2
|
+
import type { Property as CoreProperty, Schema as CoreSchema } from "@itwin/ecschema-metadata";
|
|
2
3
|
import type { EC } from "@itwin/presentation-shared";
|
|
3
4
|
/** @internal */
|
|
4
5
|
export declare function createECSchema(schema: CoreSchema): EC.Schema;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MetadataInternal.d.ts","sourceRoot":"","sources":["../../../src/core-interop/MetadataInternal.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MetadataInternal.d.ts","sourceRoot":"","sources":["../../../src/core-interop/MetadataInternal.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAoD,MAAM,0BAA0B,CAAC;AAGlH,OAAO,KAAK,EAUV,QAAQ,IAAI,YAAY,EAGxB,MAAM,IAAI,UAAU,EAMrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,4BAA4B,CAAC;AAErD,gBAAgB;AAChB,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,EAAE,CAAC,MAAM,CAW5D;AAwBD,gBAAgB;AAChB,wBAAgB,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,MAAM,GAAG,EAAE,CAAC,KAAK,CAYhF;AAoGD,gBAAgB;AAChB,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,EAAE,CAAC,KAAK,GAAG,EAAE,CAAC,QAAQ,CAqB3F"}
|
|
@@ -3,16 +3,14 @@
|
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { assert } from "@itwin/core-bentley";
|
|
6
|
-
import { PrimitiveType, SchemaItemType, StrengthDirection } from "@itwin/ecschema-metadata";
|
|
7
|
-
import * as ecschemaMetadata from "@itwin/ecschema-metadata";
|
|
6
|
+
import { ECClass as CoreClass, PrimitiveType, SchemaItemType, StrengthDirection } from "@itwin/ecschema-metadata";
|
|
8
7
|
import { normalizeFullClassName } from "@itwin/presentation-shared";
|
|
9
8
|
/** @internal */
|
|
10
9
|
export function createECSchema(schema) {
|
|
11
10
|
return {
|
|
12
11
|
name: schema.name,
|
|
13
12
|
async getClass(name) {
|
|
14
|
-
|
|
15
|
-
const item = await schema.getItem(name);
|
|
13
|
+
const item = await schema.getItem(name, CoreClass);
|
|
16
14
|
return item ? createECClass(item, this) : undefined;
|
|
17
15
|
},
|
|
18
16
|
async getCustomAttributes() {
|
|
@@ -80,14 +78,7 @@ class ECClassImpl extends ECSchemaItemImpl {
|
|
|
80
78
|
return this._coreSchemaItem.is(classOrClassName.name, classOrClassName.schema.name);
|
|
81
79
|
}
|
|
82
80
|
async getProperty(name) {
|
|
83
|
-
const coreProperty = await this._coreSchemaItem.getProperty(name,
|
|
84
|
-
// TODO: remove this when itwinjs-core 4.x support is dropped.
|
|
85
|
-
// `SchemaFormatsProvider` was introduced around the same time the meaning of this second argument was changed
|
|
86
|
-
// from `includeInherited` to `excludeInherited` - we're using its existence to determine what we need to pass to get
|
|
87
|
-
// inherited properties.
|
|
88
|
-
/* c8 ignore next 2 */
|
|
89
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
90
|
-
ecschemaMetadata.SchemaFormatsProvider ? false : true);
|
|
81
|
+
const coreProperty = await this._coreSchemaItem.getProperty(name, false);
|
|
91
82
|
return coreProperty ? createECProperty(coreProperty, this) : undefined;
|
|
92
83
|
}
|
|
93
84
|
async getProperties() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MetadataInternal.js","sourceRoot":"","sources":["../../../src/core-interop/MetadataInternal.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC5F,OAAO,KAAK,gBAAgB,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAyBpE,gBAAgB;AAChB,MAAM,UAAU,cAAc,CAAC,MAAkB;IAC/C,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,KAAK,CAAC,QAAQ,CAAC,IAAI;YACjB,wFAAwF;YACxF,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACxC,OAAO,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,IAAiB,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACnE,CAAC;QACD,KAAK,CAAC,mBAAmB;YACvB,OAAO,yBAAyB,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;QAC5D,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAe,gBAAgB;IAGjB;IAFJ,OAAO,C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IACzB,CAAC;IACD,IAAW,WAAW;QACpB,OAAO,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,cAAc,EAAE,CAAC,CAAC,CAAC;IAC3F,CAAC;IACD,IAAW,IAAI;QACb,QAAQ,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;YAClC,KAAK,aAAa,CAAC,MAAM;gBACvB,OAAO,QAAQ,CAAC;YAClB,KAAK,aAAa,CAAC,OAAO,CAAC;YAC3B;gBACE,OAAO,QAAQ,CAAC;QACpB,CAAC;IACH,CAAC;IACD,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC;IACvC,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\nimport { assert } from \"@itwin/core-bentley\";\nimport { PrimitiveType, SchemaItemType, StrengthDirection } from \"@itwin/ecschema-metadata\";\nimport * as ecschemaMetadata from \"@itwin/ecschema-metadata\";\nimport { normalizeFullClassName } from \"@itwin/presentation-shared\";\n\nimport type {\n ECClass as CoreClass,\n EntityClass as CoreEntityClass,\n Enumeration as CoreEnumeration,\n EnumerationArrayProperty as CoreEnumerationArrayProperty,\n EnumerationProperty as CoreEnumerationProperty,\n KindOfQuantity as CoreKindOfQuantity,\n Mixin as CoreMixin,\n NavigationProperty as CoreNavigationProperty,\n PrimitiveArrayProperty as CorePrimitiveArrayProperty,\n PrimitiveProperty as CorePrimitiveProperty,\n Property as CoreProperty,\n RelationshipClass as CoreRelationshipClass,\n RelationshipConstraint as CoreRelationshipConstraint,\n Schema as CoreSchema,\n SchemaItem as CoreSchemaItem,\n StructArrayProperty as CoreStructArrayProperty,\n StructClass as CoreStructClass,\n StructProperty as CoreStructProperty,\n LazyLoadedSchemaItem,\n} from \"@itwin/ecschema-metadata\";\nimport type { EC } from \"@itwin/presentation-shared\";\n\n/** @internal */\nexport function createECSchema(schema: CoreSchema): EC.Schema {\n return {\n name: schema.name,\n async getClass(name) {\n // TODO: replace with `schema.getItem(name, CoreClass)` when itwinjs-core 4.x is dropped\n const item = await schema.getItem(name);\n return item ? createECClass(item as CoreClass, this) : undefined;\n },\n async getCustomAttributes() {\n return createCustomAttributesSet(schema.customAttributes);\n },\n };\n}\n\nabstract class ECSchemaItemImpl<TCoreSchemaItem extends CoreSchemaItem> implements EC.SchemaItem {\n private _schema: EC.Schema;\n protected constructor(\n protected _coreSchemaItem: TCoreSchemaItem,\n schema?: EC.Schema,\n ) {\n this._schema = schema ?? createECSchema(this._coreSchemaItem.schema);\n }\n public get schema() {\n return this._schema;\n }\n public get fullName() {\n return normalizeFullClassName(this._coreSchemaItem.fullName);\n }\n public get name() {\n return this._coreSchemaItem.name;\n }\n public get label() {\n return this._coreSchemaItem.label;\n }\n}\n\n/** @internal */\nexport function createECClass(coreClass: CoreClass, schema?: EC.Schema): EC.Class {\n switch (coreClass.schemaItemType) {\n case SchemaItemType.EntityClass:\n return new ECEntityClassImpl(coreClass as CoreEntityClass, schema);\n case SchemaItemType.RelationshipClass:\n return new ECRelationshipClassImpl(coreClass as CoreRelationshipClass, schema);\n case SchemaItemType.StructClass:\n return new ECStructClassImpl(coreClass as CoreStructClass, schema);\n case SchemaItemType.Mixin:\n return new ECMixinImpl(coreClass as CoreMixin, schema);\n }\n throw new Error(`Invalid class type \"${coreClass.schemaItemType}\" for class ${coreClass.fullName}`);\n}\n\nabstract class ECClassImpl<TCoreClass extends CoreClass> extends ECSchemaItemImpl<TCoreClass> implements EC.Class {\n protected constructor(coreClass: TCoreClass, schema?: EC.Schema) {\n super(coreClass, schema);\n }\n public isEntityClass(): this is EC.EntityClass {\n return false;\n }\n public isRelationshipClass(): this is EC.RelationshipClass {\n return false;\n }\n public isStructClass(): this is EC.StructClass {\n return false;\n }\n public isMixin(): this is EC.Mixin {\n return false;\n }\n public get baseClass(): Promise<EC.Class | undefined> {\n return createFromOptionalLazyLoaded(this._coreSchemaItem.baseClass, (coreBaseClass) => createECClass(coreBaseClass, this.schema));\n }\n public async is(classOrClassName: EC.Class | string, schemaName?: string) {\n if (typeof classOrClassName === \"string\") {\n return this._coreSchemaItem.is(classOrClassName, schemaName!);\n }\n return this._coreSchemaItem.is(classOrClassName.name, classOrClassName.schema.name);\n }\n public async getProperty(name: string): Promise<EC.Property | undefined> {\n const coreProperty = await this._coreSchemaItem.getProperty(\n name,\n // TODO: remove this when itwinjs-core 4.x support is dropped.\n // `SchemaFormatsProvider` was introduced around the same time the meaning of this second argument was changed\n // from `includeInherited` to `excludeInherited` - we're using its existence to determine what we need to pass to get\n // inherited properties.\n /* c8 ignore next 2 */\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n ecschemaMetadata.SchemaFormatsProvider ? false : true,\n );\n return coreProperty ? createECProperty(coreProperty, this) : undefined;\n }\n public async getProperties(): Promise<Array<EC.Property>> {\n const coreProperties = await this._coreSchemaItem.getProperties();\n const result = new Array<EC.Property>();\n for (const coreProperty of coreProperties) {\n result.push(createECProperty(coreProperty, this));\n }\n return result;\n }\n public async getDerivedClasses(): Promise<EC.Class[]> {\n const coreDerivedClasses = await this._coreSchemaItem.getDerivedClasses();\n return coreDerivedClasses ? coreDerivedClasses.map((coreClass) => createECClass(coreClass, this.schema)) : [];\n }\n public async getCustomAttributes(): Promise<EC.CustomAttributeSet> {\n return createCustomAttributesSet(this._coreSchemaItem.customAttributes);\n }\n}\n\nclass ECEntityClassImpl extends ECClassImpl<CoreEntityClass> implements EC.EntityClass {\n constructor(coreClass: CoreEntityClass, schema?: EC.Schema) {\n super(coreClass, schema);\n }\n public override isEntityClass(): this is EC.EntityClass {\n return true;\n }\n}\n\nclass ECRelationshipClassImpl extends ECClassImpl<CoreRelationshipClass> implements EC.RelationshipClass {\n constructor(coreClass: CoreRelationshipClass, schema?: EC.Schema) {\n super(coreClass, schema);\n }\n public override isRelationshipClass(): this is EC.RelationshipClass {\n return true;\n }\n public get direction() {\n switch (this._coreSchemaItem.strengthDirection) {\n case StrengthDirection.Forward:\n return \"Forward\";\n case StrengthDirection.Backward:\n return \"Backward\";\n }\n }\n public get source() {\n return new ECRelationshipConstraintImpl(this._coreSchemaItem.source, this.schema);\n }\n public get target() {\n return new ECRelationshipConstraintImpl(this._coreSchemaItem.target, this.schema);\n }\n}\n\nclass ECStructClassImpl extends ECClassImpl<CoreStructClass> implements EC.StructClass {\n constructor(coreClass: CoreStructClass, schema?: EC.Schema) {\n super(coreClass, schema);\n }\n public override isStructClass(): this is EC.StructClass {\n return true;\n }\n}\n\nclass ECMixinImpl extends ECClassImpl<CoreMixin> implements EC.Mixin {\n constructor(coreClass: CoreMixin, schema?: EC.Schema) {\n super(coreClass, schema);\n }\n public override isMixin(): this is EC.Mixin {\n return true;\n }\n}\n\n/** @internal */\nexport function createECProperty(coreProperty: CoreProperty, ecClass: EC.Class): EC.Property {\n if (coreProperty.isArray()) {\n if (coreProperty.isPrimitive()) {\n return new ECPrimitivesArrayPropertyImpl(coreProperty, ecClass);\n }\n if (coreProperty.isEnumeration()) {\n return new ECEnumerationArrayPropertyImpl(coreProperty, ecClass);\n }\n return new ECStructArrayPropertyImpl(coreProperty, ecClass);\n }\n if (coreProperty.isStruct()) {\n return new ECStructPropertyImpl(coreProperty, ecClass);\n }\n if (coreProperty.isEnumeration()) {\n return new ECEnumerationPropertyImpl(coreProperty, ecClass);\n }\n if (coreProperty.isNavigation()) {\n return new ECNavigationPropertyImpl(coreProperty, ecClass);\n }\n assert(coreProperty.isPrimitive());\n return new ECPrimitivePropertyImpl(coreProperty, ecClass);\n}\n\nabstract class ECPropertyImpl<TCoreProperty extends CoreProperty> implements EC.Property {\n protected constructor(\n protected _coreProperty: TCoreProperty,\n protected _class: EC.Class,\n ) {}\n public isArray(): this is EC.ArrayProperty {\n return false;\n }\n public isStruct(): this is EC.StructProperty {\n return false;\n }\n public isPrimitive(): this is EC.PrimitiveProperty {\n return false;\n }\n public isEnumeration(): this is EC.EnumerationProperty {\n return false;\n }\n public isNavigation(): this is EC.NavigationProperty {\n return false;\n }\n public get class() {\n return this._class;\n }\n public get name() {\n return this._coreProperty.name;\n }\n public get label() {\n return this._coreProperty.label;\n }\n public get kindOfQuantity(): Promise<EC.KindOfQuantity | undefined> {\n return createFromOptionalLazyLoaded(this._coreProperty.kindOfQuantity, (coreKindOfQuantity) => new ECKindOfQuantityImpl(coreKindOfQuantity));\n }\n public async getCustomAttributes(): Promise<EC.CustomAttributeSet> {\n return createCustomAttributesSet(this._coreProperty.customAttributes);\n }\n}\n\nclass ECPrimitivePropertyImpl<TCoreProperty extends CorePrimitiveProperty> extends ECPropertyImpl<TCoreProperty> implements EC.PrimitiveProperty {\n constructor(coreProperty: TCoreProperty, c: EC.Class) {\n super(coreProperty, c);\n }\n public override isPrimitive(): this is EC.PrimitiveProperty {\n return true;\n }\n public get extendedTypeName() {\n return this._coreProperty.extendedTypeName;\n }\n public get primitiveType() {\n switch (this._coreProperty.primitiveType) {\n case PrimitiveType.Binary:\n return \"Binary\";\n case PrimitiveType.Boolean:\n return \"Boolean\";\n case PrimitiveType.DateTime:\n return \"DateTime\";\n case PrimitiveType.Double:\n return \"Double\";\n case PrimitiveType.IGeometry:\n return \"IGeometry\";\n case PrimitiveType.Integer:\n return \"Integer\";\n case PrimitiveType.Long:\n return \"Long\";\n case PrimitiveType.Point2d:\n return \"Point2d\";\n case PrimitiveType.Point3d:\n return \"Point3d\";\n case PrimitiveType.String:\n return \"String\";\n }\n throw new Error(\"Primitive property is not initialized\");\n }\n}\n\nclass ECNavigationPropertyImpl extends ECPropertyImpl<CoreNavigationProperty> implements EC.NavigationProperty {\n constructor(coreProperty: CoreNavigationProperty, c: EC.Class) {\n super(coreProperty, c);\n }\n public override isNavigation(): this is EC.NavigationProperty {\n return true;\n }\n public get relationshipClass() {\n return createFromLazyLoaded(this._coreProperty.relationshipClass, (r) => new ECRelationshipClassImpl(r));\n }\n public get direction() {\n switch (this._coreProperty.direction) {\n case StrengthDirection.Backward:\n return \"Backward\";\n case StrengthDirection.Forward:\n return \"Forward\";\n }\n }\n}\n\nclass ECEnumerationPropertyImpl<TCoreProperty extends CoreEnumerationProperty> extends ECPropertyImpl<TCoreProperty> implements EC.EnumerationProperty {\n constructor(coreProperty: TCoreProperty, c: EC.Class) {\n super(coreProperty, c);\n }\n public override isEnumeration(): this is EC.EnumerationProperty {\n return true;\n }\n public get enumeration() {\n return createFromOptionalLazyLoaded(this._coreProperty.enumeration, (coreEnumeration) => new ECEnumerationImpl(coreEnumeration));\n }\n public get extendedTypeName() {\n return this._coreProperty.extendedTypeName;\n }\n}\n\nclass ECStructPropertyImpl<TCoreProperty extends CoreStructProperty> extends ECPropertyImpl<TCoreProperty> implements EC.StructProperty {\n constructor(coreProperty: TCoreProperty, c: EC.Class) {\n super(coreProperty, c);\n }\n public override isStruct(): this is EC.StructProperty {\n return true;\n }\n public get structClass(): EC.StructClass {\n return new ECStructClassImpl(this._coreProperty.structClass);\n }\n}\n\nclass ECPrimitivesArrayPropertyImpl extends ECPrimitivePropertyImpl<CorePrimitiveArrayProperty> implements EC.PrimitiveArrayProperty {\n constructor(coreProperty: CorePrimitiveArrayProperty, c: EC.Class) {\n super(coreProperty, c);\n }\n public override isArray(): this is EC.ArrayProperty {\n return true;\n }\n public get minOccurs() {\n return this._coreProperty.minOccurs;\n }\n public get maxOccurs() {\n return this._coreProperty.maxOccurs;\n }\n}\n\nclass ECEnumerationArrayPropertyImpl extends ECEnumerationPropertyImpl<CoreEnumerationArrayProperty> implements EC.EnumerationArrayProperty {\n constructor(coreProperty: CoreEnumerationArrayProperty, c: EC.Class) {\n super(coreProperty, c);\n }\n public override isArray(): this is EC.ArrayProperty {\n return true;\n }\n public get minOccurs() {\n return this._coreProperty.minOccurs;\n }\n public get maxOccurs() {\n return this._coreProperty.maxOccurs;\n }\n}\n\nclass ECStructArrayPropertyImpl extends ECStructPropertyImpl<CoreStructArrayProperty> implements EC.StructArrayProperty {\n constructor(coreProperty: CoreStructArrayProperty, c: EC.Class) {\n super(coreProperty, c);\n }\n public override isArray(): this is EC.ArrayProperty {\n return true;\n }\n public get minOccurs() {\n return this._coreProperty.minOccurs;\n }\n public get maxOccurs() {\n return this._coreProperty.maxOccurs;\n }\n}\n\nasync function createFromLazyLoaded<TSource extends CoreSchemaItem, TTarget>(\n source: LazyLoadedSchemaItem<TSource>,\n convert: (source: TSource) => TTarget,\n): Promise<TTarget> {\n return source.then(convert);\n}\n\nasync function createFromOptionalLazyLoaded<TSource extends CoreSchemaItem, TTarget>(\n source: LazyLoadedSchemaItem<TSource> | undefined,\n convert: (source: TSource) => TTarget,\n): Promise<TTarget | undefined> {\n if (!source) {\n return undefined;\n }\n return source.then(convert);\n}\n\nconst EMPTY_MAP: ReadonlyMap<EC.FullClassName, EC.CustomAttribute> = new Map();\nasync function createCustomAttributesSet(coreCustomAttributes: CoreClass[\"customAttributes\"]): Promise<EC.CustomAttributeSet> {\n if (!coreCustomAttributes) {\n return EMPTY_MAP;\n }\n return {\n *[Symbol.iterator]() {\n for (const [className, ca] of coreCustomAttributes) {\n const normalizedClassName = normalizeFullClassName(className);\n yield [normalizedClassName, { ...ca, className: normalizedClassName }];\n }\n },\n get(className: EC.FullClassName) {\n const normalizedClassName = normalizeFullClassName(className);\n const coreCustomAttribute = coreCustomAttributes.get(normalizedClassName);\n return coreCustomAttribute ? { ...coreCustomAttribute, className: normalizedClassName } : undefined;\n },\n };\n}\n\nclass ECRelationshipConstraintImpl implements EC.RelationshipConstraint {\n constructor(\n private _coreConstraint: CoreRelationshipConstraint,\n private _schema: EC.Schema,\n ) {}\n public get multiplicity() {\n return this._coreConstraint.multiplicity;\n }\n public get polymorphic() {\n return this._coreConstraint.polymorphic;\n }\n public get abstractConstraint(): Promise<EC.EntityClass | EC.Mixin | EC.RelationshipClass | undefined> {\n return createFromOptionalLazyLoaded(this._coreConstraint.abstractConstraint, (coreConstraint) => createECClass(coreConstraint, this._schema));\n }\n}\n\nclass ECKindOfQuantityImpl extends ECSchemaItemImpl<CoreKindOfQuantity> implements EC.KindOfQuantity {\n constructor(coreKindOfQuantity: CoreKindOfQuantity) {\n super(coreKindOfQuantity);\n }\n}\n\nclass ECEnumerationImpl extends ECSchemaItemImpl<CoreEnumeration> implements EC.Enumeration {\n constructor(coreEnumeration: CoreEnumeration) {\n super(coreEnumeration);\n }\n public get enumerators() {\n return this._coreSchemaItem.enumerators.map((coreEnumerator) => ({ ...coreEnumerator }));\n }\n public get type() {\n switch (this._coreSchemaItem.type) {\n case PrimitiveType.String:\n return \"String\";\n case PrimitiveType.Integer:\n default:\n return \"Number\";\n }\n }\n public get isStrict() {\n return this._coreSchemaItem.isStrict;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"MetadataInternal.js","sourceRoot":"","sources":["../../../src/core-interop/MetadataInternal.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,aAAa,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClH,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAwBpE,gBAAgB;AAChB,MAAM,UAAU,cAAc,CAAC,MAAkB;IAC/C,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,KAAK,CAAC,QAAQ,CAAC,IAAI;YACjB,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;YACnD,OAAO,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACtD,CAAC;QACD,KAAK,CAAC,mBAAmB;YACvB,OAAO,yBAAyB,CAAC,MAAM,CAAC,gBAAgB,CAAC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AW,CAAC,GAAG,CAAC,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,cAAc,EAAE,CAAC,CAAC,CAAC;IAC3F,CAAC;IACD,IAAW,IAAI;QACb,QAAQ,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;YAClC,KAAK,aAAa,CAAC,MAAM;gBACvB,OAAO,QAAQ,CAAC;YAClB,KAAK,aAAa,CAAC,OAAO,CAAC;YAC3B;gBACE,OAAO,QAAQ,CAAC;QACpB,CAAC;IACH,CAAC;IACD,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC;IACvC,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\nimport { assert } from \"@itwin/core-bentley\";\nimport { ECClass as CoreClass, PrimitiveType, SchemaItemType, StrengthDirection } from \"@itwin/ecschema-metadata\";\nimport { normalizeFullClassName } from \"@itwin/presentation-shared\";\n\nimport type {\n EntityClass as CoreEntityClass,\n Enumeration as CoreEnumeration,\n EnumerationArrayProperty as CoreEnumerationArrayProperty,\n EnumerationProperty as CoreEnumerationProperty,\n KindOfQuantity as CoreKindOfQuantity,\n Mixin as CoreMixin,\n NavigationProperty as CoreNavigationProperty,\n PrimitiveArrayProperty as CorePrimitiveArrayProperty,\n PrimitiveProperty as CorePrimitiveProperty,\n Property as CoreProperty,\n RelationshipClass as CoreRelationshipClass,\n RelationshipConstraint as CoreRelationshipConstraint,\n Schema as CoreSchema,\n SchemaItem as CoreSchemaItem,\n StructArrayProperty as CoreStructArrayProperty,\n StructClass as CoreStructClass,\n StructProperty as CoreStructProperty,\n LazyLoadedSchemaItem,\n} from \"@itwin/ecschema-metadata\";\nimport type { EC } from \"@itwin/presentation-shared\";\n\n/** @internal */\nexport function createECSchema(schema: CoreSchema): EC.Schema {\n return {\n name: schema.name,\n async getClass(name) {\n const item = await schema.getItem(name, CoreClass);\n return item ? createECClass(item, this) : undefined;\n },\n async getCustomAttributes() {\n return createCustomAttributesSet(schema.customAttributes);\n },\n };\n}\n\nabstract class ECSchemaItemImpl<TCoreSchemaItem extends CoreSchemaItem> implements EC.SchemaItem {\n private _schema: EC.Schema;\n protected constructor(\n protected _coreSchemaItem: TCoreSchemaItem,\n schema?: EC.Schema,\n ) {\n this._schema = schema ?? createECSchema(this._coreSchemaItem.schema);\n }\n public get schema() {\n return this._schema;\n }\n public get fullName() {\n return normalizeFullClassName(this._coreSchemaItem.fullName);\n }\n public get name() {\n return this._coreSchemaItem.name;\n }\n public get label() {\n return this._coreSchemaItem.label;\n }\n}\n\n/** @internal */\nexport function createECClass(coreClass: CoreClass, schema?: EC.Schema): EC.Class {\n switch (coreClass.schemaItemType) {\n case SchemaItemType.EntityClass:\n return new ECEntityClassImpl(coreClass as CoreEntityClass, schema);\n case SchemaItemType.RelationshipClass:\n return new ECRelationshipClassImpl(coreClass as CoreRelationshipClass, schema);\n case SchemaItemType.StructClass:\n return new ECStructClassImpl(coreClass as CoreStructClass, schema);\n case SchemaItemType.Mixin:\n return new ECMixinImpl(coreClass as CoreMixin, schema);\n }\n throw new Error(`Invalid class type \"${coreClass.schemaItemType}\" for class ${coreClass.fullName}`);\n}\n\nabstract class ECClassImpl<TCoreClass extends CoreClass> extends ECSchemaItemImpl<TCoreClass> implements EC.Class {\n protected constructor(coreClass: TCoreClass, schema?: EC.Schema) {\n super(coreClass, schema);\n }\n public isEntityClass(): this is EC.EntityClass {\n return false;\n }\n public isRelationshipClass(): this is EC.RelationshipClass {\n return false;\n }\n public isStructClass(): this is EC.StructClass {\n return false;\n }\n public isMixin(): this is EC.Mixin {\n return false;\n }\n public get baseClass(): Promise<EC.Class | undefined> {\n return createFromOptionalLazyLoaded(this._coreSchemaItem.baseClass, (coreBaseClass) =>\n createECClass(coreBaseClass, this.schema),\n );\n }\n public async is(classOrClassName: EC.Class | string, schemaName?: string) {\n if (typeof classOrClassName === \"string\") {\n return this._coreSchemaItem.is(classOrClassName, schemaName!);\n }\n return this._coreSchemaItem.is(classOrClassName.name, classOrClassName.schema.name);\n }\n public async getProperty(name: string): Promise<EC.Property | undefined> {\n const coreProperty = await this._coreSchemaItem.getProperty(name, false);\n return coreProperty ? createECProperty(coreProperty, this) : undefined;\n }\n public async getProperties(): Promise<Array<EC.Property>> {\n const coreProperties = await this._coreSchemaItem.getProperties();\n const result = new Array<EC.Property>();\n for (const coreProperty of coreProperties) {\n result.push(createECProperty(coreProperty, this));\n }\n return result;\n }\n public async getDerivedClasses(): Promise<EC.Class[]> {\n const coreDerivedClasses = await this._coreSchemaItem.getDerivedClasses();\n return coreDerivedClasses ? coreDerivedClasses.map((coreClass) => createECClass(coreClass, this.schema)) : [];\n }\n public async getCustomAttributes(): Promise<EC.CustomAttributeSet> {\n return createCustomAttributesSet(this._coreSchemaItem.customAttributes);\n }\n}\n\nclass ECEntityClassImpl extends ECClassImpl<CoreEntityClass> implements EC.EntityClass {\n constructor(coreClass: CoreEntityClass, schema?: EC.Schema) {\n super(coreClass, schema);\n }\n public override isEntityClass(): this is EC.EntityClass {\n return true;\n }\n}\n\nclass ECRelationshipClassImpl extends ECClassImpl<CoreRelationshipClass> implements EC.RelationshipClass {\n constructor(coreClass: CoreRelationshipClass, schema?: EC.Schema) {\n super(coreClass, schema);\n }\n public override isRelationshipClass(): this is EC.RelationshipClass {\n return true;\n }\n public get direction() {\n switch (this._coreSchemaItem.strengthDirection) {\n case StrengthDirection.Forward:\n return \"Forward\";\n case StrengthDirection.Backward:\n return \"Backward\";\n }\n }\n public get source() {\n return new ECRelationshipConstraintImpl(this._coreSchemaItem.source, this.schema);\n }\n public get target() {\n return new ECRelationshipConstraintImpl(this._coreSchemaItem.target, this.schema);\n }\n}\n\nclass ECStructClassImpl extends ECClassImpl<CoreStructClass> implements EC.StructClass {\n constructor(coreClass: CoreStructClass, schema?: EC.Schema) {\n super(coreClass, schema);\n }\n public override isStructClass(): this is EC.StructClass {\n return true;\n }\n}\n\nclass ECMixinImpl extends ECClassImpl<CoreMixin> implements EC.Mixin {\n constructor(coreClass: CoreMixin, schema?: EC.Schema) {\n super(coreClass, schema);\n }\n public override isMixin(): this is EC.Mixin {\n return true;\n }\n}\n\n/** @internal */\nexport function createECProperty(coreProperty: CoreProperty, ecClass: EC.Class): EC.Property {\n if (coreProperty.isArray()) {\n if (coreProperty.isPrimitive()) {\n return new ECPrimitivesArrayPropertyImpl(coreProperty, ecClass);\n }\n if (coreProperty.isEnumeration()) {\n return new ECEnumerationArrayPropertyImpl(coreProperty, ecClass);\n }\n return new ECStructArrayPropertyImpl(coreProperty, ecClass);\n }\n if (coreProperty.isStruct()) {\n return new ECStructPropertyImpl(coreProperty, ecClass);\n }\n if (coreProperty.isEnumeration()) {\n return new ECEnumerationPropertyImpl(coreProperty, ecClass);\n }\n if (coreProperty.isNavigation()) {\n return new ECNavigationPropertyImpl(coreProperty, ecClass);\n }\n assert(coreProperty.isPrimitive());\n return new ECPrimitivePropertyImpl(coreProperty, ecClass);\n}\n\nabstract class ECPropertyImpl<TCoreProperty extends CoreProperty> implements EC.Property {\n protected constructor(\n protected _coreProperty: TCoreProperty,\n protected _class: EC.Class,\n ) {}\n public isArray(): this is EC.ArrayProperty {\n return false;\n }\n public isStruct(): this is EC.StructProperty {\n return false;\n }\n public isPrimitive(): this is EC.PrimitiveProperty {\n return false;\n }\n public isEnumeration(): this is EC.EnumerationProperty {\n return false;\n }\n public isNavigation(): this is EC.NavigationProperty {\n return false;\n }\n public get class() {\n return this._class;\n }\n public get name() {\n return this._coreProperty.name;\n }\n public get label() {\n return this._coreProperty.label;\n }\n public get kindOfQuantity(): Promise<EC.KindOfQuantity | undefined> {\n return createFromOptionalLazyLoaded(\n this._coreProperty.kindOfQuantity,\n (coreKindOfQuantity) => new ECKindOfQuantityImpl(coreKindOfQuantity),\n );\n }\n public async getCustomAttributes(): Promise<EC.CustomAttributeSet> {\n return createCustomAttributesSet(this._coreProperty.customAttributes);\n }\n}\n\nclass ECPrimitivePropertyImpl<TCoreProperty extends CorePrimitiveProperty>\n extends ECPropertyImpl<TCoreProperty>\n implements EC.PrimitiveProperty\n{\n constructor(coreProperty: TCoreProperty, c: EC.Class) {\n super(coreProperty, c);\n }\n public override isPrimitive(): this is EC.PrimitiveProperty {\n return true;\n }\n public get extendedTypeName() {\n return this._coreProperty.extendedTypeName;\n }\n public get primitiveType() {\n switch (this._coreProperty.primitiveType) {\n case PrimitiveType.Binary:\n return \"Binary\";\n case PrimitiveType.Boolean:\n return \"Boolean\";\n case PrimitiveType.DateTime:\n return \"DateTime\";\n case PrimitiveType.Double:\n return \"Double\";\n case PrimitiveType.IGeometry:\n return \"IGeometry\";\n case PrimitiveType.Integer:\n return \"Integer\";\n case PrimitiveType.Long:\n return \"Long\";\n case PrimitiveType.Point2d:\n return \"Point2d\";\n case PrimitiveType.Point3d:\n return \"Point3d\";\n case PrimitiveType.String:\n return \"String\";\n }\n throw new Error(\"Primitive property is not initialized\");\n }\n}\n\nclass ECNavigationPropertyImpl extends ECPropertyImpl<CoreNavigationProperty> implements EC.NavigationProperty {\n constructor(coreProperty: CoreNavigationProperty, c: EC.Class) {\n super(coreProperty, c);\n }\n public override isNavigation(): this is EC.NavigationProperty {\n return true;\n }\n public get relationshipClass() {\n return createFromLazyLoaded(this._coreProperty.relationshipClass, (r) => new ECRelationshipClassImpl(r));\n }\n public get direction() {\n switch (this._coreProperty.direction) {\n case StrengthDirection.Backward:\n return \"Backward\";\n case StrengthDirection.Forward:\n return \"Forward\";\n }\n }\n}\n\nclass ECEnumerationPropertyImpl<TCoreProperty extends CoreEnumerationProperty>\n extends ECPropertyImpl<TCoreProperty>\n implements EC.EnumerationProperty\n{\n constructor(coreProperty: TCoreProperty, c: EC.Class) {\n super(coreProperty, c);\n }\n public override isEnumeration(): this is EC.EnumerationProperty {\n return true;\n }\n public get enumeration() {\n return createFromOptionalLazyLoaded(\n this._coreProperty.enumeration,\n (coreEnumeration) => new ECEnumerationImpl(coreEnumeration),\n );\n }\n public get extendedTypeName() {\n return this._coreProperty.extendedTypeName;\n }\n}\n\nclass ECStructPropertyImpl<TCoreProperty extends CoreStructProperty>\n extends ECPropertyImpl<TCoreProperty>\n implements EC.StructProperty\n{\n constructor(coreProperty: TCoreProperty, c: EC.Class) {\n super(coreProperty, c);\n }\n public override isStruct(): this is EC.StructProperty {\n return true;\n }\n public get structClass(): EC.StructClass {\n return new ECStructClassImpl(this._coreProperty.structClass);\n }\n}\n\nclass ECPrimitivesArrayPropertyImpl\n extends ECPrimitivePropertyImpl<CorePrimitiveArrayProperty>\n implements EC.PrimitiveArrayProperty\n{\n constructor(coreProperty: CorePrimitiveArrayProperty, c: EC.Class) {\n super(coreProperty, c);\n }\n public override isArray(): this is EC.ArrayProperty {\n return true;\n }\n public get minOccurs() {\n return this._coreProperty.minOccurs;\n }\n public get maxOccurs() {\n return this._coreProperty.maxOccurs;\n }\n}\n\nclass ECEnumerationArrayPropertyImpl\n extends ECEnumerationPropertyImpl<CoreEnumerationArrayProperty>\n implements EC.EnumerationArrayProperty\n{\n constructor(coreProperty: CoreEnumerationArrayProperty, c: EC.Class) {\n super(coreProperty, c);\n }\n public override isArray(): this is EC.ArrayProperty {\n return true;\n }\n public get minOccurs() {\n return this._coreProperty.minOccurs;\n }\n public get maxOccurs() {\n return this._coreProperty.maxOccurs;\n }\n}\n\nclass ECStructArrayPropertyImpl\n extends ECStructPropertyImpl<CoreStructArrayProperty>\n implements EC.StructArrayProperty\n{\n constructor(coreProperty: CoreStructArrayProperty, c: EC.Class) {\n super(coreProperty, c);\n }\n public override isArray(): this is EC.ArrayProperty {\n return true;\n }\n public get minOccurs() {\n return this._coreProperty.minOccurs;\n }\n public get maxOccurs() {\n return this._coreProperty.maxOccurs;\n }\n}\n\nasync function createFromLazyLoaded<TSource extends CoreSchemaItem, TTarget>(\n source: LazyLoadedSchemaItem<TSource>,\n convert: (source: TSource) => TTarget,\n): Promise<TTarget> {\n return source.then(convert);\n}\n\nasync function createFromOptionalLazyLoaded<TSource extends CoreSchemaItem, TTarget>(\n source: LazyLoadedSchemaItem<TSource> | undefined,\n convert: (source: TSource) => TTarget,\n): Promise<TTarget | undefined> {\n if (!source) {\n return undefined;\n }\n return source.then(convert);\n}\n\nconst EMPTY_MAP: ReadonlyMap<EC.FullClassName, EC.CustomAttribute> = new Map();\nasync function createCustomAttributesSet(\n coreCustomAttributes: CoreClass[\"customAttributes\"],\n): Promise<EC.CustomAttributeSet> {\n if (!coreCustomAttributes) {\n return EMPTY_MAP;\n }\n return {\n *[Symbol.iterator]() {\n for (const [className, ca] of coreCustomAttributes) {\n const normalizedClassName = normalizeFullClassName(className);\n yield [normalizedClassName, { ...ca, className: normalizedClassName }];\n }\n },\n get(className: EC.FullClassName) {\n const normalizedClassName = normalizeFullClassName(className);\n const coreCustomAttribute = coreCustomAttributes.get(normalizedClassName);\n return coreCustomAttribute ? { ...coreCustomAttribute, className: normalizedClassName } : undefined;\n },\n };\n}\n\nclass ECRelationshipConstraintImpl implements EC.RelationshipConstraint {\n constructor(\n private _coreConstraint: CoreRelationshipConstraint,\n private _schema: EC.Schema,\n ) {}\n public get multiplicity() {\n return this._coreConstraint.multiplicity;\n }\n public get polymorphic() {\n return this._coreConstraint.polymorphic;\n }\n public get abstractConstraint(): Promise<EC.EntityClass | EC.Mixin | EC.RelationshipClass | undefined> {\n return createFromOptionalLazyLoaded(this._coreConstraint.abstractConstraint, (coreConstraint) =>\n createECClass(coreConstraint, this._schema),\n );\n }\n}\n\nclass ECKindOfQuantityImpl extends ECSchemaItemImpl<CoreKindOfQuantity> implements EC.KindOfQuantity {\n constructor(coreKindOfQuantity: CoreKindOfQuantity) {\n super(coreKindOfQuantity);\n }\n}\n\nclass ECEnumerationImpl extends ECSchemaItemImpl<CoreEnumeration> implements EC.Enumeration {\n constructor(coreEnumeration: CoreEnumeration) {\n super(coreEnumeration);\n }\n public get enumerators() {\n return this._coreSchemaItem.enumerators.map((coreEnumerator) => ({ ...coreEnumerator }));\n }\n public get type() {\n switch (this._coreSchemaItem.type) {\n case PrimitiveType.String:\n return \"String\";\n case PrimitiveType.Integer:\n default:\n return \"Number\";\n }\n }\n public get isStrict() {\n return this._coreSchemaItem.isStrict;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryExecutor.d.ts","sourceRoot":"","sources":["../../../src/core-interop/QueryExecutor.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAuC,MAAM,oBAAoB,CAAC;AAItF,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"QueryExecutor.d.ts","sourceRoot":"","sources":["../../../src/core-interop/QueryExecutor.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAuC,MAAM,oBAAoB,CAAC;AAItF,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,KAAK,EAGV,kBAAkB,EAGnB,MAAM,4BAA4B,CAAC;AAEpC;;;;GAIG;AACH,UAAU,sBAAsB;IAC9B,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,WAAW,CAAC;CAC7F;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,sBAAsB,GAAG,kBAAkB,CAsB3F"}
|
|
@@ -60,10 +60,7 @@ class ECSqlQueryReaderImpl {
|
|
|
60
60
|
if (res.done) {
|
|
61
61
|
return { done: true, value: undefined };
|
|
62
62
|
}
|
|
63
|
-
return {
|
|
64
|
-
done: false,
|
|
65
|
-
value: this._format === "array" ? res.value.toArray() : res.value.toRow(),
|
|
66
|
-
};
|
|
63
|
+
return { done: false, value: this._format === "array" ? res.value.toArray() : res.value.toRow() };
|
|
67
64
|
}
|
|
68
65
|
}
|
|
69
66
|
function bind(bindings) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryExecutor.js","sourceRoot":"","sources":["../../../src/core-interop/QueryExecutor.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACtF,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"QueryExecutor.js","sourceRoot":"","sources":["../../../src/core-interop/QueryExecutor.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACtF,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAoB5D;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,wBAAwB,CAAC,MAA8B;IACrE,OAAO;QACL,iBAAiB,CAAC,KAAoB,EAAE,MAAgC;YACtE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;YACxC,MAAM,IAAI,GAAG,IAAI,mBAAmB,EAAE,CAAC;YACvC,QAAQ,MAAM,EAAE,SAAS,EAAE,CAAC;gBAC1B,KAAK,oBAAoB;oBACvB,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,qBAAqB,CAAC,CAAC;oBACxD,MAAM;gBACR,KAAK,SAAS;oBACZ,IAAI,CAA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CAAC,KAAK,CAAC,CAAC,CAAC;gBACrD,MAAM;YACR,KAAK,QAAQ;gBACX,MAAM,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;gBAClC,MAAM;QACV,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,OAAO,CAAC,KAAa,EAAE,IAA0B;IACxD,MAAM,UAAU,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,kBAAkB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5E,OAAO,GAAG,UAAU,GAAG,KAAK,EAAE,CAAC;AACjC,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 { OrderedId64Iterable } from \"@itwin/core-bentley\";\nimport { QueryBinder, QueryOptionsBuilder, QueryRowFormat } from \"@itwin/core-common\";\nimport { Point2d, Point3d } from \"@itwin/core-geometry\";\nimport { trimWhitespace } from \"@itwin/presentation-shared\";\n\nimport type { ECSqlReader, QueryOptions } from \"@itwin/core-common\";\nimport type {\n ECSqlBinding,\n ECSqlQueryDef,\n ECSqlQueryExecutor,\n ECSqlQueryReaderOptions,\n ECSqlQueryRow,\n} from \"@itwin/presentation-shared\";\n\n/**\n * Defines input for `createECSqlQueryExecutor`. Generally, this is an instance of either [IModelDb](https://www.itwinjs.org/reference/core-backend/imodels/imodeldb/)\n * or [IModelConnection](https://www.itwinjs.org/reference/core-frontend/imodelconnection/imodelconnection/).\n * @public\n */\ninterface CoreECSqlReaderFactory {\n createQueryReader(ecsql: string, binder?: QueryBinder, options?: QueryOptions): ECSqlReader;\n}\n\n/**\n * Creates an `ECSqlQueryExecutor` from either [IModelDb](https://www.itwinjs.org/reference/core-backend/imodels/imodeldb/) or\n * [IModelConnection](https://www.itwinjs.org/reference/core-frontend/imodelconnection/imodelconnection/).\n *\n * Usage example:\n *\n * ```ts\n * import { IModelDb } from \"@itwin/core-backend\";\n * import { createECSqlQueryExecutor } from \"@itwin/presentation-core-interop\";\n *\n * const imodel: IModelDb = getIModelDb();\n * const executor = createECSqlQueryExecutor(imodel);\n * for await (const row of executor.createQueryReader(MY_QUERY)) {\n * // TODO: do something with `row`\n * }\n * ```\n *\n * @public\n */\nexport function createECSqlQueryExecutor(imodel: CoreECSqlReaderFactory): ECSqlQueryExecutor {\n return {\n createQueryReader(query: ECSqlQueryDef, config?: ECSqlQueryReaderOptions) {\n const { ctes, ecsql, bindings } = query;\n const opts = new QueryOptionsBuilder();\n switch (config?.rowFormat) {\n case \"ECSqlPropertyNames\":\n opts.setRowFormat(QueryRowFormat.UseECSqlPropertyNames);\n break;\n case \"Indexes\":\n opts.setRowFormat(QueryRowFormat.UseECSqlPropertyIndexes);\n break;\n }\n if (config?.restartToken) {\n opts.setRestartToken(config.restartToken);\n }\n return new ECSqlQueryReaderImpl(\n imodel.createQueryReader(trimWhitespace(addCTEs(ecsql, ctes)), bind(bindings ?? []), opts.getOptions()),\n config?.rowFormat === \"Indexes\" ? \"array\" : \"object\",\n );\n },\n };\n}\n\nclass ECSqlQueryReaderImpl implements ReturnType<ECSqlQueryExecutor[\"createQueryReader\"]> {\n public constructor(\n private _coreReader: ECSqlReader,\n private _format: \"array\" | \"object\",\n ) {}\n public [Symbol.asyncIterator](): AsyncIterableIterator<ECSqlQueryRow> {\n return this;\n }\n public async next(): Promise<IteratorResult<ECSqlQueryRow>> {\n const res = await this._coreReader.next();\n if (res.done) {\n return { done: true, value: undefined };\n }\n return { done: false, value: this._format === \"array\" ? res.value.toArray() : res.value.toRow() };\n }\n}\n\nfunction bind(bindings: ECSqlBinding[]): QueryBinder {\n const binder = new QueryBinder();\n bindings.forEach((b, i) => {\n if (b.value === undefined) {\n binder.bindNull(i + 1);\n return;\n }\n switch (b.type) {\n case \"boolean\":\n binder.bindBoolean(i + 1, b.value);\n break;\n case \"double\":\n binder.bindDouble(i + 1, b.value);\n break;\n case \"id\":\n binder.bindId(i + 1, b.value);\n break;\n case \"idset\":\n binder.bindIdSet(i + 1, OrderedId64Iterable.sortArray(b.value));\n break;\n case \"int\":\n binder.bindInt(i + 1, b.value);\n break;\n case \"long\":\n binder.bindLong(i + 1, b.value);\n break;\n case \"point2d\":\n binder.bindPoint2d(i + 1, Point2d.fromJSON(b.value));\n break;\n case \"point3d\":\n binder.bindPoint3d(i + 1, Point3d.fromJSON(b.value));\n break;\n case \"string\":\n binder.bindString(i + 1, b.value);\n break;\n }\n });\n return binder;\n}\n\nfunction addCTEs(ecsql: string, ctes: string[] | undefined) {\n const ctesPrefix = ctes?.length ? `WITH RECURSIVE ${ctes.join(\", \")} ` : \"\";\n return `${ctesPrefix}${ecsql}`;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/presentation-core-interop",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.1",
|
|
4
4
|
"description": "The package acts as a layer between iTwin.js Core and Presentation packages.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -31,49 +31,41 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"rxjs": "^7.8.2",
|
|
34
|
-
"@itwin/presentation-shared": "
|
|
34
|
+
"@itwin/presentation-shared": "2.0.0-alpha.10"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@itwin/core-bentley": "^
|
|
38
|
-
"@itwin/core-common": "^
|
|
39
|
-
"@itwin/core-geometry": "^
|
|
40
|
-
"@itwin/core-quantity": "^
|
|
41
|
-
"@itwin/ecschema-metadata": "^
|
|
37
|
+
"@itwin/core-bentley": "^5.0.0",
|
|
38
|
+
"@itwin/core-common": "^5.0.0",
|
|
39
|
+
"@itwin/core-geometry": "^5.0.0",
|
|
40
|
+
"@itwin/core-quantity": "^5.0.0",
|
|
41
|
+
"@itwin/ecschema-metadata": "^5.0.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@itwin/build-tools": "^5.
|
|
45
|
-
"@itwin/core-bentley": "^5.
|
|
46
|
-
"@itwin/core-common": "^5.
|
|
47
|
-
"@itwin/core-geometry": "^5.
|
|
48
|
-
"@itwin/core-quantity": "^5.
|
|
49
|
-
"@itwin/ecschema-metadata": "^5.
|
|
44
|
+
"@itwin/build-tools": "^5.8.0",
|
|
45
|
+
"@itwin/core-bentley": "^5.8.0",
|
|
46
|
+
"@itwin/core-common": "^5.8.0",
|
|
47
|
+
"@itwin/core-geometry": "^5.8.0",
|
|
48
|
+
"@itwin/core-quantity": "^5.8.0",
|
|
49
|
+
"@itwin/ecschema-metadata": "^5.8.0",
|
|
50
50
|
"@itwin/eslint-plugin": "5.1.0",
|
|
51
|
-
"@
|
|
52
|
-
"@types/chai-as-promised": "^8.0.2",
|
|
53
|
-
"@types/mocha": "^10.0.10",
|
|
54
|
-
"@types/sinon": "^17.0.4",
|
|
55
|
-
"@types/sinon-chai": "^4.0.0",
|
|
56
|
-
"c8": "^10.1.3",
|
|
57
|
-
"chai": "^5.3.3",
|
|
58
|
-
"chai-as-promised": "^8.0.2",
|
|
51
|
+
"@vitest/coverage-v8": "^4.1.3",
|
|
59
52
|
"cpx2": "^7.0.2",
|
|
60
53
|
"eslint": "^9.39.4",
|
|
61
|
-
"mocha": "^11.7.5",
|
|
62
54
|
"rimraf": "^6.1.3",
|
|
63
55
|
"rxjs-for-await": "^1.0.0",
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"typescript": "~5.7.3"
|
|
56
|
+
"typescript": "~5.7.3",
|
|
57
|
+
"vitest": "^4.1.3"
|
|
67
58
|
},
|
|
68
59
|
"scripts": {
|
|
69
|
-
"build": "npm run -s build:cjs && npm run -s build:esm",
|
|
60
|
+
"build": "npm run -s typecheck && npm run -s build:cjs && npm run -s build:esm",
|
|
70
61
|
"build:cjs": "node ../../scripts/package-cjs.mjs ./lib/cjs && tsc -p tsconfig.cjs.json",
|
|
71
62
|
"build:esm": "tsc -p tsconfig.esm.json",
|
|
63
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
72
64
|
"clean": "rimraf lib",
|
|
73
|
-
"cover": "
|
|
65
|
+
"cover": "vitest run --coverage",
|
|
74
66
|
"lint": "eslint \"./src/**/*.ts\"",
|
|
75
|
-
"test
|
|
76
|
-
"test": "
|
|
67
|
+
"test": "vitest run",
|
|
68
|
+
"test:watch": "vitest",
|
|
77
69
|
"extract-api": "betools extract-api --entry=presentation-core-interop --apiReportFolder=./api --apiReportTempFolder=./api/temp --apiSummaryFolder=./api --includeUnexportedApis",
|
|
78
70
|
"check-internal": "node ../../scripts/checkInternal.js --apiSummary ./api/presentation-core-interop.api.md",
|
|
79
71
|
"update-extractions": "node ../../scripts/updateExtractions.js --targets=./README.md",
|