@itwin/ecschema-metadata 3.7.0-dev.3 → 3.7.0-dev.6

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.
Files changed (140) hide show
  1. package/lib/cjs/Constants.d.ts +23 -23
  2. package/lib/cjs/Constants.js +33 -33
  3. package/lib/cjs/Constants.js.map +1 -1
  4. package/lib/cjs/Context.d.ts +139 -139
  5. package/lib/cjs/Context.js +204 -204
  6. package/lib/cjs/DelayedPromise.d.ts +88 -88
  7. package/lib/cjs/DelayedPromise.js +91 -91
  8. package/lib/cjs/DelayedPromise.js.map +1 -1
  9. package/lib/cjs/Deserialization/AbstractParser.d.ts +45 -45
  10. package/lib/cjs/Deserialization/AbstractParser.js +11 -11
  11. package/lib/cjs/Deserialization/AbstractParser.js.map +1 -1
  12. package/lib/cjs/Deserialization/Helper.d.ts +251 -251
  13. package/lib/cjs/Deserialization/Helper.js +843 -843
  14. package/lib/cjs/Deserialization/Helper.js.map +1 -1
  15. package/lib/cjs/Deserialization/JsonParser.d.ts +165 -165
  16. package/lib/cjs/Deserialization/JsonParser.js +680 -680
  17. package/lib/cjs/Deserialization/JsonParser.js.map +1 -1
  18. package/lib/cjs/Deserialization/JsonProps.d.ts +282 -282
  19. package/lib/cjs/Deserialization/JsonProps.js +9 -9
  20. package/lib/cjs/Deserialization/JsonProps.js.map +1 -1
  21. package/lib/cjs/Deserialization/SchemaGraphUtil.d.ts +34 -34
  22. package/lib/cjs/Deserialization/SchemaGraphUtil.js +77 -77
  23. package/lib/cjs/Deserialization/SchemaGraphUtil.js.map +1 -1
  24. package/lib/cjs/Deserialization/XmlParser.d.ts +85 -85
  25. package/lib/cjs/Deserialization/XmlParser.js +973 -973
  26. package/lib/cjs/Deserialization/XmlParser.js.map +1 -1
  27. package/lib/cjs/Deserialization/XmlSerializationUtils.d.ts +54 -54
  28. package/lib/cjs/Deserialization/XmlSerializationUtils.js +174 -174
  29. package/lib/cjs/Deserialization/XmlSerializationUtils.js.map +1 -1
  30. package/lib/cjs/ECName.d.ts +30 -30
  31. package/lib/cjs/ECName.js +85 -85
  32. package/lib/cjs/ECName.js.map +1 -1
  33. package/lib/cjs/ECObjects.d.ts +162 -162
  34. package/lib/cjs/ECObjects.js +453 -453
  35. package/lib/cjs/ECObjects.js.map +1 -1
  36. package/lib/cjs/Exception.d.ts +43 -43
  37. package/lib/cjs/Exception.js +86 -86
  38. package/lib/cjs/Exception.js.map +1 -1
  39. package/lib/cjs/Interfaces.d.ts +66 -66
  40. package/lib/cjs/Interfaces.js +9 -9
  41. package/lib/cjs/Interfaces.js.map +1 -1
  42. package/lib/cjs/Metadata/Class.d.ts +243 -243
  43. package/lib/cjs/Metadata/Class.js +558 -558
  44. package/lib/cjs/Metadata/Class.js.map +1 -1
  45. package/lib/cjs/Metadata/Constant.d.ts +64 -64
  46. package/lib/cjs/Metadata/Constant.js +123 -123
  47. package/lib/cjs/Metadata/Constant.js.map +1 -1
  48. package/lib/cjs/Metadata/CustomAttribute.d.ts +23 -23
  49. package/lib/cjs/Metadata/CustomAttribute.js +27 -27
  50. package/lib/cjs/Metadata/CustomAttribute.js.map +1 -1
  51. package/lib/cjs/Metadata/CustomAttributeClass.d.ts +39 -39
  52. package/lib/cjs/Metadata/CustomAttributeClass.js +68 -68
  53. package/lib/cjs/Metadata/CustomAttributeClass.js.map +1 -1
  54. package/lib/cjs/Metadata/EntityClass.d.ts +77 -77
  55. package/lib/cjs/Metadata/EntityClass.js +230 -230
  56. package/lib/cjs/Metadata/EntityClass.js.map +1 -1
  57. package/lib/cjs/Metadata/Enumeration.d.ts +86 -86
  58. package/lib/cjs/Metadata/Enumeration.js +159 -159
  59. package/lib/cjs/Metadata/Enumeration.js.map +1 -1
  60. package/lib/cjs/Metadata/Format.d.ts +98 -98
  61. package/lib/cjs/Metadata/Format.js +242 -242
  62. package/lib/cjs/Metadata/Format.js.map +1 -1
  63. package/lib/cjs/Metadata/InvertedUnit.d.ts +49 -49
  64. package/lib/cjs/Metadata/InvertedUnit.js +97 -97
  65. package/lib/cjs/Metadata/InvertedUnit.js.map +1 -1
  66. package/lib/cjs/Metadata/KindOfQuantity.d.ts +65 -65
  67. package/lib/cjs/Metadata/KindOfQuantity.js +225 -225
  68. package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
  69. package/lib/cjs/Metadata/Mixin.d.ts +54 -54
  70. package/lib/cjs/Metadata/Mixin.js +113 -113
  71. package/lib/cjs/Metadata/Mixin.js.map +1 -1
  72. package/lib/cjs/Metadata/OverrideFormat.d.ts +55 -55
  73. package/lib/cjs/Metadata/OverrideFormat.js +88 -88
  74. package/lib/cjs/Metadata/OverrideFormat.js.map +1 -1
  75. package/lib/cjs/Metadata/Phenomenon.d.ts +33 -33
  76. package/lib/cjs/Metadata/Phenomenon.js +59 -59
  77. package/lib/cjs/Metadata/Phenomenon.js.map +1 -1
  78. package/lib/cjs/Metadata/Property.d.ts +197 -197
  79. package/lib/cjs/Metadata/Property.js +491 -491
  80. package/lib/cjs/Metadata/Property.js.map +1 -1
  81. package/lib/cjs/Metadata/PropertyCategory.d.ts +39 -39
  82. package/lib/cjs/Metadata/PropertyCategory.js +61 -61
  83. package/lib/cjs/Metadata/PropertyCategory.js.map +1 -1
  84. package/lib/cjs/Metadata/RelationshipClass.d.ts +152 -152
  85. package/lib/cjs/Metadata/RelationshipClass.js +349 -349
  86. package/lib/cjs/Metadata/RelationshipClass.js.map +1 -1
  87. package/lib/cjs/Metadata/Schema.d.ts +291 -291
  88. package/lib/cjs/Metadata/Schema.js +520 -520
  89. package/lib/cjs/Metadata/Schema.js.map +1 -1
  90. package/lib/cjs/Metadata/SchemaItem.d.ts +61 -61
  91. package/lib/cjs/Metadata/SchemaItem.js +136 -136
  92. package/lib/cjs/Metadata/SchemaItem.js.map +1 -1
  93. package/lib/cjs/Metadata/Unit.d.ts +76 -76
  94. package/lib/cjs/Metadata/Unit.js +162 -162
  95. package/lib/cjs/Metadata/UnitSystem.d.ts +20 -20
  96. package/lib/cjs/Metadata/UnitSystem.js +29 -29
  97. package/lib/cjs/Metadata/UnitSystem.js.map +1 -1
  98. package/lib/cjs/PropertyTypes.d.ts +49 -49
  99. package/lib/cjs/PropertyTypes.js +91 -91
  100. package/lib/cjs/PropertyTypes.js.map +1 -1
  101. package/lib/cjs/SchemaJsonLocater.d.ts +34 -34
  102. package/lib/cjs/SchemaJsonLocater.js +42 -42
  103. package/lib/cjs/SchemaJsonLocater.js.map +1 -1
  104. package/lib/cjs/SchemaKey.d.ts +110 -110
  105. package/lib/cjs/SchemaKey.js +219 -219
  106. package/lib/cjs/SchemaKey.js.map +1 -1
  107. package/lib/cjs/SchemaLoader.d.ts +23 -23
  108. package/lib/cjs/SchemaLoader.js +47 -47
  109. package/lib/cjs/SchemaLoader.js.map +1 -1
  110. package/lib/cjs/SchemaPartVisitorDelegate.d.ts +274 -274
  111. package/lib/cjs/SchemaPartVisitorDelegate.js +212 -212
  112. package/lib/cjs/SchemaPartVisitorDelegate.js.map +1 -1
  113. package/lib/cjs/UnitConversion/Graph.d.ts +34 -34
  114. package/lib/cjs/UnitConversion/Graph.js +83 -83
  115. package/lib/cjs/UnitConversion/Graph.js.map +1 -1
  116. package/lib/cjs/UnitConversion/Parser.d.ts +8 -8
  117. package/lib/cjs/UnitConversion/Parser.js +42 -42
  118. package/lib/cjs/UnitConversion/Parser.js.map +1 -1
  119. package/lib/cjs/UnitConversion/UnitConversion.d.ts +45 -45
  120. package/lib/cjs/UnitConversion/UnitConversion.js +77 -77
  121. package/lib/cjs/UnitConversion/UnitConversion.js.map +1 -1
  122. package/lib/cjs/UnitConversion/UnitConverter.d.ts +39 -39
  123. package/lib/cjs/UnitConversion/UnitConverter.js +116 -116
  124. package/lib/cjs/UnitConversion/UnitConverter.js.map +1 -1
  125. package/lib/cjs/UnitConversion/UnitTree.d.ts +43 -43
  126. package/lib/cjs/UnitConversion/UnitTree.js +169 -169
  127. package/lib/cjs/UnitConversion/UnitTree.js.map +1 -1
  128. package/lib/cjs/UnitProvider/SchemaUnitProvider.d.ts +77 -77
  129. package/lib/cjs/UnitProvider/SchemaUnitProvider.js +236 -236
  130. package/lib/cjs/UnitProvider/SchemaUnitProvider.js.map +1 -1
  131. package/lib/cjs/Validation/SchemaWalker.d.ts +23 -23
  132. package/lib/cjs/Validation/SchemaWalker.js +53 -53
  133. package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
  134. package/lib/cjs/ecschema-metadata.d.ts +51 -51
  135. package/lib/cjs/ecschema-metadata.js +96 -96
  136. package/lib/cjs/ecschema-metadata.js.map +1 -1
  137. package/lib/cjs/utils/SchemaGraph.d.ts +25 -25
  138. package/lib/cjs/utils/SchemaGraph.js +65 -65
  139. package/lib/cjs/utils/SchemaGraph.js.map +1 -1
  140. package/package.json +7 -7
