@itwin/ecschema-metadata 4.0.0-dev.10 → 4.0.0-dev.100

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 (133) hide show
  1. package/CHANGELOG.md +51 -1
  2. package/lib/cjs/Constants.d.ts +23 -23
  3. package/lib/cjs/Constants.js +33 -33
  4. package/lib/cjs/Constants.js.map +1 -1
  5. package/lib/cjs/Context.d.ts +139 -139
  6. package/lib/cjs/Context.js +204 -204
  7. package/lib/cjs/DelayedPromise.d.ts +88 -88
  8. package/lib/cjs/DelayedPromise.d.ts.map +1 -1
  9. package/lib/cjs/DelayedPromise.js +91 -91
  10. package/lib/cjs/DelayedPromise.js.map +1 -1
  11. package/lib/cjs/Deserialization/AbstractParser.d.ts +45 -45
  12. package/lib/cjs/Deserialization/AbstractParser.d.ts.map +1 -1
  13. package/lib/cjs/Deserialization/AbstractParser.js +11 -11
  14. package/lib/cjs/Deserialization/AbstractParser.js.map +1 -1
  15. package/lib/cjs/Deserialization/Helper.d.ts +251 -251
  16. package/lib/cjs/Deserialization/Helper.js +843 -843
  17. package/lib/cjs/Deserialization/JsonParser.d.ts +165 -165
  18. package/lib/cjs/Deserialization/JsonParser.d.ts.map +1 -1
  19. package/lib/cjs/Deserialization/JsonParser.js +680 -680
  20. package/lib/cjs/Deserialization/JsonParser.js.map +1 -1
  21. package/lib/cjs/Deserialization/JsonProps.d.ts +268 -282
  22. package/lib/cjs/Deserialization/JsonProps.d.ts.map +1 -1
  23. package/lib/cjs/Deserialization/JsonProps.js +9 -9
  24. package/lib/cjs/Deserialization/JsonProps.js.map +1 -1
  25. package/lib/cjs/Deserialization/SchemaGraphUtil.d.ts +34 -34
  26. package/lib/cjs/Deserialization/SchemaGraphUtil.js +77 -77
  27. package/lib/cjs/Deserialization/XmlParser.d.ts +85 -85
  28. package/lib/cjs/Deserialization/XmlParser.d.ts.map +1 -1
  29. package/lib/cjs/Deserialization/XmlParser.js +973 -973
  30. package/lib/cjs/Deserialization/XmlParser.js.map +1 -1
  31. package/lib/cjs/Deserialization/XmlSerializationUtils.d.ts +54 -54
  32. package/lib/cjs/Deserialization/XmlSerializationUtils.js +174 -174
  33. package/lib/cjs/ECName.d.ts +30 -30
  34. package/lib/cjs/ECName.js +85 -85
  35. package/lib/cjs/ECObjects.d.ts +162 -162
  36. package/lib/cjs/ECObjects.js +453 -453
  37. package/lib/cjs/Exception.d.ts +43 -43
  38. package/lib/cjs/Exception.js +84 -84
  39. package/lib/cjs/Interfaces.d.ts +66 -66
  40. package/lib/cjs/Interfaces.d.ts.map +1 -1
  41. package/lib/cjs/Interfaces.js +9 -9
  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/CustomAttributeClass.d.ts +39 -39
  51. package/lib/cjs/Metadata/CustomAttributeClass.js +68 -68
  52. package/lib/cjs/Metadata/CustomAttributeClass.js.map +1 -1
  53. package/lib/cjs/Metadata/EntityClass.d.ts +77 -77
  54. package/lib/cjs/Metadata/EntityClass.js +230 -230
  55. package/lib/cjs/Metadata/Enumeration.d.ts +86 -86
  56. package/lib/cjs/Metadata/Enumeration.d.ts.map +1 -1
  57. package/lib/cjs/Metadata/Enumeration.js +159 -159
  58. package/lib/cjs/Metadata/Enumeration.js.map +1 -1
  59. package/lib/cjs/Metadata/Format.d.ts +98 -98
  60. package/lib/cjs/Metadata/Format.d.ts.map +1 -1
  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/KindOfQuantity.d.ts +65 -65
  66. package/lib/cjs/Metadata/KindOfQuantity.js +225 -225
  67. package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
  68. package/lib/cjs/Metadata/Mixin.d.ts +54 -54
  69. package/lib/cjs/Metadata/Mixin.js +113 -113
  70. package/lib/cjs/Metadata/Mixin.js.map +1 -1
  71. package/lib/cjs/Metadata/OverrideFormat.d.ts +67 -55
  72. package/lib/cjs/Metadata/OverrideFormat.d.ts.map +1 -1
  73. package/lib/cjs/Metadata/OverrideFormat.js +126 -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/Property.d.ts +197 -197
  78. package/lib/cjs/Metadata/Property.d.ts.map +1 -1
  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.d.ts.map +1 -1
  89. package/lib/cjs/Metadata/Schema.js +520 -520
  90. package/lib/cjs/Metadata/Schema.js.map +1 -1
  91. package/lib/cjs/Metadata/SchemaItem.d.ts +61 -61
  92. package/lib/cjs/Metadata/SchemaItem.js +136 -136
  93. package/lib/cjs/Metadata/Unit.d.ts +76 -76
  94. package/lib/cjs/Metadata/Unit.d.ts.map +1 -1
  95. package/lib/cjs/Metadata/Unit.js +162 -162
  96. package/lib/cjs/Metadata/Unit.js.map +1 -1
  97. package/lib/cjs/Metadata/UnitSystem.d.ts +20 -20
  98. package/lib/cjs/Metadata/UnitSystem.js +29 -29
  99. package/lib/cjs/PropertyTypes.d.ts +49 -49
  100. package/lib/cjs/PropertyTypes.js +91 -91
  101. package/lib/cjs/PropertyTypes.js.map +1 -1
  102. package/lib/cjs/SchemaJsonLocater.d.ts +34 -34
  103. package/lib/cjs/SchemaJsonLocater.d.ts.map +1 -1
  104. package/lib/cjs/SchemaJsonLocater.js +42 -42
  105. package/lib/cjs/SchemaKey.d.ts +110 -110
  106. package/lib/cjs/SchemaKey.js +219 -219
  107. package/lib/cjs/SchemaLoader.d.ts +23 -23
  108. package/lib/cjs/SchemaLoader.js +47 -47
  109. package/lib/cjs/SchemaPartVisitorDelegate.d.ts +274 -274
  110. package/lib/cjs/SchemaPartVisitorDelegate.js +212 -212
  111. package/lib/cjs/UnitConversion/Graph.d.ts +34 -34
  112. package/lib/cjs/UnitConversion/Graph.js +83 -83
  113. package/lib/cjs/UnitConversion/Parser.d.ts +8 -8
  114. package/lib/cjs/UnitConversion/Parser.js +42 -42
  115. package/lib/cjs/UnitConversion/UnitConversion.d.ts +45 -45
  116. package/lib/cjs/UnitConversion/UnitConversion.js +77 -77
  117. package/lib/cjs/UnitConversion/UnitConversion.js.map +1 -1
  118. package/lib/cjs/UnitConversion/UnitConverter.d.ts +39 -39
  119. package/lib/cjs/UnitConversion/UnitConverter.js +116 -116
  120. package/lib/cjs/UnitConversion/UnitTree.d.ts +43 -43
  121. package/lib/cjs/UnitConversion/UnitTree.js +169 -169
  122. package/lib/cjs/UnitProvider/SchemaUnitProvider.d.ts +77 -77
  123. package/lib/cjs/UnitProvider/SchemaUnitProvider.d.ts.map +1 -1
  124. package/lib/cjs/UnitProvider/SchemaUnitProvider.js +234 -236
  125. package/lib/cjs/UnitProvider/SchemaUnitProvider.js.map +1 -1
  126. package/lib/cjs/Validation/SchemaWalker.d.ts +23 -23
  127. package/lib/cjs/Validation/SchemaWalker.js +53 -53
  128. package/lib/cjs/ecschema-metadata.d.ts +51 -51
  129. package/lib/cjs/ecschema-metadata.js +100 -96
  130. package/lib/cjs/ecschema-metadata.js.map +1 -1
  131. package/lib/cjs/utils/SchemaGraph.d.ts +25 -25
  132. package/lib/cjs/utils/SchemaGraph.js +65 -65
  133. package/package.json +13 -14
