@twin.org/core 0.0.2-next.20 → 0.0.2-next.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 (34) hide show
  1. package/dist/cjs/index.cjs +107 -76
  2. package/dist/esm/index.mjs +107 -76
  3. package/dist/types/encoding/base32.d.ts +4 -0
  4. package/dist/types/encoding/base58.d.ts +4 -0
  5. package/dist/types/encoding/base64.d.ts +4 -0
  6. package/dist/types/encoding/base64Url.d.ts +4 -0
  7. package/dist/types/factories/factory.d.ts +4 -0
  8. package/dist/types/helpers/jsonHelper.d.ts +4 -0
  9. package/dist/types/helpers/objectHelper.d.ts +4 -0
  10. package/dist/types/models/IComponent.d.ts +4 -2
  11. package/dist/types/models/IValidationFailure.d.ts +0 -4
  12. package/dist/types/types/bitString.d.ts +4 -0
  13. package/dist/types/types/url.d.ts +6 -1
  14. package/dist/types/types/urn.d.ts +6 -1
  15. package/dist/types/utils/compression.d.ts +4 -0
  16. package/dist/types/utils/i18n.d.ts +15 -0
  17. package/docs/changelog.md +17 -0
  18. package/docs/reference/classes/Base32.md +8 -0
  19. package/docs/reference/classes/Base58.md +8 -0
  20. package/docs/reference/classes/Base64.md +8 -0
  21. package/docs/reference/classes/Base64Url.md +8 -0
  22. package/docs/reference/classes/BitString.md +8 -0
  23. package/docs/reference/classes/Compression.md +8 -0
  24. package/docs/reference/classes/Factory.md +8 -0
  25. package/docs/reference/classes/I18n.md +52 -0
  26. package/docs/reference/classes/JsonHelper.md +8 -0
  27. package/docs/reference/classes/ObjectHelper.md +8 -0
  28. package/docs/reference/classes/Url.md +15 -1
  29. package/docs/reference/classes/Urn.md +15 -1
  30. package/docs/reference/interfaces/IComponent.md +5 -5
  31. package/docs/reference/interfaces/IValidationFailure.md +0 -8
  32. package/locales/.validate-ignore +1 -0
  33. package/locales/en.json +4 -5
  34. package/package.json +7 -3
