@itwin/ecschema-metadata 3.4.0-dev.9 → 3.4.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.
- package/CHANGELOG.md +48 -1
- package/lib/cjs/Deserialization/XmlParser.d.ts.map +1 -1
- package/lib/cjs/Deserialization/XmlParser.js.map +1 -1
- package/lib/cjs/Deserialization/XmlSerializationUtils.d.ts +1 -1
- package/lib/cjs/Deserialization/XmlSerializationUtils.js +1 -1
- package/lib/cjs/Deserialization/XmlSerializationUtils.js.map +1 -1
- package/lib/cjs/Metadata/CustomAttribute.d.ts +2 -2
- package/lib/cjs/Metadata/CustomAttribute.d.ts.map +1 -1
- package/lib/cjs/Metadata/CustomAttribute.js +1 -1
- package/lib/cjs/Metadata/CustomAttribute.js.map +1 -1
- package/lib/cjs/Metadata/Format.d.ts.map +1 -1
- package/lib/cjs/Metadata/Format.js.map +1 -1
- package/lib/cjs/PropertyTypes.d.ts.map +1 -1
- package/lib/cjs/PropertyTypes.js +24 -8
- package/lib/cjs/PropertyTypes.js.map +1 -1
- package/lib/cjs/SchemaJsonLocater.d.ts +35 -0
- package/lib/cjs/SchemaJsonLocater.d.ts.map +1 -0
- package/lib/cjs/SchemaJsonLocater.js +43 -0
- package/lib/cjs/SchemaJsonLocater.js.map +1 -0
- package/lib/cjs/SchemaKey.d.ts.map +1 -1
- package/lib/cjs/SchemaKey.js +1 -2
- package/lib/cjs/SchemaKey.js.map +1 -1
- package/lib/cjs/SchemaLoader.d.ts +24 -0
- package/lib/cjs/SchemaLoader.d.ts.map +1 -0
- package/lib/cjs/SchemaLoader.js +48 -0
- package/lib/cjs/SchemaLoader.js.map +1 -0
- package/lib/cjs/UnitConversion/Parser.d.ts.map +1 -1
- package/lib/cjs/UnitConversion/Parser.js +2 -1
- package/lib/cjs/UnitConversion/Parser.js.map +1 -1
- package/lib/cjs/UnitConversion/UnitConverter.d.ts.map +1 -1
- package/lib/cjs/UnitConversion/UnitConverter.js.map +1 -1
- package/lib/cjs/UnitConversion/UnitTree.d.ts.map +1 -1
- package/lib/cjs/UnitConversion/UnitTree.js.map +1 -1
- package/lib/cjs/ecschema-metadata.d.ts +2 -0
- package/lib/cjs/ecschema-metadata.d.ts.map +1 -1
- package/lib/cjs/ecschema-metadata.js +2 -0
- package/lib/cjs/ecschema-metadata.js.map +1 -1
- package/lib/cjs/utils/SchemaGraph.d.ts +1 -1
- package/lib/cjs/utils/SchemaGraph.d.ts.map +1 -1
- package/lib/cjs/utils/SchemaGraph.js.map +1 -1
- package/package.json +8 -8
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.SchemaLoader = void 0;
|
|
8
|
+
const Context_1 = require("./Context");
|
|
9
|
+
const ECObjects_1 = require("./ECObjects");
|
|
10
|
+
const Exception_1 = require("./Exception");
|
|
11
|
+
const SchemaJsonLocater_1 = require("./SchemaJsonLocater");
|
|
12
|
+
const SchemaKey_1 = require("./SchemaKey");
|
|
13
|
+
/**
|
|
14
|
+
* A utility class for loading EC Schema objects using a function that returns schema json for a given schema name.
|
|
15
|
+
* Loaded schemas are held in memory within a schema context managed by SchemaLoader.
|
|
16
|
+
* The SchemaLoader object should be held in memory if multiple calls to [[getSchema]] or [[tryGetSchema]]
|
|
17
|
+
* is a possibility, thereby avoiding unnecessary schema retrievals from the function.
|
|
18
|
+
* @alpha
|
|
19
|
+
*/
|
|
20
|
+
class SchemaLoader {
|
|
21
|
+
constructor(getSchema) {
|
|
22
|
+
this._context = new Context_1.SchemaContext();
|
|
23
|
+
const locater = new SchemaJsonLocater_1.SchemaJsonLocater(getSchema);
|
|
24
|
+
this._context.addLocater(locater);
|
|
25
|
+
}
|
|
26
|
+
/** Get a schema by name
|
|
27
|
+
* @param schemaName a string with the name of the schema to load.
|
|
28
|
+
* @throws [ECObjectsError]($ecschema-metadata) if the schema is not found or cannot be loaded.
|
|
29
|
+
*/
|
|
30
|
+
getSchema(schemaName) {
|
|
31
|
+
const schema = this.tryGetSchema(schemaName);
|
|
32
|
+
if (!schema)
|
|
33
|
+
throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.UnableToLocateSchema, `reading schema=${schemaName}`);
|
|
34
|
+
return schema;
|
|
35
|
+
}
|
|
36
|
+
/** Attempts to get a schema by name
|
|
37
|
+
* @param schemaName a string with the name of the schema to load.
|
|
38
|
+
* @throws [ECObjectsError]($ecschema-metadata) if the schema exists, but cannot be loaded.
|
|
39
|
+
*/
|
|
40
|
+
tryGetSchema(schemaName) {
|
|
41
|
+
// SchemaKey version is not used when locating schema in an iModel, so the version is arbitrary.
|
|
42
|
+
const key = new SchemaKey_1.SchemaKey(schemaName, new SchemaKey_1.ECVersion(1, 0, 0));
|
|
43
|
+
const schema = this._context.getSchemaSync(key, ECObjects_1.SchemaMatchType.Latest);
|
|
44
|
+
return schema;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.SchemaLoader = SchemaLoader;
|
|
48
|
+
//# sourceMappingURL=SchemaLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaLoader.js","sourceRoot":"","sources":["../../src/SchemaLoader.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,uCAA0C;AAC1C,2CAA8C;AAC9C,2CAA8D;AAE9D,2DAA2E;AAC3E,2CAAmD;AAEnD;;;;;;GAMG;AACH,MAAa,YAAY;IAGvB,YAAmB,SAA4B;QAC7C,IAAI,CAAC,QAAQ,GAAG,IAAI,uBAAa,EAAE,CAAC;QACpC,MAAM,OAAO,GAAG,IAAI,qCAAiB,CAAC,SAAS,CAAC,CAAC;QACjD,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED;;;OAGG;IACI,SAAS,CAAmB,UAAkB;QACnD,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM;YACT,MAAM,IAAI,0BAAc,CAAC,2BAAe,CAAC,oBAAoB,EAAE,kBAAkB,UAAU,EAAE,CAAC,CAAC;QAEjG,OAAO,MAAW,CAAC;IACrB,CAAC;IAED;;;OAGG;IACI,YAAY,CAAmB,UAAkB;QACtD,gGAAgG;QAChG,MAAM,GAAG,GAAG,IAAI,qBAAS,CAAC,UAAU,EAAE,IAAI,qBAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC9D,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,GAAG,EAAE,2BAAe,CAAC,MAAM,CAAC,CAAC;QACxE,OAAO,MAAW,CAAC;IACrB,CAAC;CACF;AA/BD,oCA+BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { SchemaContext } from \"./Context\";\r\nimport { SchemaMatchType } from \"./ECObjects\";\r\nimport { ECObjectsError, ECObjectsStatus } from \"./Exception\";\r\nimport { Schema } from \"./Metadata/Schema\";\r\nimport { SchemaJsonLocater, SchemaPropsGetter } from \"./SchemaJsonLocater\";\r\nimport { ECVersion, SchemaKey } from \"./SchemaKey\";\r\n\r\n/**\r\n * A utility class for loading EC Schema objects using a function that returns schema json for a given schema name.\r\n * Loaded schemas are held in memory within a schema context managed by SchemaLoader.\r\n * The SchemaLoader object should be held in memory if multiple calls to [[getSchema]] or [[tryGetSchema]]\r\n * is a possibility, thereby avoiding unnecessary schema retrievals from the function.\r\n * @alpha\r\n */\r\nexport class SchemaLoader {\r\n private _context: SchemaContext;\r\n\r\n public constructor(getSchema: SchemaPropsGetter) {\r\n this._context = new SchemaContext();\r\n const locater = new SchemaJsonLocater(getSchema);\r\n this._context.addLocater(locater);\r\n }\r\n\r\n /** Get a schema by name\r\n * @param schemaName a string with the name of the schema to load.\r\n * @throws [ECObjectsError]($ecschema-metadata) if the schema is not found or cannot be loaded.\r\n */\r\n public getSchema<T extends Schema>(schemaName: string): T {\r\n const schema = this.tryGetSchema(schemaName);\r\n if (!schema)\r\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema, `reading schema=${schemaName}`);\r\n\r\n return schema as T;\r\n }\r\n\r\n /** Attempts to get a schema by name\r\n * @param schemaName a string with the name of the schema to load.\r\n * @throws [ECObjectsError]($ecschema-metadata) if the schema exists, but cannot be loaded.\r\n */\r\n public tryGetSchema<T extends Schema>(schemaName: string): T | undefined {\r\n // SchemaKey version is not used when locating schema in an iModel, so the version is arbitrary.\r\n const key = new SchemaKey(schemaName, new ECVersion(1, 0, 0));\r\n const schema = this._context.getSchemaSync(key, SchemaMatchType.Latest);\r\n return schema as T;\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Parser.d.ts","sourceRoot":"","sources":["../../../src/UnitConversion/Parser.ts"],"names":[],"mappings":"AAeA,gBAAgB;AAChB,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,gBAAgB;AAChB,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,
|
|
1
|
+
{"version":3,"file":"Parser.d.ts","sourceRoot":"","sources":["../../../src/UnitConversion/Parser.ts"],"names":[],"mappings":"AAeA,gBAAgB;AAChB,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,QA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AAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,SAAS,CAAC;YACtD,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;gBACrB,MAAM,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC;gBAC7C,iBAAiB,CAAC,QAAQ,IAAI,QAAQ,CAAC;gBACvC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;aACtC;iBAAM;gBACL,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;aACjD;SACF;QAED,OAAO,OAAO,CAAC;KAChB;SAAM;QACL,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;KACnD;AACH,CAAC;AAtBD,0CAsBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nconst expressionRgx = /^(([A-Z]\\w*:)?([A-Z]\\w*|\\[([A-Z]\\w*:)?[A-Z]\\w*\\])(\\(-?\\d+\\))?(\\*(?!$)|$))+$/i;\r\nconst tokenRgx = /(?:(\\[)?((?:[A-Z]\\w*:)?[A-Z]\\w*)\\]?)(?:\\((-?\\d+)\\))?/i;\r\nconst sp = \"*\";\r\n\r\n/** @internal */\r\nenum Tokens {\r\n Bracket = 1,\r\n Word = 2,\r\n Exponent = 3,\r\n}\r\n\r\n/** @internal */\r\nexport interface DefinitionFragment {\r\n name: string;\r\n exponent: number;\r\n constant: boolean;\r\n}\r\n\r\n/** @internal */\r\nexport function parseDefinition(definition: string): Map<string, DefinitionFragment> {\r\n const unitMap: Map<string, DefinitionFragment> = new Map();\r\n\r\n if (expressionRgx.test(definition)) {\r\n for (const unit of definition.split(sp)) {\r\n const tokens = unit.split(tokenRgx);\r\n const name = tokens[Tokens.Word];\r\n const exponent = tokens[Tokens.Exponent] ? Number(tokens[Tokens.Exponent]) : 1;\r\n const constant = tokens[Tokens.Bracket] !== undefined;\r\n if (unitMap.has(name)) {\r\n const currentDefinition = unitMap.get(name)!;\r\n currentDefinition.exponent += exponent;\r\n unitMap.set(name, currentDefinition);\r\n } else {\r\n unitMap.set(name, { name, exponent, constant });\r\n }\r\n }\r\n\r\n return unitMap;\r\n } else {\r\n throw new Error(\"Invalid definition expression.\");\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnitConverter.d.ts","sourceRoot":"","sources":["../../../src/UnitConversion/UnitConverter.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAK3C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD;;;GAGG;AACH,qBAAa,aAAa;IAOZ,OAAO,CAAC,QAAQ,CAAC,QAAQ;IANrC,OAAO,CAAC,OAAO,CAAY;IAE3B;;;OAGG;gBAC0B,QAAQ,EAAE,aAAa;IAIpD;;;;;;;;;OASG;IACU,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAqB3F;;;;OAIG;YACW,YAAY;
|
|
1
|
+
{"version":3,"file":"UnitConverter.d.ts","sourceRoot":"","sources":["../../../src/UnitConversion/UnitConverter.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAK3C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD;;;GAGG;AACH,qBAAa,aAAa;IAOZ,OAAO,CAAC,QAAQ,CAAC,QAAQ;IANrC,OAAO,CAAC,OAAO,CAAY;IAE3B;;;OAGG;gBAC0B,QAAQ,EAAE,aAAa;IAIpD;;;;;;;;;OASG;IACU,mBAAmB,CAAC,QAAQ,EAAE,MAAM,E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AAC,GAAG,EAAE,KAAK,CAAC,IAAI,aAAa,CAAC,OAAO,EAAE,EAAE;YAClD,MAAM,CAAC,EAAE,cAAc,CAAC,GAAG,uBAAU,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;YACzD,IAAI,cAAc,KAAK,KAAK,IAAI,KAAK,KAAK,CAAC,EAAE;gBAC3C,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;aAC3B;SACF;QAED,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE;YAChD,MAAM,CAAC,EAAE,cAAc,CAAC,GAAG,uBAAU,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;YACzD,IAAI,cAAc,KAAK,KAAK,IAAI,KAAK,KAAK,CAAC,EAAE;gBAC3C,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;aACzB;SACF;QAED,IAAI,aAAa,CAAC,IAAI,KAAK,WAAW,CAAC,IAAI;YACzC,OAAO,KAAK,CAAC;QAEf,KAAK,MAAM,GAAG,IAAI,aAAa,CAAC,IAAI,EAAE,EAAE;YACtC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;gBAC5E,2BAA2B;gBAC3B,OAAO,KAAK,CAAC;aACd;SACF;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAlHD,sCAkHC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { BentleyError, BentleyStatus } from \"@itwin/core-bentley\";\r\nimport { SchemaContext } from \"../Context\";\r\nimport { Constant } from \"../Metadata/Constant\";\r\nimport { SchemaItem } from \"../Metadata/SchemaItem\";\r\nimport { Unit } from \"../Metadata/Unit\";\r\nimport { SchemaKey } from \"../SchemaKey\";\r\nimport { UnitConversion } from \"./UnitConversion\";\r\nimport { UnitGraph } from \"./UnitTree\";\r\n\r\n/**\r\n * Class constructed with SchemaContext and used to calculate [[UnitConversion]] between Units\r\n * @internal\r\n */\r\nexport class UnitConverter {\r\n private _uGraph: UnitGraph;\r\n\r\n /**\r\n * Create Converter context\r\n * @param _context SchemaContext with contexts added to it.\r\n */\r\n constructor(private readonly _context: SchemaContext) {\r\n this._uGraph = new UnitGraph(this._context);\r\n }\r\n\r\n /**\r\n * Find conversion between from and to units, formatted {schemaName}.{schemaItemName} or {schemaName}:{schemaItemName}\r\n * @param fromUnit SchemaItem full name of source unit\r\n * @param toUnit SchemaItem full name of target unit\r\n * @returns [[UnitConversion]] converting fromUnit -> toUnit with a factor and an offset\r\n * @throws Error if from and to Units' SchemaItem is not found in Schema or Schema prefix is not found in SchemaContext\r\n * @throws Error if from and to Units do not belong to the same phenomenon\r\n * @throws Error if definitions' SchemaItems cannot be found in its own or referenced Schemas\r\n * @throws Error if base units of source and target unit do not match\r\n */\r\n public async calculateConversion(fromUnit: string, toUnit: string): Promise<UnitConversion> {\r\n const [fromSchemaName, fromSchemaItemName] = SchemaItem.parseFullName(fromUnit);\r\n const [toSchemaName, toSchemaItemName] = SchemaItem.parseFullName(toUnit);\r\n const fromSchemaKey = new SchemaKey(fromSchemaName);\r\n const toSchemaKey = new SchemaKey(toSchemaName);\r\n\r\n const fromSchema = await this._context.getSchema(fromSchemaKey);\r\n const toSchema = await this._context.getSchema(toSchemaKey);\r\n\r\n if (!fromSchema || !toSchema) {\r\n throw new BentleyError(BentleyStatus.ERROR, \"Cannot find from's and/or to's schema\", () => {\r\n return { from: fromUnit, fromSchema: fromSchemaName, to: toUnit, toSchema: toSchemaName };\r\n });\r\n }\r\n\r\n const from = await this._uGraph.resolveUnit(fromSchemaItemName, fromSchema);\r\n const to = await this._uGraph.resolveUnit(toSchemaItemName, toSchema);\r\n\r\n return this.processUnits(from, to);\r\n }\r\n\r\n /**\r\n * @param from Source unit converted from\r\n * @param to Target unit converted to\r\n * @internal\r\n */\r\n private async processUnits(from: Unit | Constant, to: Unit | Constant): Promise<UnitConversion> {\r\n if (from.key.matches(to.key))\r\n return UnitConversion.identity;\r\n\r\n const areCompatible = await Unit.areCompatible(from as Unit, to as Unit);\r\n if (!areCompatible)\r\n throw new BentleyError(BentleyStatus.ERROR, `Source and target units do not belong to same phenomenon`, () => {\r\n return { from, to };\r\n });\r\n\r\n // Add nodes and subsequent children to graph\r\n await this._uGraph.addUnit(from);\r\n await this._uGraph.addUnit(to);\r\n\r\n const fromBaseUnits = new Map<string, number>();\r\n const toBaseUnits = new Map<string, number>();\r\n // Calculate map of UnitConversions to get between from -> base\r\n const fromMapStore = this._uGraph.reduce(from, fromBaseUnits);\r\n // Calculate map of UnitConversions to get between base -> to\r\n const toMapStore = this._uGraph.reduce(to, toBaseUnits);\r\n\r\n if (!this.checkBaseUnitsMatch(fromBaseUnits, toBaseUnits))\r\n throw new BentleyError(BentleyStatus.ERROR, `Source and target units do not have matching base units`, () => {\r\n return { from, to };\r\n });\r\n\r\n // Final calculations to get singular UnitConversion between from -> to\r\n const fromMap = fromMapStore.get(from.key.fullName) || UnitConversion.identity;\r\n const toMap = toMapStore.get(to.key.fullName) || UnitConversion.identity;\r\n const fromInverse = fromMap.inverse();\r\n return fromInverse.compose(toMap);\r\n }\r\n\r\n /**\r\n * Check if fromBaseUnits's base units and exponents matches toBaseUnits's\r\n * @param fromBaseUnits Map of base units for source unit\r\n * @param toBaseUnits Map of base units for target unit\r\n * @internal\r\n */\r\n private checkBaseUnitsMatch(fromBaseUnits: Map<string, number>, toBaseUnits: Map<string, number>): boolean {\r\n // Trim maps of \"One\" and value that equal zero as they do not affect the base units and calculations\r\n for (const [key, value] of fromBaseUnits.entries()) {\r\n const [, schemaItemName] = SchemaItem.parseFullName(key);\r\n if (schemaItemName === \"ONE\" || value === 0) {\r\n fromBaseUnits.delete(key);\r\n }\r\n }\r\n\r\n for (const [key, value] of toBaseUnits.entries()) {\r\n const [, schemaItemName] = SchemaItem.parseFullName(key);\r\n if (schemaItemName === \"ONE\" || value === 0) {\r\n toBaseUnits.delete(key);\r\n }\r\n }\r\n\r\n if (fromBaseUnits.size !== toBaseUnits.size)\r\n return false;\r\n\r\n for (const key of fromBaseUnits.keys()) {\r\n if (!toBaseUnits.has(key) || fromBaseUnits.get(key) !== toBaseUnits.get(key)) {\r\n // Mismatching key or value\r\n return false;\r\n }\r\n }\r\n\r\n return true;\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnitTree.d.ts","sourceRoot":"","sources":["../../../src/UnitConversion/UnitTree.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAGxC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,gBAAgB;AAChB,qBAAa,UAAU;IACrB;;;;;;;OAOG;WACW,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,IAAI,GAAG,QAAQ,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,mBAAmB,EAAE,MAAM,GAAG,CAAC;CAuBhM;AAED,gBAAgB;AAChB,qBAAa,SAAS;IAGR,OAAO,CAAC,QAAQ;IAF5B,OAAO,CAAC,MAAM,CA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CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YACvC,CAAC,EAAE,SAAS,CAAC,CAAC;YACd,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,+BAAc,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,+BAAc,CAAC,QAAQ,CAAC;YAC/H,MAAM,KAAK,GAAG,IAAI,IAAI,+BAAc,CAAC,QAAQ,CAAC;YAC9C,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YACtC,aAAa,CAAC,GAAG,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;SACzC;aAAM;YACL,aAAa,CAAC,GAAG,CAAC,YAAY,EAAE,+BAAc,CAAC,QAAQ,CAAC,CAAC;SAC1D;QACD,OAAO,aAAa,CAAC;IACvB,CAAC;CACF;AArID,8BAqIC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { BentleyError, BentleyStatus } from \"@itwin/core-bentley\";\r\nimport { SchemaContext } from \"../Context\";\r\nimport { Constant } from \"../Metadata/Constant\";\r\nimport { Schema } from \"../Metadata/Schema\";\r\nimport { SchemaItem } from \"../Metadata/SchemaItem\";\r\nimport { Unit } from \"../Metadata/Unit\";\r\nimport { SchemaItemKey, SchemaKey } from \"../SchemaKey\";\r\nimport { SchemaItemType } from \"../ECObjects\";\r\nimport { UnitConversion } from \"./UnitConversion\";\r\nimport { DefinitionFragment, parseDefinition } from \"./Parser\";\r\nimport { Graph } from \"./Graph\";\r\n\r\n/** @internal */\r\nexport class GraphUtils {\r\n /**\r\n * DFS traversal - Post order\r\n * @param _graph Graph to traverse\r\n * @param start Starting node\r\n * @param keyFrom Get key from label\r\n * @param op Reducing function\r\n * @param initial Initial label\r\n */\r\n public static dfsReduce<T>(_graph: Graph<Unit | Constant>, key: string, op: (previous: T, current: string) => T, initial: T, baseUnitsMap: Map<string, number>, accumulatedExponent: number): T {\r\n const outEdges = _graph.outEdges(key);\r\n let t = initial;\r\n if (outEdges.length > 0) {\r\n t = outEdges.reduce<T>(\r\n (p, edge) => {\r\n const { v, w } = edge;\r\n const edgeExponent = _graph.edge(v, w).exponent;\r\n return GraphUtils.dfsReduce(_graph, edge.w, op, p, baseUnitsMap, accumulatedExponent * edgeExponent);\r\n },\r\n t\r\n );\r\n } else {\r\n if (baseUnitsMap.has(key)) {\r\n const oldExponent = baseUnitsMap.get(key)!;\r\n baseUnitsMap.set(key, oldExponent + accumulatedExponent);\r\n } else {\r\n baseUnitsMap.set(key, accumulatedExponent);\r\n }\r\n }\r\n\r\n return op(t, key);\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class UnitGraph {\r\n private _graph = new Graph<Unit | Constant>();\r\n\r\n constructor(private _context: SchemaContext) {\r\n this._graph.setGraph(\"Unit tree processor\");\r\n }\r\n\r\n /**\r\n * Tries to find the unit/constant given by name in currentSchema\r\n * @param name SchemaItem name or parsed definition to find unit of; Could be {schemaName}:{schemaItemName} or {alias}:{schemaItemName} or {schemaItemName}\r\n * @param currentSchema schema to find name in; name could also be in a referenced schema of current schema\r\n */\r\n public async resolveUnit(name: string, currentSchema: Schema): Promise<Unit | Constant> {\r\n let [schemaName] = SchemaItem.parseFullName(name);\r\n const [, schemaItemName] = SchemaItem.parseFullName(name);\r\n\r\n if (schemaName !== \"\") {\r\n // Check if schemaName is schemaName or alias\r\n const ref = currentSchema.getReferenceSync(schemaName);\r\n const refName = currentSchema.getReferenceNameByAlias(schemaName);\r\n if (ref) {\r\n // Got schema by schemaName\r\n schemaName = ref.name;\r\n } else if (refName) {\r\n // Got schema by alias\r\n schemaName = refName;\r\n } else {\r\n // Didn't match any referenced schema, check if it is current schemaName or alias\r\n if (schemaName === currentSchema.name || schemaName === currentSchema.alias)\r\n schemaName = currentSchema.name;\r\n }\r\n\r\n // Create schema key with schema name\r\n const schemaKey = new SchemaKey(schemaName);\r\n // Get schema with schema key\r\n const schema = await this._context.getSchema(schemaKey);\r\n if (!schema) {\r\n throw new BentleyError(BentleyStatus.ERROR, \"Cannot find schema\", () => {\r\n return { schema: schemaName };\r\n });\r\n } else {\r\n // Set currentSchema to look up schemaItem to be whatever is prefixed in name\r\n currentSchema = schema;\r\n }\r\n // Update name to not have prefix\r\n name = schemaItemName;\r\n }\r\n\r\n // Create schema item key with name and schema\r\n const itemKey = new SchemaItemKey(name, currentSchema.schemaKey);\r\n // Get schema item with schema item key\r\n const item = await this._context.getSchemaItem(itemKey);\r\n if (!item)\r\n throw new BentleyError(BentleyStatus.ERROR, \"Cannot find schema item\", () => {\r\n return { item: name };\r\n });\r\n\r\n if (item.schemaItemType === SchemaItemType.Unit || item.schemaItemType === SchemaItemType.Constant)\r\n return item as Unit | Constant;\r\n\r\n throw new BentleyError(BentleyStatus.ERROR, \"Item is neither a unit or a constant\", () => {\r\n return { itemType: item.key.fullName };\r\n });\r\n }\r\n\r\n /**\r\n * Adds unit and corresponding children to graph as well as edges between units\r\n * @param unit Current unit to be added to graph\r\n */\r\n public async addUnit(unit: Unit | Constant): Promise<void> {\r\n if (this._graph.hasNode(unit.key.fullName)) return;\r\n\r\n this._graph.setNode(unit.key.fullName, unit);\r\n if (this.isIdentity(unit))\r\n return;\r\n\r\n const umap = parseDefinition(unit.definition);\r\n\r\n const promiseArray: Promise<[Unit | Constant, DefinitionFragment]>[] = [];\r\n for (const [key, value] of umap) {\r\n promiseArray.push(\r\n this.resolveUnit(key, unit.schema).then((u) => [u, value])\r\n );\r\n }\r\n const resolved = await Promise.all<[Unit | Constant, DefinitionFragment]>(\r\n promiseArray\r\n );\r\n\r\n const children = resolved.map(async ([u, def]) => {\r\n await this.addUnit(u);\r\n this._graph.setEdge(unit.key.fullName, u.key.fullName, {\r\n exponent: def.exponent,\r\n });\r\n });\r\n\r\n await Promise.all(children);\r\n }\r\n\r\n private isIdentity(unit: Unit | Constant) {\r\n return unit.definition === unit.name;\r\n }\r\n\r\n /**\r\n * Reduce the tree to produce a single map\r\n * @param unit Unit to be processed\r\n * @param stopNodes The tree exploration should stop here\r\n */\r\n public reduce(unit: Unit | Constant, baseUnitsMap: Map<string, number>): Map<string, UnitConversion> {\r\n const unitFullName = unit.key.fullName;\r\n const innerMapStore = new Map<string, UnitConversion>();\r\n const outerMapStore = GraphUtils.dfsReduce(this._graph, unitFullName, (p, c) => this.reducingFunction(p, c), innerMapStore, baseUnitsMap, 1);\r\n return outerMapStore;\r\n }\r\n\r\n private reducingFunction(innermapStore: Map<string, UnitConversion>, unitFullName: string) {\r\n const outEdges = this._graph.outEdges(unitFullName);\r\n if (outEdges) {\r\n const cmap = outEdges.reduce<UnitConversion | undefined>((pm, e) => {\r\n const { exponent } = this._graph.edge(e.v, e.w);\r\n const stored = innermapStore.get(e.w);\r\n const map = stored ? stored : UnitConversion.identity;\r\n const emap = map.raise(exponent);\r\n return pm ? pm.multiply(emap) : emap;\r\n }, undefined);\r\n const thisMap = this._graph.node(unitFullName) ? UnitConversion.from(this._graph.node(unitFullName)) : UnitConversion.identity;\r\n const other = cmap || UnitConversion.identity;\r\n const result = other.compose(thisMap);\r\n innermapStore.set(unitFullName, result);\r\n } else {\r\n innermapStore.set(unitFullName, UnitConversion.identity);\r\n }\r\n return innermapStore;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"UnitTree.js","sourceRoot":"","sources":["../../../src/UnitConversion/UnitTree.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,sDAAkE;AAIlE,uDAAoD;AAEpD,4CAAwD;AACxD,4CAA8C;AAC9C,qDAAkD;AAClD,qCAA+D;AAC/D,mCAAgC;AAEhC,gBAAgB;AAChB,MAAa,UAAU;IACrB;;;;;;;OAOG;IACI,MAAM,CAAC,SA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":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { BentleyError, BentleyStatus } from \"@itwin/core-bentley\";\r\nimport { SchemaContext } from \"../Context\";\r\nimport { Constant } from \"../Metadata/Constant\";\r\nimport { Schema } from \"../Metadata/Schema\";\r\nimport { SchemaItem } from \"../Metadata/SchemaItem\";\r\nimport { Unit } from \"../Metadata/Unit\";\r\nimport { SchemaItemKey, SchemaKey } from \"../SchemaKey\";\r\nimport { SchemaItemType } from \"../ECObjects\";\r\nimport { UnitConversion } from \"./UnitConversion\";\r\nimport { DefinitionFragment, parseDefinition } from \"./Parser\";\r\nimport { Graph } from \"./Graph\";\r\n\r\n/** @internal */\r\nexport class GraphUtils {\r\n /**\r\n * DFS traversal - Post order\r\n * @param _graph Graph to traverse\r\n * @param start Starting node\r\n * @param keyFrom Get key from label\r\n * @param op Reducing function\r\n * @param initial Initial label\r\n */\r\n public static dfsReduce<T>(_graph: Graph<Unit | Constant>, key: string, op: (previous: T, current: string) => T, initial: T, baseUnitsMap: Map<string, number>, accumulatedExponent: number): T {\r\n const outEdges = _graph.outEdges(key);\r\n let t = initial;\r\n if (outEdges.length > 0) {\r\n t = outEdges.reduce<T>(\r\n (p, edge) => {\r\n const { v, w } = edge;\r\n const edgeExponent = _graph.edge(v, w).exponent;\r\n return GraphUtils.dfsReduce(_graph, edge.w, op, p, baseUnitsMap, accumulatedExponent * edgeExponent);\r\n },\r\n t\r\n );\r\n } else {\r\n if (baseUnitsMap.has(key)) {\r\n const oldExponent = baseUnitsMap.get(key)!;\r\n baseUnitsMap.set(key, oldExponent + accumulatedExponent);\r\n } else {\r\n baseUnitsMap.set(key, accumulatedExponent);\r\n }\r\n }\r\n\r\n return op(t, key);\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class UnitGraph {\r\n private _graph = new Graph<Unit | Constant>();\r\n\r\n constructor(private _context: SchemaContext) {\r\n this._graph.setGraph(\"Unit tree processor\");\r\n }\r\n\r\n /**\r\n * Tries to find the unit/constant given by name in currentSchema\r\n * @param name SchemaItem name or parsed definition to find unit of; Could be {schemaName}:{schemaItemName} or {alias}:{schemaItemName} or {schemaItemName}\r\n * @param currentSchema schema to find name in; name could also be in a referenced schema of current schema\r\n */\r\n public async resolveUnit(name: string, currentSchema: Schema): Promise<Unit | Constant> {\r\n let [schemaName] = SchemaItem.parseFullName(name);\r\n const [, schemaItemName] = SchemaItem.parseFullName(name);\r\n\r\n if (schemaName !== \"\") {\r\n // Check if schemaName is schemaName or alias\r\n const ref = currentSchema.getReferenceSync(schemaName);\r\n const refName = currentSchema.getReferenceNameByAlias(schemaName);\r\n if (ref) {\r\n // Got schema by schemaName\r\n schemaName = ref.name;\r\n } else if (refName) {\r\n // Got schema by alias\r\n schemaName = refName;\r\n } else {\r\n // Didn't match any referenced schema, check if it is current schemaName or alias\r\n if (schemaName === currentSchema.name || schemaName === currentSchema.alias)\r\n schemaName = currentSchema.name;\r\n }\r\n\r\n // Create schema key with schema name\r\n const schemaKey = new SchemaKey(schemaName);\r\n // Get schema with schema key\r\n const schema = await this._context.getSchema(schemaKey);\r\n if (!schema) {\r\n throw new BentleyError(BentleyStatus.ERROR, \"Cannot find schema\", () => {\r\n return { schema: schemaName };\r\n });\r\n } else {\r\n // Set currentSchema to look up schemaItem to be whatever is prefixed in name\r\n currentSchema = schema;\r\n }\r\n // Update name to not have prefix\r\n name = schemaItemName;\r\n }\r\n\r\n // Create schema item key with name and schema\r\n const itemKey = new SchemaItemKey(name, currentSchema.schemaKey);\r\n // Get schema item with schema item key\r\n const item = await this._context.getSchemaItem(itemKey);\r\n if (!item)\r\n throw new BentleyError(BentleyStatus.ERROR, \"Cannot find schema item\", () => {\r\n return { item: name };\r\n });\r\n\r\n if (item.schemaItemType === SchemaItemType.Unit || item.schemaItemType === SchemaItemType.Constant)\r\n return item as Unit | Constant;\r\n\r\n throw new BentleyError(BentleyStatus.ERROR, \"Item is neither a unit or a constant\", () => {\r\n return { itemType: item.key.fullName };\r\n });\r\n }\r\n\r\n /**\r\n * Adds unit and corresponding children to graph as well as edges between units\r\n * @param unit Current unit to be added to graph\r\n */\r\n public async addUnit(unit: Unit | Constant): Promise<void> {\r\n if (this._graph.hasNode(unit.key.fullName))\r\n return;\r\n\r\n this._graph.setNode(unit.key.fullName, unit);\r\n if (this.isIdentity(unit))\r\n return;\r\n\r\n const umap = parseDefinition(unit.definition);\r\n\r\n const promiseArray: Promise<[Unit | Constant, DefinitionFragment]>[] = [];\r\n for (const [key, value] of umap) {\r\n promiseArray.push(\r\n this.resolveUnit(key, unit.schema).then((u) => [u, value])\r\n );\r\n }\r\n const resolved = await Promise.all<[Unit | Constant, DefinitionFragment]>(\r\n promiseArray\r\n );\r\n\r\n const children = resolved.map(async ([u, def]) => {\r\n await this.addUnit(u);\r\n this._graph.setEdge(unit.key.fullName, u.key.fullName, {\r\n exponent: def.exponent,\r\n });\r\n });\r\n\r\n await Promise.all(children);\r\n }\r\n\r\n private isIdentity(unit: Unit | Constant) {\r\n return unit.definition === unit.name;\r\n }\r\n\r\n /**\r\n * Reduce the tree to produce a single map\r\n * @param unit Unit to be processed\r\n * @param stopNodes The tree exploration should stop here\r\n */\r\n public reduce(unit: Unit | Constant, baseUnitsMap: Map<string, number>): Map<string, UnitConversion> {\r\n const unitFullName = unit.key.fullName;\r\n const innerMapStore = new Map<string, UnitConversion>();\r\n const outerMapStore = GraphUtils.dfsReduce(this._graph, unitFullName, (p, c) => this.reducingFunction(p, c), innerMapStore, baseUnitsMap, 1);\r\n return outerMapStore;\r\n }\r\n\r\n private reducingFunction(innermapStore: Map<string, UnitConversion>, unitFullName: string) {\r\n const outEdges = this._graph.outEdges(unitFullName);\r\n if (outEdges) {\r\n const cmap = outEdges.reduce<UnitConversion | undefined>((pm, e) => {\r\n const { exponent } = this._graph.edge(e.v, e.w);\r\n const stored = innermapStore.get(e.w);\r\n const map = stored ? stored : UnitConversion.identity;\r\n const emap = map.raise(exponent);\r\n return pm ? pm.multiply(emap) : emap;\r\n }, undefined);\r\n const thisMap = this._graph.node(unitFullName) ? UnitConversion.from(this._graph.node(unitFullName)) : UnitConversion.identity;\r\n const other = cmap || UnitConversion.identity;\r\n const result = other.compose(thisMap);\r\n innermapStore.set(unitFullName, result);\r\n } else {\r\n innermapStore.set(unitFullName, UnitConversion.identity);\r\n }\r\n return innermapStore;\r\n }\r\n}\r\n"]}
|
|
@@ -28,7 +28,9 @@ export * from "./Metadata/SchemaItem";
|
|
|
28
28
|
export { Unit } from "./Metadata/Unit";
|
|
29
29
|
export { UnitSystem } from "./Metadata/UnitSystem";
|
|
30
30
|
export * from "./PropertyTypes";
|
|
31
|
+
export * from "./SchemaJsonLocater";
|
|
31
32
|
export * from "./SchemaKey";
|
|
33
|
+
export * from "./SchemaLoader";
|
|
32
34
|
export * from "./UnitConversion/UnitConversion";
|
|
33
35
|
export * from "./UnitConversion/UnitConverter";
|
|
34
36
|
export * from "./UnitProvider/SchemaUnitProvider";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ecschema-metadata.d.ts","sourceRoot":"","sources":["../../src/ecschema-metadata.ts"],"names":[],"mappings":"AAKA,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mCAAmC,CAAC;AAClD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACv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,aAAa,EAAE,2BAA2B,GACjG,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACnH,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,mCAAmC,CAAC;AAClD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,6BAA6B,EAAC,MAAM,4BAA4B,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD;;GAEG;AACH;;;GAGG;AACH;;;GAGG"}
|
|
@@ -73,7 +73,9 @@ Object.defineProperty(exports, "Unit", { enumerable: true, get: function () { re
|
|
|
73
73
|
var UnitSystem_1 = require("./Metadata/UnitSystem");
|
|
74
74
|
Object.defineProperty(exports, "UnitSystem", { enumerable: true, get: function () { return UnitSystem_1.UnitSystem; } });
|
|
75
75
|
__exportStar(require("./PropertyTypes"), exports);
|
|
76
|
+
__exportStar(require("./SchemaJsonLocater"), exports);
|
|
76
77
|
__exportStar(require("./SchemaKey"), exports);
|
|
78
|
+
__exportStar(require("./SchemaLoader"), exports);
|
|
77
79
|
__exportStar(require("./UnitConversion/UnitConversion"), exports);
|
|
78
80
|
__exportStar(require("./UnitConversion/UnitConverter"), exports);
|
|
79
81
|
__exportStar(require("./UnitProvider/Sch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AA,MAAM,OAAA;AACf,wDAAsC;AACtC,wCAAuC;AAA9B,4FAAA,IAAI,OAAA;AACb,oDAAmD;AAA1C,wGAAA,UAAU,OAAA;AACnB,kDAAgC;AAChC,8CAA4B;AAC5B,kEAAgD;AAChD,iEAA+C;AAC/C,oEAAkD;AAClD,4DAA0C;AAC1C,8DAA4C;AAE5C,mDAAkD;AAAzC,0GAAA,WAAW,OAAA;AAEpB;;GAEG;AACH;;;GAGG;AACH;;;GAGG","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nexport * from \"./Constants\";\r\nexport * from \"./Context\";\r\nexport * from \"./DelayedPromise\";\r\nexport * from \"./Deserialization/SchemaGraphUtil\";\r\nexport * from \"./Deserialization/JsonProps\";\r\nexport * from \"./Deserialization/Helper\";\r\nexport * from \"./Deserialization/XmlParser\";\r\nexport * from \"./ECName\";\r\nexport * from \"./ECObjects\";\r\nexport * from \"./Exception\";\r\nexport * from \"./Interfaces\";\r\nexport { ECClass, StructClass } from \"./Metadata/Class\";\r\nexport { Constant } from \"./Metadata/Constant\";\r\nexport { CustomAttributeClass } from \"./Metadata/CustomAttributeClass\";\r\nexport { EntityClass } from \"./Metadata/EntityClass\";\r\nexport { AnyEnumerator, Enumeration, Enumerator } from \"./Metadata/Enumeration\";\r\nexport { Format } from \"./Metadata/Format\";\r\nexport { InvertedUnit } from \"./Metadata/InvertedUnit\";\r\nexport { KindOfQuantity } from \"./Metadata/KindOfQuantity\";\r\nexport { Mixin } from \"./Metadata/Mixin\";\r\nexport * from \"./Metadata/OverrideFormat\";\r\nexport { Phenomenon } from \"./Metadata/Phenomenon\";\r\nexport {\r\n Property, PrimitiveProperty, PrimitiveArrayProperty, EnumerationProperty, StructProperty,\r\n StructArrayProperty, EnumerationArrayProperty, NavigationProperty, AnyArrayProperty, AnyEnumerationProperty,\r\n AnyPrimitiveProperty, AnyProperty, AnyStructProperty, ArrayProperty, PrimitiveOrEnumPropertyBase,\r\n} from \"./Metadata/Property\";\r\nexport { PropertyCategory } from \"./Metadata/PropertyCategory\";\r\nexport { RelationshipClass, RelationshipConstraint, RelationshipMultiplicity } from \"./Metadata/RelationshipClass\";\r\nexport { Schema } from \"./Metadata/Schema\";\r\nexport * from \"./Metadata/SchemaItem\";\r\nexport { Unit } from \"./Metadata/Unit\";\r\nexport { UnitSystem } from \"./Metadata/UnitSystem\";\r\nexport * from \"./PropertyTypes\";\r\nexport * from \"./SchemaKey\";\r\nexport * from \"./UnitConversion/UnitConversion\";\r\nexport * from \"./UnitConversion/UnitConverter\";\r\nexport * from \"./UnitProvider/SchemaUnitProvider\";\r\nexport * from \"./Validation/SchemaWalker\";\r\nexport * from \"./SchemaPartVisitorDelegate\";\r\nexport { CustomAttribute, CustomAttributeContainerProps} from \"./Metadata/CustomAttribute\";\r\nexport { SchemaGraph } from \"./utils/SchemaGraph\";\r\n\r\n/** @docs-package-description\r\n * The ecschema-metadata package contains classes for working with ECSchemas that can be used in both [frontend]($docs/learning/frontend/index.md) and [backend]($docs/learning/backend/index.md).\r\n */\r\n/**\r\n * @docs-group-description Metadata\r\n * Definitions of classes and interfaces that represent all [EC elements]($docs/bis/ec/index.md).\r\n */\r\n/**\r\n * @docs-group-description Utils\r\n * A set of utility classes used throughout the package.\r\n */\r\n"]}
|
|
1
|
+
{"version":3,"file":"ecschema-metadata.js","sourceRoot":"","sources":["../../src/ecschema-metadata.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;;;;;;;;;;AAE/F,8CAA4B;AAC5B,4CAA0B;AAC1B,mDAAiC;AACjC,oEAAkD;AAClD,8DAA4C;AAC5C,2DAAyC;AACzC,8DAA4C;AAC5C,2CAAyB;AACzB,8CAA4B;AAC5B,8CAA4B;AAC5B,+CAA6B;AAC7B,0CAAwD;AAA/C,gGAAA,OAAO,OAAA;AAAE,oGAAA,WAAW,OAAA;AAC7B,gDAA+C;AAAtC,oGAAA,QAAQ,OAAA;AACjB,wEAAuE;AAA9D,4HAAA,oBAAoB,OAAA;AAC7B,sDAAqD;AAA5C,0GAAA,WAAW,OAAA;AACpB,sDAAgF;AAAxD,0GAAA,WAAW,OAAA;AACnC,4CAA2C;AAAlC,gGAAA,MAAM,OAAA;AACf,wDAAuD;AAA9C,4GAAA,YAAY,OAAA;AACrB,4DAA2D;AAAlD,gHAAA,cAAc,OAAA;AACvB,0CAAyC;AAAhC,8FAAA,KAAK,OAAA;AACd,4DAA0C;AAC1C,oDAAmD;AAA1C,wGAAA,UAAU,OAAA;AACnB,gDAI6B;AAH3B,oGAAA,QAAQ,OAAA;AAAE,6GAAA,iBAAiB,OAAA;AAAE,kHAAA,sBAAsB,OAAA;AAAE,+GAAA,mBAAmB,OAAA;AAAE,0GAAA,cAAc,OAAA;AACxF,+GAAA,mBAAmB,OAAA;AAAE,oHAAA,wBAAwB,OAAA;AAAE,8GAAA,kBAAkB,OAAA;AACX,yGAAA,aAAa,OAAA;AAAE,uHAAA,2BAA2B,OAAA;AAElG,gEAA+D;AAAtD,oHAAA,gBAAgB,OAAA;AACzB,kEAAmH;AAA1G,sHAAA,iBAAiB,OAAA;AAAE,2HAAA,sBAAsB,OAAA;AAAE,6HAAA,wBAAwB,OAAA;AAC5E,4CAA2C;AAAlC,gGAAA,MAAM,OAAA;AACf,wDAAsC;AACtC,wCAAuC;AAA9B,4FAAA,IAAI,OAAA;AACb,oDAAmD;AAA1C,wGAAA,UAAU,OAAA;AACnB,kDAAgC;AAChC,sDAAoC;AACpC,8CAA4B;AAC5B,iDAA+B;AAC/B,kEAAgD;AAChD,iEAA+C;AAC/C,oEAAkD;AAClD,4DAA0C;AAC1C,8DAA4C;AAE5C,mDAAkD;AAAzC,0GAAA,WAAW,OAAA;AAEpB;;GAEG;AACH;;;GAGG;AACH;;;GAGG","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nexport * from \"./Constants\";\r\nexport * from \"./Context\";\r\nexport * from \"./DelayedPromise\";\r\nexport * from \"./Deserialization/SchemaGraphUtil\";\r\nexport * from \"./Deserialization/JsonProps\";\r\nexport * from \"./Deserialization/Helper\";\r\nexport * from \"./Deserialization/XmlParser\";\r\nexport * from \"./ECName\";\r\nexport * from \"./ECObjects\";\r\nexport * from \"./Exception\";\r\nexport * from \"./Interfaces\";\r\nexport { ECClass, StructClass } from \"./Metadata/Class\";\r\nexport { Constant } from \"./Metadata/Constant\";\r\nexport { CustomAttributeClass } from \"./Metadata/CustomAttributeClass\";\r\nexport { EntityClass } from \"./Metadata/EntityClass\";\r\nexport { AnyEnumerator, Enumeration, Enumerator } from \"./Metadata/Enumeration\";\r\nexport { Format } from \"./Metadata/Format\";\r\nexport { InvertedUnit } from \"./Metadata/InvertedUnit\";\r\nexport { KindOfQuantity } from \"./Metadata/KindOfQuantity\";\r\nexport { Mixin } from \"./Metadata/Mixin\";\r\nexport * from \"./Metadata/OverrideFormat\";\r\nexport { Phenomenon } from \"./Metadata/Phenomenon\";\r\nexport {\r\n Property, PrimitiveProperty, PrimitiveArrayProperty, EnumerationProperty, StructProperty,\r\n StructArrayProperty, EnumerationArrayProperty, NavigationProperty, AnyArrayProperty, AnyEnumerationProperty,\r\n AnyPrimitiveProperty, AnyProperty, AnyStructProperty, ArrayProperty, PrimitiveOrEnumPropertyBase,\r\n} from \"./Metadata/Property\";\r\nexport { PropertyCategory } from \"./Metadata/PropertyCategory\";\r\nexport { RelationshipClass, RelationshipConstraint, RelationshipMultiplicity } from \"./Metadata/RelationshipClass\";\r\nexport { Schema } from \"./Metadata/Schema\";\r\nexport * from \"./Metadata/SchemaItem\";\r\nexport { Unit } from \"./Metadata/Unit\";\r\nexport { UnitSystem } from \"./Metadata/UnitSystem\";\r\nexport * from \"./PropertyTypes\";\r\nexport * from \"./SchemaJsonLocater\";\r\nexport * from \"./SchemaKey\";\r\nexport * from \"./SchemaLoader\";\r\nexport * from \"./UnitConversion/UnitConversion\";\r\nexport * from \"./UnitConversion/UnitConverter\";\r\nexport * from \"./UnitProvider/SchemaUnitProvider\";\r\nexport * from \"./Validation/SchemaWalker\";\r\nexport * from \"./SchemaPartVisitorDelegate\";\r\nexport { CustomAttribute, CustomAttributeContainerProps} from \"./Metadata/CustomAttribute\";\r\nexport { SchemaGraph } from \"./utils/SchemaGraph\";\r\n\r\n/** @docs-package-description\r\n * The ecschema-metadata package contains classes for working with ECSchemas that can be used in both [frontend]($docs/learning/frontend/index.md) and [backend]($docs/learning/backend/index.md).\r\n */\r\n/**\r\n * @docs-group-description Metadata\r\n * Definitions of classes and interfaces that represent all [EC elements]($docs/bis/ec/index.md).\r\n */\r\n/**\r\n * @docs-group-description Utils\r\n * A set of utility classes used throughout the package.\r\n */\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaGraph.d.ts","sourceRoot":"","sources":["../../../src/utils/SchemaGraph.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,
|
|
1
|
+
{"version":3,"file":"SchemaGraph.d.ts","sourceRoot":"","sources":["../../../src/utils/SchemaGraph.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,gBAAgB;AAChB,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAgB;IAEhC;;;OAGG;gBACgB,MAAM,EAAE,MAAM;IAIjC;;;OAGG;IACI,YAAY,IAAI,cAAc,EAAE,GAAG,SAAS;IAcnD,OAAO,CAAC,eAAe;IAuBvB,OAAO,CAAC,aAAa;CAUtB"}
|
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,MAAM,EAAE,SAAS,EAAC,CAAC,CAAC;oBACjC,UAAU,GAAG,IAAI,CAAC;iBACnB;qBAAM,IAAI,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;oBACnC,MAAM,CAAC,IAAI,CAAC,EAAC,MAAM,EAAE,SAAS,EAAC,CAAC,CAAC;oBACjC,UAAU,GAAG,IAAI,CAAC;iBACnB;aACF;SACF;QACD,IAAI,CAAC,UAAU;YACb,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;QAEhC,OAAO,UAAU,CAAC;IACpB,CAAC;IAEO,aAAa,CAAC,MAAc;QAClC,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC;YAChC,OAAO;QAET,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAE3B,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,UAAU,EAAE;YACzC,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;SAC/B;IACH,CAAC;CACF;AA9DD,kCA8DC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { Schema } from \"../Metadata/Schema\";\r\n\r\n/** @
|
|
1
|
+
{"version":3,"file":"SchemaGraph.js","sourceRoot":"","sources":["../../../src/utils/SchemaGraph.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAU/F;;;GAGG;AACH,MAAa,WAAW;IAGtB;;;OAGG;IACH,YAAmB,MAAc;QANzB,aAAQ,GAAa,EAAE,CAAC;QAO9B,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IAED;;;OAGG;IACI,YAAY;QACjB,MAAM,OAAO,GAAG,EAAE,CAAC;QACnB,MAAM,QAAQ,GAAG,EAAE,CAAC;QACpB,MA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AAc;QAClC,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC;YAChC,OAAO;QAET,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAE3B,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,UAAU,EAAE;YACzC,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;SAC/B;IACH,CAAC;CACF;AA9DD,kCA8DC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { Schema } from \"../Metadata/Schema\";\r\n\r\n/** @internal */\r\nexport interface ReferenceCycle {\r\n schema: Schema;\r\n refSchema: Schema;\r\n}\r\n\r\n/**\r\n * Utility class for detecting cyclic references in a Schema graph.\r\n * @beta\r\n */\r\nexport class SchemaGraph {\r\n private _schemas: Schema[] = [];\r\n\r\n /**\r\n * Initializes a new SchemaGraph instance.\r\n * @param schema The schema to analyze.\r\n */\r\n public constructor(schema: Schema) {\r\n this.populateGraph(schema);\r\n }\r\n\r\n /**\r\n * Detected cyclic references in a schema.\r\n * @returns True if a cycle is found.\r\n */\r\n public detectCycles(): ReferenceCycle[] | undefined {\r\n const visited = {};\r\n const recStack = {};\r\n const cycles: ReferenceCycle[] = [];\r\n\r\n for (const schema of this._schemas) {\r\n if (this.detectCycleUtil(schema, visited, recStack, cycles)) {\r\n return cycles.length > 0 ? cycles : undefined;\r\n }\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n private detectCycleUtil(schema: Schema, visited: any, recStack: any, cycles: ReferenceCycle[]): boolean {\r\n let cycleFound = false;\r\n\r\n if (!visited[schema.name]) {\r\n visited[schema.name] = true;\r\n recStack[schema.name] = true;\r\n\r\n for (const refSchema of schema.references) {\r\n if (!visited[refSchema.name] && this.detectCycleUtil(refSchema, visited, recStack, cycles)) {\r\n cycles.push({schema, refSchema});\r\n cycleFound = true;\r\n } else if (recStack[refSchema.name]) {\r\n cycles.push({schema, refSchema});\r\n cycleFound = true;\r\n }\r\n }\r\n }\r\n if (!cycleFound)\r\n recStack[schema.name] = false;\r\n\r\n return cycleFound;\r\n }\r\n\r\n private populateGraph(schema: Schema) {\r\n if (this._schemas.includes(schema))\r\n return;\r\n\r\n this._schemas.push(schema);\r\n\r\n for (const refSchema of schema.references) {\r\n this.populateGraph(refSchema);\r\n }\r\n }\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/ecschema-metadata",
|
|
3
|
-
"version": "3.4.0
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "ECObjects core concepts in typescript",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/cjs/ecschema-metadata.js",
|
|
@@ -22,16 +22,16 @@
|
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@bentley/units-schema": "^1.0.5",
|
|
25
|
-
"@itwin/build-tools": "3.4.0
|
|
26
|
-
"@itwin/core-bentley": "3.4.0
|
|
27
|
-
"@itwin/core-quantity": "3.4.0
|
|
28
|
-
"@itwin/eslint-plugin": "3.4.0
|
|
25
|
+
"@itwin/build-tools": "3.4.0",
|
|
26
|
+
"@itwin/core-bentley": "3.4.0",
|
|
27
|
+
"@itwin/core-quantity": "3.4.0",
|
|
28
|
+
"@itwin/eslint-plugin": "3.4.0",
|
|
29
29
|
"@types/almost-equal": "1.1.0",
|
|
30
30
|
"@types/benchmark": "^2.1.0",
|
|
31
31
|
"@types/chai": "4.3.1",
|
|
32
32
|
"@types/chai-as-promised": "^7",
|
|
33
33
|
"@types/mocha": "^8.2.2",
|
|
34
|
-
"@types/node": "16.11.
|
|
34
|
+
"@types/node": "16.11.59",
|
|
35
35
|
"@types/sinon": "^9.0.0",
|
|
36
36
|
"@xmldom/xmldom": "^0.7.0",
|
|
37
37
|
"benchmark": "^2.1.4",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"typescript": "~4.4.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"@itwin/core-bentley": "^3.4.0
|
|
50
|
-
"@itwin/core-quantity": "^3.4.0
|
|
49
|
+
"@itwin/core-bentley": "^3.4.0",
|
|
50
|
+
"@itwin/core-quantity": "^3.4.0"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"almost-equal": "^1.1.0"
|