@itwin/ecschema-metadata 5.0.0-dev.78 → 5.0.0-dev.79

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.
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaKey.js","sourceRoot":"","sources":["../../src/SchemaKey.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC;;GAEG;AACH,MAAM,OAAO,SAAS;IACZ,KAAK,GAAW,CAAC,CAAC;IAClB,MAAM,GAAW,CAAC,CAAC;IACnB,MAAM,GAAW,CAAC,CAAC;IAE3B;;;;OAIG;IACI,MAAM,CAAU,UAAU,GAAG,IAAI,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAE3D;;;;;;OAMG;IACH,YAAY,IAAa,EAAE,KAAc,EAAE,KAAc;QACvD,IAAI,SAAS,KAAK,IAAI;YACpB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QACpB,IAAI,SAAS,KAAK,KAAK;YACrB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACtB,IAAI,SAAS,KAAK,KAAK;YACrB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QAEtB,IAAI,IAAI,CAAC,KAAK,GAAG,GAAG,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,GAAG,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,OAAO,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;YACxH,MAAM,IAAI,cAAc,CAAC,eAAe,CAAC,gBAAgB,CAAC,CAAC;IAC/D,CAAC;IAED,IAAW,IAAI,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,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC9E,MAAM,aAAa,GAAG,IAAI,MAAM,CAAC,IAAI,IAAI,CAAC,UAAU,OAAO,aAAa,SAAS,IAAI,CAAC,IAAI,GAAG,EAAE,GAAG,CAAC,CAAC;QACpG,OAAO,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Metadata\n */\n\nimport { SchemaKeyProps } from \"./Deserialization/JsonProps\";\nimport { SchemaMatchType } from \"./ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"./Exception\";\nimport { ECName } from \"./ECName\";\n\n/**\n * @beta\n */\nexport class ECVersion {\n private _read: number = 0;\n private _write: number = 0;\n private _minor: number = 0;\n\n /**\n * Using a version with all zero is invalid\n * for a schema, but it can be used to indicate\n * \"no version has been specified\" when locating things\n */\n public static readonly NO_VERSION = new ECVersion(0, 0, 0);\n\n /**\n * The constructor will throw an ECObjectsError if any of the parameters below are above the threshold.\n * @param read Can support up to 999.\n * @param write Can support up to 999.\n * @param minor Can support up to 9999999.\n *\n */\n constructor(read?: number, write?: number, minor?: number) {\n if (undefined !== read)\n this._read = read;\n if (undefined !== write)\n this._write = write;\n if (undefined !== minor)\n this._minor = minor;\n\n if (this._read > 999 || this._read < 0 || this._write > 999 || this._write < 0 || this._minor > 9999999 || this._minor < 0)\n throw new ECObjectsError(ECObjectsStatus.InvalidECVersion);\n }\n\n public get read() { return this._read; }\n public get write() { return this._write; }\n public get minor() { return this._minor; }\n\n /**\n * Creates a string, in the format 'RR.ww.mm', representing this ECVersion.\n * @note The default is to pad with zeroes.\n * @param padZeroes If true, the returned string will strictly follow `RR.ww.mm` and add leading zeroes if necessary.\n */\n public toString(padZeroes: boolean = true): string {\n if (!padZeroes)\n return `${this.read}.${this.write}.${this.minor}`;\n\n const padWithZeroes = (num: number) => {\n return (num < 10 ? \"0\" : \"\") + num;\n };\n\n return `${padWithZeroes(this.read)}.${padWithZeroes(this.write)}.${padWithZeroes(this.minor)}`;\n }\n\n /**\n * Given a valid version string the\n * @param versionString A valid version string of the format, 'RR.ww.mm'.\n */\n public static fromString(versionString: string): ECVersion {\n const [read, write, minor] = versionString.split(\".\");\n if (!read)\n throw new ECObjectsError(ECObjectsStatus.InvalidECVersion, `The read version is missing from version string, ${versionString}`);\n\n if (!write)\n throw new ECObjectsError(ECObjectsStatus.InvalidECVersion, `The write version is missing from version string, ${versionString}`);\n\n if (!minor)\n throw new ECObjectsError(ECObjectsStatus.InvalidECVersion, `The minor version is missing from version string, ${versionString}`);\n\n return new ECVersion(+read, +write, +minor);\n }\n\n /**\n * Compares two schema versions.\n * @param rhs The schema to compare.\n * @return A negative number if this schema version is less than the given version, a positive number if greater, and 0 if are equivalent.\n */\n public compare(rhv: ECVersion): number {\n if (this.read !== rhv.read)\n return this.read - rhv.read;\n\n if (this.write !== rhv.write)\n return this.write - rhv.write;\n\n return this.minor - rhv.minor;\n }\n}\n\n/**\n * The SchemaKey contains a Schemas name and version.\n * @beta\n */\nexport class SchemaKey {\n private _name: ECName;\n protected _version: ECVersion;\n // public checksum: number;\n // TODO: need to add a checksum\n\n constructor(name: string, version: ECVersion);\n constructor(name: string, readVersion?: number, writeVersion?: number, minorVersion?: number);\n constructor(name: string, readOrVersion?: number | ECVersion, writeVersion?: number, minorVersion?: number) {\n this._name = new ECName(name);\n if (readOrVersion !== undefined && typeof (readOrVersion) !== \"number\")\n this._version = readOrVersion;\n else\n this._version = new ECVersion(readOrVersion, writeVersion, minorVersion);\n }\n\n public get version() { return this._version; }\n public get name() { return this._name.name; }\n public get readVersion() { return this.version.read; }\n public get writeVersion() { return this.version.write; }\n public get minorVersion() { return this.version.minor; }\n\n /**\n * Creates a string, in the format 'RR.ww.mm', representing this SchemaKey.\n * @note The default is to pad the full name with zeroes.\n * @param padZeroes If true, the returned string will strictly follow `Name.RR.ww.mm` and add leading zeroes if necessary.\n */\n public toString(padZeroes: boolean = true) { return `${this.name}.${this.version.toString(padZeroes)}`; }\n\n public static parseString(fullName: string) {\n const keyPieces = fullName.split(\".\");\n if (keyPieces.length !== 4)\n throw new ECObjectsError(ECObjectsStatus.InvalidECName);\n\n const schemaName = keyPieces[0];\n const readVer = Number(keyPieces[1]);\n const writeVer = Number(keyPieces[2]);\n const minorVer = Number(keyPieces[3]);\n return new SchemaKey(schemaName, new ECVersion(readVer, writeVer, minorVer));\n }\n\n /**\n * Compares two schema names, case-insensitive.\n * @return True if they match; otherwise, false.\n */\n public compareByName(rhs: SchemaKey | string | undefined): boolean {\n if (undefined === rhs)\n return false;\n\n if (typeof (rhs) === \"string\")\n return rhs.toLowerCase() === this.name.toLowerCase();\n\n return rhs.name.toLowerCase() === this.name.toLowerCase();\n }\n\n /**\n * Compares two schema versions.\n * @param rhs The schema to compare.\n * @return A negative number if this schema version is less than the given version, a positive number if greater, and 0 if are equivalent.\n */\n public compareByVersion(rhs: SchemaKey): number {\n return this.version.compare(rhs.version);\n }\n\n /**\n *\n * @param rhs The SchemaKey to compare with\n * @param matchType The match type to use for comparison.\n */\n public matches(rhs: Readonly<SchemaKey>, matchType: SchemaMatchType = SchemaMatchType.Exact): boolean {\n switch (matchType) {\n case SchemaMatchType.Identical:\n case SchemaMatchType.Exact:\n return this.compareByName(rhs.name) && this.readVersion === rhs.readVersion &&\n this.writeVersion === rhs.writeVersion && this.minorVersion === rhs.minorVersion;\n case SchemaMatchType.LatestReadCompatible:\n if (!this.compareByName(rhs.name))\n return false;\n\n if (rhs.readVersion !== this.readVersion)\n return false;\n\n if (this.writeVersion === rhs.writeVersion)\n return this.minorVersion >= rhs.minorVersion;\n\n return this.writeVersion > rhs.writeVersion;\n case SchemaMatchType.LatestWriteCompatible:\n return this.compareByName(rhs.name) && this.readVersion === rhs.readVersion &&\n this.writeVersion === rhs.writeVersion && this.minorVersion >= rhs.minorVersion;\n case SchemaMatchType.Latest:\n return this.compareByName(rhs.name);\n default:\n return false;\n }\n }\n\n /**\n * Deserializes a SchemaKeyProps JSON object into a SchemaKey object.\n * @param props SchemaKeyProps\n * @returns A SchemaKey object.\n */\n public static fromJSON(props: SchemaKeyProps): SchemaKey {\n return new SchemaKey(props.name, props.read, props.write, props.minor);\n }\n\n /**\n * Save this SchemaKey's properties to an object for serializing to JSON.\n */\n public toJSON(): SchemaKeyProps {\n return {\n name: this.name,\n read: this.readVersion,\n write: this.writeVersion,\n minor: this.minorVersion,\n };\n }\n}\n\n/**\n * The SchemaItemKey contains a SchemaItem's name and SchemaKey.\n * @beta\n */\nexport class SchemaItemKey {\n private _name: ECName;\n protected _schemaKey: SchemaKey;\n\n constructor(name: string, schema: SchemaKey) {\n this._name = new ECName(name);\n this._schemaKey = schema;\n }\n\n public get schemaKey() { return this._schemaKey; }\n public get name() { return this._name.name; }\n\n public get schemaName() { return this.schemaKey.name; }\n\n /** Returns the name in the format, {schemaName}.{name}. */\n public get fullName() { return `${this.schemaName}.${this.name}`; }\n\n /**\n * Checks whether this SchemaItemKey matches the one provided.\n * @param rhs The SchemaItemKey to compare to this.\n */\n // TODO: Need to add a match type\n public matches(rhs: SchemaItemKey): boolean {\n if (rhs.name !== this.name)\n return false;\n\n if (!rhs.schemaKey.matches(this.schemaKey, SchemaMatchType.Latest))\n return false;\n\n return true;\n }\n\n public matchesFullName(name: string): boolean {\n const schemaVersion = this.schemaKey.version.toString().replace(/\\./g, \"\\\\.\");\n const fullNameRegex = new RegExp(`^${this.schemaName}(\\\\.${schemaVersion})?[.:]${this.name}$`, \"i\");\n return fullNameRegex.test(name);\n }\n}\n"]}
1
+ {"version":3,"file":"SchemaKey.js","sourceRoot":"","sources":["../../src/SchemaKey.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG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AI,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Metadata\n */\n\nimport { SchemaKeyProps } from \"./Deserialization/JsonProps\";\nimport { SchemaMatchType } from \"./ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"./Exception\";\nimport { ECName } from \"./ECName\";\n\n/**\n * @beta\n */\nexport class ECVersion {\n private _read: number = 0;\n private _write: number = 0;\n private _minor: number = 0;\n\n /**\n * Using a version with all zero is invalid\n * for a schema, but it can be used to indicate\n * \"no version has been specified\" when locating things\n */\n public static readonly NO_VERSION = new ECVersion(0, 0, 0);\n\n /**\n * The constructor will throw an ECObjectsError if any of the parameters below are above the threshold.\n * @param read Can support up to 999.\n * @param write Can support up to 999.\n * @param minor Can support up to 9999999.\n *\n */\n constructor(read?: number, write?: number, minor?: number) {\n if (undefined !== read)\n this._read = read;\n if (undefined !== write)\n this._write = write;\n if (undefined !== minor)\n this._minor = minor;\n\n if (this._read > 999 || this._read < 0 || this._write > 999 || this._write < 0 || this._minor > 9999999 || this._minor < 0)\n throw new ECObjectsError(ECObjectsStatus.InvalidECVersion);\n }\n\n public get read() { return this._read; }\n public get write() { return this._write; }\n public get minor() { return this._minor; }\n\n /**\n * Creates a string, in the format 'RR.ww.mm', representing this ECVersion.\n * @note The default is to pad with zeroes.\n * @param padZeroes If true, the returned string will strictly follow `RR.ww.mm` and add leading zeroes if necessary.\n */\n public toString(padZeroes: boolean = true): string {\n if (!padZeroes)\n return `${this.read}.${this.write}.${this.minor}`;\n\n const padWithZeroes = (num: number) => {\n return (num < 10 ? \"0\" : \"\") + num;\n };\n\n return `${padWithZeroes(this.read)}.${padWithZeroes(this.write)}.${padWithZeroes(this.minor)}`;\n }\n\n /**\n * Given a valid version string the\n * @param versionString A valid version string of the format, 'RR.ww.mm'.\n */\n public static fromString(versionString: string): ECVersion {\n const [read, write, minor] = versionString.split(\".\");\n if (!read)\n throw new ECObjectsError(ECObjectsStatus.InvalidECVersion, `The read version is missing from version string, ${versionString}`);\n\n if (!write)\n throw new ECObjectsError(ECObjectsStatus.InvalidECVersion, `The write version is missing from version string, ${versionString}`);\n\n if (!minor)\n throw new ECObjectsError(ECObjectsStatus.InvalidECVersion, `The minor version is missing from version string, ${versionString}`);\n\n return new ECVersion(+read, +write, +minor);\n }\n\n /**\n * Compares two schema versions.\n * @param rhs The schema to compare.\n * @return A negative number if this schema version is less than the given version, a positive number if greater, and 0 if are equivalent.\n */\n public compare(rhv: ECVersion): number {\n if (this.read !== rhv.read)\n return this.read - rhv.read;\n\n if (this.write !== rhv.write)\n return this.write - rhv.write;\n\n return this.minor - rhv.minor;\n }\n}\n\n/**\n * The SchemaKey contains a Schemas name and version.\n * @beta\n */\nexport class SchemaKey {\n private _name: ECName;\n protected _version: ECVersion;\n // public checksum: number;\n // TODO: need to add a checksum\n\n constructor(name: string, version: ECVersion);\n constructor(name: string, readVersion?: number, writeVersion?: number, minorVersion?: number);\n constructor(name: string, readOrVersion?: number | ECVersion, writeVersion?: number, minorVersion?: number) {\n this._name = new ECName(name);\n if (readOrVersion !== undefined && typeof (readOrVersion) !== \"number\")\n this._version = readOrVersion;\n else\n this._version = new ECVersion(readOrVersion, writeVersion, minorVersion);\n }\n\n public get version() { return this._version; }\n public get name() { return this._name.name; }\n public get readVersion() { return this.version.read; }\n public get writeVersion() { return this.version.write; }\n public get minorVersion() { return this.version.minor; }\n\n /**\n * Creates a string, in the format 'RR.ww.mm', representing this SchemaKey.\n * @note The default is to pad the full name with zeroes.\n * @param padZeroes If true, the returned string will strictly follow `Name.RR.ww.mm` and add leading zeroes if necessary.\n */\n public toString(padZeroes: boolean = true) { return `${this.name}.${this.version.toString(padZeroes)}`; }\n\n public static parseString(fullName: string) {\n const keyPieces = fullName.split(\".\");\n if (keyPieces.length !== 4)\n throw new ECObjectsError(ECObjectsStatus.InvalidECName);\n\n const schemaName = keyPieces[0];\n const readVer = Number(keyPieces[1]);\n const writeVer = Number(keyPieces[2]);\n const minorVer = Number(keyPieces[3]);\n return new SchemaKey(schemaName, new ECVersion(readVer, writeVer, minorVer));\n }\n\n /**\n * Compares two schema names, case-insensitive.\n * @return True if they match; otherwise, false.\n */\n public compareByName(rhs: SchemaKey | string | undefined): boolean {\n if (undefined === rhs)\n return false;\n\n if (typeof (rhs) === \"string\")\n return rhs.toLowerCase() === this.name.toLowerCase();\n\n return rhs.name.toLowerCase() === this.name.toLowerCase();\n }\n\n /**\n * Compares two schema versions.\n * @param rhs The schema to compare.\n * @return A negative number if this schema version is less than the given version, a positive number if greater, and 0 if are equivalent.\n */\n public compareByVersion(rhs: SchemaKey): number {\n return this.version.compare(rhs.version);\n }\n\n /**\n *\n * @param rhs The SchemaKey to compare with\n * @param matchType The match type to use for comparison.\n */\n public matches(rhs: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Exact): boolean {\n switch (matchType) {\n case SchemaMatchType.Identical:\n case SchemaMatchType.Exact:\n return this.compareByName(rhs.name) && this.readVersion === rhs.readVersion &&\n this.writeVersion === rhs.writeVersion && this.minorVersion === rhs.minorVersion;\n case SchemaMatchType.LatestReadCompatible:\n if (!this.compareByName(rhs.name))\n return false;\n\n if (rhs.readVersion !== this.readVersion)\n return false;\n\n if (this.writeVersion === rhs.writeVersion)\n return this.minorVersion >= rhs.minorVersion;\n\n return this.writeVersion > rhs.writeVersion;\n case SchemaMatchType.LatestWriteCompatible:\n return this.compareByName(rhs.name) && this.readVersion === rhs.readVersion &&\n this.writeVersion === rhs.writeVersion && this.minorVersion >= rhs.minorVersion;\n case SchemaMatchType.Latest:\n return this.compareByName(rhs.name);\n default:\n return false;\n }\n }\n\n /**\n * Deserializes a SchemaKeyProps JSON object into a SchemaKey object.\n * @param props SchemaKeyProps\n * @returns A SchemaKey object.\n */\n public static fromJSON(props: SchemaKeyProps): SchemaKey {\n return new SchemaKey(props.name, props.read, props.write, props.minor);\n }\n\n /**\n * Save this SchemaKey's properties to an object for serializing to JSON.\n */\n public toJSON(): SchemaKeyProps {\n return {\n name: this.name,\n read: this.readVersion,\n write: this.writeVersion,\n minor: this.minorVersion,\n };\n }\n}\n\n/**\n * The SchemaItemKey contains a SchemaItem's name and SchemaKey.\n * @beta\n */\nexport class SchemaItemKey {\n private _name: ECName;\n protected _schemaKey: SchemaKey;\n\n constructor(name: string, schema: SchemaKey) {\n this._name = new ECName(name);\n this._schemaKey = schema;\n }\n\n public get schemaKey() { return this._schemaKey; }\n public get name() { return this._name.name; }\n\n public get schemaName() { return this.schemaKey.name; }\n\n /** Returns the name in the format, {schemaName}.{name}. */\n public get fullName() { return `${this.schemaName}.${this.name}`; }\n\n /**\n * Checks whether this SchemaItemKey matches the one provided.\n * @param rhs The SchemaItemKey to compare to this.\n */\n // TODO: Need to add a match type\n public matches(rhs: SchemaItemKey): boolean {\n if (rhs.name !== this.name)\n return false;\n\n if (!rhs.schemaKey.matches(this.schemaKey, SchemaMatchType.Latest))\n return false;\n\n return true;\n }\n\n public matchesFullName(name: string): boolean {\n const schemaVersion = this.schemaKey.version.toString().replace(/\\./g, \"\\\\.\");\n const fullNameRegex = new RegExp(`^${this.schemaName}(\\\\.${schemaVersion})?[.:]${this.name}$`, \"i\");\n return fullNameRegex.test(name);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaGraph.js","sourceRoot":"","sources":["../../../src/utils/SchemaGraph.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAG/F,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAc/D;;;GAGG;AACH,MAAM,OAAO,WAAW;IACd,QAAQ,GAAiB,EAAE,CAAC;IAEpC,gBAAwB,CAAC;IAEjB,IAAI,CAAC,SAA8B;QACzC,OAAO,IAAI,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C,IAAI,CAAC,CAAC,CAAC,CAAC;YAEvB,KAAK,MAAM,SAAS,IAAI,CAAC,CAAC,UAAU,EAAE,CAAC;gBACrC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;oBAClC,QAAQ,CAAC,SAAS,CAAC,CAAC;YACxB,CAAC;QACH,CAAC,CAAC;QAEF,QAAQ,CAAC,MAAM,CAAC,CAAC;QACjB,OAAO,KAAK,CAAC;IACf,CAAC;CAEF","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 { SchemaContext } from \"../Context\";\nimport { SchemaMatchType } from \"../ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\nimport { SchemaInfo } from \"../Interfaces\";\nimport { Schema } from \"../Metadata/Schema\";\nimport { SchemaKey } from \"../SchemaKey\";\n\n/**\n * A schema and it's reference that make up part of a schema cycle\n * @internal\n */\nexport interface ReferenceCycle {\n schema: SchemaInfo;\n refSchema: SchemaInfo;\n}\n\n/**\n * Utility class for detecting cyclic references in a Schema graph.\n * @internal\n */\nexport class SchemaGraph {\n private _schemas: SchemaInfo[] = [];\n\n private constructor() { }\n\n private find(schemaKey: Readonly<SchemaKey>) {\n return this._schemas.find((info: SchemaInfo) => info.schemaKey.matches(schemaKey, SchemaMatchType.Latest));\n }\n\n /**\n * Detected cyclic references in a schema and throw an exception if a cycle is found.\n */\n public throwIfCycles() {\n const cycles = this.detectCycles();\n if (cycles) {\n const result = cycles.map((cycle) => `${cycle.schema.schemaKey.name} --> ${cycle.refSchema.schemaKey.name}`).join(\", \");\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Schema '${this._schemas[0].schemaKey.name}' has reference cycles: ${result}`);\n }\n }\n\n /**\n * Detected cyclic references in a schema.\n * @returns An array describing the cycle if there is a cycle or undefined if no cycles found.\n */\n public detectCycles(): ReferenceCycle[] | undefined {\n const visited = {};\n const recStack = {};\n const cycles: ReferenceCycle[] = [];\n\n for (const schema of this._schemas) {\n if (this.detectCycleUtil(schema, visited, recStack, cycles)) {\n return cycles.length > 0 ? cycles : undefined;\n }\n }\n\n return undefined;\n }\n\n private detectCycleUtil(schema: SchemaInfo, visited: any, recStack: any, cycles: ReferenceCycle[]): boolean {\n let cycleFound = false;\n\n if (!visited[schema.schemaKey.name]) {\n visited[schema.schemaKey.name] = true;\n recStack[schema.schemaKey.name] = true;\n\n for (const refKey of schema.references) {\n const refSchema = this.find(refKey.schemaKey);\n if (undefined === refSchema)\n throw new ECObjectsError(ECObjectsStatus.UnableToLoadSchema, `Could not find the schema info for ref schema ${refKey.schemaKey.toString()} for schema ${schema.schemaKey.toString()}`);\n if (!visited[refKey.schemaKey.name] && this.detectCycleUtil(refSchema, visited, recStack, cycles)) {\n cycles.push({ schema, refSchema });\n cycleFound = true;\n } else if (recStack[refKey.schemaKey.name]) {\n cycles.push({ schema, refSchema });\n cycleFound = true;\n }\n }\n }\n if (!cycleFound)\n recStack[schema.schemaKey.name] = false;\n\n return cycleFound;\n }\n\n /**\n * Generates a SchemaGraph for the input schema using the context to find info on referenced schemas. Use the generateGraphSync if you have the fully loaded Schema.\n * @param schema The SchemaInfo to build the graph from\n * @param context The SchemaContext used to locate info on the referenced schemas\n * @returns A SchemaGraph that can be used to detect schema cycles\n */\n public static async generateGraph(schema: SchemaInfo, context: SchemaContext): Promise<SchemaGraph> {\n const graph = new SchemaGraph();\n\n const genGraph = async (s: SchemaInfo) => {\n if (graph.find(s.schemaKey))\n return;\n\n graph._schemas.push(s);\n\n for (const refSchema of s.references) {\n if (!graph.find(refSchema.schemaKey)) {\n const refInfo = await context.getSchemaInfo(refSchema.schemaKey, SchemaMatchType.LatestWriteCompatible);\n if (undefined === refInfo) {\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema,\n `Could not locate the referenced schema, ${refSchema.schemaKey.name}.${refSchema.schemaKey.version.toString()}, of ${s.schemaKey.name} when populating the graph for ${schema.schemaKey.name}`);\n }\n await genGraph(refInfo);\n }\n }\n };\n\n await genGraph(schema);\n return graph;\n }\n\n /**\n * Generates a SchemaGraph for the input schema. Use the generateGraph if you just have schema info.\n * @param schema The Schema to build the graph from.\n * @returns A SchemaGraph that can be used to detect schema cycles\n */\n public static generateGraphSync(schema: Schema): SchemaGraph {\n const graph = new SchemaGraph();\n\n const genGraph = (s: Schema) => {\n if (graph.find(s.schemaKey))\n return;\n\n graph._schemas.push(s);\n\n for (const refSchema of s.references) {\n if (!graph.find(refSchema.schemaKey))\n genGraph(refSchema);\n }\n };\n\n genGraph(schema);\n return graph;\n }\n\n}\n\n"]}
1
+ {"version":3,"file":"SchemaGraph.js","sourceRoot":"","sources":["../../../src/utils/SchemaGraph.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAG/F,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAc/D;;;GAGG;AACH,MAAM,OAAO,WAAW;IACd,QAAQ,GAAiB,EAAE,CAAC;IAEpC,gBAAwB,CAAC;IAEjB,IAAI,CAAC,SAAoB;QAC/B,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAgB,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;IAC7G,CAAC;IAED;;OAEG;IACI,aAAa;QAClB,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QACnC,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,QAAQ,KAAK,CAAC,SAAS,CAAC,SAAS,CAA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O,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,EAAE,eAAe,CAAC,qBAAqB,CAAC,CAAC;oBACxG,IAAI,SAAS,KAAK,OAAO,EAAE,CAAC;wBAC1B,MAAM,IAAI,cAAc,CAAC,eAAe,CAAC,oBAAoB,EAC3D,2CAA2C,SAAS,CAAC,SAAS,CAAC,IAAI,IAAI,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,SAAS,CAAC,IAAI,kCAAkC,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;oBACpM,CAAC;oBACD,MAAM,QAAQ,CAAC,OAAO,CAAC,CAAC;gBAC1B,CAAC;YACH,CAAC;QACH,CAAC,CAAC;QAEF,MAAM,QAAQ,CAAC,MAAM,CAAC,CAAC;QACvB,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,iBAAiB,CAAC,MAAc;QAC5C,MAAM,KAAK,GAAG,IAAI,WAAW,EAAE,CAAC;QAEhC,MAAM,QAAQ,GAAG,CAAC,CAAS,EAAE,EAAE;YAC7B,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;gBACzB,OAAO;YAET,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAEvB,KAAK,MAAM,SAAS,IAAI,CAAC,CAAC,UAAU,EAAE,CAAC;gBACrC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;oBAClC,QAAQ,CAAC,SAAS,CAAC,CAAC;YACxB,CAAC;QACH,CAAC,CAAC;QAEF,QAAQ,CAAC,MAAM,CAAC,CAAC;QACjB,OAAO,KAAK,CAAC;IACf,CAAC;CAEF","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 { SchemaContext } from \"../Context\";\nimport { SchemaMatchType } from \"../ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\nimport { SchemaInfo } from \"../Interfaces\";\nimport { Schema } from \"../Metadata/Schema\";\nimport { SchemaKey } from \"../SchemaKey\";\n\n/**\n * A schema and it's reference that make up part of a schema cycle\n * @internal\n */\nexport interface ReferenceCycle {\n schema: SchemaInfo;\n refSchema: SchemaInfo;\n}\n\n/**\n * Utility class for detecting cyclic references in a Schema graph.\n * @internal\n */\nexport class SchemaGraph {\n private _schemas: SchemaInfo[] = [];\n\n private constructor() { }\n\n private find(schemaKey: SchemaKey) {\n return this._schemas.find((info: SchemaInfo) => info.schemaKey.matches(schemaKey, SchemaMatchType.Latest));\n }\n\n /**\n * Detected cyclic references in a schema and throw an exception if a cycle is found.\n */\n public throwIfCycles() {\n const cycles = this.detectCycles();\n if (cycles) {\n const result = cycles.map((cycle) => `${cycle.schema.schemaKey.name} --> ${cycle.refSchema.schemaKey.name}`).join(\", \");\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Schema '${this._schemas[0].schemaKey.name}' has reference cycles: ${result}`);\n }\n }\n\n /**\n * Detected cyclic references in a schema.\n * @returns An array describing the cycle if there is a cycle or undefined if no cycles found.\n */\n public detectCycles(): ReferenceCycle[] | undefined {\n const visited = {};\n const recStack = {};\n const cycles: ReferenceCycle[] = [];\n\n for (const schema of this._schemas) {\n if (this.detectCycleUtil(schema, visited, recStack, cycles)) {\n return cycles.length > 0 ? cycles : undefined;\n }\n }\n\n return undefined;\n }\n\n private detectCycleUtil(schema: SchemaInfo, visited: any, recStack: any, cycles: ReferenceCycle[]): boolean {\n let cycleFound = false;\n\n if (!visited[schema.schemaKey.name]) {\n visited[schema.schemaKey.name] = true;\n recStack[schema.schemaKey.name] = true;\n\n for (const refKey of schema.references) {\n const refSchema = this.find(refKey.schemaKey);\n if (undefined === refSchema)\n throw new ECObjectsError(ECObjectsStatus.UnableToLoadSchema, `Could not find the schema info for ref schema ${refKey.schemaKey.toString()} for schema ${schema.schemaKey.toString()}`);\n if (!visited[refKey.schemaKey.name] && this.detectCycleUtil(refSchema, visited, recStack, cycles)) {\n cycles.push({ schema, refSchema });\n cycleFound = true;\n } else if (recStack[refKey.schemaKey.name]) {\n cycles.push({ schema, refSchema });\n cycleFound = true;\n }\n }\n }\n if (!cycleFound)\n recStack[schema.schemaKey.name] = false;\n\n return cycleFound;\n }\n\n /**\n * Generates a SchemaGraph for the input schema using the context to find info on referenced schemas. Use the generateGraphSync if you have the fully loaded Schema.\n * @param schema The SchemaInfo to build the graph from\n * @param context The SchemaContext used to locate info on the referenced schemas\n * @returns A SchemaGraph that can be used to detect schema cycles\n */\n public static async generateGraph(schema: SchemaInfo, context: SchemaContext): Promise<SchemaGraph> {\n const graph = new SchemaGraph();\n\n const genGraph = async (s: SchemaInfo) => {\n if (graph.find(s.schemaKey))\n return;\n\n graph._schemas.push(s);\n\n for (const refSchema of s.references) {\n if (!graph.find(refSchema.schemaKey)) {\n const refInfo = await context.getSchemaInfo(refSchema.schemaKey, SchemaMatchType.LatestWriteCompatible);\n if (undefined === refInfo) {\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema,\n `Could not locate the referenced schema, ${refSchema.schemaKey.name}.${refSchema.schemaKey.version.toString()}, of ${s.schemaKey.name} when populating the graph for ${schema.schemaKey.name}`);\n }\n await genGraph(refInfo);\n }\n }\n };\n\n await genGraph(schema);\n return graph;\n }\n\n /**\n * Generates a SchemaGraph for the input schema. Use the generateGraph if you just have schema info.\n * @param schema The Schema to build the graph from.\n * @returns A SchemaGraph that can be used to detect schema cycles\n */\n public static generateGraphSync(schema: Schema): SchemaGraph {\n const graph = new SchemaGraph();\n\n const genGraph = (s: Schema) => {\n if (graph.find(s.schemaKey))\n return;\n\n graph._schemas.push(s);\n\n for (const refSchema of s.references) {\n if (!graph.find(refSchema.schemaKey))\n genGraph(refSchema);\n }\n };\n\n genGraph(schema);\n return graph;\n }\n\n}\n\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/ecschema-metadata",
3
- "version": "5.0.0-dev.78",
3
+ "version": "5.0.0-dev.79",
4
4
  "description": "ECObjects core concepts in typescript",
5
5
  "license": "MIT",
6
6
  "main": "lib/cjs/ecschema-metadata.js",
@@ -42,13 +42,13 @@
42
42
  "rimraf": "^3.0.2",
43
43
  "sinon": "^17.0.2",
44
44
  "typescript": "~5.6.2",
45
- "@itwin/core-bentley": "5.0.0-dev.78",
46
- "@itwin/core-quantity": "5.0.0-dev.78",
47
- "@itwin/build-tools": "5.0.0-dev.78"
45
+ "@itwin/build-tools": "5.0.0-dev.79",
46
+ "@itwin/core-bentley": "5.0.0-dev.79",
47
+ "@itwin/core-quantity": "5.0.0-dev.79"
48
48
  },
49
49
  "peerDependencies": {
50
- "@itwin/core-bentley": "5.0.0-dev.78",
51
- "@itwin/core-quantity": "5.0.0-dev.78"
50
+ "@itwin/core-bentley": "5.0.0-dev.79",
51
+ "@itwin/core-quantity": "5.0.0-dev.79"
52
52
  },
53
53
  "nyc": {
54
54
  "extends": "./node_modules/@itwin/build-tools/.nycrc"