@itwin/ecschema-metadata 3.5.0-dev.19 → 3.5.0-dev.21

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 +8 -8
@@ -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
+ 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;
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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AAuC,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":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Metadata\n */\n\nimport { DelayedPromiseWithProps } from \"../DelayedPromise\";\nimport { MixinProps } from \"../Deserialization/JsonProps\";\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\nimport { ECClassModifier, SchemaItemType, StrengthDirection } from \"../ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\nimport { LazyLoadedEntityClass } from \"../Interfaces\";\nimport { SchemaItemKey } from \"../SchemaKey\";\nimport { ECClass } from \"./Class\";\nimport { createNavigationProperty, createNavigationPropertySync, EntityClass } from \"./EntityClass\";\nimport { NavigationProperty } from \"./Property\";\nimport { RelationshipClass } from \"./RelationshipClass\";\nimport { Schema } from \"./Schema\";\n\n/**\n * A Typescript class representation of a Mixin.\n * @beta\n */\nexport class Mixin extends ECClass {\n public override readonly schemaItemType!: SchemaItemType.Mixin; // eslint-disable-line\n protected _appliesTo?: LazyLoadedEntityClass;\n\n public get appliesTo(): LazyLoadedEntityClass | undefined {\n return this._appliesTo;\n }\n\n constructor(schema: Schema, name: string) {\n super(schema, name, ECClassModifier.Abstract);\n this.schemaItemType = SchemaItemType.Mixin;\n }\n\n /**\n *\n * @param name\n * @param relationship\n * @param direction\n */\n protected async createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty> {\n return this.addProperty(await createNavigationProperty(this, name, relationship, direction));\n }\n\n protected createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty {\n return this.addProperty(createNavigationPropertySync(this, name, relationship, direction));\n }\n\n /**\n * @alpha Used for schema editing.\n */\n protected setAppliesTo(appliesTo: LazyLoadedEntityClass) {\n this._appliesTo = appliesTo;\n }\n /**\n * Save this Mixin's properties to an object for serializing to JSON.\n * @param standalone Serialization includes only this object (as opposed to the full schema).\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\n */\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): MixinProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n if (undefined !== this.appliesTo) {\n schemaJson.appliesTo = this.appliesTo.fullName;\n }\n return schemaJson;\n }\n\n /** @internal */\n public override async toXml(schemaXml: Document): Promise<Element> {\n const itemElement = await super.toXml(schemaXml);\n\n // When CustomAttributes are added, there must be a check to see if the ECCustomAttributes\n // already exist for this item before creating a new one to apply IsMixin\n const customAttributes = schemaXml.createElement(\"ECCustomAttributes\");\n const isMixinElement = schemaXml.createElement(\"IsMixin\");\n const coreCustomSchema = this.schema.getReferenceSync(\"CoreCustomAttributes\");\n if (undefined !== coreCustomSchema) {\n const xmlns = `CoreCustomAttributes.${coreCustomSchema.schemaKey.version.toString()}`;\n isMixinElement.setAttribute(\"xmlns\", xmlns);\n }\n\n const appliesToElement = schemaXml.createElement(\"AppliesToEntityClass\");\n const appliesTo = await this.appliesTo;\n if (undefined !== appliesTo) {\n const appliesToName = XmlSerializationUtils.createXmlTypedName(this.schema, appliesTo.schema, appliesTo.name);\n appliesToElement.textContent = appliesToName;\n isMixinElement.appendChild(appliesToElement);\n }\n\n customAttributes.appendChild(isMixinElement);\n itemElement.appendChild(customAttributes);\n\n return itemElement;\n }\n\n public override fromJSONSync(mixinProps: MixinProps) {\n super.fromJSONSync(mixinProps);\n const entityClassSchemaItemKey = this.schema.getSchemaItemKey(mixinProps.appliesTo);\n if (!entityClassSchemaItemKey)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the appliesTo ${mixinProps.appliesTo}.`);\n this._appliesTo = new DelayedPromiseWithProps<SchemaItemKey, EntityClass>(entityClassSchemaItemKey,\n async () => {\n const appliesTo = await this.schema.lookupItem<EntityClass>(entityClassSchemaItemKey);\n if (undefined === appliesTo)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the appliesTo ${mixinProps.appliesTo}.`);\n return appliesTo;\n });\n }\n\n public override async fromJSON(mixinProps: MixinProps) {\n this.fromJSONSync(mixinProps);\n }\n\n public async applicableTo(entityClass: EntityClass) {\n if (!this.appliesTo)\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `appliesTo is undefined in the class ${this.fullName}.`);\n\n const appliesTo = await this.appliesTo;\n if (appliesTo === undefined)\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `Unable to locate the appliesTo ${this.appliesTo.fullName}.`);\n\n return appliesTo.is(entityClass);\n }\n}\n/**\n * @internal\n * An abstract class used for schema editing.\n */\nexport abstract class MutableMixin extends Mixin {\n public abstract override setAppliesTo(entityClass: LazyLoadedEntityClass): void;\n public abstract override createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty>;\n public abstract override createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n"]}
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;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,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,56 @@
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, 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
+ }
56
56
  //# sourceMappingURL=OverrideFormat.d.ts.map