@itwin/ecschema-metadata 3.5.0-dev.5 → 3.5.0-dev.8

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,111 +1,111 @@
1
- /** @packageDocumentation
2
- * @module Metadata
3
- */
4
- import { SchemaKeyProps } from "./Deserialization/JsonProps";
5
- import { SchemaMatchType } from "./ECObjects";
6
- /**
7
- * @beta
8
- */
9
- export declare class ECVersion {
10
- private _read;
11
- private _write;
12
- private _minor;
13
- /**
14
- * The constructor will throw an ECObjectsError if any of the parameters below are above the threshold.
15
- * @param read Can support up to 999.
16
- * @param write Can support up to 999.
17
- * @param minor Can support up to 9999999.
18
- *
19
- */
20
- constructor(read?: number, write?: number, minor?: number);
21
- get read(): number;
22
- get write(): number;
23
- get minor(): number;
24
- /**
25
- * Creates a string, in the format 'RR.ww.mm', representing this ECVersion.
26
- * @note The default is to pad with zeroes.
27
- * @param padZeroes If true, the returned string will strictly follow `RR.ww.mm` and add leading zeroes if necessary.
28
- */
29
- toString(padZeroes?: boolean): string;
30
- /**
31
- * Given a valid version string the
32
- * @param versionString A valid version string of the format, 'RR.ww.mm'.
33
- */
34
- static fromString(versionString: string): ECVersion;
35
- /**
36
- * Compares two schema versions.
37
- * @param rhs The schema to compare.
38
- * @return A negative number if this schema version is less than the given version, a positive number if greater, and 0 if are equivalent.
39
- */
40
- compare(rhv: ECVersion): number;
41
- }
42
- /**
43
- * The SchemaKey contains a Schemas name and version.
44
- * @beta
45
- */
46
- export declare class SchemaKey {
47
- private _name;
48
- protected _version: ECVersion;
49
- constructor(name: string, version: ECVersion);
50
- constructor(name: string, readVersion?: number, writeVersion?: number, minorVersion?: number);
51
- get version(): ECVersion;
52
- get name(): string;
53
- get readVersion(): number;
54
- get writeVersion(): number;
55
- get minorVersion(): number;
56
- /**
57
- * Creates a string, in the format 'RR.ww.mm', representing this SchemaKey.
58
- * @note The default is to pad the full name with zeroes.
59
- * @param padZeroes If true, the returned string will strictly follow `Name.RR.ww.mm` and add leading zeroes if necessary.
60
- */
61
- toString(padZeroes?: boolean): string;
62
- static parseString(fullName: string): SchemaKey;
63
- /**
64
- * Compares two schema names, case-insensitive.
65
- * @return True if they match; otherwise, false.
66
- */
67
- compareByName(rhs: SchemaKey | string | undefined): boolean;
68
- /**
69
- * Compares two schema versions.
70
- * @param rhs The schema to compare.
71
- * @return A negative number if this schema version is less than the given version, a positive number if greater, and 0 if are equivalent.
72
- */
73
- compareByVersion(rhs: SchemaKey): number;
74
- /**
75
- *
76
- * @param rhs The SchemaKey to compare with
77
- * @param matchType The match type to use for comparison.
78
- */
79
- matches(rhs: SchemaKey, matchType?: SchemaMatchType): boolean;
80
- /**
81
- * Deserializes a SchemaKeyProps JSON object into a SchemaKey object.
82
- * @param props SchemaKeyProps
83
- * @returns A SchemaKey object.
84
- */
85
- static fromJSON(props: SchemaKeyProps): SchemaKey;
86
- /**
87
- * Save this SchemaKey's properties to an object for serializing to JSON.
88
- */
89
- toJSON(): SchemaKeyProps;
90
- }
91
- /**
92
- * The SchemaItemKey contains a SchemaItem's name and SchemaKey.
93
- * @beta
94
- */
95
- export declare class SchemaItemKey {
96
- private _name;
97
- protected _schemaKey: SchemaKey;
98
- constructor(name: string, schema: SchemaKey);
99
- get schemaKey(): SchemaKey;
100
- get name(): string;
101
- get schemaName(): string;
102
- /** Returns the name in the format, {schemaName}.{name}. */
103
- get fullName(): string;
104
- /**
105
- * Checks whether this SchemaItemKey matches the one provided.
106
- * @param rhs The SchemaItemKey to compare to this.
107
- */
108
- matches(rhs: SchemaItemKey): boolean;
109
- matchesFullName(name: string): boolean;
110
- }
1
+ /** @packageDocumentation
2
+ * @module Metadata
3
+ */
4
+ import { SchemaKeyProps } from "./Deserialization/JsonProps";
5
+ import { SchemaMatchType } from "./ECObjects";
6
+ /**
7
+ * @beta
8
+ */
9
+ export declare class ECVersion {
10
+ private _read;
11
+ private _write;
12
+ private _minor;
13
+ /**
14
+ * The constructor will throw an ECObjectsError if any of the parameters below are above the threshold.
15
+ * @param read Can support up to 999.
16
+ * @param write Can support up to 999.
17
+ * @param minor Can support up to 9999999.
18
+ *
19
+ */
20
+ constructor(read?: number, write?: number, minor?: number);
21
+ get read(): number;
22
+ get write(): number;
23
+ get minor(): number;
24
+ /**
25
+ * Creates a string, in the format 'RR.ww.mm', representing this ECVersion.
26
+ * @note The default is to pad with zeroes.
27
+ * @param padZeroes If true, the returned string will strictly follow `RR.ww.mm` and add leading zeroes if necessary.
28
+ */
29
+ toString(padZeroes?: boolean): string;
30
+ /**
31
+ * Given a valid version string the
32
+ * @param versionString A valid version string of the format, 'RR.ww.mm'.
33
+ */
34
+ static fromString(versionString: string): ECVersion;
35
+ /**
36
+ * Compares two schema versions.
37
+ * @param rhs The schema to compare.
38
+ * @return A negative number if this schema version is less than the given version, a positive number if greater, and 0 if are equivalent.
39
+ */
40
+ compare(rhv: ECVersion): number;
41
+ }
42
+ /**
43
+ * The SchemaKey contains a Schemas name and version.
44
+ * @beta
45
+ */
46
+ export declare class SchemaKey {
47
+ private _name;
48
+ protected _version: ECVersion;
49
+ constructor(name: string, version: ECVersion);
50
+ constructor(name: string, readVersion?: number, writeVersion?: number, minorVersion?: number);
51
+ get version(): ECVersion;
52
+ get name(): string;
53
+ get readVersion(): number;
54
+ get writeVersion(): number;
55
+ get minorVersion(): number;
56
+ /**
57
+ * Creates a string, in the format 'RR.ww.mm', representing this SchemaKey.
58
+ * @note The default is to pad the full name with zeroes.
59
+ * @param padZeroes If true, the returned string will strictly follow `Name.RR.ww.mm` and add leading zeroes if necessary.
60
+ */
61
+ toString(padZeroes?: boolean): string;
62
+ static parseString(fullName: string): SchemaKey;
63
+ /**
64
+ * Compares two schema names, case-insensitive.
65
+ * @return True if they match; otherwise, false.
66
+ */
67
+ compareByName(rhs: SchemaKey | string | undefined): boolean;
68
+ /**
69
+ * Compares two schema versions.
70
+ * @param rhs The schema to compare.
71
+ * @return A negative number if this schema version is less than the given version, a positive number if greater, and 0 if are equivalent.
72
+ */
73
+ compareByVersion(rhs: SchemaKey): number;
74
+ /**
75
+ *
76
+ * @param rhs The SchemaKey to compare with
77
+ * @param matchType The match type to use for comparison.
78
+ */
79
+ matches(rhs: SchemaKey, matchType?: SchemaMatchType): boolean;
80
+ /**
81
+ * Deserializes a SchemaKeyProps JSON object into a SchemaKey object.
82
+ * @param props SchemaKeyProps
83
+ * @returns A SchemaKey object.
84
+ */
85
+ static fromJSON(props: SchemaKeyProps): SchemaKey;
86
+ /**
87
+ * Save this SchemaKey's properties to an object for serializing to JSON.
88
+ */
89
+ toJSON(): SchemaKeyProps;
90
+ }
91
+ /**
92
+ * The SchemaItemKey contains a SchemaItem's name and SchemaKey.
93
+ * @beta
94
+ */
95
+ export declare class SchemaItemKey {
96
+ private _name;
97
+ protected _schemaKey: SchemaKey;
98
+ constructor(name: string, schema: SchemaKey);
99
+ get schemaKey(): SchemaKey;
100
+ get name(): string;
101
+ get schemaName(): string;
102
+ /** Returns the name in the format, {schemaName}.{name}. */
103
+ get fullName(): string;
104
+ /**
105
+ * Checks whether this SchemaItemKey matches the one provided.
106
+ * @param rhs The SchemaItemKey to compare to this.
107
+ */
108
+ matches(rhs: SchemaItemKey): boolean;
109
+ matchesFullName(name: string): boolean;
110
+ }
111
111
  //# sourceMappingURL=SchemaKey.d.ts.map
