@itwin/presentation-core-interop 1.4.0-alpha.4 → 1.4.0-alpha.6
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 +33 -0
- package/README.md +69 -17
- package/lib/cjs/core-interop/Formatting.d.ts +7 -7
- package/lib/cjs/core-interop/Formatting.d.ts.map +1 -1
- package/lib/cjs/core-interop/Formatting.js +3 -3
- package/lib/cjs/core-interop/Formatting.js.map +1 -1
- package/lib/cjs/core-interop/Logging.d.ts +1 -1
- package/lib/cjs/core-interop/Logging.d.ts.map +1 -1
- package/lib/cjs/core-interop/Logging.js.map +1 -1
- package/lib/cjs/core-interop/Metadata.d.ts +6 -5
- package/lib/cjs/core-interop/Metadata.d.ts.map +1 -1
- package/lib/cjs/core-interop/Metadata.js +3 -3
- package/lib/cjs/core-interop/Metadata.js.map +1 -1
- package/lib/cjs/core-interop/MetadataInternal.d.ts +2 -2
- package/lib/cjs/core-interop/MetadataInternal.d.ts.map +1 -1
- package/lib/cjs/core-interop/MetadataInternal.js +4 -8
- package/lib/cjs/core-interop/MetadataInternal.js.map +1 -1
- package/lib/cjs/core-interop/QueryExecutor.d.ts +3 -2
- package/lib/cjs/core-interop/QueryExecutor.d.ts.map +1 -1
- package/lib/cjs/core-interop/QueryExecutor.js +1 -1
- package/lib/cjs/core-interop/QueryExecutor.js.map +1 -1
- package/lib/cjs/core-interop/Transactions.d.ts +1 -1
- package/lib/cjs/core-interop/Transactions.d.ts.map +1 -1
- package/lib/cjs/core-interop/Transactions.js.map +1 -1
- package/lib/esm/core-interop/Formatting.d.ts +7 -7
- package/lib/esm/core-interop/Formatting.d.ts.map +1 -1
- package/lib/esm/core-interop/Formatting.js +4 -4
- package/lib/esm/core-interop/Formatting.js.map +1 -1
- package/lib/esm/core-interop/Logging.d.ts +1 -1
- package/lib/esm/core-interop/Logging.d.ts.map +1 -1
- package/lib/esm/core-interop/Logging.js.map +1 -1
- package/lib/esm/core-interop/Metadata.d.ts +6 -5
- package/lib/esm/core-interop/Metadata.d.ts.map +1 -1
- package/lib/esm/core-interop/Metadata.js +3 -3
- package/lib/esm/core-interop/Metadata.js.map +1 -1
- package/lib/esm/core-interop/MetadataInternal.d.ts +2 -2
- package/lib/esm/core-interop/MetadataInternal.d.ts.map +1 -1
- package/lib/esm/core-interop/MetadataInternal.js +5 -9
- package/lib/esm/core-interop/MetadataInternal.js.map +1 -1
- package/lib/esm/core-interop/QueryExecutor.d.ts +3 -2
- package/lib/esm/core-interop/QueryExecutor.d.ts.map +1 -1
- package/lib/esm/core-interop/QueryExecutor.js +1 -1
- package/lib/esm/core-interop/QueryExecutor.js.map +1 -1
- package/lib/esm/core-interop/Transactions.d.ts +1 -1
- package/lib/esm/core-interop/Transactions.d.ts.map +1 -1
- package/lib/esm/core-interop/Transactions.js.map +1 -1
- package/package.json +12 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @itwin/presentation-core-interop
|
|
2
2
|
|
|
3
|
+
## 1.4.0-alpha.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1200](https://github.com/iTwin/presentation/pull/1200): Removed unnecessary, always-truthy condition checks.
|
|
8
|
+
- Updated dependencies:
|
|
9
|
+
- @itwin/presentation-shared@2.0.0-alpha.7
|
|
10
|
+
|
|
11
|
+
## 1.4.0-alpha.5
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#1180](https://github.com/iTwin/presentation/pull/1180): Version bump
|
|
16
|
+
- Updated dependencies:
|
|
17
|
+
- @itwin/presentation-shared@2.0.0-alpha.6
|
|
18
|
+
|
|
3
19
|
## 1.4.0-alpha.4
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -49,6 +65,23 @@
|
|
|
49
65
|
- Updated dependencies:
|
|
50
66
|
- @itwin/presentation-shared@2.0.0-alpha.0
|
|
51
67
|
|
|
68
|
+
## 1.3.8
|
|
69
|
+
|
|
70
|
+
### Patch Changes
|
|
71
|
+
|
|
72
|
+
- [#1168](https://github.com/iTwin/presentation/pull/1168): Bump dependencies.
|
|
73
|
+
- [#1161](https://github.com/iTwin/presentation/pull/1161): Bump iTwin.js dependencies to `^5.5.0`.
|
|
74
|
+
- Updated dependencies:
|
|
75
|
+
- @itwin/presentation-shared@1.2.7
|
|
76
|
+
|
|
77
|
+
## 1.3.7
|
|
78
|
+
|
|
79
|
+
### Patch Changes
|
|
80
|
+
|
|
81
|
+
- [#1152](https://github.com/iTwin/presentation/pull/1152): Bump dependencies.
|
|
82
|
+
- Updated dependencies:
|
|
83
|
+
- @itwin/presentation-shared@1.2.6
|
|
84
|
+
|
|
52
85
|
## 1.3.6
|
|
53
86
|
|
|
54
87
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -17,6 +17,9 @@ Attempts to create a unique identifier for the given iModel. In majority of case
|
|
|
17
17
|
|
|
18
18
|
Example:
|
|
19
19
|
|
|
20
|
+
<!-- [[include: [Presentation.CoreInterop.CreateIModelKey.Imports, Presentation.CoreInterop.CreateIModelKey.Example], ts]] -->
|
|
21
|
+
<!-- BEGIN EXTRACTION -->
|
|
22
|
+
|
|
20
23
|
```ts
|
|
21
24
|
import { IModelConnection } from "@itwin/core-frontend";
|
|
22
25
|
import { createIModelKey } from "@itwin/presentation-core-interop";
|
|
@@ -27,85 +30,132 @@ IModelConnection.onOpen.addListener((imodel: IModelConnection) => {
|
|
|
27
30
|
});
|
|
28
31
|
```
|
|
29
32
|
|
|
33
|
+
<!-- END EXTRACTION -->
|
|
34
|
+
|
|
30
35
|
### `createECSqlQueryExecutor`
|
|
31
36
|
|
|
32
37
|
Maps an iModel in the form of `itwinjs-core` [IModelDb](https://www.itwinjs.org/reference/core-backend/imodels/imodeldb/) or [IModelConnection](https://www.itwinjs.org/reference/core-frontend/imodelconnection/imodelconnection/) to an instance of `ECSqlQueryExecutor`, used in `@itwin/presentation-hierarchies` and `@itwin/unified-selection` packages.
|
|
33
38
|
|
|
34
39
|
Example:
|
|
35
40
|
|
|
41
|
+
<!-- [[include: [Presentation.CoreInterop.CreateECSqlQueryExecutor.Imports, Presentation.CoreInterop.CreateECSqlQueryExecutor.Example], ts]] -->
|
|
42
|
+
<!-- BEGIN EXTRACTION -->
|
|
43
|
+
|
|
36
44
|
```ts
|
|
37
|
-
import {
|
|
45
|
+
import { IModelConnection } from "@itwin/core-frontend";
|
|
38
46
|
import { createECSqlQueryExecutor } from "@itwin/presentation-core-interop";
|
|
39
47
|
|
|
40
|
-
const imodel:
|
|
48
|
+
const imodel: IModelConnection = getIModelConnection();
|
|
41
49
|
const executor = createECSqlQueryExecutor(imodel);
|
|
42
|
-
for await (const row of executor.createQueryReader(MY_QUERY)) {
|
|
43
|
-
|
|
50
|
+
for await (const row of executor.createQueryReader({ ecsql: MY_QUERY })) {
|
|
51
|
+
console.log(row);
|
|
44
52
|
}
|
|
45
53
|
```
|
|
46
54
|
|
|
55
|
+
<!-- END EXTRACTION -->
|
|
56
|
+
|
|
47
57
|
### `createECSchemaProvider`
|
|
48
58
|
|
|
49
59
|
Maps an instance of `itwinjs-core` [SchemaContext](https://www.itwinjs.org/reference/ecschema-metadata/context/schemacontext/) class to an instance of `ECSchemaProvider`, used in `@itwin/presentation-hierarchies` and `@itwin/unified-selection` packages.
|
|
50
60
|
|
|
51
61
|
Example:
|
|
52
62
|
|
|
63
|
+
<!-- [[include: [Presentation.CoreInterop.CreateECSchemaProvider.Imports, Presentation.CoreInterop.CreateECSchemaProvider.Example], ts]] -->
|
|
64
|
+
<!-- BEGIN EXTRACTION -->
|
|
65
|
+
|
|
53
66
|
```ts
|
|
54
|
-
import {
|
|
67
|
+
import { IModelConnection } from "@itwin/core-frontend";
|
|
55
68
|
import { createECSchemaProvider } from "@itwin/presentation-core-interop";
|
|
56
69
|
|
|
57
|
-
const
|
|
58
|
-
const schemaProvider = createECSchemaProvider(
|
|
70
|
+
const imodel: IModelConnection = getIModelConnection();
|
|
71
|
+
const schemaProvider = createECSchemaProvider(imodel.schemaContext);
|
|
59
72
|
// the created schema provider may be used in `@itwin/presentation-hierarchies` or `@itwin/unified-selection` packages
|
|
60
73
|
```
|
|
61
74
|
|
|
75
|
+
<!-- END EXTRACTION -->
|
|
76
|
+
|
|
62
77
|
### `createValueFormatter`
|
|
63
78
|
|
|
64
79
|
Creates an instance of `IPrimitiveValueFormatter` that knows how to format primitive property values using their units' information. That information is retrieved from an iModel through `itwinjs-core` [SchemaContext](https://www.itwinjs.org/reference/ecschema-metadata/context/schemacontext/).
|
|
65
80
|
|
|
66
81
|
Example:
|
|
67
82
|
|
|
83
|
+
<!-- [[include: [Presentation.CoreInterop.CreateValueFormatter.Imports, Presentation.CoreInterop.CreateValueFormatter.Example], ts]] -->
|
|
84
|
+
<!-- BEGIN EXTRACTION -->
|
|
85
|
+
|
|
68
86
|
```ts
|
|
69
|
-
import {
|
|
87
|
+
import { IModelConnection } from "@itwin/core-frontend";
|
|
70
88
|
import { createValueFormatter } from "@itwin/presentation-core-interop";
|
|
71
89
|
|
|
72
|
-
const
|
|
73
|
-
const
|
|
74
|
-
const
|
|
90
|
+
const imodel: IModelConnection = getIModelConnection();
|
|
91
|
+
const metricFormatter = createValueFormatter({ schemaContext: imodel.schemaContext, unitSystem: "metric" });
|
|
92
|
+
const imperialFormatter = createValueFormatter({ schemaContext: imodel.schemaContext, unitSystem: "imperial" });
|
|
93
|
+
|
|
94
|
+
// Define the raw value to be formatted
|
|
95
|
+
const value = 1.234;
|
|
96
|
+
|
|
97
|
+
// Define the `KindOfQuantity` to use for formatting:
|
|
98
|
+
// <KindOfQuantity
|
|
99
|
+
// typeName="FlowRate"
|
|
100
|
+
// displayLabel="Flow Rate"
|
|
101
|
+
// persistenceUnit="u:CUB_M_PER_SEC"
|
|
102
|
+
// relativeError="1e-05"
|
|
103
|
+
// presentationUnits="f:DefaultRealU(4)[u:LITRE_PER_MIN];f:DefaultRealU(4)[u:GALLON_PER_MIN]"
|
|
104
|
+
// />
|
|
105
|
+
const koqName = `${KOQ_SCHEMA_NAME}.FlowRate`;
|
|
106
|
+
|
|
107
|
+
// Not passing `koqName` formats the value without units using the default formatter:
|
|
108
|
+
expect(await metricFormatter({ type: "Double", value })).to.eq("1.23");
|
|
109
|
+
|
|
110
|
+
// Metric formatter formats the value in liters per minute:
|
|
111
|
+
expect(await metricFormatter({ type: "Double", value, koqName })).to.eq("74040.0 L/min");
|
|
112
|
+
|
|
113
|
+
// Imperial formatter formats the value in gallons per minute:
|
|
114
|
+
expect(await imperialFormatter({ type: "Double", value, koqName })).to.eq("19559.2988 gal/min");
|
|
75
115
|
```
|
|
76
116
|
|
|
117
|
+
<!-- END EXTRACTION -->
|
|
118
|
+
|
|
77
119
|
### `registerTxnListeners`
|
|
78
120
|
|
|
79
121
|
Registers a number of transaction listeners on either the backend [TxnManager](https://www.itwinjs.org/reference/core-backend/imodels/txnmanager/) or the frontend [BriefcaseTxns](https://www.itwinjs.org/reference/core-frontend/imodelconnection/briefcasetxns/) and calls the given `onChange` function whenever there's a change in an iModel holding the transaction manager.
|
|
80
122
|
|
|
81
123
|
Example:
|
|
82
124
|
|
|
125
|
+
<!-- [[include: [Presentation.CoreInterop.RegisterTxnListeners.Imports, Presentation.CoreInterop.RegisterTxnListeners.Example], ts]] -->
|
|
126
|
+
<!-- BEGIN EXTRACTION -->
|
|
127
|
+
|
|
83
128
|
```ts
|
|
84
129
|
import { BriefcaseDb } from "@itwin/core-backend";
|
|
85
130
|
import { registerTxnListeners } from "@itwin/presentation-core-interop";
|
|
86
131
|
import { HierarchyProvider } from "@itwin/presentation-hierarchies";
|
|
87
132
|
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
const provider: HierarchyProvider = getHierarchyProvider();
|
|
133
|
+
const imodel: BriefcaseDb = getIModel();
|
|
134
|
+
const provider: HierarchyProvider & { notifyDataSourceChanged: () => void } = getHierarchyProvider();
|
|
91
135
|
|
|
92
136
|
// register the listeners
|
|
93
|
-
const unregister = registerTxnListeners(
|
|
137
|
+
const unregister = registerTxnListeners(imodel.txns, () => {
|
|
94
138
|
// notify provided about the changed data
|
|
95
139
|
provider.notifyDataSourceChanged();
|
|
96
|
-
//
|
|
140
|
+
// the provider is expected to raise `hierarchyChanged` event, which in turn
|
|
141
|
+
// should trigger an update in the UI that uses this provider
|
|
97
142
|
});
|
|
98
143
|
|
|
99
144
|
// clean up on iModel close
|
|
100
|
-
|
|
145
|
+
imodel.onClosed.addOnce(() => unregister());
|
|
101
146
|
```
|
|
102
147
|
|
|
148
|
+
<!-- END EXTRACTION -->
|
|
149
|
+
|
|
103
150
|
### `createLogger`
|
|
104
151
|
|
|
105
152
|
Maps the `itwinjs-core` [Logger](https://www.itwinjs.org/reference/core-bentley/logging/logger/) class to an `ILogger` interface used by Presentation packages.
|
|
106
153
|
|
|
107
154
|
Example:
|
|
108
155
|
|
|
156
|
+
<!-- [[include: [Presentation.CoreInterop.CreateLogger.Imports, Presentation.CoreInterop.CreateLogger.Example], ts]] -->
|
|
157
|
+
<!-- BEGIN EXTRACTION -->
|
|
158
|
+
|
|
109
159
|
```ts
|
|
110
160
|
import { Logger as CoreLogger } from "@itwin/core-bentley";
|
|
111
161
|
import { createLogger as createPresentationLogger } from "@itwin/presentation-core-interop";
|
|
@@ -113,3 +163,5 @@ import { setLogger as setPresentationLogger } from "@itwin/presentation-hierarch
|
|
|
113
163
|
|
|
114
164
|
setPresentationLogger(createPresentationLogger(CoreLogger));
|
|
115
165
|
```
|
|
166
|
+
|
|
167
|
+
<!-- END EXTRACTION -->
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { UnitSystemKey } from "@itwin/core-quantity";
|
|
2
|
-
import { SchemaContext } from "@itwin/ecschema-metadata";
|
|
3
|
-
import { IPrimitiveValueFormatter } from "@itwin/presentation-shared";
|
|
1
|
+
import type { UnitSystemKey } from "@itwin/core-quantity";
|
|
2
|
+
import type { SchemaContext } from "@itwin/ecschema-metadata";
|
|
3
|
+
import type { IPrimitiveValueFormatter } from "@itwin/presentation-shared";
|
|
4
4
|
/**
|
|
5
5
|
* Props for `createValueFormatter` function.
|
|
6
6
|
* @public
|
|
@@ -8,7 +8,7 @@ import { IPrimitiveValueFormatter } from "@itwin/presentation-shared";
|
|
|
8
8
|
interface CreateValueFormatterProps {
|
|
9
9
|
/**
|
|
10
10
|
* An instance of [SchemaContext](https://www.itwinjs.org/reference/ecschema-metadata/context/schemacontext/) for
|
|
11
|
-
* getting units information.
|
|
11
|
+
* getting units information. Generally, retrieved directly from `IModelDb` or `IModelConnection` using the `schemaContext` accessor.
|
|
12
12
|
*/
|
|
13
13
|
schemaContext: SchemaContext;
|
|
14
14
|
/**
|
|
@@ -30,11 +30,11 @@ interface CreateValueFormatterProps {
|
|
|
30
30
|
* Usage example:
|
|
31
31
|
*
|
|
32
32
|
* ```ts
|
|
33
|
-
* import {
|
|
33
|
+
* import { IModelConnection } from "@itwin/core-frontend";
|
|
34
34
|
* import { createValueFormatter } from "@itwin/presentation-core-interop";
|
|
35
35
|
*
|
|
36
|
-
* const
|
|
37
|
-
* const formatter = createValueFormatter({ schemaContext, unitSystem: "metric" });
|
|
36
|
+
* const imodel: IModelConnection = getIModel();
|
|
37
|
+
* const formatter = createValueFormatter({ schemaContext: imodel.schemaContext, unitSystem: "metric" });
|
|
38
38
|
* const formattedValue = await formatter({ type: "Double", value: 1.234, koqName: "MySchema.LengthKindOfQuantity" });
|
|
39
39
|
* ```
|
|
40
40
|
*
|
|
@@ -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":"AASA,OAAO,KAAK,EAA8B,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACtF,OAAO,KAAK,EAA0D,aAAa,EAAQ,MAAM,0BAA0B,CAAC;AAC5H,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,CAc/F"}
|
|
@@ -15,11 +15,11 @@ const presentation_shared_1 = require("@itwin/presentation-shared");
|
|
|
15
15
|
* Usage example:
|
|
16
16
|
*
|
|
17
17
|
* ```ts
|
|
18
|
-
* import {
|
|
18
|
+
* import { IModelConnection } from "@itwin/core-frontend";
|
|
19
19
|
* import { createValueFormatter } from "@itwin/presentation-core-interop";
|
|
20
20
|
*
|
|
21
|
-
* const
|
|
22
|
-
* const formatter = createValueFormatter({ schemaContext, unitSystem: "metric" });
|
|
21
|
+
* const imodel: IModelConnection = getIModel();
|
|
22
|
+
* const formatter = createValueFormatter({ schemaContext: imodel.schemaContext, unitSystem: "metric" });
|
|
23
23
|
* const formattedValue = await formatter({ type: "Double", value: 1.234, koqName: "MySchema.LengthKindOfQuantity" });
|
|
24
24
|
* ```
|
|
25
25
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Formatting.js","sourceRoot":"","sources":["../../../src/core-interop/Formatting.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AA2DhG,oDAcC;AAvED,wDAA0H;AAC1H,gEAWkC;AAClC,oEAA4I;AA2B5I;;;;;;;;;;;;;;;;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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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;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 { FormatProps, FormatterSpec, Format as QuantityFormat, UnitsProvider, UnitSystemKey } from \"@itwin/core-quantity\";\nimport {\n Format,\n InvertedUnit,\n KindOfQuantity,\n LazyLoadedFormat,\n OverrideFormat,\n SchemaContext,\n SchemaKey,\n SchemaMatchType,\n SchemaUnitProvider,\n Unit,\n} from \"@itwin/ecschema-metadata\";\nimport { createDefaultValueFormatter, IPrimitiveValueFormatter, parseFullClassName, 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.\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 { SchemaContext } from \"@itwin/ecschema-metadata\";\n * import { createValueFormatter } from \"@itwin/presentation-core-interop\";\n *\n * const schemaContext = new SchemaContext();\n * const formatter = createValueFormatter({ 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;;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,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,iBAAiB,CAAC,OAAsB,EAAE,QAAgB;IACvE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAA,wCAAkB,EAAC,QAAQ,CAAC,CAAC;IACxE,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,IAAI,6B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AU,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,5 +1,5 @@
|
|
|
1
1
|
import { LogLevel as CoreLogLevel } from "@itwin/core-bentley";
|
|
2
|
-
import { ILogger } from "@itwin/presentation-shared";
|
|
2
|
+
import type { ILogger } from "@itwin/presentation-shared";
|
|
3
3
|
/**
|
|
4
4
|
* Defines input for `createLogger`. Generally, this is the [Logger](https://www.itwinjs.org/reference/core-bentley/logging/logger/)
|
|
5
5
|
* class from `@itwin/core-bentley` package.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Logging.d.ts","sourceRoot":"","sources":["../../../src/core-interop/Logging.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"Logging.d.ts","sourceRoot":"","sources":["../../../src/core-interop/Logging.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAE/D,OAAO,KAAK,EAAE,OAAO,EAAY,MAAM,4BAA4B,CAAC;AAEpE;;;;GAIG;AACH,UAAU,WAAW;IACnB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC;IAC1D,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAClD,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACpD,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACjD,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACnD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,WAAW,GAAG,OAAO,CAQ7D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Logging.js","sourceRoot":"","sources":["../../../src/core-interop/Logging.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;
|
|
1
|
+
{"version":3,"file":"Logging.js","sourceRoot":"","sources":["../../../src/core-interop/Logging.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AAmChG,oCAQC;AAzCD,sDAA+D;AAiB/D;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,YAAY,CAAC,UAAuB;IAClD,OAAO;QACL,SAAS,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,QAAQ,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC;QACtF,QAAQ,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC;QAC/D,UAAU,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,QAAQ,EAAE,GAAG,CAAC;QACnE,OAAO,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;QAC7D,QAAQ,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC;KAChE,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,CAAC,KAAe;IACtC,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,OAAO;YACV,OAAO,uBAAY,CAAC,KAAK,CAAC;QAC5B,KAAK,SAAS;YACZ,OAAO,uBAAY,CAAC,OAAO,CAAC;QAC9B,KAAK,MAAM;YACT,OAAO,uBAAY,CAAC,IAAI,CAAC;QAC3B,KAAK,OAAO;YACV,OAAO,uBAAY,CAAC,KAAK,CAAC;IAC9B,CAAC;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { LogLevel as CoreLogLevel } from \"@itwin/core-bentley\";\n\nimport type { ILogger, LogLevel } from \"@itwin/presentation-shared\";\n\n/**\n * Defines input for `createLogger`. Generally, this is the [Logger](https://www.itwinjs.org/reference/core-bentley/logging/logger/)\n * class from `@itwin/core-bentley` package.\n * @public\n */\ninterface ICoreLogger {\n isEnabled(category: string, level: CoreLogLevel): boolean;\n logError(category: string, message: string): void;\n logWarning(category: string, message: string): void;\n logInfo(category: string, message: string): void;\n logTrace(category: string, message: string): void;\n}\n\n/**\n * Creates a presentation `ILogger` instance that forwards all logging calls to the\n * [Logger](https://www.itwinjs.org/reference/core-bentley/logging/logger/) API.\n *\n * Usage example:\n *\n * ```ts\n * import { Logger } from \"@itwin/core-bentley\";\n * import { createLogger } from \"@itwin/presentation-core-interop\";\n * import { setLogger } from \"@itwin/presentation-hierarchies\";\n *\n * setLogger(createLogger(Logger));\n * ```\n *\n * @public\n */\nexport function createLogger(coreLogger: ICoreLogger): ILogger {\n return {\n isEnabled: (category, level) => coreLogger.isEnabled(category, getCoreLogLevel(level)),\n logError: (category, msg) => coreLogger.logError(category, msg),\n logWarning: (category, msg) => coreLogger.logWarning(category, msg),\n logInfo: (category, msg) => coreLogger.logInfo(category, msg),\n logTrace: (category, msg) => coreLogger.logTrace(category, msg),\n };\n}\n\nfunction getCoreLogLevel(level: LogLevel): CoreLogLevel {\n switch (level) {\n case \"error\":\n return CoreLogLevel.Error;\n case \"warning\":\n return CoreLogLevel.Warning;\n case \"info\":\n return CoreLogLevel.Info;\n case \"trace\":\n return CoreLogLevel.Trace;\n }\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { SchemaKey as CoreSchemaKey } from "@itwin/ecschema-metadata";
|
|
2
|
+
import type { Schema as CoreSchema } from "@itwin/ecschema-metadata";
|
|
3
|
+
import type { ECSchemaProvider } from "@itwin/presentation-shared";
|
|
3
4
|
/**
|
|
4
5
|
* Defines input for `createECSchemaProvider`. Generally, this is an instance of [SchemaContext](https://www.itwinjs.org/reference/ecschema-metadata/context/schemacontext/)
|
|
5
6
|
* class from `@itwin/ecschema-metadata` package.
|
|
@@ -14,11 +15,11 @@ interface CoreSchemaContext {
|
|
|
14
15
|
* Usage example:
|
|
15
16
|
*
|
|
16
17
|
* ```ts
|
|
17
|
-
* import {
|
|
18
|
+
* import { IModelConnection } from "@itwin/core-frontend";
|
|
18
19
|
* import { createECSchemaProvider } from "@itwin/presentation-core-interop";
|
|
19
20
|
*
|
|
20
|
-
* const
|
|
21
|
-
* const schemaProvider = createECSchemaProvider(
|
|
21
|
+
* const imodel: IModelConnection = getIModel();
|
|
22
|
+
* const schemaProvider = createECSchemaProvider(imodel.schemaContext);
|
|
22
23
|
* // the created schema provider may be used in `@itwin/presentation-hierarchies` and other Presentation packages
|
|
23
24
|
* ```
|
|
24
25
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Metadata.d.ts","sourceRoot":"","sources":["../../../src/core-interop/Metadata.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,
|
|
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,CAiCzF"}
|
|
@@ -13,11 +13,11 @@ const MetadataInternal_js_1 = require("./MetadataInternal.js");
|
|
|
13
13
|
* Usage example:
|
|
14
14
|
*
|
|
15
15
|
* ```ts
|
|
16
|
-
* import {
|
|
16
|
+
* import { IModelConnection } from "@itwin/core-frontend";
|
|
17
17
|
* import { createECSchemaProvider } from "@itwin/presentation-core-interop";
|
|
18
18
|
*
|
|
19
|
-
* const
|
|
20
|
-
* const schemaProvider = createECSchemaProvider(
|
|
19
|
+
* const imodel: IModelConnection = getIModel();
|
|
20
|
+
* const schemaProvider = createECSchemaProvider(imodel.schemaContext);
|
|
21
21
|
* // the created schema provider may be used in `@itwin/presentation-hierarchies` and other Presentation packages
|
|
22
22
|
* ```
|
|
23
23
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Metadata.js","sourceRoot":"","sources":["../../../src/core-interop/Metadata.ts"],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I;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,5 +1,5 @@
|
|
|
1
|
-
import { ECClass as CoreClass, Property as CoreProperty, Schema as CoreSchema } from "@itwin/ecschema-metadata";
|
|
2
|
-
import { EC } from "@itwin/presentation-shared";
|
|
1
|
+
import type { ECClass as CoreClass, Property as CoreProperty, Schema as CoreSchema } from "@itwin/ecschema-metadata";
|
|
2
|
+
import type { EC } from "@itwin/presentation-shared";
|
|
3
3
|
/** @internal */
|
|
4
4
|
export declare function createECSchema(schema: CoreSchema): EC.Schema;
|
|
5
5
|
/** @internal */
|
|
@@ -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":"AASA,OAAO,KAAK,EACV,OAAO,IAAI,SAAS,EAUpB,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,CAY5D;AAwBD,gBAAgB;AAChB,wBAAgB,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,MAAM,GAAG,EAAE,CAAC,KAAK,CAYhF;AA2GD,gBAAgB;AAChB,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,EAAE,CAAC,KAAK,GAAG,EAAE,CAAC,QAAQ,CAqB3F"}
|
|
@@ -122,7 +122,8 @@ class ECClassImpl extends ECSchemaItemImpl {
|
|
|
122
122
|
// `SchemaFormatsProvider` was introduced around the same time the meaning of this second argument was changed
|
|
123
123
|
// from `includeInherited` to `excludeInherited` - we're using its existence to determine what we need to pass to get
|
|
124
124
|
// inherited properties.
|
|
125
|
-
/* c8 ignore next */
|
|
125
|
+
/* c8 ignore next 2 */
|
|
126
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
126
127
|
ecschemaMetadata.SchemaFormatsProvider ? false : true);
|
|
127
128
|
return coreProperty ? createECProperty(coreProperty, this) : undefined;
|
|
128
129
|
}
|
|
@@ -395,15 +396,10 @@ class ECRelationshipConstraintImpl {
|
|
|
395
396
|
this._schema = _schema;
|
|
396
397
|
}
|
|
397
398
|
get multiplicity() {
|
|
398
|
-
return this._coreConstraint.multiplicity
|
|
399
|
-
? {
|
|
400
|
-
lowerLimit: this._coreConstraint.multiplicity.lowerLimit,
|
|
401
|
-
upperLimit: this._coreConstraint.multiplicity.upperLimit,
|
|
402
|
-
}
|
|
403
|
-
: undefined;
|
|
399
|
+
return this._coreConstraint.multiplicity;
|
|
404
400
|
}
|
|
405
401
|
get polymorphic() {
|
|
406
|
-
return this._coreConstraint.polymorphic
|
|
402
|
+
return this._coreConstraint.polymorphic;
|
|
407
403
|
}
|
|
408
404
|
get abstractConstraint() {
|
|
409
405
|
return createFromOptionalLazyLoaded(this._coreConstraint.abstractConstraint, (coreConstraint) => createECClass(coreConstraint, this._schema));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MetadataInternal.js","sourceRoot":"","sources":["../../../src/core-interop/MetadataInternal.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BhG,wCAYC;AAyBD,sCAYC;AA2GD,4CAqBC;AA9MD,sDAA6C;AAC7C,gEAuBkC;AAClC,2EAA6D;AAG7D,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,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,CAAY;IAC3B,YACY,eAAgC,EAC1C,MAAkB;QADR,oBAAe,GAAf,eAAe,CAAiB;QAG1C,IAAI,CAAC,OAAO,GAAG,MAAM,IAAI,cAAc,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;IACvE,CAAC;IACD,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IACD,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC;IACvC,CAAC;IACD,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC;IACn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;IACnD,CAAC;IACD,IAAW,kBAAkB;QAC3B,OAAO,4BAA4B,CAAC,IAAI,CAAC,eAAe,CAAC,kBAAkB,EAAE,CAAC,cAAc,EAAE,EAAE,CAAC,aAAa,CAAC,cAAc,EAAE,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 {\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 PrimitiveType,\n SchemaItemType,\n StrengthDirection,\n} from \"@itwin/ecschema-metadata\";\nimport * as ecschemaMetadata from \"@itwin/ecschema-metadata\";\nimport { 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 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 */\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<string, EC.CustomAttribute> = new Map();\nasync function createCustomAttributesSet(coreCustomAttributes: CoreClass[\"customAttributes\"]): Promise<EC.CustomAttributeSet> {\n if (!coreCustomAttributes) {\n return EMPTY_MAP;\n }\n return coreCustomAttributes;\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 lowerLimit: this._coreConstraint.multiplicity.lowerLimit,\n upperLimit: this._coreConstraint.multiplicity.upperLimit,\n }\n : undefined;\n }\n public get polymorphic() {\n return this._coreConstraint.polymorphic ?? false;\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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BhG,wCAYC;AAyBD,sCAYC;AA4GD,4CAqBC;AA9MD,sDAA6C;AAC7C,gEAA4F;AAC5F,2EAA6D;AAyB7D,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,IAAiB,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACnE,CAAC;QACD,KAAK,CAAC,mB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AC,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\";\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 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<string, EC.CustomAttribute> = new Map();\nasync function createCustomAttributesSet(coreCustomAttributes: CoreClass[\"customAttributes\"]): Promise<EC.CustomAttributeSet> {\n if (!coreCustomAttributes) {\n return EMPTY_MAP;\n }\n return coreCustomAttributes;\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"]}
|