@itwin/ecschema-metadata 5.2.0-dev.15 → 5.2.0-dev.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/IncrementalLoading/ECSqlSchemaLocater.d.ts.map +1 -1
- package/lib/cjs/IncrementalLoading/ECSqlSchemaLocater.js +14 -8
- package/lib/cjs/IncrementalLoading/ECSqlSchemaLocater.js.map +1 -1
- package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.d.ts +14 -1
- package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.d.ts.map +1 -1
- package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.js.map +1 -1
- package/lib/cjs/IncrementalLoading/IncrementalSchemaReader.d.ts.map +1 -1
- package/lib/cjs/IncrementalLoading/IncrementalSchemaReader.js +1 -7
- package/lib/cjs/IncrementalLoading/IncrementalSchemaReader.js.map +1 -1
- package/lib/cjs/IncrementalLoading/SchemaItemParsers.d.ts +4 -4
- package/lib/cjs/IncrementalLoading/SchemaItemParsers.d.ts.map +1 -1
- package/lib/cjs/IncrementalLoading/SchemaItemParsers.js +16 -16
- package/lib/cjs/IncrementalLoading/SchemaItemParsers.js.map +1 -1
- package/lib/cjs/IncrementalLoading/SchemaItemQueries.js +3 -3
- package/lib/cjs/IncrementalLoading/SchemaItemQueries.js.map +1 -1
- package/lib/cjs/IncrementalLoading/SchemaParser.d.ts +4 -4
- package/lib/cjs/IncrementalLoading/SchemaParser.d.ts.map +1 -1
- package/lib/cjs/IncrementalLoading/SchemaParser.js +13 -13
- package/lib/cjs/IncrementalLoading/SchemaParser.js.map +1 -1
- package/lib/cjs/Metadata/KindOfQuantity.d.ts.map +1 -1
- package/lib/cjs/Metadata/KindOfQuantity.js +9 -22
- package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
- package/lib/esm/IncrementalLoading/ECSqlSchemaLocater.d.ts.map +1 -1
- package/lib/esm/IncrementalLoading/ECSqlSchemaLocater.js +14 -8
- package/lib/esm/IncrementalLoading/ECSqlSchemaLocater.js.map +1 -1
- package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.d.ts +14 -1
- package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.d.ts.map +1 -1
- package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js.map +1 -1
- package/lib/esm/IncrementalLoading/IncrementalSchemaReader.d.ts.map +1 -1
- package/lib/esm/IncrementalLoading/IncrementalSchemaReader.js +1 -7
- package/lib/esm/IncrementalLoading/IncrementalSchemaReader.js.map +1 -1
- package/lib/esm/IncrementalLoading/SchemaItemParsers.d.ts +4 -4
- package/lib/esm/IncrementalLoading/SchemaItemParsers.d.ts.map +1 -1
- package/lib/esm/IncrementalLoading/SchemaItemParsers.js +16 -16
- package/lib/esm/IncrementalLoading/SchemaItemParsers.js.map +1 -1
- package/lib/esm/IncrementalLoading/SchemaItemQueries.js +3 -3
- package/lib/esm/IncrementalLoading/SchemaItemQueries.js.map +1 -1
- package/lib/esm/IncrementalLoading/SchemaParser.d.ts +4 -4
- package/lib/esm/IncrementalLoading/SchemaParser.d.ts.map +1 -1
- package/lib/esm/IncrementalLoading/SchemaParser.js +13 -13
- package/lib/esm/IncrementalLoading/SchemaParser.js.map +1 -1
- package/lib/esm/Metadata/KindOfQuantity.d.ts.map +1 -1
- package/lib/esm/Metadata/KindOfQuantity.js +9 -22
- package/lib/esm/Metadata/KindOfQuantity.js.map +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaItemParsers.js","sourceRoot":"","sources":["../../../src/IncrementalLoading/SchemaItemParsers.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;
|
|
1
|
+
{"version":3,"file":"SchemaItemParsers.js","sourceRoot":"","sources":["../../../src/IncrementalLoading/SchemaItemParsers.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAGhG,4CAAmD;AAEnD,+DAAiF;AACjF,uDAAoD;AACpD,iDAAsD;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I,CAAC,0BAA0B,CAAC,kBAAkB,CAAC,CAAC;YACzE,iBAAiB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACvC,CAAC;QAAA,CAAC;QAEF,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAEO,0BAA0B,CAAC,mBAAwC;QAEzE,IAAI,cAAc,GAAG,IAAI,CAAC,oBAAoB,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;QACzE,IAAI,mBAAmB,CAAC,SAAS;YAC/B,cAAc,IAAI,IAAI,mBAAmB,CAAC,SAAS,CAAC,QAAQ,EAAE,GAAG,CAAC;QAEpE,IAAI,SAAS,KAAK,mBAAmB,CAAC,aAAa;YACjD,OAAO,cAAc,CAAC;QAExB,KAAK,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,mBAAmB,CAAC,aAAa,EAAE,CAAC;YAClE,MAAM,YAAY,GAAG,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;YAErD,IAAI,SAAS,KAAK,SAAS;gBACzB,cAAc,IAAI,IAAI,YAAY,GAAG,CAAC;;gBAEtC,cAAc,IAAI,IAAI,YAAY,IAAI,SAAS,GAAG,CAAC;QACvD,CAAC;QACD,OAAO,cAAc,CAAC;IACxB,CAAC;CACF;AAlDD,oDAkDC","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 { AnySchemaItemProps, KindOfQuantityProps, SchemaItemProps } from \"../Deserialization/JsonProps\";\nimport { parseSchemaItemType } from \"../ECObjects\";\nimport { SchemaInfo } from \"../Interfaces\";\nimport { OverrideFormat, OverrideFormatProps } from \"../Metadata/OverrideFormat\";\nimport { SchemaItem } from \"../Metadata/SchemaItem\";\nimport { parseCustomAttribute } from \"./SchemaParser\";\n\ntype MutableSchemaItemProps = {\n -readonly [K in keyof SchemaItemProps]: SchemaItemProps[K]\n};\n\n/**\n * Parses SchemaItemProps JSON returned from an ECSql query and returns the correct SchemaItemProps JSON.\n * This is necessary as a small amount information (ie. CustomAttribute data) returned from the iModelDb\n * is in a different format than is required for a SchemaItemProps JSON object.\n * @internal\n */\nexport class SchemaItemParser {\n protected _schema: string;\n protected _schemaInfos: Iterable<SchemaInfo>;\n\n /**\n * Initializes a new SchemaItemParser.\n * @param schemaName The name the Schema containing the SchemaItems.\n * @param context The SchemaContext containing the Schema.\n */\n public constructor(schemaName: string, schemaInfos: Iterable<SchemaInfo>) {\n this._schema = schemaName;\n this._schemaInfos = schemaInfos;\n }\n\n /**\n * Parses the given SchemaItemProps JSON returned from an ECSql query.\n * @param data The SchemaItemProps JSON as returned from an iModelDb.\n * @returns The corrected SchemaItemProps Json.\n */\n public async parse(data: AnySchemaItemProps): Promise<SchemaItemProps> {\n const props = data as MutableSchemaItemProps;\n props.schemaItemType = parseSchemaItemType((data as any).schemaItemType);\n props.customAttributes = props.customAttributes ? props.customAttributes.map((attr: any) => { return parseCustomAttribute(attr); }) : undefined;\n if (!props.customAttributes || props.customAttributes.length === 0)\n delete props.customAttributes;\n\n return props;\n }\n\n /**\n * Helper method to resolve the SchemaItem's full name from the given rawTypeName.\n * If the SchemaItem is defined in the same Schema from which it is referenced,\n * the rawTypeName will be SchemaItem name ('PhysicalElement'). Otherwise,\n * the rawTypeName will have the schema alias ('bis:PhysicalElement').\n * @param rawTypeName The name or aliased name of the SchemaItem.\n * @returns The full name of the SchemaItem, ie. 'BisCore.PhysicalElement'\n */\n public getQualifiedTypeName(rawTypeName: string): string {\n const nameParts = rawTypeName.split(\":\");\n if (nameParts.length !== 2) {\n const [schemaName, itemName] = SchemaItem.parseFullName(rawTypeName);\n if (!schemaName || schemaName === '')\n return `${this._schema}.${itemName}`;\n return rawTypeName;\n }\n\n const resolvedName = this.resolveNameFromAlias(nameParts[0].toLocaleLowerCase());\n if (!resolvedName)\n throw new Error(`No valid schema found for alias '${nameParts[0]}'`);\n\n return `${resolvedName}.${nameParts[1]}`;\n }\n\n private resolveNameFromAlias(alias: string): string | undefined {\n for (const schemaInfo of this._schemaInfos) {\n if (schemaInfo.alias === alias)\n return schemaInfo.schemaKey.name;\n }\n return undefined;\n }\n}\n\ntype MutableKindOfQuantityProps = {\n -readonly [K in keyof KindOfQuantityProps]: KindOfQuantityProps[K]\n};\n\n/**\n * Parses KindOfQuantityProps JSON returned from an ECSql query and returns the correct KindOfQuantityProps JSON.\n * This is necessary as a small amount information (ie. unqualified type names of presentationUnits) returned from\n * the iModelDb is in a different format than is required for a KindOfQuantityProps JSON object.\n * @internal\n */\nexport class KindOfQuantityParser extends SchemaItemParser {\n /**\n * Parses the given KindOfQuantityProps JSON returned from an ECSql query.\n * @param data The KindOfQuantityProps JSON as returned from an iModelDb.\n * @returns The corrected KindOfQuantityProps Json.\n */\n public override async parse(data: KindOfQuantityProps): Promise<KindOfQuantityProps> {\n const mutableProps = await super.parse(data) as MutableKindOfQuantityProps;\n\n if (mutableProps.persistenceUnit) {\n mutableProps.persistenceUnit = this.getQualifiedTypeName(mutableProps.persistenceUnit);\n }\n mutableProps.presentationUnits = this.parsePresentationUnits(mutableProps);\n\n return mutableProps;\n }\n\n private parsePresentationUnits(props: KindOfQuantityProps): string[] {\n const presentationUnits: string[] = [];\n if (!props.presentationUnits)\n return [];\n\n for (const presentationUnit of props.presentationUnits) {\n const presFormatOverride: OverrideFormatProps = OverrideFormat.parseFormatString(presentationUnit);\n const formatString = this.createOverrideFormatString(presFormatOverride);\n presentationUnits.push(formatString);\n };\n\n return presentationUnits;\n }\n\n private createOverrideFormatString(overrideFormatProps: OverrideFormatProps): string {\n\n let formatFullName = this.getQualifiedTypeName(overrideFormatProps.name);\n if (overrideFormatProps.precision)\n formatFullName += `(${overrideFormatProps.precision.toString()})`;\n\n if (undefined === overrideFormatProps.unitAndLabels)\n return formatFullName;\n\n for (const [unit, unitLabel] of overrideFormatProps.unitAndLabels) {\n const unitFullName = this.getQualifiedTypeName(unit);\n\n if (undefined === unitLabel)\n formatFullName += `[${unitFullName}]`;\n else\n formatFullName += `[${unitFullName}|${unitLabel}]`;\n }\n return formatFullName;\n }\n}"]}
|
|
@@ -21,10 +21,10 @@ SELECT
|
|
|
21
21
|
'name', [koq].[Name],
|
|
22
22
|
'label', [koq].[DisplayLabel],
|
|
23
23
|
'description', [koq].[Description]
|
|
24
|
-
${singleSchema ? `
|
|
25
24
|
,'relativeError', [koq].[RelativeError],
|
|
26
|
-
'persistenceUnit', [koq].[PersistenceUnit]
|
|
27
|
-
|
|
25
|
+
'persistenceUnit', [koq].[PersistenceUnit]
|
|
26
|
+
${singleSchema ? `
|
|
27
|
+
, 'presentationUnits', (
|
|
28
28
|
SELECT json_group_array(js."value")
|
|
29
29
|
FROM [meta].[KindOfQuantityDef] [koq1], json1.json_each([PresentationUnits]) js
|
|
30
30
|
WHERE [koq1].[ECInstanceId] = [koq].[ECInstanceId]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaItemQueries.js","sourceRoot":"","sources":["../../../src/IncrementalLoading/SchemaItemQueries.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG;;;qFAGqF;AAErF;;;GAGG;AACH,MAAM,cAAc,GAAG,CAAC,YAAsB,EAAE,EAAE,CAAC;;;;;;;;MAQ7C,YAAY,CAAC,CAAC,CAAC;;;;;;;OAOd,CAAA,CAAC,CAAC,EAAE;;;;EAIT,YAAY,CAAC,CAAC,CAAC;;;;CAIhB,CAAC,CAAC,CAAC,EAAE;CACL,CAAC;AAEF;;;GAGG;AACH,MAAM,gBAAgB,GAAG,CAAC,YAAsB,EAAE,EAAE,CAAC;;;;;;;;;;;;EAYnD,YAAY,CAAC,CAAC,CAAC;;;;CAIhB,CAAC,CAAC,CAAC,EAAE;CACL,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,GAAG,CAAC,YAAsB,EAAE,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;EAuB9C,YAAY,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;;;;;;;;;;MAoBf,CAAC,CAAC,CAAC,EAAE;;;;EAIT,YAAY,CAAC,CAAC,CAAC;;;oCAGmB,CAAC,CAAC,CAAC,EAAE;CACxC,CAAA;AAED;;;GAGG;AACH,gEAAgE;AACnD,QAAA,iBAAiB,GAAG;IAC/B,cAAc;IACd,gBAAgB;IAChB,WAAW;IACX,IAAI;IACJ,YAAY;IACZ,QAAQ;IACR,UAAU;IACV,UAAU;IACV,MAAM;CACP,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\n/************************************************************************************\n * All SchemaItem queries for each SchemaItemType are defined here. These queries\n * are shared for both 'partial schema' and 'full schema' queries.\n ***********************************************************************************/\n\n/**\n * Query for SchemaItemType KindOfQuantity data.\n * @param singleSchema Indicates if a filter and join for a single Schema should be applied.\n */\nconst kindOfQuantity = (singleSchema?: boolean) => `\nSELECT\n [koq].[Schema].[Id] AS [SchemaId],\n json_object (\n 'schemaItemType', 'KindOfQuantity',\n 'name', [koq].[Name],\n 'label', [koq].[DisplayLabel],\n 'description', [koq].[Description]\n ${singleSchema ? `\n ,'relativeError', [koq].[RelativeError],\n 'persistenceUnit', [koq].[PersistenceUnit],\n 'presentationUnits', (\n SELECT json_group_array(js.\"value\")\n FROM [meta].[KindOfQuantityDef] [koq1], json1.json_each([PresentationUnits]) js\n WHERE [koq1].[ECInstanceId] = [koq].[ECInstanceId]\n ) `: \"\"}\n ) as [item]\nFROM\n [meta].[KindOfQuantityDef] [koq]\n${singleSchema ? `\nJOIN\n [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [koq].[Schema].[Id]\nWHERE [schema].[Name] = :schemaName\n` : \"\"}\n`;\n\n/**\n * Query for SchemaItemType PropertyCategory data.\n * @param singleSchema Indicates if a filter and join for a single Schema should be applied.\n */\nconst propertyCategory = (singleSchema?: boolean) => `\nSELECT\n [pc].[Schema].[Id] AS [SchemaId],\n json_object (\n 'schemaItemType', 'PropertyCategory',\n 'name', [pc].[Name],\n 'label', [pc].[DisplayLabel],\n 'description', [pc].[Description],\n 'priority', [pc].[Priority]\n ) as [item]\nFROM\n [meta].[PropertyCategoryDef] [pc]\n${singleSchema ? `\nJOIN\n [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [pc].[Schema].[Id]\nWHERE [schema].[Name] = :schemaName\n` : \"\"}\n`;\n\n/**\n * Query for SchemaItemType Enumeration data.\n * @param singleSchema Indicates if a filter and join for a single Schema should be applied.\n */\nconst enumeration = (singleSchema?: boolean) => `\nSELECT\n [ed].[Schema].[Id] AS [SchemaId],\n json_object (\n 'schemaItemType', 'Enumeration',\n 'name', [ed].[Name],\n 'label', [ed].[DisplayLabel],\n 'description', [ed].[Description],\n 'type', IIF([ed].[Type] = 1281, 'int', IIF([ed].[Type] = 2305, 'string', null)),\n 'isStrict', IIF([ed].[IsStrict] = 1, json('true'), json('false')),\n 'enumerators', (\n SELECT json_group_array(json(json_object(\n 'name', json_extract(js.\"value\", '$.Name'),\n 'value', IFNULL(json_extract(js.\"value\", '$.StringValue'), (json_extract(js.\"value\", '$.IntValue'))),\n 'label', json_extract(js.\"value\", '$.DisplayLabel'),\n 'description', json_extract(js.\"value\", '$.Description')\n )))\n FROM [meta].[ECEnumerationDef] [enumerationDef], json1.json_each([EnumValues]) js\n WHERE [enumerationDef].[ECInstanceId] = [ed].[ECInstanceId]\n )\n ) as [item]\nFROM\n [meta].[ECEnumerationDef] [ed]\n${singleSchema ? `\nJOIN\n [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [ed].[Schema].[Id]\nWHERE [schema].[Name] = :schemaName` : \"\"}\n`;\n\n/**\n * Query for SchemaItemType Unit data.\n * @param singleSchema Indicates if a filter and join for a single Schema should be applied.\n */\nconst unit = (singleSchema?: boolean) => `\nSELECT\n [ud].[Schema].[Id] AS [SchemaId],\n json_object (\n 'schemaItemType', 'Unit',\n 'name', [ud].[Name],\n 'label', [ud].[DisplayLabel],\n 'description', [ud].[Description],\n 'definition', [ud].[Definition],\n 'numerator', IIF([ud].[Numerator] IS NULL, NULL, json(format('%.16g', [ud].[Numerator]))),\n 'denominator', IIF([ud].[Denominator] IS NULL, NULL, json(format('%.16g', [ud].[Denominator]))),\n 'offset', IIF([ud].[Offset] IS NULL, NULL, json(format('%!.15f', [ud].[Offset]))),\n 'unitSystem', CONCAT([uss].[Name],'.', [usd].[Name]),\n 'phenomenon', CONCAT([ps].[Name],'.', [pd].[Name])\n ) as item\nFROM\n [meta].[UnitDef] [ud]\n${singleSchema ? `\nJOIN\n [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [ud].[Schema].[Id]` : \"\"}\nJOIN [meta].[UnitSystemDef] [usd]\n ON [usd].[ECInstanceId] = [ud].[UnitSystem].[Id]\nJOIN [meta].[ECSchemaDef] [uss]\n ON [uss].[ECInstanceId] = [usd].[Schema].[Id]\nJOIN [meta].[PhenomenonDef] [pd]\n ON [pd].[ECInstanceId] = [ud].[Phenomenon].[Id]\nJOIN [meta].[ECSchemaDef] [ps]\n ON [ps].[ECInstanceId] = [pd].[Schema].[Id]\nWHERE\n ${singleSchema ? `\n [schema].[Name] = :schemaName AND` : \"\"}\n [ud].[IsConstant] = 0 AND\n [ud].[InvertingUnit] IS NULL\n`;\n\n/**\n * Query for SchemaItemType InvertedUnit data.\n * @param singleSchema Indicates if a filter and join for a single Schema should be applied.\n */\nconst invertedUnit = (singleSchema?: boolean) => `\nSELECT\n [ud].[Schema].[Id] AS [SchemaId],\n json_object (\n 'schemaItemType', 'InvertedUnit',\n 'name', [ud].[Name],\n 'label', [ud].[DisplayLabel],\n 'description', [ud].[Description],\n 'unitSystem', CONCAT([systemSchema].[Name],'.', [usd].[Name]),\n 'invertsUnit', IIF([iud].[Name] IS NULL, null, CONCAT([ius].[Name],'.', [iud].[Name]))\n ) as [item]\nFROM\n [meta].[UnitDef] [ud]\n${singleSchema ? `\nJOIN\n [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [ud].[Schema].[Id]` : \"\"}\nJOIN [meta].[UnitSystemDef] [usd]\n ON [usd].[ECInstanceId] = [ud].[UnitSystem].[Id]\nJOIN [meta].[ECSchemaDef] [systemSchema]\n ON [systemSchema].[ECInstanceId] = [usd].[Schema].[Id]\nLEFT JOIN [meta].[UnitDef] [iud]\n ON [iud].[ECInstanceId] = [ud].[InvertingUnit].[Id]\nLEFT JOIN [meta].[ECSchemaDef] [ius]\n ON [ius].[ECInstanceId] = [iud].[Schema].[Id]\nWHERE\n ${singleSchema ? `\n [schema].[Name] = :schemaName AND` : \"\"}\n [ud].[IsConstant] = 0 AND\n [ud].[InvertingUnit] IS NOT NULL\n`;\n\n/**\n * Query for SchemaItemType Constant data.\n * @param singleSchema Indicates if a filter and join for a single Schema should be applied.\n */\nconst constant = (singleSchema?: boolean) => `\nSELECT\n [cd].[Schema].[Id] AS [SchemaId],\n json_object(\n 'schemaItemType', 'Constant',\n 'name', [cd].[Name],\n 'label', [cd].[DisplayLabel],\n 'description', [cd].[Description],\n 'definition', [cd].[Definition],\n 'numerator', IIF([cd].[Numerator] IS NULL, NULL, json(format('%.16g', [cd].[Numerator]))),\n 'denominator', IIF([cd].[Denominator] IS NULL, NULL, json(format('%.16g', [cd].[Denominator]))),\n 'phenomenon', CONCAT([phenomSchema].[Name],'.', [phenomDef].[Name])\n ) as item\nFROM\n [meta].[UnitDef] [cd]\n${singleSchema ? `\nJOIN\n [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [cd].[Schema].[Id]` : \"\"}\nJOIN [meta].[PhenomenonDef] [phenomDef]\n ON [phenomDef].[ECInstanceId] = [cd].[Phenomenon].[Id]\nJOIN [meta].[ECSchemaDef] [phenomSchema]\n ON [phenomSchema].[ECInstanceId] = [phenomDef].[Schema].[Id]\nWHERE\n ${singleSchema ? `\n [schema].[Name] = :schemaName AND` : \"\"}\n [cd].[IsConstant] = 1\n`;\n\n/**\n * Query for SchemaItemType UnitSystem data.\n * @param singleSchema Indicates if a filter and join for a single Schema should be applied.\n */\nconst unitSystem = (singleSchema?: boolean) => `\nSELECT\n [us].[Schema].[Id] AS [SchemaId],\n json_object (\n 'schemaItemType', 'UnitSystem',\n 'name', [us].[Name],\n 'label', [us].[DisplayLabel],\n 'description', [us].[Description]\n ) as [item]\nFROM\n [meta].[UnitSystemDef] [us]\n${singleSchema ? `\nJOIN\n [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [us].[Schema].[Id]\nWHERE [schema].[Name] = :schemaName` : \"\"}\n`;\n\n/**\n * Query for SchemaItemType Phenomenon data.\n * @param singleSchema Indicates if a filter and join for a single Schema should be applied.\n */\nconst phenomenon = (singleSchema?: boolean) => `\nSELECT\n [pd].[Schema].[Id] AS [SchemaId],\n json_object(\n 'schemaItemType', 'Phenomenon',\n 'name', [pd].[Name],\n 'label', [pd].[DisplayLabel],\n 'description', [pd].[Description],\n 'definition', [pd].[Definition]\n ) as [item]\nFROM\n [meta].[PhenomenonDef] [pd]\n${singleSchema ? `\nJOIN\n [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [pd].[Schema].[Id]\nWHERE [schema].[Name] = :schemaName` : \"\"}\n`;\n\n/**\n * Query for SchemaItemType Format data.\n * @param singleSchema Indicates if a filter and join for a single Schema should be applied.\n */\nconst format = (singleSchema?: boolean) => `\nSELECT\n [fd].[Schema].[Id] AS [SchemaId],\n json_object(\n 'schemaItemType', 'Format',\n 'name', [fd].[Name],\n 'label', [fd].[DisplayLabel],\n 'description', [fd].[Description],\n 'type', json_extract([fd].[NumericSpec], '$.type'),\n 'precision', json_extract([fd].[NumericSpec], '$.precision'),\n 'roundFactor', json_extract([fd].[NumericSpec], '$.roundFactor'),\n 'minWidth', json_extract([fd].[NumericSpec], '$.minWidth'),\n 'showSignOption', json_extract([fd].[NumericSpec], '$.showSignOption'),\n 'decimalSeparator', json_extract([fd].[NumericSpec], '$.decimalSeparator'),\n 'thousandSeparator', json_extract([fd].[NumericSpec], '$.thousandSeparator'),\n 'uomSeparator', json_extract([fd].[NumericSpec], '$.uomSeparator'),\n 'scientificType', json_extract([fd].[NumericSpec], '$.scientificType'),\n 'stationOffsetSize', json_extract([fd].[NumericSpec], '$.stationOffsetSize'),\n 'stationSeparator', json_extract([fd].[NumericSpec], '$.stationSeparator'),\n 'formatTraits', json_extract([fd].[NumericSpec], '$.formatTraits')\n ${singleSchema ? `\n ,'composite', (\n SELECT\n json_object(\n 'spacer', json_extract([fd1].[CompositeSpec], '$.spacer'),\n 'includeZero', json(IIF(json_extract([fd1].[CompositeSpec], '$.includeZero') = 1, 'true', IIF(json_extract([fd1].[CompositeSpec], '$.includeZero') = 0, 'false', null))),\n 'units', (\n SELECT json_group_array(json(json_object(\n 'name', CONCAT([sd].[Name], '.', [ud].[Name]),\n 'label', [fud].[Label]\n )))\n FROM [meta].[FormatDef] [fd2]\n LEFT JOIN [meta].[FormatCompositeUnitDef] [fud] ON [fud].[Format].[Id] = [fd2].[ECInstanceId]\n LEFT JOIN [meta].[UnitDef] [ud] ON [ud].[ECInstanceId] = [fud].[Unit].[Id]\n INNER JOIN [meta].[ECSchemaDef] [sd] ON [sd].[ECInstanceId] = [ud].[Schema].[Id]\n WHERE [fd2].[ECInstanceId] = [fd1].[ECInstanceId]\n )\n )\n FROM [meta].[FormatDef] [fd1]\n WHERE [fd1].[ECInstanceId]= [fd].[ECInstanceId] AND [fd1].[CompositeSpec] IS NOT NULL\n )` : \"\"}\n) AS item\nFROM\n [meta].[FormatDef] [fd]\n${singleSchema ? `\nJOIN\n [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [fd].[Schema].[Id]\nWHERE [schema].[Name] = :schemaName` : \"\"}\n`\n\n/**\n * Queries for each SchemaItemType\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const SchemaItemQueries = {\n kindOfQuantity,\n propertyCategory,\n enumeration,\n unit,\n invertedUnit,\n constant,\n unitSystem,\n phenomenon,\n format\n};\n"]}
|
|
1
|
+
{"version":3,"file":"SchemaItemQueries.js","sourceRoot":"","sources":["../../../src/IncrementalLoading/SchemaItemQueries.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG;;;qFAGqF;AAErF;;;GAGG;AACH,MAAM,cAAc,GAAG,CAAC,YAAsB,EAAE,EAAE,CAAC;;;;;;;;;;MAU7C,YAAY,CAAC,CAAC,CAAC;;;;;OAKd,CAAA,CAAC,CAAC,EAAE;;;;EAIT,YAAY,CAAC,CAAC,CAAC;;;;CAIhB,CAAC,CAAC,CAAC,EAAE;CACL,CAAC;AAEF;;;GAGG;AACH,MAAM,gBAAgB,GAAG,CAAC,YAAsB,EAAE,EAAE,CAAC;;;;;;;;;;;;EAYnD,YAAY,CAAC,CAAC,CAAC;;;;CAIhB,CAAC,CAAC,CAAC,EAAE;CACL,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,GAAG,CAAC,YAAsB,EAAE,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;EAuB9C,YAAY,CAAC,CAAC,CAAC;;;oCAGmB,CAAC,CAAC,CAAC,EAAE;CACxC,CAAC;AAEF;;;GAGG;AACH,MAAM,IAAI,GAAG,CAAC,YAAsB,EAAE,EAAE,CAAC;;;;;;;;;;;;;;;;;EAiBvC,YAAY,CAAC,CAAC,CAAC;;gFAE+D,CAAC,CAAC,CAAC,EAAE;;;;;;;;;;IAUjF,YAAY,CAAC,CAAC,CAAC;oCACiB,CAAC,CAAC,CAAC,EAAE;;;CAGxC,CAAC;AAEF;;;GAGG;AACH,MAAM,YAAY,GAAG,CAAC,YAAsB,EAAE,EAAE,CAAC;;;;;;;;;;;;;EAa/C,YAAY,CAAC,CAAC,CAAC;;gFAE+D,CAAC,CAAC,CAAC,EAAE;;;;;;;;;;IAUjF,YAAY,CAAC,CAAC,CAAC;oCACiB,CAAC,CAAC,CAAC,EAAE;;;CAGxC,CAAC;AAEF;;;GAGG;AACH,MAAM,QAAQ,GAAG,CAAC,YAAsB,EAAE,EAAE,CAAC;;;;;;;;;;;;;;;EAe3C,YAAY,CAAC,CAAC,CAAC;;gFAE+D,CAAC,CAAC,CAAC,EAAE;;;;;;IAMjF,YAAY,CAAC,CAAC,CAAC;oCACiB,CAAC,CAAC,CAAC,EAAE;;CAExC,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,GAAG,CAAC,YAAsB,EAAE,EAAE,CAAC;;;;;;;;;;;EAW7C,YAAY,CAAC,CAAC,CAAC;;;oCAGmB,CAAC,CAAC,CAAC,EAAE;CACxC,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,GAAG,CAAC,YAAsB,EAAE,EAAE,CAAC;;;;;;;;;;;;EAY7C,YAAY,CAAC,CAAC,CAAC;;;oCAGmB,CAAC,CAAC,CAAC,EAAE;CACxC,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,GAAG,CAAC,YAAsB,EAAE,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;MAoBrC,YAAY,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;MAoBf,CAAC,CAAC,CAAC,EAAE;;;;EAIT,YAAY,CAAC,CAAC,CAAC;;;oCAGmB,CAAC,CAAC,CAAC,EAAE;CACxC,CAAA;AAED;;;GAGG;AACH,gEAAgE;AACnD,QAAA,iBAAiB,GAAG;IAC/B,cAAc;IACd,gBAAgB;IAChB,WAAW;IACX,IAAI;IACJ,YAAY;IACZ,QAAQ;IACR,UAAU;IACV,UAAU;IACV,MAAM;CACP,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\n/************************************************************************************\n * All SchemaItem queries for each SchemaItemType are defined here. These queries\n * are shared for both 'partial schema' and 'full schema' queries.\n ***********************************************************************************/\n\n/**\n * Query for SchemaItemType KindOfQuantity data.\n * @param singleSchema Indicates if a filter and join for a single Schema should be applied.\n */\nconst kindOfQuantity = (singleSchema?: boolean) => `\nSELECT\n [koq].[Schema].[Id] AS [SchemaId],\n json_object (\n 'schemaItemType', 'KindOfQuantity',\n 'name', [koq].[Name],\n 'label', [koq].[DisplayLabel],\n 'description', [koq].[Description]\n ,'relativeError', [koq].[RelativeError],\n 'persistenceUnit', [koq].[PersistenceUnit]\n ${singleSchema ? `\n , 'presentationUnits', (\n SELECT json_group_array(js.\"value\")\n FROM [meta].[KindOfQuantityDef] [koq1], json1.json_each([PresentationUnits]) js\n WHERE [koq1].[ECInstanceId] = [koq].[ECInstanceId]\n ) `: \"\"}\n ) as [item]\nFROM\n [meta].[KindOfQuantityDef] [koq]\n${singleSchema ? `\nJOIN\n [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [koq].[Schema].[Id]\nWHERE [schema].[Name] = :schemaName\n` : \"\"}\n`;\n\n/**\n * Query for SchemaItemType PropertyCategory data.\n * @param singleSchema Indicates if a filter and join for a single Schema should be applied.\n */\nconst propertyCategory = (singleSchema?: boolean) => `\nSELECT\n [pc].[Schema].[Id] AS [SchemaId],\n json_object (\n 'schemaItemType', 'PropertyCategory',\n 'name', [pc].[Name],\n 'label', [pc].[DisplayLabel],\n 'description', [pc].[Description],\n 'priority', [pc].[Priority]\n ) as [item]\nFROM\n [meta].[PropertyCategoryDef] [pc]\n${singleSchema ? `\nJOIN\n [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [pc].[Schema].[Id]\nWHERE [schema].[Name] = :schemaName\n` : \"\"}\n`;\n\n/**\n * Query for SchemaItemType Enumeration data.\n * @param singleSchema Indicates if a filter and join for a single Schema should be applied.\n */\nconst enumeration = (singleSchema?: boolean) => `\nSELECT\n [ed].[Schema].[Id] AS [SchemaId],\n json_object (\n 'schemaItemType', 'Enumeration',\n 'name', [ed].[Name],\n 'label', [ed].[DisplayLabel],\n 'description', [ed].[Description],\n 'type', IIF([ed].[Type] = 1281, 'int', IIF([ed].[Type] = 2305, 'string', null)),\n 'isStrict', IIF([ed].[IsStrict] = 1, json('true'), json('false')),\n 'enumerators', (\n SELECT json_group_array(json(json_object(\n 'name', json_extract(js.\"value\", '$.Name'),\n 'value', IFNULL(json_extract(js.\"value\", '$.StringValue'), (json_extract(js.\"value\", '$.IntValue'))),\n 'label', json_extract(js.\"value\", '$.DisplayLabel'),\n 'description', json_extract(js.\"value\", '$.Description')\n )))\n FROM [meta].[ECEnumerationDef] [enumerationDef], json1.json_each([EnumValues]) js\n WHERE [enumerationDef].[ECInstanceId] = [ed].[ECInstanceId]\n )\n ) as [item]\nFROM\n [meta].[ECEnumerationDef] [ed]\n${singleSchema ? `\nJOIN\n [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [ed].[Schema].[Id]\nWHERE [schema].[Name] = :schemaName` : \"\"}\n`;\n\n/**\n * Query for SchemaItemType Unit data.\n * @param singleSchema Indicates if a filter and join for a single Schema should be applied.\n */\nconst unit = (singleSchema?: boolean) => `\nSELECT\n [ud].[Schema].[Id] AS [SchemaId],\n json_object (\n 'schemaItemType', 'Unit',\n 'name', [ud].[Name],\n 'label', [ud].[DisplayLabel],\n 'description', [ud].[Description],\n 'definition', [ud].[Definition],\n 'numerator', IIF([ud].[Numerator] IS NULL, NULL, json(format('%.16g', [ud].[Numerator]))),\n 'denominator', IIF([ud].[Denominator] IS NULL, NULL, json(format('%.16g', [ud].[Denominator]))),\n 'offset', IIF([ud].[Offset] IS NULL, NULL, json(format('%!.15f', [ud].[Offset]))),\n 'unitSystem', CONCAT([uss].[Name],'.', [usd].[Name]),\n 'phenomenon', CONCAT([ps].[Name],'.', [pd].[Name])\n ) as item\nFROM\n [meta].[UnitDef] [ud]\n${singleSchema ? `\nJOIN\n [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [ud].[Schema].[Id]` : \"\"}\nJOIN [meta].[UnitSystemDef] [usd]\n ON [usd].[ECInstanceId] = [ud].[UnitSystem].[Id]\nJOIN [meta].[ECSchemaDef] [uss]\n ON [uss].[ECInstanceId] = [usd].[Schema].[Id]\nJOIN [meta].[PhenomenonDef] [pd]\n ON [pd].[ECInstanceId] = [ud].[Phenomenon].[Id]\nJOIN [meta].[ECSchemaDef] [ps]\n ON [ps].[ECInstanceId] = [pd].[Schema].[Id]\nWHERE\n ${singleSchema ? `\n [schema].[Name] = :schemaName AND` : \"\"}\n [ud].[IsConstant] = 0 AND\n [ud].[InvertingUnit] IS NULL\n`;\n\n/**\n * Query for SchemaItemType InvertedUnit data.\n * @param singleSchema Indicates if a filter and join for a single Schema should be applied.\n */\nconst invertedUnit = (singleSchema?: boolean) => `\nSELECT\n [ud].[Schema].[Id] AS [SchemaId],\n json_object (\n 'schemaItemType', 'InvertedUnit',\n 'name', [ud].[Name],\n 'label', [ud].[DisplayLabel],\n 'description', [ud].[Description],\n 'unitSystem', CONCAT([systemSchema].[Name],'.', [usd].[Name]),\n 'invertsUnit', IIF([iud].[Name] IS NULL, null, CONCAT([ius].[Name],'.', [iud].[Name]))\n ) as [item]\nFROM\n [meta].[UnitDef] [ud]\n${singleSchema ? `\nJOIN\n [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [ud].[Schema].[Id]` : \"\"}\nJOIN [meta].[UnitSystemDef] [usd]\n ON [usd].[ECInstanceId] = [ud].[UnitSystem].[Id]\nJOIN [meta].[ECSchemaDef] [systemSchema]\n ON [systemSchema].[ECInstanceId] = [usd].[Schema].[Id]\nLEFT JOIN [meta].[UnitDef] [iud]\n ON [iud].[ECInstanceId] = [ud].[InvertingUnit].[Id]\nLEFT JOIN [meta].[ECSchemaDef] [ius]\n ON [ius].[ECInstanceId] = [iud].[Schema].[Id]\nWHERE\n ${singleSchema ? `\n [schema].[Name] = :schemaName AND` : \"\"}\n [ud].[IsConstant] = 0 AND\n [ud].[InvertingUnit] IS NOT NULL\n`;\n\n/**\n * Query for SchemaItemType Constant data.\n * @param singleSchema Indicates if a filter and join for a single Schema should be applied.\n */\nconst constant = (singleSchema?: boolean) => `\nSELECT\n [cd].[Schema].[Id] AS [SchemaId],\n json_object(\n 'schemaItemType', 'Constant',\n 'name', [cd].[Name],\n 'label', [cd].[DisplayLabel],\n 'description', [cd].[Description],\n 'definition', [cd].[Definition],\n 'numerator', IIF([cd].[Numerator] IS NULL, NULL, json(format('%.16g', [cd].[Numerator]))),\n 'denominator', IIF([cd].[Denominator] IS NULL, NULL, json(format('%.16g', [cd].[Denominator]))),\n 'phenomenon', CONCAT([phenomSchema].[Name],'.', [phenomDef].[Name])\n ) as item\nFROM\n [meta].[UnitDef] [cd]\n${singleSchema ? `\nJOIN\n [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [cd].[Schema].[Id]` : \"\"}\nJOIN [meta].[PhenomenonDef] [phenomDef]\n ON [phenomDef].[ECInstanceId] = [cd].[Phenomenon].[Id]\nJOIN [meta].[ECSchemaDef] [phenomSchema]\n ON [phenomSchema].[ECInstanceId] = [phenomDef].[Schema].[Id]\nWHERE\n ${singleSchema ? `\n [schema].[Name] = :schemaName AND` : \"\"}\n [cd].[IsConstant] = 1\n`;\n\n/**\n * Query for SchemaItemType UnitSystem data.\n * @param singleSchema Indicates if a filter and join for a single Schema should be applied.\n */\nconst unitSystem = (singleSchema?: boolean) => `\nSELECT\n [us].[Schema].[Id] AS [SchemaId],\n json_object (\n 'schemaItemType', 'UnitSystem',\n 'name', [us].[Name],\n 'label', [us].[DisplayLabel],\n 'description', [us].[Description]\n ) as [item]\nFROM\n [meta].[UnitSystemDef] [us]\n${singleSchema ? `\nJOIN\n [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [us].[Schema].[Id]\nWHERE [schema].[Name] = :schemaName` : \"\"}\n`;\n\n/**\n * Query for SchemaItemType Phenomenon data.\n * @param singleSchema Indicates if a filter and join for a single Schema should be applied.\n */\nconst phenomenon = (singleSchema?: boolean) => `\nSELECT\n [pd].[Schema].[Id] AS [SchemaId],\n json_object(\n 'schemaItemType', 'Phenomenon',\n 'name', [pd].[Name],\n 'label', [pd].[DisplayLabel],\n 'description', [pd].[Description],\n 'definition', [pd].[Definition]\n ) as [item]\nFROM\n [meta].[PhenomenonDef] [pd]\n${singleSchema ? `\nJOIN\n [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [pd].[Schema].[Id]\nWHERE [schema].[Name] = :schemaName` : \"\"}\n`;\n\n/**\n * Query for SchemaItemType Format data.\n * @param singleSchema Indicates if a filter and join for a single Schema should be applied.\n */\nconst format = (singleSchema?: boolean) => `\nSELECT\n [fd].[Schema].[Id] AS [SchemaId],\n json_object(\n 'schemaItemType', 'Format',\n 'name', [fd].[Name],\n 'label', [fd].[DisplayLabel],\n 'description', [fd].[Description],\n 'type', json_extract([fd].[NumericSpec], '$.type'),\n 'precision', json_extract([fd].[NumericSpec], '$.precision'),\n 'roundFactor', json_extract([fd].[NumericSpec], '$.roundFactor'),\n 'minWidth', json_extract([fd].[NumericSpec], '$.minWidth'),\n 'showSignOption', json_extract([fd].[NumericSpec], '$.showSignOption'),\n 'decimalSeparator', json_extract([fd].[NumericSpec], '$.decimalSeparator'),\n 'thousandSeparator', json_extract([fd].[NumericSpec], '$.thousandSeparator'),\n 'uomSeparator', json_extract([fd].[NumericSpec], '$.uomSeparator'),\n 'scientificType', json_extract([fd].[NumericSpec], '$.scientificType'),\n 'stationOffsetSize', json_extract([fd].[NumericSpec], '$.stationOffsetSize'),\n 'stationSeparator', json_extract([fd].[NumericSpec], '$.stationSeparator'),\n 'formatTraits', json_extract([fd].[NumericSpec], '$.formatTraits')\n ${singleSchema ? `\n ,'composite', (\n SELECT\n json_object(\n 'spacer', json_extract([fd1].[CompositeSpec], '$.spacer'),\n 'includeZero', json(IIF(json_extract([fd1].[CompositeSpec], '$.includeZero') = 1, 'true', IIF(json_extract([fd1].[CompositeSpec], '$.includeZero') = 0, 'false', null))),\n 'units', (\n SELECT json_group_array(json(json_object(\n 'name', CONCAT([sd].[Name], '.', [ud].[Name]),\n 'label', [fud].[Label]\n )))\n FROM [meta].[FormatDef] [fd2]\n LEFT JOIN [meta].[FormatCompositeUnitDef] [fud] ON [fud].[Format].[Id] = [fd2].[ECInstanceId]\n LEFT JOIN [meta].[UnitDef] [ud] ON [ud].[ECInstanceId] = [fud].[Unit].[Id]\n INNER JOIN [meta].[ECSchemaDef] [sd] ON [sd].[ECInstanceId] = [ud].[Schema].[Id]\n WHERE [fd2].[ECInstanceId] = [fd1].[ECInstanceId]\n )\n )\n FROM [meta].[FormatDef] [fd1]\n WHERE [fd1].[ECInstanceId]= [fd].[ECInstanceId] AND [fd1].[CompositeSpec] IS NOT NULL\n )` : \"\"}\n) AS item\nFROM\n [meta].[FormatDef] [fd]\n${singleSchema ? `\nJOIN\n [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [fd].[Schema].[Id]\nWHERE [schema].[Name] = :schemaName` : \"\"}\n`\n\n/**\n * Queries for each SchemaItemType\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const SchemaItemQueries = {\n kindOfQuantity,\n propertyCategory,\n enumeration,\n unit,\n invertedUnit,\n constant,\n unitSystem,\n phenomenon,\n format\n};\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SchemaContext } from "../Context";
|
|
2
1
|
import { SchemaItemProps, SchemaProps } from "../Deserialization/JsonProps";
|
|
2
|
+
import { SchemaInfo } from "../Interfaces";
|
|
3
3
|
import { CustomAttribute } from "../Metadata/CustomAttribute";
|
|
4
4
|
/**
|
|
5
5
|
* Parses SchemaProps JSON returned from an ECSql query and returns the correct SchemaProps JSON object.
|
|
@@ -16,7 +16,7 @@ export declare class SchemaParser {
|
|
|
16
16
|
* @param context The SchemaContext that will contain the schema and it's references.
|
|
17
17
|
* @returns The corrected SchemaProps JSON.
|
|
18
18
|
*/
|
|
19
|
-
static parse(schema: SchemaProps,
|
|
19
|
+
static parse(schema: SchemaProps, schemaInfos: Iterable<SchemaInfo>): Promise<SchemaProps>;
|
|
20
20
|
/**
|
|
21
21
|
* Parse the given SchemaItemProps array, as returned from an ECSql query, and returns the corrected SchemaItemProps.
|
|
22
22
|
* @param schemaItems The SchemaItemProps array returned from an iModelDb.
|
|
@@ -24,9 +24,9 @@ export declare class SchemaParser {
|
|
|
24
24
|
* @param context The SchemaContext containing the Schema.
|
|
25
25
|
* @returns The corrected SchemaItemProps.
|
|
26
26
|
*/
|
|
27
|
-
static parseSchemaItems(schemaItems: readonly SchemaItemProps[], schemaName: string,
|
|
27
|
+
static parseSchemaItems(schemaItems: readonly SchemaItemProps[], schemaName: string, schemaInfos: Iterable<SchemaInfo>): Promise<SchemaItemProps[] | undefined>;
|
|
28
28
|
private static parseItems;
|
|
29
|
-
static parseItem(props: SchemaItemProps, schemaName: string,
|
|
29
|
+
static parseItem(props: SchemaItemProps, schemaName: string, schemaInfos: Iterable<SchemaInfo>): Promise<SchemaItemProps>;
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* Utility method to parse CustomAttribute data retrieved from a ECSql query.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaParser.d.ts","sourceRoot":"","sources":["../../../src/IncrementalLoading/SchemaParser.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"SchemaParser.d.ts","sourceRoot":"","sources":["../../../src/IncrementalLoading/SchemaParser.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE5E,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAY9D;;;;;;GAMG;AACH,qBAAa,YAAY;IACvB;;;;;;OAMG;WACiB,KAAK,CAAC,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC;IAiBvG;;;;;;OAMG;WACiB,gBAAgB,CAAC,WAAW,EAAE,SAAS,eAAe,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,eAAe,EAAE,GAAG,SAAS,CAAC;mBAUvJ,UAAU;WAWX,SAAS,CAAC,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC;CAyBvI;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,eAAe,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAA,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAAC;CAAE,GAAG,eAAe,CAKrI"}
|
|
@@ -28,14 +28,14 @@ class SchemaParser {
|
|
|
28
28
|
* @param context The SchemaContext that will contain the schema and it's references.
|
|
29
29
|
* @returns The corrected SchemaProps JSON.
|
|
30
30
|
*/
|
|
31
|
-
static async parse(schema,
|
|
31
|
+
static async parse(schema, schemaInfos) {
|
|
32
32
|
const props = schema;
|
|
33
33
|
props.$schema = Constants_1.ECSchemaNamespaceUris.SCHEMAURL3_2_JSON,
|
|
34
34
|
props.customAttributes = props.customAttributes ? props.customAttributes.map((attr) => { return parseCustomAttribute(attr); }) : undefined;
|
|
35
35
|
props.label = props.label === null ? undefined : props.label;
|
|
36
36
|
props.description = props.description === null ? undefined : props.description;
|
|
37
37
|
if (props.items) {
|
|
38
|
-
props.items = await this.parseItems(props.items, props.name,
|
|
38
|
+
props.items = await this.parseItems(props.items, props.name, schemaInfos);
|
|
39
39
|
}
|
|
40
40
|
if (!props.customAttributes || props.customAttributes.length === 0)
|
|
41
41
|
delete props.customAttributes;
|
|
@@ -49,46 +49,46 @@ class SchemaParser {
|
|
|
49
49
|
* @param context The SchemaContext containing the Schema.
|
|
50
50
|
* @returns The corrected SchemaItemProps.
|
|
51
51
|
*/
|
|
52
|
-
static async parseSchemaItems(schemaItems, schemaName,
|
|
52
|
+
static async parseSchemaItems(schemaItems, schemaName, schemaInfos) {
|
|
53
53
|
const items = [];
|
|
54
54
|
for (const item of schemaItems) {
|
|
55
|
-
const props = await this.parseItem(item, schemaName,
|
|
55
|
+
const props = await this.parseItem(item, schemaName, schemaInfos);
|
|
56
56
|
const cleaned = JSON.parse(JSON.stringify(props, clean));
|
|
57
57
|
items.push(cleaned);
|
|
58
58
|
}
|
|
59
59
|
return items.length > 0 ? items : undefined;
|
|
60
60
|
}
|
|
61
|
-
static async parseItems(schemaItemProps, schemaName,
|
|
61
|
+
static async parseItems(schemaItemProps, schemaName, schemaInfos) {
|
|
62
62
|
const items = {};
|
|
63
63
|
for (const itemProps of schemaItemProps) {
|
|
64
|
-
const props = await this.parseItem(itemProps, schemaName,
|
|
64
|
+
const props = await this.parseItem(itemProps, schemaName, schemaInfos);
|
|
65
65
|
items[props.name] = props;
|
|
66
66
|
delete props.name;
|
|
67
67
|
}
|
|
68
68
|
return Object.keys(items).length > 0 ? items : undefined;
|
|
69
69
|
}
|
|
70
|
-
static async parseItem(props, schemaName,
|
|
70
|
+
static async parseItem(props, schemaName, schemaInfos) {
|
|
71
71
|
const schemaItem = "string" === typeof (props) ? JSON.parse(props) : props;
|
|
72
72
|
const type = (0, ECObjects_1.parseSchemaItemType)(schemaItem.schemaItemType);
|
|
73
73
|
switch (type) {
|
|
74
74
|
case ECObjects_1.SchemaItemType.KindOfQuantity:
|
|
75
|
-
const koqParser = new SchemaItemParsers_1.KindOfQuantityParser(schemaName,
|
|
75
|
+
const koqParser = new SchemaItemParsers_1.KindOfQuantityParser(schemaName, schemaInfos);
|
|
76
76
|
return koqParser.parse(schemaItem);
|
|
77
77
|
case ECObjects_1.SchemaItemType.EntityClass:
|
|
78
78
|
case ECObjects_1.SchemaItemType.StructClass:
|
|
79
|
-
const classParser = new ClassParsers_1.ClassParser(schemaName,
|
|
79
|
+
const classParser = new ClassParsers_1.ClassParser(schemaName, schemaInfos);
|
|
80
80
|
return classParser.parse(schemaItem);
|
|
81
81
|
case ECObjects_1.SchemaItemType.RelationshipClass:
|
|
82
|
-
const relationshipParser = new ClassParsers_1.RelationshipClassParser(schemaName,
|
|
82
|
+
const relationshipParser = new ClassParsers_1.RelationshipClassParser(schemaName, schemaInfos);
|
|
83
83
|
return relationshipParser.parse(schemaItem);
|
|
84
84
|
case ECObjects_1.SchemaItemType.Mixin:
|
|
85
|
-
const mixinParser = new ClassParsers_1.MixinParser(schemaName,
|
|
85
|
+
const mixinParser = new ClassParsers_1.MixinParser(schemaName, schemaInfos);
|
|
86
86
|
return mixinParser.parse(schemaItem);
|
|
87
87
|
case ECObjects_1.SchemaItemType.CustomAttributeClass:
|
|
88
|
-
const caParser = new ClassParsers_1.CustomAttributeClassParser(schemaName,
|
|
88
|
+
const caParser = new ClassParsers_1.CustomAttributeClassParser(schemaName, schemaInfos);
|
|
89
89
|
return caParser.parse(schemaItem);
|
|
90
90
|
default:
|
|
91
|
-
const itemParser = new SchemaItemParsers_1.SchemaItemParser(schemaName,
|
|
91
|
+
const itemParser = new SchemaItemParsers_1.SchemaItemParser(schemaName, schemaInfos);
|
|
92
92
|
return itemParser.parse(schemaItem);
|
|
93
93
|
}
|
|
94
94
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaParser.js","sourceRoot":"","sources":["../../../src/IncrementalLoading/SchemaParser.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AA+GhG,oDAKC;AAlHD,4CAAqD;
|
|
1
|
+
{"version":3,"file":"SchemaParser.js","sourceRoot":"","sources":["../../../src/IncrementalLoading/SchemaParser.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AA+GhG,oDAKC;AAlHD,4CAAqD;AAErD,4CAAmE;AAGnE,iDAA+G;AAC/G,2DAA6E;AAE7E,SAAS,KAAK,CAAC,IAAY,EAAE,KAAU;IACrC,OAAO,KAAK,KAAK,IAAI,CAAC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AO;QACL,GAAG,eAAe,CAAC,eAAe,CAAC,OAAO,CAAC;QAC3C,SAAS,EAAE,GAAG,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,eAAe,CAAC,OAAO,EAAE;KACpF,CAAA;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 { ECSchemaNamespaceUris } from \"../Constants\";\nimport { SchemaItemProps, SchemaProps } from \"../Deserialization/JsonProps\";\nimport { parseSchemaItemType, SchemaItemType } from \"../ECObjects\";\nimport { SchemaInfo } from \"../Interfaces\";\nimport { CustomAttribute } from \"../Metadata/CustomAttribute\";\nimport { ClassParser, CustomAttributeClassParser, MixinParser, RelationshipClassParser } from \"./ClassParsers\";\nimport { KindOfQuantityParser, SchemaItemParser } from \"./SchemaItemParsers\";\n\nfunction clean(_key: string, value: any) {\n return value === null ? undefined : value;\n}\n\ntype MutableSchemaProps = {\n -readonly [K in keyof SchemaProps]: SchemaProps[K]\n};\n\n/**\n * Parses SchemaProps JSON returned from an ECSql query and returns the correct SchemaProps JSON object.\n * This is necessary as a small amount information (ie. CustomAttributes, unqualified type names, etc.)\n * returned from the iModelDb is in a different format than is required for a given Schema or\n * SchemaItemProps JSON object.\n * @internal\n */\nexport class SchemaParser {\n /**\n * Corrects the SchemaProps JSON returned from the query to a proper SchemaProps\n * JSON object.\n * @param schema The SchemaProps JSON object to parse.\n * @param context The SchemaContext that will contain the schema and it's references.\n * @returns The corrected SchemaProps JSON.\n */\n public static async parse(schema: SchemaProps, schemaInfos: Iterable<SchemaInfo>): Promise<SchemaProps> {\n const props = schema as MutableSchemaProps;\n props.$schema = ECSchemaNamespaceUris.SCHEMAURL3_2_JSON,\n props.customAttributes = props.customAttributes ? props.customAttributes.map((attr: any) => { return parseCustomAttribute(attr); }) : undefined;\n props.label = props.label === null ? undefined : props.label;\n props.description = props.description === null ? undefined : props.description;\n if (props.items) {\n props.items = await this.parseItems(props.items as any, props.name, schemaInfos);\n }\n\n if (!props.customAttributes || props.customAttributes.length === 0)\n delete props.customAttributes;\n\n const cleaned = JSON.parse(JSON.stringify(props, clean)) as SchemaProps;\n return cleaned;\n }\n\n /**\n * Parse the given SchemaItemProps array, as returned from an ECSql query, and returns the corrected SchemaItemProps.\n * @param schemaItems The SchemaItemProps array returned from an iModelDb.\n * @param schemaName The name of the Schema to which the SchemaItemProps belong.\n * @param context The SchemaContext containing the Schema.\n * @returns The corrected SchemaItemProps.\n */\n public static async parseSchemaItems(schemaItems: readonly SchemaItemProps[], schemaName: string, schemaInfos: Iterable<SchemaInfo>): Promise<SchemaItemProps[] | undefined> {\n const items: SchemaItemProps[] = [];\n for (const item of schemaItems) {\n const props = await this.parseItem(item, schemaName, schemaInfos);\n const cleaned = JSON.parse(JSON.stringify(props, clean));\n items.push(cleaned);\n }\n return items.length > 0 ? items : undefined;\n }\n\n private static async parseItems(schemaItemProps: readonly SchemaItemProps[], schemaName: string, schemaInfos: Iterable<SchemaInfo>): Promise<{ [name: string]: SchemaItemProps } | undefined> {\n const items: { [name: string]: SchemaItemProps } = {};\n for (const itemProps of schemaItemProps) {\n const props = await this.parseItem(itemProps, schemaName, schemaInfos);\n items[props.name!] = props;\n delete (props as any).name;\n }\n\n return Object.keys(items).length > 0 ? items : undefined;\n }\n\n public static async parseItem(props: SchemaItemProps, schemaName: string, schemaInfos: Iterable<SchemaInfo>): Promise<SchemaItemProps> {\n const schemaItem = \"string\" === typeof (props) ? JSON.parse(props) : props;\n const type = parseSchemaItemType(schemaItem.schemaItemType);\n switch (type) {\n case SchemaItemType.KindOfQuantity:\n const koqParser = new KindOfQuantityParser(schemaName, schemaInfos);\n return koqParser.parse(schemaItem);\n case SchemaItemType.EntityClass:\n case SchemaItemType.StructClass:\n const classParser = new ClassParser(schemaName, schemaInfos);\n return classParser.parse(schemaItem);\n case SchemaItemType.RelationshipClass:\n const relationshipParser = new RelationshipClassParser(schemaName, schemaInfos);\n return relationshipParser.parse(schemaItem);\n case SchemaItemType.Mixin:\n const mixinParser = new MixinParser(schemaName, schemaInfos);\n return mixinParser.parse(schemaItem);\n case SchemaItemType.CustomAttributeClass:\n const caParser = new CustomAttributeClassParser(schemaName, schemaInfos);\n return caParser.parse(schemaItem);\n default:\n const itemParser = new SchemaItemParser(schemaName, schemaInfos);\n return itemParser.parse(schemaItem);\n }\n }\n}\n\n/**\n * Utility method to parse CustomAttribute data retrieved from a ECSql query.\n * @param customAttribute CustomAttribute data as retrieved from an iModel query.\n * @returns The CustomAttribute instance.\n * @internal\n */\nexport function parseCustomAttribute(customAttribute: { ecClass: string; ecSchema: string;[propName: string]: any; }): CustomAttribute {\n return {\n ...customAttribute[customAttribute.ecClass],\n className: `${(customAttribute.ecSchema).split('.')[0]}.${customAttribute.ecClass}`,\n }\n}"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KindOfQuantity.d.ts","sourceRoot":"","sources":["../../../src/Metadata/KindOfQuantity.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACzF,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,cAAc,EAAuB,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C;;GAEG;AACH,qBAAa,cAAe,SAAQ,UAAU;IAC5C,SAAyB,cAAc,iBAAiC;IACxE,gBAAgB;IAChB,WAA2B,cAAc,mBAA4C;IACrF,OAAO,CAAC,cAAc,CAAe;IACrC,OAAO,CAAC,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QAAQ,CAAC,mBAAmB,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvF;;;OAGG;IACH,SAAS,CAAC,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI;IAIvD;;;OAGG;IACH,SAAS,CAAC,kBAAkB,CAAC,KAAK,EAAE,cAAc,GAAG,sBAAsB,GAAG,SAAS,GAAG,IAAI;IAI9F;;;;OAIG;WACW,gBAAgB,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI,IAAI,cAAc;IAOzE;;;;;OAKG;WACW,sBAAsB,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,IAAI,cAAc;CAIxF;AACD;;;GAGG;AACH,8BAAsB,qBAAsB,SAAQ,cAAc;aACvC,qBAAqB,CAAC,MAAM,EAAE,gBAAgB,GAAG,cAAc,EAAE,SAAS,EAAE,OAAO,GAAG,IAAI;aAC1F,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,kBAAkB,CAAC,EAAE,KAAK,CAAC,CAAC,cAAc,GAAG,sBAAsB,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GAAG,cAAc;aACnK,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;aAC3C,kBAAkB,CAAC,KAAK,EAAE,cAAc,GAAG,sBAAsB,GAAG,SAAS,GAAG,IAAI;aACpF,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI;CACvE"}
|
|
@@ -159,32 +159,19 @@ class KindOfQuantity extends SchemaItem_1.SchemaItem {
|
|
|
159
159
|
fromJSONSync(kindOfQuantityProps) {
|
|
160
160
|
super.fromJSONSync(kindOfQuantityProps);
|
|
161
161
|
this._relativeError = kindOfQuantityProps.relativeError;
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
this._persistenceUnit = new DelayedPromise_1.DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);
|
|
162
|
+
const unitItemKey = this.schema.getSchemaItemKey(kindOfQuantityProps.persistenceUnit);
|
|
163
|
+
this._persistenceUnit = new DelayedPromise_1.DelayedPromiseWithProps(unitItemKey, async () => {
|
|
164
|
+
const unitItem = await this.schema.lookupItem(unitItemKey, Unit_1.Unit)
|
|
165
|
+
|| await this.schema.lookupItem(unitItemKey, InvertedUnit_1.InvertedUnit);
|
|
166
|
+
if (undefined === unitItem)
|
|
167
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `Unable to locate the unit ${kindOfQuantityProps.persistenceUnit}.`);
|
|
168
|
+
return unitItem;
|
|
169
|
+
});
|
|
171
170
|
if (undefined !== kindOfQuantityProps.presentationUnits)
|
|
172
171
|
this.processPresentationUnitsSync(kindOfQuantityProps.presentationUnits);
|
|
173
172
|
}
|
|
174
173
|
async fromJSON(kindOfQuantityProps) {
|
|
175
|
-
|
|
176
|
-
this._relativeError = kindOfQuantityProps.relativeError;
|
|
177
|
-
const persistenceUnit = await this.schema.lookupItem(kindOfQuantityProps.persistenceUnit);
|
|
178
|
-
if (undefined === persistenceUnit)
|
|
179
|
-
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Unit ${kindOfQuantityProps.persistenceUnit} does not exist.`);
|
|
180
|
-
if (!Unit_1.Unit.isUnit(persistenceUnit) && !InvertedUnit_1.InvertedUnit.isInvertedUnit(persistenceUnit))
|
|
181
|
-
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The item ${kindOfQuantityProps.persistenceUnit} is not a Unit or InvertedUnit.`);
|
|
182
|
-
if (Unit_1.Unit.isUnit(persistenceUnit))
|
|
183
|
-
this._persistenceUnit = new DelayedPromise_1.DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);
|
|
184
|
-
else
|
|
185
|
-
this._persistenceUnit = new DelayedPromise_1.DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);
|
|
186
|
-
if (undefined !== kindOfQuantityProps.presentationUnits)
|
|
187
|
-
await this.processPresentationUnits(kindOfQuantityProps.presentationUnits);
|
|
174
|
+
this.fromJSONSync(kindOfQuantityProps);
|
|
188
175
|
}
|
|
189
176
|
/**
|
|
190
177
|
* Used for schema editing.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KindOfQuantity.js","sourceRoot":"","sources":["../../../src/Metadata/KindOfQuantity.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA4D;AAE5D,oFAAiF;AACjF,4CAA8C;AAC9C,4CAA6D;AAE7D,qCAAkC;AAClC,iDAA8C;AAC9C,qDAAuE;AACvE,6CAA0C;AAC1C,iCAA8B;AAE9B;;GAEG;AACH,MAAa,cAAe,SAAQ,uBAAU;IACnB,cAAc,GAAG,cAAc,CAAC,cAAc,CAAC;IACxE,gBAAgB;IACT,MAAM,KAAc,cAAc,KAAK,OAAO,0BAAc,CAAC,cAAc,CAAC,CAAC,CAAC;IAC7E,cAAc,GAAW,GAAG,CAAC;IAC7B,oBAAoB,GAA6C,EAAE,CAAC;IACpE,gBAAgB,CAA2C;IAEnE,4DAA4D;IAC5D,IAAW,yBAAyB,KAAoD,OAAO,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAE7H,sCAAsC;IACtC,IAAW,mBAAmB,KAA+C,OAAO,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC;IAEhH,uBAAuB;IACvB,IAAW,eAAe,KAA0D,OAAO,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAEnH,IAAW,aAAa,KAAK,OAAO,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC;IAE1D;;;;;OAKG;IACO,qBAAqB,CAAC,MAAyC,EAAE,YAAqB,KAAK;QACnG,qCAAqC;QACrC,mEAAmE;QACnE,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wBAAwB,CAAC,mBAAmB,CAAC,iBAAiB,CAAC,CAAC;IAC/E,CAAC;IAED;;;OAGG;IACO,gBAAgB,CAAC,aAAqB;QAC9C,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;IACtC,CAAC;IAED;;;OAGG;IACO,kBAAkB,CAAC,KAA0D;QACrF,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,gBAAgB,CAAC,IAAiB;QAC9C,IAAI,IAAI,IAAI,IAAI,CAAC,cAAc,KAAK,0BAAc,CAAC,cAAc;YAC/D,OAAO,IAAI,CAAC;QAEd,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,sBAAsB,CAAC,IAAiB;QACpD,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC;YAC9B,MAAM,IAAI,yBAAa,CAAC,0BAAc,CAAC,qBAAqB,EAAE,aAAa,0BAAc,CAAC,cAAc,oBAAoB,CAAC,CAAC;IAClI,CAAC;CACF;AAlPD,wCAkPC;AACD;;;GAGG;AACH,MAAsB,qBAAsB,SAAQ,cAAc;CAMjE;AAND,sDAMC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Metadata\n */\n\nimport { DelayedPromiseWithProps } from \"../DelayedPromise\";\nimport { KindOfQuantityProps } from \"../Deserialization/JsonProps\";\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\nimport { SchemaItemType } from \"../ECObjects\";\nimport { ECSchemaError, ECSchemaStatus } from \"../Exception\";\nimport { LazyLoadedFormat, LazyLoadedInvertedUnit, LazyLoadedUnit } from \"../Interfaces\";\nimport { Format } from \"./Format\";\nimport { InvertedUnit } from \"./InvertedUnit\";\nimport { OverrideFormat, OverrideFormatProps } from \"./OverrideFormat\";\nimport { SchemaItem } from \"./SchemaItem\";\nimport { Unit } from \"./Unit\";\n\n/** A Typescript class representation of a KindOfQuantity.\n * @public @preview\n */\nexport class KindOfQuantity extends SchemaItem {\n public override readonly schemaItemType = KindOfQuantity.schemaItemType;\n /** @internal */\n public static override get schemaItemType() { return SchemaItemType.KindOfQuantity; }\n private _relativeError: number = 1.0;\n private _presentationFormats: Array<LazyLoadedFormat | OverrideFormat> = [];\n private _persistenceUnit?: LazyLoadedUnit | LazyLoadedInvertedUnit;\n\n /** The first presentation format in the list of Formats. */\n public get defaultPresentationFormat(): LazyLoadedFormat | OverrideFormat | undefined { return this.presentationFormats[0]; }\n\n /** A list of presentation formats. */\n public get presentationFormats(): Array<LazyLoadedFormat | OverrideFormat> { return this._presentationFormats; }\n\n /** Persistence unit */\n public get persistenceUnit(): LazyLoadedUnit | LazyLoadedInvertedUnit | undefined { return this._persistenceUnit; }\n\n public get relativeError() { return this._relativeError; }\n\n /**\n *\n * @param format The Format to add to this KindOfQuantity\n * @param isDefault\n * @internal\n */\n protected addPresentationFormat(format: LazyLoadedFormat | OverrideFormat, isDefault: boolean = false) {\n // TODO: Add some sort of validation?\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n (isDefault) ? this._presentationFormats.splice(0, 0, format) : this._presentationFormats.push(format);\n }\n\n /** Creates an OverrideFormat in the context of this KindOfQuantity.\n * @param parent The Format to override.\n * @param precision The precision override\n * @param unitLabelOverrides The list of unit and label overrides.\n * @internal\n */\n protected createFormatOverride(parent: Format, precision?: number, unitLabelOverrides?: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]>): OverrideFormat {\n if (unitLabelOverrides && parent.units && parent.units.length !== unitLabelOverrides.length)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Cannot add presentation format to KindOfQuantity '${this.name}' because the number of unit overrides is inconsistent with the number in the Format '${parent.name}'.`);\n\n if (parent.units && 0 === parent.units.length && unitLabelOverrides && 0 < unitLabelOverrides.length)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Cannot add a presentation format to KindOfQuantity '${this.name}' without any units and no unit overrides.`);\n\n // TODO: Check compatibility of Unit overrides with the persistence unit\n\n return new OverrideFormat(parent, precision, unitLabelOverrides);\n }\n\n private async processPresentationUnits(presentationUnitsJson: string | string[]): Promise<void> {\n const presUnitsArr = Array.isArray(presentationUnitsJson) ? presentationUnitsJson : presentationUnitsJson.split(\";\");\n for (const formatString of presUnitsArr) {\n const presFormatOverride: OverrideFormatProps = OverrideFormat.parseFormatString(formatString);\n\n const format = await this.schema.lookupItem(presFormatOverride.name, Format);\n if (undefined === format || format.schemaItemType !== SchemaItemType.Format)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate Format '${presFormatOverride.name}' for the presentation unit on KindOfQuantity ${this.fullName}.`);\n\n if (undefined === presFormatOverride.precision && undefined === presFormatOverride.unitAndLabels) {\n this.addPresentationFormat(new DelayedPromiseWithProps(format.key, async () => format));\n continue;\n }\n\n let unitAndLabels: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]> | undefined;\n if (undefined !== presFormatOverride.unitAndLabels) {\n if (4 < presFormatOverride.unitAndLabels.length)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, ``);\n\n unitAndLabels = [];\n for (const unitOverride of presFormatOverride.unitAndLabels) {\n const unitOrInverted = await this.schema.lookupItem(unitOverride[0]);\n\n if(Unit.isUnit(unitOrInverted))\n unitAndLabels.push([new DelayedPromiseWithProps(unitOrInverted.key, async () => unitOrInverted), unitOverride[1]]);\n else if(InvertedUnit.isInvertedUnit(unitOrInverted))\n unitAndLabels.push([new DelayedPromiseWithProps(unitOrInverted.key, async () => unitOrInverted), unitOverride[1]]);\n else\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate SchemaItem ${unitOverride[0]}.`);\n }\n }\n\n const overrideFormat = this.createFormatOverride(format, presFormatOverride.precision, unitAndLabels);\n this.addPresentationFormat(overrideFormat);\n }\n }\n\n private processPresentationUnitsSync(presentationUnitsJson: string | string[]): void {\n const presUnitsArr = Array.isArray(presentationUnitsJson) ? presentationUnitsJson : presentationUnitsJson.split(\";\");\n for (const formatString of presUnitsArr) {\n const presFormatOverride: OverrideFormatProps = OverrideFormat.parseFormatString(formatString);\n\n const format = this.schema.lookupItemSync(presFormatOverride.name, Format);\n if (undefined === format || format.schemaItemType !== SchemaItemType.Format)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate Format '${presFormatOverride.name}' for the presentation unit on KindOfQuantity ${this.fullName}.`);\n\n if (undefined === presFormatOverride.precision && undefined === presFormatOverride.unitAndLabels) {\n this.addPresentationFormat(new DelayedPromiseWithProps(format.key, async () => format));\n continue;\n }\n\n let unitAndLabels: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]> | undefined;\n if (undefined !== presFormatOverride.unitAndLabels) {\n if (4 < presFormatOverride.unitAndLabels.length)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, ``);\n\n unitAndLabels = [];\n for (const unitOverride of presFormatOverride.unitAndLabels) {\n const unitOrInverted = this.schema.lookupItemSync(unitOverride[0]);\n if(Unit.isUnit(unitOrInverted))\n unitAndLabels.push([new DelayedPromiseWithProps(unitOrInverted.key, async () => unitOrInverted), unitOverride[1]]);\n else if(InvertedUnit.isInvertedUnit(unitOrInverted))\n unitAndLabels.push([new DelayedPromiseWithProps(unitOrInverted.key, async () => unitOrInverted), unitOverride[1]]);\n else\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate SchemaItem ${unitOverride[0]}.`);\n }\n }\n\n const overrideFormat = this.createFormatOverride(format, presFormatOverride.precision, unitAndLabels);\n this.addPresentationFormat(overrideFormat);\n }\n }\n\n /**\n * Save this KindOfQuantity's properties to an object for serializing to JSON.\n * @param standalone Serialization includes only this object (as opposed to the full schema).\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\n */\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): KindOfQuantityProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n schemaJson.relativeError = this.relativeError;\n schemaJson.persistenceUnit = this.persistenceUnit!.fullName;\n if (undefined !== this.presentationFormats && 0 < this.presentationFormats.length)\n schemaJson.presentationUnits = this.presentationFormats.map((format) => format.fullName);\n return schemaJson;\n }\n\n /** @internal */\n public override async toXml(schemaXml: Document): Promise<Element> {\n const itemElement = await super.toXml(schemaXml);\n\n const persistenceUnit = await this.persistenceUnit;\n if (undefined !== persistenceUnit) {\n const unitName = XmlSerializationUtils.createXmlTypedName(this.schema, persistenceUnit.schema, persistenceUnit.name);\n itemElement.setAttribute(\"persistenceUnit\", unitName);\n }\n\n if (undefined !== this.presentationFormats) {\n const presUnitStrings: string[] = [];\n for(const format of this.presentationFormats) {\n if (!OverrideFormat.isOverrideFormat(format)) {\n const resolvedFormat = await format;\n presUnitStrings.push(XmlSerializationUtils.createXmlTypedName(this.schema, resolvedFormat.schema, format.name));\n continue;\n }\n presUnitStrings.push(format.fullNameXml(this.schema));\n };\n itemElement.setAttribute(\"presentationUnits\", presUnitStrings.join(\";\"));\n }\n itemElement.setAttribute(\"relativeError\", this.relativeError.toString());\n\n return itemElement;\n }\n\n public override fromJSONSync(kindOfQuantityProps: KindOfQuantityProps): void {\n super.fromJSONSync(kindOfQuantityProps);\n this._relativeError = kindOfQuantityProps.relativeError;\n\n const persistenceUnit = this.schema.lookupItemSync(kindOfQuantityProps.persistenceUnit);\n if (undefined === persistenceUnit)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Unit ${kindOfQuantityProps.persistenceUnit} does not exist.`);\n\n if (!Unit.isUnit(persistenceUnit) && !InvertedUnit.isInvertedUnit(persistenceUnit))\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The item ${kindOfQuantityProps.persistenceUnit} is not a Unit or InvertedUnit.`);\n\n if (Unit.isUnit(persistenceUnit))\n this._persistenceUnit = new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);\n else\n this._persistenceUnit = new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);\n\n if (undefined !== kindOfQuantityProps.presentationUnits)\n this.processPresentationUnitsSync(kindOfQuantityProps.presentationUnits);\n }\n\n public override async fromJSON(kindOfQuantityProps: KindOfQuantityProps): Promise<void> {\n await super.fromJSON(kindOfQuantityProps);\n this._relativeError = kindOfQuantityProps.relativeError;\n\n const persistenceUnit = await this.schema.lookupItem(kindOfQuantityProps.persistenceUnit);\n if (undefined === persistenceUnit)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Unit ${kindOfQuantityProps.persistenceUnit} does not exist.`);\n\n if (!Unit.isUnit(persistenceUnit) && !InvertedUnit.isInvertedUnit(persistenceUnit))\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The item ${kindOfQuantityProps.persistenceUnit} is not a Unit or InvertedUnit.`);\n\n if (Unit.isUnit(persistenceUnit))\n this._persistenceUnit = new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);\n else\n this._persistenceUnit = new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);\n\n\n if (undefined !== kindOfQuantityProps.presentationUnits)\n await this.processPresentationUnits(kindOfQuantityProps.presentationUnits);\n }\n\n /**\n * Used for schema editing.\n * @internal\n */\n protected setRelativeError(relativeError: number): void {\n this._relativeError = relativeError;\n }\n\n /**\n * Used for schema editing.\n * @internal\n */\n protected setPersistenceUnit(value: LazyLoadedUnit | LazyLoadedInvertedUnit | undefined): void {\n this._persistenceUnit = value;\n }\n\n /**\n * Type guard to check if the SchemaItem is of type KindOfQuantity.\n * @param item The SchemaItem to check.\n * @returns True if the item is a KindOfQuantity, false otherwise.\n */\n public static isKindOfQuantity(item?: SchemaItem): item is KindOfQuantity {\n if (item && item.schemaItemType === SchemaItemType.KindOfQuantity)\n return true;\n\n return false;\n }\n\n /**\n * Type assertion to check if the SchemaItem is of type KindOfQuantity.\n * @param item The SchemaItem to check.\n * @returns The item cast to KindOfQuantity if it is a KindOfQuantity, undefined otherwise.\n * @internal\n */\n public static assertIsKindOfQuantity(item?: SchemaItem): asserts item is KindOfQuantity {\n if (!this.isKindOfQuantity(item))\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.KindOfQuantity}' (KindOfQuantity)`);\n }\n}\n/**\n * @internal\n * An abstract class used for schema editing.\n */\nexport abstract class MutableKindOfQuantity extends KindOfQuantity {\n public abstract override addPresentationFormat(format: LazyLoadedFormat | OverrideFormat, isDefault: boolean): void;\n public abstract override createFormatOverride(parent: Format, precision?: number, unitLabelOverrides?: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]>): OverrideFormat;\n public abstract override setDisplayLabel(displayLabel: string): void;\n public abstract override setPersistenceUnit(value: LazyLoadedUnit | LazyLoadedInvertedUnit | undefined): void;\n public abstract override setRelativeError(relativeError: number): void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"KindOfQuantity.js","sourceRoot":"","sources":["../../../src/Metadata/KindOfQuantity.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA4D;AAE5D,oFAAiF;AACjF,4CAA8C;AAC9C,4CAA6D;AAE7D,qCAAkC;AAClC,iDAA8C;AAC9C,qDAAuE;AACvE,6CAA0C;AAC1C,iCAA8B;AAE9B;;GAEG;AACH,MAAa,cAAe,SAAQ,uBAAU;IACnB,cAAc,GAAG,cAAc,CAAC,cAAc,CAAC;IACxE,gBAAgB;IACT,MAAM,KAAc,cAAc,KAAK,OAAO,0BAAc,CAAC,cAAc,CAAC,CAAC,CAAC;IAC7E,cAAc,GAAW,GAAG,CAAC;IAC7B,oBAAoB,GAA6C,EAAE,CAAC;IACpE,gBAAgB,CAA2C;IAEnE,4DAA4D;IAC5D,IAAW,yBAAyB,KAAoD,OAAO,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC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------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Metadata\n */\n\nimport { DelayedPromiseWithProps } from \"../DelayedPromise\";\nimport { KindOfQuantityProps } from \"../Deserialization/JsonProps\";\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\nimport { SchemaItemType } from \"../ECObjects\";\nimport { ECSchemaError, ECSchemaStatus } from \"../Exception\";\nimport { LazyLoadedFormat, LazyLoadedInvertedUnit, LazyLoadedUnit } from \"../Interfaces\";\nimport { Format } from \"./Format\";\nimport { InvertedUnit } from \"./InvertedUnit\";\nimport { OverrideFormat, OverrideFormatProps } from \"./OverrideFormat\";\nimport { SchemaItem } from \"./SchemaItem\";\nimport { Unit } from \"./Unit\";\n\n/** A Typescript class representation of a KindOfQuantity.\n * @public @preview\n */\nexport class KindOfQuantity extends SchemaItem {\n public override readonly schemaItemType = KindOfQuantity.schemaItemType;\n /** @internal */\n public static override get schemaItemType() { return SchemaItemType.KindOfQuantity; }\n private _relativeError: number = 1.0;\n private _presentationFormats: Array<LazyLoadedFormat | OverrideFormat> = [];\n private _persistenceUnit?: LazyLoadedUnit | LazyLoadedInvertedUnit;\n\n /** The first presentation format in the list of Formats. */\n public get defaultPresentationFormat(): LazyLoadedFormat | OverrideFormat | undefined { return this.presentationFormats[0]; }\n\n /** A list of presentation formats. */\n public get presentationFormats(): Array<LazyLoadedFormat | OverrideFormat> { return this._presentationFormats; }\n\n /** Persistence unit */\n public get persistenceUnit(): LazyLoadedUnit | LazyLoadedInvertedUnit | undefined { return this._persistenceUnit; }\n\n public get relativeError() { return this._relativeError; }\n\n /**\n *\n * @param format The Format to add to this KindOfQuantity\n * @param isDefault\n * @internal\n */\n protected addPresentationFormat(format: LazyLoadedFormat | OverrideFormat, isDefault: boolean = false) {\n // TODO: Add some sort of validation?\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n (isDefault) ? this._presentationFormats.splice(0, 0, format) : this._presentationFormats.push(format);\n }\n\n /** Creates an OverrideFormat in the context of this KindOfQuantity.\n * @param parent The Format to override.\n * @param precision The precision override\n * @param unitLabelOverrides The list of unit and label overrides.\n * @internal\n */\n protected createFormatOverride(parent: Format, precision?: number, unitLabelOverrides?: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]>): OverrideFormat {\n if (unitLabelOverrides && parent.units && parent.units.length !== unitLabelOverrides.length)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Cannot add presentation format to KindOfQuantity '${this.name}' because the number of unit overrides is inconsistent with the number in the Format '${parent.name}'.`);\n\n if (parent.units && 0 === parent.units.length && unitLabelOverrides && 0 < unitLabelOverrides.length)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Cannot add a presentation format to KindOfQuantity '${this.name}' without any units and no unit overrides.`);\n\n // TODO: Check compatibility of Unit overrides with the persistence unit\n\n return new OverrideFormat(parent, precision, unitLabelOverrides);\n }\n\n private async processPresentationUnits(presentationUnitsJson: string | string[]): Promise<void> {\n const presUnitsArr = Array.isArray(presentationUnitsJson) ? presentationUnitsJson : presentationUnitsJson.split(\";\");\n for (const formatString of presUnitsArr) {\n const presFormatOverride: OverrideFormatProps = OverrideFormat.parseFormatString(formatString);\n\n const format = await this.schema.lookupItem(presFormatOverride.name, Format);\n if (undefined === format || format.schemaItemType !== SchemaItemType.Format)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate Format '${presFormatOverride.name}' for the presentation unit on KindOfQuantity ${this.fullName}.`);\n\n if (undefined === presFormatOverride.precision && undefined === presFormatOverride.unitAndLabels) {\n this.addPresentationFormat(new DelayedPromiseWithProps(format.key, async () => format));\n continue;\n }\n\n let unitAndLabels: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]> | undefined;\n if (undefined !== presFormatOverride.unitAndLabels) {\n if (4 < presFormatOverride.unitAndLabels.length)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, ``);\n\n unitAndLabels = [];\n for (const unitOverride of presFormatOverride.unitAndLabels) {\n const unitOrInverted = await this.schema.lookupItem(unitOverride[0]);\n\n if(Unit.isUnit(unitOrInverted))\n unitAndLabels.push([new DelayedPromiseWithProps(unitOrInverted.key, async () => unitOrInverted), unitOverride[1]]);\n else if(InvertedUnit.isInvertedUnit(unitOrInverted))\n unitAndLabels.push([new DelayedPromiseWithProps(unitOrInverted.key, async () => unitOrInverted), unitOverride[1]]);\n else\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate SchemaItem ${unitOverride[0]}.`);\n }\n }\n\n const overrideFormat = this.createFormatOverride(format, presFormatOverride.precision, unitAndLabels);\n this.addPresentationFormat(overrideFormat);\n }\n }\n\n private processPresentationUnitsSync(presentationUnitsJson: string | string[]): void {\n const presUnitsArr = Array.isArray(presentationUnitsJson) ? presentationUnitsJson : presentationUnitsJson.split(\";\");\n for (const formatString of presUnitsArr) {\n const presFormatOverride: OverrideFormatProps = OverrideFormat.parseFormatString(formatString);\n\n const format = this.schema.lookupItemSync(presFormatOverride.name, Format);\n if (undefined === format || format.schemaItemType !== SchemaItemType.Format)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate Format '${presFormatOverride.name}' for the presentation unit on KindOfQuantity ${this.fullName}.`);\n\n if (undefined === presFormatOverride.precision && undefined === presFormatOverride.unitAndLabels) {\n this.addPresentationFormat(new DelayedPromiseWithProps(format.key, async () => format));\n continue;\n }\n\n let unitAndLabels: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]> | undefined;\n if (undefined !== presFormatOverride.unitAndLabels) {\n if (4 < presFormatOverride.unitAndLabels.length)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, ``);\n\n unitAndLabels = [];\n for (const unitOverride of presFormatOverride.unitAndLabels) {\n const unitOrInverted = this.schema.lookupItemSync(unitOverride[0]);\n if(Unit.isUnit(unitOrInverted))\n unitAndLabels.push([new DelayedPromiseWithProps(unitOrInverted.key, async () => unitOrInverted), unitOverride[1]]);\n else if(InvertedUnit.isInvertedUnit(unitOrInverted))\n unitAndLabels.push([new DelayedPromiseWithProps(unitOrInverted.key, async () => unitOrInverted), unitOverride[1]]);\n else\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate SchemaItem ${unitOverride[0]}.`);\n }\n }\n\n const overrideFormat = this.createFormatOverride(format, presFormatOverride.precision, unitAndLabels);\n this.addPresentationFormat(overrideFormat);\n }\n }\n\n /**\n * Save this KindOfQuantity's properties to an object for serializing to JSON.\n * @param standalone Serialization includes only this object (as opposed to the full schema).\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\n */\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): KindOfQuantityProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n schemaJson.relativeError = this.relativeError;\n schemaJson.persistenceUnit = this.persistenceUnit!.fullName;\n if (undefined !== this.presentationFormats && 0 < this.presentationFormats.length)\n schemaJson.presentationUnits = this.presentationFormats.map((format) => format.fullName);\n return schemaJson;\n }\n\n /** @internal */\n public override async toXml(schemaXml: Document): Promise<Element> {\n const itemElement = await super.toXml(schemaXml);\n\n const persistenceUnit = await this.persistenceUnit;\n if (undefined !== persistenceUnit) {\n const unitName = XmlSerializationUtils.createXmlTypedName(this.schema, persistenceUnit.schema, persistenceUnit.name);\n itemElement.setAttribute(\"persistenceUnit\", unitName);\n }\n\n if (undefined !== this.presentationFormats) {\n const presUnitStrings: string[] = [];\n for(const format of this.presentationFormats) {\n if (!OverrideFormat.isOverrideFormat(format)) {\n const resolvedFormat = await format;\n presUnitStrings.push(XmlSerializationUtils.createXmlTypedName(this.schema, resolvedFormat.schema, format.name));\n continue;\n }\n presUnitStrings.push(format.fullNameXml(this.schema));\n };\n itemElement.setAttribute(\"presentationUnits\", presUnitStrings.join(\";\"));\n }\n itemElement.setAttribute(\"relativeError\", this.relativeError.toString());\n\n return itemElement;\n }\n\n public override fromJSONSync(kindOfQuantityProps: KindOfQuantityProps): void {\n super.fromJSONSync(kindOfQuantityProps);\n this._relativeError = kindOfQuantityProps.relativeError;\n\n const unitItemKey = this.schema.getSchemaItemKey(kindOfQuantityProps.persistenceUnit);\n this._persistenceUnit = new DelayedPromiseWithProps(unitItemKey, async () => {\n const unitItem = await this.schema.lookupItem(unitItemKey, Unit)\n || await this.schema.lookupItem(unitItemKey, InvertedUnit);\n\n if (undefined === unitItem)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate the unit ${kindOfQuantityProps.persistenceUnit}.`);\n\n return unitItem;\n }) as LazyLoadedUnit | LazyLoadedInvertedUnit;\n\n if (undefined !== kindOfQuantityProps.presentationUnits)\n this.processPresentationUnitsSync(kindOfQuantityProps.presentationUnits);\n }\n\n public override async fromJSON(kindOfQuantityProps: KindOfQuantityProps): Promise<void> {\n this.fromJSONSync(kindOfQuantityProps);\n }\n\n /**\n * Used for schema editing.\n * @internal\n */\n protected setRelativeError(relativeError: number): void {\n this._relativeError = relativeError;\n }\n\n /**\n * Used for schema editing.\n * @internal\n */\n protected setPersistenceUnit(value: LazyLoadedUnit | LazyLoadedInvertedUnit | undefined): void {\n this._persistenceUnit = value;\n }\n\n /**\n * Type guard to check if the SchemaItem is of type KindOfQuantity.\n * @param item The SchemaItem to check.\n * @returns True if the item is a KindOfQuantity, false otherwise.\n */\n public static isKindOfQuantity(item?: SchemaItem): item is KindOfQuantity {\n if (item && item.schemaItemType === SchemaItemType.KindOfQuantity)\n return true;\n\n return false;\n }\n\n /**\n * Type assertion to check if the SchemaItem is of type KindOfQuantity.\n * @param item The SchemaItem to check.\n * @returns The item cast to KindOfQuantity if it is a KindOfQuantity, undefined otherwise.\n * @internal\n */\n public static assertIsKindOfQuantity(item?: SchemaItem): asserts item is KindOfQuantity {\n if (!this.isKindOfQuantity(item))\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.KindOfQuantity}' (KindOfQuantity)`);\n }\n}\n/**\n * @internal\n * An abstract class used for schema editing.\n */\nexport abstract class MutableKindOfQuantity extends KindOfQuantity {\n public abstract override addPresentationFormat(format: LazyLoadedFormat | OverrideFormat, isDefault: boolean): void;\n public abstract override createFormatOverride(parent: Format, precision?: number, unitLabelOverrides?: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]>): OverrideFormat;\n public abstract override setDisplayLabel(displayLabel: string): void;\n public abstract override setPersistenceUnit(value: LazyLoadedUnit | LazyLoadedInvertedUnit | undefined): void;\n public abstract override setRelativeError(relativeError: number): void;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ECSqlSchemaLocater.d.ts","sourceRoot":"","sources":["../../../src/IncrementalLoading/ECSqlSchemaLocater.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,UAAU,EACvI,eAAe,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,qBAAqB,EAAmB,mBAAmB,EAAE,WAAW,EACxI,gBAAgB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE1E,OAAO,EAAE,UAAU,EAAiB,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAC5F,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AA8DxD,UAAU,eAAe;IACvB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;CAC1C;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B,KAAK,CAAC,EAA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;IAI5G;;;;;;OAMG;IACU,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAIjG;;;;;;OAMG;IACU,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC;IAI7F;;;;;;OAMG;IACU,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAInG;;;;;;OAMG;IACU,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAI3F;;;;;;OAMG;IACU,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAI/F;;;;;;OAMG;IACU,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAI9F;;;;;;OAMG;IACU,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAIjG;;;OAGG;IACU,eAAe,IAAI,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAWlE;;;;;;OAMG;IACU,iBAAiB,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,WAAW,CAAC,GAAG,SAAS,CAAC;YAwD/G,eAAe;YAgBf,aAAa;YAgBb,4BAA4B;CA8B3C"}
|
|
@@ -65,7 +65,8 @@ export class ECSqlSchemaLocater extends IncrementalSchemaLocater {
|
|
|
65
65
|
if (schemaRow === undefined)
|
|
66
66
|
return undefined;
|
|
67
67
|
const schema = JSON.parse(schemaRow.schema);
|
|
68
|
-
|
|
68
|
+
const schemaInfos = await this._schemaInfoCache.getSchemasByContext(context) ?? [];
|
|
69
|
+
return SchemaParser.parse(schema, schemaInfos);
|
|
69
70
|
}
|
|
70
71
|
/**
|
|
71
72
|
* Checks if the [[SchemaContext]] has the right Meta Schema version to support the incremental schema loading.
|
|
@@ -243,10 +244,12 @@ export class ECSqlSchemaLocater extends IncrementalSchemaLocater {
|
|
|
243
244
|
* @internal
|
|
244
245
|
*/
|
|
245
246
|
async getSchemaPartials(schemaKey, context) {
|
|
247
|
+
const start = Date.now();
|
|
246
248
|
const [schemaRow] = await this.executeQuery(ecsqlQueries.schemaStubQuery, {
|
|
247
249
|
parameters: { schemaName: schemaKey.name },
|
|
248
250
|
limit: 1
|
|
249
251
|
});
|
|
252
|
+
this.options.performanceLogger?.logSchemaItem(start, schemaKey.name, 'SchemaPartials', 1);
|
|
250
253
|
if (!schemaRow)
|
|
251
254
|
return undefined;
|
|
252
255
|
const schemaPartials = [];
|
|
@@ -280,7 +283,8 @@ export class ECSqlSchemaLocater extends IncrementalSchemaLocater {
|
|
|
280
283
|
return value;
|
|
281
284
|
};
|
|
282
285
|
await addSchema(schemaKey);
|
|
283
|
-
|
|
286
|
+
const schemaInfos = await this._schemaInfoCache.getSchemasByContext(context) ?? [];
|
|
287
|
+
await parseSchemaItemStubs(schemaKey.name, JSON.parse(schemaRow.items, reviver), addItems, schemaInfos);
|
|
284
288
|
return schemaPartials;
|
|
285
289
|
}
|
|
286
290
|
async querySchemaItem(context, schemaName, query, schemaType) {
|
|
@@ -292,7 +296,8 @@ export class ECSqlSchemaLocater extends IncrementalSchemaLocater {
|
|
|
292
296
|
const items = itemRows.map((itemRow) => {
|
|
293
297
|
return "string" === typeof itemRow.item ? JSON.parse(itemRow.item) : itemRow.item;
|
|
294
298
|
});
|
|
295
|
-
|
|
299
|
+
const schemaInfos = await this._schemaInfoCache.getSchemasByContext(context) ?? [];
|
|
300
|
+
return await SchemaParser.parseSchemaItems(items, schemaName, schemaInfos) ?? [];
|
|
296
301
|
}
|
|
297
302
|
async getFullSchema(schemaKey, context) {
|
|
298
303
|
const schemaRows = await this.executeQuery(FullSchemaQueries.schemaQuery, { parameters: { schemaName: schemaKey.name } });
|
|
@@ -304,7 +309,8 @@ export class ECSqlSchemaLocater extends IncrementalSchemaLocater {
|
|
|
304
309
|
if (schema.items) {
|
|
305
310
|
schema.items = schema.items.map((itemRow) => { return itemRow.item; });
|
|
306
311
|
}
|
|
307
|
-
|
|
312
|
+
const schemaInfos = await this._schemaInfoCache.getSchemasByContext(context) ?? [];
|
|
313
|
+
return SchemaParser.parse(schema, schemaInfos);
|
|
308
314
|
}
|
|
309
315
|
async getFullSchemaMultipleQueries(schemaKey, context) {
|
|
310
316
|
const schema = await this.getSchemaNoItems(schemaKey.name, context);
|
|
@@ -338,7 +344,7 @@ export class ECSqlSchemaLocater extends IncrementalSchemaLocater {
|
|
|
338
344
|
function parseSchemaReference(referenceName) {
|
|
339
345
|
return { schemaKey: SchemaKey.parseString(referenceName) };
|
|
340
346
|
}
|
|
341
|
-
async function parseSchemaItemStubs(schemaName,
|
|
347
|
+
async function parseSchemaItemStubs(schemaName, itemRows, addItemsHandler, schemaInfos) {
|
|
342
348
|
if (!itemRows || itemRows.length === 0) {
|
|
343
349
|
return;
|
|
344
350
|
}
|
|
@@ -349,7 +355,7 @@ async function parseSchemaItemStubs(schemaName, context, itemRows, addItemsHandl
|
|
|
349
355
|
const currentItem = baseClasses[index--];
|
|
350
356
|
const baseClassItem = baseClasses[index];
|
|
351
357
|
const baseClassName = baseClassItem ? `${baseClassItem.schema}.${baseClassItem.name}` : undefined;
|
|
352
|
-
const schemaItem = await SchemaParser.parseItem(currentItem, currentItem.schema,
|
|
358
|
+
const schemaItem = await SchemaParser.parseItem(currentItem, currentItem.schema, schemaInfos);
|
|
353
359
|
await addItemsHandler(currentItem.schema, {
|
|
354
360
|
...schemaItem,
|
|
355
361
|
name: schemaItem.name,
|
|
@@ -359,7 +365,7 @@ async function parseSchemaItemStubs(schemaName, context, itemRows, addItemsHandl
|
|
|
359
365
|
}
|
|
360
366
|
};
|
|
361
367
|
for (const itemRow of itemRows) {
|
|
362
|
-
const schemaItem = await SchemaParser.parseItem(itemRow, schemaName,
|
|
368
|
+
const schemaItem = await SchemaParser.parseItem(itemRow, schemaName, schemaInfos);
|
|
363
369
|
await addItemsHandler(schemaName, {
|
|
364
370
|
...schemaItem,
|
|
365
371
|
name: schemaItem.name,
|
|
@@ -370,7 +376,7 @@ async function parseSchemaItemStubs(schemaName, context, itemRows, addItemsHandl
|
|
|
370
376
|
});
|
|
371
377
|
await parseBaseClasses(itemRow.baseClasses);
|
|
372
378
|
for (const mixinRow of itemRow.mixins || []) {
|
|
373
|
-
const mixinItem = await SchemaParser.parseItem(mixinRow, mixinRow.schema,
|
|
379
|
+
const mixinItem = await SchemaParser.parseItem(mixinRow, mixinRow.schema, schemaInfos);
|
|
374
380
|
await addItemsHandler(mixinRow.schema, {
|
|
375
381
|
...mixinItem,
|
|
376
382
|
name: mixinItem.name,
|