@itwin/presentation-core-interop 0.2.7 → 1.1.0

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.
Files changed (42) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/lib/cjs/core-interop/Formatting.d.ts +2 -2
  3. package/lib/cjs/core-interop/Formatting.js +4 -4
  4. package/lib/cjs/core-interop/Formatting.js.map +1 -1
  5. package/lib/cjs/core-interop/Logging.d.ts +2 -2
  6. package/lib/cjs/core-interop/Logging.js +1 -1
  7. package/lib/cjs/core-interop/Logging.js.map +1 -1
  8. package/lib/cjs/core-interop/Metadata.d.ts +2 -2
  9. package/lib/cjs/core-interop/Metadata.d.ts.map +1 -1
  10. package/lib/cjs/core-interop/Metadata.js +3 -4
  11. package/lib/cjs/core-interop/Metadata.js.map +1 -1
  12. package/lib/cjs/core-interop/QueryExecutor.d.ts +2 -2
  13. package/lib/cjs/core-interop/QueryExecutor.js +1 -1
  14. package/lib/cjs/core-interop/QueryExecutor.js.map +1 -1
  15. package/lib/cjs/core-interop/Transactions.d.ts +2 -2
  16. package/lib/cjs/core-interop/Transactions.js +1 -1
  17. package/lib/cjs/core-interop/Transactions.js.map +1 -1
  18. package/lib/cjs/presentation-core-interop.d.ts +5 -5
  19. package/lib/cjs/presentation-core-interop.d.ts.map +1 -1
  20. package/lib/cjs/presentation-core-interop.js +10 -10
  21. package/lib/cjs/presentation-core-interop.js.map +1 -1
  22. package/lib/esm/core-interop/Formatting.d.ts +2 -2
  23. package/lib/esm/core-interop/Formatting.js +4 -4
  24. package/lib/esm/core-interop/Formatting.js.map +1 -1
  25. package/lib/esm/core-interop/Logging.d.ts +2 -2
  26. package/lib/esm/core-interop/Logging.js +1 -1
  27. package/lib/esm/core-interop/Logging.js.map +1 -1
  28. package/lib/esm/core-interop/Metadata.d.ts +2 -2
  29. package/lib/esm/core-interop/Metadata.d.ts.map +1 -1
  30. package/lib/esm/core-interop/Metadata.js +2 -3
  31. package/lib/esm/core-interop/Metadata.js.map +1 -1
  32. package/lib/esm/core-interop/QueryExecutor.d.ts +2 -2
  33. package/lib/esm/core-interop/QueryExecutor.js +1 -1
  34. package/lib/esm/core-interop/QueryExecutor.js.map +1 -1
  35. package/lib/esm/core-interop/Transactions.d.ts +2 -2
  36. package/lib/esm/core-interop/Transactions.js +1 -1
  37. package/lib/esm/core-interop/Transactions.js.map +1 -1
  38. package/lib/esm/presentation-core-interop.d.ts +5 -5
  39. package/lib/esm/presentation-core-interop.d.ts.map +1 -1
  40. package/lib/esm/presentation-core-interop.js +5 -5
  41. package/lib/esm/presentation-core-interop.js.map +1 -1
  42. package/package.json +23 -14
