@itwin/presentation-core-interop 2.0.0-alpha.1 → 2.0.0-alpha.3
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 +46 -0
- package/lib/core-interop/Formatting.d.ts.map +1 -0
- package/lib/core-interop/Formatting.js.map +1 -0
- package/lib/core-interop/IModelKey.d.ts.map +1 -0
- package/lib/core-interop/IModelKey.js.map +1 -0
- package/lib/core-interop/Logging.d.ts.map +1 -0
- package/lib/core-interop/Logging.js.map +1 -0
- package/lib/core-interop/Metadata.d.ts.map +1 -0
- package/lib/core-interop/Metadata.js.map +1 -0
- package/lib/core-interop/MetadataInternal.d.ts.map +1 -0
- package/lib/{esm/core-interop → core-interop}/MetadataInternal.js +28 -3
- package/lib/core-interop/MetadataInternal.js.map +1 -0
- package/lib/{cjs/core-interop → core-interop}/QueryExecutor.d.ts +3 -2
- package/lib/core-interop/QueryExecutor.d.ts.map +1 -0
- package/lib/{esm/core-interop → core-interop}/QueryExecutor.js +56 -19
- package/lib/core-interop/QueryExecutor.js.map +1 -0
- package/lib/core-interop/Transactions.d.ts.map +1 -0
- package/lib/core-interop/Transactions.js.map +1 -0
- package/lib/presentation-core-interop.d.ts.map +1 -0
- package/lib/presentation-core-interop.js.map +1 -0
- package/package.json +20 -22
- package/lib/cjs/core-interop/Formatting.d.ts.map +0 -1
- package/lib/cjs/core-interop/Formatting.js +0 -136
- package/lib/cjs/core-interop/Formatting.js.map +0 -1
- package/lib/cjs/core-interop/IModelKey.d.ts.map +0 -1
- package/lib/cjs/core-interop/IModelKey.js +0 -36
- package/lib/cjs/core-interop/IModelKey.js.map +0 -1
- package/lib/cjs/core-interop/Logging.d.ts.map +0 -1
- package/lib/cjs/core-interop/Logging.js +0 -46
- package/lib/cjs/core-interop/Logging.js.map +0 -1
- package/lib/cjs/core-interop/Metadata.d.ts.map +0 -1
- package/lib/cjs/core-interop/Metadata.js +0 -62
- package/lib/cjs/core-interop/Metadata.js.map +0 -1
- package/lib/cjs/core-interop/MetadataInternal.d.ts.map +0 -1
- package/lib/cjs/core-interop/MetadataInternal.js +0 -404
- package/lib/cjs/core-interop/MetadataInternal.js.map +0 -1
- package/lib/cjs/core-interop/QueryExecutor.d.ts.map +0 -1
- package/lib/cjs/core-interop/QueryExecutor.js +0 -112
- package/lib/cjs/core-interop/QueryExecutor.js.map +0 -1
- package/lib/cjs/core-interop/Transactions.d.ts.map +0 -1
- package/lib/cjs/core-interop/Transactions.js +0 -60
- package/lib/cjs/core-interop/Transactions.js.map +0 -1
- package/lib/cjs/package.json +0 -1
- package/lib/cjs/presentation-core-interop.d.ts.map +0 -1
- package/lib/cjs/presentation-core-interop.js +0 -20
- package/lib/cjs/presentation-core-interop.js.map +0 -1
- package/lib/esm/core-interop/Formatting.d.ts +0 -45
- package/lib/esm/core-interop/Formatting.d.ts.map +0 -1
- package/lib/esm/core-interop/Formatting.js.map +0 -1
- package/lib/esm/core-interop/IModelKey.d.ts +0 -31
- package/lib/esm/core-interop/IModelKey.d.ts.map +0 -1
- package/lib/esm/core-interop/IModelKey.js.map +0 -1
- package/lib/esm/core-interop/Logging.d.ts +0 -33
- package/lib/esm/core-interop/Logging.d.ts.map +0 -1
- package/lib/esm/core-interop/Logging.js.map +0 -1
- package/lib/esm/core-interop/Metadata.d.ts +0 -30
- package/lib/esm/core-interop/Metadata.d.ts.map +0 -1
- package/lib/esm/core-interop/Metadata.js.map +0 -1
- package/lib/esm/core-interop/MetadataInternal.d.ts +0 -10
- package/lib/esm/core-interop/MetadataInternal.d.ts.map +0 -1
- package/lib/esm/core-interop/MetadataInternal.js.map +0 -1
- package/lib/esm/core-interop/QueryExecutor.d.ts +0 -33
- package/lib/esm/core-interop/QueryExecutor.d.ts.map +0 -1
- package/lib/esm/core-interop/QueryExecutor.js.map +0 -1
- package/lib/esm/core-interop/Transactions.d.ts +0 -71
- package/lib/esm/core-interop/Transactions.d.ts.map +0 -1
- package/lib/esm/core-interop/Transactions.js.map +0 -1
- package/lib/esm/presentation-core-interop.d.ts +0 -7
- package/lib/esm/presentation-core-interop.d.ts.map +0 -1
- package/lib/esm/presentation-core-interop.js.map +0 -1
- /package/lib/{cjs/core-interop → core-interop}/Formatting.d.ts +0 -0
- /package/lib/{esm/core-interop → core-interop}/Formatting.js +0 -0
- /package/lib/{cjs/core-interop → core-interop}/IModelKey.d.ts +0 -0
- /package/lib/{esm/core-interop → core-interop}/IModelKey.js +0 -0
- /package/lib/{cjs/core-interop → core-interop}/Logging.d.ts +0 -0
- /package/lib/{esm/core-interop → core-interop}/Logging.js +0 -0
- /package/lib/{cjs/core-interop → core-interop}/Metadata.d.ts +0 -0
- /package/lib/{esm/core-interop → core-interop}/Metadata.js +0 -0
- /package/lib/{cjs/core-interop → core-interop}/MetadataInternal.d.ts +0 -0
- /package/lib/{cjs/core-interop → core-interop}/Transactions.d.ts +0 -0
- /package/lib/{esm/core-interop → core-interop}/Transactions.js +0 -0
- /package/lib/{cjs/presentation-core-interop.d.ts → presentation-core-interop.d.ts} +0 -0
- /package/lib/{esm/presentation-core-interop.js → presentation-core-interop.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @itwin/presentation-core-interop
|
|
2
2
|
|
|
3
|
+
## 2.0.0-alpha.3
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#1454](https://github.com/iTwin/presentation/pull/1454): Dropped CommonJS support. These packages are now published as ES modules (ESM) only.
|
|
8
|
+
|
|
9
|
+
### Minor Changes
|
|
10
|
+
|
|
11
|
+
- [#1446](https://github.com/iTwin/presentation/pull/1446): `EC.EntityClass`: Added `getMixins` method that returns the mixins applied directly to the entity class.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies:
|
|
16
|
+
- @itwin/presentation-shared@2.0.0-alpha.12
|
|
17
|
+
|
|
18
|
+
## 2.0.0-alpha.2
|
|
19
|
+
|
|
20
|
+
### Minor Changes
|
|
21
|
+
|
|
22
|
+
- [#1445](https://github.com/iTwin/presentation/pull/1445): `EC.Class`: Added `getOwnProperties` method that returns only the properties defined directly on the class, excluding those inherited from base classes.
|
|
23
|
+
- [#1350](https://github.com/iTwin/presentation/pull/1350): `createECSqlQueryExecutor`: Updated to handle both positional and named bindings when creating query readers.
|
|
24
|
+
- [#1444](https://github.com/iTwin/presentation/pull/1444): `EC.Property`: Added `category` attribute that provides access to the property's `EC.PropertyCategory`. Also added a `description` attribute to `EC.SchemaItem`.
|
|
25
|
+
- [#1363](https://github.com/iTwin/presentation/pull/1363): `createECSchemaProvider`: Populate `version` property on `EC.Schema` objects from the underlying `@itwin/ecschema-metadata` schema version fields.
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- [#1377](https://github.com/iTwin/presentation/pull/1377): `createECSqlQueryExecutor`: queries are now automatically cancelled when consumers break out of iteration.
|
|
30
|
+
- Updated dependencies:
|
|
31
|
+
- @itwin/presentation-shared@2.0.0-alpha.11
|
|
32
|
+
|
|
3
33
|
## 2.0.0-alpha.1
|
|
4
34
|
|
|
5
35
|
### Patch Changes
|
|
@@ -99,6 +129,22 @@
|
|
|
99
129
|
- Updated dependencies:
|
|
100
130
|
- @itwin/presentation-shared@2.0.0-alpha.0
|
|
101
131
|
|
|
132
|
+
## 1.3.13
|
|
133
|
+
|
|
134
|
+
### Patch Changes
|
|
135
|
+
|
|
136
|
+
- [#1338](https://github.com/iTwin/presentation/pull/1338): Bump iTwin.js core dependencies to `^5.9.1`.
|
|
137
|
+
- Updated dependencies:
|
|
138
|
+
- @itwin/presentation-shared@1.2.13
|
|
139
|
+
|
|
140
|
+
## 1.3.12
|
|
141
|
+
|
|
142
|
+
### Patch Changes
|
|
143
|
+
|
|
144
|
+
- [#1313](https://github.com/iTwin/presentation/pull/1313): Bump dependencies.
|
|
145
|
+
- Updated dependencies:
|
|
146
|
+
- @itwin/presentation-shared@1.2.12
|
|
147
|
+
|
|
102
148
|
## 1.3.11
|
|
103
149
|
|
|
104
150
|
### Patch Changes
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +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,EACL,cAAc,EACd,cAAc,EACd,SAAS,EACT,eAAe,EACf,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAClC,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,iCAAiC;IACjC,MAAM,aAAa,GAAG,KAAK,CAAC,aAAa,IAAI,2BAA2B,EAAE,C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E,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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IModelKey.d.ts","sourceRoot":"","sources":["../../src/core-interop/IModelKey.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,UAAU,UAAU;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAQ1D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IModelKey.js","sourceRoot":"","sources":["../../src/core-interop/IModelKey.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAYhG;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,eAAe,CAAC,MAAkB;IAChD,IAAI,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;QACtB,OAAO,MAAM,CAAC,GAAG,CAAC;IACpB,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QACvB,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;AACjE,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\n/**\n * Defines input for `createIModelKey`. 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 CoreIModel {\n key: string;\n name: string;\n}\n\n/**\n * Attempts to create a unique identifier for the given iModel. In majority of cases that's going to be the `key` property, but if it's not\n * set (e.g. when using [BlankConnection](https://www.itwinjs.org/reference/core-frontend/imodelconnection/blankconnection/)) - `name` property\n * is used instead. Finally, if both are empty - the function will throw an error.\n *\n * Example:\n *\n * ```ts\n * import { IModelConnection } from \"@itwin/core-frontend\";\n * import { createIModelKey } from \"@itwin/presentation-core-interop\";\n *\n * IModelConnection.onOpen.addListener((imodel: IModelConnection) => {\n * const key = createIModelKey(imodel);\n * console.log(`IModel opened: \"${key}\"`);\n * });\n * ```\n *\n * @public\n */\nexport function createIModelKey(imodel: CoreIModel): string {\n if (imodel.key.length) {\n return imodel.key;\n }\n if (imodel.name.length) {\n return imodel.name;\n }\n throw new Error(`Provided iModel doesn't have a key or name.`);\n}\n"]}
|
|
@@ -0,0 +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;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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Logging.js","sourceRoot":"","sources":["../../src/core-interop/Logging.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAiB/D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,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,YAAY,CAAC,KAAK,CAAC;QAC5B,KAAK,SAAS;YACZ,OAAO,YAAY,CAAC,OAAO,CAAC;QAC9B,KAAK,MAAM;YACT,OAAO,YAAY,CAAC,IAAI,CAAC;QAC3B,KAAK,OAAO;YACV,OAAO,YAAY,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"]}
|
|
@@ -0,0 +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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AC,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"]}
|
|
@@ -0,0 +1 @@
|
|
|
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,EAIxB,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;AA2BD,gBAAgB;AAChB,wBAAgB,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,MAAM,GAAG,EAAE,CAAC,KAAK,CAYhF;AAiHD,gBAAgB;AAChB,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,EAAE,CAAC,KAAK,GAAG,EAAE,CAAC,QAAQ,CAqB3F"}
|
|
@@ -9,6 +9,7 @@ import { normalizeFullClassName } from "@itwin/presentation-shared";
|
|
|
9
9
|
export function createECSchema(schema) {
|
|
10
10
|
return {
|
|
11
11
|
name: schema.name,
|
|
12
|
+
version: schema.schemaKey.version,
|
|
12
13
|
async getClass(name) {
|
|
13
14
|
const item = await schema.getItem(name, CoreClass);
|
|
14
15
|
return item ? createECClass(item, this) : undefined;
|
|
@@ -37,6 +38,9 @@ class ECSchemaItemImpl {
|
|
|
37
38
|
get label() {
|
|
38
39
|
return this._coreSchemaItem.label;
|
|
39
40
|
}
|
|
41
|
+
get description() {
|
|
42
|
+
return this._coreSchemaItem.description;
|
|
43
|
+
}
|
|
40
44
|
}
|
|
41
45
|
/** @internal */
|
|
42
46
|
export function createECClass(coreClass, schema) {
|
|
@@ -89,6 +93,14 @@ class ECClassImpl extends ECSchemaItemImpl {
|
|
|
89
93
|
}
|
|
90
94
|
return result;
|
|
91
95
|
}
|
|
96
|
+
async getOwnProperties() {
|
|
97
|
+
const coreProperties = await this._coreSchemaItem.getProperties(true);
|
|
98
|
+
const result = new Array();
|
|
99
|
+
for (const coreProperty of coreProperties) {
|
|
100
|
+
result.push(createECProperty(coreProperty, this));
|
|
101
|
+
}
|
|
102
|
+
return result;
|
|
103
|
+
}
|
|
92
104
|
async getDerivedClasses() {
|
|
93
105
|
const coreDerivedClasses = await this._coreSchemaItem.getDerivedClasses();
|
|
94
106
|
return coreDerivedClasses ? coreDerivedClasses.map((coreClass) => createECClass(coreClass, this.schema)) : [];
|
|
@@ -104,6 +116,9 @@ class ECEntityClassImpl extends ECClassImpl {
|
|
|
104
116
|
isEntityClass() {
|
|
105
117
|
return true;
|
|
106
118
|
}
|
|
119
|
+
async getMixins() {
|
|
120
|
+
return Promise.all(this._coreSchemaItem.mixins.map(async (coreMixin) => new ECMixinImpl(await coreMixin, this.schema)));
|
|
121
|
+
}
|
|
107
122
|
}
|
|
108
123
|
class ECRelationshipClassImpl extends ECClassImpl {
|
|
109
124
|
constructor(coreClass, schema) {
|
|
@@ -200,6 +215,9 @@ class ECPropertyImpl {
|
|
|
200
215
|
get kindOfQuantity() {
|
|
201
216
|
return createFromOptionalLazyLoaded(this._coreProperty.kindOfQuantity, (coreKindOfQuantity) => new ECKindOfQuantityImpl(coreKindOfQuantity));
|
|
202
217
|
}
|
|
218
|
+
get category() {
|
|
219
|
+
return createFromOptionalLazyLoaded(this._coreProperty.category, (coreCategory) => new ECPropertyCategoryImpl(coreCategory));
|
|
220
|
+
}
|
|
203
221
|
async getCustomAttributes() {
|
|
204
222
|
return createCustomAttributesSet(this._coreProperty.customAttributes);
|
|
205
223
|
}
|
|
@@ -348,9 +366,8 @@ async function createCustomAttributesSet(coreCustomAttributes) {
|
|
|
348
366
|
}
|
|
349
367
|
},
|
|
350
368
|
get(className) {
|
|
351
|
-
const
|
|
352
|
-
|
|
353
|
-
return coreCustomAttribute ? { ...coreCustomAttribute, className: normalizedClassName } : undefined;
|
|
369
|
+
const coreCustomAttribute = coreCustomAttributes.get(className);
|
|
370
|
+
return coreCustomAttribute ? { ...coreCustomAttribute, className } : undefined;
|
|
354
371
|
},
|
|
355
372
|
};
|
|
356
373
|
}
|
|
@@ -376,6 +393,14 @@ class ECKindOfQuantityImpl extends ECSchemaItemImpl {
|
|
|
376
393
|
super(coreKindOfQuantity);
|
|
377
394
|
}
|
|
378
395
|
}
|
|
396
|
+
class ECPropertyCategoryImpl extends ECSchemaItemImpl {
|
|
397
|
+
constructor(coreCategory) {
|
|
398
|
+
super(coreCategory);
|
|
399
|
+
}
|
|
400
|
+
get priority() {
|
|
401
|
+
return this._coreSchemaItem.priority;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
379
404
|
class ECEnumerationImpl extends ECSchemaItemImpl {
|
|
380
405
|
constructor(coreEnumeration) {
|
|
381
406
|
super(coreEnumeration);
|
|
@@ -0,0 +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,OAAO,IAAI,SAAS,EAAE,aAAa,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClH,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,OAAO,EAAE,MAAM,CAAC,SAAS,CAAC,OAAO;QACjC,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,CAAC;QAC5D,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAe,gBAAgB;IAGjB,eAAe;IAFnB,OAAO,CAAY;IAC3B,YACY,eAAgC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IAC3C,CAAC;IACD,IAAW,WAAW;QACpB,OAAO,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC;IAC1C,CAAC;IACD,IAAW,kBAAkB;QAC3B,OAAO,4BAA4B,CAAC,IAAI,CAAC,eAAe,CAAC,kBAAkB,EAAE,CAAC,cAAc,EAAE,EAAE,CAC9F,aAAa,CAAC,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,CAC5C,CAAC;IACJ,CAAC;CACF;AAED,MAAM,oBAAqB,SAAQ,gBAAoC;IACrE,YAAY,kBAAsC;QAChD,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAC5B,CAAC;CACF;AAED,MAAM,sBAAuB,SAAQ,gBAAsC;IACzE,YAAY,YAAkC;QAC5C,KAAK,CAAC,YAAY,CAAC,CAAC;IACtB,CAAC;IACD,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC;IACvC,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,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 PropertyCategory as CorePropertyCategory,\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 version: schema.schemaKey.version,\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 public get description() {\n return this._coreSchemaItem.description;\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, 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 getOwnProperties(): Promise<Array<EC.Property>> {\n const coreProperties = await this._coreSchemaItem.getProperties(true);\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 public async getMixins(): Promise<EC.Mixin[]> {\n return Promise.all(\n this._coreSchemaItem.mixins.map(async (coreMixin) => new ECMixinImpl(await coreMixin, this.schema)),\n );\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 get category(): Promise<EC.PropertyCategory | undefined> {\n return createFromOptionalLazyLoaded(\n this._coreProperty.category,\n (coreCategory) => new ECPropertyCategoryImpl(coreCategory),\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.FullClassNameDotNotation, 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.FullClassNameDotNotation) {\n const coreCustomAttribute = coreCustomAttributes.get(className);\n return coreCustomAttribute ? { ...coreCustomAttribute, className } : 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 ECPropertyCategoryImpl extends ECSchemaItemImpl<CorePropertyCategory> implements EC.PropertyCategory {\n constructor(coreCategory: CorePropertyCategory) {\n super(coreCategory);\n }\n public get priority() {\n return this._coreSchemaItem.priority;\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,13 +1,14 @@
|
|
|
1
1
|
import { QueryBinder } from "@itwin/core-common";
|
|
2
|
-
import type {
|
|
2
|
+
import type { QueryOptions, QueryRowProxy } from "@itwin/core-common";
|
|
3
3
|
import type { ECSqlQueryExecutor } from "@itwin/presentation-shared";
|
|
4
|
+
export declare const QUERY_CANCEL_DELAY_MS = 100;
|
|
4
5
|
/**
|
|
5
6
|
* Defines input for `createECSqlQueryExecutor`. Generally, this is an instance of either [IModelDb](https://www.itwinjs.org/reference/core-backend/imodels/imodeldb/)
|
|
6
7
|
* or [IModelConnection](https://www.itwinjs.org/reference/core-frontend/imodelconnection/imodelconnection/).
|
|
7
8
|
* @public
|
|
8
9
|
*/
|
|
9
10
|
interface CoreECSqlReaderFactory {
|
|
10
|
-
createQueryReader(ecsql: string, binder?: QueryBinder, options?: QueryOptions):
|
|
11
|
+
createQueryReader(ecsql: string, binder?: QueryBinder, options?: QueryOptions): AsyncIterableIterator<QueryRowProxy>;
|
|
11
12
|
}
|
|
12
13
|
/**
|
|
13
14
|
* Creates an `ECSqlQueryExecutor` from either [IModelDb](https://www.itwinjs.org/reference/core-backend/imodels/imodeldb/) or
|
|
@@ -0,0 +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,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,KAAK,EAGV,kBAAkB,EAGnB,MAAM,4BAA4B,CAAC;AAEpC,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAEzC;;;;GAIG;AACH,UAAU,sBAAsB;IAC9B,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,qBAAqB,CAAC,aAAa,CAAC,CAAC;CACtH;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,sBAAsB,GAAG,kBAAkB,CA8C3F"}
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { OrderedId64Iterable } from "@itwin/core-bentley";
|
|
5
|
+
import { Guid, OrderedId64Iterable } from "@itwin/core-bentley";
|
|
6
6
|
import { QueryBinder, QueryOptionsBuilder, QueryRowFormat } from "@itwin/core-common";
|
|
7
7
|
import { Point2d, Point3d } from "@itwin/core-geometry";
|
|
8
8
|
import { trimWhitespace } from "@itwin/presentation-shared";
|
|
9
|
+
export const QUERY_CANCEL_DELAY_MS = 100;
|
|
9
10
|
/**
|
|
10
11
|
* Creates an `ECSqlQueryExecutor` from either [IModelDb](https://www.itwinjs.org/reference/core-backend/imodels/imodeldb/) or
|
|
11
12
|
* [IModelConnection](https://www.itwinjs.org/reference/core-frontend/imodelconnection/imodelconnection/).
|
|
@@ -38,19 +39,39 @@ export function createECSqlQueryExecutor(imodel) {
|
|
|
38
39
|
opts.setRowFormat(QueryRowFormat.UseECSqlPropertyIndexes);
|
|
39
40
|
break;
|
|
40
41
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
const restartToken = config?.restartToken ?? Guid.createValue();
|
|
43
|
+
opts.setRestartToken(restartToken);
|
|
44
|
+
const onCancel = () => {
|
|
45
|
+
try {
|
|
46
|
+
const cancelReader = imodel.createQueryReader("SELECT 1", undefined, new QueryOptionsBuilder().setRestartToken(restartToken).getOptions());
|
|
47
|
+
void (async () => {
|
|
48
|
+
try {
|
|
49
|
+
for await (const _ of cancelReader) {
|
|
50
|
+
/* drain */
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
/* expected */
|
|
55
|
+
}
|
|
56
|
+
})();
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
/* ignore */
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
return new ECSqlQueryReaderImpl(imodel.createQueryReader(trimWhitespace(addCTEs(ecsql, ctes)), bindings ? bind(bindings) : undefined, opts.getOptions()), config?.rowFormat === "Indexes" ? "array" : "object", onCancel);
|
|
45
63
|
},
|
|
46
64
|
};
|
|
47
65
|
}
|
|
48
66
|
class ECSqlQueryReaderImpl {
|
|
49
67
|
_coreReader;
|
|
50
68
|
_format;
|
|
51
|
-
|
|
69
|
+
_onCancel;
|
|
70
|
+
_cancelTimer;
|
|
71
|
+
constructor(_coreReader, _format, _onCancel) {
|
|
52
72
|
this._coreReader = _coreReader;
|
|
53
73
|
this._format = _format;
|
|
74
|
+
this._onCancel = _onCancel;
|
|
54
75
|
}
|
|
55
76
|
[Symbol.asyncIterator]() {
|
|
56
77
|
return this;
|
|
@@ -58,48 +79,64 @@ class ECSqlQueryReaderImpl {
|
|
|
58
79
|
async next() {
|
|
59
80
|
const res = await this._coreReader.next();
|
|
60
81
|
if (res.done) {
|
|
82
|
+
if (this._cancelTimer) {
|
|
83
|
+
clearTimeout(this._cancelTimer);
|
|
84
|
+
this._cancelTimer = undefined;
|
|
85
|
+
}
|
|
61
86
|
return { done: true, value: undefined };
|
|
62
87
|
}
|
|
63
88
|
return { done: false, value: this._format === "array" ? res.value.toArray() : res.value.toRow() };
|
|
64
89
|
}
|
|
90
|
+
async return() {
|
|
91
|
+
if (this._coreReader.return) {
|
|
92
|
+
await this._coreReader.return();
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
this._cancelTimer = setTimeout(() => this._onCancel(), QUERY_CANCEL_DELAY_MS);
|
|
96
|
+
}
|
|
97
|
+
return { done: true, value: undefined };
|
|
98
|
+
}
|
|
65
99
|
}
|
|
66
100
|
function bind(bindings) {
|
|
67
101
|
const binder = new QueryBinder();
|
|
68
|
-
|
|
102
|
+
const entries = Array.isArray(bindings)
|
|
103
|
+
? bindings.map((b, i) => [i + 1, b])
|
|
104
|
+
: Object.entries(bindings);
|
|
105
|
+
for (const [key, b] of entries) {
|
|
69
106
|
if (b.value === undefined) {
|
|
70
|
-
binder.bindNull(
|
|
71
|
-
|
|
107
|
+
binder.bindNull(key);
|
|
108
|
+
continue;
|
|
72
109
|
}
|
|
73
110
|
switch (b.type) {
|
|
74
111
|
case "boolean":
|
|
75
|
-
binder.bindBoolean(
|
|
112
|
+
binder.bindBoolean(key, b.value);
|
|
76
113
|
break;
|
|
77
114
|
case "double":
|
|
78
|
-
binder.bindDouble(
|
|
115
|
+
binder.bindDouble(key, b.value);
|
|
79
116
|
break;
|
|
80
117
|
case "id":
|
|
81
|
-
binder.bindId(
|
|
118
|
+
binder.bindId(key, b.value);
|
|
82
119
|
break;
|
|
83
120
|
case "idset":
|
|
84
|
-
binder.bindIdSet(
|
|
121
|
+
binder.bindIdSet(key, OrderedId64Iterable.sortArray(b.value));
|
|
85
122
|
break;
|
|
86
123
|
case "int":
|
|
87
|
-
binder.bindInt(
|
|
124
|
+
binder.bindInt(key, b.value);
|
|
88
125
|
break;
|
|
89
126
|
case "long":
|
|
90
|
-
binder.bindLong(
|
|
127
|
+
binder.bindLong(key, b.value);
|
|
91
128
|
break;
|
|
92
129
|
case "point2d":
|
|
93
|
-
binder.bindPoint2d(
|
|
130
|
+
binder.bindPoint2d(key, Point2d.fromJSON(b.value));
|
|
94
131
|
break;
|
|
95
132
|
case "point3d":
|
|
96
|
-
binder.bindPoint3d(
|
|
133
|
+
binder.bindPoint3d(key, Point3d.fromJSON(b.value));
|
|
97
134
|
break;
|
|
98
135
|
case "string":
|
|
99
|
-
binder.bindString(
|
|
136
|
+
binder.bindString(key, b.value);
|
|
100
137
|
break;
|
|
101
138
|
}
|
|
102
|
-
}
|
|
139
|
+
}
|
|
103
140
|
return binder;
|
|
104
141
|
}
|
|
105
142
|
function addCTEs(ecsql, ctes) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueryExecutor.js","sourceRoot":"","sources":["../../src/core-interop/QueryExecutor.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,IAAI,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAChE,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;AAW5D,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAWzC;;;;;;;;;;;;;;;;;;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,CAAC,YAAY,CAAC,cAAc,CAAC,uBAAuB,CAAC,CAAC;oBAC1D,MAAM;YACV,CAAC;YACD,MAAM,YAAY,GA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AAQ;gBACX,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;gBAChC,MAAM;QACV,CAAC;IACH,CAAC;IACD,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 { Guid, 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 { QueryOptions, QueryRowProxy } from \"@itwin/core-common\";\nimport type {\n ECSqlBinding,\n ECSqlQueryDef,\n ECSqlQueryExecutor,\n ECSqlQueryReaderOptions,\n ECSqlQueryRow,\n} from \"@itwin/presentation-shared\";\n\nexport const QUERY_CANCEL_DELAY_MS = 100;\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): AsyncIterableIterator<QueryRowProxy>;\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 const restartToken = config?.restartToken ?? Guid.createValue();\n opts.setRestartToken(restartToken);\n const onCancel = () => {\n try {\n const cancelReader = imodel.createQueryReader(\n \"SELECT 1\",\n undefined,\n new QueryOptionsBuilder().setRestartToken(restartToken).getOptions(),\n );\n void (async () => {\n try {\n for await (const _ of cancelReader) {\n /* drain */\n }\n } catch {\n /* expected */\n }\n })();\n } catch {\n /* ignore */\n }\n };\n return new ECSqlQueryReaderImpl(\n imodel.createQueryReader(\n trimWhitespace(addCTEs(ecsql, ctes)),\n bindings ? bind(bindings) : undefined,\n opts.getOptions(),\n ),\n config?.rowFormat === \"Indexes\" ? \"array\" : \"object\",\n onCancel,\n );\n },\n };\n}\n\nclass ECSqlQueryReaderImpl implements ReturnType<ECSqlQueryExecutor[\"createQueryReader\"]> {\n private _cancelTimer: ReturnType<typeof setTimeout> | undefined;\n\n public constructor(\n private _coreReader: AsyncIterableIterator<QueryRowProxy>,\n private _format: \"array\" | \"object\",\n private _onCancel: () => void,\n ) {}\n\n public [Symbol.asyncIterator](): AsyncIterableIterator<ECSqlQueryRow> {\n return this;\n }\n\n public async next(): Promise<IteratorResult<ECSqlQueryRow>> {\n const res = await this._coreReader.next();\n if (res.done) {\n if (this._cancelTimer) {\n clearTimeout(this._cancelTimer);\n this._cancelTimer = undefined;\n }\n return { done: true, value: undefined };\n }\n return { done: false, value: this._format === \"array\" ? res.value.toArray() : res.value.toRow() };\n }\n\n public async return(): Promise<IteratorResult<ECSqlQueryRow>> {\n if (this._coreReader.return) {\n await this._coreReader.return();\n } else {\n this._cancelTimer = setTimeout(() => this._onCancel(), QUERY_CANCEL_DELAY_MS);\n }\n return { done: true, value: undefined };\n }\n}\n\nfunction bind(bindings: ECSqlBinding[] | Record<string, ECSqlBinding>): QueryBinder {\n const binder = new QueryBinder();\n const entries: Array<[string | number, ECSqlBinding]> = Array.isArray(bindings)\n ? bindings.map((b, i) => [i + 1, b])\n : Object.entries(bindings);\n for (const [key, b] of entries) {\n if (b.value === undefined) {\n binder.bindNull(key);\n continue;\n }\n switch (b.type) {\n case \"boolean\":\n binder.bindBoolean(key, b.value);\n break;\n case \"double\":\n binder.bindDouble(key, b.value);\n break;\n case \"id\":\n binder.bindId(key, b.value);\n break;\n case \"idset\":\n binder.bindIdSet(key, OrderedId64Iterable.sortArray(b.value));\n break;\n case \"int\":\n binder.bindInt(key, b.value);\n break;\n case \"long\":\n binder.bindLong(key, b.value);\n break;\n case \"point2d\":\n binder.bindPoint2d(key, Point2d.fromJSON(b.value));\n break;\n case \"point3d\":\n binder.bindPoint3d(key, Point3d.fromJSON(b.value));\n break;\n case \"string\":\n binder.bindString(key, 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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Transactions.d.ts","sourceRoot":"","sources":["../../src/core-interop/Transactions.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAExD;;;;;;;;;GASG;AACH,UAAU,eAAe;IACvB;;;;;OAKG;IACH,QAAQ,EAAE,KAAK,CAAC;IAChB;;;;;OAKG;IACH,WAAW,EAAE,KAAK,CAAC;IACnB;;;;;OAKG;IACH,gBAAgB,EAAE,KAAK,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAiB7F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Transactions.js","sourceRoot":"","sources":["../../src/core-interop/Transactions.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAsChG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAqB,EAAE,SAAqB;IAC/E,IAAI,UAAU,GAAG,KAAK,CAAC;IACvB,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,EAAE;QAClD,UAAU,GAAG,IAAI,CAAC;IACpB,CAAC,CAAC,CAAC;IACH,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,GAAG,EAAE;QACpD,IAAI,UAAU,EAAE,CAAC;YACf,SAAS,EAAE,CAAC;QACd,CAAC;QACD,UAAU,GAAG,KAAK,CAAC;IACrB,CAAC,CAAC,CAAC;IACH,MAAM,cAAc,GAAG,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IACpE,OAAO,GAAG,EAAE;QACV,YAAY,EAAE,CAAC;QACf,WAAW,EAAE,CAAC;QACd,cAAc,EAAE,CAAC;IACnB,CAAC,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 type { Event } from \"@itwin/presentation-shared\";\n\n/**\n * An interface for a transaction manager that has 3 types of events fired before and after a commit\n * and when changes are applied on a briefcase.\n *\n * Generally, this either means [TxnManager](https://www.itwinjs.org/reference/core-backend/imodels/txnmanager/), accessed\n * through [BriefcaseDb.txns](https://www.itwinjs.org/reference/core-backend/imodels/briefcasedb/#txns), or\n * [BriefcaseTxns](https://www.itwinjs.org/reference/core-frontend/imodelconnection/briefcasetxns/), accessed\n * through [BriefcaseConnection.txns](https://www.itwinjs.org/reference/core-frontend/imodelconnection/briefcaseconnection/#txns).\n * @public\n */\ninterface ICoreTxnManager {\n /**\n * Event raised before a commit operation is performed. Initiated by a call to either\n * [IModelDb.saveChanges](https://www.itwinjs.org/reference/core-backend/imodels/imodeldb/savechanges/)\n * or [BriefcaseConnection.saveChanges](https://www.itwinjs.org/reference/core-frontend/imodelconnection/briefcaseconnection/savechanges/),\n * unless there are no changes to save.\n */\n onCommit: Event;\n /**\n * Event raised after a commit operation is performed. Initiated by a call to either\n * [IModelDb.saveChanges](https://www.itwinjs.org/reference/core-backend/imodels/imodeldb/savechanges/)\n * or [BriefcaseConnection.saveChanges](https://www.itwinjs.org/reference/core-frontend/imodelconnection/briefcaseconnection/savechanges/),\n * even if there were no changes to save.\n */\n onCommitted: Event;\n /**\n * Event raised after a changeset has been applied to the briefcase. Changesets may be applied as a result of\n * [BriefcaseDb.pullChanges](https://www.itwinjs.org/reference/core-backend/imodels/briefcasedb/) or\n * [BriefcaseConnection.pullChanges](https://www.itwinjs.org/reference/core-frontend/imodelconnection/briefcaseconnection/pullchanges/),\n * or by undo/redo operations.\n */\n onChangesApplied: Event;\n}\n\n/**\n * Registers listeners to `txns` events and calls provided `onChanged` callback when transaction manager\n * reports there are iModel data changes.\n *\n * Usage example:\n *\n * ```ts\n * import { BriefcaseDb } from \"@itwin/core-backend\";\n * import { registerTxnListeners } from \"@itwin/presentation-core-interop\";\n * import { HierarchyProvider } from \"@itwin/presentation-hierarchies\";\n *\n * // get iModel and hierarchy provider from arbitrary sources\n * const db: BriefcaseDb = getIModel();\n * const provider: HierarchyProvider = getHierarchyProvider();\n *\n * // register the listeners\n * const unregister = registerTxnListeners(db.txns, () => {\n * // notify provided about the changed data\n * provider.notifyDataSourceChanged();\n * // TODO: force the components using `provider` to reload\n * });\n *\n * // clean up on iModel close\n * db.onClosed.addOnce(() => unregister());\n * ```\n *\n * @param txns Either [TxnManager](https://www.itwinjs.org/reference/core-backend/imodels/txnmanager/), accessed\n * through [BriefcaseDb.txns](https://www.itwinjs.org/reference/core-backend/imodels/briefcasedb/#txns),\n * or [BriefcaseTxns](https://www.itwinjs.org/reference/core-frontend/imodelconnection/briefcasetxns/), accessed\n * through [BriefcaseConnection.txns](https://www.itwinjs.org/reference/core-frontend/imodelconnection/briefcaseconnection/#txns).\n * @param onChanged A function to call when transaction manager reports iModel data changes.\n * @returns A function that unregisters the transaction manager listeners.\n * @public\n */\nexport function registerTxnListeners(txns: ICoreTxnManager, onChanged: () => void): () => void {\n let hasChanges = false;\n const beforeCommit = txns.onCommit.addListener(() => {\n hasChanges = true;\n });\n const afterCommit = txns.onCommitted.addListener(() => {\n if (hasChanges) {\n onChanged();\n }\n hasChanges = false;\n });\n const appliedChanges = txns.onChangesApplied.addListener(onChanged);\n return () => {\n beforeCommit();\n afterCommit();\n appliedChanges();\n };\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation-core-interop.d.ts","sourceRoot":"","sources":["../src/presentation-core-interop.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation-core-interop.js","sourceRoot":"","sources":["../src/presentation-core-interop.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,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\nexport { createValueFormatter } from \"./core-interop/Formatting.js\";\nexport { createIModelKey } from \"./core-interop/IModelKey.js\";\nexport { createLogger } from \"./core-interop/Logging.js\";\nexport { createECSchemaProvider } from \"./core-interop/Metadata.js\";\nexport { createECSqlQueryExecutor } from \"./core-interop/QueryExecutor.js\";\nexport { registerTxnListeners } from \"./core-interop/Transactions.js\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/presentation-core-interop",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.3",
|
|
4
4
|
"description": "The package acts as a layer between iTwin.js Core and Presentation packages.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -19,19 +19,17 @@
|
|
|
19
19
|
"Presentation"
|
|
20
20
|
],
|
|
21
21
|
"type": "module",
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"module": "lib/esm/presentation-core-interop.js",
|
|
22
|
+
"types": "lib/presentation-core-interop",
|
|
23
|
+
"module": "lib/presentation-core-interop.js",
|
|
25
24
|
"exports": {
|
|
26
25
|
".": {
|
|
27
|
-
"import": "./lib/
|
|
28
|
-
"require": "./lib/cjs/presentation-core-interop.js"
|
|
26
|
+
"import": "./lib/presentation-core-interop.js"
|
|
29
27
|
},
|
|
30
28
|
"./package.json": "./package.json"
|
|
31
29
|
},
|
|
32
30
|
"dependencies": {
|
|
33
31
|
"rxjs": "^7.8.2",
|
|
34
|
-
"@itwin/presentation-shared": "2.0.0-alpha.
|
|
32
|
+
"@itwin/presentation-shared": "2.0.0-alpha.12"
|
|
35
33
|
},
|
|
36
34
|
"peerDependencies": {
|
|
37
35
|
"@itwin/core-bentley": "^5.0.0",
|
|
@@ -41,32 +39,32 @@
|
|
|
41
39
|
"@itwin/ecschema-metadata": "^5.0.0"
|
|
42
40
|
},
|
|
43
41
|
"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.
|
|
50
|
-
"@itwin/eslint-plugin": "
|
|
51
|
-
"@vitest/coverage-v8": "^4.1.
|
|
42
|
+
"@itwin/build-tools": "^5.11.3",
|
|
43
|
+
"@itwin/core-bentley": "^5.11.3",
|
|
44
|
+
"@itwin/core-common": "^5.11.3",
|
|
45
|
+
"@itwin/core-geometry": "^5.11.3",
|
|
46
|
+
"@itwin/core-quantity": "^5.11.3",
|
|
47
|
+
"@itwin/ecschema-metadata": "^5.11.3",
|
|
48
|
+
"@itwin/eslint-plugin": "^6.1.0",
|
|
49
|
+
"@vitest/coverage-v8": "^4.1.10",
|
|
52
50
|
"cpx2": "^7.0.2",
|
|
53
|
-
"eslint": "^9.39.
|
|
51
|
+
"eslint": "^9.39.5",
|
|
54
52
|
"rimraf": "^6.1.3",
|
|
55
53
|
"rxjs-for-await": "^1.0.0",
|
|
56
|
-
"typescript": "
|
|
57
|
-
"
|
|
54
|
+
"@typescript/native": "npm:typescript@~7.0.2",
|
|
55
|
+
"typescript": "npm:@typescript/typescript6@~6.0.2",
|
|
56
|
+
"vitest": "^4.1.10"
|
|
58
57
|
},
|
|
59
58
|
"scripts": {
|
|
60
|
-
"build": "npm run -s typecheck && npm run -s build:
|
|
61
|
-
"build:
|
|
62
|
-
"build:esm": "tsc -p tsconfig.esm.json",
|
|
59
|
+
"build": "npm run -s typecheck && npm run -s build:lib",
|
|
60
|
+
"build:lib": "tsc -p tsconfig.lib.json",
|
|
63
61
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
64
62
|
"clean": "rimraf lib",
|
|
65
63
|
"cover": "vitest run --coverage",
|
|
66
64
|
"lint": "eslint \"./src/**/*.ts\"",
|
|
67
65
|
"test": "vitest run",
|
|
68
66
|
"test:watch": "vitest",
|
|
69
|
-
"extract-api": "betools extract-api --entry=presentation-core-interop --apiReportFolder=./api --apiReportTempFolder=./api/temp --apiSummaryFolder=./api --includeUnexportedApis",
|
|
67
|
+
"extract-api": "betools extract-api --entry=lib/presentation-core-interop --apiReportFolder=./api --apiReportTempFolder=./api/temp --apiSummaryFolder=./api --includeUnexportedApis",
|
|
70
68
|
"check-internal": "node ../../scripts/checkInternal.js --apiSummary ./api/presentation-core-interop.api.md",
|
|
71
69
|
"update-extractions": "node ../../scripts/updateExtractions.js --targets=./README.md",
|
|
72
70
|
"check-extractions": "node ../../scripts/updateExtractions.js --targets=./README.md --check",
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|