@@ -1,220 +1,220 @@
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.SchemaItemKey = exports.SchemaKey = exports.ECVersion = void 0;
11
- const ECObjects_1 = require("./ECObjects");
12
- const Exception_1 = require("./Exception");
13
- const ECName_1 = require("./ECName");
14
- /**
15
- * @beta
16
- */
17
- class ECVersion {
18
- /**
19
- * The constructor will throw an ECObjectsError if any of the parameters below are above the threshold.
20
- * @param read Can support up to 999.
21
- * @param write Can support up to 999.
22
- * @param minor Can support up to 9999999.
23
- *
24
- */
25
- constructor(read, write, minor) {
26
- this._read = 0;
27
- this._write = 0;
28
- this._minor = 0;
29
- if (undefined !== read)
30
- this._read = read;
31
- if (undefined !== write)
32
- this._write = write;
33
- if (undefined !== minor)
34
- this._minor = minor;
35
- if (this._read > 999 || this._read < 0 || this._write > 999 || this._write < 0 || this._minor > 9999999 || this._minor < 0)
36
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECVersion);
37
- }
38
- get read() { return this._read; }
39
- get write() { return this._write; }
40
- get minor() { return this._minor; }
41
- /**
42
- * Creates a string, in the format 'RR.ww.mm', representing this ECVersion.
43
- * @note The default is to pad with zeroes.
44
- * @param padZeroes If true, the returned string will strictly follow `RR.ww.mm` and add leading zeroes if necessary.
45
- */
46
- toString(padZeroes = true) {
47
- if (!padZeroes)
48
- return `${this.read}.${this.write}.${this.minor}`;
49
- const padWithZeroes = (num) => {
50
- return (num < 10 ? "0" : "") + num;
51
- };
52
- return `${padWithZeroes(this.read)}.${padWithZeroes(this.write)}.${padWithZeroes(this.minor)}`;
53
- }
54
- /**
55
- * Given a valid version string the
56
- * @param versionString A valid version string of the format, 'RR.ww.mm'.
57
- */
58
- static fromString(versionString) {
59
- const [read, write, minor] = versionString.split(".");
60
- if (!read)
61
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECVersion, `The read version is missing from version string, ${versionString}`);
62
- if (!write)
63
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECVersion, `The write version is missing from version string, ${versionString}`);
64
- if (!minor)
65
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECVersion, `The minor version is missing from version string, ${versionString}`);
66
- return new ECVersion(+read, +write, +minor);
67
- }
68
- /**
69
- * Compares two schema versions.
70
- * @param rhs The schema to compare.
71
- * @return A negative number if this schema version is less than the given version, a positive number if greater, and 0 if are equivalent.
72
- */
73
- compare(rhv) {
74
- if (this.read !== rhv.read)
75
- return this.read - rhv.read;
76
- if (this.write !== rhv.write)
77
- return this.write - rhv.write;
78
- return this.minor - rhv.minor;
79
- }
80
- }
81
- exports.ECVersion = ECVersion;
82
- /**
83
- * The SchemaKey contains a Schemas name and version.
84
- * @beta
85
- */
86
- class SchemaKey {
87
- constructor(name, readOrVersion, writeVersion, minorVersion) {
88
- this._name = new ECName_1.ECName(name);
89
- if (readOrVersion !== undefined && typeof (readOrVersion) !== "number")
90
- this._version = readOrVersion;
91
- else
92
- this._version = new ECVersion(readOrVersion, writeVersion, minorVersion);
93
- }
94
- get version() { return this._version; }
95
- get name() { return this._name.name; }
96
- get readVersion() { return this.version.read; }
97
- get writeVersion() { return this.version.write; }
98
- get minorVersion() { return this.version.minor; }
99
- /**
100
- * Creates a string, in the format 'RR.ww.mm', representing this SchemaKey.
101
- * @note The default is to pad the full name with zeroes.
102
- * @param padZeroes If true, the returned string will strictly follow `Name.RR.ww.mm` and add leading zeroes if necessary.
103
- */
104
- toString(padZeroes = true) { return `${this.name}.${this.version.toString(padZeroes)}`; }
105
- static parseString(fullName) {
106
- const keyPieces = fullName.split(".");
107
- if (keyPieces.length !== 4)
108
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECName);
109
- const schemaName = keyPieces[0];
110
- const readVer = Number(keyPieces[1]);
111
- const writeVer = Number(keyPieces[2]);
112
- const minorVer = Number(keyPieces[3]);
113
- return new SchemaKey(schemaName, new ECVersion(readVer, writeVer, minorVer));
114
- }
115
- /**
116
- * Compares two schema names, case-insensitive.
117
- * @return True if they match; otherwise, false.
118
- */
119
- compareByName(rhs) {
120
- if (undefined === rhs)
121
- return false;
122
- if (typeof (rhs) === "string")
123
- return rhs.toLowerCase() === this.name.toLowerCase();
124
- return rhs.name.toLowerCase() === this.name.toLowerCase();
125
- }
126
- /**
127
- * Compares two schema versions.
128
- * @param rhs The schema to compare.
129
- * @return A negative number if this schema version is less than the given version, a positive number if greater, and 0 if are equivalent.
130
- */
131
- compareByVersion(rhs) {
132
- return this.version.compare(rhs.version);
133
- }
134
- /**
135
- *
136
- * @param rhs The SchemaKey to compare with
137
- * @param matchType The match type to use for comparison.
138
- */
139
- matches(rhs, matchType = ECObjects_1.SchemaMatchType.Identical) {
140
- switch (matchType) {
141
- case ECObjects_1.SchemaMatchType.Identical:
142
- // TODO: if (this.checksum && rhs.checksum)
143
- // TODO: return this.checksum === rhs.checksum;
144
- return this.compareByName(rhs.name) && this.readVersion === rhs.readVersion &&
145
- this.writeVersion === rhs.writeVersion && this.minorVersion === rhs.minorVersion;
146
- case ECObjects_1.SchemaMatchType.Exact:
147
- return this.compareByName(rhs.name) && this.readVersion === rhs.readVersion &&
148
- this.writeVersion === rhs.writeVersion && this.minorVersion === rhs.minorVersion;
149
- case ECObjects_1.SchemaMatchType.LatestReadCompatible:
150
- if (!this.compareByName(rhs.name))
151
- return false;
152
- if (rhs.readVersion !== this.readVersion)
153
- return false;
154
- if (this.writeVersion === rhs.writeVersion)
155
- return this.minorVersion >= rhs.minorVersion;
156
- return this.writeVersion > rhs.writeVersion;
157
- case ECObjects_1.SchemaMatchType.LatestWriteCompatible:
158
- return this.compareByName(rhs.name) && this.readVersion === rhs.readVersion &&
159
- this.writeVersion === rhs.writeVersion && this.minorVersion >= rhs.minorVersion;
160
- case ECObjects_1.SchemaMatchType.Latest:
161
- return this.compareByName(rhs.name);
162
- default:
163
- return false;
164
- }
165
- }
166
- /**
167
- * Deserializes a SchemaKeyProps JSON object into a SchemaKey object.
168
- * @param props SchemaKeyProps
169
- * @returns A SchemaKey object.
170
- */
171
- static fromJSON(props) {
172
- return new SchemaKey(props.name, props.read, props.write, props.minor);
173
- }
174
- /**
175
- * Save this SchemaKey's properties to an object for serializing to JSON.
176
- */
177
- toJSON() {
178
- return {
179
- name: this.name,
180
- read: this.readVersion,
181
- write: this.writeVersion,
182
- minor: this.minorVersion,
183
- };
184
- }
185
- }
186
- exports.SchemaKey = SchemaKey;
187
- /**
188
- * The SchemaItemKey contains a SchemaItem's name and SchemaKey.
189
- * @beta
190
- */
191
- class SchemaItemKey {
192
- constructor(name, schema) {
193
- this._name = new ECName_1.ECName(name);
194
- this._schemaKey = schema;
195
- }
196
- get schemaKey() { return this._schemaKey; }
197
- get name() { return this._name.name; }
198
- get schemaName() { return this.schemaKey.name; }
199
- /** Returns the name in the format, {schemaName}.{name}. */
200
- get fullName() { return `${this.schemaName}.${this.name}`; }
201
- /**
202
- * Checks whether this SchemaItemKey matches the one provided.
203
- * @param rhs The SchemaItemKey to compare to this.
204
- */
205
- // TODO: Need to add a match type
206
- matches(rhs) {
207
- if (rhs.name !== this.name)
208
- return false;
209
- if (!rhs.schemaKey.matches(this.schemaKey, ECObjects_1.SchemaMatchType.Latest))
210
- return false;
211
- return true;
212
- }
213
- matchesFullName(name) {
214
- const schemaVersion = this.schemaKey.version.toString().replace(/\./g, "\\.");
215
- const fullNameRegex = new RegExp(`^${this.schemaName}(\\.${schemaVersion})?[.:]${this.name}$`, "i");
216
- return fullNameRegex.test(name);
217
- }
218
- }
219
- exports.SchemaItemKey = SchemaItemKey;
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.SchemaItemKey = exports.SchemaKey = exports.ECVersion = void 0;
11
+ const ECObjects_1 = require("./ECObjects");
12
+ const Exception_1 = require("./Exception");
13
+ const ECName_1 = require("./ECName");
14
+ /**
15
+ * @beta
16
+ */
17
+ class ECVersion {
18
+ /**
19
+ * The constructor will throw an ECObjectsError if any of the parameters below are above the threshold.
20
+ * @param read Can support up to 999.
21
+ * @param write Can support up to 999.
22
+ * @param minor Can support up to 9999999.
23
+ *
24
+ */
25
+ constructor(read, write, minor) {
26
+ this._read = 0;
27
+ this._write = 0;
28
+ this._minor = 0;
29
+ if (undefined !== read)
30
+ this._read = read;
31
+ if (undefined !== write)
32
+ this._write = write;
33
+ if (undefined !== minor)
34
+ this._minor = minor;
35
+ if (this._read > 999 || this._read < 0 || this._write > 999 || this._write < 0 || this._minor > 9999999 || this._minor < 0)
36
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECVersion);
37
+ }
38
+ get read() { return this._read; }
39
+ get write() { return this._write; }
40
+ get minor() { return this._minor; }
41
+ /**
42
+ * Creates a string, in the format 'RR.ww.mm', representing this ECVersion.
43
+ * @note The default is to pad with zeroes.
44
+ * @param padZeroes If true, the returned string will strictly follow `RR.ww.mm` and add leading zeroes if necessary.
45
+ */
46
+ toString(padZeroes = true) {
47
+ if (!padZeroes)
48
+ return `${this.read}.${this.write}.${this.minor}`;
49
+ const padWithZeroes = (num) => {
50
+ return (num < 10 ? "0" : "") + num;
51
+ };
52
+ return `${padWithZeroes(this.read)}.${padWithZeroes(this.write)}.${padWithZeroes(this.minor)}`;
53
+ }
54
+ /**
55
+ * Given a valid version string the
56
+ * @param versionString A valid version string of the format, 'RR.ww.mm'.
57
+ */
58
+ static fromString(versionString) {
59
+ const [read, write, minor] = versionString.split(".");
60
+ if (!read)
61
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECVersion, `The read version is missing from version string, ${versionString}`);
62
+ if (!write)
63
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECVersion, `The write version is missing from version string, ${versionString}`);
64
+ if (!minor)
65
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECVersion, `The minor version is missing from version string, ${versionString}`);
66
+ return new ECVersion(+read, +write, +minor);
67
+ }
68
+ /**
69
+ * Compares two schema versions.
70
+ * @param rhs The schema to compare.
71
+ * @return A negative number if this schema version is less than the given version, a positive number if greater, and 0 if are equivalent.
72
+ */
73
+ compare(rhv) {
74
+ if (this.read !== rhv.read)
75
+ return this.read - rhv.read;
76
+ if (this.write !== rhv.write)
77
+ return this.write - rhv.write;
78
+ return this.minor - rhv.minor;
79
+ }
80
+ }
81
+ exports.ECVersion = ECVersion;
82
+ /**
83
+ * The SchemaKey contains a Schemas name and version.
84
+ * @beta
85
+ */
86
+ class SchemaKey {
87
+ constructor(name, readOrVersion, writeVersion, minorVersion) {
88
+ this._name = new ECName_1.ECName(name);
89
+ if (readOrVersion !== undefined && typeof (readOrVersion) !== "number")
90
+ this._version = readOrVersion;
91
+ else
92
+ this._version = new ECVersion(readOrVersion, writeVersion, minorVersion);
93
+ }
94
+ get version() { return this._version; }
95
+ get name() { return this._name.name; }
96
+ get readVersion() { return this.version.read; }
97
+ get writeVersion() { return this.version.write; }
98
+ get minorVersion() { return this.version.minor; }
99
+ /**
100
+ * Creates a string, in the format 'RR.ww.mm', representing this SchemaKey.
101
+ * @note The default is to pad the full name with zeroes.
102
+ * @param padZeroes If true, the returned string will strictly follow `Name.RR.ww.mm` and add leading zeroes if necessary.
103
+ */
104
+ toString(padZeroes = true) { return `${this.name}.${this.version.toString(padZeroes)}`; }
105
+ static parseString(fullName) {
106
+ const keyPieces = fullName.split(".");
107
+ if (keyPieces.length !== 4)
108
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECName);
109
+ const schemaName = keyPieces[0];
110
+ const readVer = Number(keyPieces[1]);
111
+ const writeVer = Number(keyPieces[2]);
112
+ const minorVer = Number(keyPieces[3]);
113
+ return new SchemaKey(schemaName, new ECVersion(readVer, writeVer, minorVer));
114
+ }
115
+ /**
116
+ * Compares two schema names, case-insensitive.
117
+ * @return True if they match; otherwise, false.
118
+ */
119
+ compareByName(rhs) {
120
+ if (undefined === rhs)
121
+ return false;
122
+ if (typeof (rhs) === "string")
123
+ return rhs.toLowerCase() === this.name.toLowerCase();
124
+ return rhs.name.toLowerCase() === this.name.toLowerCase();
125
+ }
126
+ /**
127
+ * Compares two schema versions.
128
+ * @param rhs The schema to compare.
129
+ * @return A negative number if this schema version is less than the given version, a positive number if greater, and 0 if are equivalent.
130
+ */
131
+ compareByVersion(rhs) {
132
+ return this.version.compare(rhs.version);
133
+ }
134
+ /**
135
+ *
136
+ * @param rhs The SchemaKey to compare with
137
+ * @param matchType The match type to use for comparison.
138
+ */
139
+ matches(rhs, matchType = ECObjects_1.SchemaMatchType.Identical) {
140
+ switch (matchType) {
141
+ case ECObjects_1.SchemaMatchType.Identical:
142
+ // TODO: if (this.checksum && rhs.checksum)
143
+ // TODO: return this.checksum === rhs.checksum;
144
+ return this.compareByName(rhs.name) && this.readVersion === rhs.readVersion &&
145
+ this.writeVersion === rhs.writeVersion && this.minorVersion === rhs.minorVersion;
146
+ case ECObjects_1.SchemaMatchType.Exact:
147
+ return this.compareByName(rhs.name) && this.readVersion === rhs.readVersion &&
148
+ this.writeVersion === rhs.writeVersion && this.minorVersion === rhs.minorVersion;
149
+ case ECObjects_1.SchemaMatchType.LatestReadCompatible:
150
+ if (!this.compareByName(rhs.name))
151
+ return false;
152
+ if (rhs.readVersion !== this.readVersion)
153
+ return false;
154
+ if (this.writeVersion === rhs.writeVersion)
155
+ return this.minorVersion >= rhs.minorVersion;
156
+ return this.writeVersion > rhs.writeVersion;
157
+ case ECObjects_1.SchemaMatchType.LatestWriteCompatible:
158
+ return this.compareByName(rhs.name) && this.readVersion === rhs.readVersion &&
159
+ this.writeVersion === rhs.writeVersion && this.minorVersion >= rhs.minorVersion;
160
+ case ECObjects_1.SchemaMatchType.Latest:
161
+ return this.compareByName(rhs.name);
162
+ default:
163
+ return false;
164
+ }
165
+ }
166
+ /**
167
+ * Deserializes a SchemaKeyProps JSON object into a SchemaKey object.
168
+ * @param props SchemaKeyProps
169
+ * @returns A SchemaKey object.
170
+ */
171
+ static fromJSON(props) {
172
+ return new SchemaKey(props.name, props.read, props.write, props.minor);
173
+ }
174
+ /**
175
+ * Save this SchemaKey's properties to an object for serializing to JSON.
176
+ */
177
+ toJSON() {
178
+ return {
179
+ name: this.name,
180
+ read: this.readVersion,
181
+ write: this.writeVersion,
182
+ minor: this.minorVersion,
183
+ };
184
+ }
185
+ }
186
+ exports.SchemaKey = SchemaKey;
187
+ /**
188
+ * The SchemaItemKey contains a SchemaItem's name and SchemaKey.
189
+ * @beta
190
+ */
191
+ class SchemaItemKey {
192
+ constructor(name, schema) {
193
+ this._name = new ECName_1.ECName(name);
194
+ this._schemaKey = schema;
195
+ }
196
+ get schemaKey() { return this._schemaKey; }
197
+ get name() { return this._name.name; }
198
+ get schemaName() { return this.schemaKey.name; }
199
+ /** Returns the name in the format, {schemaName}.{name}. */
200
+ get fullName() { return `${this.schemaName}.${this.name}`; }
201
+ /**
202
+ * Checks whether this SchemaItemKey matches the one provided.
203
+ * @param rhs The SchemaItemKey to compare to this.
204
+ */
205
+ // TODO: Need to add a match type
206
+ matches(rhs) {
207
+ if (rhs.name !== this.name)
208
+ return false;
209
+ if (!rhs.schemaKey.matches(this.schemaKey, ECObjects_1.SchemaMatchType.Latest))
210
+ return false;
211
+ return true;
212
+ }
213
+ matchesFullName(name) {
214
+ const schemaVersion = this.schemaKey.version.toString().replace(/\./g, "\\.");
215
+ const fullNameRegex = new RegExp(`^${this.schemaName}(\\.${schemaVersion})?[.:]${this.name}$`, "i");
216
+ return fullNameRegex.test(name);
217
+ }
218
+ }
219
+ exports.SchemaItemKey = SchemaItemKey;
220
220
  //# sourceMappingURL=SchemaKey.js.map