@itwin/ecschema-metadata 4.8.0-dev.9 → 4.9.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 +36 -1
- package/lib/cjs/Constants.js.map +1 -1
- package/lib/cjs/DelayedPromise.js.map +1 -1
- package/lib/cjs/Deserialization/AbstractParser.js.map +1 -1
- package/lib/cjs/Deserialization/Helper.js.map +1 -1
- package/lib/cjs/Deserialization/JsonParser.js.map +1 -1
- package/lib/cjs/Deserialization/JsonProps.d.ts +4 -0
- package/lib/cjs/Deserialization/JsonProps.d.ts.map +1 -1
- package/lib/cjs/Deserialization/JsonProps.js.map +1 -1
- package/lib/cjs/Deserialization/SchemaGraphUtil.js.map +1 -1
- package/lib/cjs/Deserialization/XmlParser.js.map +1 -1
- package/lib/cjs/Deserialization/XmlSerializationUtils.js.map +1 -1
- package/lib/cjs/ECName.js.map +1 -1
- package/lib/cjs/ECObjects.js.map +1 -1
- package/lib/cjs/Exception.js.map +1 -1
- package/lib/cjs/Interfaces.js.map +1 -1
- package/lib/cjs/Metadata/Class.d.ts +0 -6
- package/lib/cjs/Metadata/Class.d.ts.map +1 -1
- package/lib/cjs/Metadata/Class.js +0 -8
- package/lib/cjs/Metadata/Class.js.map +1 -1
- package/lib/cjs/Metadata/Constant.js.map +1 -1
- package/lib/cjs/Metadata/CustomAttribute.js.map +1 -1
- package/lib/cjs/Metadata/CustomAttributeClass.d.ts +7 -3
- package/lib/cjs/Metadata/CustomAttributeClass.d.ts.map +1 -1
- package/lib/cjs/Metadata/CustomAttributeClass.js +16 -10
- package/lib/cjs/Metadata/CustomAttributeClass.js.map +1 -1
- package/lib/cjs/Metadata/EntityClass.js.map +1 -1
- package/lib/cjs/Metadata/Enumeration.js.map +1 -1
- package/lib/cjs/Metadata/Format.js.map +1 -1
- package/lib/cjs/Metadata/InvertedUnit.js.map +1 -1
- package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
- package/lib/cjs/Metadata/Mixin.js.map +1 -1
- package/lib/cjs/Metadata/OverrideFormat.d.ts.map +1 -1
- package/lib/cjs/Metadata/OverrideFormat.js +3 -1
- package/lib/cjs/Metadata/OverrideFormat.js.map +1 -1
- package/lib/cjs/Metadata/Phenomenon.js.map +1 -1
- package/lib/cjs/Metadata/Property.js.map +1 -1
- package/lib/cjs/Metadata/PropertyCategory.js.map +1 -1
- package/lib/cjs/Metadata/RelationshipClass.js.map +1 -1
- package/lib/cjs/Metadata/Schema.d.ts +14 -0
- package/lib/cjs/Metadata/Schema.d.ts.map +1 -1
- package/lib/cjs/Metadata/Schema.js +21 -0
- package/lib/cjs/Metadata/Schema.js.map +1 -1
- package/lib/cjs/Metadata/SchemaItem.d.ts +5 -0
- package/lib/cjs/Metadata/SchemaItem.d.ts.map +1 -1
- package/lib/cjs/Metadata/SchemaItem.js +7 -0
- package/lib/cjs/Metadata/SchemaItem.js.map +1 -1
- package/lib/cjs/Metadata/UnitSystem.js.map +1 -1
- package/lib/cjs/PropertyTypes.js.map +1 -1
- package/lib/cjs/SchemaJsonLocater.js.map +1 -1
- package/lib/cjs/SchemaKey.js.map +1 -1
- package/lib/cjs/SchemaLoader.js.map +1 -1
- package/lib/cjs/SchemaPartVisitorDelegate.js.map +1 -1
- package/lib/cjs/UnitConversion/Graph.js.map +1 -1
- package/lib/cjs/UnitConversion/Parser.js.map +1 -1
- package/lib/cjs/UnitConversion/UnitConversion.js.map +1 -1
- package/lib/cjs/UnitConversion/UnitConverter.js.map +1 -1
- package/lib/cjs/UnitConversion/UnitTree.js.map +1 -1
- package/lib/cjs/UnitProvider/SchemaUnitProvider.js.map +1 -1
- package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
- package/lib/cjs/ecschema-metadata.js.map +1 -1
- package/lib/cjs/utils/SchemaGraph.js.map +1 -1
- package/lib/esm/Constants.d.ts +24 -0
- package/lib/esm/Constants.d.ts.map +1 -0
- package/lib/esm/Constants.js +30 -0
- package/lib/esm/Constants.js.map +1 -0
- package/lib/esm/Context.d.ts +219 -0
- package/lib/esm/Context.d.ts.map +1 -0
- package/lib/esm/Context.js +321 -0
- package/lib/esm/Context.js.map +1 -0
- package/lib/esm/DelayedPromise.d.ts +89 -0
- package/lib/esm/DelayedPromise.d.ts.map +1 -0
- package/lib/esm/DelayedPromise.js +88 -0
- package/lib/esm/DelayedPromise.js.map +1 -0
- package/lib/esm/Deserialization/AbstractParser.d.ts +46 -0
- package/lib/esm/Deserialization/AbstractParser.d.ts.map +1 -0
- package/lib/esm/Deserialization/AbstractParser.js +8 -0
- package/lib/esm/Deserialization/AbstractParser.js.map +1 -0
- package/lib/esm/Deserialization/Helper.d.ts +263 -0
- package/lib/esm/Deserialization/Helper.d.ts.map +1 -0
- package/lib/esm/Deserialization/Helper.js +871 -0
- package/lib/esm/Deserialization/Helper.js.map +1 -0
- package/lib/esm/Deserialization/JsonParser.d.ts +166 -0
- package/lib/esm/Deserialization/JsonParser.d.ts.map +1 -0
- package/lib/esm/Deserialization/JsonParser.js +677 -0
- package/lib/esm/Deserialization/JsonParser.js.map +1 -0
- package/lib/esm/Deserialization/JsonProps.d.ts +273 -0
- package/lib/esm/Deserialization/JsonProps.d.ts.map +1 -0
- package/lib/esm/Deserialization/JsonProps.js +9 -0
- package/lib/esm/Deserialization/JsonProps.js.map +1 -0
- package/lib/esm/Deserialization/SchemaGraphUtil.d.ts +35 -0
- package/lib/esm/Deserialization/SchemaGraphUtil.d.ts.map +1 -0
- package/lib/esm/Deserialization/SchemaGraphUtil.js +74 -0
- package/lib/esm/Deserialization/SchemaGraphUtil.js.map +1 -0
- package/lib/esm/Deserialization/XmlParser.d.ts +86 -0
- package/lib/esm/Deserialization/XmlParser.d.ts.map +1 -0
- package/lib/esm/Deserialization/XmlParser.js +970 -0
- package/lib/esm/Deserialization/XmlParser.js.map +1 -0
- package/lib/esm/Deserialization/XmlSerializationUtils.d.ts +55 -0
- package/lib/esm/Deserialization/XmlSerializationUtils.d.ts.map +1 -0
- package/lib/esm/Deserialization/XmlSerializationUtils.js +172 -0
- package/lib/esm/Deserialization/XmlSerializationUtils.js.map +1 -0
- package/lib/esm/ECName.d.ts +31 -0
- package/lib/esm/ECName.d.ts.map +1 -0
- package/lib/esm/ECName.js +82 -0
- package/lib/esm/ECName.js.map +1 -0
- package/lib/esm/ECObjects.d.ts +166 -0
- package/lib/esm/ECObjects.d.ts.map +1 -0
- package/lib/esm/ECObjects.js +422 -0
- package/lib/esm/ECObjects.js.map +1 -0
- package/lib/esm/Exception.d.ts +45 -0
- package/lib/esm/Exception.d.ts.map +1 -0
- package/lib/esm/Exception.js +82 -0
- package/lib/esm/Exception.js.map +1 -0
- package/lib/esm/Interfaces.d.ts +79 -0
- package/lib/esm/Interfaces.d.ts.map +1 -0
- package/lib/esm/Interfaces.js +9 -0
- package/lib/esm/Interfaces.js.map +1 -0
- package/lib/esm/Metadata/Class.d.ts +245 -0
- package/lib/esm/Metadata/Class.d.ts.map +1 -0
- package/lib/esm/Metadata/Class.js +552 -0
- package/lib/esm/Metadata/Class.js.map +1 -0
- package/lib/esm/Metadata/Constant.d.ts +65 -0
- package/lib/esm/Metadata/Constant.d.ts.map +1 -0
- package/lib/esm/Metadata/Constant.js +119 -0
- package/lib/esm/Metadata/Constant.js.map +1 -0
- package/lib/esm/Metadata/CustomAttribute.d.ts +24 -0
- package/lib/esm/Metadata/CustomAttribute.d.ts.map +1 -0
- package/lib/esm/Metadata/CustomAttribute.js +24 -0
- package/lib/esm/Metadata/CustomAttribute.js.map +1 -0
- package/lib/esm/Metadata/CustomAttributeClass.d.ts +44 -0
- package/lib/esm/Metadata/CustomAttributeClass.d.ts.map +1 -0
- package/lib/esm/Metadata/CustomAttributeClass.js +70 -0
- package/lib/esm/Metadata/CustomAttributeClass.js.map +1 -0
- package/lib/esm/Metadata/EntityClass.d.ts +78 -0
- package/lib/esm/Metadata/EntityClass.d.ts.map +1 -0
- package/lib/esm/Metadata/EntityClass.js +224 -0
- package/lib/esm/Metadata/EntityClass.js.map +1 -0
- package/lib/esm/Metadata/Enumeration.d.ts +87 -0
- package/lib/esm/Metadata/Enumeration.d.ts.map +1 -0
- package/lib/esm/Metadata/Enumeration.js +155 -0
- package/lib/esm/Metadata/Enumeration.js.map +1 -0
- package/lib/esm/Metadata/Format.d.ts +99 -0
- package/lib/esm/Metadata/Format.d.ts.map +1 -0
- package/lib/esm/Metadata/Format.js +238 -0
- package/lib/esm/Metadata/Format.js.map +1 -0
- package/lib/esm/Metadata/InvertedUnit.d.ts +50 -0
- package/lib/esm/Metadata/InvertedUnit.d.ts.map +1 -0
- package/lib/esm/Metadata/InvertedUnit.js +93 -0
- package/lib/esm/Metadata/InvertedUnit.js.map +1 -0
- package/lib/esm/Metadata/KindOfQuantity.d.ts +72 -0
- package/lib/esm/Metadata/KindOfQuantity.d.ts.map +1 -0
- package/lib/esm/Metadata/KindOfQuantity.js +229 -0
- package/lib/esm/Metadata/KindOfQuantity.js.map +1 -0
- package/lib/esm/Metadata/Mixin.d.ts +55 -0
- package/lib/esm/Metadata/Mixin.d.ts.map +1 -0
- package/lib/esm/Metadata/Mixin.js +109 -0
- package/lib/esm/Metadata/Mixin.js.map +1 -0
- package/lib/esm/Metadata/OverrideFormat.d.ts +68 -0
- package/lib/esm/Metadata/OverrideFormat.d.ts.map +1 -0
- package/lib/esm/Metadata/OverrideFormat.js +124 -0
- package/lib/esm/Metadata/OverrideFormat.js.map +1 -0
- package/lib/esm/Metadata/Phenomenon.d.ts +34 -0
- package/lib/esm/Metadata/Phenomenon.d.ts.map +1 -0
- package/lib/esm/Metadata/Phenomenon.js +55 -0
- package/lib/esm/Metadata/Phenomenon.js.map +1 -0
- package/lib/esm/Metadata/Property.d.ts +247 -0
- package/lib/esm/Metadata/Property.d.ts.map +1 -0
- package/lib/esm/Metadata/Property.js +565 -0
- package/lib/esm/Metadata/Property.js.map +1 -0
- package/lib/esm/Metadata/PropertyCategory.d.ts +40 -0
- package/lib/esm/Metadata/PropertyCategory.d.ts.map +1 -0
- package/lib/esm/Metadata/PropertyCategory.js +57 -0
- package/lib/esm/Metadata/PropertyCategory.js.map +1 -0
- package/lib/esm/Metadata/RelationshipClass.d.ts +170 -0
- package/lib/esm/Metadata/RelationshipClass.d.ts.map +1 -0
- package/lib/esm/Metadata/RelationshipClass.js +380 -0
- package/lib/esm/Metadata/RelationshipClass.js.map +1 -0
- package/lib/esm/Metadata/Schema.d.ts +330 -0
- package/lib/esm/Metadata/Schema.d.ts.map +1 -0
- package/lib/esm/Metadata/Schema.js +570 -0
- package/lib/esm/Metadata/Schema.js.map +1 -0
- package/lib/esm/Metadata/SchemaItem.d.ts +67 -0
- package/lib/esm/Metadata/SchemaItem.d.ts.map +1 -0
- package/lib/esm/Metadata/SchemaItem.js +140 -0
- package/lib/esm/Metadata/SchemaItem.js.map +1 -0
- package/lib/esm/Metadata/Unit.d.ts +77 -0
- package/lib/esm/Metadata/Unit.d.ts.map +1 -0
- package/lib/esm/Metadata/Unit.js +158 -0
- package/lib/esm/Metadata/Unit.js.map +1 -0
- package/lib/esm/Metadata/UnitSystem.d.ts +21 -0
- package/lib/esm/Metadata/UnitSystem.d.ts.map +1 -0
- package/lib/esm/Metadata/UnitSystem.js +25 -0
- package/lib/esm/Metadata/UnitSystem.js.map +1 -0
- package/lib/esm/PropertyTypes.d.ts +50 -0
- package/lib/esm/PropertyTypes.d.ts.map +1 -0
- package/lib/esm/PropertyTypes.js +88 -0
- package/lib/esm/PropertyTypes.js.map +1 -0
- package/lib/esm/SchemaJsonLocater.d.ts +42 -0
- package/lib/esm/SchemaJsonLocater.d.ts.map +1 -0
- package/lib/esm/SchemaJsonLocater.js +54 -0
- package/lib/esm/SchemaJsonLocater.js.map +1 -0
- package/lib/esm/SchemaKey.d.ts +111 -0
- package/lib/esm/SchemaKey.d.ts.map +1 -0
- package/lib/esm/SchemaKey.js +214 -0
- package/lib/esm/SchemaKey.js.map +1 -0
- package/lib/esm/SchemaLoader.d.ts +32 -0
- package/lib/esm/SchemaLoader.d.ts.map +1 -0
- package/lib/esm/SchemaLoader.js +53 -0
- package/lib/esm/SchemaLoader.js.map +1 -0
- package/lib/esm/SchemaPartVisitorDelegate.d.ts +275 -0
- package/lib/esm/SchemaPartVisitorDelegate.d.ts.map +1 -0
- package/lib/esm/SchemaPartVisitorDelegate.js +209 -0
- package/lib/esm/SchemaPartVisitorDelegate.js.map +1 -0
- package/lib/esm/UnitConversion/Graph.d.ts +35 -0
- package/lib/esm/UnitConversion/Graph.d.ts.map +1 -0
- package/lib/esm/UnitConversion/Graph.js +80 -0
- package/lib/esm/UnitConversion/Graph.js.map +1 -0
- package/lib/esm/UnitConversion/Parser.d.ts +9 -0
- package/lib/esm/UnitConversion/Parser.d.ts.map +1 -0
- package/lib/esm/UnitConversion/Parser.js +39 -0
- package/lib/esm/UnitConversion/Parser.js.map +1 -0
- package/lib/esm/UnitConversion/UnitConversion.d.ts +46 -0
- package/lib/esm/UnitConversion/UnitConversion.d.ts.map +1 -0
- package/lib/esm/UnitConversion/UnitConversion.js +74 -0
- package/lib/esm/UnitConversion/UnitConversion.js.map +1 -0
- package/lib/esm/UnitConversion/UnitConverter.d.ts +40 -0
- package/lib/esm/UnitConversion/UnitConverter.d.ts.map +1 -0
- package/lib/esm/UnitConversion/UnitConverter.js +113 -0
- package/lib/esm/UnitConversion/UnitConverter.js.map +1 -0
- package/lib/esm/UnitConversion/UnitTree.d.ts +44 -0
- package/lib/esm/UnitConversion/UnitTree.d.ts.map +1 -0
- package/lib/esm/UnitConversion/UnitTree.js +165 -0
- package/lib/esm/UnitConversion/UnitTree.js.map +1 -0
- package/lib/esm/UnitProvider/SchemaUnitProvider.d.ts +78 -0
- package/lib/esm/UnitProvider/SchemaUnitProvider.d.ts.map +1 -0
- package/lib/esm/UnitProvider/SchemaUnitProvider.js +231 -0
- package/lib/esm/UnitProvider/SchemaUnitProvider.js.map +1 -0
- package/lib/esm/Validation/SchemaWalker.d.ts +24 -0
- package/lib/esm/Validation/SchemaWalker.d.ts.map +1 -0
- package/lib/esm/Validation/SchemaWalker.js +50 -0
- package/lib/esm/Validation/SchemaWalker.js.map +1 -0
- package/lib/esm/ecschema-metadata.d.ts +52 -0
- package/lib/esm/ecschema-metadata.d.ts.map +1 -0
- package/lib/esm/ecschema-metadata.js +55 -0
- package/lib/esm/ecschema-metadata.js.map +1 -0
- package/lib/esm/utils/SchemaGraph.d.ts +44 -0
- package/lib/esm/utils/SchemaGraph.d.ts.map +1 -0
- package/lib/esm/utils/SchemaGraph.js +111 -0
- package/lib/esm/utils/SchemaGraph.js.map +1 -0
- package/package.json +9 -7
|
@@ -0,0 +1,570 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/** @packageDocumentation
|
|
6
|
+
* @module Metadata
|
|
7
|
+
*/
|
|
8
|
+
import { SchemaReadHelper } from "../Deserialization/Helper";
|
|
9
|
+
import { JsonParser } from "../Deserialization/JsonParser";
|
|
10
|
+
import { XmlSerializationUtils } from "../Deserialization/XmlSerializationUtils";
|
|
11
|
+
import { ECObjectsError, ECObjectsStatus } from "../Exception";
|
|
12
|
+
import { ECVersion, SchemaItemKey, SchemaKey } from "../SchemaKey";
|
|
13
|
+
import { ECName } from "../ECName";
|
|
14
|
+
import { ECClass, StructClass } from "./Class";
|
|
15
|
+
import { Constant } from "./Constant";
|
|
16
|
+
import { serializeCustomAttributes } from "./CustomAttribute";
|
|
17
|
+
import { CustomAttributeClass } from "./CustomAttributeClass";
|
|
18
|
+
import { EntityClass } from "./EntityClass";
|
|
19
|
+
import { Enumeration } from "./Enumeration";
|
|
20
|
+
import { Format } from "./Format";
|
|
21
|
+
import { InvertedUnit } from "./InvertedUnit";
|
|
22
|
+
import { KindOfQuantity } from "./KindOfQuantity";
|
|
23
|
+
import { Mixin } from "./Mixin";
|
|
24
|
+
import { Phenomenon } from "./Phenomenon";
|
|
25
|
+
import { PropertyCategory } from "./PropertyCategory";
|
|
26
|
+
import { RelationshipClass } from "./RelationshipClass";
|
|
27
|
+
import { SchemaItem } from "./SchemaItem";
|
|
28
|
+
import { Unit } from "./Unit";
|
|
29
|
+
import { UnitSystem } from "./UnitSystem";
|
|
30
|
+
const SCHEMAURL3_2_JSON = "https://dev.bentley.com/json_schemas/ec/32/ecschema";
|
|
31
|
+
const SCHEMAURL3_2_XML = "http://www.bentley.com/schemas/Bentley.ECXML.3.2";
|
|
32
|
+
/**
|
|
33
|
+
* @beta
|
|
34
|
+
*/
|
|
35
|
+
export class Schema {
|
|
36
|
+
/** @internal */
|
|
37
|
+
constructor(context, nameOrKey, alias, readVer, writeVer, minorVer) {
|
|
38
|
+
this._schemaKey = (typeof (nameOrKey) === "string") ? new SchemaKey(nameOrKey, new ECVersion(readVer, writeVer, minorVer)) : nameOrKey;
|
|
39
|
+
this._context = context;
|
|
40
|
+
this.references = [];
|
|
41
|
+
this._items = new Map();
|
|
42
|
+
if (alias !== undefined && ECName.validate(alias)) {
|
|
43
|
+
this._alias = alias;
|
|
44
|
+
}
|
|
45
|
+
else if (nameOrKey !== undefined) {
|
|
46
|
+
throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Schema ${this.name} does not have the required 'alias' attribute.`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
get schemaKey() {
|
|
50
|
+
if (undefined === this._schemaKey)
|
|
51
|
+
throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The schema '${this.name}' has an invalid SchemaKey.`);
|
|
52
|
+
return this._schemaKey;
|
|
53
|
+
}
|
|
54
|
+
get name() { return this.schemaKey.name; }
|
|
55
|
+
get readVersion() { return this.schemaKey.readVersion; }
|
|
56
|
+
get writeVersion() { return this.schemaKey.writeVersion; }
|
|
57
|
+
get minorVersion() { return this.schemaKey.minorVersion; }
|
|
58
|
+
get alias() {
|
|
59
|
+
if (this._alias === undefined || this._alias === null) {
|
|
60
|
+
throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Schema ${this.name} does not have the required 'alias' attribute.`);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
return this._alias;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
get label() { return this._label; }
|
|
67
|
+
get description() { return this._description; }
|
|
68
|
+
get customAttributes() { return this._customAttributes; }
|
|
69
|
+
/** Returns the schema name. */
|
|
70
|
+
get fullName() { return this.schemaKey.name; }
|
|
71
|
+
/** Returns the schema. */
|
|
72
|
+
get schema() { return this; }
|
|
73
|
+
/** Returns the schema context this schema is within. */
|
|
74
|
+
get context() { return this._context; }
|
|
75
|
+
/**
|
|
76
|
+
* Returns a SchemaItemKey given the item name and the schema it belongs to
|
|
77
|
+
* @param fullName fully qualified name {Schema name}.{Item Name}
|
|
78
|
+
*/
|
|
79
|
+
getSchemaItemKey(fullName) {
|
|
80
|
+
const [schemaName, itemName] = SchemaItem.parseFullName(fullName);
|
|
81
|
+
let schemaKey = this.schemaKey;
|
|
82
|
+
if (this.name !== schemaName) {
|
|
83
|
+
const newSchemaRef = this.getReferenceSync(schemaName);
|
|
84
|
+
if (undefined === newSchemaRef)
|
|
85
|
+
throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to find the referenced SchemaItem ${itemName}.`);
|
|
86
|
+
schemaKey = newSchemaRef.schemaKey;
|
|
87
|
+
}
|
|
88
|
+
return new SchemaItemKey(itemName, schemaKey);
|
|
89
|
+
}
|
|
90
|
+
addItem(item) {
|
|
91
|
+
if (undefined !== this.getItemSync(item.name))
|
|
92
|
+
throw new ECObjectsError(ECObjectsStatus.DuplicateItem, `The SchemaItem ${item.name} cannot be added to the schema ${this.name} because it already exists`);
|
|
93
|
+
this._items.set(item.name.toUpperCase(), item);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* @alpha
|
|
97
|
+
*/
|
|
98
|
+
createClass(type, name, modifier) {
|
|
99
|
+
const item = new type(this, name, modifier);
|
|
100
|
+
this.addItem(item);
|
|
101
|
+
return item;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Deletes a class from within this schema.
|
|
105
|
+
* @param name the local (unqualified) class name, lookup is case-insensitive
|
|
106
|
+
* @alpha
|
|
107
|
+
*/
|
|
108
|
+
async deleteClass(name) {
|
|
109
|
+
const schemaItem = await this.getItem(name);
|
|
110
|
+
if (ECClass.isECClass(schemaItem)) {
|
|
111
|
+
this._items.delete(name.toUpperCase());
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Deletes a class from within this schema.
|
|
116
|
+
* @param name the local (unqualified) class name, lookup is case-insensitive
|
|
117
|
+
* @alpha
|
|
118
|
+
*/
|
|
119
|
+
deleteClassSync(name) {
|
|
120
|
+
const schemaItem = this.getItemSync(name);
|
|
121
|
+
if (ECClass.isECClass(schemaItem))
|
|
122
|
+
this._items.delete(name.toUpperCase());
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Deletes a SchemaItem from within this schema.
|
|
126
|
+
* @param name the local (unqualified) class name, lookup is case-insensitive
|
|
127
|
+
* @alpha
|
|
128
|
+
*/
|
|
129
|
+
async deleteSchemaItem(name) {
|
|
130
|
+
const schemaItem = await this.getItem(name);
|
|
131
|
+
if (SchemaItem.isSchemaItem(schemaItem)) {
|
|
132
|
+
this._items.delete(name.toUpperCase());
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Deletes a SchemaItem from within this schema.
|
|
137
|
+
* @param name the local (unqualified) class name, lookup is case-insensitive
|
|
138
|
+
* @alpha
|
|
139
|
+
*/
|
|
140
|
+
deleteSchemaItemSync(name) {
|
|
141
|
+
const schemaItem = this.getItemSync(name);
|
|
142
|
+
if (SchemaItem.isSchemaItem(schemaItem))
|
|
143
|
+
this._items.delete(name.toUpperCase());
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* @alpha
|
|
147
|
+
*/
|
|
148
|
+
createItem(type, name) {
|
|
149
|
+
const item = new type(this, name);
|
|
150
|
+
this.addItem(item);
|
|
151
|
+
return item;
|
|
152
|
+
}
|
|
153
|
+
addCustomAttribute(customAttribute) {
|
|
154
|
+
if (!this._customAttributes)
|
|
155
|
+
this._customAttributes = new Map();
|
|
156
|
+
this._customAttributes.set(customAttribute.className, customAttribute);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Creates a EntityClass with the provided name in this schema.
|
|
160
|
+
* @param name
|
|
161
|
+
* @param modifier
|
|
162
|
+
*/
|
|
163
|
+
async createEntityClass(name, modifier) {
|
|
164
|
+
return this.createClass(EntityClass, name, modifier);
|
|
165
|
+
}
|
|
166
|
+
createEntityClassSync(name, modifier) {
|
|
167
|
+
return this.createClass(EntityClass, name, modifier);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Creates a Mixin with the provided name in this schema.
|
|
171
|
+
* @param name
|
|
172
|
+
*/
|
|
173
|
+
async createMixinClass(name) { return this.createClass(Mixin, name); }
|
|
174
|
+
createMixinClassSync(name) { return this.createClass(Mixin, name); }
|
|
175
|
+
/**
|
|
176
|
+
* Creates a StructClass with the provided name in this schema.
|
|
177
|
+
* @param name
|
|
178
|
+
* @param modifier
|
|
179
|
+
*/
|
|
180
|
+
async createStructClass(name, modifier) {
|
|
181
|
+
return this.createClass(StructClass, name, modifier);
|
|
182
|
+
}
|
|
183
|
+
createStructClassSync(name, modifier) {
|
|
184
|
+
return this.createClass(StructClass, name, modifier);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Creates a CustomAttributeClass with the provided name in this schema.
|
|
188
|
+
* @param name
|
|
189
|
+
* @param modifier
|
|
190
|
+
*/
|
|
191
|
+
async createCustomAttributeClass(name, modifier) {
|
|
192
|
+
return this.createClass(CustomAttributeClass, name, modifier);
|
|
193
|
+
}
|
|
194
|
+
createCustomAttributeClassSync(name, modifier) {
|
|
195
|
+
return this.createClass(CustomAttributeClass, name, modifier);
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Creates a RelationshipClass with the provided name in this schema.
|
|
199
|
+
* @param name
|
|
200
|
+
* @param modifier
|
|
201
|
+
*/
|
|
202
|
+
async createRelationshipClass(name, modifier) {
|
|
203
|
+
return this.createRelationshipClassSync(name, modifier);
|
|
204
|
+
}
|
|
205
|
+
createRelationshipClassSync(name, modifier) {
|
|
206
|
+
return this.createClass(RelationshipClass, name, modifier);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Creates an Enumeration with the provided name in this schema.
|
|
210
|
+
* @param name
|
|
211
|
+
*/
|
|
212
|
+
async createEnumeration(name, primitiveType) {
|
|
213
|
+
return this.createEnumerationSync(name, primitiveType);
|
|
214
|
+
}
|
|
215
|
+
createEnumerationSync(name, primitiveType) {
|
|
216
|
+
const item = new Enumeration(this, name, primitiveType);
|
|
217
|
+
this.addItem(item);
|
|
218
|
+
return item;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Creates an KindOfQuantity with the provided name in this schema.
|
|
222
|
+
* @param name
|
|
223
|
+
*/
|
|
224
|
+
async createKindOfQuantity(name) {
|
|
225
|
+
return this.createKindOfQuantitySync(name);
|
|
226
|
+
}
|
|
227
|
+
createKindOfQuantitySync(name) {
|
|
228
|
+
return this.createItem(KindOfQuantity, name);
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Creates a Constant with the provided name in this schema.
|
|
232
|
+
* @param name
|
|
233
|
+
*/
|
|
234
|
+
async createConstant(name) {
|
|
235
|
+
return this.createItem(Constant, name);
|
|
236
|
+
}
|
|
237
|
+
createConstantSync(name) {
|
|
238
|
+
return this.createItem(Constant, name);
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Creates a Inverted Unit with the provided name in this schema.
|
|
242
|
+
* @param name
|
|
243
|
+
*/
|
|
244
|
+
async createInvertedUnit(name) {
|
|
245
|
+
return this.createItem(InvertedUnit, name);
|
|
246
|
+
}
|
|
247
|
+
createInvertedUnitSync(name) {
|
|
248
|
+
return this.createItem(InvertedUnit, name);
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Creates an Format with the provided name in this schema.
|
|
252
|
+
* @param name
|
|
253
|
+
*/
|
|
254
|
+
async createFormat(name) {
|
|
255
|
+
return this.createItem(Format, name);
|
|
256
|
+
}
|
|
257
|
+
createFormatSync(name) {
|
|
258
|
+
return this.createItem(Format, name);
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Creates a UnitSystem with the provided name in this schema.
|
|
262
|
+
* @param name
|
|
263
|
+
*/
|
|
264
|
+
async createUnitSystem(name) {
|
|
265
|
+
return this.createItem(UnitSystem, name);
|
|
266
|
+
}
|
|
267
|
+
createUnitSystemSync(name) {
|
|
268
|
+
return this.createItem(UnitSystem, name);
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Creates a Phenomenon with the provided name in this schema.
|
|
272
|
+
* @param name
|
|
273
|
+
*/
|
|
274
|
+
async createPhenomenon(name) {
|
|
275
|
+
return this.createItem(Phenomenon, name);
|
|
276
|
+
}
|
|
277
|
+
createPhenomenonSync(name) {
|
|
278
|
+
return this.createItem(Phenomenon, name);
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Creates a Unit with the provided name in this schema.
|
|
282
|
+
* @param name
|
|
283
|
+
*/
|
|
284
|
+
async createUnit(name) {
|
|
285
|
+
return this.createItem(Unit, name);
|
|
286
|
+
}
|
|
287
|
+
createUnitSync(name) {
|
|
288
|
+
return this.createItem(Unit, name);
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Creates an PropertyCategory with the provided name in this schema.
|
|
292
|
+
* @param name
|
|
293
|
+
*/
|
|
294
|
+
async createPropertyCategory(name) {
|
|
295
|
+
return this.createItem(PropertyCategory, name);
|
|
296
|
+
}
|
|
297
|
+
createPropertyCategorySync(name) {
|
|
298
|
+
return this.createItem(PropertyCategory, name);
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
*
|
|
302
|
+
* @param refSchema
|
|
303
|
+
*/
|
|
304
|
+
async addReference(refSchema) {
|
|
305
|
+
// TODO validation of reference schema. For now just adding
|
|
306
|
+
this.addReferenceSync(refSchema);
|
|
307
|
+
}
|
|
308
|
+
addReferenceSync(refSchema) {
|
|
309
|
+
this.references.push(refSchema);
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* @alpha Used for schema editing.
|
|
313
|
+
*/
|
|
314
|
+
setContext(context) {
|
|
315
|
+
this._context = context;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Sets the version of the SchemaKey identifying the schema.
|
|
319
|
+
* @param readVersion The read version of the schema. If undefined, the value from the existing SchemaKey will be used.
|
|
320
|
+
* @param writeVersion The write version of the schema. If undefined, the value from the existing SchemaKey will be used.
|
|
321
|
+
* @param minorVersion The minor version of the schema. If undefined, the value from the existing SchemaKey will be used.
|
|
322
|
+
*/
|
|
323
|
+
setVersion(readVersion, writeVersion, minorVersion) {
|
|
324
|
+
if (!this._schemaKey)
|
|
325
|
+
throw new ECObjectsError(ECObjectsStatus.InvalidSchemaKey, `The schema '${this.name}' has an invalid SchemaKey.`);
|
|
326
|
+
const newVersion = new ECVersion(readVersion ?? this._schemaKey.readVersion, writeVersion ?? this._schemaKey.writeVersion, minorVersion ?? this._schemaKey.minorVersion);
|
|
327
|
+
this._schemaKey = new SchemaKey(this._schemaKey.name, newVersion);
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Gets an item from within this schema. To get by full name use lookupItem instead.
|
|
331
|
+
* @param key the local (unqualified) name, lookup is case-insensitive
|
|
332
|
+
*/
|
|
333
|
+
async getItem(name) {
|
|
334
|
+
// this method exists so we can rewire it later when we load partial schemas, for now it is identical to the sync version
|
|
335
|
+
return this.getItemSync(name);
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Gets an item from within this schema. To get by full name use lookupItem instead.
|
|
339
|
+
* @param key the local (unqualified) name, lookup is case-insensitive
|
|
340
|
+
*/
|
|
341
|
+
getItemSync(name) {
|
|
342
|
+
// Case-insensitive search
|
|
343
|
+
return this._items.get(name.toUpperCase());
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Attempts to find a schema item within this schema or a (directly) referenced schema
|
|
347
|
+
* @param key The full name or a SchemaItemKey identifying the desired item.
|
|
348
|
+
*/
|
|
349
|
+
async lookupItem(key) {
|
|
350
|
+
let schemaName, itemName;
|
|
351
|
+
if (typeof (key) === "string") {
|
|
352
|
+
[schemaName, itemName] = SchemaItem.parseFullName(key);
|
|
353
|
+
}
|
|
354
|
+
else {
|
|
355
|
+
itemName = key.name;
|
|
356
|
+
schemaName = key.schemaName;
|
|
357
|
+
}
|
|
358
|
+
if (!schemaName || schemaName.toUpperCase() === this.name.toUpperCase()) {
|
|
359
|
+
return this.getItem(itemName);
|
|
360
|
+
}
|
|
361
|
+
const refSchema = await this.getReference(schemaName);
|
|
362
|
+
if (!refSchema)
|
|
363
|
+
return undefined;
|
|
364
|
+
return refSchema.getItem(itemName);
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Attempts to find a schema item within this schema or a (directly) referenced schema
|
|
368
|
+
* @param key The full name or a SchemaItemKey identifying the desired item.
|
|
369
|
+
*/
|
|
370
|
+
lookupItemSync(key) {
|
|
371
|
+
let schemaName, itemName;
|
|
372
|
+
if (typeof (key) === "string") {
|
|
373
|
+
[schemaName, itemName] = SchemaItem.parseFullName(key);
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
itemName = key.name;
|
|
377
|
+
schemaName = key.schemaName;
|
|
378
|
+
}
|
|
379
|
+
if (!schemaName || schemaName.toUpperCase() === this.name.toUpperCase()) {
|
|
380
|
+
return this.getItemSync(itemName);
|
|
381
|
+
}
|
|
382
|
+
const refSchema = this.getReferenceSync(schemaName);
|
|
383
|
+
if (!refSchema)
|
|
384
|
+
return undefined;
|
|
385
|
+
return refSchema.getItemSync(itemName);
|
|
386
|
+
}
|
|
387
|
+
getItems() {
|
|
388
|
+
if (!this._items)
|
|
389
|
+
return new Map().values();
|
|
390
|
+
return this._items.values();
|
|
391
|
+
}
|
|
392
|
+
*getClasses() {
|
|
393
|
+
for (const [, value] of this._items) {
|
|
394
|
+
if (ECClass.isECClass(value))
|
|
395
|
+
yield value;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
async getReference(refSchemaName) {
|
|
399
|
+
if (this.references.length === 0)
|
|
400
|
+
return undefined;
|
|
401
|
+
return this.references.find((ref) => ref.name.toLowerCase() === refSchemaName.toLowerCase());
|
|
402
|
+
}
|
|
403
|
+
getReferenceNameByAlias(alias) {
|
|
404
|
+
if (this.references.length === 0)
|
|
405
|
+
return undefined;
|
|
406
|
+
const schema = this.references.find((ref) => ref.alias ? ref.alias.toLowerCase() === alias.toLowerCase() : false);
|
|
407
|
+
return schema ? schema.name : undefined;
|
|
408
|
+
}
|
|
409
|
+
getReferenceSync(refSchemaName) {
|
|
410
|
+
if (this.references.length === 0)
|
|
411
|
+
return undefined;
|
|
412
|
+
return this.references.find((ref) => ref.name.toLowerCase() === refSchemaName.toLowerCase());
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Save this Schema's properties to an object for serializing to JSON.
|
|
416
|
+
*/
|
|
417
|
+
toJSON() {
|
|
418
|
+
const schemaJson = {};
|
|
419
|
+
schemaJson.$schema = SCHEMAURL3_2_JSON; // $schema is required
|
|
420
|
+
schemaJson.name = this.name; // name is required
|
|
421
|
+
schemaJson.version = this.schemaKey.version.toString(true);
|
|
422
|
+
schemaJson.alias = this.alias; // alias is required
|
|
423
|
+
if (undefined !== this.label) // label is optional
|
|
424
|
+
schemaJson.label = this.label;
|
|
425
|
+
if (undefined !== this.description) // description is optional
|
|
426
|
+
schemaJson.description = this.description;
|
|
427
|
+
if (undefined !== this.references && this.references.length > 0) // references is optional
|
|
428
|
+
schemaJson.references = this.references.map(({ name, schemaKey }) => ({ name, version: schemaKey.version.toString() }));
|
|
429
|
+
const customAttributes = serializeCustomAttributes(this.customAttributes);
|
|
430
|
+
if (undefined !== customAttributes)
|
|
431
|
+
schemaJson.customAttributes = customAttributes;
|
|
432
|
+
if (this._items.size > 0) {
|
|
433
|
+
schemaJson.items = {};
|
|
434
|
+
this._items.forEach((schemaItem) => {
|
|
435
|
+
schemaJson.items[schemaItem.name] = schemaItem.toJSON(false, true);
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
return schemaJson;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Converts the schema to a DOM XML Document.
|
|
442
|
+
* @param schemaXml An empty DOM document to which the schema will be written
|
|
443
|
+
*/
|
|
444
|
+
async toXml(schemaXml) {
|
|
445
|
+
const schemaMetadata = schemaXml.createElement("ECSchema");
|
|
446
|
+
schemaMetadata.setAttribute("xmlns", SCHEMAURL3_2_XML);
|
|
447
|
+
schemaMetadata.setAttribute("version", this.schemaKey.version.toString());
|
|
448
|
+
schemaMetadata.setAttribute("schemaName", this.name);
|
|
449
|
+
schemaMetadata.setAttribute("alias", this.alias ? this.alias : "");
|
|
450
|
+
if (undefined !== this.label)
|
|
451
|
+
schemaMetadata.setAttribute("displayLabel", this.label);
|
|
452
|
+
if (undefined !== this.description)
|
|
453
|
+
schemaMetadata.setAttribute("description", this.description);
|
|
454
|
+
// Map used for CA serialization
|
|
455
|
+
const refSchemaMap = new Map();
|
|
456
|
+
this.references.forEach(({ name, schemaKey, alias }) => {
|
|
457
|
+
const schemaRef = schemaXml.createElement("ECSchemaReference");
|
|
458
|
+
schemaRef.setAttribute("name", name);
|
|
459
|
+
schemaRef.setAttribute("version", schemaKey.version.toString());
|
|
460
|
+
schemaRef.setAttribute("alias", alias ? alias : "");
|
|
461
|
+
schemaMetadata.appendChild(schemaRef);
|
|
462
|
+
refSchemaMap.set(name, schemaKey.version.toString());
|
|
463
|
+
});
|
|
464
|
+
if (this._customAttributes) {
|
|
465
|
+
const parentElem = schemaXml.createElement("ECCustomAttributes");
|
|
466
|
+
for (const [name, attribute] of this._customAttributes) {
|
|
467
|
+
const caElem = await XmlSerializationUtils.writeCustomAttribute(name, attribute, schemaXml, this);
|
|
468
|
+
parentElem.appendChild(caElem);
|
|
469
|
+
}
|
|
470
|
+
schemaMetadata.appendChild(parentElem);
|
|
471
|
+
}
|
|
472
|
+
for (const [, item] of this._items) {
|
|
473
|
+
const itemXml = await item.toXml(schemaXml);
|
|
474
|
+
schemaMetadata.appendChild(itemXml);
|
|
475
|
+
}
|
|
476
|
+
schemaXml.appendChild(schemaMetadata);
|
|
477
|
+
return schemaXml;
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Loads the schema header (name, version alias, label and description) from the input SchemaProps
|
|
481
|
+
*/
|
|
482
|
+
fromJSONSync(schemaProps) {
|
|
483
|
+
if (undefined === this._schemaKey) {
|
|
484
|
+
const schemaName = schemaProps.name;
|
|
485
|
+
const version = ECVersion.fromString(schemaProps.version);
|
|
486
|
+
this._schemaKey = new SchemaKey(schemaName, version);
|
|
487
|
+
}
|
|
488
|
+
else {
|
|
489
|
+
if (schemaProps.name.toLowerCase() !== this.name.toLowerCase())
|
|
490
|
+
throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Schema ${this.name} does not match the provided name, '${schemaProps.name}'.`);
|
|
491
|
+
if (this.schemaKey.version.compare(ECVersion.fromString(schemaProps.version)))
|
|
492
|
+
throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Schema ${this.name} has the version '${this.schemaKey.version}' that does not match the provided version '${schemaProps.version}'.`);
|
|
493
|
+
}
|
|
494
|
+
if (SCHEMAURL3_2_JSON !== schemaProps.$schema && SCHEMAURL3_2_XML !== schemaProps.$schema) // TODO: Allow for 3.x URI versions to allow the API to read newer specs. (Start at 3.2 though)
|
|
495
|
+
throw new ECObjectsError(ECObjectsStatus.MissingSchemaUrl, `The Schema ${this.name} has an unsupported namespace '${schemaProps.$schema}'.`);
|
|
496
|
+
if (ECName.validate(schemaProps.alias)) {
|
|
497
|
+
this._alias = schemaProps.alias;
|
|
498
|
+
}
|
|
499
|
+
else {
|
|
500
|
+
throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Schema ${schemaProps.name} does not have the required 'alias' attribute.`);
|
|
501
|
+
}
|
|
502
|
+
if (undefined !== schemaProps.label)
|
|
503
|
+
this._label = schemaProps.label;
|
|
504
|
+
if (undefined !== schemaProps.description)
|
|
505
|
+
this._description = schemaProps.description;
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Loads the schema header (name, version alias, label and description) from the input SchemaProps
|
|
509
|
+
*/
|
|
510
|
+
async fromJSON(schemaProps) {
|
|
511
|
+
this.fromJSONSync(schemaProps);
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Completely loads the SchemaInfo from the input json and starts loading the entire schema. The complete schema can be retrieved from the
|
|
515
|
+
* schema context using the getCachedSchema method
|
|
516
|
+
*/
|
|
517
|
+
static async startLoadingFromJson(jsonObj, context) {
|
|
518
|
+
const schema = new Schema(context);
|
|
519
|
+
const reader = new SchemaReadHelper(JsonParser, context);
|
|
520
|
+
const rawSchema = typeof jsonObj === "string" ? JSON.parse(jsonObj) : jsonObj;
|
|
521
|
+
return reader.readSchemaInfo(schema, rawSchema);
|
|
522
|
+
}
|
|
523
|
+
static async fromJson(jsonObj, context) {
|
|
524
|
+
let schema = new Schema(context);
|
|
525
|
+
const reader = new SchemaReadHelper(JsonParser, context);
|
|
526
|
+
const rawSchema = typeof jsonObj === "string" ? JSON.parse(jsonObj) : jsonObj;
|
|
527
|
+
schema = await reader.readSchema(schema, rawSchema);
|
|
528
|
+
return schema;
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Completely loads the Schema from the input json. The schema is cached in the schema context.
|
|
532
|
+
*/
|
|
533
|
+
static fromJsonSync(jsonObj, context) {
|
|
534
|
+
let schema = new Schema(context);
|
|
535
|
+
const reader = new SchemaReadHelper(JsonParser, context);
|
|
536
|
+
const rawSchema = typeof jsonObj === "string" ? JSON.parse(jsonObj) : jsonObj;
|
|
537
|
+
schema = reader.readSchemaSync(schema, rawSchema);
|
|
538
|
+
return schema;
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* @internal
|
|
542
|
+
*/
|
|
543
|
+
static isSchema(object) {
|
|
544
|
+
const schema = object;
|
|
545
|
+
return schema !== undefined && schema.schemaKey !== undefined && schema.context !== undefined;
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* @alpha
|
|
549
|
+
* Used for schema editing.
|
|
550
|
+
*/
|
|
551
|
+
setDisplayLabel(displayLabel) {
|
|
552
|
+
this._label = displayLabel;
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* @alpha
|
|
556
|
+
* Used for schema editing.
|
|
557
|
+
*/
|
|
558
|
+
setDescription(description) {
|
|
559
|
+
this._description = description;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Hackish approach that works like a "friend class" so we can access protected members without making them public.
|
|
564
|
+
* We cannot put this into Helper.ts and make it non-export, because we are importing Helper.ts from this file, and the circular import
|
|
565
|
+
* would prevent this class from extending Schema.
|
|
566
|
+
* @internal
|
|
567
|
+
*/
|
|
568
|
+
export class MutableSchema extends Schema {
|
|
569
|
+
}
|
|
570
|
+
//# sourceMappingURL=Schema.js.map
|