@@ -329,6 +329,8 @@ class Is {
329
329
  * @returns True if the value is a Uint8Array.
330
330
  */
331
331
  static uint8Array(value) {
332
+ // This is the only way we can reliably check for Uint8Array
333
+ // eslint-disable-next-line no-restricted-syntax
332
334
  return value instanceof Uint8Array;
333
335
  }
334
336
  /**
@@ -337,6 +339,8 @@ class Is {
337
339
  * @returns True if the value is a TypedArray.
338
340
  */
339
341
  static typedArray(value) {
342
+ // This is the only way we can reliably check for TypedArray
343
+ // eslint-disable-next-line no-restricted-syntax
340
344
  return value instanceof Object.getPrototypeOf(Uint8Array);
341
345
  }
342
346
  /**
@@ -363,6 +367,8 @@ class Is {
363
367
  * @returns True if the value is a promise.
364
368
  */
365
369
  static promise(value) {
370
+ // This is the only way we can reliably check for Promise
371
+ // eslint-disable-next-line no-restricted-syntax
366
372
  return value instanceof Promise;
367
373
  }
368
374
  /**
@@ -371,6 +377,8 @@ class Is {
371
377
  * @returns True if the value is a regexp.
372
378
  */
373
379
  static regexp(value) {
380
+ // This is the only way we can reliably check for RegExp
381
+ // eslint-disable-next-line no-restricted-syntax
374
382
  return value instanceof RegExp;
375
383
  }
376
384
  /**
@@ -838,6 +846,8 @@ class BaseError extends Error {
838
846
  * @returns True if the error is an aggregate error.
839
847
  */
840
848
  static isAggregateError(err) {
849
+ // This is the only way we can reliably check for AggregateError
850
+ // eslint-disable-next-line no-restricted-syntax
841
851
  return err instanceof AggregateError;
842
852
  }
843
853
  /**
@@ -1035,7 +1045,7 @@ class Guards {
1035
1045
  */
1036
1046
  static stringBase64(source, property, value) {
1037
1047
  if (!Is.stringBase64(value)) {
1038
- throw new GuardError(source, "guard.base64", property, value);
1048
+ throw new GuardError(source, "guard.stringBase64", property, value);
1039
1049
  }
1040
1050
  }
1041
1051
  /**
@@ -1047,7 +1057,7 @@ class Guards {
1047
1057
  */
1048
1058
  static stringBase64Url(source, property, value) {
1049
1059
  if (!Is.stringBase64Url(value)) {
1050
- throw new GuardError(source, "guard.base64Url", property, value);
1060
+ throw new GuardError(source, "guard.stringBase64Url", property, value);
1051
1061
  }
1052
1062
  }
1053
1063
  /**
@@ -1059,7 +1069,7 @@ class Guards {
1059
1069
  */
1060
1070
  static stringBase58(source, property, value) {
1061
1071
  if (!Is.stringBase58(value)) {
1062
- throw new GuardError(source, "guard.base58", property, value);
1072
+ throw new GuardError(source, "guard.stringBase58", property, value);
1063
1073
  }
1064
1074
  }
1065
1075
  /**
@@ -1344,9 +1354,8 @@ class Guards {
1344
1354
  class Base32 {
1345
1355
  /**
1346
1356
  * Runtime name for the class.
1347
- * @internal
1348
1357
  */
1349
- static _CLASS_NAME = "Base32";
1358
+ static CLASS_NAME = "Base32";
1350
1359
  /**
1351
1360
  * Alphabet table for encoding.
1352
1361
  * @internal
@@ -1359,7 +1368,7 @@ class Base32 {
1359
1368
  * @throws If the input string contains a character not in the Base32 alphabet.
1360
1369
  */
1361
1370
  static decode(base32) {
1362
- Guards.string(Base32._CLASS_NAME, "base32", base32);
1371
+ Guards.string(Base32.CLASS_NAME, "base32", base32);
1363
1372
  let bits = 0;
1364
1373
  let value = 0;
1365
1374
  base32 = base32.replace(/=+$/, "");
@@ -1368,7 +1377,7 @@ class Base32 {
1368
1377
  for (let i = 0; i < base32.length; i++) {
1369
1378
  const idx = Base32._ALPHABET.indexOf(base32[i]);
1370
1379
  if (idx === -1) {
1371
- throw new GeneralError(Base32._CLASS_NAME, "invalidCharacter", {
1380
+ throw new GeneralError(Base32.CLASS_NAME, "invalidCharacter", {
1372
1381
  invalidCharacter: base32[i]
1373
1382
  });
1374
1383
  }
@@ -1387,7 +1396,7 @@ class Base32 {
1387
1396
  * @returns The data as base32 string.
1388
1397
  */
1389
1398
  static encode(bytes) {
1390
- Guards.uint8Array(Base32._CLASS_NAME, "bytes", bytes);
1399
+ Guards.uint8Array(Base32.CLASS_NAME, "bytes", bytes);
1391
1400
  let bits = 0;
1392
1401
  let value = 0;
1393
1402
  let output = "";
@@ -1415,9 +1424,8 @@ class Base32 {
1415
1424
  class Base58 {
1416
1425
  /**
1417
1426
  * Runtime name for the class.
1418
- * @internal
1419
1427
  */
1420
- static _CLASS_NAME = "Base58";
1428
+ static CLASS_NAME = "Base58";
1421
1429
  /**
1422
1430
  * Alphabet table for encoding.
1423
1431
  * @internal
@@ -1444,7 +1452,7 @@ class Base58 {
1444
1452
  * @throws If the input string contains a character not in the Base58 alphabet.
1445
1453
  */
1446
1454
  static decode(base58) {
1447
- Guards.string(Base58._CLASS_NAME, "base58", base58);
1455
+ Guards.string(Base58.CLASS_NAME, "base58", base58);
1448
1456
  let zeroes = 0;
1449
1457
  for (let i = 0; i < base58.length; i++) {
1450
1458
  if (base58[i] !== "1") {
@@ -1458,11 +1466,11 @@ class Base58 {
1458
1466
  for (let i = zeroes; i < base58.length; i++) {
1459
1467
  const ch = base58.charCodeAt(i);
1460
1468
  if (ch & 0xff80) {
1461
- throw new GeneralError(Base58._CLASS_NAME, "invalidCharacter", { invalidCharacter: ch });
1469
+ throw new GeneralError(Base58.CLASS_NAME, "invalidCharacter", { invalidCharacter: ch });
1462
1470
  }
1463
1471
  const val = Base58._ALPHABET_REVERSE[ch];
1464
1472
  if (val === -1) {
1465
- throw new GeneralError(Base58._CLASS_NAME, "invalidCharacter", { invalidCharacter: ch });
1473
+ throw new GeneralError(Base58.CLASS_NAME, "invalidCharacter", { invalidCharacter: ch });
1466
1474
  }
1467
1475
  let carry = val;
1468
1476
  let j = 0;
@@ -1493,7 +1501,7 @@ class Base58 {
1493
1501
  * @returns The data as base58 string.
1494
1502
  */
1495
1503
  static encode(bytes) {
1496
- Guards.uint8Array(Base58._CLASS_NAME, "bytes", bytes);
1504
+ Guards.uint8Array(Base58.CLASS_NAME, "bytes", bytes);
1497
1505
  let zeroes = 0;
1498
1506
  for (let i = 0; i < bytes.length; i++) {
1499
1507
  if (bytes[i] !== 0) {
@@ -1543,9 +1551,8 @@ class Base58 {
1543
1551
  class Base64 {
1544
1552
  /**
1545
1553
  * Runtime name for the class.
1546
- * @internal
1547
1554
  */
1548
- static _CLASS_NAME = "Base64";
1555
+ static CLASS_NAME = "Base64";
1549
1556
  /**
1550
1557
  * Alphabet table for encoding.
1551
1558
  * @internal
@@ -1638,7 +1645,7 @@ class Base64 {
1638
1645
  * @returns The byte array.
1639
1646
  */
1640
1647
  static decode(base64) {
1641
- Guards.string(Base64._CLASS_NAME, "base64", base64);
1648
+ Guards.string(Base64.CLASS_NAME, "base64", base64);
1642
1649
  let tmp;
1643
1650
  const lens = Base64.getLengths(base64);
1644
1651
  const validLen = lens[0];
@@ -1680,7 +1687,7 @@ class Base64 {
1680
1687
  * @returns The data as base64 string.
1681
1688
  */
1682
1689
  static encode(bytes) {
1683
- Guards.uint8Array(Base64._CLASS_NAME, "bytes", bytes);
1690
+ Guards.uint8Array(Base64.CLASS_NAME, "bytes", bytes);
1684
1691
  let tmp;
1685
1692
  const len = bytes.length;
1686
1693
  const extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes
@@ -1720,7 +1727,7 @@ class Base64 {
1720
1727
  static getLengths(base64) {
1721
1728
  const len = base64.length;
1722
1729
  if (len % 4 > 0) {
1723
- throw new GeneralError(Base64._CLASS_NAME, "length4Multiple", { value: len });
1730
+ throw new GeneralError(Base64.CLASS_NAME, "length4Multiple", { value: len });
1724
1731
  }
1725
1732
  // Trim off extra bytes after placeholder bytes are found
1726
1733
  // See: https://github.com/beatgammit/base64-js/issues/42
@@ -1769,16 +1776,15 @@ class Base64 {
1769
1776
  class Base64Url {
1770
1777
  /**
1771
1778
  * Runtime name for the class.
1772
- * @internal
1773
1779
  */
1774
- static _CLASS_NAME = "Base64";
1780
+ static CLASS_NAME = "Base64";
1775
1781
  /**
1776
1782
  * Convert the base 64 string to a byte array.
1777
1783
  * @param base64Url The base64 url string to convert.
1778
1784
  * @returns The byte array.
1779
1785
  */
1780
1786
  static decode(base64Url) {
1781
- Guards.string(Base64Url._CLASS_NAME, "base64Url", base64Url);
1787
+ Guards.string(Base64Url.CLASS_NAME, "base64Url", base64Url);
1782
1788
  let base64 = base64Url;
1783
1789
  // Base 64 url can have padding removed, so add it back if it is missing.
1784
1790
  if (base64.length > 0 && !base64.endsWith("=")) {
@@ -1796,7 +1802,7 @@ class Base64Url {
1796
1802
  * @returns The data as base64 url string.
1797
1803
  */
1798
1804
  static encode(bytes) {
1799
- Guards.uint8Array(Base64Url._CLASS_NAME, "bytes", bytes);
1805
+ Guards.uint8Array(Base64Url.CLASS_NAME, "bytes", bytes);
1800
1806
  const base64 = Base64.encode(bytes);
1801
1807
  // Base 64 url can have padding removed, so remove it.
1802
1808
  return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
@@ -2025,9 +2031,8 @@ class SharedStore {
2025
2031
  class Factory {
2026
2032
  /**
2027
2033
  * Runtime name for the class.
2028
- * @internal
2029
2034
  */
2030
- static _CLASS_NAME = "Factory";
2035
+ static CLASS_NAME = "Factory";
2031
2036
  /**
2032
2037
  * Type name for the instances.
2033
2038
  * @internal
@@ -2123,8 +2128,8 @@ class Factory {
2123
2128
  * @param generator The function to create an instance.
2124
2129
  */
2125
2130
  register(name, generator) {
2126
- Guards.stringValue(Factory._CLASS_NAME, "name", name);
2127
- Guards.function(Factory._CLASS_NAME, "generator", generator);
2131
+ Guards.stringValue(Factory.CLASS_NAME, "name", name);
2132
+ Guards.function(Factory.CLASS_NAME, "generator", generator);
2128
2133
  this._generators[name] = {
2129
2134
  generator,
2130
2135
  order: this._orderCounter++
@@ -2142,9 +2147,9 @@ class Factory {
2142
2147
  * @throws GeneralError if no generator exists.
2143
2148
  */
2144
2149
  unregister(name) {
2145
- Guards.stringValue(Factory._CLASS_NAME, "name", name);
2150
+ Guards.stringValue(Factory.CLASS_NAME, "name", name);
2146
2151
  if (!this._generators[name]) {
2147
- throw new GeneralError(Factory._CLASS_NAME, "noUnregister", {
2152
+ throw new GeneralError(Factory.CLASS_NAME, "noUnregister", {
2148
2153
  typeName: this._typeName,
2149
2154
  name
2150
2155
  });
@@ -2161,10 +2166,10 @@ class Factory {
2161
2166
  * @throws GeneralError if no item exists to get.
2162
2167
  */
2163
2168
  get(name) {
2164
- Guards.stringValue(Factory._CLASS_NAME, "name", name);
2169
+ Guards.stringValue(Factory.CLASS_NAME, "name", name);
2165
2170
  const instance = this.getIfExists(name);
2166
2171
  if (!instance) {
2167
- throw new GeneralError(Factory._CLASS_NAME, "noGet", {
2172
+ throw new GeneralError(Factory.CLASS_NAME, "noGet", {
2168
2173
  typeName: this._typeName,
2169
2174
  name
2170
2175
  });
@@ -2180,7 +2185,7 @@ class Factory {
2180
2185
  if (Is.empty(name)) {
2181
2186
  return;
2182
2187
  }
2183
- Guards.stringValue(Factory._CLASS_NAME, "name", name);
2188
+ Guards.stringValue(Factory.CLASS_NAME, "name", name);
2184
2189
  const matchName = this._matcher(Object.keys(this._generators), name);
2185
2190
  if (Is.stringValue(matchName) && this._generators[matchName]) {
2186
2191
  if (!this._instances[matchName]) {
@@ -2249,7 +2254,7 @@ class Factory {
2249
2254
  * @returns True if the factory has a matching name.
2250
2255
  */
2251
2256
  hasName(name) {
2252
- Guards.stringValue(Factory._CLASS_NAME, "name", name);
2257
+ Guards.stringValue(Factory.CLASS_NAME, "name", name);
2253
2258
  return Is.stringValue(this._matcher(Object.keys(this._generators), name));
2254
2259
  }
2255
2260
  /**
@@ -2375,7 +2380,7 @@ class Converter {
2375
2380
  */
2376
2381
  static bytesToHex(array, includePrefix = false, startIndex, length, reverse) {
2377
2382
  let hex = "";
2378
- this.buildHexLookups();
2383
+ Converter.buildHexLookups();
2379
2384
  if (Converter._ENCODE_LOOKUP) {
2380
2385
  const len = length ?? array.length;
2381
2386
  const start = startIndex ?? 0;
@@ -2403,7 +2408,7 @@ class Converter {
2403
2408
  const sizeof = strippedHex.length >> 1;
2404
2409
  const length = sizeof << 1;
2405
2410
  const array = new Uint8Array(sizeof);
2406
- this.buildHexLookups();
2411
+ Converter.buildHexLookups();
2407
2412
  if (Converter._DECODE_LOOKUP) {
2408
2413
  let i = 0;
2409
2414
  let n = 0;
@@ -2538,9 +2543,8 @@ class Converter {
2538
2543
  class JsonHelper {
2539
2544
  /**
2540
2545
  * Runtime name for the class.
2541
- * @internal
2542
2546
  */
2543
- static _CLASS_NAME = "JsonHelper";
2547
+ static CLASS_NAME = "JsonHelper";
2544
2548
  /**
2545
2549
  * Serializes in canonical format.
2546
2550
  * Based on https://www.rfc-editor.org/rfc/rfc8785.
@@ -2551,7 +2555,7 @@ class JsonHelper {
2551
2555
  const buffer = [];
2552
2556
  if (object === null ||
2553
2557
  typeof object !== "object" ||
2554
- ("toJSON" in object && object.toJSON instanceof Function)) {
2558
+ ("toJSON" in object && Is.function(object.toJSON))) {
2555
2559
  // Primitive data type
2556
2560
  buffer.push(JSON.stringify(object));
2557
2561
  }
@@ -2606,7 +2610,7 @@ class JsonHelper {
2606
2610
  const result = applyPatch(clone, patches);
2607
2611
  for (let i = 0; i < result.length; i++) {
2608
2612
  if (!Is.empty(result[i])) {
2609
- throw new GeneralError(JsonHelper._CLASS_NAME, "failedPatch", { index: i }, result[i]);
2613
+ throw new GeneralError(JsonHelper.CLASS_NAME, "failedPatch", { index: i }, result[i]);
2610
2614
  }
2611
2615
  }
2612
2616
  return clone;
@@ -2643,6 +2647,9 @@ class JsonHelper {
2643
2647
  */
2644
2648
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2645
2649
  static stringifyExReplacer(key, value) {
2650
+ // The this in the replacer is the containing object
2651
+ // so we need to get the actual value from there
2652
+ // eslint-disable-next-line no-restricted-syntax
2646
2653
  const rawValue = this[key];
2647
2654
  if (Is.bigint(rawValue)) {
2648
2655
  return {
@@ -2694,9 +2701,8 @@ class JsonHelper {
2694
2701
  class ObjectHelper {
2695
2702
  /**
2696
2703
  * Runtime name for the class.
2697
- * @internal
2698
2704
  */
2699
- static _CLASS_NAME = "ObjectHelper";
2705
+ static CLASS_NAME = "ObjectHelper";
2700
2706
  /**
2701
2707
  * Convert an object to bytes.
2702
2708
  * @param obj The object to convert.
@@ -2725,7 +2731,7 @@ class ObjectHelper {
2725
2731
  return JSON.parse(utf8);
2726
2732
  }
2727
2733
  catch (err) {
2728
- throw new GeneralError(ObjectHelper._CLASS_NAME, "failedBytesToJSON", undefined, err);
2734
+ throw new GeneralError(ObjectHelper.CLASS_NAME, "failedBytesToJSON", undefined, err);
2729
2735
  }
2730
2736
  }
2731
2737
  /**
@@ -2838,7 +2844,7 @@ class ObjectHelper {
2838
2844
  pathValue[arrayIndex] = value;
2839
2845
  }
2840
2846
  else {
2841
- throw new GeneralError(ObjectHelper._CLASS_NAME, "cannotSetArrayIndex", {
2847
+ throw new GeneralError(ObjectHelper.CLASS_NAME, "cannotSetArrayIndex", {
2842
2848
  property,
2843
2849
  index: arrayIndex
2844
2850
  });
@@ -2848,7 +2854,7 @@ class ObjectHelper {
2848
2854
  pathValue[pathPart] = value;
2849
2855
  }
2850
2856
  else {
2851
- throw new GeneralError(ObjectHelper._CLASS_NAME, "cannotSetProperty", { property });
2857
+ throw new GeneralError(ObjectHelper.CLASS_NAME, "cannotSetProperty", { property });
2852
2858
  }
2853
2859
  }
2854
2860
  else {
@@ -3190,7 +3196,6 @@ class I18n {
3190
3196
  * @param translation The translation to merge.
3191
3197
  * @param propertyPath The current root path.
3192
3198
  * @param mergedKeys The merged keys dictionary to populate.
3193
- * @internal
3194
3199
  */
3195
3200
  static flattenTranslationKeys(translation, propertyPath, mergedKeys) {
3196
3201
  for (const key in translation) {
@@ -3204,6 +3209,31 @@ class I18n {
3204
3209
  }
3205
3210
  }
3206
3211
  }
3212
+ /**
3213
+ * Get a list of the property names from the message.
3214
+ * @param message The message to extract the property names from.
3215
+ * @returns The list of property names.
3216
+ */
3217
+ static getPropertyNames(message) {
3218
+ const properties = new Set();
3219
+ // Handle basic placeholders: {property}
3220
+ const basicRegex = /{([$A-Z_a-z][\w$]*)}/g;
3221
+ let match;
3222
+ while ((match = basicRegex.exec(message)) !== null) {
3223
+ properties.add(match[1]);
3224
+ }
3225
+ // Handle ICU format with types: {property, number}, {property, date}, etc.
3226
+ const icuRegex = /{([$A-Z_a-z][\w$]*)\s*,\s*\w+/g;
3227
+ while ((match = icuRegex.exec(message)) !== null) {
3228
+ properties.add(match[1]);
3229
+ }
3230
+ // Handle plural/select: {count, plural, one {1 item} other {# items}}
3231
+ const pluralSelectRegex = /{([$A-Z_a-z][\w$]*)\s*,\s*(plural|select|selectordinal)/g;
3232
+ while ((match = pluralSelectRegex.exec(message)) !== null) {
3233
+ properties.add(match[1]);
3234
+ }
3235
+ return Array.from(properties);
3236
+ }
3207
3237
  /**
3208
3238
  * Get the I18n shared data.
3209
3239
  * @returns The I18n shared data.
@@ -3733,9 +3763,8 @@ const CompressionType = {
3733
3763
  class BitString {
3734
3764
  /**
3735
3765
  * Runtime name for the class.
3736
- * @internal
3737
3766
  */
3738
- static _CLASS_NAME = "BitString";
3767
+ static CLASS_NAME = "BitString";
3739
3768
  /**
3740
3769
  * The storage for the bits.
3741
3770
  * @internal
@@ -3751,7 +3780,7 @@ class BitString {
3751
3780
  * @param numberBits The length of the bit string.
3752
3781
  */
3753
3782
  constructor(numberBits) {
3754
- Guards.integer(BitString._CLASS_NAME, "numberBits", numberBits);
3783
+ Guards.integer(BitString.CLASS_NAME, "numberBits", numberBits);
3755
3784
  this._numberBits = numberBits;
3756
3785
  this._bits = new Uint8Array(Math.ceil(numberBits / 8));
3757
3786
  }
@@ -3762,8 +3791,8 @@ class BitString {
3762
3791
  * @returns The new instance of BitString.
3763
3792
  */
3764
3793
  static fromBits(bits, numberBits) {
3765
- Guards.uint8Array(BitString._CLASS_NAME, "bits", bits);
3766
- Guards.integer(BitString._CLASS_NAME, "numberBits", numberBits);
3794
+ Guards.uint8Array(BitString.CLASS_NAME, "bits", bits);
3795
+ Guards.integer(BitString.CLASS_NAME, "numberBits", numberBits);
3767
3796
  const bs = new BitString(numberBits);
3768
3797
  bs._bits.set(bits);
3769
3798
  return bs;
@@ -3775,9 +3804,9 @@ class BitString {
3775
3804
  * @throws GeneralError if the index is out of range.
3776
3805
  */
3777
3806
  getBit(index) {
3778
- Guards.integer(BitString._CLASS_NAME, "index", index);
3807
+ Guards.integer(BitString.CLASS_NAME, "index", index);
3779
3808
  if (index < 0 || index >= this._numberBits) {
3780
- throw new GeneralError(BitString._CLASS_NAME, "outOfRange", {
3809
+ throw new GeneralError(BitString.CLASS_NAME, "outOfRange", {
3781
3810
  index,
3782
3811
  numberBits: this._numberBits
3783
3812
  });
@@ -3794,7 +3823,7 @@ class BitString {
3794
3823
  */
3795
3824
  setBit(index, value) {
3796
3825
  if (index < 0 || index >= this._numberBits) {
3797
- throw new GeneralError(BitString._CLASS_NAME, "outOfRange", {
3826
+ throw new GeneralError(BitString.CLASS_NAME, "outOfRange", {
3798
3827
  index,
3799
3828
  numberBits: this._numberBits
3800
3829
  });
@@ -3830,9 +3859,8 @@ class BitString {
3830
3859
  class Url {
3831
3860
  /**
3832
3861
  * Runtime name for the class.
3833
- * @internal
3834
3862
  */
3835
- static _CLASS_NAME = "Url";
3863
+ static CLASS_NAME = "Url";
3836
3864
  /**
3837
3865
  * The internal representation of the url.
3838
3866
  * @internal
@@ -3843,13 +3871,13 @@ class Url {
3843
3871
  * @param url The url string.
3844
3872
  */
3845
3873
  constructor(url) {
3846
- Guards.stringValue(Url._CLASS_NAME, "url", url);
3874
+ Guards.stringValue(Url.CLASS_NAME, "url", url);
3847
3875
  try {
3848
3876
  const u = new URL(url);
3849
3877
  this._urlParts = Url.fromURLToParts(u);
3850
3878
  }
3851
3879
  catch {
3852
- throw new GuardError(Url._CLASS_NAME, "guard.url", "url", url);
3880
+ throw new GuardError(Url.CLASS_NAME, "guard.url", "url", url);
3853
3881
  }
3854
3882
  }
3855
3883
  /**
@@ -3888,13 +3916,15 @@ class Url {
3888
3916
  * @param property Throw an exception if the url property is invalid.
3889
3917
  * @param value The url to parse.
3890
3918
  * @param failures The list of failures to add to.
3919
+ * @param fieldNameResource The optional human readable name for the field as an i18 resource.
3891
3920
  * @returns The formatted url.
3892
3921
  */
3893
- static validate(property, value, failures) {
3922
+ static validate(property, value, failures, fieldNameResource) {
3894
3923
  if (!Is.stringValue(value)) {
3895
3924
  failures.push({
3896
3925
  property,
3897
- reason: "validation.notEmpty"
3926
+ reason: "validation.beNotEmpty",
3927
+ properties: { fieldName: fieldNameResource ?? "validation.defaultFieldName", value }
3898
3928
  });
3899
3929
  return false;
3900
3930
  }
@@ -3902,7 +3932,8 @@ class Url {
3902
3932
  if (Is.undefined(result)) {
3903
3933
  failures.push({
3904
3934
  property,
3905
- reason: "validation.beUrl"
3935
+ reason: "validation.beUrl",
3936
+ properties: { fieldName: fieldNameResource ?? "validation.defaultFieldName", value }
3906
3937
  });
3907
3938
  return false;
3908
3939
  }
@@ -3968,9 +3999,8 @@ class Url {
3968
3999
  class Urn {
3969
4000
  /**
3970
4001
  * Runtime name for the class.
3971
- * @internal
3972
4002
  */
3973
- static _CLASS_NAME = "Urn";
4003
+ static CLASS_NAME = "Urn";
3974
4004
  /**
3975
4005
  * The specific part of the namespace.
3976
4006
  * @internal
@@ -3982,15 +4012,15 @@ class Urn {
3982
4012
  * @param namespaceSpecific The specific part of the namespace.
3983
4013
  */
3984
4014
  constructor(namespaceIdentifier, namespaceSpecific) {
3985
- Guards.stringValue(Urn._CLASS_NAME, "namespaceIdentifier", namespaceIdentifier);
4015
+ Guards.stringValue(Urn.CLASS_NAME, "namespaceIdentifier", namespaceIdentifier);
3986
4016
  // Strip leading and trailing colons
3987
4017
  this._urnParts = [this.stripColons(namespaceIdentifier)];
3988
4018
  if (Is.array(namespaceSpecific)) {
3989
- Guards.arrayValue(Urn._CLASS_NAME, "namespaceSpecific", namespaceSpecific);
4019
+ Guards.arrayValue(Urn.CLASS_NAME, "namespaceSpecific", namespaceSpecific);
3990
4020
  this._urnParts.push(...namespaceSpecific);
3991
4021
  }
3992
4022
  else {
3993
- Guards.stringValue(Urn._CLASS_NAME, "namespaceSpecific", namespaceSpecific);
4023
+ Guards.stringValue(Urn.CLASS_NAME, "namespaceSpecific", namespaceSpecific);
3994
4024
  this._urnParts.push(...this.stripColons(namespaceSpecific).split(":"));
3995
4025
  }
3996
4026
  }
@@ -4090,13 +4120,15 @@ class Urn {
4090
4120
  * @param property Throw an exception if the urn property is invalid.
4091
4121
  * @param value The urn to parse.
4092
4122
  * @param failures The list of failures to add to.
4123
+ * @param fieldNameResource The optional human readable name for the field as an i18 resource.
4093
4124
  * @returns The formatted urn.
4094
4125
  */
4095
- static validate(property, value, failures) {
4126
+ static validate(property, value, failures, fieldNameResource) {
4096
4127
  if (!Is.stringValue(value)) {
4097
4128
  failures.push({
4098
4129
  property,
4099
- reason: "validation.notEmpty"
4130
+ reason: "validation.beNotEmpty",
4131
+ properties: { fieldName: fieldNameResource ?? "validation.defaultFieldName", value }
4100
4132
  });
4101
4133
  return false;
4102
4134
  }
@@ -4104,7 +4136,8 @@ class Urn {
4104
4136
  if (Is.undefined(result)) {
4105
4137
  failures.push({
4106
4138
  property,
4107
- reason: "validation.beUrn"
4139
+ reason: "validation.beUrn",
4140
+ properties: { fieldName: fieldNameResource ?? "validation.defaultFieldName", value }
4108
4141
  });
4109
4142
  return false;
4110
4143
  }
@@ -4350,9 +4383,8 @@ class AsyncCache {
4350
4383
  class Compression {
4351
4384
  /**
4352
4385
  * Runtime name for the class.
4353
- * @internal
4354
4386
  */
4355
- static _CLASS_NAME = "Compression";
4387
+ static CLASS_NAME = "Compression";
4356
4388
  /**
4357
4389
  * Compress bytes using GZIP.
4358
4390
  * @param bytes The bytes to compress.
@@ -4360,8 +4392,8 @@ class Compression {
4360
4392
  * @returns The compressed bytes.
4361
4393
  */
4362
4394
  static async compress(bytes, type) {
4363
- Guards.uint8Array(Compression._CLASS_NAME, "bytes", bytes);
4364
- Guards.arrayOneOf(Compression._CLASS_NAME, "type", type, Object.values(CompressionType));
4395
+ Guards.uint8Array(Compression.CLASS_NAME, "bytes", bytes);
4396
+ Guards.arrayOneOf(Compression.CLASS_NAME, "type", type, Object.values(CompressionType));
4365
4397
  const blob = new Blob([new Uint8Array(bytes)]);
4366
4398
  const compressionStream = new CompressionStream(type);
4367
4399
  const compressionPipe = blob.stream().pipeThrough(compressionStream);
@@ -4382,8 +4414,8 @@ class Compression {
4382
4414
  * @returns The decompressed bytes.
4383
4415
  */
4384
4416
  static async decompress(compressedBytes, type) {
4385
- Guards.uint8Array(Compression._CLASS_NAME, "compressedBytes", compressedBytes);
4386
- Guards.arrayOneOf(Compression._CLASS_NAME, "type", type, Object.values(CompressionType));
4417
+ Guards.uint8Array(Compression.CLASS_NAME, "compressedBytes", compressedBytes);
4418
+ Guards.arrayOneOf(Compression.CLASS_NAME, "type", type, Object.values(CompressionType));
4387
4419
  const blob = new Blob([new Uint8Array(compressedBytes)]);
4388
4420
  const decompressionStream = new DecompressionStream(type);
4389
4421
  const decompressionPipe = blob.stream().pipeThrough(decompressionStream);
@@ -4412,8 +4444,7 @@ class Validation {
4412
4444
  failures.push({
4413
4445
  property,
4414
4446
  reason: "validation.beEmpty",
4415
- fieldName: fieldNameResource ?? "validation.defaultFieldName",
4416
- properties: { value }
4447
+ properties: { fieldName: fieldNameResource ?? "validation.defaultFieldName", value }
4417
4448
  });
4418
4449
  }
4419
4450
  return is;
@@ -2,6 +2,10 @@
2
2
  * Class to help with base63 Encoding/Decoding.
3
3
  */
4
4
  export declare class Base32 {
5
+ /**
6
+ * Runtime name for the class.
7
+ */
8
+ static readonly CLASS_NAME: string;
5
9
  /**
6
10
  * Convert the base 32 string to a byte array.
7
11
  * @param base32 The base32 string to convert.
@@ -2,6 +2,10 @@
2
2
  * Class to help with base58 Encoding/Decoding.
3
3
  */
4
4
  export declare class Base58 {
5
+ /**
6
+ * Runtime name for the class.
7
+ */
8
+ static readonly CLASS_NAME: string;
5
9
  /**
6
10
  * Convert the base 58 string to a byte array.
7
11
  * @param base58 The base58 string to convert.
@@ -3,6 +3,10 @@
3
3
  * Sourced from https://github.com/beatgammit/base64-js.
4
4
  */
5
5
  export declare class Base64 {
6
+ /**
7
+ * Runtime name for the class.
8
+ */
9
+ static readonly CLASS_NAME: string;
6
10
  /**
7
11
  * Get the byte length of the data.
8
12
  * @param base64 The base64 string.
@@ -3,6 +3,10 @@
3
3
  * https://www.rfc-editor.org/rfc/rfc4648#section-5.
4
4
  */
5
5
  export declare class Base64Url {
6
+ /**
7
+ * Runtime name for the class.
8
+ */
9
+ static readonly CLASS_NAME: string;
6
10
  /**
7
11
  * Convert the base 64 string to a byte array.
8
12
  * @param base64Url The base64 url string to convert.
@@ -2,6 +2,10 @@
2
2
  * Factory for creating implementation of generic types.
3
3
  */
4
4
  export declare class Factory<T> {
5
+ /**
6
+ * Runtime name for the class.
7
+ */
8
+ static readonly CLASS_NAME: string;
5
9
  /**
6
10
  * Create a new factory, which is shared throughout all library instances.
7
11
  * @param typeName The type name for the instances.
@@ -3,6 +3,10 @@ import type { IPatchOperation } from "../models/IPatchOperation";
3
3
  * Helpers methods for JSON objects.
4
4
  */
5
5
  export declare class JsonHelper {
6
+ /**
7
+ * Runtime name for the class.
8
+ */
9
+ static readonly CLASS_NAME: string;
6
10
  /**
7
11
  * Serializes in canonical format.
8
12
  * Based on https://www.rfc-editor.org/rfc/rfc8785.