@@ -1,681 +1,681 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.JsonParser = void 0;
8
- const Exception_1 = require("../Exception");
9
- const ECName_1 = require("../ECName");
10
- const AbstractParser_1 = require("./AbstractParser");
11
- function isObject(x) {
12
- return typeof (x) === "object";
13
- }
14
- /** @internal */
15
- class JsonParser extends AbstractParser_1.AbstractParser {
16
- constructor(rawSchema) {
17
- super();
18
- if (!isObject(rawSchema))
19
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `Invalid JSON object.`);
20
- this._rawSchema = rawSchema;
21
- this._schemaName = rawSchema.name;
22
- }
23
- /**
24
- * Type checks Schema and returns SchemaProps interface
25
- * @param this._rawSchema
26
- * @returns SchemaProps
27
- */
28
- parseSchema() {
29
- if (undefined === this._rawSchema.name)
30
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `An ECSchema is missing the required 'name' attribute.`);
31
- if (typeof (this._rawSchema.name) !== "string")
32
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `An ECSchema has an invalid 'name' attribute. It should be of type 'string'.`);
33
- if (undefined === this._rawSchema.$schema)
34
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECSchema ${this._schemaName} is missing the required '$schema' attribute.`);
35
- if (typeof (this._rawSchema.$schema) !== "string")
36
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECSchema ${this._schemaName} has an invalid '$schema' attribute. It should be of type 'string'.`);
37
- if (undefined === this._rawSchema.version)
38
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECSchema ${this._schemaName} is missing the required 'version' attribute.`);
39
- if (typeof (this._rawSchema.version) !== "string")
40
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECSchema ${this._schemaName} has an invalid 'version' attribute. It should be of type 'string'.`);
41
- if (undefined !== this._rawSchema.alias) {
42
- if (typeof (this._rawSchema.alias) !== "string")
43
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECSchema ${this._schemaName} has an invalid 'alias' attribute. It should be of type 'string'.`);
44
- }
45
- if (undefined !== this._rawSchema.label) {
46
- if (typeof (this._rawSchema.label) !== "string")
47
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECSchema ${this._schemaName} has an invalid 'label' attribute. It should be of type 'string'.`);
48
- }
49
- if (undefined !== this._rawSchema.description) {
50
- if (typeof (this._rawSchema.description) !== "string")
51
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECSchema ${this._schemaName} has an invalid 'description' attribute. It should be of type 'string'.`);
52
- }
53
- return this._rawSchema;
54
- }
55
- *getReferences() {
56
- if (undefined !== this._rawSchema.references) {
57
- if (!Array.isArray(this._rawSchema.references))
58
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The schema ${this._rawSchema.name} has an invalid 'references' attribute. It should be of type 'object[]'.`);
59
- for (const ref of this._rawSchema.references) {
60
- yield this.checkSchemaReference(ref);
61
- }
62
- }
63
- }
64
- checkSchemaReference(jsonObj) {
65
- if (!isObject(jsonObj))
66
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The schema ${this._schemaName} has an invalid 'references' attribute. It should be of type 'object[]'.`);
67
- if (undefined === jsonObj.name)
68
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The schema ${this._schemaName} has an invalid 'references' attribute. One of the references is missing the required 'name' attribute.`);
69
- if (typeof (jsonObj.name) !== "string")
70
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The schema ${this._schemaName} has an invalid 'references' attribute. One of the references has an invalid 'name' attribute. It should be of type 'string'.`);
71
- if (undefined === jsonObj.version)
72
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The schema ${this._schemaName} has an invalid 'references' attribute. One of the references is missing the required 'version' attribute.`);
73
- if (typeof (jsonObj.version) !== "string")
74
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The schema ${this._schemaName} has an invalid 'references' attribute. One of the references has an invalid 'version' attribute. It should be of type 'string'.`);
75
- return jsonObj;
76
- }
77
- *getItems() {
78
- const items = this._rawSchema.items;
79
- if (undefined !== items) {
80
- if (!isObject(items) || Array.isArray(items))
81
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The schema ${this._schemaName} has an invalid 'items' attribute. It should be of type 'object'.`);
82
- // eslint-disable-next-line guard-for-in
83
- for (const itemName in items) {
84
- const item = items[itemName];
85
- if (!isObject(item))
86
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `A SchemaItem in ${this._schemaName} is an invalid JSON object.`);
87
- if (!ECName_1.ECName.validate(itemName))
88
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECName, `A SchemaItem in ${this._schemaName} has an invalid 'name' attribute. '${itemName}' is not a valid ECName.`);
89
- if (undefined === item.schemaItemType)
90
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The SchemaItem ${this._schemaName}.${itemName} is missing the required 'schemaItemType' attribute.`);
91
- if (typeof (item.schemaItemType) !== "string")
92
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The SchemaItem ${this._schemaName}.${itemName} has an invalid 'schemaItemType' attribute. It should be of type 'string'.`);
93
- this._currentItemFullName = `${this._schemaName}.${itemName}`;
94
- yield [itemName, item.schemaItemType, item];
95
- }
96
- }
97
- }
98
- findItem(itemName) {
99
- const items = this._rawSchema.items;
100
- if (undefined !== items) {
101
- if (!isObject(items) || Array.isArray(items))
102
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The schema ${this._schemaName} has an invalid 'items' attribute. It should be of type 'object'.`);
103
- const item = items[itemName];
104
- if (undefined !== item) {
105
- if (!isObject(item))
106
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `A SchemaItem in ${this._schemaName} is an invalid JSON object.`);
107
- if (!ECName_1.ECName.validate(itemName))
108
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECName, `A SchemaItem in ${this._schemaName} has an invalid 'name' attribute. '${itemName}' is not a valid ECName.`);
109
- if (undefined === item.schemaItemType)
110
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The SchemaItem ${this._schemaName}.${itemName} is missing the required 'schemaItemType' attribute.`);
111
- if (typeof (item.schemaItemType) !== "string")
112
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The SchemaItem ${this._schemaName}.${itemName} has an invalid 'schemaItemType' attribute. It should be of type 'string'.`);
113
- this._currentItemFullName = `${this._schemaName}.${itemName}`;
114
- return [itemName, item.schemaItemType, item];
115
- }
116
- }
117
- return undefined;
118
- }
119
- /**
120
- * Type checks all Schema Item attributes.
121
- * @param jsonObj The JSON object to check if it represents a Schema Item.
122
- */
123
- checkSchemaItemProps(jsonObj) {
124
- if (undefined !== jsonObj.description) {
125
- if (typeof (jsonObj.description) !== "string")
126
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The SchemaItem ${this._currentItemFullName} has an invalid 'description' attribute. It should be of type 'string'.`);
127
- }
128
- if (undefined !== jsonObj.label) {
129
- if (typeof (jsonObj.label) !== "string")
130
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The SchemaItem ${this._currentItemFullName} has an invalid 'label' attribute. It should be of type 'string'.`);
131
- }
132
- }
133
- *getProperties(jsonObj, itemName) {
134
- const properties = jsonObj.properties;
135
- if (undefined !== properties) {
136
- if (!Array.isArray(properties))
137
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECClass ${itemName} has an invalid 'properties' attribute. It should be of type 'object[]'.`);
138
- for (const property of properties) {
139
- if (!isObject(property))
140
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `An ECProperty in ${itemName} is an invalid JSON object.`);
141
- if (undefined === property.name)
142
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `An ECProperty in ${itemName} is missing the required 'name' attribute.`);
143
- if (typeof (property.name) !== "string")
144
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `An ECProperty in ${itemName} has an invalid 'name' attribute. It should be of type 'string'.`);
145
- if (undefined === property.type)
146
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${itemName}.${property.name} does not have the required 'type' attribute.`);
147
- if (typeof (property.type) !== "string")
148
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${itemName}.${property.name} has an invalid 'type' attribute. It should be of type 'string'.`);
149
- if (!this.isValidPropertyType(property.type))
150
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${itemName}.${property.name} has an invalid 'type' attribute. '${property.type}' is not a valid type.`);
151
- yield [property.name, property.type, property];
152
- }
153
- }
154
- }
155
- /**
156
- * Type checks Class and returns ClassProps interface
157
- * @param jsonObj The JSON object to check if it represents a Class.
158
- */
159
- checkClassProps(jsonObj) {
160
- this.checkSchemaItemProps(jsonObj);
161
- if (undefined !== jsonObj.modifier) {
162
- if (typeof (jsonObj.modifier) !== "string")
163
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECClass ${this._currentItemFullName} has an invalid 'modifier' attribute. It should be of type 'string'.`);
164
- }
165
- if (undefined !== jsonObj.baseClass) {
166
- if (typeof (jsonObj.baseClass) !== "string")
167
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECClass ${this._currentItemFullName} has an invalid 'baseClass' attribute. It should be of type 'string'.`);
168
- }
169
- if (undefined !== jsonObj.customAttributes) {
170
- if (!Array.isArray(jsonObj.customAttributes)) {
171
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECClass ${this._currentItemFullName} has an invalid 'customAttributes' attribute. It should be of type 'array'.`);
172
- }
173
- }
174
- }
175
- /**
176
- * Type checks entity class and returns EntityClassProps interface
177
- * @param jsonObj
178
- * @returns EntityClassProps
179
- */
180
- parseEntityClass(jsonObj) {
181
- this.checkClassProps(jsonObj);
182
- if (undefined !== jsonObj.mixins) {
183
- if (!Array.isArray(jsonObj.mixins))
184
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECEntityClass ${this._currentItemFullName} has an invalid 'mixins' attribute. It should be of type 'string[]'.`);
185
- for (const mixinName of jsonObj.mixins) {
186
- if (typeof (mixinName) !== "string")
187
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECEntityClass ${this._currentItemFullName} has an invalid 'mixins' attribute. It should be of type 'string[]'.`);
188
- }
189
- }
190
- return jsonObj;
191
- }
192
- /**
193
- * Type checks mixin and returns MixinProps interface
194
- * @param jsonObj
195
- * @returns MixinProps
196
- */
197
- parseMixin(jsonObj) {
198
- this.checkClassProps(jsonObj);
199
- if (undefined === jsonObj.appliesTo)
200
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Mixin ${this._currentItemFullName} is missing the required 'appliesTo' attribute.`);
201
- if (typeof (jsonObj.appliesTo) !== "string")
202
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Mixin ${this._currentItemFullName} has an invalid 'appliesTo' attribute. It should be of type 'string'.`);
203
- return jsonObj;
204
- }
205
- /**
206
- * Type checks custom attribute class and returns CustomAttributeClassProps interface
207
- * @param jsonObj
208
- * @returns CustomAttributeClassProps
209
- */
210
- parseCustomAttributeClass(jsonObj) {
211
- this.checkClassProps(jsonObj);
212
- if (undefined === jsonObj.appliesTo)
213
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The CustomAttributeClass ${this._currentItemFullName} is missing the required 'appliesTo' attribute.`);
214
- if (typeof (jsonObj.appliesTo) !== "string")
215
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The CustomAttributeClass ${this._currentItemFullName} has an invalid 'appliesTo' attribute. It should be of type 'string'.`);
216
- return jsonObj;
217
- }
218
- parseStructClass(jsonObj) {
219
- this.checkClassProps(jsonObj);
220
- return jsonObj;
221
- }
222
- parseUnitSystem(jsonObj) {
223
- this.checkSchemaItemProps(jsonObj);
224
- return jsonObj;
225
- }
226
- /**
227
- * Type checks Relationship Class and returns RelationshipClassProps interface
228
- * @param jsonObj
229
- * @returns RelationshipClassProps
230
- */
231
- parseRelationshipClass(jsonObj) {
232
- this.checkClassProps(jsonObj);
233
- if (undefined === jsonObj.strength)
234
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The RelationshipClass ${this._currentItemFullName} is missing the required 'strength' attribute.`);
235
- if (typeof (jsonObj.strength) !== "string")
236
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The RelationshipClass ${this._currentItemFullName} has an invalid 'strength' attribute. It should be of type 'string'.`);
237
- if (undefined === jsonObj.strengthDirection)
238
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The RelationshipClass ${this._currentItemFullName} is missing the required 'strengthDirection' attribute.`);
239
- if (typeof (jsonObj.strengthDirection) !== "string")
240
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The RelationshipClass ${this._currentItemFullName} has an invalid 'strengthDirection' attribute. It should be of type 'string'.`);
241
- if (undefined === jsonObj.source)
242
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The RelationshipClass ${this._currentItemFullName} is missing the required source constraint.`);
243
- if (!isObject(jsonObj.source))
244
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The RelationshipClass ${this._currentItemFullName} has an invalid source constraint. It should be of type 'object'.`);
245
- this.checkRelationshipConstraintProps(jsonObj.source, true);
246
- if (undefined === jsonObj.target)
247
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The RelationshipClass ${this._currentItemFullName} is missing the required target constraint.`);
248
- if (!isObject(jsonObj.target))
249
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The RelationshipClass ${this._currentItemFullName} has an invalid target constraint. It should be of type 'object'.`);
250
- this.checkRelationshipConstraintProps(jsonObj.target, false);
251
- return jsonObj;
252
- }
253
- /**
254
- * Type checks Relationship Constraint and returns RelationshipConstraintProps interface.
255
- * @param jsonObj
256
- * @param isSource For sake of error message, is this relationship constraint a source or target
257
- * @returns RelationshipConstraintProps
258
- */
259
- checkRelationshipConstraintProps(jsonObj, isSource) {
260
- const constraintName = `${(isSource) ? "Source" : "Target"} Constraint of ${this._currentItemFullName}`; // most specific name to call RelationshipConstraint
261
- if (undefined === jsonObj.multiplicity)
262
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ${constraintName} is missing the required 'multiplicity' attribute.`);
263
- if (typeof (jsonObj.multiplicity) !== "string")
264
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ${constraintName} has an invalid 'multiplicity' attribute. It should be of type 'string'.`);
265
- if (undefined === jsonObj.roleLabel)
266
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ${constraintName} is missing the required 'roleLabel' attribute.`);
267
- if (typeof (jsonObj.roleLabel) !== "string")
268
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ${constraintName} has an invalid 'roleLabel' attribute. It should be of type 'string'.`);
269
- if (undefined === jsonObj.polymorphic)
270
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ${constraintName} is missing the required 'polymorphic' attribute.`);
271
- if (typeof (jsonObj.polymorphic) !== "boolean")
272
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ${constraintName} has an invalid 'polymorphic' attribute. It should be of type 'boolean'.`);
273
- if (undefined !== jsonObj.abstractConstraint && typeof (jsonObj.abstractConstraint) !== "string")
274
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ${constraintName} has an invalid 'abstractConstraint' attribute. It should be of type 'string'.`);
275
- if (undefined === jsonObj.constraintClasses)
276
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ${constraintName} is missing the required 'constraintClasses' attribute.`);
277
- if (!Array.isArray(jsonObj.constraintClasses))
278
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ${constraintName} has an invalid 'constraintClasses' attribute. It should be of type 'string[]'.`);
279
- for (const constraintClassName of jsonObj.constraintClasses) {
280
- if (typeof (constraintClassName) !== "string")
281
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ${constraintName} has an invalid 'constraintClasses' attribute. It should be of type 'string[]'.`);
282
- }
283
- if (undefined !== jsonObj.customAttributes && !Array.isArray(jsonObj.customAttributes))
284
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ${constraintName} has an invalid 'customAttributes' attribute. It should be of type 'array'.`);
285
- }
286
- /**
287
- * Type checks Enumeration and returns EnumerationProps interface
288
- * @param jsonObj
289
- * @returns EnumerationProps
290
- */
291
- parseEnumeration(jsonObj) {
292
- this.checkSchemaItemProps(jsonObj);
293
- if (undefined === jsonObj.type)
294
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} is missing the required 'type' attribute.`);
295
- if (typeof (jsonObj.type) !== "string")
296
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an invalid 'type' attribute. It should be of type 'string'.`);
297
- const isValidEnumerationType = (type) => {
298
- type = type.toLowerCase();
299
- return (type === "int") ||
300
- (type === "integer") ||
301
- (type === "string");
302
- };
303
- if (!isValidEnumerationType(jsonObj.type))
304
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an invalid 'type' attribute. It should be either "int" or "string".`);
305
- if (undefined !== jsonObj.isStrict) { // TODO: make required
306
- if (typeof (jsonObj.isStrict) !== "boolean")
307
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an invalid 'isStrict' attribute. It should be of type 'boolean'.`);
308
- }
309
- if (undefined === jsonObj.enumerators)
310
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} is missing the required 'enumerators' attribute.`);
311
- if (!Array.isArray(jsonObj.enumerators))
312
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an invalid 'enumerators' attribute. It should be of type 'object[]'.`);
313
- for (const enumerator of jsonObj.enumerators) {
314
- if (!isObject(enumerator))
315
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an invalid 'enumerators' attribute. It should be of type 'object[]'.`);
316
- if (undefined === enumerator.value)
317
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an enumerator that is missing the required attribute 'value'.`);
318
- // TODO: Should this really be handled here?
319
- const expectedType = jsonObj.type;
320
- const receivedType = (typeof (enumerator.value) === "number") ? "int" : typeof (enumerator.value);
321
- if (!expectedType.includes(receivedType)) // is receivedType a substring of expectedType? - easiest way to check "int" === "int" | "integer" && "string" === "string"
322
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an incompatible type. It must be "${expectedType}", not "${receivedType}".`);
323
- if (undefined === enumerator.name)
324
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an enumerator that is missing the required attribute 'name'.`);
325
- if (typeof (enumerator.name) !== "string")
326
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an enumerator with an invalid 'name' attribute. It should be of type 'string'.`);
327
- if (undefined !== enumerator.label) {
328
- if (typeof (enumerator.label) !== "string")
329
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an enumerator with an invalid 'label' attribute. It should be of type 'string'.`);
330
- }
331
- if (undefined !== enumerator.description) {
332
- if (typeof (enumerator.description) !== "string")
333
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an enumerator with an invalid 'description' attribute. It should be of type 'string'.`);
334
- }
335
- }
336
- return jsonObj;
337
- }
338
- /**
339
- * Type checks KindOfQuantity and returns KindOfQuantityProps interface
340
- * @param jsonObj
341
- * @returns KindOfQuantityProps
342
- */
343
- parseKindOfQuantity(jsonObj) {
344
- this.checkSchemaItemProps(jsonObj);
345
- if (undefined === jsonObj.relativeError)
346
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The KindOfQuantity ${this._currentItemFullName} is missing the required 'relativeError' attribute.`);
347
- if (typeof (jsonObj.relativeError) !== "number")
348
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The KindOfQuantity ${this._currentItemFullName} has an invalid 'relativeError' attribute. It should be of type 'number'.`);
349
- if (undefined !== jsonObj.presentationUnits) {
350
- if (!Array.isArray(jsonObj.presentationUnits) && typeof (jsonObj.presentationUnits) !== "string")
351
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The KindOfQuantity ${this._currentItemFullName} has an invalid 'presentationUnits' attribute. It should be of type 'string' or 'string[]'.`);
352
- }
353
- if (undefined === jsonObj.persistenceUnit)
354
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The KindOfQuantity ${this._currentItemFullName} is missing the required 'persistenceUnit' attribute.`);
355
- if (typeof (jsonObj.persistenceUnit) !== "string")
356
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The KindOfQuantity ${this._currentItemFullName} has an invalid 'persistenceUnit' attribute. It should be of type 'string'.`);
357
- return jsonObj;
358
- }
359
- /**
360
- * Type checks Property Category and returns PropertyCategoryProps interface
361
- * @param jsonObj
362
- * @returns PropertyCategoryProps
363
- */
364
- parsePropertyCategory(jsonObj) {
365
- this.checkSchemaItemProps(jsonObj);
366
- if (undefined !== jsonObj.priority) { // TODO: make required
367
- if (typeof (jsonObj.priority) !== "number")
368
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The PropertyCategory ${this._currentItemFullName} has an invalid 'priority' attribute. It should be of type 'number'.`);
369
- }
370
- return jsonObj;
371
- }
372
- /**
373
- * Type checks unit and returns UnitProps interface
374
- * @param jsonObj
375
- * @returns UnitProps
376
- */
377
- parseUnit(jsonObj) {
378
- this.checkSchemaItemProps(jsonObj);
379
- if (undefined === jsonObj.phenomenon)
380
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Unit ${this._currentItemFullName} does not have the required 'phenomenon' attribute.`);
381
- if (typeof (jsonObj.phenomenon) !== "string")
382
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Unit ${this._currentItemFullName} has an invalid 'phenomenon' attribute. It should be of type 'string'.`);
383
- if (undefined === jsonObj.unitSystem)
384
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Unit ${this._currentItemFullName} does not have the required 'unitSystem' attribute.`);
385
- if (typeof (jsonObj.unitSystem) !== "string")
386
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Unit ${this._currentItemFullName} has an invalid 'unitSystem' attribute. It should be of type 'string'.`);
387
- if (undefined === jsonObj.definition)
388
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Unit ${this._currentItemFullName} does not have the required 'definition' attribute.`);
389
- if (typeof (jsonObj.definition) !== "string")
390
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Unit ${this._currentItemFullName} has an invalid 'definition' attribute. It should be of type 'string'.`);
391
- if (undefined !== jsonObj.numerator) {
392
- if (typeof (jsonObj.numerator) !== "number")
393
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Unit ${this._currentItemFullName} has an invalid 'numerator' attribute. It should be of type 'number'.`);
394
- }
395
- if (undefined !== jsonObj.denominator) {
396
- if (typeof (jsonObj.denominator) !== "number")
397
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Unit ${this._currentItemFullName} has an invalid 'denominator' attribute. It should be of type 'number'.`);
398
- }
399
- if (undefined !== jsonObj.offset) {
400
- if (typeof (jsonObj.offset) !== "number")
401
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Unit ${this._currentItemFullName} has an invalid 'offset' attribute. It should be of type 'number'.`);
402
- }
403
- return jsonObj;
404
- }
405
- /**
406
- * Type checks inverted unit and returns InvertedUnitProps interface
407
- * @param jsonObj
408
- * @returns InvertedUnitProps
409
- */
410
- parseInvertedUnit(jsonObj) {
411
- this.checkSchemaItemProps(jsonObj);
412
- if (undefined === jsonObj.invertsUnit)
413
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The InvertedUnit ${this._currentItemFullName} does not have the required 'invertsUnit' attribute.`);
414
- if (typeof (jsonObj.invertsUnit) !== "string")
415
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The InvertedUnit ${this._currentItemFullName} has an invalid 'invertsUnit' attribute. It should be of type 'string'.`);
416
- if (undefined === jsonObj.unitSystem)
417
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The InvertedUnit ${this._currentItemFullName} does not have the required 'unitSystem' attribute.`);
418
- if (typeof (jsonObj.unitSystem) !== "string")
419
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The InvertedUnit ${this._currentItemFullName} has an invalid 'unitSystem' attribute. It should be of type 'string'.`);
420
- return jsonObj;
421
- }
422
- /**
423
- * Type checks constant and returns ConstantProps interface
424
- * @param jsonObj
425
- * @returns ConstantProps
426
- */
427
- parseConstant(jsonObj) {
428
- this.checkSchemaItemProps(jsonObj);
429
- if (undefined === jsonObj.phenomenon)
430
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Constant ${this._currentItemFullName} does not have the required 'phenomenon' attribute.`);
431
- if (typeof (jsonObj.phenomenon) !== "string")
432
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Constant ${this._currentItemFullName} has an invalid 'phenomenon' attribute. It should be of type 'string'.`);
433
- if (undefined === jsonObj.definition)
434
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Constant ${this._currentItemFullName} does not have the required 'definition' attribute.`);
435
- if (typeof (jsonObj.definition) !== "string")
436
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Constant ${this._currentItemFullName} has an invalid 'definition' attribute. It should be of type 'string'.`);
437
- if (undefined !== jsonObj.numerator) {
438
- if (typeof (jsonObj.numerator) !== "number")
439
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Constant ${this._currentItemFullName} has an invalid 'numerator' attribute. It should be of type 'number'.`);
440
- }
441
- if (undefined !== jsonObj.denominator) {
442
- if (typeof (jsonObj.denominator) !== "number")
443
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Constant ${this._currentItemFullName} has an invalid 'denominator' attribute. It should be of type 'number'.`);
444
- }
445
- return jsonObj;
446
- }
447
- /**
448
- * Type checks phenomenon and returns PhenomenonProps interface
449
- * @param jsonObj
450
- * @returns PhenomenonProps
451
- */
452
- parsePhenomenon(jsonObj) {
453
- this.checkSchemaItemProps(jsonObj);
454
- if (undefined === jsonObj.definition)
455
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Phenomenon ${this._currentItemFullName} does not have the required 'definition' attribute.`);
456
- if (typeof (jsonObj.definition) !== "string")
457
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Phenomenon ${this._currentItemFullName} has an invalid 'definition' attribute. It should be of type 'string'.`);
458
- return jsonObj;
459
- }
460
- /**
461
- * Type checks format and returns FormatProps interface
462
- * @param jsonObj
463
- * @returns FormatProps
464
- */
465
- parseFormat(jsonObj) {
466
- this.checkSchemaItemProps(jsonObj);
467
- if (undefined === jsonObj.type)
468
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} does not have the required 'type' attribute.`);
469
- if (typeof (jsonObj.type) !== "string")
470
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'type' attribute. It should be of type 'string'.`);
471
- if (undefined !== jsonObj.precision && typeof (jsonObj.precision) !== "number")
472
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'precision' attribute. It should be of type 'number'.`);
473
- if (undefined !== jsonObj.roundFactor && typeof (jsonObj.roundFactor) !== "number")
474
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'roundFactor' attribute. It should be of type 'number'.`);
475
- if (undefined !== jsonObj.minWidth && typeof (jsonObj.minWidth) !== "number")
476
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'minWidth' attribute. It should be of type 'number'.`);
477
- if (undefined !== jsonObj.showSignOption && typeof (jsonObj.showSignOption) !== "string")
478
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'showSignOption' attribute. It should be of type 'string'.`);
479
- if (undefined !== jsonObj.formatTraits) {
480
- if (!Array.isArray(jsonObj.formatTraits) && typeof (jsonObj.formatTraits) !== "string") // must be either an array of strings or a string
481
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'formatTraits' attribute. It should be of type 'string' or 'string[]'.`);
482
- }
483
- if (undefined !== jsonObj.decimalSeparator && typeof (jsonObj.decimalSeparator) !== "string")
484
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'decimalSeparator' attribute. It should be of type 'string'.`);
485
- if (undefined !== jsonObj.thousandSeparator && typeof (jsonObj.thousandSeparator) !== "string")
486
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'thousandSeparator' attribute. It should be of type 'string'.`);
487
- if (undefined !== jsonObj.uomSeparator && typeof (jsonObj.uomSeparator) !== "string")
488
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'uomSeparator' attribute. It should be of type 'string'.`);
489
- if (undefined !== jsonObj.scientificType && typeof (jsonObj.scientificType) !== "string")
490
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'scientificType' attribute. It should be of type 'string'.`);
491
- if (undefined !== jsonObj.stationOffsetSize && typeof (jsonObj.stationOffsetSize) !== "number")
492
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'stationOffsetSize' attribute. It should be of type 'number'.`);
493
- if (undefined !== jsonObj.stationSeparator && typeof (jsonObj.stationSeparator) !== "string")
494
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'stationSeparator' attribute. It should be of type 'string'.`);
495
- if (undefined !== jsonObj.composite) { // optional
496
- if (!isObject(jsonObj.composite))
497
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'composite' object.`);
498
- if (undefined !== jsonObj.composite.includeZero && typeof (jsonObj.composite.includeZero) !== "boolean")
499
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has a Composite with an invalid 'includeZero' attribute. It should be of type 'boolean'.`);
500
- if (undefined !== jsonObj.composite.spacer && typeof (jsonObj.composite.spacer) !== "string")
501
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has a Composite with an invalid 'spacer' attribute. It should be of type 'string'.`);
502
- // if composite is defined
503
- if (undefined === jsonObj.composite.units)
504
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'Composite' attribute. It should have 1-4 units.`);
505
- if (!Array.isArray(jsonObj.composite.units))
506
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has a Composite with an invalid 'units' attribute. It should be of type 'object[]'.`);
507
- for (let i = 0; i < jsonObj.composite.units.length; i++) {
508
- if (!isObject(jsonObj.composite.units[i]))
509
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has a Composite with an invalid 'units' attribute. It should be of type 'object[]'.`);
510
- if (undefined === jsonObj.composite.units[i].name) // required
511
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has a Composite with an invalid 'units' attribute. The object at position ${i} is missing the required 'name' attribute.`);
512
- if (typeof (jsonObj.composite.units[i].name) !== "string")
513
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has a Composite with an invalid 'units' attribute. The object at position ${i} has an invalid 'name' attribute. It should be of type 'string'.`);
514
- if (undefined !== jsonObj.composite.units[i].label && typeof (jsonObj.composite.units[i].label) !== "string")
515
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has a Composite with an invalid 'units' attribute. The object at position ${i} has an invalid 'label' attribute. It should be of type 'string'.`);
516
- }
517
- }
518
- return jsonObj;
519
- }
520
- isValidPropertyType(type) {
521
- type = type.toLowerCase();
522
- return (type === "primitiveproperty") ||
523
- (type === "structproperty") ||
524
- (type === "primitivearrayproperty") ||
525
- (type === "structarrayproperty") ||
526
- (type === "navigationproperty");
527
- }
528
- /**
529
- * Type checks property and returns PropertyProps interface
530
- * @param jsonObj
531
- * @returns PropertyProps
532
- */
533
- checkPropertyProps(jsonObj) {
534
- const propName = jsonObj.name;
535
- if (undefined !== jsonObj.label && typeof (jsonObj.label) !== "string")
536
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'label' attribute. It should be of type 'string'.`);
537
- if (undefined !== jsonObj.description && typeof (jsonObj.description) !== "string")
538
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'description' attribute. It should be of type 'string'.`);
539
- if (undefined !== jsonObj.priority && typeof (jsonObj.priority) !== "number")
540
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'priority' attribute. It should be of type 'number'.`);
541
- if (undefined !== jsonObj.isReadOnly && typeof (jsonObj.isReadOnly) !== "boolean")
542
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'isReadOnly' attribute. It should be of type 'boolean'.`);
543
- if (undefined !== jsonObj.category && typeof (jsonObj.category) !== "string")
544
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'category' attribute. It should be of type 'string'.`);
545
- if (undefined !== jsonObj.kindOfQuantity && typeof (jsonObj.kindOfQuantity) !== "string")
546
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'kindOfQuantity' attribute. It should be of type 'string'.`);
547
- if (undefined !== jsonObj.inherited && typeof (jsonObj.inherited) !== "boolean")
548
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'inherited' attribute. It should be of type 'boolean'.`);
549
- if (undefined !== jsonObj.customAttributes && !Array.isArray(jsonObj.customAttributes))
550
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'customAttributes' attribute. It should be of type 'array'.`);
551
- return jsonObj;
552
- }
553
- checkPropertyTypename(jsonObj) {
554
- const propName = jsonObj.name;
555
- if (undefined === jsonObj.typeName)
556
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} is missing the required 'typeName' attribute.`);
557
- if (typeof (jsonObj.typeName) !== "string")
558
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'typeName' attribute. It should be of type 'string'.`);
559
- }
560
- checkPropertyMinAndMaxOccurs(jsonObj) {
561
- const propName = jsonObj.name;
562
- if (undefined !== jsonObj.minOccurs && typeof (jsonObj.minOccurs) !== "number")
563
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'minOccurs' attribute. It should be of type 'number'.`);
564
- if (undefined !== jsonObj.maxOccurs && typeof (jsonObj.maxOccurs) !== "number")
565
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'maxOccurs' attribute. It should be of type 'number'.`);
566
- }
567
- /**
568
- * Type checks PrimitiveOrEnumProperty and returns PrimitiveOrEnumPropertyBaseProps interface
569
- * @param jsonObj
570
- * @returns PrimitiveOrEnumPropertyBaseProps
571
- */
572
- checkPrimitiveOrEnumPropertyBaseProps(jsonObj) {
573
- this.checkPropertyProps(jsonObj);
574
- this.checkPropertyTypename(jsonObj);
575
- const propName = jsonObj.name;
576
- if (undefined !== jsonObj.minLength && typeof (jsonObj.minLength) !== "number")
577
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'minLength' attribute. It should be of type 'number'.`);
578
- if (undefined !== jsonObj.maxLength && typeof (jsonObj.maxLength) !== "number")
579
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'maxLength' attribute. It should be of type 'number'.`);
580
- if (undefined !== jsonObj.minValue && typeof (jsonObj.minValue) !== "number")
581
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'minValue' attribute. It should be of type 'number'.`);
582
- if (undefined !== jsonObj.maxValue && typeof (jsonObj.maxValue) !== "number")
583
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'maxValue' attribute. It should be of type 'number'.`);
584
- if (undefined !== jsonObj.extendedTypeName && typeof (jsonObj.extendedTypeName) !== "string")
585
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'extendedTypeName' attribute. It should be of type 'string'.`);
586
- return jsonObj;
587
- }
588
- /**
589
- * Type checks PrimitiveProperty and returns PrimitivePropertyProps interface
590
- * @param jsonObj
591
- * @returns PrimitivePropertyProps
592
- */
593
- parsePrimitiveProperty(jsonObj) {
594
- this.checkPrimitiveOrEnumPropertyBaseProps(jsonObj);
595
- return jsonObj;
596
- }
597
- /**
598
- * Type checks StructProperty and returns StructPropertyProps interface
599
- * @param jsonObj
600
- * @returns StructPropertyProps
601
- */
602
- parseStructProperty(jsonObj) {
603
- this.checkPropertyProps(jsonObj);
604
- this.checkPropertyTypename(jsonObj);
605
- return jsonObj;
606
- }
607
- /**
608
- * Type checks PrimitiveArrayProperty and returns PrimitiveArrayPropertyProps interface
609
- * @param jsonObj
610
- * @returns PrimitiveArrayPropertyProps
611
- */
612
- parsePrimitiveArrayProperty(jsonObj) {
613
- this.checkPrimitiveOrEnumPropertyBaseProps(jsonObj);
614
- this.checkPropertyMinAndMaxOccurs(jsonObj);
615
- return jsonObj;
616
- }
617
- /**
618
- * Type checks StructArrayProperty and returns StructArrayPropertyProps interface
619
- * @param jsonObj
620
- * @returns StructArrayPropertyProps
621
- */
622
- parseStructArrayProperty(jsonObj) {
623
- this.checkPropertyProps(jsonObj);
624
- this.checkPropertyTypename(jsonObj);
625
- this.checkPropertyMinAndMaxOccurs(jsonObj);
626
- return jsonObj;
627
- }
628
- /**
629
- * Type checks NavigationProperty and returns NavigationPropertyProps interface
630
- * @param jsonObj
631
- * @returns NavigationPropertyProps
632
- */
633
- parseNavigationProperty(jsonObj) {
634
- this.checkPropertyProps(jsonObj);
635
- const fullname = `${this._currentItemFullName}.${jsonObj.name}`;
636
- if (undefined === jsonObj.relationshipName)
637
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Navigation Property ${fullname} is missing the required 'relationshipName' property.`);
638
- if (typeof (jsonObj.relationshipName) !== "string")
639
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Navigation Property ${fullname} has an invalid 'relationshipName' property. It should be of type 'string'.`);
640
- if (undefined === jsonObj.direction)
641
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Navigation Property ${fullname} is missing the required 'direction' property.`);
642
- if (typeof (jsonObj.direction) !== "string")
643
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Navigation Property ${fullname} has an invalid 'direction' property. It should be of type 'string'.`);
644
- return jsonObj;
645
- }
646
- getSchemaCustomAttributeProviders() {
647
- return this.getCustomAttributeProviders(this._rawSchema, "Schema", this._schemaName);
648
- }
649
- getClassCustomAttributeProviders(jsonObj) {
650
- return this.getCustomAttributeProviders(jsonObj, "ECClass", this._currentItemFullName);
651
- }
652
- getPropertyCustomAttributeProviders(jsonObj) {
653
- return this.getCustomAttributeProviders(jsonObj, "ECProperty", `${this._currentItemFullName}.${jsonObj.name}`);
654
- }
655
- getRelationshipConstraintCustomAttributeProviders(jsonObj) {
656
- const sourceCustomAttributes = this.getCustomAttributeProviders(jsonObj.source, "Source Constraint of", this._currentItemFullName);
657
- const targetCustomAttributes = this.getCustomAttributeProviders(jsonObj.target, "Target Constraint of", this._currentItemFullName);
658
- return [sourceCustomAttributes, targetCustomAttributes];
659
- }
660
- *getCustomAttributeProviders(jsonObj, type, name) {
661
- if (undefined !== jsonObj.customAttributes) {
662
- if (!Array.isArray(jsonObj.customAttributes))
663
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ${type} ${name} has an invalid 'customAttributes' attribute. It should be of type 'object[]'.`);
664
- for (const instance of jsonObj.customAttributes) {
665
- if (!isObject(instance) || Array.isArray(instance))
666
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ${type} ${name} has an invalid 'customAttributes' attribute. It should be of type 'object[]'.`);
667
- if (undefined === instance.className)
668
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `A CustomAttribute in ${name}.customAttributes is missing the required 'className' attribute.`);
669
- if (typeof (instance.className) !== "string")
670
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `A CustomAttribute in ${name}.customAttributes has an invalid 'className' attribute. It should be of type 'string'.`);
671
- const provider = (_caClass) => {
672
- return instance;
673
- };
674
- const caTuple = [instance.className, provider];
675
- yield caTuple;
676
- }
677
- }
678
- }
679
- }
680
- exports.JsonParser = JsonParser;
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.JsonParser = void 0;
8
+ const Exception_1 = require("../Exception");
9
+ const ECName_1 = require("../ECName");
10
+ const AbstractParser_1 = require("./AbstractParser");
11
+ function isObject(x) {
12
+ return typeof (x) === "object";
13
+ }
14
+ /** @internal */
15
+ class JsonParser extends AbstractParser_1.AbstractParser {
16
+ constructor(rawSchema) {
17
+ super();
18
+ if (!isObject(rawSchema))
19
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `Invalid JSON object.`);
20
+ this._rawSchema = rawSchema;
21
+ this._schemaName = rawSchema.name;
22
+ }
23
+ /**
24
+ * Type checks Schema and returns SchemaProps interface
25
+ * @param this._rawSchema
26
+ * @returns SchemaProps
27
+ */
28
+ parseSchema() {
29
+ if (undefined === this._rawSchema.name)
30
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `An ECSchema is missing the required 'name' attribute.`);
31
+ if (typeof (this._rawSchema.name) !== "string")
32
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `An ECSchema has an invalid 'name' attribute. It should be of type 'string'.`);
33
+ if (undefined === this._rawSchema.$schema)
34
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECSchema ${this._schemaName} is missing the required '$schema' attribute.`);
35
+ if (typeof (this._rawSchema.$schema) !== "string")
36
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECSchema ${this._schemaName} has an invalid '$schema' attribute. It should be of type 'string'.`);
37
+ if (undefined === this._rawSchema.version)
38
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECSchema ${this._schemaName} is missing the required 'version' attribute.`);
39
+ if (typeof (this._rawSchema.version) !== "string")
40
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECSchema ${this._schemaName} has an invalid 'version' attribute. It should be of type 'string'.`);
41
+ if (undefined !== this._rawSchema.alias) {
42
+ if (typeof (this._rawSchema.alias) !== "string")
43
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECSchema ${this._schemaName} has an invalid 'alias' attribute. It should be of type 'string'.`);
44
+ }
45
+ if (undefined !== this._rawSchema.label) {
46
+ if (typeof (this._rawSchema.label) !== "string")
47
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECSchema ${this._schemaName} has an invalid 'label' attribute. It should be of type 'string'.`);
48
+ }
49
+ if (undefined !== this._rawSchema.description) {
50
+ if (typeof (this._rawSchema.description) !== "string")
51
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECSchema ${this._schemaName} has an invalid 'description' attribute. It should be of type 'string'.`);
52
+ }
53
+ return this._rawSchema;
54
+ }
55
+ *getReferences() {
56
+ if (undefined !== this._rawSchema.references) {
57
+ if (!Array.isArray(this._rawSchema.references))
58
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The schema ${this._rawSchema.name} has an invalid 'references' attribute. It should be of type 'object[]'.`);
59
+ for (const ref of this._rawSchema.references) {
60
+ yield this.checkSchemaReference(ref);
61
+ }
62
+ }
63
+ }
64
+ checkSchemaReference(jsonObj) {
65
+ if (!isObject(jsonObj))
66
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The schema ${this._schemaName} has an invalid 'references' attribute. It should be of type 'object[]'.`);
67
+ if (undefined === jsonObj.name)
68
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The schema ${this._schemaName} has an invalid 'references' attribute. One of the references is missing the required 'name' attribute.`);
69
+ if (typeof (jsonObj.name) !== "string")
70
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The schema ${this._schemaName} has an invalid 'references' attribute. One of the references has an invalid 'name' attribute. It should be of type 'string'.`);
71
+ if (undefined === jsonObj.version)
72
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The schema ${this._schemaName} has an invalid 'references' attribute. One of the references is missing the required 'version' attribute.`);
73
+ if (typeof (jsonObj.version) !== "string")
74
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The schema ${this._schemaName} has an invalid 'references' attribute. One of the references has an invalid 'version' attribute. It should be of type 'string'.`);
75
+ return jsonObj;
76
+ }
77
+ *getItems() {
78
+ const items = this._rawSchema.items;
79
+ if (undefined !== items) {
80
+ if (!isObject(items) || Array.isArray(items))
81
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The schema ${this._schemaName} has an invalid 'items' attribute. It should be of type 'object'.`);
82
+ // eslint-disable-next-line guard-for-in
83
+ for (const itemName in items) {
84
+ const item = items[itemName];
85
+ if (!isObject(item))
86
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `A SchemaItem in ${this._schemaName} is an invalid JSON object.`);
87
+ if (!ECName_1.ECName.validate(itemName))
88
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECName, `A SchemaItem in ${this._schemaName} has an invalid 'name' attribute. '${itemName}' is not a valid ECName.`);
89
+ if (undefined === item.schemaItemType)
90
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The SchemaItem ${this._schemaName}.${itemName} is missing the required 'schemaItemType' attribute.`);
91
+ if (typeof (item.schemaItemType) !== "string")
92
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The SchemaItem ${this._schemaName}.${itemName} has an invalid 'schemaItemType' attribute. It should be of type 'string'.`);
93
+ this._currentItemFullName = `${this._schemaName}.${itemName}`;
94
+ yield [itemName, item.schemaItemType, item];
95
+ }
96
+ }
97
+ }
98
+ findItem(itemName) {
99
+ const items = this._rawSchema.items;
100
+ if (undefined !== items) {
101
+ if (!isObject(items) || Array.isArray(items))
102
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The schema ${this._schemaName} has an invalid 'items' attribute. It should be of type 'object'.`);
103
+ const item = items[itemName];
104
+ if (undefined !== item) {
105
+ if (!isObject(item))
106
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `A SchemaItem in ${this._schemaName} is an invalid JSON object.`);
107
+ if (!ECName_1.ECName.validate(itemName))
108
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECName, `A SchemaItem in ${this._schemaName} has an invalid 'name' attribute. '${itemName}' is not a valid ECName.`);
109
+ if (undefined === item.schemaItemType)
110
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The SchemaItem ${this._schemaName}.${itemName} is missing the required 'schemaItemType' attribute.`);
111
+ if (typeof (item.schemaItemType) !== "string")
112
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The SchemaItem ${this._schemaName}.${itemName} has an invalid 'schemaItemType' attribute. It should be of type 'string'.`);
113
+ this._currentItemFullName = `${this._schemaName}.${itemName}`;
114
+ return [itemName, item.schemaItemType, item];
115
+ }
116
+ }
117
+ return undefined;
118
+ }
119
+ /**
120
+ * Type checks all Schema Item attributes.
121
+ * @param jsonObj The JSON object to check if it represents a Schema Item.
122
+ */
123
+ checkSchemaItemProps(jsonObj) {
124
+ if (undefined !== jsonObj.description) {
125
+ if (typeof (jsonObj.description) !== "string")
126
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The SchemaItem ${this._currentItemFullName} has an invalid 'description' attribute. It should be of type 'string'.`);
127
+ }
128
+ if (undefined !== jsonObj.label) {
129
+ if (typeof (jsonObj.label) !== "string")
130
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The SchemaItem ${this._currentItemFullName} has an invalid 'label' attribute. It should be of type 'string'.`);
131
+ }
132
+ }
133
+ *getProperties(jsonObj, itemName) {
134
+ const properties = jsonObj.properties;
135
+ if (undefined !== properties) {
136
+ if (!Array.isArray(properties))
137
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECClass ${itemName} has an invalid 'properties' attribute. It should be of type 'object[]'.`);
138
+ for (const property of properties) {
139
+ if (!isObject(property))
140
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `An ECProperty in ${itemName} is an invalid JSON object.`);
141
+ if (undefined === property.name)
142
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `An ECProperty in ${itemName} is missing the required 'name' attribute.`);
143
+ if (typeof (property.name) !== "string")
144
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `An ECProperty in ${itemName} has an invalid 'name' attribute. It should be of type 'string'.`);
145
+ if (undefined === property.type)
146
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${itemName}.${property.name} does not have the required 'type' attribute.`);
147
+ if (typeof (property.type) !== "string")
148
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${itemName}.${property.name} has an invalid 'type' attribute. It should be of type 'string'.`);
149
+ if (!this.isValidPropertyType(property.type))
150
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${itemName}.${property.name} has an invalid 'type' attribute. '${property.type}' is not a valid type.`);
151
+ yield [property.name, property.type, property];
152
+ }
153
+ }
154
+ }
155
+ /**
156
+ * Type checks Class and returns ClassProps interface
157
+ * @param jsonObj The JSON object to check if it represents a Class.
158
+ */
159
+ checkClassProps(jsonObj) {
160
+ this.checkSchemaItemProps(jsonObj);
161
+ if (undefined !== jsonObj.modifier) {
162
+ if (typeof (jsonObj.modifier) !== "string")
163
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECClass ${this._currentItemFullName} has an invalid 'modifier' attribute. It should be of type 'string'.`);
164
+ }
165
+ if (undefined !== jsonObj.baseClass) {
166
+ if (typeof (jsonObj.baseClass) !== "string")
167
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECClass ${this._currentItemFullName} has an invalid 'baseClass' attribute. It should be of type 'string'.`);
168
+ }
169
+ if (undefined !== jsonObj.customAttributes) {
170
+ if (!Array.isArray(jsonObj.customAttributes)) {
171
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECClass ${this._currentItemFullName} has an invalid 'customAttributes' attribute. It should be of type 'array'.`);
172
+ }
173
+ }
174
+ }
175
+ /**
176
+ * Type checks entity class and returns EntityClassProps interface
177
+ * @param jsonObj
178
+ * @returns EntityClassProps
179
+ */
180
+ parseEntityClass(jsonObj) {
181
+ this.checkClassProps(jsonObj);
182
+ if (undefined !== jsonObj.mixins) {
183
+ if (!Array.isArray(jsonObj.mixins))
184
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECEntityClass ${this._currentItemFullName} has an invalid 'mixins' attribute. It should be of type 'string[]'.`);
185
+ for (const mixinName of jsonObj.mixins) {
186
+ if (typeof (mixinName) !== "string")
187
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECEntityClass ${this._currentItemFullName} has an invalid 'mixins' attribute. It should be of type 'string[]'.`);
188
+ }
189
+ }
190
+ return jsonObj;
191
+ }
192
+ /**
193
+ * Type checks mixin and returns MixinProps interface
194
+ * @param jsonObj
195
+ * @returns MixinProps
196
+ */
197
+ parseMixin(jsonObj) {
198
+ this.checkClassProps(jsonObj);
199
+ if (undefined === jsonObj.appliesTo)
200
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Mixin ${this._currentItemFullName} is missing the required 'appliesTo' attribute.`);
201
+ if (typeof (jsonObj.appliesTo) !== "string")
202
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Mixin ${this._currentItemFullName} has an invalid 'appliesTo' attribute. It should be of type 'string'.`);
203
+ return jsonObj;
204
+ }
205
+ /**
206
+ * Type checks custom attribute class and returns CustomAttributeClassProps interface
207
+ * @param jsonObj
208
+ * @returns CustomAttributeClassProps
209
+ */
210
+ parseCustomAttributeClass(jsonObj) {
211
+ this.checkClassProps(jsonObj);
212
+ if (undefined === jsonObj.appliesTo)
213
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The CustomAttributeClass ${this._currentItemFullName} is missing the required 'appliesTo' attribute.`);
214
+ if (typeof (jsonObj.appliesTo) !== "string")
215
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The CustomAttributeClass ${this._currentItemFullName} has an invalid 'appliesTo' attribute. It should be of type 'string'.`);
216
+ return jsonObj;
217
+ }
218
+ parseStructClass(jsonObj) {
219
+ this.checkClassProps(jsonObj);
220
+ return jsonObj;
221
+ }
222
+ parseUnitSystem(jsonObj) {
223
+ this.checkSchemaItemProps(jsonObj);
224
+ return jsonObj;
225
+ }
226
+ /**
227
+ * Type checks Relationship Class and returns RelationshipClassProps interface
228
+ * @param jsonObj
229
+ * @returns RelationshipClassProps
230
+ */
231
+ parseRelationshipClass(jsonObj) {
232
+ this.checkClassProps(jsonObj);
233
+ if (undefined === jsonObj.strength)
234
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The RelationshipClass ${this._currentItemFullName} is missing the required 'strength' attribute.`);
235
+ if (typeof (jsonObj.strength) !== "string")
236
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The RelationshipClass ${this._currentItemFullName} has an invalid 'strength' attribute. It should be of type 'string'.`);
237
+ if (undefined === jsonObj.strengthDirection)
238
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The RelationshipClass ${this._currentItemFullName} is missing the required 'strengthDirection' attribute.`);
239
+ if (typeof (jsonObj.strengthDirection) !== "string")
240
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The RelationshipClass ${this._currentItemFullName} has an invalid 'strengthDirection' attribute. It should be of type 'string'.`);
241
+ if (undefined === jsonObj.source)
242
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The RelationshipClass ${this._currentItemFullName} is missing the required source constraint.`);
243
+ if (!isObject(jsonObj.source))
244
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The RelationshipClass ${this._currentItemFullName} has an invalid source constraint. It should be of type 'object'.`);
245
+ this.checkRelationshipConstraintProps(jsonObj.source, true);
246
+ if (undefined === jsonObj.target)
247
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The RelationshipClass ${this._currentItemFullName} is missing the required target constraint.`);
248
+ if (!isObject(jsonObj.target))
249
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The RelationshipClass ${this._currentItemFullName} has an invalid target constraint. It should be of type 'object'.`);
250
+ this.checkRelationshipConstraintProps(jsonObj.target, false);
251
+ return jsonObj;
252
+ }
253
+ /**
254
+ * Type checks Relationship Constraint and returns RelationshipConstraintProps interface.
255
+ * @param jsonObj
256
+ * @param isSource For sake of error message, is this relationship constraint a source or target
257
+ * @returns RelationshipConstraintProps
258
+ */
259
+ checkRelationshipConstraintProps(jsonObj, isSource) {
260
+ const constraintName = `${(isSource) ? "Source" : "Target"} Constraint of ${this._currentItemFullName}`; // most specific name to call RelationshipConstraint
261
+ if (undefined === jsonObj.multiplicity)
262
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ${constraintName} is missing the required 'multiplicity' attribute.`);
263
+ if (typeof (jsonObj.multiplicity) !== "string")
264
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ${constraintName} has an invalid 'multiplicity' attribute. It should be of type 'string'.`);
265
+ if (undefined === jsonObj.roleLabel)
266
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ${constraintName} is missing the required 'roleLabel' attribute.`);
267
+ if (typeof (jsonObj.roleLabel) !== "string")
268
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ${constraintName} has an invalid 'roleLabel' attribute. It should be of type 'string'.`);
269
+ if (undefined === jsonObj.polymorphic)
270
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ${constraintName} is missing the required 'polymorphic' attribute.`);
271
+ if (typeof (jsonObj.polymorphic) !== "boolean")
272
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ${constraintName} has an invalid 'polymorphic' attribute. It should be of type 'boolean'.`);
273
+ if (undefined !== jsonObj.abstractConstraint && typeof (jsonObj.abstractConstraint) !== "string")
274
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ${constraintName} has an invalid 'abstractConstraint' attribute. It should be of type 'string'.`);
275
+ if (undefined === jsonObj.constraintClasses)
276
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ${constraintName} is missing the required 'constraintClasses' attribute.`);
277
+ if (!Array.isArray(jsonObj.constraintClasses))
278
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ${constraintName} has an invalid 'constraintClasses' attribute. It should be of type 'string[]'.`);
279
+ for (const constraintClassName of jsonObj.constraintClasses) {
280
+ if (typeof (constraintClassName) !== "string")
281
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ${constraintName} has an invalid 'constraintClasses' attribute. It should be of type 'string[]'.`);
282
+ }
283
+ if (undefined !== jsonObj.customAttributes && !Array.isArray(jsonObj.customAttributes))
284
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ${constraintName} has an invalid 'customAttributes' attribute. It should be of type 'array'.`);
285
+ }
286
+ /**
287
+ * Type checks Enumeration and returns EnumerationProps interface
288
+ * @param jsonObj
289
+ * @returns EnumerationProps
290
+ */
291
+ parseEnumeration(jsonObj) {
292
+ this.checkSchemaItemProps(jsonObj);
293
+ if (undefined === jsonObj.type)
294
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} is missing the required 'type' attribute.`);
295
+ if (typeof (jsonObj.type) !== "string")
296
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an invalid 'type' attribute. It should be of type 'string'.`);
297
+ const isValidEnumerationType = (type) => {
298
+ type = type.toLowerCase();
299
+ return (type === "int") ||
300
+ (type === "integer") ||
301
+ (type === "string");
302
+ };
303
+ if (!isValidEnumerationType(jsonObj.type))
304
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an invalid 'type' attribute. It should be either "int" or "string".`);
305
+ if (undefined !== jsonObj.isStrict) { // TODO: make required
306
+ if (typeof (jsonObj.isStrict) !== "boolean")
307
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an invalid 'isStrict' attribute. It should be of type 'boolean'.`);
308
+ }
309
+ if (undefined === jsonObj.enumerators)
310
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} is missing the required 'enumerators' attribute.`);
311
+ if (!Array.isArray(jsonObj.enumerators))
312
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an invalid 'enumerators' attribute. It should be of type 'object[]'.`);
313
+ for (const enumerator of jsonObj.enumerators) {
314
+ if (!isObject(enumerator))
315
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an invalid 'enumerators' attribute. It should be of type 'object[]'.`);
316
+ if (undefined === enumerator.value)
317
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an enumerator that is missing the required attribute 'value'.`);
318
+ // TODO: Should this really be handled here?
319
+ const expectedType = jsonObj.type;
320
+ const receivedType = (typeof (enumerator.value) === "number") ? "int" : typeof (enumerator.value);
321
+ if (!expectedType.includes(receivedType)) // is receivedType a substring of expectedType? - easiest way to check "int" === "int" | "integer" && "string" === "string"
322
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an incompatible type. It must be "${expectedType}", not "${receivedType}".`);
323
+ if (undefined === enumerator.name)
324
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an enumerator that is missing the required attribute 'name'.`);
325
+ if (typeof (enumerator.name) !== "string")
326
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an enumerator with an invalid 'name' attribute. It should be of type 'string'.`);
327
+ if (undefined !== enumerator.label) {
328
+ if (typeof (enumerator.label) !== "string")
329
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an enumerator with an invalid 'label' attribute. It should be of type 'string'.`);
330
+ }
331
+ if (undefined !== enumerator.description) {
332
+ if (typeof (enumerator.description) !== "string")
333
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an enumerator with an invalid 'description' attribute. It should be of type 'string'.`);
334
+ }
335
+ }
336
+ return jsonObj;
337
+ }
338
+ /**
339
+ * Type checks KindOfQuantity and returns KindOfQuantityProps interface
340
+ * @param jsonObj
341
+ * @returns KindOfQuantityProps
342
+ */
343
+ parseKindOfQuantity(jsonObj) {
344
+ this.checkSchemaItemProps(jsonObj);
345
+ if (undefined === jsonObj.relativeError)
346
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The KindOfQuantity ${this._currentItemFullName} is missing the required 'relativeError' attribute.`);
347
+ if (typeof (jsonObj.relativeError) !== "number")
348
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The KindOfQuantity ${this._currentItemFullName} has an invalid 'relativeError' attribute. It should be of type 'number'.`);
349
+ if (undefined !== jsonObj.presentationUnits) {
350
+ if (!Array.isArray(jsonObj.presentationUnits) && typeof (jsonObj.presentationUnits) !== "string")
351
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The KindOfQuantity ${this._currentItemFullName} has an invalid 'presentationUnits' attribute. It should be of type 'string' or 'string[]'.`);
352
+ }
353
+ if (undefined === jsonObj.persistenceUnit)
354
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The KindOfQuantity ${this._currentItemFullName} is missing the required 'persistenceUnit' attribute.`);
355
+ if (typeof (jsonObj.persistenceUnit) !== "string")
356
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The KindOfQuantity ${this._currentItemFullName} has an invalid 'persistenceUnit' attribute. It should be of type 'string'.`);
357
+ return jsonObj;
358
+ }
359
+ /**
360
+ * Type checks Property Category and returns PropertyCategoryProps interface
361
+ * @param jsonObj
362
+ * @returns PropertyCategoryProps
363
+ */
364
+ parsePropertyCategory(jsonObj) {
365
+ this.checkSchemaItemProps(jsonObj);
366
+ if (undefined !== jsonObj.priority) { // TODO: make required
367
+ if (typeof (jsonObj.priority) !== "number")
368
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The PropertyCategory ${this._currentItemFullName} has an invalid 'priority' attribute. It should be of type 'number'.`);
369
+ }
370
+ return jsonObj;
371
+ }
372
+ /**
373
+ * Type checks unit and returns UnitProps interface
374
+ * @param jsonObj
375
+ * @returns UnitProps
376
+ */
377
+ parseUnit(jsonObj) {
378
+ this.checkSchemaItemProps(jsonObj);
379
+ if (undefined === jsonObj.phenomenon)
380
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Unit ${this._currentItemFullName} does not have the required 'phenomenon' attribute.`);
381
+ if (typeof (jsonObj.phenomenon) !== "string")
382
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Unit ${this._currentItemFullName} has an invalid 'phenomenon' attribute. It should be of type 'string'.`);
383
+ if (undefined === jsonObj.unitSystem)
384
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Unit ${this._currentItemFullName} does not have the required 'unitSystem' attribute.`);
385
+ if (typeof (jsonObj.unitSystem) !== "string")
386
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Unit ${this._currentItemFullName} has an invalid 'unitSystem' attribute. It should be of type 'string'.`);
387
+ if (undefined === jsonObj.definition)
388
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Unit ${this._currentItemFullName} does not have the required 'definition' attribute.`);
389
+ if (typeof (jsonObj.definition) !== "string")
390
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Unit ${this._currentItemFullName} has an invalid 'definition' attribute. It should be of type 'string'.`);
391
+ if (undefined !== jsonObj.numerator) {
392
+ if (typeof (jsonObj.numerator) !== "number")
393
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Unit ${this._currentItemFullName} has an invalid 'numerator' attribute. It should be of type 'number'.`);
394
+ }
395
+ if (undefined !== jsonObj.denominator) {
396
+ if (typeof (jsonObj.denominator) !== "number")
397
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Unit ${this._currentItemFullName} has an invalid 'denominator' attribute. It should be of type 'number'.`);
398
+ }
399
+ if (undefined !== jsonObj.offset) {
400
+ if (typeof (jsonObj.offset) !== "number")
401
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Unit ${this._currentItemFullName} has an invalid 'offset' attribute. It should be of type 'number'.`);
402
+ }
403
+ return jsonObj;
404
+ }
405
+ /**
406
+ * Type checks inverted unit and returns InvertedUnitProps interface
407
+ * @param jsonObj
408
+ * @returns InvertedUnitProps
409
+ */
410
+ parseInvertedUnit(jsonObj) {
411
+ this.checkSchemaItemProps(jsonObj);
412
+ if (undefined === jsonObj.invertsUnit)
413
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The InvertedUnit ${this._currentItemFullName} does not have the required 'invertsUnit' attribute.`);
414
+ if (typeof (jsonObj.invertsUnit) !== "string")
415
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The InvertedUnit ${this._currentItemFullName} has an invalid 'invertsUnit' attribute. It should be of type 'string'.`);
416
+ if (undefined === jsonObj.unitSystem)
417
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The InvertedUnit ${this._currentItemFullName} does not have the required 'unitSystem' attribute.`);
418
+ if (typeof (jsonObj.unitSystem) !== "string")
419
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The InvertedUnit ${this._currentItemFullName} has an invalid 'unitSystem' attribute. It should be of type 'string'.`);
420
+ return jsonObj;
421
+ }
422
+ /**
423
+ * Type checks constant and returns ConstantProps interface
424
+ * @param jsonObj
425
+ * @returns ConstantProps
426
+ */
427
+ parseConstant(jsonObj) {
428
+ this.checkSchemaItemProps(jsonObj);
429
+ if (undefined === jsonObj.phenomenon)
430
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Constant ${this._currentItemFullName} does not have the required 'phenomenon' attribute.`);
431
+ if (typeof (jsonObj.phenomenon) !== "string")
432
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Constant ${this._currentItemFullName} has an invalid 'phenomenon' attribute. It should be of type 'string'.`);
433
+ if (undefined === jsonObj.definition)
434
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Constant ${this._currentItemFullName} does not have the required 'definition' attribute.`);
435
+ if (typeof (jsonObj.definition) !== "string")
436
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Constant ${this._currentItemFullName} has an invalid 'definition' attribute. It should be of type 'string'.`);
437
+ if (undefined !== jsonObj.numerator) {
438
+ if (typeof (jsonObj.numerator) !== "number")
439
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Constant ${this._currentItemFullName} has an invalid 'numerator' attribute. It should be of type 'number'.`);
440
+ }
441
+ if (undefined !== jsonObj.denominator) {
442
+ if (typeof (jsonObj.denominator) !== "number")
443
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Constant ${this._currentItemFullName} has an invalid 'denominator' attribute. It should be of type 'number'.`);
444
+ }
445
+ return jsonObj;
446
+ }
447
+ /**
448
+ * Type checks phenomenon and returns PhenomenonProps interface
449
+ * @param jsonObj
450
+ * @returns PhenomenonProps
451
+ */
452
+ parsePhenomenon(jsonObj) {
453
+ this.checkSchemaItemProps(jsonObj);
454
+ if (undefined === jsonObj.definition)
455
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Phenomenon ${this._currentItemFullName} does not have the required 'definition' attribute.`);
456
+ if (typeof (jsonObj.definition) !== "string")
457
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Phenomenon ${this._currentItemFullName} has an invalid 'definition' attribute. It should be of type 'string'.`);
458
+ return jsonObj;
459
+ }
460
+ /**
461
+ * Type checks format and returns FormatProps interface
462
+ * @param jsonObj
463
+ * @returns FormatProps
464
+ */
465
+ parseFormat(jsonObj) {
466
+ this.checkSchemaItemProps(jsonObj);
467
+ if (undefined === jsonObj.type)
468
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} does not have the required 'type' attribute.`);
469
+ if (typeof (jsonObj.type) !== "string")
470
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'type' attribute. It should be of type 'string'.`);
471
+ if (undefined !== jsonObj.precision && typeof (jsonObj.precision) !== "number")
472
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'precision' attribute. It should be of type 'number'.`);
473
+ if (undefined !== jsonObj.roundFactor && typeof (jsonObj.roundFactor) !== "number")
474
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'roundFactor' attribute. It should be of type 'number'.`);
475
+ if (undefined !== jsonObj.minWidth && typeof (jsonObj.minWidth) !== "number")
476
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'minWidth' attribute. It should be of type 'number'.`);
477
+ if (undefined !== jsonObj.showSignOption && typeof (jsonObj.showSignOption) !== "string")
478
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'showSignOption' attribute. It should be of type 'string'.`);
479
+ if (undefined !== jsonObj.formatTraits) {
480
+ if (!Array.isArray(jsonObj.formatTraits) && typeof (jsonObj.formatTraits) !== "string") // must be either an array of strings or a string
481
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'formatTraits' attribute. It should be of type 'string' or 'string[]'.`);
482
+ }
483
+ if (undefined !== jsonObj.decimalSeparator && typeof (jsonObj.decimalSeparator) !== "string")
484
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'decimalSeparator' attribute. It should be of type 'string'.`);
485
+ if (undefined !== jsonObj.thousandSeparator && typeof (jsonObj.thousandSeparator) !== "string")
486
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'thousandSeparator' attribute. It should be of type 'string'.`);
487
+ if (undefined !== jsonObj.uomSeparator && typeof (jsonObj.uomSeparator) !== "string")
488
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'uomSeparator' attribute. It should be of type 'string'.`);
489
+ if (undefined !== jsonObj.scientificType && typeof (jsonObj.scientificType) !== "string")
490
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'scientificType' attribute. It should be of type 'string'.`);
491
+ if (undefined !== jsonObj.stationOffsetSize && typeof (jsonObj.stationOffsetSize) !== "number")
492
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'stationOffsetSize' attribute. It should be of type 'number'.`);
493
+ if (undefined !== jsonObj.stationSeparator && typeof (jsonObj.stationSeparator) !== "string")
494
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'stationSeparator' attribute. It should be of type 'string'.`);
495
+ if (undefined !== jsonObj.composite) { // optional
496
+ if (!isObject(jsonObj.composite))
497
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'composite' object.`);
498
+ if (undefined !== jsonObj.composite.includeZero && typeof (jsonObj.composite.includeZero) !== "boolean")
499
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has a Composite with an invalid 'includeZero' attribute. It should be of type 'boolean'.`);
500
+ if (undefined !== jsonObj.composite.spacer && typeof (jsonObj.composite.spacer) !== "string")
501
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has a Composite with an invalid 'spacer' attribute. It should be of type 'string'.`);
502
+ // if composite is defined
503
+ if (undefined === jsonObj.composite.units)
504
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'Composite' attribute. It should have 1-4 units.`);
505
+ if (!Array.isArray(jsonObj.composite.units))
506
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has a Composite with an invalid 'units' attribute. It should be of type 'object[]'.`);
507
+ for (let i = 0; i < jsonObj.composite.units.length; i++) {
508
+ if (!isObject(jsonObj.composite.units[i]))
509
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has a Composite with an invalid 'units' attribute. It should be of type 'object[]'.`);
510
+ if (undefined === jsonObj.composite.units[i].name) // required
511
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has a Composite with an invalid 'units' attribute. The object at position ${i} is missing the required 'name' attribute.`);
512
+ if (typeof (jsonObj.composite.units[i].name) !== "string")
513
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has a Composite with an invalid 'units' attribute. The object at position ${i} has an invalid 'name' attribute. It should be of type 'string'.`);
514
+ if (undefined !== jsonObj.composite.units[i].label && typeof (jsonObj.composite.units[i].label) !== "string")
515
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Format ${this._currentItemFullName} has a Composite with an invalid 'units' attribute. The object at position ${i} has an invalid 'label' attribute. It should be of type 'string'.`);
516
+ }
517
+ }
518
+ return jsonObj;
519
+ }
520
+ isValidPropertyType(type) {
521
+ type = type.toLowerCase();
522
+ return (type === "primitiveproperty") ||
523
+ (type === "structproperty") ||
524
+ (type === "primitivearrayproperty") ||
525
+ (type === "structarrayproperty") ||
526
+ (type === "navigationproperty");
527
+ }
528
+ /**
529
+ * Type checks property and returns PropertyProps interface
530
+ * @param jsonObj
531
+ * @returns PropertyProps
532
+ */
533
+ checkPropertyProps(jsonObj) {
534
+ const propName = jsonObj.name;
535
+ if (undefined !== jsonObj.label && typeof (jsonObj.label) !== "string")
536
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'label' attribute. It should be of type 'string'.`);
537
+ if (undefined !== jsonObj.description && typeof (jsonObj.description) !== "string")
538
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'description' attribute. It should be of type 'string'.`);
539
+ if (undefined !== jsonObj.priority && typeof (jsonObj.priority) !== "number")
540
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'priority' attribute. It should be of type 'number'.`);
541
+ if (undefined !== jsonObj.isReadOnly && typeof (jsonObj.isReadOnly) !== "boolean")
542
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'isReadOnly' attribute. It should be of type 'boolean'.`);
543
+ if (undefined !== jsonObj.category && typeof (jsonObj.category) !== "string")
544
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'category' attribute. It should be of type 'string'.`);
545
+ if (undefined !== jsonObj.kindOfQuantity && typeof (jsonObj.kindOfQuantity) !== "string")
546
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'kindOfQuantity' attribute. It should be of type 'string'.`);
547
+ if (undefined !== jsonObj.inherited && typeof (jsonObj.inherited) !== "boolean")
548
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'inherited' attribute. It should be of type 'boolean'.`);
549
+ if (undefined !== jsonObj.customAttributes && !Array.isArray(jsonObj.customAttributes))
550
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'customAttributes' attribute. It should be of type 'array'.`);
551
+ return jsonObj;
552
+ }
553
+ checkPropertyTypename(jsonObj) {
554
+ const propName = jsonObj.name;
555
+ if (undefined === jsonObj.typeName)
556
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} is missing the required 'typeName' attribute.`);
557
+ if (typeof (jsonObj.typeName) !== "string")
558
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'typeName' attribute. It should be of type 'string'.`);
559
+ }
560
+ checkPropertyMinAndMaxOccurs(jsonObj) {
561
+ const propName = jsonObj.name;
562
+ if (undefined !== jsonObj.minOccurs && typeof (jsonObj.minOccurs) !== "number")
563
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'minOccurs' attribute. It should be of type 'number'.`);
564
+ if (undefined !== jsonObj.maxOccurs && typeof (jsonObj.maxOccurs) !== "number")
565
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'maxOccurs' attribute. It should be of type 'number'.`);
566
+ }
567
+ /**
568
+ * Type checks PrimitiveOrEnumProperty and returns PrimitiveOrEnumPropertyBaseProps interface
569
+ * @param jsonObj
570
+ * @returns PrimitiveOrEnumPropertyBaseProps
571
+ */
572
+ checkPrimitiveOrEnumPropertyBaseProps(jsonObj) {
573
+ this.checkPropertyProps(jsonObj);
574
+ this.checkPropertyTypename(jsonObj);
575
+ const propName = jsonObj.name;
576
+ if (undefined !== jsonObj.minLength && typeof (jsonObj.minLength) !== "number")
577
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'minLength' attribute. It should be of type 'number'.`);
578
+ if (undefined !== jsonObj.maxLength && typeof (jsonObj.maxLength) !== "number")
579
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'maxLength' attribute. It should be of type 'number'.`);
580
+ if (undefined !== jsonObj.minValue && typeof (jsonObj.minValue) !== "number")
581
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'minValue' attribute. It should be of type 'number'.`);
582
+ if (undefined !== jsonObj.maxValue && typeof (jsonObj.maxValue) !== "number")
583
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'maxValue' attribute. It should be of type 'number'.`);
584
+ if (undefined !== jsonObj.extendedTypeName && typeof (jsonObj.extendedTypeName) !== "string")
585
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'extendedTypeName' attribute. It should be of type 'string'.`);
586
+ return jsonObj;
587
+ }
588
+ /**
589
+ * Type checks PrimitiveProperty and returns PrimitivePropertyProps interface
590
+ * @param jsonObj
591
+ * @returns PrimitivePropertyProps
592
+ */
593
+ parsePrimitiveProperty(jsonObj) {
594
+ this.checkPrimitiveOrEnumPropertyBaseProps(jsonObj);
595
+ return jsonObj;
596
+ }
597
+ /**
598
+ * Type checks StructProperty and returns StructPropertyProps interface
599
+ * @param jsonObj
600
+ * @returns StructPropertyProps
601
+ */
602
+ parseStructProperty(jsonObj) {
603
+ this.checkPropertyProps(jsonObj);
604
+ this.checkPropertyTypename(jsonObj);
605
+ return jsonObj;
606
+ }
607
+ /**
608
+ * Type checks PrimitiveArrayProperty and returns PrimitiveArrayPropertyProps interface
609
+ * @param jsonObj
610
+ * @returns PrimitiveArrayPropertyProps
611
+ */
612
+ parsePrimitiveArrayProperty(jsonObj) {
613
+ this.checkPrimitiveOrEnumPropertyBaseProps(jsonObj);
614
+ this.checkPropertyMinAndMaxOccurs(jsonObj);
615
+ return jsonObj;
616
+ }
617
+ /**
618
+ * Type checks StructArrayProperty and returns StructArrayPropertyProps interface
619
+ * @param jsonObj
620
+ * @returns StructArrayPropertyProps
621
+ */
622
+ parseStructArrayProperty(jsonObj) {
623
+ this.checkPropertyProps(jsonObj);
624
+ this.checkPropertyTypename(jsonObj);
625
+ this.checkPropertyMinAndMaxOccurs(jsonObj);
626
+ return jsonObj;
627
+ }
628
+ /**
629
+ * Type checks NavigationProperty and returns NavigationPropertyProps interface
630
+ * @param jsonObj
631
+ * @returns NavigationPropertyProps
632
+ */
633
+ parseNavigationProperty(jsonObj) {
634
+ this.checkPropertyProps(jsonObj);
635
+ const fullname = `${this._currentItemFullName}.${jsonObj.name}`;
636
+ if (undefined === jsonObj.relationshipName)
637
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Navigation Property ${fullname} is missing the required 'relationshipName' property.`);
638
+ if (typeof (jsonObj.relationshipName) !== "string")
639
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Navigation Property ${fullname} has an invalid 'relationshipName' property. It should be of type 'string'.`);
640
+ if (undefined === jsonObj.direction)
641
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Navigation Property ${fullname} is missing the required 'direction' property.`);
642
+ if (typeof (jsonObj.direction) !== "string")
643
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Navigation Property ${fullname} has an invalid 'direction' property. It should be of type 'string'.`);
644
+ return jsonObj;
645
+ }
646
+ getSchemaCustomAttributeProviders() {
647
+ return this.getCustomAttributeProviders(this._rawSchema, "Schema", this._schemaName);
648
+ }
649
+ getClassCustomAttributeProviders(jsonObj) {
650
+ return this.getCustomAttributeProviders(jsonObj, "ECClass", this._currentItemFullName);
651
+ }
652
+ getPropertyCustomAttributeProviders(jsonObj) {
653
+ return this.getCustomAttributeProviders(jsonObj, "ECProperty", `${this._currentItemFullName}.${jsonObj.name}`);
654
+ }
655
+ getRelationshipConstraintCustomAttributeProviders(jsonObj) {
656
+ const sourceCustomAttributes = this.getCustomAttributeProviders(jsonObj.source, "Source Constraint of", this._currentItemFullName);
657
+ const targetCustomAttributes = this.getCustomAttributeProviders(jsonObj.target, "Target Constraint of", this._currentItemFullName);
658
+ return [sourceCustomAttributes, targetCustomAttributes];
659
+ }
660
+ *getCustomAttributeProviders(jsonObj, type, name) {
661
+ if (undefined !== jsonObj.customAttributes) {
662
+ if (!Array.isArray(jsonObj.customAttributes))
663
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ${type} ${name} has an invalid 'customAttributes' attribute. It should be of type 'object[]'.`);
664
+ for (const instance of jsonObj.customAttributes) {
665
+ if (!isObject(instance) || Array.isArray(instance))
666
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ${type} ${name} has an invalid 'customAttributes' attribute. It should be of type 'object[]'.`);
667
+ if (undefined === instance.className)
668
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `A CustomAttribute in ${name}.customAttributes is missing the required 'className' attribute.`);
669
+ if (typeof (instance.className) !== "string")
670
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `A CustomAttribute in ${name}.customAttributes has an invalid 'className' attribute. It should be of type 'string'.`);
671
+ const provider = (_caClass) => {
672
+ return instance;
673
+ };
674
+ const caTuple = [instance.className, provider];
675
+ yield caTuple;
676
+ }
677
+ }
678
+ }
679
+ }
680
+ exports.JsonParser = JsonParser;
681
681
  //# sourceMappingURL=JsonParser.js.map