@@ -1,55 +1,55 @@
1
- /** @packageDocumentation
2
- * @module Metadata
3
- */
4
- import { MixinProps } from "../Deserialization/JsonProps";
5
- import { SchemaItemType, StrengthDirection } from "../ECObjects";
6
- import { LazyLoadedEntityClass } from "../Interfaces";
7
- import { ECClass } from "./Class";
8
- import { EntityClass } from "./EntityClass";
9
- import { NavigationProperty } from "./Property";
10
- import { RelationshipClass } from "./RelationshipClass";
11
- import { Schema } from "./Schema";
12
- /**
13
- * A Typescript class representation of a Mixin.
14
- * @beta
15
- */
16
- export declare class Mixin extends ECClass {
17
- readonly schemaItemType: SchemaItemType.Mixin;
18
- protected _appliesTo?: LazyLoadedEntityClass;
19
- get appliesTo(): LazyLoadedEntityClass | undefined;
20
- constructor(schema: Schema, name: string);
21
- /**
22
- *
23
- * @param name
24
- * @param relationship
25
- * @param direction
26
- */
27
- protected createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty>;
28
- protected createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty;
29
- /**
30
- * @alpha Used for schema editing.
31
- */
32
- protected setAppliesTo(appliesTo: LazyLoadedEntityClass): void;
33
- /**
34
- * Save this Mixin's properties to an object for serializing to JSON.
35
- * @param standalone Serialization includes only this object (as opposed to the full schema).
36
- * @param includeSchemaVersion Include the Schema's version information in the serialized object.
37
- */
38
- toJSON(standalone?: boolean, includeSchemaVersion?: boolean): MixinProps;
39
- /** @internal */
40
- toXml(schemaXml: Document): Promise<Element>;
41
- fromJSONSync(mixinProps: MixinProps): void;
42
- fromJSON(mixinProps: MixinProps): Promise<void>;
43
- applicableTo(entityClass: EntityClass): Promise<boolean>;
44
- }
45
- /**
46
- * @internal
47
- * An abstract class used for schema editing.
48
- */
49
- export declare abstract class MutableMixin extends Mixin {
50
- abstract setAppliesTo(entityClass: LazyLoadedEntityClass): void;
51
- abstract createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty>;
52
- abstract createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty;
53
- abstract setDisplayLabel(displayLabel: string): void;
54
- }
1
+ /** @packageDocumentation
2
+ * @module Metadata
3
+ */
4
+ import { MixinProps } from "../Deserialization/JsonProps";
5
+ import { SchemaItemType, StrengthDirection } from "../ECObjects";
6
+ import { LazyLoadedEntityClass } from "../Interfaces";
7
+ import { ECClass } from "./Class";
8
+ import { EntityClass } from "./EntityClass";
9
+ import { NavigationProperty } from "./Property";
10
+ import { RelationshipClass } from "./RelationshipClass";
11
+ import { Schema } from "./Schema";
12
+ /**
13
+ * A Typescript class representation of a Mixin.
14
+ * @beta
15
+ */
16
+ export declare class Mixin extends ECClass {
17
+ readonly schemaItemType: SchemaItemType.Mixin;
18
+ protected _appliesTo?: LazyLoadedEntityClass;
19
+ get appliesTo(): LazyLoadedEntityClass | undefined;
20
+ constructor(schema: Schema, name: string);
21
+ /**
22
+ *
23
+ * @param name
24
+ * @param relationship
25
+ * @param direction
26
+ */
27
+ protected createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty>;
28
+ protected createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty;
29
+ /**
30
+ * @alpha Used for schema editing.
31
+ */
32
+ protected setAppliesTo(appliesTo: LazyLoadedEntityClass): void;
33
+ /**
34
+ * Save this Mixin's properties to an object for serializing to JSON.
35
+ * @param standalone Serialization includes only this object (as opposed to the full schema).
36
+ * @param includeSchemaVersion Include the Schema's version information in the serialized object.
37
+ */
38
+ toJSON(standalone?: boolean, includeSchemaVersion?: boolean): MixinProps;
39
+ /** @internal */
40
+ toXml(schemaXml: Document): Promise<Element>;
41
+ fromJSONSync(mixinProps: MixinProps): void;
42
+ fromJSON(mixinProps: MixinProps): Promise<void>;
43
+ applicableTo(entityClass: EntityClass): Promise<boolean>;
44
+ }
45
+ /**
46
+ * @internal
47
+ * An abstract class used for schema editing.
48
+ */
49
+ export declare abstract class MutableMixin extends Mixin {
50
+ abstract setAppliesTo(entityClass: LazyLoadedEntityClass): void;
51
+ abstract createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty>;
52
+ abstract createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty;
53
+ abstract setDisplayLabel(displayLabel: string): void;
54
+ }
55
55
  //# sourceMappingURL=Mixin.d.ts.map
