@itwin/ecschema-metadata 5.5.0-dev.9 → 5.6.0-dev.1
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 +16 -1
- package/lib/cjs/Context.d.ts +4 -0
- package/lib/cjs/Context.d.ts.map +1 -1
- package/lib/cjs/Context.js +9 -1
- package/lib/cjs/Context.js.map +1 -1
- package/lib/cjs/Deserialization/JsonProps.d.ts +1 -1
- package/lib/cjs/Deserialization/JsonProps.js.map +1 -1
- package/lib/cjs/Metadata/Class.d.ts +0 -15
- package/lib/cjs/Metadata/Class.d.ts.map +1 -1
- package/lib/cjs/Metadata/Class.js +29 -82
- package/lib/cjs/Metadata/Class.js.map +1 -1
- package/lib/cjs/Metadata/EntityClass.d.ts.map +1 -1
- package/lib/cjs/Metadata/EntityClass.js +2 -0
- package/lib/cjs/Metadata/EntityClass.js.map +1 -1
- package/lib/cjs/utils/ECClassHierarchy.d.ts +18 -0
- package/lib/cjs/utils/ECClassHierarchy.d.ts.map +1 -0
- package/lib/cjs/utils/ECClassHierarchy.js +78 -0
- package/lib/cjs/utils/ECClassHierarchy.js.map +1 -0
- package/lib/cjs/utils/SchemaLoadingController.d.ts.map +1 -1
- package/lib/cjs/utils/SchemaLoadingController.js +5 -1
- package/lib/cjs/utils/SchemaLoadingController.js.map +1 -1
- package/lib/esm/Context.d.ts +4 -0
- package/lib/esm/Context.d.ts.map +1 -1
- package/lib/esm/Context.js +9 -1
- package/lib/esm/Context.js.map +1 -1
- package/lib/esm/Deserialization/JsonProps.d.ts +1 -1
- package/lib/esm/Deserialization/JsonProps.js.map +1 -1
- package/lib/esm/Metadata/Class.d.ts +0 -15
- package/lib/esm/Metadata/Class.d.ts.map +1 -1
- package/lib/esm/Metadata/Class.js +29 -82
- package/lib/esm/Metadata/Class.js.map +1 -1
- package/lib/esm/Metadata/EntityClass.d.ts.map +1 -1
- package/lib/esm/Metadata/EntityClass.js +2 -0
- package/lib/esm/Metadata/EntityClass.js.map +1 -1
- package/lib/esm/utils/ECClassHierarchy.d.ts +18 -0
- package/lib/esm/utils/ECClassHierarchy.d.ts.map +1 -0
- package/lib/esm/utils/ECClassHierarchy.js +74 -0
- package/lib/esm/utils/ECClassHierarchy.js.map +1 -0
- package/lib/esm/utils/SchemaLoadingController.d.ts.map +1 -1
- package/lib/esm/utils/SchemaLoadingController.js +5 -1
- package/lib/esm/utils/SchemaLoadingController.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,27 @@
|
|
|
1
1
|
# Change Log - @itwin/ecschema-metadata
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Fri, 12 Dec 2025 20:14:11 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 5.4.2
|
|
6
|
+
Fri, 12 Dec 2025 14:40:14 GMT
|
|
7
|
+
|
|
8
|
+
_Version update only_
|
|
9
|
+
|
|
10
|
+
## 5.4.1
|
|
11
|
+
Thu, 11 Dec 2025 21:29:31 GMT
|
|
12
|
+
|
|
13
|
+
_Version update only_
|
|
4
14
|
|
|
5
15
|
## 5.4.0
|
|
6
16
|
Tue, 02 Dec 2025 21:22:25 GMT
|
|
7
17
|
|
|
8
18
|
_Version update only_
|
|
9
19
|
|
|
20
|
+
## 5.3.4
|
|
21
|
+
Fri, 12 Dec 2025 20:11:41 GMT
|
|
22
|
+
|
|
23
|
+
_Version update only_
|
|
24
|
+
|
|
10
25
|
## 5.3.3
|
|
11
26
|
Thu, 20 Nov 2025 22:30:37 GMT
|
|
12
27
|
|
package/lib/cjs/Context.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { SchemaInfo } from "./Interfaces";
|
|
|
3
3
|
import { Schema } from "./Metadata/Schema";
|
|
4
4
|
import { SchemaItem } from "./Metadata/SchemaItem";
|
|
5
5
|
import { SchemaItemKey, SchemaKey } from "./SchemaKey";
|
|
6
|
+
import { ECClassHierarchy } from "./utils/ECClassHierarchy";
|
|
6
7
|
/**
|
|
7
8
|
* The interface defines what is needed to be an `ISchemaLocater`.
|
|
8
9
|
* A Schema Locater loads the requested schema if it can or returns undefined.
|
|
@@ -113,8 +114,11 @@ export declare class SchemaContext {
|
|
|
113
114
|
private _locaters;
|
|
114
115
|
private _knownSchemas;
|
|
115
116
|
private _fallbackLocaterDefined;
|
|
117
|
+
private _classHierarchy;
|
|
116
118
|
constructor();
|
|
117
119
|
get locaters(): ReadonlyArray<ISchemaLocater>;
|
|
120
|
+
/** @internal */
|
|
121
|
+
get classHierarchy(): ECClassHierarchy;
|
|
118
122
|
/**
|
|
119
123
|
* Adds a locater to the context.
|
|
120
124
|
*
|
package/lib/cjs/Context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../src/Context.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAiB,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../src/Context.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAiB,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAgB5D;;;;;;;GAOG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GAAG,MAAM,EAAE,cAAc,CAAC,EAAE,CAAC,GAAG,UAAU,GAAG,SAAS;IACnI,iBAAiB,CAAC,CAAC,SAAS,OAAO,UAAU,EAAE,eAAe,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS;IACjJ,iBAAiB,CAAC,CAAC,SAAS,OAAO,UAAU,EAAE,eAAe,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,CAAC,GAAG,UAAU,GAAG,SAAS;IA0BnJ;;;;;OAKG;IACI,cAAc,IAAI,QAAQ,CAAC,UAAU,CAAC;IAI7C;;;;;;OAMG;IACI,eAAe,IAAI,QAAQ,CAAC,MAAM,CAAC;CAG3C"}
|
package/lib/cjs/Context.js
CHANGED
|
@@ -9,6 +9,7 @@ const ECObjects_1 = require("./ECObjects");
|
|
|
9
9
|
const Exception_1 = require("./Exception");
|
|
10
10
|
const SchemaItem_1 = require("./Metadata/SchemaItem");
|
|
11
11
|
const SchemaKey_1 = require("./SchemaKey");
|
|
12
|
+
const ECClassHierarchy_1 = require("./utils/ECClassHierarchy");
|
|
12
13
|
/**
|
|
13
14
|
* @internal
|
|
14
15
|
*/
|
|
@@ -61,9 +62,10 @@ class SchemaCache {
|
|
|
61
62
|
// This promise is cached and will be awaited when the user requests the full schema.
|
|
62
63
|
// If the promise competes successfully before the user requests the schema it will be removed from the cache
|
|
63
64
|
// If it fails it will remain in the cache until the user awaits it and handles the error
|
|
64
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
65
65
|
schemaPromise.then(() => {
|
|
66
66
|
this.removeSchemaPromise(schemaInfo.schemaKey);
|
|
67
|
+
}).catch(() => {
|
|
68
|
+
// Leave the promise in the cache so that when the user requests the schema they get the rejection
|
|
67
69
|
});
|
|
68
70
|
}
|
|
69
71
|
/**
|
|
@@ -170,13 +172,19 @@ class SchemaContext {
|
|
|
170
172
|
_locaters;
|
|
171
173
|
_knownSchemas;
|
|
172
174
|
_fallbackLocaterDefined;
|
|
175
|
+
_classHierarchy;
|
|
173
176
|
constructor() {
|
|
174
177
|
this._locaters = [];
|
|
175
178
|
this._knownSchemas = new SchemaCache();
|
|
176
179
|
this._locaters.push(this._knownSchemas);
|
|
177
180
|
this._fallbackLocaterDefined = false;
|
|
181
|
+
this._classHierarchy = new ECClassHierarchy_1.ECClassHierarchy();
|
|
178
182
|
}
|
|
179
183
|
get locaters() { return this._locaters; }
|
|
184
|
+
/** @internal */
|
|
185
|
+
get classHierarchy() {
|
|
186
|
+
return this._classHierarchy;
|
|
187
|
+
}
|
|
180
188
|
/**
|
|
181
189
|
* Adds a locater to the context.
|
|
182
190
|
*
|
package/lib/cjs/Context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Context.js","sourceRoot":"","sources":["../../src/Context.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,2CAA8C;AAC9C,2CAA4D;AAG5D,sDAAmD;AACnD,2CAAuD;AAEvD;;GAEG;AACH,MAAM,SAAU,SAAQ,KAAkB;CAAI;AAgD9C;;GAEG;AACH,MAAa,WAAW;IACd,OAAO,CAAY;IAE3B;QACE,IAAI,CAAC,OAAO,GAAG,IAAI,SAAS,EAAE,CAAC;IACjC,CAAC;IAED,IAAW,KAAK,KAAK,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAE1C,kBAAkB,CAAC,SAAoB;QAC7C,OAAO,SAAS,KAAK,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAkB,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,2BAAe,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IAChK,CAAC;IAEO,mBAAmB,CAAC,SAAoB;QAC9C,OAAO,SAA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cAAc;QACnB,OAAO,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE,CAAC;IAC7C,CAAC;IAED;;;;;;OAMG;IACI,eAAe;QACpB,OAAO,IAAI,CAAC,aAAa,CAAC,aAAa,EAAE,CAAC;IAC5C,CAAC;CACF;AA7RD,sCA6RC","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 { SchemaMatchType } from \"./ECObjects\";\r\nimport { ECSchemaError, ECSchemaStatus } from \"./Exception\";\r\nimport { SchemaInfo } from \"./Interfaces\";\r\nimport { MutableSchema, Schema } from \"./Metadata/Schema\";\r\nimport { SchemaItem } from \"./Metadata/SchemaItem\";\r\nimport { SchemaItemKey, SchemaKey } from \"./SchemaKey\";\r\n\r\n/**\r\n * @internal\r\n */\r\nclass SchemaMap extends Array<SchemaEntry> { }\r\n\r\n/**\r\n * @internal\r\n */\r\ninterface SchemaEntry {\r\n schemaInfo: SchemaInfo;\r\n schema: Schema;\r\n schemaPromise?: Promise<Schema>;\r\n}\r\n\r\n/**\r\n * The interface defines what is needed to be an `ISchemaLocater`.\r\n * A Schema Locater loads the requested schema if it can or returns undefined.\r\n * Schema Locaters should always load the schema on each request and should not hold a cache of schemas.\r\n * Schema locaters should never be used directly to load a schema, they should be added to a `SchemaContext`\r\n * and the context should be used to load schemas. The `SchemaContext` caches schemas and manages schema life time.\r\n * @public @preview\r\n */\r\nexport interface ISchemaLocater {\r\n\r\n /**\r\n * Attempts to get a schema from the locater. Yields undefined if no matching schema is found.\r\n * For schemas that may have references, construct and call through a SchemaContext instead.\r\n * @param schemaKey key to look up\r\n * @param matchType how to match key against candidate schemas\r\n * @param context context for loading schema references\r\n */\r\n getSchema(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<Schema | undefined>;\r\n\r\n /**\r\n * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.\r\n * May return the entire Schema so long as it is completely loaded as it satisfies the SchemaInfo interface.\r\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\r\n * @param matchType The match type to use when locating the schema\r\n */\r\n getSchemaInfo(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<SchemaInfo | undefined>;\r\n\r\n /**\r\n * Attempts to get a schema from the locater. Yields undefined if no matching schema is found.\r\n * For schemas that may have references, construct and call through a SchemaContext instead.\r\n * @param schemaKey key to look up\r\n * @param matchType how to match key against candidate schemas\r\n * @param context context for loading schema references\r\n */\r\n getSchemaSync(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Schema | undefined;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class SchemaCache implements ISchemaLocater {\r\n private _schema: SchemaMap;\r\n\r\n constructor() {\r\n this._schema = new SchemaMap();\r\n }\r\n\r\n public get count() { return this._schema.length; }\r\n\r\n private loadedSchemaExists(schemaKey: SchemaKey): boolean {\r\n return undefined !== this._schema.find((entry: SchemaEntry) => entry.schemaInfo.schemaKey.matches(schemaKey, SchemaMatchType.Latest) && !entry.schemaPromise);\r\n }\r\n\r\n private schemaPromiseExists(schemaKey: SchemaKey): boolean {\r\n return undefined !== this._schema.find((entry: SchemaEntry) => entry.schemaInfo.schemaKey.matches(schemaKey, SchemaMatchType.Latest) && undefined !== entry.schemaPromise);\r\n }\r\n\r\n private findEntry(schemaKey: SchemaKey, matchType: SchemaMatchType): SchemaEntry | undefined {\r\n return this._schema.find((entry: SchemaEntry) => entry.schemaInfo.schemaKey.matches(schemaKey, matchType));\r\n }\r\n\r\n private removeSchemaPromise(schemaKey: SchemaKey) {\r\n const entry = this.findEntry(schemaKey, SchemaMatchType.Latest);\r\n if (entry)\r\n entry.schemaPromise = undefined;\r\n }\r\n\r\n private removeEntry(schemaKey: SchemaKey) {\r\n this._schema = this._schema.filter((entry: SchemaEntry) => !entry.schemaInfo.schemaKey.matches(schemaKey));\r\n }\r\n\r\n /**\r\n * Returns true if the schema exists in either the schema cache or the promise cache. SchemaMatchType.Latest used.\r\n * @param schemaKey The key to search for.\r\n */\r\n public schemaExists(schemaKey: SchemaKey): boolean {\r\n return this.loadedSchemaExists(schemaKey) || this.schemaPromiseExists(schemaKey);\r\n }\r\n\r\n /**\r\n * Adds a promise to load the schema to the cache. Does not allow for duplicate schemas in the cache of schemas or cache of promises, checks using SchemaMatchType.Latest.\r\n * When the promise completes the schema will be added to the schema cache and the promise will be removed from the promise cache\r\n * @param schemaInfo An object with the schema key for the schema being loaded and it's references\r\n * @param schema The partially loaded schema that the promise will fulfill\r\n * @param schemaPromise The schema promise to add to the cache.\r\n */\r\n public async addSchemaPromise(schemaInfo: SchemaInfo, schema: Schema, schemaPromise: Promise<Schema>) {\r\n if (this.schemaExists(schemaInfo.schemaKey))\r\n throw new ECSchemaError(ECSchemaStatus.DuplicateSchema, `The schema, ${schemaInfo.schemaKey.toString()}, already exists within this cache.`);\r\n\r\n this._schema.push({ schemaInfo, schema, schemaPromise });\r\n\r\n // This promise is cached and will be awaited when the user requests the full schema.\r\n // If the promise competes successfully before the user requests the schema it will be removed from the cache\r\n // If it fails it will remain in the cache until the user awaits it and handles the error\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n schemaPromise.then(() => {\r\n this.removeSchemaPromise(schemaInfo.schemaKey);\r\n });\r\n }\r\n\r\n /**\r\n * Adds a schema to the cache. Does not allow for duplicate schemas, checks using SchemaMatchType.Latest.\r\n * @param schema The schema to add to the cache.\r\n */\r\n public async addSchema(schema: Schema) {\r\n if (this.schemaExists(schema.schemaKey))\r\n throw new ECSchemaError(ECSchemaStatus.DuplicateSchema, `The schema, ${schema.schemaKey.toString()}, already exists within this cache.`);\r\n\r\n this._schema.push({ schemaInfo: schema, schema });\r\n }\r\n\r\n /**\r\n * Adds a schema to the cache. Does not allow for duplicate schemas, checks using SchemaMatchType.Latest.\r\n * @param schema The schema to add to the cache.\r\n */\r\n public addSchemaSync(schema: Schema) {\r\n if (this.schemaExists(schema.schemaKey))\r\n throw new ECSchemaError(ECSchemaStatus.DuplicateSchema, `The schema, ${schema.schemaKey.toString()}, already exists within this cache.`);\r\n\r\n this._schema.push({ schemaInfo: schema, schema });\r\n }\r\n\r\n /**\r\n * Gets the schema which matches the provided SchemaKey.\r\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\r\n * @param matchType The match type to use when locating the schema\r\n */\r\n public async getSchema(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<Schema | undefined> {\r\n if (this.count === 0)\r\n return undefined;\r\n\r\n const entry = this.findEntry(schemaKey, matchType);\r\n if (!entry)\r\n return undefined;\r\n\r\n if (entry.schemaPromise) {\r\n try {\r\n const schema = await entry.schemaPromise;\r\n return schema;\r\n } catch (e) {\r\n this.removeEntry(schemaKey);\r\n throw e;\r\n }\r\n }\r\n\r\n return entry.schema;\r\n }\r\n\r\n /**\r\n * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.\r\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\r\n * @param matchType The match type to use when locating the schema\r\n */\r\n public async getSchemaInfo(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<SchemaInfo | undefined> {\r\n if (this.count === 0)\r\n return undefined;\r\n\r\n const entry = this.findEntry(schemaKey, matchType);\r\n if (entry)\r\n return entry.schemaInfo;\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Gets the schema which matches the provided SchemaKey. If the schema is partially loaded an exception will be thrown.\r\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\r\n * @param matchType The match type to use when locating the schema\r\n */\r\n public getSchemaSync(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Schema | undefined {\r\n if (this.count === 0)\r\n return undefined;\r\n\r\n const entry = this.findEntry(schemaKey, matchType);\r\n if (entry) {\r\n if (entry.schemaPromise) {\r\n throw new ECSchemaError(ECSchemaStatus.UnableToLoadSchema, `The Schema ${schemaKey.toString()} is partially loaded so cannot be loaded synchronously.`);\r\n }\r\n return entry.schema;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Generator function that can iterate through each schema in _schema SchemaMap and items for each Schema.\r\n * Does not include schema items from schemas that are not completely loaded yet.\r\n */\r\n public * getSchemaItems(): Iterable<SchemaItem> {\r\n for (const entry of this._schema) {\r\n for (const schemaItem of entry.schema.getItems()) {\r\n yield schemaItem;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets all the schemas from the schema cache.\r\n * Does not include schemas from schemas that are not completely loaded yet.\r\n * @returns An array of Schema objects.\r\n */\r\n public getAllSchemas(): Iterable<Schema> {\r\n return this._schema.map((entry: SchemaEntry) => entry.schema);\r\n }\r\n}\r\n\r\n/**\r\n * The SchemaContext, context object is used to facilitate schema and schema item location.\r\n *\r\n * The context controls the lifetime of each schema that it knows about. It has to be explicitly removed from the context to delete a schema object.\r\n *\r\n * The context is made up of a group of Schema Locators.\r\n * @public @preview\r\n */\r\nexport class SchemaContext {\r\n private _locaters: ISchemaLocater[];\r\n\r\n private _knownSchemas: SchemaCache;\r\n private _fallbackLocaterDefined: boolean;\r\n\r\n constructor() {\r\n this._locaters = [];\r\n\r\n this._knownSchemas = new SchemaCache();\r\n this._locaters.push(this._knownSchemas);\r\n this._fallbackLocaterDefined = false;\r\n }\r\n\r\n public get locaters(): ReadonlyArray<ISchemaLocater> { return this._locaters; }\r\n\r\n /**\r\n * Adds a locater to the context.\r\n *\r\n * If no locaters are defined or a fallback locater is not defined, the new locater is added at the end of the locaters array.\r\n * If a fallback locater is already defined, the new locater is inserted before the fallback locater.\r\n *\r\n * @param locater - The locater to be added.\r\n */\r\n public addLocater(locater: ISchemaLocater) {\r\n const insertIndex = (this._locaters.length === 0 || !this._fallbackLocaterDefined) ? this._locaters.length : this._locaters.length - 1;\r\n this._locaters.splice(insertIndex, 0, locater);\r\n }\r\n\r\n /**\r\n * Adds a fallback locater to the context.\r\n *\r\n * If a fallback locater is already defined, it replaces the existing one.\r\n * Otherwise, it adds the new locater to the end of the locaters array and marks the fallback locater as defined.\r\n *\r\n * @param locater - The locater to be added as a fallback.\r\n */\r\n public addFallbackLocater(locater: ISchemaLocater) {\r\n if (this._fallbackLocaterDefined) {\r\n this._locaters[this._locaters.length - 1] = locater;\r\n } else {\r\n this._locaters.push(locater);\r\n this._fallbackLocaterDefined = true;\r\n }\r\n }\r\n\r\n /**\r\n * Adds the schema to this context. Use addSchemaPromise instead when asynchronously loading schemas.\r\n * @param schema The schema to add to this context\r\n */\r\n public async addSchema(schema: Schema) {\r\n this.addSchemaSync(schema);\r\n }\r\n\r\n /**\r\n * Adds the schema to this context\r\n * @param schema The schema to add to this context\r\n */\r\n public addSchemaSync(schema: Schema) {\r\n this._knownSchemas.addSchemaSync(schema);\r\n }\r\n\r\n /**\r\n * Adds the given SchemaItem to the the SchemaContext by locating the schema, with the best match of SchemaMatchType.Exact, and\r\n * @param schemaItem The SchemaItem to add\r\n * @deprecated in 4.0 - will not be removed until after 2026-06-13. Use ecschema-editing package\r\n */\r\n public async addSchemaItem(schemaItem: SchemaItem) {\r\n const schema = await this.getSchema(schemaItem.key.schemaKey, SchemaMatchType.Exact);\r\n if (!schema)\r\n throw new ECSchemaError(ECSchemaStatus.UnableToLocateSchema, `Unable to add the schema item ${schemaItem.name} to the schema ${schemaItem.key.schemaKey.toString()} because the schema could not be located.`);\r\n\r\n (schema as MutableSchema).addItem(schemaItem);\r\n }\r\n\r\n /**\r\n * Returns true if the schema is already in the context. SchemaMatchType.Latest is used to find a match.\r\n * @param schemaKey\r\n */\r\n public schemaExists(schemaKey: SchemaKey): boolean {\r\n return this._knownSchemas.schemaExists(schemaKey);\r\n }\r\n\r\n /**\r\n * Adds a promise to load the schema to the cache. Does not allow for duplicate schemas in the cache of schemas or cache of promises, checks using SchemaMatchType.Latest.\r\n * When the promise completes the schema will be added to the schema cache and the promise will be removed from the promise cache.\r\n * Use this method over addSchema when asynchronously loading schemas\r\n * @param schemaInfo An object with the schema key for the schema being loaded and it's references\r\n * @param schema The partially loaded schema that the promise will fulfill\r\n * @param schemaPromise The schema promise to add to the cache.\r\n */\r\n public async addSchemaPromise(schemaInfo: SchemaInfo, schema: Schema, schemaPromise: Promise<Schema>) {\r\n return this._knownSchemas.addSchemaPromise(schemaInfo, schema, schemaPromise);\r\n }\r\n\r\n /** Attempts to obtain a schema from this context that matches the specified criteria.\r\n * @param schemaKey Identifies the schema to obtain.\r\n * @param matchType Criteria by which to identify potentially matching schemas.\r\n * @returns the schema matching the input criteria, or `undefined` if no such schema could be located.\r\n */\r\n public async getSchema(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<Schema | undefined> {\r\n // the first locater is _knownSchemas, so we don't have to check the cache explicitly here\r\n for (const locater of this._locaters) {\r\n const schema = await locater.getSchema(schemaKey, matchType, this);\r\n if (undefined !== schema)\r\n return schema;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.\r\n * The fully loaded schema can be gotten later from the context using [[getSchema]].\r\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\r\n * @param matchType The match type to use when locating the schema\r\n */\r\n public async getSchemaInfo(schemaKey: SchemaKey, matchType: SchemaMatchType): Promise<SchemaInfo | undefined> {\r\n for (const locater of this._locaters) {\r\n const schemaInfo = await locater.getSchemaInfo(schemaKey, matchType, this);\r\n if (undefined !== schemaInfo)\r\n return schemaInfo;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /** Attempts to obtain a schema from this context that matches the specified criteria.\r\n * Will return undefined if the schema is partially loaded. Use [[getSchema]] to await until the schema is completely loaded.\r\n * @param schemaKey Identifies the schema to obtain.\r\n * @param matchType Criteria by which to identify potentially matching schemas.\r\n * @returns the schema matching the input criteria, or `undefined` if no such schema could be located.\r\n */\r\n public getSchemaSync(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Schema | undefined {\r\n // the first locater is _knownSchemas, so we don't have to check the cache explicitly here\r\n for (const locater of this._locaters) {\r\n const schema = locater.getSchemaSync(schemaKey, matchType, this);\r\n if (undefined !== schema)\r\n return schema;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Attempts to get a Schema from the context's cache.\r\n * Will await a partially loaded schema then return when it is completely loaded.\r\n * @param schemaKey The SchemaKey to identify the Schema.\r\n * @param matchType The SchemaMatch type to use. Default is SchemaMatchType.Latest.\r\n * @internal\r\n */\r\n public async getCachedSchema(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<Schema | undefined> {\r\n return this._knownSchemas.getSchema(schemaKey, matchType);\r\n }\r\n\r\n /**\r\n * Attempts to get a Schema from the context's cache.\r\n * Will return undefined if the cached schema is partially loaded. Use [[getCachedSchema]] to await until the schema is completely loaded.\r\n * @param schemaKey The SchemaKey to identify the Schema.\r\n * @param matchType The SchemaMatch type to use. Default is SchemaMatchType.Latest.\r\n * @internal\r\n */\r\n public getCachedSchemaSync(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Schema | undefined {\r\n return this._knownSchemas.getSchemaSync(schemaKey, matchType);\r\n }\r\n\r\n /**\r\n * Gets the schema item from the specified schema if it exists in this [[SchemaContext]].\r\n * Will await a partially loaded schema then look in it for the requested item.\r\n *\r\n * @param schemaNameOrKey - The SchemaItemKey identifying the item to return or the name of the schema or the schema item full name.\r\n * @param itemNameOrCtor - The name of the item to return or the constructor of the item to return.\r\n * @param itemConstructor - The constructor of the item to return.\r\n * @returns The requested schema item, or `undefined` if the item could not be found.\r\n *\r\n * @examples\r\n * ```typescript\r\n * const schemaItem = await schemaContext.getSchemaItem(new SchemaItemKey(\"TestElement\", new SchemaKey(\"TestSchema\")));\r\n * const schemaItemWithCtor = await schemaContext.getSchemaItem(new SchemaItemKey(\"TestElement\", new SchemaKey(\"TestSchema\")), EntityClass);\r\n * const schemaItemByName = await schemaContext.getSchemaItem(\"TestSchema\", \"TestElement\");\r\n * const schemaItemByNameWithCtor = await schemaContext.getSchemaItem(\"TestSchema\", \"TestElement\", EntityClass);\r\n * const schemaItemFullName = await schemaContext.getSchemaItem(\"TestSchema:TestElement\", EntityClass);\r\n * const schemaItemFullNameWithCtor = await schemaContext.getSchemaItem(\"TestSchema:TestElement\", EntityClass);\r\n * const schemaItemFullNameSep = await schemaContext.getSchemaItem(\"TestSchema.TestElement\", EntityClass);\r\n * const schemaItemFullNameSepWithCtor = await schemaContext.getSchemaItem(\"TestSchema.TestElement\", EntityClass);\r\n * ```\r\n */\r\n public async getSchemaItem<T extends typeof SchemaItem>(schemaNameOrKey: SchemaItemKey | string, itemNameOrCtor?: T): Promise<InstanceType<T> | undefined>\r\n public async getSchemaItem<T extends typeof SchemaItem>(schemaNameOrKey: SchemaItemKey | string, itemNameOrCtor?: T): Promise<SchemaItem | undefined>\r\n public async getSchemaItem<T extends typeof SchemaItem>(schemaNameOrKey: string, itemNameOrCtor: string, itemConstructor?: T): Promise<InstanceType<T> | undefined>\r\n public async getSchemaItem<T extends typeof SchemaItem>(schemaNameOrKey: string, itemNameOrCtor: string, itemConstructor?: T): Promise<SchemaItem | undefined>\r\n public async getSchemaItem<T extends typeof SchemaItem>(schemaNameOrKey: SchemaItemKey | string, itemNameOrCtor?: T | string, itemConstructor?: T): Promise<SchemaItem | InstanceType<T> | undefined> {\r\n let schemaKey: SchemaKey;\r\n if (typeof schemaNameOrKey === \"string\") {\r\n const [schemaName, itemName] = SchemaItem.parseFullName(schemaNameOrKey);\r\n schemaKey = (!schemaName) ? new SchemaKey(itemName) : new SchemaKey(schemaName);\r\n } else {\r\n schemaKey = schemaNameOrKey.schemaKey;\r\n }\r\n\r\n const schema = await this.getSchema(schemaKey, SchemaMatchType.Latest);\r\n\r\n if (!schema)\r\n return undefined;\r\n\r\n if (typeof itemNameOrCtor === \"string\") // Separate schema and item name arguments with/without an itemConstructor\r\n return itemConstructor ? schema.getItem(itemNameOrCtor, itemConstructor) : schema.getItem(itemNameOrCtor);\r\n\r\n if (typeof schemaNameOrKey === \"string\") // Single schema item full name argument with/without an itemConstructor\r\n return itemNameOrCtor ? schema.lookupItem(schemaNameOrKey, itemNameOrCtor) : schema.lookupItem(schemaNameOrKey);\r\n\r\n // Schema Item Key with/without an itemConstructor\r\n return itemNameOrCtor ? schema.getItem(schemaNameOrKey.name, itemNameOrCtor) : schema.getItem(schemaNameOrKey.name);\r\n }\r\n\r\n /**\r\n * Gets the schema item from the specified schema if it exists in this [[SchemaContext]].\r\n * Will return undefined if the cached schema is partially loaded. Use [[getSchemaItem]] to await until the schema is completely loaded.\r\n *\r\n * @param nameOrKey - The SchemaItemKey identifying the item to return or the name of the schema or the schema item full name.\r\n * @param nameOrCtor - The name of the item to return or the constructor of the item to return.\r\n * @param ctor - The constructor of the item to return.\r\n * @returns The requested schema item, or `undefined` if the item could not be found.\r\n *\r\n * @example\r\n * ```typescript\r\n * const schemaItem = schemaContext.getSchemaItemSync(new SchemaItemKey(\"TestElement\", new SchemaKey(\"TestSchema\")));\r\n * const schemaItemWithCtor = schemaContext.getSchemaItemSync(new SchemaItemKey(\"TestElement\", new SchemaKey(\"TestSchema\")), EntityClass);\r\n * const schemaItemByName = schemaContext.getSchemaItemSync(\"TestSchema\", \"TestElement\");\r\n * const schemaItemByNameWithCtor = schemaContext.getSchemaItemSync(\"TestSchema\", \"TestElement\", EntityClass);\r\n * const schemaItemFullName = schemaContext.getSchemaItemSync(\"TestSchema:TestElement\", EntityClass);\r\n * const schemaItemFullNameWithCtor = schemaContext.getSchemaItemSync(\"TestSchema:TestElement\", EntityClass);\r\n * const schemaItemFullNameSep = schemaContext.getSchemaItemSync(\"TestSchema.TestElement\", EntityClass);\r\n * const schemaItemFullNameSepWithCtor = schemaContext.getSchemaItemSync(\"TestSchema.TestElement\", EntityClass);\r\n * ```\r\n */\r\n public getSchemaItemSync<T extends typeof SchemaItem>(schemaNameOrKey: SchemaItemKey | string, itemNameOrCtor?: T): InstanceType<T> | undefined\r\n public getSchemaItemSync<T extends typeof SchemaItem>(schemaNameOrKey: SchemaItemKey | string, itemNameOrCtor?: T): SchemaItem | undefined\r\n public getSchemaItemSync<T extends typeof SchemaItem>(schemaNameOrKey: string, itemNameOrCtor: string, itemConstructor?: T): InstanceType<T> | undefined\r\n public getSchemaItemSync<T extends typeof SchemaItem>(schemaNameOrKey: string, itemNameOrCtor: string, itemConstructor?: T): SchemaItem | undefined\r\n public getSchemaItemSync<T extends typeof SchemaItem>(schemaNameOrKey: SchemaItemKey | string, itemNameOrCtor?: T | string, itemConstructor?: T): SchemaItem | InstanceType<T> | undefined {\r\n let schemaKey: SchemaKey;\r\n if (typeof schemaNameOrKey === \"string\") {\r\n const [schemaName, itemName] = SchemaItem.parseFullName(schemaNameOrKey);\r\n schemaKey = (!schemaName) ? new SchemaKey(itemName) : new SchemaKey(schemaName);\r\n } else {\r\n schemaKey = schemaNameOrKey.schemaKey;\r\n }\r\n\r\n const schema = this.getSchemaSync(schemaKey, SchemaMatchType.Latest);\r\n if (!schema)\r\n return undefined;\r\n\r\n // Separate schema and item name arguments with/without an itemConstructor\r\n if (typeof itemNameOrCtor === \"string\") {\r\n return itemConstructor ? schema.getItemSync(itemNameOrCtor, itemConstructor) : schema.getItemSync(itemNameOrCtor);\r\n }\r\n\r\n if (typeof schemaNameOrKey === \"string\") // Single schema item full name argument with/without an itemConstructor\r\n return itemNameOrCtor ? schema.lookupItemSync(schemaNameOrKey, itemNameOrCtor) : schema.lookupItemSync(schemaNameOrKey);\r\n\r\n // Schema Item Key with/without an itemConstructor\r\n return itemNameOrCtor ? schema.getItemSync(schemaNameOrKey.name, itemNameOrCtor) : schema.getItemSync(schemaNameOrKey.name);\r\n }\r\n\r\n /**\r\n * Iterates through the items of each schema known to the context. This includes schemas added to the\r\n * context using [[SchemaContext.addSchema]]. This does not include schemas that\r\n * can be located by an ISchemaLocater instance added to the context.\r\n * Does not include schema items from schemas that are not completely loaded yet.\r\n */\r\n public getSchemaItems(): Iterable<SchemaItem> {\r\n return this._knownSchemas.getSchemaItems();\r\n }\r\n\r\n /**\r\n * Gets all the Schemas known by the context. This includes schemas added to the\r\n * context using [[SchemaContext.addSchema]]. This does not include schemas that\r\n * can be located by an ISchemaLocater instance added to the context. Does not\r\n * include schemas that are partially loaded.\r\n * @returns An array of Schema objects.\r\n */\r\n public getKnownSchemas(): Iterable<Schema> {\r\n return this._knownSchemas.getAllSchemas();\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"Context.js","sourceRoot":"","sources":["../../src/Context.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,2CAA8C;AAC9C,2CAA4D;AAG5D,sDAAmD;AACnD,2CAAuD;AACvD,+DAA4D;AAE5D;;GAEG;AACH,MAAM,SAAU,SAAQ,KAAkB;CAAI;AAgD9C;;GAEG;AACH,MAAa,WAAW;IACd,OAAO,CAAY;IAE3B;QACE,IAAI,CAAC,OAAO,GAAG,IAAI,SAAS,EAAE,CAAC;IACjC,CAAC;IAED,IAAW,KAAK,KAAK,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAE1C,kBAAkB,CAAC,SAAoB;QAC7C,OAAO,SAAS,KAAK,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAkB,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,2BAAe,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IAChK,CAAC;IAEO,mBAAmB,CAAC,SAAoB;QAC9C,OAAO,SAAS,KAAK,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAkB,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,2BAAe,CAAC,MAAM,CAAC,IAAI,SAA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;IAC9H,CAAC;IAED;;;;;OAKG;IACI,cAAc;QACnB,OAAO,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE,CAAC;IAC7C,CAAC;IAED;;;;;;OAMG;IACI,eAAe;QACpB,OAAO,IAAI,CAAC,aAAa,CAAC,aAAa,EAAE,CAAC;IAC5C,CAAC;CACF;AApSD,sCAoSC","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 { SchemaMatchType } from \"./ECObjects\";\r\nimport { ECSchemaError, ECSchemaStatus } from \"./Exception\";\r\nimport { SchemaInfo } from \"./Interfaces\";\r\nimport { MutableSchema, Schema } from \"./Metadata/Schema\";\r\nimport { SchemaItem } from \"./Metadata/SchemaItem\";\r\nimport { SchemaItemKey, SchemaKey } from \"./SchemaKey\";\r\nimport { ECClassHierarchy } from \"./utils/ECClassHierarchy\";\r\n\r\n/**\r\n * @internal\r\n */\r\nclass SchemaMap extends Array<SchemaEntry> { }\r\n\r\n/**\r\n * @internal\r\n */\r\ninterface SchemaEntry {\r\n schemaInfo: SchemaInfo;\r\n schema: Schema;\r\n schemaPromise?: Promise<Schema>;\r\n}\r\n\r\n/**\r\n * The interface defines what is needed to be an `ISchemaLocater`.\r\n * A Schema Locater loads the requested schema if it can or returns undefined.\r\n * Schema Locaters should always load the schema on each request and should not hold a cache of schemas.\r\n * Schema locaters should never be used directly to load a schema, they should be added to a `SchemaContext`\r\n * and the context should be used to load schemas. The `SchemaContext` caches schemas and manages schema life time.\r\n * @public @preview\r\n */\r\nexport interface ISchemaLocater {\r\n\r\n /**\r\n * Attempts to get a schema from the locater. Yields undefined if no matching schema is found.\r\n * For schemas that may have references, construct and call through a SchemaContext instead.\r\n * @param schemaKey key to look up\r\n * @param matchType how to match key against candidate schemas\r\n * @param context context for loading schema references\r\n */\r\n getSchema(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<Schema | undefined>;\r\n\r\n /**\r\n * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.\r\n * May return the entire Schema so long as it is completely loaded as it satisfies the SchemaInfo interface.\r\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\r\n * @param matchType The match type to use when locating the schema\r\n */\r\n getSchemaInfo(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<SchemaInfo | undefined>;\r\n\r\n /**\r\n * Attempts to get a schema from the locater. Yields undefined if no matching schema is found.\r\n * For schemas that may have references, construct and call through a SchemaContext instead.\r\n * @param schemaKey key to look up\r\n * @param matchType how to match key against candidate schemas\r\n * @param context context for loading schema references\r\n */\r\n getSchemaSync(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Schema | undefined;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class SchemaCache implements ISchemaLocater {\r\n private _schema: SchemaMap;\r\n\r\n constructor() {\r\n this._schema = new SchemaMap();\r\n }\r\n\r\n public get count() { return this._schema.length; }\r\n\r\n private loadedSchemaExists(schemaKey: SchemaKey): boolean {\r\n return undefined !== this._schema.find((entry: SchemaEntry) => entry.schemaInfo.schemaKey.matches(schemaKey, SchemaMatchType.Latest) && !entry.schemaPromise);\r\n }\r\n\r\n private schemaPromiseExists(schemaKey: SchemaKey): boolean {\r\n return undefined !== this._schema.find((entry: SchemaEntry) => entry.schemaInfo.schemaKey.matches(schemaKey, SchemaMatchType.Latest) && undefined !== entry.schemaPromise);\r\n }\r\n\r\n private findEntry(schemaKey: SchemaKey, matchType: SchemaMatchType): SchemaEntry | undefined {\r\n return this._schema.find((entry: SchemaEntry) => entry.schemaInfo.schemaKey.matches(schemaKey, matchType));\r\n }\r\n\r\n private removeSchemaPromise(schemaKey: SchemaKey) {\r\n const entry = this.findEntry(schemaKey, SchemaMatchType.Latest);\r\n if (entry)\r\n entry.schemaPromise = undefined;\r\n }\r\n\r\n private removeEntry(schemaKey: SchemaKey) {\r\n this._schema = this._schema.filter((entry: SchemaEntry) => !entry.schemaInfo.schemaKey.matches(schemaKey));\r\n }\r\n\r\n /**\r\n * Returns true if the schema exists in either the schema cache or the promise cache. SchemaMatchType.Latest used.\r\n * @param schemaKey The key to search for.\r\n */\r\n public schemaExists(schemaKey: SchemaKey): boolean {\r\n return this.loadedSchemaExists(schemaKey) || this.schemaPromiseExists(schemaKey);\r\n }\r\n\r\n /**\r\n * Adds a promise to load the schema to the cache. Does not allow for duplicate schemas in the cache of schemas or cache of promises, checks using SchemaMatchType.Latest.\r\n * When the promise completes the schema will be added to the schema cache and the promise will be removed from the promise cache\r\n * @param schemaInfo An object with the schema key for the schema being loaded and it's references\r\n * @param schema The partially loaded schema that the promise will fulfill\r\n * @param schemaPromise The schema promise to add to the cache.\r\n */\r\n public async addSchemaPromise(schemaInfo: SchemaInfo, schema: Schema, schemaPromise: Promise<Schema>) {\r\n if (this.schemaExists(schemaInfo.schemaKey))\r\n throw new ECSchemaError(ECSchemaStatus.DuplicateSchema, `The schema, ${schemaInfo.schemaKey.toString()}, already exists within this cache.`);\r\n\r\n this._schema.push({ schemaInfo, schema, schemaPromise });\r\n\r\n // This promise is cached and will be awaited when the user requests the full schema.\r\n // If the promise competes successfully before the user requests the schema it will be removed from the cache\r\n // If it fails it will remain in the cache until the user awaits it and handles the error\r\n schemaPromise.then(() => {\r\n this.removeSchemaPromise(schemaInfo.schemaKey);\r\n }).catch(() => {\r\n // Leave the promise in the cache so that when the user requests the schema they get the rejection\r\n });\r\n }\r\n\r\n /**\r\n * Adds a schema to the cache. Does not allow for duplicate schemas, checks using SchemaMatchType.Latest.\r\n * @param schema The schema to add to the cache.\r\n */\r\n public async addSchema(schema: Schema) {\r\n if (this.schemaExists(schema.schemaKey))\r\n throw new ECSchemaError(ECSchemaStatus.DuplicateSchema, `The schema, ${schema.schemaKey.toString()}, already exists within this cache.`);\r\n\r\n this._schema.push({ schemaInfo: schema, schema });\r\n }\r\n\r\n /**\r\n * Adds a schema to the cache. Does not allow for duplicate schemas, checks using SchemaMatchType.Latest.\r\n * @param schema The schema to add to the cache.\r\n */\r\n public addSchemaSync(schema: Schema) {\r\n if (this.schemaExists(schema.schemaKey))\r\n throw new ECSchemaError(ECSchemaStatus.DuplicateSchema, `The schema, ${schema.schemaKey.toString()}, already exists within this cache.`);\r\n\r\n this._schema.push({ schemaInfo: schema, schema });\r\n }\r\n\r\n /**\r\n * Gets the schema which matches the provided SchemaKey.\r\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\r\n * @param matchType The match type to use when locating the schema\r\n */\r\n public async getSchema(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<Schema | undefined> {\r\n if (this.count === 0)\r\n return undefined;\r\n\r\n const entry = this.findEntry(schemaKey, matchType);\r\n if (!entry)\r\n return undefined;\r\n\r\n if (entry.schemaPromise) {\r\n try {\r\n const schema = await entry.schemaPromise;\r\n return schema;\r\n } catch (e) {\r\n this.removeEntry(schemaKey);\r\n throw e;\r\n }\r\n }\r\n\r\n return entry.schema;\r\n }\r\n\r\n /**\r\n * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.\r\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\r\n * @param matchType The match type to use when locating the schema\r\n */\r\n public async getSchemaInfo(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<SchemaInfo | undefined> {\r\n if (this.count === 0)\r\n return undefined;\r\n\r\n const entry = this.findEntry(schemaKey, matchType);\r\n if (entry)\r\n return entry.schemaInfo;\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Gets the schema which matches the provided SchemaKey. If the schema is partially loaded an exception will be thrown.\r\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\r\n * @param matchType The match type to use when locating the schema\r\n */\r\n public getSchemaSync(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Schema | undefined {\r\n if (this.count === 0)\r\n return undefined;\r\n\r\n const entry = this.findEntry(schemaKey, matchType);\r\n if (entry) {\r\n if (entry.schemaPromise) {\r\n throw new ECSchemaError(ECSchemaStatus.UnableToLoadSchema, `The Schema ${schemaKey.toString()} is partially loaded so cannot be loaded synchronously.`);\r\n }\r\n return entry.schema;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Generator function that can iterate through each schema in _schema SchemaMap and items for each Schema.\r\n * Does not include schema items from schemas that are not completely loaded yet.\r\n */\r\n public * getSchemaItems(): Iterable<SchemaItem> {\r\n for (const entry of this._schema) {\r\n for (const schemaItem of entry.schema.getItems()) {\r\n yield schemaItem;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets all the schemas from the schema cache.\r\n * Does not include schemas from schemas that are not completely loaded yet.\r\n * @returns An array of Schema objects.\r\n */\r\n public getAllSchemas(): Iterable<Schema> {\r\n return this._schema.map((entry: SchemaEntry) => entry.schema);\r\n }\r\n}\r\n\r\n/**\r\n * The SchemaContext, context object is used to facilitate schema and schema item location.\r\n *\r\n * The context controls the lifetime of each schema that it knows about. It has to be explicitly removed from the context to delete a schema object.\r\n *\r\n * The context is made up of a group of Schema Locators.\r\n * @public @preview\r\n */\r\nexport class SchemaContext {\r\n private _locaters: ISchemaLocater[];\r\n\r\n private _knownSchemas: SchemaCache;\r\n private _fallbackLocaterDefined: boolean;\r\n private _classHierarchy: ECClassHierarchy;\r\n\r\n constructor() {\r\n this._locaters = [];\r\n\r\n this._knownSchemas = new SchemaCache();\r\n this._locaters.push(this._knownSchemas);\r\n this._fallbackLocaterDefined = false;\r\n this._classHierarchy = new ECClassHierarchy();\r\n }\r\n\r\n public get locaters(): ReadonlyArray<ISchemaLocater> { return this._locaters; }\r\n\r\n /** @internal */\r\n public get classHierarchy(): ECClassHierarchy {\r\n return this._classHierarchy;\r\n }\r\n\r\n /**\r\n * Adds a locater to the context.\r\n *\r\n * If no locaters are defined or a fallback locater is not defined, the new locater is added at the end of the locaters array.\r\n * If a fallback locater is already defined, the new locater is inserted before the fallback locater.\r\n *\r\n * @param locater - The locater to be added.\r\n */\r\n public addLocater(locater: ISchemaLocater) {\r\n const insertIndex = (this._locaters.length === 0 || !this._fallbackLocaterDefined) ? this._locaters.length : this._locaters.length - 1;\r\n this._locaters.splice(insertIndex, 0, locater);\r\n }\r\n\r\n /**\r\n * Adds a fallback locater to the context.\r\n *\r\n * If a fallback locater is already defined, it replaces the existing one.\r\n * Otherwise, it adds the new locater to the end of the locaters array and marks the fallback locater as defined.\r\n *\r\n * @param locater - The locater to be added as a fallback.\r\n */\r\n public addFallbackLocater(locater: ISchemaLocater) {\r\n if (this._fallbackLocaterDefined) {\r\n this._locaters[this._locaters.length - 1] = locater;\r\n } else {\r\n this._locaters.push(locater);\r\n this._fallbackLocaterDefined = true;\r\n }\r\n }\r\n\r\n /**\r\n * Adds the schema to this context. Use addSchemaPromise instead when asynchronously loading schemas.\r\n * @param schema The schema to add to this context\r\n */\r\n public async addSchema(schema: Schema) {\r\n this.addSchemaSync(schema);\r\n }\r\n\r\n /**\r\n * Adds the schema to this context\r\n * @param schema The schema to add to this context\r\n */\r\n public addSchemaSync(schema: Schema) {\r\n this._knownSchemas.addSchemaSync(schema);\r\n }\r\n\r\n /**\r\n * Adds the given SchemaItem to the the SchemaContext by locating the schema, with the best match of SchemaMatchType.Exact, and\r\n * @param schemaItem The SchemaItem to add\r\n * @deprecated in 4.0 - will not be removed until after 2026-06-13. Use ecschema-editing package\r\n */\r\n public async addSchemaItem(schemaItem: SchemaItem) {\r\n const schema = await this.getSchema(schemaItem.key.schemaKey, SchemaMatchType.Exact);\r\n if (!schema)\r\n throw new ECSchemaError(ECSchemaStatus.UnableToLocateSchema, `Unable to add the schema item ${schemaItem.name} to the schema ${schemaItem.key.schemaKey.toString()} because the schema could not be located.`);\r\n\r\n (schema as MutableSchema).addItem(schemaItem);\r\n }\r\n\r\n /**\r\n * Returns true if the schema is already in the context. SchemaMatchType.Latest is used to find a match.\r\n * @param schemaKey\r\n */\r\n public schemaExists(schemaKey: SchemaKey): boolean {\r\n return this._knownSchemas.schemaExists(schemaKey);\r\n }\r\n\r\n /**\r\n * Adds a promise to load the schema to the cache. Does not allow for duplicate schemas in the cache of schemas or cache of promises, checks using SchemaMatchType.Latest.\r\n * When the promise completes the schema will be added to the schema cache and the promise will be removed from the promise cache.\r\n * Use this method over addSchema when asynchronously loading schemas\r\n * @param schemaInfo An object with the schema key for the schema being loaded and it's references\r\n * @param schema The partially loaded schema that the promise will fulfill\r\n * @param schemaPromise The schema promise to add to the cache.\r\n */\r\n public async addSchemaPromise(schemaInfo: SchemaInfo, schema: Schema, schemaPromise: Promise<Schema>) {\r\n return this._knownSchemas.addSchemaPromise(schemaInfo, schema, schemaPromise);\r\n }\r\n\r\n /** Attempts to obtain a schema from this context that matches the specified criteria.\r\n * @param schemaKey Identifies the schema to obtain.\r\n * @param matchType Criteria by which to identify potentially matching schemas.\r\n * @returns the schema matching the input criteria, or `undefined` if no such schema could be located.\r\n */\r\n public async getSchema(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<Schema | undefined> {\r\n // the first locater is _knownSchemas, so we don't have to check the cache explicitly here\r\n for (const locater of this._locaters) {\r\n const schema = await locater.getSchema(schemaKey, matchType, this);\r\n if (undefined !== schema)\r\n return schema;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.\r\n * The fully loaded schema can be gotten later from the context using [[getSchema]].\r\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\r\n * @param matchType The match type to use when locating the schema\r\n */\r\n public async getSchemaInfo(schemaKey: SchemaKey, matchType: SchemaMatchType): Promise<SchemaInfo | undefined> {\r\n for (const locater of this._locaters) {\r\n const schemaInfo = await locater.getSchemaInfo(schemaKey, matchType, this);\r\n if (undefined !== schemaInfo)\r\n return schemaInfo;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /** Attempts to obtain a schema from this context that matches the specified criteria.\r\n * Will return undefined if the schema is partially loaded. Use [[getSchema]] to await until the schema is completely loaded.\r\n * @param schemaKey Identifies the schema to obtain.\r\n * @param matchType Criteria by which to identify potentially matching schemas.\r\n * @returns the schema matching the input criteria, or `undefined` if no such schema could be located.\r\n */\r\n public getSchemaSync(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Schema | undefined {\r\n // the first locater is _knownSchemas, so we don't have to check the cache explicitly here\r\n for (const locater of this._locaters) {\r\n const schema = locater.getSchemaSync(schemaKey, matchType, this);\r\n if (undefined !== schema)\r\n return schema;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Attempts to get a Schema from the context's cache.\r\n * Will await a partially loaded schema then return when it is completely loaded.\r\n * @param schemaKey The SchemaKey to identify the Schema.\r\n * @param matchType The SchemaMatch type to use. Default is SchemaMatchType.Latest.\r\n * @internal\r\n */\r\n public async getCachedSchema(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<Schema | undefined> {\r\n return this._knownSchemas.getSchema(schemaKey, matchType);\r\n }\r\n\r\n /**\r\n * Attempts to get a Schema from the context's cache.\r\n * Will return undefined if the cached schema is partially loaded. Use [[getCachedSchema]] to await until the schema is completely loaded.\r\n * @param schemaKey The SchemaKey to identify the Schema.\r\n * @param matchType The SchemaMatch type to use. Default is SchemaMatchType.Latest.\r\n * @internal\r\n */\r\n public getCachedSchemaSync(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Schema | undefined {\r\n return this._knownSchemas.getSchemaSync(schemaKey, matchType);\r\n }\r\n\r\n /**\r\n * Gets the schema item from the specified schema if it exists in this [[SchemaContext]].\r\n * Will await a partially loaded schema then look in it for the requested item.\r\n *\r\n * @param schemaNameOrKey - The SchemaItemKey identifying the item to return or the name of the schema or the schema item full name.\r\n * @param itemNameOrCtor - The name of the item to return or the constructor of the item to return.\r\n * @param itemConstructor - The constructor of the item to return.\r\n * @returns The requested schema item, or `undefined` if the item could not be found.\r\n *\r\n * @examples\r\n * ```typescript\r\n * const schemaItem = await schemaContext.getSchemaItem(new SchemaItemKey(\"TestElement\", new SchemaKey(\"TestSchema\")));\r\n * const schemaItemWithCtor = await schemaContext.getSchemaItem(new SchemaItemKey(\"TestElement\", new SchemaKey(\"TestSchema\")), EntityClass);\r\n * const schemaItemByName = await schemaContext.getSchemaItem(\"TestSchema\", \"TestElement\");\r\n * const schemaItemByNameWithCtor = await schemaContext.getSchemaItem(\"TestSchema\", \"TestElement\", EntityClass);\r\n * const schemaItemFullName = await schemaContext.getSchemaItem(\"TestSchema:TestElement\", EntityClass);\r\n * const schemaItemFullNameWithCtor = await schemaContext.getSchemaItem(\"TestSchema:TestElement\", EntityClass);\r\n * const schemaItemFullNameSep = await schemaContext.getSchemaItem(\"TestSchema.TestElement\", EntityClass);\r\n * const schemaItemFullNameSepWithCtor = await schemaContext.getSchemaItem(\"TestSchema.TestElement\", EntityClass);\r\n * ```\r\n */\r\n public async getSchemaItem<T extends typeof SchemaItem>(schemaNameOrKey: SchemaItemKey | string, itemNameOrCtor?: T): Promise<InstanceType<T> | undefined>\r\n public async getSchemaItem<T extends typeof SchemaItem>(schemaNameOrKey: SchemaItemKey | string, itemNameOrCtor?: T): Promise<SchemaItem | undefined>\r\n public async getSchemaItem<T extends typeof SchemaItem>(schemaNameOrKey: string, itemNameOrCtor: string, itemConstructor?: T): Promise<InstanceType<T> | undefined>\r\n public async getSchemaItem<T extends typeof SchemaItem>(schemaNameOrKey: string, itemNameOrCtor: string, itemConstructor?: T): Promise<SchemaItem | undefined>\r\n public async getSchemaItem<T extends typeof SchemaItem>(schemaNameOrKey: SchemaItemKey | string, itemNameOrCtor?: T | string, itemConstructor?: T): Promise<SchemaItem | InstanceType<T> | undefined> {\r\n let schemaKey: SchemaKey;\r\n if (typeof schemaNameOrKey === \"string\") {\r\n const [schemaName, itemName] = SchemaItem.parseFullName(schemaNameOrKey);\r\n schemaKey = (!schemaName) ? new SchemaKey(itemName) : new SchemaKey(schemaName);\r\n } else {\r\n schemaKey = schemaNameOrKey.schemaKey;\r\n }\r\n\r\n const schema = await this.getSchema(schemaKey, SchemaMatchType.Latest);\r\n\r\n if (!schema)\r\n return undefined;\r\n\r\n if (typeof itemNameOrCtor === \"string\") // Separate schema and item name arguments with/without an itemConstructor\r\n return itemConstructor ? schema.getItem(itemNameOrCtor, itemConstructor) : schema.getItem(itemNameOrCtor);\r\n\r\n if (typeof schemaNameOrKey === \"string\") // Single schema item full name argument with/without an itemConstructor\r\n return itemNameOrCtor ? schema.lookupItem(schemaNameOrKey, itemNameOrCtor) : schema.lookupItem(schemaNameOrKey);\r\n\r\n // Schema Item Key with/without an itemConstructor\r\n return itemNameOrCtor ? schema.getItem(schemaNameOrKey.name, itemNameOrCtor) : schema.getItem(schemaNameOrKey.name);\r\n }\r\n\r\n /**\r\n * Gets the schema item from the specified schema if it exists in this [[SchemaContext]].\r\n * Will return undefined if the cached schema is partially loaded. Use [[getSchemaItem]] to await until the schema is completely loaded.\r\n *\r\n * @param nameOrKey - The SchemaItemKey identifying the item to return or the name of the schema or the schema item full name.\r\n * @param nameOrCtor - The name of the item to return or the constructor of the item to return.\r\n * @param ctor - The constructor of the item to return.\r\n * @returns The requested schema item, or `undefined` if the item could not be found.\r\n *\r\n * @example\r\n * ```typescript\r\n * const schemaItem = schemaContext.getSchemaItemSync(new SchemaItemKey(\"TestElement\", new SchemaKey(\"TestSchema\")));\r\n * const schemaItemWithCtor = schemaContext.getSchemaItemSync(new SchemaItemKey(\"TestElement\", new SchemaKey(\"TestSchema\")), EntityClass);\r\n * const schemaItemByName = schemaContext.getSchemaItemSync(\"TestSchema\", \"TestElement\");\r\n * const schemaItemByNameWithCtor = schemaContext.getSchemaItemSync(\"TestSchema\", \"TestElement\", EntityClass);\r\n * const schemaItemFullName = schemaContext.getSchemaItemSync(\"TestSchema:TestElement\", EntityClass);\r\n * const schemaItemFullNameWithCtor = schemaContext.getSchemaItemSync(\"TestSchema:TestElement\", EntityClass);\r\n * const schemaItemFullNameSep = schemaContext.getSchemaItemSync(\"TestSchema.TestElement\", EntityClass);\r\n * const schemaItemFullNameSepWithCtor = schemaContext.getSchemaItemSync(\"TestSchema.TestElement\", EntityClass);\r\n * ```\r\n */\r\n public getSchemaItemSync<T extends typeof SchemaItem>(schemaNameOrKey: SchemaItemKey | string, itemNameOrCtor?: T): InstanceType<T> | undefined\r\n public getSchemaItemSync<T extends typeof SchemaItem>(schemaNameOrKey: SchemaItemKey | string, itemNameOrCtor?: T): SchemaItem | undefined\r\n public getSchemaItemSync<T extends typeof SchemaItem>(schemaNameOrKey: string, itemNameOrCtor: string, itemConstructor?: T): InstanceType<T> | undefined\r\n public getSchemaItemSync<T extends typeof SchemaItem>(schemaNameOrKey: string, itemNameOrCtor: string, itemConstructor?: T): SchemaItem | undefined\r\n public getSchemaItemSync<T extends typeof SchemaItem>(schemaNameOrKey: SchemaItemKey | string, itemNameOrCtor?: T | string, itemConstructor?: T): SchemaItem | InstanceType<T> | undefined {\r\n let schemaKey: SchemaKey;\r\n if (typeof schemaNameOrKey === \"string\") {\r\n const [schemaName, itemName] = SchemaItem.parseFullName(schemaNameOrKey);\r\n schemaKey = (!schemaName) ? new SchemaKey(itemName) : new SchemaKey(schemaName);\r\n } else {\r\n schemaKey = schemaNameOrKey.schemaKey;\r\n }\r\n\r\n const schema = this.getSchemaSync(schemaKey, SchemaMatchType.Latest);\r\n if (!schema)\r\n return undefined;\r\n\r\n // Separate schema and item name arguments with/without an itemConstructor\r\n if (typeof itemNameOrCtor === \"string\") {\r\n return itemConstructor ? schema.getItemSync(itemNameOrCtor, itemConstructor) : schema.getItemSync(itemNameOrCtor);\r\n }\r\n\r\n if (typeof schemaNameOrKey === \"string\") // Single schema item full name argument with/without an itemConstructor\r\n return itemNameOrCtor ? schema.lookupItemSync(schemaNameOrKey, itemNameOrCtor) : schema.lookupItemSync(schemaNameOrKey);\r\n\r\n // Schema Item Key with/without an itemConstructor\r\n return itemNameOrCtor ? schema.getItemSync(schemaNameOrKey.name, itemNameOrCtor) : schema.getItemSync(schemaNameOrKey.name);\r\n }\r\n\r\n /**\r\n * Iterates through the items of each schema known to the context. This includes schemas added to the\r\n * context using [[SchemaContext.addSchema]]. This does not include schemas that\r\n * can be located by an ISchemaLocater instance added to the context.\r\n * Does not include schema items from schemas that are not completely loaded yet.\r\n */\r\n public getSchemaItems(): Iterable<SchemaItem> {\r\n return this._knownSchemas.getSchemaItems();\r\n }\r\n\r\n /**\r\n * Gets all the Schemas known by the context. This includes schemas added to the\r\n * context using [[SchemaContext.addSchema]]. This does not include schemas that\r\n * can be located by an ISchemaLocater instance added to the context. Does not\r\n * include schemas that are partially loaded.\r\n * @returns An array of Schema objects.\r\n */\r\n public getKnownSchemas(): Iterable<Schema> {\r\n return this._knownSchemas.getAllSchemas();\r\n }\r\n}\r\n"]}
|
|
@@ -101,7 +101,7 @@ export type StructClassProps = ClassProps;
|
|
|
101
101
|
*/
|
|
102
102
|
export interface CustomAttributeClassProps extends ClassProps {
|
|
103
103
|
/**
|
|
104
|
-
* Can be any combination of the [CustomAttributeContainerType]$
|
|
104
|
+
* Can be any combination of the [CustomAttributeContainerType]($docs/bis/ec/customattribute-container-types.md) string values
|
|
105
105
|
* separated by commas.
|
|
106
106
|
*/
|
|
107
107
|
readonly appliesTo: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsonProps.js","sourceRoot":"","sources":["../../../src/Deserialization/JsonProps.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG","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/** @packageDocumentation\r\n * @module Metadata\r\n */\r\n\r\nimport { FormatDefinition, FormatProps, UnitSystemKey } from \"@itwin/core-quantity\";\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport type AnyPropertyProps =\r\n | PrimitivePropertyProps\r\n | StructPropertyProps\r\n | PrimitiveArrayPropertyProps\r\n | StructArrayPropertyProps\r\n | NavigationPropertyProps;\r\n/**\r\n * @public @preview\r\n */\r\nexport type AnyClassProps =\r\n | EntityClassProps\r\n | MixinProps\r\n | CustomAttributeClassProps\r\n | RelationshipClassProps;\r\n/**\r\n * @public @preview\r\n */\r\nexport type AnySchemaItemProps =\r\n | AnyClassProps\r\n | EnumerationProps\r\n | KindOfQuantityProps\r\n | PropertyCategoryProps\r\n | SchemaItemUnitProps\r\n | InvertedUnitProps\r\n | ConstantProps\r\n | PhenomenonProps\r\n | SchemaItemFormatProps\r\n | SchemaItemOverrideFormatProps;\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport interface SchemaProps {\r\n readonly $schema: string;\r\n readonly name: string;\r\n readonly version: string;\r\n readonly alias: string;\r\n readonly label?: string;\r\n readonly description?: string;\r\n readonly references?: SchemaReferenceProps[];\r\n readonly items?: { [name: string]: SchemaItemProps };\r\n readonly customAttributes?: Array<{ [value: string]: any }>;\r\n readonly ecSpecMajorVersion?: number;\r\n readonly ecSpecMinorVersion?: number;\r\n}\r\n\r\n/**\r\n * JSON Object interface used to deserialize into a [[SchemaKey]].\r\n * @public @preview\r\n */\r\nexport interface SchemaKeyProps {\r\n /** The schema name */\r\n readonly name: string;\r\n /** Read version of the schema */\r\n readonly read: number;\r\n /** Write version of the schema */\r\n readonly write: number;\r\n /** Minor version of the schema */\r\n readonly minor: number;\r\n}\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport interface SchemaReferenceProps {\r\n readonly name: string;\r\n readonly version: string;\r\n}\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport interface SchemaItemProps {\r\n // NEEDSWORK: Still need to clarify how single-item deserialization works...\r\n readonly $schema?: string;\r\n readonly schema?: string; // conditionally required\r\n readonly schemaVersion?: string;\r\n readonly name?: string;\r\n readonly schemaItemType?: string;\r\n readonly label?: string;\r\n readonly description?: string;\r\n readonly customAttributes?: Array<{ [value: string]: any }>;\r\n readonly originalECSpecMajorVersion?: number;\r\n readonly originalECSpecMinorVersion?: number;\r\n}\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport interface ClassProps extends SchemaItemProps {\r\n readonly modifier?: string;\r\n readonly baseClass?: string;\r\n readonly properties?: AnyPropertyProps[];\r\n}\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport interface EntityClassProps extends ClassProps {\r\n readonly mixins?: string[];\r\n}\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport interface MixinProps extends ClassProps {\r\n readonly appliesTo: string;\r\n}\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport type StructClassProps = ClassProps;\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport interface CustomAttributeClassProps extends ClassProps {\r\n /**\r\n * Can be any combination of the [CustomAttributeContainerType]$
|
|
1
|
+
{"version":3,"file":"JsonProps.js","sourceRoot":"","sources":["../../../src/Deserialization/JsonProps.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG","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/** @packageDocumentation\r\n * @module Metadata\r\n */\r\n\r\nimport { FormatDefinition, FormatProps, UnitSystemKey } from \"@itwin/core-quantity\";\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport type AnyPropertyProps =\r\n | PrimitivePropertyProps\r\n | StructPropertyProps\r\n | PrimitiveArrayPropertyProps\r\n | StructArrayPropertyProps\r\n | NavigationPropertyProps;\r\n/**\r\n * @public @preview\r\n */\r\nexport type AnyClassProps =\r\n | EntityClassProps\r\n | MixinProps\r\n | CustomAttributeClassProps\r\n | RelationshipClassProps;\r\n/**\r\n * @public @preview\r\n */\r\nexport type AnySchemaItemProps =\r\n | AnyClassProps\r\n | EnumerationProps\r\n | KindOfQuantityProps\r\n | PropertyCategoryProps\r\n | SchemaItemUnitProps\r\n | InvertedUnitProps\r\n | ConstantProps\r\n | PhenomenonProps\r\n | SchemaItemFormatProps\r\n | SchemaItemOverrideFormatProps;\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport interface SchemaProps {\r\n readonly $schema: string;\r\n readonly name: string;\r\n readonly version: string;\r\n readonly alias: string;\r\n readonly label?: string;\r\n readonly description?: string;\r\n readonly references?: SchemaReferenceProps[];\r\n readonly items?: { [name: string]: SchemaItemProps };\r\n readonly customAttributes?: Array<{ [value: string]: any }>;\r\n readonly ecSpecMajorVersion?: number;\r\n readonly ecSpecMinorVersion?: number;\r\n}\r\n\r\n/**\r\n * JSON Object interface used to deserialize into a [[SchemaKey]].\r\n * @public @preview\r\n */\r\nexport interface SchemaKeyProps {\r\n /** The schema name */\r\n readonly name: string;\r\n /** Read version of the schema */\r\n readonly read: number;\r\n /** Write version of the schema */\r\n readonly write: number;\r\n /** Minor version of the schema */\r\n readonly minor: number;\r\n}\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport interface SchemaReferenceProps {\r\n readonly name: string;\r\n readonly version: string;\r\n}\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport interface SchemaItemProps {\r\n // NEEDSWORK: Still need to clarify how single-item deserialization works...\r\n readonly $schema?: string;\r\n readonly schema?: string; // conditionally required\r\n readonly schemaVersion?: string;\r\n readonly name?: string;\r\n readonly schemaItemType?: string;\r\n readonly label?: string;\r\n readonly description?: string;\r\n readonly customAttributes?: Array<{ [value: string]: any }>;\r\n readonly originalECSpecMajorVersion?: number;\r\n readonly originalECSpecMinorVersion?: number;\r\n}\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport interface ClassProps extends SchemaItemProps {\r\n readonly modifier?: string;\r\n readonly baseClass?: string;\r\n readonly properties?: AnyPropertyProps[];\r\n}\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport interface EntityClassProps extends ClassProps {\r\n readonly mixins?: string[];\r\n}\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport interface MixinProps extends ClassProps {\r\n readonly appliesTo: string;\r\n}\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport type StructClassProps = ClassProps;\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport interface CustomAttributeClassProps extends ClassProps {\r\n /**\r\n * Can be any combination of the [CustomAttributeContainerType]($docs/bis/ec/customattribute-container-types.md) string values\r\n * separated by commas.\r\n */\r\n readonly appliesTo: string;\r\n}\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport interface RelationshipClassProps extends ClassProps {\r\n readonly strength: string;\r\n readonly strengthDirection: string;\r\n readonly source: RelationshipConstraintProps;\r\n readonly target: RelationshipConstraintProps;\r\n}\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport interface RelationshipConstraintProps {\r\n readonly multiplicity: string;\r\n readonly roleLabel: string;\r\n readonly polymorphic: boolean;\r\n readonly abstractConstraint?: string;\r\n readonly constraintClasses: string[];\r\n readonly customAttributes?: Array<{ [value: string]: any }>;\r\n}\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport interface EnumerationProps extends SchemaItemProps {\r\n readonly type: string;\r\n readonly isStrict: boolean;\r\n readonly enumerators: EnumeratorProps[];\r\n}\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport interface EnumeratorProps {\r\n readonly name: string;\r\n readonly value: string | number;\r\n readonly label?: string;\r\n readonly description?: string;\r\n}\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport interface KindOfQuantityProps extends SchemaItemProps {\r\n readonly persistenceUnit: string;\r\n readonly presentationUnits?: string | string[];\r\n readonly relativeError: number;\r\n}\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport interface PropertyCategoryProps extends SchemaItemProps {\r\n readonly priority: number;\r\n}\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport interface PropertyProps {\r\n readonly name: string;\r\n readonly type: string;\r\n readonly description?: string;\r\n readonly label?: string;\r\n readonly isReadOnly?: boolean;\r\n readonly category?: string;\r\n readonly priority?: number;\r\n readonly inherited?: boolean;\r\n readonly kindOfQuantity?: string;\r\n readonly customAttributes?: Array<{ [value: string]: any }>;\r\n}\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport interface PrimitiveOrEnumPropertyBaseProps extends PropertyProps {\r\n readonly extendedTypeName?: string;\r\n readonly minLength?: number;\r\n readonly maxLength?: number;\r\n readonly minValue?: number;\r\n readonly maxValue?: number;\r\n}\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport interface PrimitivePropertyProps\r\n extends PrimitiveOrEnumPropertyBaseProps {\r\n readonly typeName: string;\r\n}\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport interface StructPropertyProps extends PropertyProps {\r\n readonly typeName: string;\r\n}\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport interface EnumerationPropertyProps\r\n extends PrimitiveOrEnumPropertyBaseProps {\r\n readonly typeName: string;\r\n}\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport interface ArrayPropertyProps extends PrimitiveOrEnumPropertyBaseProps {\r\n readonly minOccurs?: number;\r\n readonly maxOccurs?: number;\r\n}\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport interface PrimitiveArrayPropertyProps extends ArrayPropertyProps {\r\n readonly typeName: string;\r\n}\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport interface StructArrayPropertyProps extends ArrayPropertyProps {\r\n readonly typeName: string;\r\n}\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport interface NavigationPropertyProps extends PropertyProps {\r\n readonly relationshipName: string;\r\n readonly direction: string;\r\n}\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport interface ConstantProps extends SchemaItemProps {\r\n readonly phenomenon: string;\r\n readonly definition: string;\r\n readonly numerator?: number;\r\n readonly denominator?: number;\r\n}\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport type SchemaItemFormatProps = SchemaItemProps & FormatProps;\r\n\r\n/**\r\n * This interface defines properties necessary to support persistence of a set of formats.\r\n * @beta\r\n */\r\nexport interface FormatSet {\r\n /** The unique name identifier for this format set. */\r\n name: string;\r\n /** The display label for this format set. */\r\n label: string;\r\n /** The description for this format set. */\r\n description?: string;\r\n /** A [UnitSystemKey]($quantity) that determines the unit system for this format set. */\r\n unitSystem: UnitSystemKey;\r\n /** \r\n * A mapping of kind of quantity identifiers to their corresponding format properties.\r\n * When a format is a [FormatDefinition]($quantity), it defines the complete format specification.\r\n * When a format is a string, it references another kindOfQuantityId to map one format to another.\r\n */\r\n formats: { [kindOfQuantityId: string]: FormatDefinition | string };\r\n}\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport interface SchemaItemOverrideFormatProps extends SchemaItemFormatProps {\r\n readonly parent: string;\r\n}\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport interface InvertedUnitProps extends SchemaItemProps {\r\n readonly invertsUnit: string;\r\n readonly unitSystem: string;\r\n}\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport interface PhenomenonProps extends SchemaItemProps {\r\n readonly definition: string;\r\n}\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport type UnitSystemProps = SchemaItemProps;\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport interface SchemaItemUnitProps extends SchemaItemProps {\r\n readonly phenomenon: string;\r\n readonly unitSystem: string;\r\n readonly definition: string;\r\n readonly numerator?: number;\r\n readonly denominator?: number;\r\n readonly offset?: number;\r\n}\r\n"]}
|
|
@@ -18,7 +18,6 @@ export declare abstract class ECClass extends SchemaItem implements CustomAttrib
|
|
|
18
18
|
static get schemaItemType(): SupportedSchemaItemType;
|
|
19
19
|
private _modifier;
|
|
20
20
|
private _baseClass?;
|
|
21
|
-
private _derivedClasses?;
|
|
22
21
|
private _properties?;
|
|
23
22
|
private _customAttributes?;
|
|
24
23
|
private _mergedPropertyCache?;
|
|
@@ -300,20 +299,6 @@ export declare abstract class ECClass extends SchemaItem implements CustomAttrib
|
|
|
300
299
|
* @internal
|
|
301
300
|
*/
|
|
302
301
|
protected setModifier(modifier: ECClassModifier): void;
|
|
303
|
-
/**
|
|
304
|
-
* Adds an ECClass to the derived class collection. This method is only intended to update the local
|
|
305
|
-
* cache of derived classes. For adding a class to the hierarchy, use the baseClass setter method.
|
|
306
|
-
* @param prop The property to add.
|
|
307
|
-
* @return The property that was added.
|
|
308
|
-
*/
|
|
309
|
-
private addDerivedClass;
|
|
310
|
-
/**
|
|
311
|
-
* Removes an ECClass from the derived class collection. This method is only intended to update the local
|
|
312
|
-
* cache of derived classes. For updating the class hierarchy, use the baseClass setter method.
|
|
313
|
-
* @param prop The property to add.
|
|
314
|
-
* @return The property that was added.
|
|
315
|
-
*/
|
|
316
|
-
private removeDerivedClass;
|
|
317
302
|
}
|
|
318
303
|
/**
|
|
319
304
|
* A Typescript class representation of an ECStructClass.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Class.d.ts","sourceRoot":"","sources":["../../../src/Metadata/Class.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAE1D,OAAO,EAAiD,eAAe,EAA0C,aAAa,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAE9L,OAAO,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"Class.d.ts","sourceRoot":"","sources":["../../../src/Metadata/Class.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAE1D,OAAO,EAAiD,eAAe,EAA0C,aAAa,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAE9L,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,6BAA6B,EAAE,kBAAkB,EAA6B,MAAM,mBAAmB,CAAC;AAClI,OAAO,EAAE,WAAW,EAAE,MAAM,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BAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC;aACvG,6BAA6B,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,WAAW,GAAG,mBAAmB;aAElG,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;aAC3C,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;CAChE"}
|
|
@@ -28,7 +28,6 @@ class ECClass extends SchemaItem_1.SchemaItem {
|
|
|
28
28
|
static get schemaItemType() { return ECObjects_1.AbstractSchemaItemType.Class; } // need this so getItem("name", ECClass) in schema works
|
|
29
29
|
_modifier;
|
|
30
30
|
_baseClass;
|
|
31
|
-
_derivedClasses;
|
|
32
31
|
_properties;
|
|
33
32
|
_customAttributes;
|
|
34
33
|
_mergedPropertyCache;
|
|
@@ -63,18 +62,24 @@ class ECClass extends SchemaItem_1.SchemaItem {
|
|
|
63
62
|
const oldBaseClass = this._baseClass;
|
|
64
63
|
this._baseClass = baseClass;
|
|
65
64
|
if (baseClass)
|
|
66
|
-
this.
|
|
65
|
+
this.schema.context.classHierarchy.addBaseClass(this.key, baseClass);
|
|
67
66
|
else if (oldBaseClass)
|
|
68
|
-
this.
|
|
67
|
+
this.schema.context.classHierarchy.removeBaseClass(this.key, oldBaseClass);
|
|
69
68
|
}
|
|
70
69
|
/**
|
|
71
70
|
* Gets the derived classes belonging to this class.
|
|
72
71
|
* @returns An array of ECClasses or undefined if no derived classes exist.
|
|
73
72
|
*/
|
|
74
73
|
async getDerivedClasses() {
|
|
75
|
-
|
|
74
|
+
const derivedClasses = [];
|
|
75
|
+
for (const derivedClassKey of this.schema.context.classHierarchy.getDerivedClassKeys(this.key)) {
|
|
76
|
+
const derivedClass = await this.schema.context.getSchemaItem(derivedClassKey, ECClass);
|
|
77
|
+
if (derivedClass)
|
|
78
|
+
derivedClasses.push(derivedClass);
|
|
79
|
+
}
|
|
80
|
+
if (derivedClasses.length === 0)
|
|
76
81
|
return undefined;
|
|
77
|
-
return
|
|
82
|
+
return derivedClasses;
|
|
78
83
|
}
|
|
79
84
|
/**
|
|
80
85
|
* Convenience method for adding an already loaded ECProperty used by create*Property methods.
|
|
@@ -433,9 +438,7 @@ class ECClass extends SchemaItem_1.SchemaItem {
|
|
|
433
438
|
});
|
|
434
439
|
}
|
|
435
440
|
this._baseClass = lazyBase;
|
|
436
|
-
|
|
437
|
-
return;
|
|
438
|
-
this.addDerivedClass(baseClass, this);
|
|
441
|
+
this.schema.context.classHierarchy.addBaseClass(this.key, lazyBase);
|
|
439
442
|
}
|
|
440
443
|
}
|
|
441
444
|
async fromJSON(classProps) {
|
|
@@ -457,39 +460,16 @@ class ECClass extends SchemaItem_1.SchemaItem {
|
|
|
457
460
|
* This is essentially a depth-first traversal through the inheritance tree.
|
|
458
461
|
*/
|
|
459
462
|
async *getAllBaseClasses() {
|
|
460
|
-
const
|
|
461
|
-
|
|
462
|
-
if (
|
|
463
|
-
for (let i = ecClass.mixins.length - 1; i >= 0; i--) {
|
|
464
|
-
baseClasses.push(await ecClass.mixins[i]);
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
if (ecClass.baseClass)
|
|
468
|
-
baseClasses.push(await ecClass.baseClass);
|
|
469
|
-
};
|
|
470
|
-
while (baseClasses.length > 0) {
|
|
471
|
-
const baseClass = baseClasses.pop();
|
|
472
|
-
await addBaseClasses(baseClass);
|
|
473
|
-
if (baseClass !== this)
|
|
463
|
+
for (const baseClassKey of this.schema.context.classHierarchy.getBaseClassKeys(this.key)) {
|
|
464
|
+
const baseClass = await this.schema.lookupItem(baseClassKey, ECClass);
|
|
465
|
+
if (baseClass)
|
|
474
466
|
yield baseClass;
|
|
475
467
|
}
|
|
476
468
|
}
|
|
477
469
|
*getAllBaseClassesSync() {
|
|
478
|
-
const
|
|
479
|
-
|
|
480
|
-
if (ecClass.schemaItemType === ECObjects_1.SchemaItemType.EntityClass) { // cannot use EntityClass typeguard because of circular reference
|
|
481
|
-
for (const m of Array.from(ecClass.getMixinsSync()).reverse()) {
|
|
482
|
-
baseClasses.push(m);
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
const baseClass = ecClass.getBaseClassSync();
|
|
470
|
+
for (const baseClassKey of this.schema.context.classHierarchy.getBaseClassKeys(this.key)) {
|
|
471
|
+
const baseClass = this.schema.lookupItemSync(baseClassKey, ECClass);
|
|
486
472
|
if (baseClass)
|
|
487
|
-
baseClasses.push(baseClass);
|
|
488
|
-
};
|
|
489
|
-
while (baseClasses.length > 0) {
|
|
490
|
-
const baseClass = baseClasses.pop();
|
|
491
|
-
addBaseClasses(baseClass);
|
|
492
|
-
if (baseClass !== this)
|
|
493
473
|
yield baseClass;
|
|
494
474
|
}
|
|
495
475
|
}
|
|
@@ -637,35 +617,31 @@ class ECClass extends SchemaItem_1.SchemaItem {
|
|
|
637
617
|
return false;
|
|
638
618
|
}
|
|
639
619
|
async is(targetClass, schemaName) {
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
if (SchemaItem_1.SchemaItem.equalByKey(this, key))
|
|
644
|
-
return true;
|
|
645
|
-
return this.traverseBaseClasses((thisSchemaItem, thatSchemaItemOrKey) => SchemaItem_1.SchemaItem.equalByKey(thisSchemaItem, thatSchemaItemOrKey), key);
|
|
646
|
-
}
|
|
647
|
-
else {
|
|
648
|
-
(0, core_bentley_1.assert)(ECClass.isECClass(targetClass), "Expected targetClass to be of type ECClass");
|
|
649
|
-
if (SchemaItem_1.SchemaItem.equalByKey(this, targetClass))
|
|
650
|
-
return true;
|
|
651
|
-
return this.traverseBaseClasses((thisSchemaItem, thatSchemaItemOrKey) => SchemaItem_1.SchemaItem.equalByKey(thisSchemaItem, thatSchemaItemOrKey), targetClass);
|
|
652
|
-
}
|
|
620
|
+
return typeof targetClass === "string"
|
|
621
|
+
? this.isSync(targetClass, schemaName ?? "")
|
|
622
|
+
: this.isSync(targetClass);
|
|
653
623
|
}
|
|
654
624
|
/** @internal */
|
|
655
625
|
isSync(targetClass, schemaName) {
|
|
626
|
+
let targetSchemaKey;
|
|
656
627
|
if (schemaName !== undefined) {
|
|
657
628
|
(0, core_bentley_1.assert)(typeof (targetClass) === "string", "Expected targetClass of type string because schemaName was specified");
|
|
658
|
-
|
|
659
|
-
if (SchemaItem_1.SchemaItem.equalByKey(this,
|
|
629
|
+
targetSchemaKey = new SchemaKey_1.SchemaItemKey(targetClass, new SchemaKey_1.SchemaKey(schemaName));
|
|
630
|
+
if (SchemaItem_1.SchemaItem.equalByKey(this, targetSchemaKey))
|
|
660
631
|
return true;
|
|
661
|
-
return this.traverseBaseClassesSync((thisSchemaItem, thatSchemaItemOrKey) => SchemaItem_1.SchemaItem.equalByKey(thisSchemaItem, thatSchemaItemOrKey), key);
|
|
662
632
|
}
|
|
663
633
|
else {
|
|
664
634
|
(0, core_bentley_1.assert)(ECClass.isECClass(targetClass), "Expected targetClass to be of type ECClass");
|
|
665
635
|
if (SchemaItem_1.SchemaItem.equalByKey(this, targetClass))
|
|
666
636
|
return true;
|
|
667
|
-
|
|
637
|
+
targetSchemaKey = targetClass.key;
|
|
668
638
|
}
|
|
639
|
+
for (const baseClassKey of this.schema.context.classHierarchy.getBaseClassKeys(this.key)) {
|
|
640
|
+
if (baseClassKey.matchesFullName(targetSchemaKey.fullName)) {
|
|
641
|
+
return true;
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
return false;
|
|
669
645
|
}
|
|
670
646
|
/**
|
|
671
647
|
* @internal
|
|
@@ -684,35 +660,6 @@ class ECClass extends SchemaItem_1.SchemaItem {
|
|
|
684
660
|
setModifier(modifier) {
|
|
685
661
|
this._modifier = modifier;
|
|
686
662
|
}
|
|
687
|
-
/**
|
|
688
|
-
* Adds an ECClass to the derived class collection. This method is only intended to update the local
|
|
689
|
-
* cache of derived classes. For adding a class to the hierarchy, use the baseClass setter method.
|
|
690
|
-
* @param prop The property to add.
|
|
691
|
-
* @return The property that was added.
|
|
692
|
-
*/
|
|
693
|
-
addDerivedClass(baseClass, derivedClass) {
|
|
694
|
-
if (!baseClass._derivedClasses)
|
|
695
|
-
baseClass._derivedClasses = new Map();
|
|
696
|
-
if (baseClass._derivedClasses.has(derivedClass.fullName))
|
|
697
|
-
return;
|
|
698
|
-
if (derivedClass.isSync(baseClass)) {
|
|
699
|
-
const promise = new DelayedPromise_1.DelayedPromiseWithProps(derivedClass.key, async () => derivedClass);
|
|
700
|
-
baseClass._derivedClasses.set(derivedClass.fullName, promise);
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
/**
|
|
704
|
-
* Removes an ECClass from the derived class collection. This method is only intended to update the local
|
|
705
|
-
* cache of derived classes. For updating the class hierarchy, use the baseClass setter method.
|
|
706
|
-
* @param prop The property to add.
|
|
707
|
-
* @return The property that was added.
|
|
708
|
-
*/
|
|
709
|
-
removeDerivedClass(baseClass, derivedClass) {
|
|
710
|
-
if (!baseClass._derivedClasses)
|
|
711
|
-
return;
|
|
712
|
-
if (!baseClass._derivedClasses.has(derivedClass.fullName))
|
|
713
|
-
return;
|
|
714
|
-
baseClass._derivedClasses.delete(derivedClass.fullName);
|
|
715
|
-
}
|
|
716
663
|
}
|
|
717
664
|
exports.ECClass = ECClass;
|
|
718
665
|
/**
|