package/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # @itwin/presentation-core-interop
2
2
 
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#740](https://github.com/iTwin/presentation/pull/740): Define `type` and `exports` attributes in `package.json`.
8
+
9
+ The change moves this package a step closer towards dropping CommonJS support - it's now transpiled from ESM to CommonJS instead of the opposite.
10
+
11
+ In addition, the `exports` attribute has been added to `package.json` to prohibit access to APIs that are not intended to be used by external consumers.
12
+
13
+ ### Patch Changes
14
+
15
+ - [#758](https://github.com/iTwin/presentation/pull/758): Promote `@beta` APIs to `@public`.
16
+ - Updated dependencies:
17
+ - @itwin/presentation-shared@1.1.0
18
+
19
+ ## 1.0.0
20
+
21
+ ### Major Changes
22
+
23
+ - [#727](https://github.com/iTwin/presentation/pull/727): 1.0 release.
24
+
25
+ The APIs are now considered stable and ready for production use.
26
+
27
+ ### Patch Changes
28
+
29
+ - Updated dependencies:
30
+ - @itwin/presentation-shared@1.0.0
31
+
3
32
  ## 0.2.7
4
33
 
5
34
  ### Patch Changes
@@ -3,7 +3,7 @@ import { SchemaContext } from "@itwin/ecschema-metadata";
3
3
  import { IPrimitiveValueFormatter } from "@itwin/presentation-shared";
4
4
  /**
5
5
  * Props for `createValueFormatter` function.
6
- * @beta
6
+ * @public
7
7
  */
8
8
  interface CreateValueFormatterProps {
9
9
  /**
@@ -38,7 +38,7 @@ interface CreateValueFormatterProps {
38
38
  * const formattedValue = await formatter({ type: "Double", value: 1.234, koqName: "MySchema.LengthKindOfQuantity" });
39
39
  * ```
40
40
  *
41
- * @beta
41
+ * @public
42
42
  */
43
43
  export declare function createValueFormatter(props: CreateValueFormatterProps): IPrimitiveValueFormatter;
44
44
  export {};
@@ -23,11 +23,11 @@ const presentation_shared_1 = require("@itwin/presentation-shared");
23
23
  * const formattedValue = await formatter({ type: "Double", value: 1.234, koqName: "MySchema.LengthKindOfQuantity" });
24
24
  * ```
25
25
  *
26
- * @beta
26
+ * @public
27
27
  */
28
28
  function createValueFormatter(props) {
29
29
  const { schemaContext, unitSystem } = props;
30
- const baseFormatter = props.baseFormatter ?? /* istanbul ignore next */ (0, presentation_shared_1.createDefaultValueFormatter)();
30
+ const baseFormatter = props.baseFormatter ?? /* c8 ignore next */ (0, presentation_shared_1.createDefaultValueFormatter)();
31
31
  const unitsProvider = new ecschema_metadata_1.SchemaUnitProvider(schemaContext);
32
32
  return async function (value) {
33
33
  if (value.type === "Double" && !!value.koqName) {
@@ -64,7 +64,7 @@ async function getFormatterSpec(unitsProvider, koq, unitSystem) {
64
64
  }
65
65
  async function getFormattingProps(koq, unitSystem) {
66
66
  const persistenceUnit = await koq.persistenceUnit;
67
- // istanbul ignore if
67
+ /* c8 ignore next 3 */
68
68
  if (!persistenceUnit) {
69
69
  return undefined;
70
70
  }
@@ -97,7 +97,7 @@ async function getKoqPresentationFormat(koq, unitSystems) {
97
97
  for (const system of unitSystems) {
98
98
  for (const format of presentationFormats) {
99
99
  const unit = format.units && format.units[0][0];
100
- // istanbul ignore if
100
+ /* c8 ignore next 3 */
101
101
  if (!unit) {
102
102
  continue;
103
103
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Formatting.js","sourceRoot":"","sources":["../../../src/core-interop/Formatting.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AA0DhG,oDAc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gBACzE,OAAO,MAAM,CAAC;YAChB,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,cAAc,CAAC,MAA+B;IACrD,OAAO,MAAM,YAAY,kCAAc,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;AACtF,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 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 * @beta\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 * @beta\n */\nexport function createValueFormatter(props: CreateValueFormatterProps): IPrimitiveValueFormatter {\n const { schemaContext, unitSystem } = props;\n const baseFormatter = props.baseFormatter ?? /* istanbul 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 const koq = await schema.getItem<KindOfQuantity>(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;\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 // istanbul ignore if\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 unit = format.units && format.units[0][0];\n // istanbul ignore if\n if (!unit) {\n continue;\n }\n const currentUnitSystem = await unit.unitSystem;\n if (currentUnitSystem && currentUnitSystem.name.toUpperCase() === system) {\n return format;\n }\n }\n }\n return undefined;\n}\n\nfunction getFormatProps(format: Format | OverrideFormat): FormatProps {\n return format instanceof OverrideFormat ? format.getFormatProps() : format.toJSON();\n}\n\nfunction getPersistenceUnitFormatProps(persistenceUnit: Unit | InvertedUnit): FormatProps {\n // Same as Format \"DefaultRealU\" in Formats ecschema\n return {\n formatTraits: [\"keepSingleZero\", \"keepDecimalPoint\", \"showUnitLabel\"],\n precision: 6,\n type: \"Decimal\",\n uomSeparator: \" \",\n decimalSeparator: \".\",\n composite: {\n units: [\n {\n name: persistenceUnit.fullName,\n label: persistenceUnit.label,\n },\n ],\n },\n };\n}\n\nfunction getUnitSystemGroupNames(unitSystem?: UnitSystemKey) {\n switch (unitSystem) {\n case \"imperial\":\n return [\"IMPERIAL\", \"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"];\n case \"metric\":\n return [\"SI\", \"METRIC\", \"INTERNATIONAL\", \"FINANCE\"];\n case \"usCustomary\":\n return [\"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"];\n case \"usSurvey\":\n return [\"USSURVEY\", \"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"];\n }\n return [];\n}\n"]}
1
+ {"version":3,"file":"Formatting.js","sourceRoot":"","sources":["../../../src/core-interop/Formatting.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AA0DhG,oDAcC;AAtED,wDAA0H;AAC1H,gEAUkC;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,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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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 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 const koq = await schema.getItem<KindOfQuantity>(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;\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 unit = format.units && format.units[0][0];\n /* c8 ignore next 3 */\n if (!unit) {\n continue;\n }\n const currentUnitSystem = await unit.unitSystem;\n if (currentUnitSystem && currentUnitSystem.name.toUpperCase() === system) {\n return format;\n }\n }\n }\n return undefined;\n}\n\nfunction getFormatProps(format: Format | OverrideFormat): FormatProps {\n return format instanceof OverrideFormat ? format.getFormatProps() : 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"]}
@@ -3,7 +3,7 @@ import { 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.
6
- * @beta
6
+ * @public
7
7
  */
8
8
  interface ICoreLogger {
9
9
  isEnabled(category: string, level: CoreLogLevel): boolean;
@@ -26,7 +26,7 @@ interface ICoreLogger {
26
26
  * setLogger(createLogger(Logger));
27
27
  * ```
28
28
  *
29
- * @beta
29
+ * @public
30
30
  */
31
31
  export declare function createLogger(coreLogger: ICoreLogger): ILogger;
32
32
  export {};
@@ -20,7 +20,7 @@ const core_bentley_1 = require("@itwin/core-bentley");
20
20
  * setLogger(createLogger(Logger));
21
21
  * ```
22
22
  *
23
- * @beta
23
+ * @public
24
24
  */
25
25
  function createLogger(coreLogger) {
26
26
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"Logging.js","sourceRoot":"","sources":["../../../src/core-interop/Logging.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AAkChG,oCAQC;AAxCD,sDAA+D;AAgB/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\";\nimport { 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 * @beta\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 * @beta\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
+ {"version":3,"file":"Logging.js","sourceRoot":"","sources":["../../../src/core-interop/Logging.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AAkChG,oCAQC;AAxCD,sDAA+D;AAgB/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\";\nimport { 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"]}
@@ -3,7 +3,7 @@ import { ECSchemaProvider } from "@itwin/presentation-shared";
3
3
  /**
4
4
  * Defines input for `createECSchemaProvider`. Generally, this is an instance of [SchemaContext](https://www.itwinjs.org/reference/ecschema-metadata/context/schemacontext/)
5
5
  * class from `@itwin/ecschema-metadata` package.
6
- * @beta
6
+ * @public
7
7
  */
8
8
  interface CoreSchemaContext {
9
9
  getSchema(key: CoreSchemaKey): Promise<CoreSchema | undefined>;
@@ -22,7 +22,7 @@ interface CoreSchemaContext {
22
22
  * // the created schema provider may be used in `@itwin/presentation-hierarchies` and other Presentation packages
23
23
  * ```
24
24
  *
25
- * @beta
25
+ * @public
26
26
  */
27
27
  export declare function createECSchemaProvider(schemaContext: CoreSchemaContext): ECSchemaProvider;
28
28
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"Metadata.d.ts","sourceRoot":"","sources":["../../../src/core-interop/Metadata.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC5F,OAAO,EAAM,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAGlE;;;;GAIG;AACH,UAAU,iBAAiB;IACzB,SAAS,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;CAChE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CAAC,aAAa,EAAE,iBAAiB,GAAG,gBAAgB,CAkCzF"}
1
+ {"version":3,"file":"Metadata.d.ts","sourceRoot":"","sources":["../../../src/core-interop/Metadata.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC5F,OAAO,EAAM,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAGlE;;;;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"}
@@ -6,7 +6,7 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.createECSchemaProvider = createECSchemaProvider;
8
8
  const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
9
- const MetadataInternal_1 = require("./MetadataInternal");
9
+ const MetadataInternal_js_1 = require("./MetadataInternal.js");
10
10
  /**
11
11
  * Creates an `ECSchemaProvider` for given [SchemaContext](https://www.itwinjs.org/reference/ecschema-metadata/context/schemacontext/).
12
12
  *
@@ -21,13 +21,13 @@ const MetadataInternal_1 = require("./MetadataInternal");
21
21
  * // the created schema provider may be used in `@itwin/presentation-hierarchies` and other Presentation packages
22
22
  * ```
23
23
  *
24
- * @beta
24
+ * @public
25
25
  */
26
26
  function createECSchemaProvider(schemaContext) {
27
27
  const schemaRequestsCache = new Map();
28
28
  async function getSchemaUnprotected(schemaName) {
29
29
  const coreSchema = await schemaContext.getSchema(new ecschema_metadata_1.SchemaKey(schemaName));
30
- return coreSchema ? (0, MetadataInternal_1.createECSchema)(coreSchema) : undefined;
30
+ return coreSchema ? (0, MetadataInternal_js_1.createECSchema)(coreSchema) : undefined;
31
31
  }
32
32
  async function getSchemaProtected(schemaName, handledExistingSchemaErrors) {
33
33
  // workaround for https://github.com/iTwin/itwinjs-core/issues/6542
@@ -35,7 +35,6 @@ function createECSchemaProvider(schemaContext) {
35
35
  return await getSchemaUnprotected(schemaName);
36
36
  }
37
37
  catch (e) {
38
- // istanbul ignore else
39
38
  if (e instanceof Error) {
40
39
  if (e.message.includes("already exists within this cache") && !handledExistingSchemaErrors.has(schemaName)) {
41
40
  handledExistingSchemaErrors.add(schemaName);
@@ -1 +1 @@
1
- {"version":3,"file":"Metadata.js","sourceRoot":"","sources":["../../../src/core-interop/Metadata.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AA+BhG,wDAkCC;AA/DD,gEAA4F;AAE5F,yDAAoD;AAWpD;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,sBAAsB,CAAC,aAAgC;IACrE,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAA0C,CAAC;IAC9E,KAAK,UAAU,oBAAoB,CAAC,UAAkB;QACpD,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC,SAAS,CAAC,IAAI,6BAAa,CAAC,UAAU,CAAC,CAAC,CAAC;QAChF,OAAO,UAAU,CAAC,CAAC,CAAC,IAAA,iCAAc,EAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC7D,CAAC;IACD,KAAK,UAAU,kBAAkB,CAAC,UAAkB,EAAE,2BAAwC;QAC5F,mEAAmE;QACnE,IAAI,CAAC;YACH,OAAO,MAAM,oBAAoB,CAAC,UAAU,CAAC,CAAC;QAChD,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,uBAAuB;YACvB,IAAI,CAAC,YAAY,KAAK,EAAE,CAAC;gBACvB,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,kCAAkC,CAAC,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;oBAC3G,2BAA2B,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;oBAC5C,OAAO,kBAAkB,CAAC,UAAU,EAAE,2BAA2B,CAAC,CAAC;gBACrE,CAAC;gBACD,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;oBAC3C,OAAO,SAAS,CAAC;gBACnB,CAAC;YACH,CAAC;YACD,MAAM,CAAC,CAAC;QACV,CAAC;IACH,CAAC;IACD,OAAO;QACL,KAAK,CAAC,SAAS,CAAC,IAAI;YAClB,IAAI,OAAO,GAAG,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC5C,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,OAAO,GAAG,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;gBAC9C,mBAAmB,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACzC,CAAC;YACD,OAAO,OAAO,CAAC;QACjB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { Schema as CoreSchema, SchemaKey as CoreSchemaKey } from \"@itwin/ecschema-metadata\";\nimport { EC, ECSchemaProvider } from \"@itwin/presentation-shared\";\nimport { createECSchema } from \"./MetadataInternal\";\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 * @beta\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 { SchemaContext } from \"@itwin/ecschema-metadata\";\n * import { createECSchemaProvider } from \"@itwin/presentation-core-interop\";\n *\n * const schemaContext = new SchemaContext();\n * const schemaProvider = createECSchemaProvider(schemas);\n * // the created schema provider may be used in `@itwin/presentation-hierarchies` and other Presentation packages\n * ```\n *\n * @beta\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 // istanbul ignore else\n if (e instanceof Error) {\n if (e.message.includes(\"already exists within this cache\") && !handledExistingSchemaErrors.has(schemaName)) {\n handledExistingSchemaErrors.add(schemaName);\n return getSchemaProtected(schemaName, handledExistingSchemaErrors);\n }\n if (e.message.includes(\"schema not found\")) {\n return undefined;\n }\n }\n throw e;\n }\n }\n return {\n async getSchema(name) {\n let promise = schemaRequestsCache.get(name);\n if (!promise) {\n promise = getSchemaProtected(name, new Set());\n schemaRequestsCache.set(name, promise);\n }\n return promise;\n },\n };\n}\n"]}
1
+ {"version":3,"file":"Metadata.js","sourceRoot":"","sources":["../../../src/core-interop/Metadata.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AA+BhG,wDAiCC;AA9DD,gEAA4F;AAE5F,+DAAuD;AAWvD;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,sBAAsB,CAAC,aAAgC;IACrE,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAA0C,CAAC;IAC9E,KAAK,UAAU,oBAAoB,CAAC,UAAkB;QACpD,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC,SAAS,CAAC,IAAI,6BAAa,CAAC,UAAU,CAAC,CAAC,CAAC;QAChF,OAAO,UAAU,CAAC,CAAC,CAAC,IAAA,oCAAc,EAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC7D,CAAC;IACD,KAAK,UAAU,kBAAkB,CAAC,UAAkB,EAAE,2BAAwC;QAC5F,mEAAmE;QACnE,IAAI,CAAC;YACH,OAAO,MAAM,oBAAoB,CAAC,UAAU,CAAC,CAAC;QAChD,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,CAAC,YAAY,KAAK,EAAE,CAAC;gBACvB,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,kCAAkC,CAAC,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;oBAC3G,2BAA2B,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;oBAC5C,OAAO,kBAAkB,CAAC,UAAU,EAAE,2BAA2B,CAAC,CAAC;gBACrE,CAAC;gBACD,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;oBAC3C,OAAO,SAAS,CAAC;gBACnB,CAAC;YACH,CAAC;YACD,MAAM,CAAC,CAAC;QACV,CAAC;IACH,CAAC;IACD,OAAO;QACL,KAAK,CAAC,SAAS,CAAC,IAAI;YAClB,IAAI,OAAO,GAAG,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC5C,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,OAAO,GAAG,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;gBAC9C,mBAAmB,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACzC,CAAC;YACD,OAAO,OAAO,CAAC;QACjB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { Schema as CoreSchema, SchemaKey as CoreSchemaKey } from \"@itwin/ecschema-metadata\";\nimport { EC, ECSchemaProvider } from \"@itwin/presentation-shared\";\nimport { createECSchema } from \"./MetadataInternal.js\";\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 { SchemaContext } from \"@itwin/ecschema-metadata\";\n * import { createECSchemaProvider } from \"@itwin/presentation-core-interop\";\n *\n * const schemaContext = new SchemaContext();\n * const schemaProvider = createECSchemaProvider(schemas);\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"]}
@@ -3,7 +3,7 @@ import { ECSqlQueryExecutor } from "@itwin/presentation-shared";
3
3
  /**
4
4
  * Defines input for `createECSqlQueryExecutor`. Generally, this is an instance of either [IModelDb](https://www.itwinjs.org/reference/core-backend/imodels/imodeldb/)
5
5
  * or [IModelConnection](https://www.itwinjs.org/reference/core-frontend/imodelconnection/imodelconnection/).
6
- * @beta
6
+ * @public
7
7
  */
8
8
  interface CoreECSqlReaderFactory {
9
9
  createQueryReader(ecsql: string, binder?: QueryBinder, options?: QueryOptions): ECSqlReader;
@@ -25,7 +25,7 @@ interface CoreECSqlReaderFactory {
25
25
  * }
26
26
  * ```
27
27
  *
28
- * @beta
28
+ * @public
29
29
  */
30
30
  export declare function createECSqlQueryExecutor(imodel: CoreECSqlReaderFactory): ECSqlQueryExecutor;
31
31
  export {};
@@ -26,7 +26,7 @@ const presentation_shared_1 = require("@itwin/presentation-shared");
26
26
  * }
27
27
  * ```
28
28
  *
29
- * @beta
29
+ * @public
30
30
  */
31
31
  function createECSqlQueryExecutor(imodel) {
32
32
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"QueryExecutor.js","sourceRoot":"","sources":["../../../src/core-interop/QueryExecutor.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AAmChG,4DAsBC;AAvDD,sDAA0D;AAC1D,oDAAiH;AACjH,wDAAwD;AACxD,oEAAqJ;AAWrJ;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,wBAAwB,CAAC,MAA8B;IACrE,OAAO;QACL,iBAAiB,CAAC,KAAoB,EAAE,MAAgC;YACtE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;YACxC,MAAM,IAAI,GAAG,IAAI,iCAAmB,EAAE,CAAC;YACvC,QAAQ,MAAM,EAAE,SAAS,EAAE,CAAC;gBAC1B,KAAK,oBAAoB;oBACvB,IAAI,CAAC,YAAY,CAAC,4BAAc,CAAC,qBAAqB,C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,WAAW,CAAC,CAAC,GAAG,CAAC,EAAE,uBAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;gBACrD,MAAM;YACR,KAAK,QAAQ;gBACX,MAAM,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;gBAClC,MAAM;QACV,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,OAAO,CAAC,KAAa,EAAE,IAA0B;IACxD,MAAM,UAAU,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,kBAAkB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5E,OAAO,GAAG,UAAU,GAAG,KAAK,EAAE,CAAC;AACjC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { OrderedId64Iterable } from \"@itwin/core-bentley\";\nimport { ECSqlReader, QueryBinder, QueryOptions, QueryOptionsBuilder, QueryRowFormat } from \"@itwin/core-common\";\nimport { Point2d, Point3d } from \"@itwin/core-geometry\";\nimport { ECSqlBinding, ECSqlQueryDef, ECSqlQueryExecutor, ECSqlQueryReaderOptions, ECSqlQueryRow, trimWhitespace } from \"@itwin/presentation-shared\";\n\n/**\n * Defines input for `createECSqlQueryExecutor`. Generally, this is an instance of either [IModelDb](https://www.itwinjs.org/reference/core-backend/imodels/imodeldb/)\n * or [IModelConnection](https://www.itwinjs.org/reference/core-frontend/imodelconnection/imodelconnection/).\n * @beta\n */\ninterface CoreECSqlReaderFactory {\n createQueryReader(ecsql: string, binder?: QueryBinder, options?: QueryOptions): ECSqlReader;\n}\n\n/**\n * Creates an `ECSqlQueryExecutor` from either [IModelDb](https://www.itwinjs.org/reference/core-backend/imodels/imodeldb/) or\n * [IModelConnection](https://www.itwinjs.org/reference/core-frontend/imodelconnection/imodelconnection/).\n *\n * Usage example:\n *\n * ```ts\n * import { IModelDb } from \"@itwin/core-backend\";\n * import { createECSqlQueryExecutor } from \"@itwin/presentation-core-interop\";\n *\n * const imodel: IModelDb = getIModelDb();\n * const executor = createECSqlQueryExecutor(imodel);\n * for await (const row of executor.createQueryReader(MY_QUERY)) {\n * // TODO: do something with `row`\n * }\n * ```\n *\n * @beta\n */\nexport function createECSqlQueryExecutor(imodel: CoreECSqlReaderFactory): ECSqlQueryExecutor {\n return {\n createQueryReader(query: ECSqlQueryDef, config?: ECSqlQueryReaderOptions) {\n const { ctes, ecsql, bindings } = query;\n const opts = new QueryOptionsBuilder();\n switch (config?.rowFormat) {\n case \"ECSqlPropertyNames\":\n opts.setRowFormat(QueryRowFormat.UseECSqlPropertyNames);\n break;\n case \"Indexes\":\n opts.setRowFormat(QueryRowFormat.UseECSqlPropertyIndexes);\n break;\n }\n if (config?.restartToken) {\n opts.setRestartToken(config?.restartToken);\n }\n return new ECSqlQueryReaderImpl(\n imodel.createQueryReader(trimWhitespace(addCTEs(ecsql, ctes)), bind(bindings ?? []), opts.getOptions()),\n config?.rowFormat === \"Indexes\" ? \"array\" : \"object\",\n );\n },\n };\n}\n\nclass ECSqlQueryReaderImpl implements ReturnType<ECSqlQueryExecutor[\"createQueryReader\"]> {\n public constructor(\n private _coreReader: ECSqlReader,\n private _format: \"array\" | \"object\",\n ) {}\n public [Symbol.asyncIterator](): AsyncIterableIterator<ECSqlQueryRow> {\n return this;\n }\n public async next(): Promise<IteratorResult<ECSqlQueryRow>> {\n const res = await this._coreReader.next();\n if (res.done) {\n return { done: true, value: undefined };\n }\n return {\n done: false,\n value: this._format === \"array\" ? res.value.toArray() : res.value.toRow(),\n };\n }\n}\n\nfunction bind(bindings: ECSqlBinding[]): QueryBinder {\n const binder = new QueryBinder();\n bindings.forEach((b, i) => {\n if (b.value === undefined) {\n binder.bindNull(i + 1);\n return;\n }\n switch (b.type) {\n case \"boolean\":\n binder.bindBoolean(i + 1, b.value);\n break;\n case \"double\":\n binder.bindDouble(i + 1, b.value);\n break;\n case \"id\":\n binder.bindId(i + 1, b.value);\n break;\n case \"idset\":\n binder.bindIdSet(i + 1, OrderedId64Iterable.sortArray(b.value));\n break;\n case \"int\":\n binder.bindInt(i + 1, b.value);\n break;\n case \"long\":\n binder.bindLong(i + 1, b.value);\n break;\n case \"point2d\":\n binder.bindPoint2d(i + 1, Point2d.fromJSON(b.value));\n break;\n case \"point3d\":\n binder.bindPoint3d(i + 1, Point3d.fromJSON(b.value));\n break;\n case \"string\":\n binder.bindString(i + 1, b.value);\n break;\n }\n });\n return binder;\n}\n\nfunction addCTEs(ecsql: string, ctes: string[] | undefined) {\n const ctesPrefix = ctes?.length ? `WITH RECURSIVE ${ctes.join(\", \")} ` : \"\";\n return `${ctesPrefix}${ecsql}`;\n}\n"]}
1
+ {"version":3,"file":"QueryExecutor.js","sourceRoot":"","sources":["../../../src/core-interop/QueryExecutor.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AAmChG,4DAsBC;AAvDD,sDAA0D;AAC1D,oDAAiH;AACjH,wDAAwD;AACxD,oEAAqJ;AAWrJ;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,wBAAwB,CAAC,MAA8B;IACrE,OAAO;QACL,iBAAiB,CAAC,KAAoB,EAAE,MAAgC;YACtE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;YACxC,MAAM,IAAI,GAAG,IAAI,iCAAmB,EAAE,CAAC;YACvC,QAAQ,MAAM,EAAE,SAAS,EAAE,CAAC;gBAC1B,KAAK,oBAAoB;oBACvB,IAAI,CAAC,YAAY,CAAC,4BAAc,CAAC,qBAAqB,CAAC,CAAC;oBACxD,MAAM;gBACR,KAAK,SAAS;oBACZ,IAAI,CAAC,YAAY,CAAC,4BAAc,CAAC,uBAAuB,CAAC,CA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rD,MAAM;YACR,KAAK,QAAQ;gBACX,MAAM,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;gBAClC,MAAM;QACV,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,OAAO,CAAC,KAAa,EAAE,IAA0B;IACxD,MAAM,UAAU,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,kBAAkB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5E,OAAO,GAAG,UAAU,GAAG,KAAK,EAAE,CAAC;AACjC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { OrderedId64Iterable } from \"@itwin/core-bentley\";\nimport { ECSqlReader, QueryBinder, QueryOptions, QueryOptionsBuilder, QueryRowFormat } from \"@itwin/core-common\";\nimport { Point2d, Point3d } from \"@itwin/core-geometry\";\nimport { ECSqlBinding, ECSqlQueryDef, ECSqlQueryExecutor, ECSqlQueryReaderOptions, ECSqlQueryRow, trimWhitespace } from \"@itwin/presentation-shared\";\n\n/**\n * Defines input for `createECSqlQueryExecutor`. Generally, this is an instance of either [IModelDb](https://www.itwinjs.org/reference/core-backend/imodels/imodeldb/)\n * or [IModelConnection](https://www.itwinjs.org/reference/core-frontend/imodelconnection/imodelconnection/).\n * @public\n */\ninterface CoreECSqlReaderFactory {\n createQueryReader(ecsql: string, binder?: QueryBinder, options?: QueryOptions): ECSqlReader;\n}\n\n/**\n * Creates an `ECSqlQueryExecutor` from either [IModelDb](https://www.itwinjs.org/reference/core-backend/imodels/imodeldb/) or\n * [IModelConnection](https://www.itwinjs.org/reference/core-frontend/imodelconnection/imodelconnection/).\n *\n * Usage example:\n *\n * ```ts\n * import { IModelDb } from \"@itwin/core-backend\";\n * import { createECSqlQueryExecutor } from \"@itwin/presentation-core-interop\";\n *\n * const imodel: IModelDb = getIModelDb();\n * const executor = createECSqlQueryExecutor(imodel);\n * for await (const row of executor.createQueryReader(MY_QUERY)) {\n * // TODO: do something with `row`\n * }\n * ```\n *\n * @public\n */\nexport function createECSqlQueryExecutor(imodel: CoreECSqlReaderFactory): ECSqlQueryExecutor {\n return {\n createQueryReader(query: ECSqlQueryDef, config?: ECSqlQueryReaderOptions) {\n const { ctes, ecsql, bindings } = query;\n const opts = new QueryOptionsBuilder();\n switch (config?.rowFormat) {\n case \"ECSqlPropertyNames\":\n opts.setRowFormat(QueryRowFormat.UseECSqlPropertyNames);\n break;\n case \"Indexes\":\n opts.setRowFormat(QueryRowFormat.UseECSqlPropertyIndexes);\n break;\n }\n if (config?.restartToken) {\n opts.setRestartToken(config?.restartToken);\n }\n return new ECSqlQueryReaderImpl(\n imodel.createQueryReader(trimWhitespace(addCTEs(ecsql, ctes)), bind(bindings ?? []), opts.getOptions()),\n config?.rowFormat === \"Indexes\" ? \"array\" : \"object\",\n );\n },\n };\n}\n\nclass ECSqlQueryReaderImpl implements ReturnType<ECSqlQueryExecutor[\"createQueryReader\"]> {\n public constructor(\n private _coreReader: ECSqlReader,\n private _format: \"array\" | \"object\",\n ) {}\n public [Symbol.asyncIterator](): AsyncIterableIterator<ECSqlQueryRow> {\n return this;\n }\n public async next(): Promise<IteratorResult<ECSqlQueryRow>> {\n const res = await this._coreReader.next();\n if (res.done) {\n return { done: true, value: undefined };\n }\n return {\n done: false,\n value: this._format === \"array\" ? res.value.toArray() : res.value.toRow(),\n };\n }\n}\n\nfunction bind(bindings: ECSqlBinding[]): QueryBinder {\n const binder = new QueryBinder();\n bindings.forEach((b, i) => {\n if (b.value === undefined) {\n binder.bindNull(i + 1);\n return;\n }\n switch (b.type) {\n case \"boolean\":\n binder.bindBoolean(i + 1, b.value);\n break;\n case \"double\":\n binder.bindDouble(i + 1, b.value);\n break;\n case \"id\":\n binder.bindId(i + 1, b.value);\n break;\n case \"idset\":\n binder.bindIdSet(i + 1, OrderedId64Iterable.sortArray(b.value));\n break;\n case \"int\":\n binder.bindInt(i + 1, b.value);\n break;\n case \"long\":\n binder.bindLong(i + 1, b.value);\n break;\n case \"point2d\":\n binder.bindPoint2d(i + 1, Point2d.fromJSON(b.value));\n break;\n case \"point3d\":\n binder.bindPoint3d(i + 1, Point3d.fromJSON(b.value));\n break;\n case \"string\":\n binder.bindString(i + 1, b.value);\n break;\n }\n });\n return binder;\n}\n\nfunction addCTEs(ecsql: string, ctes: string[] | undefined) {\n const ctesPrefix = ctes?.length ? `WITH RECURSIVE ${ctes.join(\", \")} ` : \"\";\n return `${ctesPrefix}${ecsql}`;\n}\n"]}
@@ -7,7 +7,7 @@ import { Event } from "@itwin/presentation-shared";
7
7
  * through [BriefcaseDb.txns](https://www.itwinjs.org/reference/core-backend/imodels/briefcasedb/#txns), or
8
8
  * [BriefcaseTxns](https://www.itwinjs.org/reference/core-frontend/imodelconnection/briefcasetxns/), accessed
9
9
  * through [BriefcaseConnection.txns](https://www.itwinjs.org/reference/core-frontend/imodelconnection/briefcaseconnection/#txns).
10
- * @beta
10
+ * @public
11
11
  */
12
12
  interface ICoreTxnManager {
13
13
  /**
@@ -64,7 +64,7 @@ interface ICoreTxnManager {
64
64
  * through [BriefcaseConnection.txns](https://www.itwinjs.org/reference/core-frontend/imodelconnection/briefcaseconnection/#txns).
65
65
  * @param onChanged A function to call when transaction manager reports iModel data changes.
66
66
  * @returns A function that unregisters the transaction manager listeners.
67
- * @beta
67
+ * @public
68
68
  */
69
69
  export declare function registerTxnListeners(txns: ICoreTxnManager, onChanged: () => void): () => void;
70
70
  export {};
@@ -37,7 +37,7 @@ exports.registerTxnListeners = registerTxnListeners;
37
37
  * through [BriefcaseConnection.txns](https://www.itwinjs.org/reference/core-frontend/imodelconnection/briefcaseconnection/#txns).
38
38
  * @param onChanged A function to call when transaction manager reports iModel data changes.
39
39
  * @returns A function that unregisters the transaction manager listeners.
40
- * @beta
40
+ * @public
41
41
  */
42
42
  function registerTxnListeners(txns, onChanged) {
43
43
  let hasChanges = false;
@@ -1 +1 @@
1
- {"version":3,"file":"Transactions.js","sourceRoot":"","sources":["../../../src/core-interop/Transactions.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AAwEhG,oDAiBC;AAnDD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,SAAgB,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 { 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 * @beta\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 * @beta\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"]}
1
+ {"version":3,"file":"Transactions.js","sourceRoot":"","sources":["../../../src/core-interop/Transactions.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AAwEhG,oDAiBC;AAnDD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,SAAgB,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 { 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"]}
@@ -1,6 +1,6 @@
1
- export { createValueFormatter } from "./core-interop/Formatting";
2
- export { createLogger } from "./core-interop/Logging";
3
- export { createECSchemaProvider } from "./core-interop/Metadata";
4
- export { createECSqlQueryExecutor } from "./core-interop/QueryExecutor";
5
- export { registerTxnListeners } from "./core-interop/Transactions";
1
+ export { createValueFormatter } from "./core-interop/Formatting.js";
2
+ export { createLogger } from "./core-interop/Logging.js";
3
+ export { createECSchemaProvider } from "./core-interop/Metadata.js";
4
+ export { createECSqlQueryExecutor } from "./core-interop/QueryExecutor.js";
5
+ export { registerTxnListeners } from "./core-interop/Transactions.js";
6
6
  //# sourceMappingURL=presentation-core-interop.d.ts.map
@@ -1 +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,2BAA2B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC"}
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,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"}
@@ -5,14 +5,14 @@
5
5
  *--------------------------------------------------------------------------------------------*/
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.registerTxnListeners = exports.createECSqlQueryExecutor = exports.createECSchemaProvider = exports.createLogger = exports.createValueFormatter = void 0;
8
- var Formatting_1 = require("./core-interop/Formatting");
9
- Object.defineProperty(exports, "createValueFormatter", { enumerable: true, get: function () { return Formatting_1.createValueFormatter; } });
10
- var Logging_1 = require("./core-interop/Logging");
11
- Object.defineProperty(exports, "createLogger", { enumerable: true, get: function () { return Logging_1.createLogger; } });
12
- var Metadata_1 = require("./core-interop/Metadata");
13
- Object.defineProperty(exports, "createECSchemaProvider", { enumerable: true, get: function () { return Metadata_1.createECSchemaProvider; } });
14
- var QueryExecutor_1 = require("./core-interop/QueryExecutor");
15
- Object.defineProperty(exports, "createECSqlQueryExecutor", { enumerable: true, get: function () { return QueryExecutor_1.createECSqlQueryExecutor; } });
16
- var Transactions_1 = require("./core-interop/Transactions");
17
- Object.defineProperty(exports, "registerTxnListeners", { enumerable: true, get: function () { return Transactions_1.registerTxnListeners; } });
8
+ var Formatting_js_1 = require("./core-interop/Formatting.js");
9
+ Object.defineProperty(exports, "createValueFormatter", { enumerable: true, get: function () { return Formatting_js_1.createValueFormatter; } });
10
+ var Logging_js_1 = require("./core-interop/Logging.js");
11
+ Object.defineProperty(exports, "createLogger", { enumerable: true, get: function () { return Logging_js_1.createLogger; } });
12
+ var Metadata_js_1 = require("./core-interop/Metadata.js");
13
+ Object.defineProperty(exports, "createECSchemaProvider", { enumerable: true, get: function () { return Metadata_js_1.createECSchemaProvider; } });
14
+ var QueryExecutor_js_1 = require("./core-interop/QueryExecutor.js");
15
+ Object.defineProperty(exports, "createECSqlQueryExecutor", { enumerable: true, get: function () { return QueryExecutor_js_1.createECSqlQueryExecutor; } });
16
+ var Transactions_js_1 = require("./core-interop/Transactions.js");
17
+ Object.defineProperty(exports, "registerTxnListeners", { enumerable: true, get: function () { return Transactions_js_1.registerTxnListeners; } });
18
18
  //# sourceMappingURL=presentation-core-interop.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"presentation-core-interop.js","sourceRoot":"","sources":["../../src/presentation-core-interop.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,wDAAiE;AAAxD,kHAAA,oBAAoB,OAAA;AAC7B,kDAAsD;AAA7C,uGAAA,YAAY,OAAA;AACrB,oDAAiE;AAAxD,kHAAA,sBAAsB,OAAA;AAC/B,8DAAwE;AAA/D,yHAAA,wBAAwB,OAAA;AACjC,4DAAmE;AAA1D,oHAAA,oBAAoB,OAAA","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\";\nexport { createLogger } from \"./core-interop/Logging\";\nexport { createECSchemaProvider } from \"./core-interop/Metadata\";\nexport { createECSqlQueryExecutor } from \"./core-interop/QueryExecutor\";\nexport { registerTxnListeners } from \"./core-interop/Transactions\";\n"]}
1
+ {"version":3,"file":"presentation-core-interop.js","sourceRoot":"","sources":["../../src/presentation-core-interop.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,8DAAoE;AAA3D,qHAAA,oBAAoB,OAAA;AAC7B,wDAAyD;AAAhD,0GAAA,YAAY,OAAA;AACrB,0DAAoE;AAA3D,qHAAA,sBAAsB,OAAA;AAC/B,oEAA2E;AAAlE,4HAAA,wBAAwB,OAAA;AACjC,kEAAsE;AAA7D,uHAAA,oBAAoB,OAAA","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 { 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"]}
@@ -3,7 +3,7 @@ import { SchemaContext } from "@itwin/ecschema-metadata";
3
3
  import { IPrimitiveValueFormatter } from "@itwin/presentation-shared";
4
4
  /**
5
5
  * Props for `createValueFormatter` function.
6
- * @beta
6
+ * @public
7
7
  */
8
8
  interface CreateValueFormatterProps {
9
9
  /**
@@ -38,7 +38,7 @@ interface CreateValueFormatterProps {
38
38
  * const formattedValue = await formatter({ type: "Double", value: 1.234, koqName: "MySchema.LengthKindOfQuantity" });
39
39
  * ```
40
40
  *
41
- * @beta
41
+ * @public
42
42
  */
43
43
  export declare function createValueFormatter(props: CreateValueFormatterProps): IPrimitiveValueFormatter;
44
44
  export {};
@@ -20,11 +20,11 @@ import { createDefaultValueFormatter, parseFullClassName } from "@itwin/presenta
20
20
  * const formattedValue = await formatter({ type: "Double", value: 1.234, koqName: "MySchema.LengthKindOfQuantity" });
21
21
  * ```
22
22
  *
23
- * @beta
23
+ * @public
24
24
  */
25
25
  export function createValueFormatter(props) {
26
26
  const { schemaContext, unitSystem } = props;
27
- const baseFormatter = props.baseFormatter ?? /* istanbul ignore next */ createDefaultValueFormatter();
27
+ const baseFormatter = props.baseFormatter ?? /* c8 ignore next */ createDefaultValueFormatter();
28
28
  const unitsProvider = new SchemaUnitProvider(schemaContext);
29
29
  return async function (value) {
30
30
  if (value.type === "Double" && !!value.koqName) {
@@ -61,7 +61,7 @@ async function getFormatterSpec(unitsProvider, koq, unitSystem) {
61
61
  }
62
62
  async function getFormattingProps(koq, unitSystem) {
63
63
  const persistenceUnit = await koq.persistenceUnit;
64
- // istanbul ignore if
64
+ /* c8 ignore next 3 */
65
65
  if (!persistenceUnit) {
66
66
  return undefined;
67
67
  }
@@ -94,7 +94,7 @@ async function getKoqPresentationFormat(koq, unitSystems) {
94
94
  for (const system of unitSystems) {
95
95
  for (const format of presentationFormats) {
96
96
  const unit = format.units && format.units[0][0];
97
- // istanbul ignore if
97
+ /* c8 ignore next 3 */
98
98
  if (!unit) {
99
99
  continue;
100
100
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Formatting.js","sourceRoot":"","sources":["../../../src/core-interop/Formatting.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEh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ACD,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 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 * @beta\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 * @beta\n */\nexport function createValueFormatter(props: CreateValueFormatterProps): IPrimitiveValueFormatter {\n const { schemaContext, unitSystem } = props;\n const baseFormatter = props.baseFormatter ?? /* istanbul 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 const koq = await schema.getItem<KindOfQuantity>(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;\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 // istanbul ignore if\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 unit = format.units && format.units[0][0];\n // istanbul ignore if\n if (!unit) {\n continue;\n }\n const currentUnitSystem = await unit.unitSystem;\n if (currentUnitSystem && currentUnitSystem.name.toUpperCase() === system) {\n return format;\n }\n }\n }\n return undefined;\n}\n\nfunction getFormatProps(format: Format | OverrideFormat): FormatProps {\n return format instanceof OverrideFormat ? format.getFormatProps() : format.toJSON();\n}\n\nfunction getPersistenceUnitFormatProps(persistenceUnit: Unit | InvertedUnit): FormatProps {\n // Same as Format \"DefaultRealU\" in Formats ecschema\n return {\n formatTraits: [\"keepSingleZero\", \"keepDecimalPoint\", \"showUnitLabel\"],\n precision: 6,\n type: \"Decimal\",\n uomSeparator: \" \",\n decimalSeparator: \".\",\n composite: {\n units: [\n {\n name: persistenceUnit.fullName,\n label: persistenceUnit.label,\n },\n ],\n },\n };\n}\n\nfunction getUnitSystemGroupNames(unitSystem?: UnitSystemKey) {\n switch (unitSystem) {\n case \"imperial\":\n return [\"IMPERIAL\", \"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"];\n case \"metric\":\n return [\"SI\", \"METRIC\", \"INTERNATIONAL\", \"FINANCE\"];\n case \"usCustomary\":\n return [\"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"];\n case \"usSurvey\":\n return [\"USSURVEY\", \"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"];\n }\n return [];\n}\n"]}
1
+ {"version":3,"file":"Formatting.js","sourceRoot":"","sources":["../../../src/core-interop/Formatting.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAe,aAAa,EAAE,MAAM,IAAI,cAAc,EAAgC,MAAM,sBAAsB,CAAC;AAC1H,OAAO,EAIL,cAAc,EAEd,SAAS,EACT,eAAe,EACf,kBAAkB,GAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,2BAA2B,EAA4B,kBAAkB,EAAuB,MAAM,4BAA4B,CAAC;AA2B5I;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAgC;IACnE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;IAC5C,MAAM,aAAa,GAAG,KAAK,CAAC,aAAa,IAAI,oBAAoB,CAAC,2BAA2B,EAAE,CAAC;IAChG,MAAM,aAAa,GAAG,IAAI,kBAAkB,CAAC,aAAa,CAAC,CAAC;IAC5D,OAAO,KAAK,WAAW,KAA0B;QAC/C,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;YAC/C,MAAM,GAAG,GAAG,MAAM,iBAAiB,CAAC,aAAa,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;YAClE,MAAM,IAAI,GAAG,MAAM,gBAAgB,CAAC,aAAa,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC;YACpE,IAAI,IAAI,EAAE,CAAC;gBACT,OAAO,IAAI,CAAC,eAAe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;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 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 const koq = await schema.getItem<KindOfQuantity>(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;\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 unit = format.units && format.units[0][0];\n /* c8 ignore next 3 */\n if (!unit) {\n continue;\n }\n const currentUnitSystem = await unit.unitSystem;\n if (currentUnitSystem && currentUnitSystem.name.toUpperCase() === system) {\n return format;\n }\n }\n }\n return undefined;\n}\n\nfunction getFormatProps(format: Format | OverrideFormat): FormatProps {\n return format instanceof OverrideFormat ? format.getFormatProps() : 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"]}
@@ -3,7 +3,7 @@ import { 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.
6
- * @beta
6
+ * @public
7
7
  */
8
8
  interface ICoreLogger {
9
9
  isEnabled(category: string, level: CoreLogLevel): boolean;
@@ -26,7 +26,7 @@ interface ICoreLogger {
26
26
  * setLogger(createLogger(Logger));
27
27
  * ```
28
28
  *
29
- * @beta
29
+ * @public
30
30
  */
31
31
  export declare function createLogger(coreLogger: ICoreLogger): ILogger;
32
32
  export {};
@@ -17,7 +17,7 @@ import { LogLevel as CoreLogLevel } from "@itwin/core-bentley";
17
17
  * setLogger(createLogger(Logger));
18
18
  * ```
19
19
  *
20
- * @beta
20
+ * @public
21
21
  */
22
22
  export function createLogger(coreLogger) {
23
23
  return {
@@ -1 +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;AAgB/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\";\nimport { 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 * @beta\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 * @beta\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
+ {"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;AAgB/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\";\nimport { 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"]}
@@ -3,7 +3,7 @@ import { ECSchemaProvider } from "@itwin/presentation-shared";
3
3
  /**
4
4
  * Defines input for `createECSchemaProvider`. Generally, this is an instance of [SchemaContext](https://www.itwinjs.org/reference/ecschema-metadata/context/schemacontext/)
5
5
  * class from `@itwin/ecschema-metadata` package.
6
- * @beta
6
+ * @public
7
7
  */
8
8
  interface CoreSchemaContext {
9
9
  getSchema(key: CoreSchemaKey): Promise<CoreSchema | undefined>;
@@ -22,7 +22,7 @@ interface CoreSchemaContext {
22
22
  * // the created schema provider may be used in `@itwin/presentation-hierarchies` and other Presentation packages
23
23
  * ```
24
24
  *
25
- * @beta
25
+ * @public
26
26
  */
27
27
  export declare function createECSchemaProvider(schemaContext: CoreSchemaContext): ECSchemaProvider;
28
28
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"Metadata.d.ts","sourceRoot":"","sources":["../../../src/core-interop/Metadata.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC5F,OAAO,EAAM,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAGlE;;;;GAIG;AACH,UAAU,iBAAiB;IACzB,SAAS,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;CAChE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CAAC,aAAa,EAAE,iBAAiB,GAAG,gBAAgB,CAkCzF"}
1
+ {"version":3,"file":"Metadata.d.ts","sourceRoot":"","sources":["../../../src/core-interop/Metadata.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC5F,OAAO,EAAM,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAGlE;;;;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"}
@@ -3,7 +3,7 @@
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import { SchemaKey as CoreSchemaKey } from "@itwin/ecschema-metadata";
6
- import { createECSchema } from "./MetadataInternal";
6
+ import { createECSchema } from "./MetadataInternal.js";
7
7
  /**
8
8
  * Creates an `ECSchemaProvider` for given [SchemaContext](https://www.itwinjs.org/reference/ecschema-metadata/context/schemacontext/).
9
9
  *
@@ -18,7 +18,7 @@ import { createECSchema } from "./MetadataInternal";
18
18
  * // the created schema provider may be used in `@itwin/presentation-hierarchies` and other Presentation packages
19
19
  * ```
20
20
  *
21
- * @beta
21
+ * @public
22
22
  */
23
23
  export function createECSchemaProvider(schemaContext) {
24
24
  const schemaRequestsCache = new Map();
@@ -32,7 +32,6 @@ export function createECSchemaProvider(schemaContext) {
32
32
  return await getSchemaUnprotected(schemaName);
33
33
  }
34
34
  catch (e) {
35
- // istanbul ignore else
36
35
  if (e instanceof Error) {
37
36
  if (e.message.includes("already exists within this cache") && !handledExistingSchemaErrors.has(schemaName)) {
38
37
  handledExistingSchemaErrors.add(schemaName);
@@ -1 +1 @@
1
- {"version":3,"file":"Metadata.js","sourceRoot":"","sources":["../../../src/core-interop/Metadata.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAwB,SAAS,IAAI,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE5F,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAWpD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,sBAAsB,CAAC,aAAgC;IACrE,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAA0C,CAAC;IAC9E,KAAK,UAAU,oBAAoB,CAAC,UAAkB;QACpD,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC,SAAS,CAAC,IAAI,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC;QAChF,OAAO,UAAU,CAAC,CAAC,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC7D,CAAC;IACD,KAAK,UAAU,kBAAkB,CAAC,UAAkB,EAAE,2BAAwC;QAC5F,mEAAmE;QACnE,IAAI,CAAC;YACH,OAAO,MAAM,oBAAoB,CAAC,UAAU,CAAC,CAAC;QAChD,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,uBAAuB;YACvB,IAAI,CAAC,YAAY,KAAK,EAAE,CAAC;gBACvB,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,kCAAkC,CAAC,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;oBAC3G,2BAA2B,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;oBAC5C,OAAO,kBAAkB,CAAC,UAAU,EAAE,2BAA2B,CAAC,CAAC;gBACrE,CAAC;gBACD,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;oBAC3C,OAAO,SAAS,CAAC;gBACnB,CAAC;YACH,CAAC;YACD,MAAM,CAAC,CAAC;QACV,CAAC;IACH,CAAC;IACD,OAAO;QACL,KAAK,CAAC,SAAS,CAAC,IAAI;YAClB,IAAI,OAAO,GAAG,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC5C,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,OAAO,GAAG,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;gBAC9C,mBAAmB,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACzC,CAAC;YACD,OAAO,OAAO,CAAC;QACjB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { Schema as CoreSchema, SchemaKey as CoreSchemaKey } from \"@itwin/ecschema-metadata\";\nimport { EC, ECSchemaProvider } from \"@itwin/presentation-shared\";\nimport { createECSchema } from \"./MetadataInternal\";\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 * @beta\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 { SchemaContext } from \"@itwin/ecschema-metadata\";\n * import { createECSchemaProvider } from \"@itwin/presentation-core-interop\";\n *\n * const schemaContext = new SchemaContext();\n * const schemaProvider = createECSchemaProvider(schemas);\n * // the created schema provider may be used in `@itwin/presentation-hierarchies` and other Presentation packages\n * ```\n *\n * @beta\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 // istanbul ignore else\n if (e instanceof Error) {\n if (e.message.includes(\"already exists within this cache\") && !handledExistingSchemaErrors.has(schemaName)) {\n handledExistingSchemaErrors.add(schemaName);\n return getSchemaProtected(schemaName, handledExistingSchemaErrors);\n }\n if (e.message.includes(\"schema not found\")) {\n return undefined;\n }\n }\n throw e;\n }\n }\n return {\n async getSchema(name) {\n let promise = schemaRequestsCache.get(name);\n if (!promise) {\n promise = getSchemaProtected(name, new Set());\n schemaRequestsCache.set(name, promise);\n }\n return promise;\n },\n };\n}\n"]}
1
+ {"version":3,"file":"Metadata.js","sourceRoot":"","sources":["../../../src/core-interop/Metadata.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAwB,SAAS,IAAI,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE5F,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAWvD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,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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 { Schema as CoreSchema, SchemaKey as CoreSchemaKey } from \"@itwin/ecschema-metadata\";\nimport { EC, ECSchemaProvider } from \"@itwin/presentation-shared\";\nimport { createECSchema } from \"./MetadataInternal.js\";\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 { SchemaContext } from \"@itwin/ecschema-metadata\";\n * import { createECSchemaProvider } from \"@itwin/presentation-core-interop\";\n *\n * const schemaContext = new SchemaContext();\n * const schemaProvider = createECSchemaProvider(schemas);\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"]}
@@ -3,7 +3,7 @@ import { ECSqlQueryExecutor } from "@itwin/presentation-shared";
3
3
  /**
4
4
  * Defines input for `createECSqlQueryExecutor`. Generally, this is an instance of either [IModelDb](https://www.itwinjs.org/reference/core-backend/imodels/imodeldb/)
5
5
  * or [IModelConnection](https://www.itwinjs.org/reference/core-frontend/imodelconnection/imodelconnection/).
6
- * @beta
6
+ * @public
7
7
  */
8
8
  interface CoreECSqlReaderFactory {
9
9
  createQueryReader(ecsql: string, binder?: QueryBinder, options?: QueryOptions): ECSqlReader;
@@ -25,7 +25,7 @@ interface CoreECSqlReaderFactory {
25
25
  * }
26
26
  * ```
27
27
  *
28
- * @beta
28
+ * @public
29
29
  */
30
30
  export declare function createECSqlQueryExecutor(imodel: CoreECSqlReaderFactory): ECSqlQueryExecutor;
31
31
  export {};
@@ -23,7 +23,7 @@ import { trimWhitespace } from "@itwin/presentation-shared";
23
23
  * }
24
24
  * ```
25
25
  *
26
- * @beta
26
+ * @public
27
27
  */
28
28
  export function createECSqlQueryExecutor(imodel) {
29
29
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"QueryExecutor.js","sourceRoot":"","sources":["../../../src/core-interop/QueryExecutor.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAe,WAAW,EAAgB,mBAAmB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACjH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO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AK;gBACR,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;gBAC/B,MAAM;YACR,KAAK,MAAM;gBACT,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;gBAChC,MAAM;YACR,KAAK,SAAS;gBACZ,MAAM,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;gBACrD,MAAM;YACR,KAAK,SAAS;gBACZ,MAAM,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;gBACrD,MAAM;YACR,KAAK,QAAQ;gBACX,MAAM,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;gBAClC,MAAM;QACV,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,OAAO,CAAC,KAAa,EAAE,IAA0B;IACxD,MAAM,UAAU,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,kBAAkB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5E,OAAO,GAAG,UAAU,GAAG,KAAK,EAAE,CAAC;AACjC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { OrderedId64Iterable } from \"@itwin/core-bentley\";\nimport { ECSqlReader, QueryBinder, QueryOptions, QueryOptionsBuilder, QueryRowFormat } from \"@itwin/core-common\";\nimport { Point2d, Point3d } from \"@itwin/core-geometry\";\nimport { ECSqlBinding, ECSqlQueryDef, ECSqlQueryExecutor, ECSqlQueryReaderOptions, ECSqlQueryRow, trimWhitespace } from \"@itwin/presentation-shared\";\n\n/**\n * Defines input for `createECSqlQueryExecutor`. Generally, this is an instance of either [IModelDb](https://www.itwinjs.org/reference/core-backend/imodels/imodeldb/)\n * or [IModelConnection](https://www.itwinjs.org/reference/core-frontend/imodelconnection/imodelconnection/).\n * @beta\n */\ninterface CoreECSqlReaderFactory {\n createQueryReader(ecsql: string, binder?: QueryBinder, options?: QueryOptions): ECSqlReader;\n}\n\n/**\n * Creates an `ECSqlQueryExecutor` from either [IModelDb](https://www.itwinjs.org/reference/core-backend/imodels/imodeldb/) or\n * [IModelConnection](https://www.itwinjs.org/reference/core-frontend/imodelconnection/imodelconnection/).\n *\n * Usage example:\n *\n * ```ts\n * import { IModelDb } from \"@itwin/core-backend\";\n * import { createECSqlQueryExecutor } from \"@itwin/presentation-core-interop\";\n *\n * const imodel: IModelDb = getIModelDb();\n * const executor = createECSqlQueryExecutor(imodel);\n * for await (const row of executor.createQueryReader(MY_QUERY)) {\n * // TODO: do something with `row`\n * }\n * ```\n *\n * @beta\n */\nexport function createECSqlQueryExecutor(imodel: CoreECSqlReaderFactory): ECSqlQueryExecutor {\n return {\n createQueryReader(query: ECSqlQueryDef, config?: ECSqlQueryReaderOptions) {\n const { ctes, ecsql, bindings } = query;\n const opts = new QueryOptionsBuilder();\n switch (config?.rowFormat) {\n case \"ECSqlPropertyNames\":\n opts.setRowFormat(QueryRowFormat.UseECSqlPropertyNames);\n break;\n case \"Indexes\":\n opts.setRowFormat(QueryRowFormat.UseECSqlPropertyIndexes);\n break;\n }\n if (config?.restartToken) {\n opts.setRestartToken(config?.restartToken);\n }\n return new ECSqlQueryReaderImpl(\n imodel.createQueryReader(trimWhitespace(addCTEs(ecsql, ctes)), bind(bindings ?? []), opts.getOptions()),\n config?.rowFormat === \"Indexes\" ? \"array\" : \"object\",\n );\n },\n };\n}\n\nclass ECSqlQueryReaderImpl implements ReturnType<ECSqlQueryExecutor[\"createQueryReader\"]> {\n public constructor(\n private _coreReader: ECSqlReader,\n private _format: \"array\" | \"object\",\n ) {}\n public [Symbol.asyncIterator](): AsyncIterableIterator<ECSqlQueryRow> {\n return this;\n }\n public async next(): Promise<IteratorResult<ECSqlQueryRow>> {\n const res = await this._coreReader.next();\n if (res.done) {\n return { done: true, value: undefined };\n }\n return {\n done: false,\n value: this._format === \"array\" ? res.value.toArray() : res.value.toRow(),\n };\n }\n}\n\nfunction bind(bindings: ECSqlBinding[]): QueryBinder {\n const binder = new QueryBinder();\n bindings.forEach((b, i) => {\n if (b.value === undefined) {\n binder.bindNull(i + 1);\n return;\n }\n switch (b.type) {\n case \"boolean\":\n binder.bindBoolean(i + 1, b.value);\n break;\n case \"double\":\n binder.bindDouble(i + 1, b.value);\n break;\n case \"id\":\n binder.bindId(i + 1, b.value);\n break;\n case \"idset\":\n binder.bindIdSet(i + 1, OrderedId64Iterable.sortArray(b.value));\n break;\n case \"int\":\n binder.bindInt(i + 1, b.value);\n break;\n case \"long\":\n binder.bindLong(i + 1, b.value);\n break;\n case \"point2d\":\n binder.bindPoint2d(i + 1, Point2d.fromJSON(b.value));\n break;\n case \"point3d\":\n binder.bindPoint3d(i + 1, Point3d.fromJSON(b.value));\n break;\n case \"string\":\n binder.bindString(i + 1, b.value);\n break;\n }\n });\n return binder;\n}\n\nfunction addCTEs(ecsql: string, ctes: string[] | undefined) {\n const ctesPrefix = ctes?.length ? `WITH RECURSIVE ${ctes.join(\", \")} ` : \"\";\n return `${ctesPrefix}${ecsql}`;\n}\n"]}
1
+ {"version":3,"file":"QueryExecutor.js","sourceRoot":"","sources":["../../../src/core-interop/QueryExecutor.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAe,WAAW,EAAgB,mBAAmB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACjH,OAAO,EAA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,CAAC,KAAK,CAAC,CAAC,CAAC;gBAChE,MAAM;YACR,KAAK,KAAK;gBACR,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;gBAC/B,MAAM;YACR,KAAK,MAAM;gBACT,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;gBAChC,MAAM;YACR,KAAK,SAAS;gBACZ,MAAM,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;gBACrD,MAAM;YACR,KAAK,SAAS;gBACZ,MAAM,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;gBACrD,MAAM;YACR,KAAK,QAAQ;gBACX,MAAM,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;gBAClC,MAAM;QACV,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,OAAO,CAAC,KAAa,EAAE,IAA0B;IACxD,MAAM,UAAU,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,kBAAkB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5E,OAAO,GAAG,UAAU,GAAG,KAAK,EAAE,CAAC;AACjC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { OrderedId64Iterable } from \"@itwin/core-bentley\";\nimport { ECSqlReader, QueryBinder, QueryOptions, QueryOptionsBuilder, QueryRowFormat } from \"@itwin/core-common\";\nimport { Point2d, Point3d } from \"@itwin/core-geometry\";\nimport { ECSqlBinding, ECSqlQueryDef, ECSqlQueryExecutor, ECSqlQueryReaderOptions, ECSqlQueryRow, trimWhitespace } from \"@itwin/presentation-shared\";\n\n/**\n * Defines input for `createECSqlQueryExecutor`. Generally, this is an instance of either [IModelDb](https://www.itwinjs.org/reference/core-backend/imodels/imodeldb/)\n * or [IModelConnection](https://www.itwinjs.org/reference/core-frontend/imodelconnection/imodelconnection/).\n * @public\n */\ninterface CoreECSqlReaderFactory {\n createQueryReader(ecsql: string, binder?: QueryBinder, options?: QueryOptions): ECSqlReader;\n}\n\n/**\n * Creates an `ECSqlQueryExecutor` from either [IModelDb](https://www.itwinjs.org/reference/core-backend/imodels/imodeldb/) or\n * [IModelConnection](https://www.itwinjs.org/reference/core-frontend/imodelconnection/imodelconnection/).\n *\n * Usage example:\n *\n * ```ts\n * import { IModelDb } from \"@itwin/core-backend\";\n * import { createECSqlQueryExecutor } from \"@itwin/presentation-core-interop\";\n *\n * const imodel: IModelDb = getIModelDb();\n * const executor = createECSqlQueryExecutor(imodel);\n * for await (const row of executor.createQueryReader(MY_QUERY)) {\n * // TODO: do something with `row`\n * }\n * ```\n *\n * @public\n */\nexport function createECSqlQueryExecutor(imodel: CoreECSqlReaderFactory): ECSqlQueryExecutor {\n return {\n createQueryReader(query: ECSqlQueryDef, config?: ECSqlQueryReaderOptions) {\n const { ctes, ecsql, bindings } = query;\n const opts = new QueryOptionsBuilder();\n switch (config?.rowFormat) {\n case \"ECSqlPropertyNames\":\n opts.setRowFormat(QueryRowFormat.UseECSqlPropertyNames);\n break;\n case \"Indexes\":\n opts.setRowFormat(QueryRowFormat.UseECSqlPropertyIndexes);\n break;\n }\n if (config?.restartToken) {\n opts.setRestartToken(config?.restartToken);\n }\n return new ECSqlQueryReaderImpl(\n imodel.createQueryReader(trimWhitespace(addCTEs(ecsql, ctes)), bind(bindings ?? []), opts.getOptions()),\n config?.rowFormat === \"Indexes\" ? \"array\" : \"object\",\n );\n },\n };\n}\n\nclass ECSqlQueryReaderImpl implements ReturnType<ECSqlQueryExecutor[\"createQueryReader\"]> {\n public constructor(\n private _coreReader: ECSqlReader,\n private _format: \"array\" | \"object\",\n ) {}\n public [Symbol.asyncIterator](): AsyncIterableIterator<ECSqlQueryRow> {\n return this;\n }\n public async next(): Promise<IteratorResult<ECSqlQueryRow>> {\n const res = await this._coreReader.next();\n if (res.done) {\n return { done: true, value: undefined };\n }\n return {\n done: false,\n value: this._format === \"array\" ? res.value.toArray() : res.value.toRow(),\n };\n }\n}\n\nfunction bind(bindings: ECSqlBinding[]): QueryBinder {\n const binder = new QueryBinder();\n bindings.forEach((b, i) => {\n if (b.value === undefined) {\n binder.bindNull(i + 1);\n return;\n }\n switch (b.type) {\n case \"boolean\":\n binder.bindBoolean(i + 1, b.value);\n break;\n case \"double\":\n binder.bindDouble(i + 1, b.value);\n break;\n case \"id\":\n binder.bindId(i + 1, b.value);\n break;\n case \"idset\":\n binder.bindIdSet(i + 1, OrderedId64Iterable.sortArray(b.value));\n break;\n case \"int\":\n binder.bindInt(i + 1, b.value);\n break;\n case \"long\":\n binder.bindLong(i + 1, b.value);\n break;\n case \"point2d\":\n binder.bindPoint2d(i + 1, Point2d.fromJSON(b.value));\n break;\n case \"point3d\":\n binder.bindPoint3d(i + 1, Point3d.fromJSON(b.value));\n break;\n case \"string\":\n binder.bindString(i + 1, b.value);\n break;\n }\n });\n return binder;\n}\n\nfunction addCTEs(ecsql: string, ctes: string[] | undefined) {\n const ctesPrefix = ctes?.length ? `WITH RECURSIVE ${ctes.join(\", \")} ` : \"\";\n return `${ctesPrefix}${ecsql}`;\n}\n"]}
@@ -7,7 +7,7 @@ import { Event } from "@itwin/presentation-shared";
7
7
  * through [BriefcaseDb.txns](https://www.itwinjs.org/reference/core-backend/imodels/briefcasedb/#txns), or
8
8
  * [BriefcaseTxns](https://www.itwinjs.org/reference/core-frontend/imodelconnection/briefcasetxns/), accessed
9
9
  * through [BriefcaseConnection.txns](https://www.itwinjs.org/reference/core-frontend/imodelconnection/briefcaseconnection/#txns).
10
- * @beta
10
+ * @public
11
11
  */
12
12
  interface ICoreTxnManager {
13
13
  /**
@@ -64,7 +64,7 @@ interface ICoreTxnManager {
64
64
  * through [BriefcaseConnection.txns](https://www.itwinjs.org/reference/core-frontend/imodelconnection/briefcaseconnection/#txns).
65
65
  * @param onChanged A function to call when transaction manager reports iModel data changes.
66
66
  * @returns A function that unregisters the transaction manager listeners.
67
- * @beta
67
+ * @public
68
68
  */
69
69
  export declare function registerTxnListeners(txns: ICoreTxnManager, onChanged: () => void): () => void;
70
70
  export {};
@@ -34,7 +34,7 @@
34
34
  * through [BriefcaseConnection.txns](https://www.itwinjs.org/reference/core-frontend/imodelconnection/briefcaseconnection/#txns).
35
35
  * @param onChanged A function to call when transaction manager reports iModel data changes.
36
36
  * @returns A function that unregisters the transaction manager listeners.
37
- * @beta
37
+ * @public
38
38
  */
39
39
  export function registerTxnListeners(txns, onChanged) {
40
40
  let hasChanges = false;
@@ -1 +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 { 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 * @beta\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 * @beta\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"]}
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 { 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"]}
@@ -1,6 +1,6 @@
1
- export { createValueFormatter } from "./core-interop/Formatting";
2
- export { createLogger } from "./core-interop/Logging";
3
- export { createECSchemaProvider } from "./core-interop/Metadata";
4
- export { createECSqlQueryExecutor } from "./core-interop/QueryExecutor";
5
- export { registerTxnListeners } from "./core-interop/Transactions";
1
+ export { createValueFormatter } from "./core-interop/Formatting.js";
2
+ export { createLogger } from "./core-interop/Logging.js";
3
+ export { createECSchemaProvider } from "./core-interop/Metadata.js";
4
+ export { createECSqlQueryExecutor } from "./core-interop/QueryExecutor.js";
5
+ export { registerTxnListeners } from "./core-interop/Transactions.js";
6
6
  //# sourceMappingURL=presentation-core-interop.d.ts.map
@@ -1 +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,2BAA2B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC"}
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,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"}
@@ -2,9 +2,9 @@
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
- export { createValueFormatter } from "./core-interop/Formatting";
6
- export { createLogger } from "./core-interop/Logging";
7
- export { createECSchemaProvider } from "./core-interop/Metadata";
8
- export { createECSqlQueryExecutor } from "./core-interop/QueryExecutor";
9
- export { registerTxnListeners } from "./core-interop/Transactions";
5
+ export { createValueFormatter } from "./core-interop/Formatting.js";
6
+ export { createLogger } from "./core-interop/Logging.js";
7
+ export { createECSchemaProvider } from "./core-interop/Metadata.js";
8
+ export { createECSqlQueryExecutor } from "./core-interop/QueryExecutor.js";
9
+ export { registerTxnListeners } from "./core-interop/Transactions.js";
10
10
  //# sourceMappingURL=presentation-core-interop.js.map
@@ -1 +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,2BAA2B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,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\";\nexport { createLogger } from \"./core-interop/Logging\";\nexport { createECSchemaProvider } from \"./core-interop/Metadata\";\nexport { createECSqlQueryExecutor } from \"./core-interop/QueryExecutor\";\nexport { registerTxnListeners } from \"./core-interop/Transactions\";\n"]}
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,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 { 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": "0.2.7",
3
+ "version": "1.1.0",
4
4
  "description": "The package acts as a layer between iTwin.js Core and Presentation packages.",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -18,12 +18,20 @@
18
18
  "iTwin.js",
19
19
  "Presentation"
20
20
  ],
21
+ "type": "module",
21
22
  "main": "lib/cjs/presentation-core-interop.js",
23
+ "types": "lib/cjs/presentation-core-interop",
22
24
  "module": "lib/esm/presentation-core-interop.js",
23
- "types": "lib/cjs/presentation-core-interop.d.ts",
25
+ "exports": {
26
+ ".": {
27
+ "import": "./lib/esm/presentation-core-interop.js",
28
+ "require": "./lib/cjs/presentation-core-interop.js"
29
+ },
30
+ "./package.json": "./package.json"
31
+ },
24
32
  "dependencies": {
25
33
  "rxjs": "^7.8.1",
26
- "@itwin/presentation-shared": "~0.5.0"
34
+ "@itwin/presentation-shared": "~1.1.0"
27
35
  },
28
36
  "peerDependencies": {
29
37
  "@itwin/core-bentley": "^4.1.0",
@@ -33,41 +41,42 @@
33
41
  "@itwin/ecschema-metadata": "^4.1.0"
34
42
  },
35
43
  "devDependencies": {
36
- "@itwin/build-tools": "^4.9.0",
44
+ "@itwin/build-tools": "^4.10.0-dev.33",
37
45
  "@itwin/core-bentley": "^4.9.0",
38
46
  "@itwin/core-common": "^4.9.0",
39
47
  "@itwin/core-geometry": "^4.9.0",
40
48
  "@itwin/core-quantity": "^4.9.0",
41
49
  "@itwin/ecschema-metadata": "^4.9.0",
42
- "@itwin/eslint-plugin": "^4.1.1",
50
+ "@itwin/eslint-plugin": "5.0.0-dev.1",
43
51
  "@types/chai": "^4.3.16",
44
52
  "@types/chai-as-promised": "^7.1.8",
45
53
  "@types/mocha": "^10.0.7",
46
54
  "@types/sinon": "^17.0.3",
47
55
  "@types/sinon-chai": "^3.2.12",
56
+ "c8": "^10.1.2",
48
57
  "chai": "^4.4.1",
49
58
  "chai-as-promised": "^7.1.2",
50
59
  "cpx2": "^7.0.1",
51
- "eslint": "^8.57.0",
52
- "mocha": "^10.6.0",
53
- "nyc": "^17.0.0",
60
+ "eslint": "^9.13.0",
61
+ "mocha": "^10.7.3",
54
62
  "rimraf": "^6.0.1",
55
63
  "rxjs-for-await": "^1.0.0",
56
64
  "sinon": "^18.0.0",
57
65
  "sinon-chai": "^3.7.0",
58
- "typescript": "~5.5.3",
66
+ "typescript": "~5.6.3",
59
67
  "presentation-build-tools": "^0.0.0"
60
68
  },
61
69
  "scripts": {
62
70
  "build": "npm run -s build:cjs && npm run -s build:esm",
63
- "build:cjs": "tsc -p tsconfig.cjs.json",
71
+ "build:cjs": "node ../../scripts/package-cjs.mjs ./lib/cjs && tsc -p tsconfig.cjs.json",
64
72
  "build:esm": "tsc -p tsconfig.esm.json",
65
- "build:watch": "npm run -s build:cjs -- -w",
66
73
  "clean": "rimraf lib",
67
- "cover": "nyc npm -s test",
74
+ "cover": "c8 npm -s test",
68
75
  "lint": "eslint ./src/**/*.ts",
69
- "test": "mocha --enable-source-maps --config ./.mocharc.json \"./lib/cjs/test/**/*.test.js\"",
76
+ "test:dev": "mocha --enable-source-maps --config ./.mocharc.json",
77
+ "test": "npm run test:dev",
70
78
  "extract-api": "extract-api --entry=presentation-core-interop --apiReportFolder=./api --apiReportTempFolder=./api/temp --apiSummaryFolder=./api",
71
- "check-internal": "node ../../scripts/checkInternal.js --apiSummary ./api/presentation-core-interop.api.md"
79
+ "check-internal": "node ../../scripts/checkInternal.js --apiSummary ./api/presentation-core-interop.api.md",
80
+ "validate-markdowns": "node ../../scripts/validateMarkdowns.js README.md"
72
81
  }
73
82
  }