@@ -1,114 +1,114 @@
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
- /** @packageDocumentation
7
- * @module Metadata
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.MutableMixin = exports.Mixin = void 0;
11
- const DelayedPromise_1 = require("../DelayedPromise");
12
- const XmlSerializationUtils_1 = require("../Deserialization/XmlSerializationUtils");
13
- const ECObjects_1 = require("../ECObjects");
14
- const Exception_1 = require("../Exception");
15
- const Class_1 = require("./Class");
16
- const EntityClass_1 = require("./EntityClass");
17
- /**
18
- * A Typescript class representation of a Mixin.
19
- * @beta
20
- */
21
- class Mixin extends Class_1.ECClass {
22
- constructor(schema, name) {
23
- super(schema, name, ECObjects_1.ECClassModifier.Abstract);
24
- this.schemaItemType = ECObjects_1.SchemaItemType.Mixin;
25
- }
26
- get appliesTo() {
27
- return this._appliesTo;
28
- }
29
- /**
30
- *
31
- * @param name
32
- * @param relationship
33
- * @param direction
34
- */
35
- async createNavigationProperty(name, relationship, direction) {
36
- return this.addProperty(await (0, EntityClass_1.createNavigationProperty)(this, name, relationship, direction));
37
- }
38
- createNavigationPropertySync(name, relationship, direction) {
39
- return this.addProperty((0, EntityClass_1.createNavigationPropertySync)(this, name, relationship, direction));
40
- }
41
- /**
42
- * @alpha Used for schema editing.
43
- */
44
- setAppliesTo(appliesTo) {
45
- this._appliesTo = appliesTo;
46
- }
47
- /**
48
- * Save this Mixin's properties to an object for serializing to JSON.
49
- * @param standalone Serialization includes only this object (as opposed to the full schema).
50
- * @param includeSchemaVersion Include the Schema's version information in the serialized object.
51
- */
52
- toJSON(standalone = false, includeSchemaVersion = false) {
53
- const schemaJson = super.toJSON(standalone, includeSchemaVersion);
54
- if (undefined !== this.appliesTo) {
55
- schemaJson.appliesTo = this.appliesTo.fullName;
56
- }
57
- return schemaJson;
58
- }
59
- /** @internal */
60
- async toXml(schemaXml) {
61
- const itemElement = await super.toXml(schemaXml);
62
- // When CustomAttributes are added, there must be a check to see if the ECCustomAttributes
63
- // already exist for this item before creating a new one to apply IsMixin
64
- const customAttributes = schemaXml.createElement("ECCustomAttributes");
65
- const isMixinElement = schemaXml.createElement("IsMixin");
66
- const coreCustomSchema = this.schema.getReferenceSync("CoreCustomAttributes");
67
- if (undefined !== coreCustomSchema) {
68
- const xmlns = `CoreCustomAttributes.${coreCustomSchema.schemaKey.version.toString()}`;
69
- isMixinElement.setAttribute("xmlns", xmlns);
70
- }
71
- const appliesToElement = schemaXml.createElement("AppliesToEntityClass");
72
- const appliesTo = await this.appliesTo;
73
- if (undefined !== appliesTo) {
74
- const appliesToName = XmlSerializationUtils_1.XmlSerializationUtils.createXmlTypedName(this.schema, appliesTo.schema, appliesTo.name);
75
- appliesToElement.textContent = appliesToName;
76
- isMixinElement.appendChild(appliesToElement);
77
- }
78
- customAttributes.appendChild(isMixinElement);
79
- itemElement.appendChild(customAttributes);
80
- return itemElement;
81
- }
82
- fromJSONSync(mixinProps) {
83
- super.fromJSONSync(mixinProps);
84
- const entityClassSchemaItemKey = this.schema.getSchemaItemKey(mixinProps.appliesTo);
85
- if (!entityClassSchemaItemKey)
86
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `Unable to locate the appliesTo ${mixinProps.appliesTo}.`);
87
- this._appliesTo = new DelayedPromise_1.DelayedPromiseWithProps(entityClassSchemaItemKey, async () => {
88
- const appliesTo = await this.schema.lookupItem(entityClassSchemaItemKey);
89
- if (undefined === appliesTo)
90
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `Unable to locate the appliesTo ${mixinProps.appliesTo}.`);
91
- return appliesTo;
92
- });
93
- }
94
- async fromJSON(mixinProps) {
95
- this.fromJSONSync(mixinProps);
96
- }
97
- async applicableTo(entityClass) {
98
- if (!this.appliesTo)
99
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidType, `appliesTo is undefined in the class ${this.fullName}.`);
100
- const appliesTo = await this.appliesTo;
101
- if (appliesTo === undefined)
102
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidType, `Unable to locate the appliesTo ${this.appliesTo.fullName}.`);
103
- return appliesTo.is(entityClass);
104
- }
105
- }
106
- exports.Mixin = Mixin;
107
- /**
108
- * @internal
109
- * An abstract class used for schema editing.
110
- */
111
- class MutableMixin extends Mixin {
112
- }
113
- exports.MutableMixin = MutableMixin;
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
+ /** @packageDocumentation
7
+ * @module Metadata
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.MutableMixin = exports.Mixin = void 0;
11
+ const DelayedPromise_1 = require("../DelayedPromise");
12
+ const XmlSerializationUtils_1 = require("../Deserialization/XmlSerializationUtils");
13
+ const ECObjects_1 = require("../ECObjects");
14
+ const Exception_1 = require("../Exception");
15
+ const Class_1 = require("./Class");
16
+ const EntityClass_1 = require("./EntityClass");
17
+ /**
18
+ * A Typescript class representation of a Mixin.
19
+ * @beta
20
+ */
21
+ class Mixin extends Class_1.ECClass {
22
+ get appliesTo() {
23
+ return this._appliesTo;
24
+ }
25
+ constructor(schema, name) {
26
+ super(schema, name, ECObjects_1.ECClassModifier.Abstract);
27
+ this.schemaItemType = ECObjects_1.SchemaItemType.Mixin;
28
+ }
29
+ /**
30
+ *
31
+ * @param name
32
+ * @param relationship
33
+ * @param direction
34
+ */
35
+ async createNavigationProperty(name, relationship, direction) {
36
+ return this.addProperty(await (0, EntityClass_1.createNavigationProperty)(this, name, relationship, direction));
37
+ }
38
+ createNavigationPropertySync(name, relationship, direction) {
39
+ return this.addProperty((0, EntityClass_1.createNavigationPropertySync)(this, name, relationship, direction));
40
+ }
41
+ /**
42
+ * @alpha Used for schema editing.
43
+ */
44
+ setAppliesTo(appliesTo) {
45
+ this._appliesTo = appliesTo;
46
+ }
47
+ /**
48
+ * Save this Mixin's properties to an object for serializing to JSON.
49
+ * @param standalone Serialization includes only this object (as opposed to the full schema).
50
+ * @param includeSchemaVersion Include the Schema's version information in the serialized object.
51
+ */
52
+ toJSON(standalone = false, includeSchemaVersion = false) {
53
+ const schemaJson = super.toJSON(standalone, includeSchemaVersion);
54
+ if (undefined !== this.appliesTo) {
55
+ schemaJson.appliesTo = this.appliesTo.fullName;
56
+ }
57
+ return schemaJson;
58
+ }
59
+ /** @internal */
60
+ async toXml(schemaXml) {
61
+ const itemElement = await super.toXml(schemaXml);
62
+ // When CustomAttributes are added, there must be a check to see if the ECCustomAttributes
63
+ // already exist for this item before creating a new one to apply IsMixin
64
+ const customAttributes = schemaXml.createElement("ECCustomAttributes");
65
+ const isMixinElement = schemaXml.createElement("IsMixin");
66
+ const coreCustomSchema = this.schema.getReferenceSync("CoreCustomAttributes");
67
+ if (undefined !== coreCustomSchema) {
68
+ const xmlns = `CoreCustomAttributes.${coreCustomSchema.schemaKey.version.toString()}`;
69
+ isMixinElement.setAttribute("xmlns", xmlns);
70
+ }
71
+ const appliesToElement = schemaXml.createElement("AppliesToEntityClass");
72
+ const appliesTo = await this.appliesTo;
73
+ if (undefined !== appliesTo) {
74
+ const appliesToName = XmlSerializationUtils_1.XmlSerializationUtils.createXmlTypedName(this.schema, appliesTo.schema, appliesTo.name);
75
+ appliesToElement.textContent = appliesToName;
76
+ isMixinElement.appendChild(appliesToElement);
77
+ }
78
+ customAttributes.appendChild(isMixinElement);
79
+ itemElement.appendChild(customAttributes);
80
+ return itemElement;
81
+ }
82
+ fromJSONSync(mixinProps) {
83
+ super.fromJSONSync(mixinProps);
84
+ const entityClassSchemaItemKey = this.schema.getSchemaItemKey(mixinProps.appliesTo);
85
+ if (!entityClassSchemaItemKey)
86
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `Unable to locate the appliesTo ${mixinProps.appliesTo}.`);
87
+ this._appliesTo = new DelayedPromise_1.DelayedPromiseWithProps(entityClassSchemaItemKey, async () => {
88
+ const appliesTo = await this.schema.lookupItem(entityClassSchemaItemKey);
89
+ if (undefined === appliesTo)
90
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `Unable to locate the appliesTo ${mixinProps.appliesTo}.`);
91
+ return appliesTo;
92
+ });
93
+ }
94
+ async fromJSON(mixinProps) {
95
+ this.fromJSONSync(mixinProps);
96
+ }
97
+ async applicableTo(entityClass) {
98
+ if (!this.appliesTo)
99
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidType, `appliesTo is undefined in the class ${this.fullName}.`);
100
+ const appliesTo = await this.appliesTo;
101
+ if (appliesTo === undefined)
102
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidType, `Unable to locate the appliesTo ${this.appliesTo.fullName}.`);
103
+ return appliesTo.is(entityClass);
104
+ }
105
+ }
106
+ exports.Mixin = Mixin;
107
+ /**
108
+ * @internal
109
+ * An abstract class used for schema editing.
110
+ */
111
+ class MutableMixin extends Mixin {
112
+ }
113
+ exports.MutableMixin = MutableMixin;
114
114
  //# sourceMappingURL=Mixin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Mixin.js","sourceRoot":"","sources":["../../../src/Metadata/Mixin.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA4D;AAE5D,oFAAiF;AACjF,4CAAkF;AAClF,4CAA+D;AAG/D,mCAAkC;AAClC,+CAAoG;AAKpG;;;GAGG;AACH,MAAa,KAAM,SAAQ,eAAO;IAQhC,YAAY,MAAc,EAAE,IAAY;QACtC,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,2BAAe,CAAC,QAAQ,CAAC,CAAC;QAC9C,IAAI,CAAC,cAAc,GAAG,0BAAc,CAAC,KAAK,CAAC;IAC7C,CAAC;IAPD,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAOD;;;;;OAKG;IACO,KAAK,CAAC,wBAAwB,CAAC,IAAY,EAAE,YAAwC,EAAE,SAAqC;QACpI,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,IAAA,sCAAwB,EAAC,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC,CAAC;IAC/F,CAAC;IAES,4BAA4B,CAAC,IAAY,EAAE,YAAwC,EAAE,SAAqC;QAClI,OAAO,IAAI,CAAC,WAAW,CAAC,IAAA,0CAA4B,EAAC,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC,CAAC;IAC7F,CAAC;IAED;;OAEG;IACO,YAAY,CAAC,SAAgC;QACrD,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IACD;;;;OAIG;IACa,MAAM,CAAC,aAAsB,KAAK,EAAE,uBAAgC,KAAK;QACvF,MAAM,UAAU,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CAAC;QAEtH,OAAO,SAAS,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC;IACnC,CAAC;CACF;AAtGD,sBAsGC;AACD;;;GAGG;AACH,MAAsB,YAAa,SAAQ,KAAK;CAK/C;AALD,oCAKC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Metadata\r\n */\r\n\r\nimport { DelayedPromiseWithProps } from \"../DelayedPromise\";\r\nimport { MixinProps } from \"../Deserialization/JsonProps\";\r\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\r\nimport { ECClassModifier, SchemaItemType, StrengthDirection } from \"../ECObjects\";\r\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\r\nimport { LazyLoadedEntityClass } from \"../Interfaces\";\r\nimport { SchemaItemKey } from \"../SchemaKey\";\r\nimport { ECClass } from \"./Class\";\r\nimport { createNavigationProperty, createNavigationPropertySync, EntityClass } from \"./EntityClass\";\r\nimport { NavigationProperty } from \"./Property\";\r\nimport { RelationshipClass } from \"./RelationshipClass\";\r\nimport { Schema } from \"./Schema\";\r\n\r\n/**\r\n * A Typescript class representation of a Mixin.\r\n * @beta\r\n */\r\nexport class Mixin extends ECClass {\r\n public override readonly schemaItemType!: SchemaItemType.Mixin; // eslint-disable-line\r\n protected _appliesTo?: LazyLoadedEntityClass;\r\n\r\n public get appliesTo(): LazyLoadedEntityClass | undefined {\r\n return this._appliesTo;\r\n }\r\n\r\n constructor(schema: Schema, name: string) {\r\n super(schema, name, ECClassModifier.Abstract);\r\n this.schemaItemType = SchemaItemType.Mixin;\r\n }\r\n\r\n /**\r\n *\r\n * @param name\r\n * @param relationship\r\n * @param direction\r\n */\r\n protected async createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty> {\r\n return this.addProperty(await createNavigationProperty(this, name, relationship, direction));\r\n }\r\n\r\n protected createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty {\r\n return this.addProperty(createNavigationPropertySync(this, name, relationship, direction));\r\n }\r\n\r\n /**\r\n * @alpha Used for schema editing.\r\n */\r\n protected setAppliesTo(appliesTo: LazyLoadedEntityClass) {\r\n this._appliesTo = appliesTo;\r\n }\r\n /**\r\n * Save this Mixin's properties to an object for serializing to JSON.\r\n * @param standalone Serialization includes only this object (as opposed to the full schema).\r\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\r\n */\r\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): MixinProps {\r\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\r\n if (undefined !== this.appliesTo) {\r\n schemaJson.appliesTo = this.appliesTo.fullName;\r\n }\r\n return schemaJson;\r\n }\r\n\r\n /** @internal */\r\n public override async toXml(schemaXml: Document): Promise<Element> {\r\n const itemElement = await super.toXml(schemaXml);\r\n\r\n // When CustomAttributes are added, there must be a check to see if the ECCustomAttributes\r\n // already exist for this item before creating a new one to apply IsMixin\r\n const customAttributes = schemaXml.createElement(\"ECCustomAttributes\");\r\n const isMixinElement = schemaXml.createElement(\"IsMixin\");\r\n const coreCustomSchema = this.schema.getReferenceSync(\"CoreCustomAttributes\");\r\n if (undefined !== coreCustomSchema) {\r\n const xmlns = `CoreCustomAttributes.${coreCustomSchema.schemaKey.version.toString()}`;\r\n isMixinElement.setAttribute(\"xmlns\", xmlns);\r\n }\r\n\r\n const appliesToElement = schemaXml.createElement(\"AppliesToEntityClass\");\r\n const appliesTo = await this.appliesTo;\r\n if (undefined !== appliesTo) {\r\n const appliesToName = XmlSerializationUtils.createXmlTypedName(this.schema, appliesTo.schema, appliesTo.name);\r\n appliesToElement.textContent = appliesToName;\r\n isMixinElement.appendChild(appliesToElement);\r\n }\r\n\r\n customAttributes.appendChild(isMixinElement);\r\n itemElement.appendChild(customAttributes);\r\n\r\n return itemElement;\r\n }\r\n\r\n public override fromJSONSync(mixinProps: MixinProps) {\r\n super.fromJSONSync(mixinProps);\r\n const entityClassSchemaItemKey = this.schema.getSchemaItemKey(mixinProps.appliesTo);\r\n if (!entityClassSchemaItemKey)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the appliesTo ${mixinProps.appliesTo}.`);\r\n this._appliesTo = new DelayedPromiseWithProps<SchemaItemKey, EntityClass>(entityClassSchemaItemKey,\r\n async () => {\r\n const appliesTo = await this.schema.lookupItem<EntityClass>(entityClassSchemaItemKey);\r\n if (undefined === appliesTo)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the appliesTo ${mixinProps.appliesTo}.`);\r\n return appliesTo;\r\n });\r\n }\r\n\r\n public override async fromJSON(mixinProps: MixinProps) {\r\n this.fromJSONSync(mixinProps);\r\n }\r\n\r\n public async applicableTo(entityClass: EntityClass) {\r\n if (!this.appliesTo)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `appliesTo is undefined in the class ${this.fullName}.`);\r\n\r\n const appliesTo = await this.appliesTo;\r\n if (appliesTo === undefined)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `Unable to locate the appliesTo ${this.appliesTo.fullName}.`);\r\n\r\n return appliesTo.is(entityClass);\r\n }\r\n}\r\n/**\r\n * @internal\r\n * An abstract class used for schema editing.\r\n */\r\nexport abstract class MutableMixin extends Mixin {\r\n public abstract override setAppliesTo(entityClass: LazyLoadedEntityClass): void;\r\n public abstract override createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty>;\r\n public abstract override createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty;\r\n public abstract override setDisplayLabel(displayLabel: string): void;\r\n}\r\n"]}
1
+ {"version":3,"file":"Mixin.js","sourceRoot":"","sources":["../../../src/Metadata/Mixin.ts"],"names":[],"mappings":";AAAA;;;+FAG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AC,CAAC;QACpF,IAAI,CAAC,wBAAwB;YAC3B,MAAM,IAAI,0BAAc,CAAC,2BAAe,CAAC,aAAa,EAAE,kCAAkC,UAAU,CAAC,SAAS,GAAG,CAAC,CAAC;QACrH,IAAI,CAAC,UAAU,GAAG,IAAI,wCAAuB,CAA6B,wBAAwB,EAChG,KAAK,IAAI,EAAE;YACT,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAc,wBAAwB,CAAC,CAAC;YACtF,IAAI,SAAS,KAAK,SAAS;gBACzB,MAAM,IAAI,0BAAc,CAAC,2BAAe,CAAC,aAAa,EAAE,kCAAkC,UAAU,CAAC,SAAS,GAAG,CAAC,CAAC;YACrH,OAAO,SAAS,CAAC;QACnB,CAAC,CAAC,CAAC;IACP,CAAC;IAEe,KAAK,CAAC,QAAQ,CAAC,UAAsB;QACnD,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;IAChC,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,WAAwB;QAChD,IAAI,CAAC,IAAI,CAAC,SAAS;YACjB,MAAM,IAAI,0BAAc,CAAC,2BAAe,CAAC,WAAW,EAAE,uCAAuC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;QAEjH,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC;QACvC,IAAI,SAAS,KAAK,SAAS;YACzB,MAAM,IAAI,0BAAc,CAAC,2BAAe,CAAC,WAAW,EAAE,kCAAkC,IAAI,CAAC,SAAS,CAAC,QAAQ,GAAG,CAAC,CAAC;QAEtH,OAAO,SAAS,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC;IACnC,CAAC;CACF;AAtGD,sBAsGC;AACD;;;GAGG;AACH,MAAsB,YAAa,SAAQ,KAAK;CAK/C;AALD,oCAKC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Metadata\r\n */\r\n\r\nimport { DelayedPromiseWithProps } from \"../DelayedPromise\";\r\nimport { MixinProps } from \"../Deserialization/JsonProps\";\r\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\r\nimport { ECClassModifier, SchemaItemType, StrengthDirection } from \"../ECObjects\";\r\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\r\nimport { LazyLoadedEntityClass } from \"../Interfaces\";\r\nimport { SchemaItemKey } from \"../SchemaKey\";\r\nimport { ECClass } from \"./Class\";\r\nimport { createNavigationProperty, createNavigationPropertySync, EntityClass } from \"./EntityClass\";\r\nimport { NavigationProperty } from \"./Property\";\r\nimport { RelationshipClass } from \"./RelationshipClass\";\r\nimport { Schema } from \"./Schema\";\r\n\r\n/**\r\n * A Typescript class representation of a Mixin.\r\n * @beta\r\n */\r\nexport class Mixin extends ECClass {\r\n public override readonly schemaItemType!: SchemaItemType.Mixin; // eslint-disable-line\r\n protected _appliesTo?: LazyLoadedEntityClass;\r\n\r\n public get appliesTo(): LazyLoadedEntityClass | undefined {\r\n return this._appliesTo;\r\n }\r\n\r\n constructor(schema: Schema, name: string) {\r\n super(schema, name, ECClassModifier.Abstract);\r\n this.schemaItemType = SchemaItemType.Mixin;\r\n }\r\n\r\n /**\r\n *\r\n * @param name\r\n * @param relationship\r\n * @param direction\r\n */\r\n protected async createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty> {\r\n return this.addProperty(await createNavigationProperty(this, name, relationship, direction));\r\n }\r\n\r\n protected createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty {\r\n return this.addProperty(createNavigationPropertySync(this, name, relationship, direction));\r\n }\r\n\r\n /**\r\n * @alpha Used for schema editing.\r\n */\r\n protected setAppliesTo(appliesTo: LazyLoadedEntityClass) {\r\n this._appliesTo = appliesTo;\r\n }\r\n /**\r\n * Save this Mixin's properties to an object for serializing to JSON.\r\n * @param standalone Serialization includes only this object (as opposed to the full schema).\r\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\r\n */\r\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): MixinProps {\r\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\r\n if (undefined !== this.appliesTo) {\r\n schemaJson.appliesTo = this.appliesTo.fullName;\r\n }\r\n return schemaJson;\r\n }\r\n\r\n /** @internal */\r\n public override async toXml(schemaXml: Document): Promise<Element> {\r\n const itemElement = await super.toXml(schemaXml);\r\n\r\n // When CustomAttributes are added, there must be a check to see if the ECCustomAttributes\r\n // already exist for this item before creating a new one to apply IsMixin\r\n const customAttributes = schemaXml.createElement(\"ECCustomAttributes\");\r\n const isMixinElement = schemaXml.createElement(\"IsMixin\");\r\n const coreCustomSchema = this.schema.getReferenceSync(\"CoreCustomAttributes\");\r\n if (undefined !== coreCustomSchema) {\r\n const xmlns = `CoreCustomAttributes.${coreCustomSchema.schemaKey.version.toString()}`;\r\n isMixinElement.setAttribute(\"xmlns\", xmlns);\r\n }\r\n\r\n const appliesToElement = schemaXml.createElement(\"AppliesToEntityClass\");\r\n const appliesTo = await this.appliesTo;\r\n if (undefined !== appliesTo) {\r\n const appliesToName = XmlSerializationUtils.createXmlTypedName(this.schema, appliesTo.schema, appliesTo.name);\r\n appliesToElement.textContent = appliesToName;\r\n isMixinElement.appendChild(appliesToElement);\r\n }\r\n\r\n customAttributes.appendChild(isMixinElement);\r\n itemElement.appendChild(customAttributes);\r\n\r\n return itemElement;\r\n }\r\n\r\n public override fromJSONSync(mixinProps: MixinProps) {\r\n super.fromJSONSync(mixinProps);\r\n const entityClassSchemaItemKey = this.schema.getSchemaItemKey(mixinProps.appliesTo);\r\n if (!entityClassSchemaItemKey)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the appliesTo ${mixinProps.appliesTo}.`);\r\n this._appliesTo = new DelayedPromiseWithProps<SchemaItemKey, EntityClass>(entityClassSchemaItemKey,\r\n async () => {\r\n const appliesTo = await this.schema.lookupItem<EntityClass>(entityClassSchemaItemKey);\r\n if (undefined === appliesTo)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the appliesTo ${mixinProps.appliesTo}.`);\r\n return appliesTo;\r\n });\r\n }\r\n\r\n public override async fromJSON(mixinProps: MixinProps) {\r\n this.fromJSONSync(mixinProps);\r\n }\r\n\r\n public async applicableTo(entityClass: EntityClass) {\r\n if (!this.appliesTo)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `appliesTo is undefined in the class ${this.fullName}.`);\r\n\r\n const appliesTo = await this.appliesTo;\r\n if (appliesTo === undefined)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `Unable to locate the appliesTo ${this.appliesTo.fullName}.`);\r\n\r\n return appliesTo.is(entityClass);\r\n }\r\n}\r\n/**\r\n * @internal\r\n * An abstract class used for schema editing.\r\n */\r\nexport abstract class MutableMixin extends Mixin {\r\n public abstract override setAppliesTo(entityClass: LazyLoadedEntityClass): void;\r\n public abstract override createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty>;\r\n public abstract override createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty;\r\n public abstract override setDisplayLabel(displayLabel: string): void;\r\n}\r\n"]}
@@ -1,56 +1,68 @@
1
- /** @packageDocumentation
2
- * @module Metadata
3
- */
4
- import { DecimalPrecision, FormatTraits, FormatType, FractionalPrecision, ScientificType, ShowSignOption } from "@itwin/core-quantity";
5
- import { Format } from "./Format";
6
- import { InvertedUnit } from "./InvertedUnit";
7
- import { Schema } from "./Schema";
8
- import { Unit } from "./Unit";
9
- /**
10
- * Overrides of a Format, from a Schema, and is SchemaItem that is used specifically on KindOfQuantity.
11
- * @beta
12
- */
13
- export declare class OverrideFormat {
14
- private _precision?;
15
- private _units?;
16
- /** The Format that this OverrideFormat is extending */
17
- readonly parent: Format;
18
- /** The name of this OverrideFormat.
19
- *
20
- * This should be set to the [FormatString]($docs/bis/ec/kindofquantity/#format-string) which represents the format override.
21
- */
22
- readonly name: string;
23
- constructor(parent: Format, precision?: DecimalPrecision | FractionalPrecision, unitAndLabels?: Array<[Unit | InvertedUnit, string | undefined]>);
24
- get precision(): DecimalPrecision | FractionalPrecision;
25
- get units(): [Unit | InvertedUnit, string | undefined][] | undefined;
26
- get fullName(): string;
27
- get roundFactor(): number;
28
- get type(): FormatType;
29
- get minWidth(): number | undefined;
30
- get scientificType(): ScientificType | undefined;
31
- get showSignOption(): ShowSignOption;
32
- get decimalSeparator(): string;
33
- get thousandSeparator(): string;
34
- get uomSeparator(): string;
35
- get stationSeparator(): string;
36
- get stationOffsetSize(): number | undefined;
37
- get formatTraits(): FormatTraits;
38
- get spacer(): string | undefined;
39
- get includeZero(): boolean | undefined;
40
- hasFormatTrait(formatTrait: FormatTraits): boolean;
41
- /** Returns the format string of this override in the Xml full name format.
42
- * @alpha
43
- */
44
- fullNameXml(koqSchema: Schema): string;
45
- /**
46
- * Creates a valid OverrideFormat fullName from the parent Format and overridden units.
47
- * @param parent The parent Format.
48
- * @param unitAndLabels The overridden unit and labels collection.
49
- */
50
- static createOverrideFormatFullName(parent: Format, precision?: DecimalPrecision | FractionalPrecision, unitAndLabels?: Array<[Unit | InvertedUnit, string | undefined]>): string;
51
- /**
52
- * @internal
53
- */
54
- static isOverrideFormat(object: any): object is OverrideFormat;
55
- }
1
+ /** @packageDocumentation
2
+ * @module Metadata
3
+ */
4
+ import { DecimalPrecision, FormatProps, FormatTraits, FormatType, FractionalPrecision, ScientificType, ShowSignOption } from "@itwin/core-quantity";
5
+ import { Format } from "./Format";
6
+ import { InvertedUnit } from "./InvertedUnit";
7
+ import { Schema } from "./Schema";
8
+ import { SchemaItemOverrideFormatProps } from "../Deserialization/JsonProps";
9
+ import { Unit } from "./Unit";
10
+ /**
11
+ * Overrides of a Format, from a Schema, and is SchemaItem that is used specifically on KindOfQuantity.
12
+ * @beta
13
+ */
14
+ export declare class OverrideFormat {
15
+ private _precision?;
16
+ private _units?;
17
+ /** The Format that this OverrideFormat is extending */
18
+ readonly parent: Format;
19
+ /** The name of this OverrideFormat.
20
+ *
21
+ * This should be set to the [FormatString]($docs/bis/ec/kindofquantity/#format-string) which represents the format override.
22
+ */
23
+ readonly name: string;
24
+ constructor(parent: Format, precision?: DecimalPrecision | FractionalPrecision, unitAndLabels?: Array<[Unit | InvertedUnit, string | undefined]>);
25
+ get precision(): DecimalPrecision | FractionalPrecision;
26
+ get units(): [Unit | InvertedUnit, string | undefined][] | undefined;
27
+ get fullName(): string;
28
+ get roundFactor(): number;
29
+ get type(): FormatType;
30
+ get minWidth(): number | undefined;
31
+ get scientificType(): ScientificType | undefined;
32
+ get showSignOption(): ShowSignOption;
33
+ get decimalSeparator(): string;
34
+ get thousandSeparator(): string;
35
+ get uomSeparator(): string;
36
+ get stationSeparator(): string;
37
+ get stationOffsetSize(): number | undefined;
38
+ get formatTraits(): FormatTraits;
39
+ get spacer(): string | undefined;
40
+ get includeZero(): boolean | undefined;
41
+ hasFormatTrait(formatTrait: FormatTraits): boolean;
42
+ /** Returns the format string of this override in the Xml full name format.
43
+ * @alpha
44
+ */
45
+ fullNameXml(koqSchema: Schema): string;
46
+ /**
47
+ * Creates a valid OverrideFormat fullName from the parent Format and overridden units.
48
+ * @param parent The parent Format.
49
+ * @param unitAndLabels The overridden unit and labels collection.
50
+ */
51
+ static createOverrideFormatFullName(parent: Format, precision?: DecimalPrecision | FractionalPrecision, unitAndLabels?: Array<[Unit | InvertedUnit, string | undefined]>): string;
52
+ /**
53
+ * @internal
54
+ */
55
+ static isOverrideFormat(object: any): object is OverrideFormat;
56
+ /**
57
+ * Returns a JSON object that contains the specification for the OverrideFormat where the precision and units properties have been overriden.
58
+ * If the precision and/or units properties have been overriden, the returned object will contain a "name" and a "parent" property.
59
+ * The "name" property identifies the OverrideFormat object itself and the "parent" property identifies the Format that has been overriden.
60
+ * This method is not intended for complete serialization as it does not serialize any of the schema item properties.
61
+ */
62
+ getFormatProps(): SchemaItemOverrideFormatProps;
63
+ }
64
+ /**
65
+ * @internal
66
+ */
67
+ export declare function getFormatProps(format: Format | OverrideFormat): FormatProps;
56
68
  //# sourceMappingURL=OverrideFormat.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"OverrideFormat.d.ts","sourceRoot":"","sources":["../../../src/Metadata/OverrideFormat.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,UAAU,EAAE,mBAAmB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACvI,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B;;;GAGG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,UAAU,CAAC,CAAyC;IAC5D,OAAO,CAAC,MAAM,CAAC,CAAmD;IAElE,uDAAuD;IACvD,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B;;;OAGG;IACH,SAAgB,IAAI,EAAE,MAAM,CAAC;gBAEjB,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,gBAAgB,GAAG,mBAAmB,EAAE,aAAa,CAAC,EAAE,KAAK,CAAC,CAAC,IAAI,GAAG,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IAQhJ,IAAW,SAAS,IAAI,gBAAgB,GAAG,mBAAmB,CAAsF;IACpJ,IAAW,KAAK,4DAA4E;IAG5F,IAAW,QAAQ,IAAI,MAAM,CAAsB;IACnD,IAAW,WAAW,IAAI,MAAM,CAAoC;IACpE,IAAW,IAAI,IAAI,UAAU,CAA6B;IAC1D,IAA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