@twin.org/core 0.0.2-next.20 → 0.0.2-next.22

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 +34 -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 +8 -4
@@ -331,6 +331,8 @@ class Is {
331
331
  * @returns True if the value is a Uint8Array.
332
332
  */
333
333
  static uint8Array(value) {
334
+ // This is the only way we can reliably check for Uint8Array
335
+ // eslint-disable-next-line no-restricted-syntax
334
336
  return value instanceof Uint8Array;
335
337
  }
336
338
  /**
@@ -339,6 +341,8 @@ class Is {
339
341
  * @returns True if the value is a TypedArray.
340
342
  */
341
343
  static typedArray(value) {
344
+ // This is the only way we can reliably check for TypedArray
345
+ // eslint-disable-next-line no-restricted-syntax
342
346
  return value instanceof Object.getPrototypeOf(Uint8Array);
343
347
  }
344
348
  /**
@@ -365,6 +369,8 @@ class Is {
365
369
  * @returns True if the value is a promise.
366
370
  */
367
371
  static promise(value) {
372
+ // This is the only way we can reliably check for Promise
373
+ // eslint-disable-next-line no-restricted-syntax
368
374
  return value instanceof Promise;
369
375
  }
370
376
  /**
@@ -373,6 +379,8 @@ class Is {
373
379
  * @returns True if the value is a regexp.
374
380
  */
375
381
  static regexp(value) {
382
+ // This is the only way we can reliably check for RegExp
383
+ // eslint-disable-next-line no-restricted-syntax
376
384
  return value instanceof RegExp;
377
385
  }
378
386
  /**
@@ -840,6 +848,8 @@ class BaseError extends Error {
840
848
  * @returns True if the error is an aggregate error.
841
849
  */
842
850
  static isAggregateError(err) {
851
+ // This is the only way we can reliably check for AggregateError
852
+ // eslint-disable-next-line no-restricted-syntax
843
853
  return err instanceof AggregateError;
844
854
  }
845
855
  /**
@@ -1037,7 +1047,7 @@ class Guards {
1037
1047
  */
1038
1048
  static stringBase64(source, property, value) {
1039
1049
  if (!Is.stringBase64(value)) {
1040
- throw new GuardError(source, "guard.base64", property, value);
1050
+ throw new GuardError(source, "guard.stringBase64", property, value);
1041
1051
  }
1042
1052
  }
1043
1053
  /**
@@ -1049,7 +1059,7 @@ class Guards {
1049
1059
  */
1050
1060
  static stringBase64Url(source, property, value) {
1051
1061
  if (!Is.stringBase64Url(value)) {
1052
- throw new GuardError(source, "guard.base64Url", property, value);
1062
+ throw new GuardError(source, "guard.stringBase64Url", property, value);
1053
1063
  }
1054
1064
  }
1055
1065
  /**
@@ -1061,7 +1071,7 @@ class Guards {
1061
1071
  */
1062
1072
  static stringBase58(source, property, value) {
1063
1073
  if (!Is.stringBase58(value)) {
1064
- throw new GuardError(source, "guard.base58", property, value);
1074
+ throw new GuardError(source, "guard.stringBase58", property, value);
1065
1075
  }
1066
1076
  }
1067
1077
  /**
@@ -1346,9 +1356,8 @@ class Guards {
1346
1356
  class Base32 {
1347
1357
  /**
1348
1358
  * Runtime name for the class.
1349
- * @internal
1350
1359
  */
1351
- static _CLASS_NAME = "Base32";
1360
+ static CLASS_NAME = "Base32";
1352
1361
  /**
1353
1362
  * Alphabet table for encoding.
1354
1363
  * @internal
@@ -1361,7 +1370,7 @@ class Base32 {
1361
1370
  * @throws If the input string contains a character not in the Base32 alphabet.
1362
1371
  */
1363
1372
  static decode(base32) {
1364
- Guards.string(Base32._CLASS_NAME, "base32", base32);
1373
+ Guards.string(Base32.CLASS_NAME, "base32", base32);
1365
1374
  let bits = 0;
1366
1375
  let value = 0;
1367
1376
  base32 = base32.replace(/=+$/, "");
@@ -1370,7 +1379,7 @@ class Base32 {
1370
1379
  for (let i = 0; i < base32.length; i++) {
1371
1380
  const idx = Base32._ALPHABET.indexOf(base32[i]);
1372
1381
  if (idx === -1) {
1373
- throw new GeneralError(Base32._CLASS_NAME, "invalidCharacter", {
1382
+ throw new GeneralError(Base32.CLASS_NAME, "invalidCharacter", {
1374
1383
  invalidCharacter: base32[i]
1375
1384
  });
1376
1385
  }
@@ -1389,7 +1398,7 @@ class Base32 {
1389
1398
  * @returns The data as base32 string.
1390
1399
  */
1391
1400
  static encode(bytes) {
1392
- Guards.uint8Array(Base32._CLASS_NAME, "bytes", bytes);
1401
+ Guards.uint8Array(Base32.CLASS_NAME, "bytes", bytes);
1393
1402
  let bits = 0;
1394
1403
  let value = 0;
1395
1404
  let output = "";
@@ -1417,9 +1426,8 @@ class Base32 {
1417
1426
  class Base58 {
1418
1427
  /**
1419
1428
  * Runtime name for the class.
1420
- * @internal
1421
1429
  */
1422
- static _CLASS_NAME = "Base58";
1430
+ static CLASS_NAME = "Base58";
1423
1431
  /**
1424
1432
  * Alphabet table for encoding.
1425
1433
  * @internal
@@ -1446,7 +1454,7 @@ class Base58 {
1446
1454
  * @throws If the input string contains a character not in the Base58 alphabet.
1447
1455
  */
1448
1456
  static decode(base58) {
1449
- Guards.string(Base58._CLASS_NAME, "base58", base58);
1457
+ Guards.string(Base58.CLASS_NAME, "base58", base58);
1450
1458
  let zeroes = 0;
1451
1459
  for (let i = 0; i < base58.length; i++) {
1452
1460
  if (base58[i] !== "1") {
@@ -1460,11 +1468,11 @@ class Base58 {
1460
1468
  for (let i = zeroes; i < base58.length; i++) {
1461
1469
  const ch = base58.charCodeAt(i);
1462
1470
  if (ch & 0xff80) {
1463
- throw new GeneralError(Base58._CLASS_NAME, "invalidCharacter", { invalidCharacter: ch });
1471
+ throw new GeneralError(Base58.CLASS_NAME, "invalidCharacter", { invalidCharacter: ch });
1464
1472
  }
1465
1473
  const val = Base58._ALPHABET_REVERSE[ch];
1466
1474
  if (val === -1) {
1467
- throw new GeneralError(Base58._CLASS_NAME, "invalidCharacter", { invalidCharacter: ch });
1475
+ throw new GeneralError(Base58.CLASS_NAME, "invalidCharacter", { invalidCharacter: ch });
1468
1476
  }
1469
1477
  let carry = val;
1470
1478
  let j = 0;
@@ -1495,7 +1503,7 @@ class Base58 {
1495
1503
  * @returns The data as base58 string.
1496
1504
  */
1497
1505
  static encode(bytes) {
1498
- Guards.uint8Array(Base58._CLASS_NAME, "bytes", bytes);
1506
+ Guards.uint8Array(Base58.CLASS_NAME, "bytes", bytes);
1499
1507
  let zeroes = 0;
1500
1508
  for (let i = 0; i < bytes.length; i++) {
1501
1509
  if (bytes[i] !== 0) {
@@ -1545,9 +1553,8 @@ class Base58 {
1545
1553
  class Base64 {
1546
1554
  /**
1547
1555
  * Runtime name for the class.
1548
- * @internal
1549
1556
  */
1550
- static _CLASS_NAME = "Base64";
1557
+ static CLASS_NAME = "Base64";
1551
1558
  /**
1552
1559
  * Alphabet table for encoding.
1553
1560
  * @internal
@@ -1640,7 +1647,7 @@ class Base64 {
1640
1647
  * @returns The byte array.
1641
1648
  */
1642
1649
  static decode(base64) {
1643
- Guards.string(Base64._CLASS_NAME, "base64", base64);
1650
+ Guards.string(Base64.CLASS_NAME, "base64", base64);
1644
1651
  let tmp;
1645
1652
  const lens = Base64.getLengths(base64);
1646
1653
  const validLen = lens[0];
@@ -1682,7 +1689,7 @@ class Base64 {
1682
1689
  * @returns The data as base64 string.
1683
1690
  */
1684
1691
  static encode(bytes) {
1685
- Guards.uint8Array(Base64._CLASS_NAME, "bytes", bytes);
1692
+ Guards.uint8Array(Base64.CLASS_NAME, "bytes", bytes);
1686
1693
  let tmp;
1687
1694
  const len = bytes.length;
1688
1695
  const extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes
@@ -1722,7 +1729,7 @@ class Base64 {
1722
1729
  static getLengths(base64) {
1723
1730
  const len = base64.length;
1724
1731
  if (len % 4 > 0) {
1725
- throw new GeneralError(Base64._CLASS_NAME, "length4Multiple", { value: len });
1732
+ throw new GeneralError(Base64.CLASS_NAME, "length4Multiple", { value: len });
1726
1733
  }
1727
1734
  // Trim off extra bytes after placeholder bytes are found
1728
1735
  // See: https://github.com/beatgammit/base64-js/issues/42
@@ -1771,16 +1778,15 @@ class Base64 {
1771
1778
  class Base64Url {
1772
1779
  /**
1773
1780
  * Runtime name for the class.
1774
- * @internal
1775
1781
  */
1776
- static _CLASS_NAME = "Base64";
1782
+ static CLASS_NAME = "Base64";
1777
1783
  /**
1778
1784
  * Convert the base 64 string to a byte array.
1779
1785
  * @param base64Url The base64 url string to convert.
1780
1786
  * @returns The byte array.
1781
1787
  */
1782
1788
  static decode(base64Url) {
1783
- Guards.string(Base64Url._CLASS_NAME, "base64Url", base64Url);
1789
+ Guards.string(Base64Url.CLASS_NAME, "base64Url", base64Url);
1784
1790
  let base64 = base64Url;
1785
1791
  // Base 64 url can have padding removed, so add it back if it is missing.
1786
1792
  if (base64.length > 0 && !base64.endsWith("=")) {
@@ -1798,7 +1804,7 @@ class Base64Url {
1798
1804
  * @returns The data as base64 url string.
1799
1805
  */
1800
1806
  static encode(bytes) {
1801
- Guards.uint8Array(Base64Url._CLASS_NAME, "bytes", bytes);
1807
+ Guards.uint8Array(Base64Url.CLASS_NAME, "bytes", bytes);
1802
1808
  const base64 = Base64.encode(bytes);
1803
1809
  // Base 64 url can have padding removed, so remove it.
1804
1810
  return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
@@ -2027,9 +2033,8 @@ class SharedStore {
2027
2033
  class Factory {
2028
2034
  /**
2029
2035
  * Runtime name for the class.
2030
- * @internal
2031
2036
  */
2032
- static _CLASS_NAME = "Factory";
2037
+ static CLASS_NAME = "Factory";
2033
2038
  /**
2034
2039
  * Type name for the instances.
2035
2040
  * @internal
@@ -2125,8 +2130,8 @@ class Factory {
2125
2130
  * @param generator The function to create an instance.
2126
2131
  */
2127
2132
  register(name, generator) {
2128
- Guards.stringValue(Factory._CLASS_NAME, "name", name);
2129
- Guards.function(Factory._CLASS_NAME, "generator", generator);
2133
+ Guards.stringValue(Factory.CLASS_NAME, "name", name);
2134
+ Guards.function(Factory.CLASS_NAME, "generator", generator);
2130
2135
  this._generators[name] = {
2131
2136
  generator,
2132
2137
  order: this._orderCounter++
@@ -2144,9 +2149,9 @@ class Factory {
2144
2149
  * @throws GeneralError if no generator exists.
2145
2150
  */
2146
2151
  unregister(name) {
2147
- Guards.stringValue(Factory._CLASS_NAME, "name", name);
2152
+ Guards.stringValue(Factory.CLASS_NAME, "name", name);
2148
2153
  if (!this._generators[name]) {
2149
- throw new GeneralError(Factory._CLASS_NAME, "noUnregister", {
2154
+ throw new GeneralError(Factory.CLASS_NAME, "noUnregister", {
2150
2155
  typeName: this._typeName,
2151
2156
  name
2152
2157
  });
@@ -2163,10 +2168,10 @@ class Factory {
2163
2168
  * @throws GeneralError if no item exists to get.
2164
2169
  */
2165
2170
  get(name) {
2166
- Guards.stringValue(Factory._CLASS_NAME, "name", name);
2171
+ Guards.stringValue(Factory.CLASS_NAME, "name", name);
2167
2172
  const instance = this.getIfExists(name);
2168
2173
  if (!instance) {
2169
- throw new GeneralError(Factory._CLASS_NAME, "noGet", {
2174
+ throw new GeneralError(Factory.CLASS_NAME, "noGet", {
2170
2175
  typeName: this._typeName,
2171
2176
  name
2172
2177
  });
@@ -2182,7 +2187,7 @@ class Factory {
2182
2187
  if (Is.empty(name)) {
2183
2188
  return;
2184
2189
  }
2185
- Guards.stringValue(Factory._CLASS_NAME, "name", name);
2190
+ Guards.stringValue(Factory.CLASS_NAME, "name", name);
2186
2191
  const matchName = this._matcher(Object.keys(this._generators), name);
2187
2192
  if (Is.stringValue(matchName) && this._generators[matchName]) {
2188
2193
  if (!this._instances[matchName]) {
@@ -2251,7 +2256,7 @@ class Factory {
2251
2256
  * @returns True if the factory has a matching name.
2252
2257
  */
2253
2258
  hasName(name) {
2254
- Guards.stringValue(Factory._CLASS_NAME, "name", name);
2259
+ Guards.stringValue(Factory.CLASS_NAME, "name", name);
2255
2260
  return Is.stringValue(this._matcher(Object.keys(this._generators), name));
2256
2261
  }
2257
2262
  /**
@@ -2377,7 +2382,7 @@ class Converter {
2377
2382
  */
2378
2383
  static bytesToHex(array, includePrefix = false, startIndex, length, reverse) {
2379
2384
  let hex = "";
2380
- this.buildHexLookups();
2385
+ Converter.buildHexLookups();
2381
2386
  if (Converter._ENCODE_LOOKUP) {
2382
2387
  const len = length ?? array.length;
2383
2388
  const start = startIndex ?? 0;
@@ -2405,7 +2410,7 @@ class Converter {
2405
2410
  const sizeof = strippedHex.length >> 1;
2406
2411
  const length = sizeof << 1;
2407
2412
  const array = new Uint8Array(sizeof);
2408
- this.buildHexLookups();
2413
+ Converter.buildHexLookups();
2409
2414
  if (Converter._DECODE_LOOKUP) {
2410
2415
  let i = 0;
2411
2416
  let n = 0;
@@ -2540,9 +2545,8 @@ class Converter {
2540
2545
  class JsonHelper {
2541
2546
  /**
2542
2547
  * Runtime name for the class.
2543
- * @internal
2544
2548
  */
2545
- static _CLASS_NAME = "JsonHelper";
2549
+ static CLASS_NAME = "JsonHelper";
2546
2550
  /**
2547
2551
  * Serializes in canonical format.
2548
2552
  * Based on https://www.rfc-editor.org/rfc/rfc8785.
@@ -2553,7 +2557,7 @@ class JsonHelper {
2553
2557
  const buffer = [];
2554
2558
  if (object === null ||
2555
2559
  typeof object !== "object" ||
2556
- ("toJSON" in object && object.toJSON instanceof Function)) {
2560
+ ("toJSON" in object && Is.function(object.toJSON))) {
2557
2561
  // Primitive data type
2558
2562
  buffer.push(JSON.stringify(object));
2559
2563
  }
@@ -2608,7 +2612,7 @@ class JsonHelper {
2608
2612
  const result = rfc6902.applyPatch(clone, patches);
2609
2613
  for (let i = 0; i < result.length; i++) {
2610
2614
  if (!Is.empty(result[i])) {
2611
- throw new GeneralError(JsonHelper._CLASS_NAME, "failedPatch", { index: i }, result[i]);
2615
+ throw new GeneralError(JsonHelper.CLASS_NAME, "failedPatch", { index: i }, result[i]);
2612
2616
  }
2613
2617
  }
2614
2618
  return clone;
@@ -2645,6 +2649,9 @@ class JsonHelper {
2645
2649
  */
2646
2650
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2647
2651
  static stringifyExReplacer(key, value) {
2652
+ // The this in the replacer is the containing object
2653
+ // so we need to get the actual value from there
2654
+ // eslint-disable-next-line no-restricted-syntax
2648
2655
  const rawValue = this[key];
2649
2656
  if (Is.bigint(rawValue)) {
2650
2657
  return {
@@ -2696,9 +2703,8 @@ class JsonHelper {
2696
2703
  class ObjectHelper {
2697
2704
  /**
2698
2705
  * Runtime name for the class.
2699
- * @internal
2700
2706
  */
2701
- static _CLASS_NAME = "ObjectHelper";
2707
+ static CLASS_NAME = "ObjectHelper";
2702
2708
  /**
2703
2709
  * Convert an object to bytes.
2704
2710
  * @param obj The object to convert.
@@ -2727,7 +2733,7 @@ class ObjectHelper {
2727
2733
  return JSON.parse(utf8);
2728
2734
  }
2729
2735
  catch (err) {
2730
- throw new GeneralError(ObjectHelper._CLASS_NAME, "failedBytesToJSON", undefined, err);
2736
+ throw new GeneralError(ObjectHelper.CLASS_NAME, "failedBytesToJSON", undefined, err);
2731
2737
  }
2732
2738
  }
2733
2739
  /**
@@ -2840,7 +2846,7 @@ class ObjectHelper {
2840
2846
  pathValue[arrayIndex] = value;
2841
2847
  }
2842
2848
  else {
2843
- throw new GeneralError(ObjectHelper._CLASS_NAME, "cannotSetArrayIndex", {
2849
+ throw new GeneralError(ObjectHelper.CLASS_NAME, "cannotSetArrayIndex", {
2844
2850
  property,
2845
2851
  index: arrayIndex
2846
2852
  });
@@ -2850,7 +2856,7 @@ class ObjectHelper {
2850
2856
  pathValue[pathPart] = value;
2851
2857
  }
2852
2858
  else {
2853
- throw new GeneralError(ObjectHelper._CLASS_NAME, "cannotSetProperty", { property });
2859
+ throw new GeneralError(ObjectHelper.CLASS_NAME, "cannotSetProperty", { property });
2854
2860
  }
2855
2861
  }
2856
2862
  else {
@@ -3192,7 +3198,6 @@ class I18n {
3192
3198
  * @param translation The translation to merge.
3193
3199
  * @param propertyPath The current root path.
3194
3200
  * @param mergedKeys The merged keys dictionary to populate.
3195
- * @internal
3196
3201
  */
3197
3202
  static flattenTranslationKeys(translation, propertyPath, mergedKeys) {
3198
3203
  for (const key in translation) {
@@ -3206,6 +3211,31 @@ class I18n {
3206
3211
  }
3207
3212
  }
3208
3213
  }
3214
+ /**
3215
+ * Get a list of the property names from the message.
3216
+ * @param message The message to extract the property names from.
3217
+ * @returns The list of property names.
3218
+ */
3219
+ static getPropertyNames(message) {
3220
+ const properties = new Set();
3221
+ // Handle basic placeholders: {property}
3222
+ const basicRegex = /{([$A-Z_a-z][\w$]*)}/g;
3223
+ let match;
3224
+ while ((match = basicRegex.exec(message)) !== null) {
3225
+ properties.add(match[1]);
3226
+ }
3227
+ // Handle ICU format with types: {property, number}, {property, date}, etc.
3228
+ const icuRegex = /{([$A-Z_a-z][\w$]*)\s*,\s*\w+/g;
3229
+ while ((match = icuRegex.exec(message)) !== null) {
3230
+ properties.add(match[1]);
3231
+ }
3232
+ // Handle plural/select: {count, plural, one {1 item} other {# items}}
3233
+ const pluralSelectRegex = /{([$A-Z_a-z][\w$]*)\s*,\s*(plural|select|selectordinal)/g;
3234
+ while ((match = pluralSelectRegex.exec(message)) !== null) {
3235
+ properties.add(match[1]);
3236
+ }
3237
+ return Array.from(properties);
3238
+ }
3209
3239
  /**
3210
3240
  * Get the I18n shared data.
3211
3241
  * @returns The I18n shared data.
@@ -3735,9 +3765,8 @@ const CompressionType = {
3735
3765
  class BitString {
3736
3766
  /**
3737
3767
  * Runtime name for the class.
3738
- * @internal
3739
3768
  */
3740
- static _CLASS_NAME = "BitString";
3769
+ static CLASS_NAME = "BitString";
3741
3770
  /**
3742
3771
  * The storage for the bits.
3743
3772
  * @internal
@@ -3753,7 +3782,7 @@ class BitString {
3753
3782
  * @param numberBits The length of the bit string.
3754
3783
  */
3755
3784
  constructor(numberBits) {
3756
- Guards.integer(BitString._CLASS_NAME, "numberBits", numberBits);
3785
+ Guards.integer(BitString.CLASS_NAME, "numberBits", numberBits);
3757
3786
  this._numberBits = numberBits;
3758
3787
  this._bits = new Uint8Array(Math.ceil(numberBits / 8));
3759
3788
  }
@@ -3764,8 +3793,8 @@ class BitString {
3764
3793
  * @returns The new instance of BitString.
3765
3794
  */
3766
3795
  static fromBits(bits, numberBits) {
3767
- Guards.uint8Array(BitString._CLASS_NAME, "bits", bits);
3768
- Guards.integer(BitString._CLASS_NAME, "numberBits", numberBits);
3796
+ Guards.uint8Array(BitString.CLASS_NAME, "bits", bits);
3797
+ Guards.integer(BitString.CLASS_NAME, "numberBits", numberBits);
3769
3798
  const bs = new BitString(numberBits);
3770
3799
  bs._bits.set(bits);
3771
3800
  return bs;
@@ -3777,9 +3806,9 @@ class BitString {
3777
3806
  * @throws GeneralError if the index is out of range.
3778
3807
  */
3779
3808
  getBit(index) {
3780
- Guards.integer(BitString._CLASS_NAME, "index", index);
3809
+ Guards.integer(BitString.CLASS_NAME, "index", index);
3781
3810
  if (index < 0 || index >= this._numberBits) {
3782
- throw new GeneralError(BitString._CLASS_NAME, "outOfRange", {
3811
+ throw new GeneralError(BitString.CLASS_NAME, "outOfRange", {
3783
3812
  index,
3784
3813
  numberBits: this._numberBits
3785
3814
  });
@@ -3796,7 +3825,7 @@ class BitString {
3796
3825
  */
3797
3826
  setBit(index, value) {
3798
3827
  if (index < 0 || index >= this._numberBits) {
3799
- throw new GeneralError(BitString._CLASS_NAME, "outOfRange", {
3828
+ throw new GeneralError(BitString.CLASS_NAME, "outOfRange", {
3800
3829
  index,
3801
3830
  numberBits: this._numberBits
3802
3831
  });
@@ -3832,9 +3861,8 @@ class BitString {
3832
3861
  class Url {
3833
3862
  /**
3834
3863
  * Runtime name for the class.
3835
- * @internal
3836
3864
  */
3837
- static _CLASS_NAME = "Url";
3865
+ static CLASS_NAME = "Url";
3838
3866
  /**
3839
3867
  * The internal representation of the url.
3840
3868
  * @internal
@@ -3845,13 +3873,13 @@ class Url {
3845
3873
  * @param url The url string.
3846
3874
  */
3847
3875
  constructor(url) {
3848
- Guards.stringValue(Url._CLASS_NAME, "url", url);
3876
+ Guards.stringValue(Url.CLASS_NAME, "url", url);
3849
3877
  try {
3850
3878
  const u = new URL(url);
3851
3879
  this._urlParts = Url.fromURLToParts(u);
3852
3880
  }
3853
3881
  catch {
3854
- throw new GuardError(Url._CLASS_NAME, "guard.url", "url", url);
3882
+ throw new GuardError(Url.CLASS_NAME, "guard.url", "url", url);
3855
3883
  }
3856
3884
  }
3857
3885
  /**
@@ -3890,13 +3918,15 @@ class Url {
3890
3918
  * @param property Throw an exception if the url property is invalid.
3891
3919
  * @param value The url to parse.
3892
3920
  * @param failures The list of failures to add to.
3921
+ * @param fieldNameResource The optional human readable name for the field as an i18 resource.
3893
3922
  * @returns The formatted url.
3894
3923
  */
3895
- static validate(property, value, failures) {
3924
+ static validate(property, value, failures, fieldNameResource) {
3896
3925
  if (!Is.stringValue(value)) {
3897
3926
  failures.push({
3898
3927
  property,
3899
- reason: "validation.notEmpty"
3928
+ reason: "validation.beNotEmpty",
3929
+ properties: { fieldName: fieldNameResource ?? "validation.defaultFieldName", value }
3900
3930
  });
3901
3931
  return false;
3902
3932
  }
@@ -3904,7 +3934,8 @@ class Url {
3904
3934
  if (Is.undefined(result)) {
3905
3935
  failures.push({
3906
3936
  property,
3907
- reason: "validation.beUrl"
3937
+ reason: "validation.beUrl",
3938
+ properties: { fieldName: fieldNameResource ?? "validation.defaultFieldName", value }
3908
3939
  });
3909
3940
  return false;
3910
3941
  }
@@ -3970,9 +4001,8 @@ class Url {
3970
4001
  class Urn {
3971
4002
  /**
3972
4003
  * Runtime name for the class.
3973
- * @internal
3974
4004
  */
3975
- static _CLASS_NAME = "Urn";
4005
+ static CLASS_NAME = "Urn";
3976
4006
  /**
3977
4007
  * The specific part of the namespace.
3978
4008
  * @internal
@@ -3984,15 +4014,15 @@ class Urn {
3984
4014
  * @param namespaceSpecific The specific part of the namespace.
3985
4015
  */
3986
4016
  constructor(namespaceIdentifier, namespaceSpecific) {
3987
- Guards.stringValue(Urn._CLASS_NAME, "namespaceIdentifier", namespaceIdentifier);
4017
+ Guards.stringValue(Urn.CLASS_NAME, "namespaceIdentifier", namespaceIdentifier);
3988
4018
  // Strip leading and trailing colons
3989
4019
  this._urnParts = [this.stripColons(namespaceIdentifier)];
3990
4020
  if (Is.array(namespaceSpecific)) {
3991
- Guards.arrayValue(Urn._CLASS_NAME, "namespaceSpecific", namespaceSpecific);
4021
+ Guards.arrayValue(Urn.CLASS_NAME, "namespaceSpecific", namespaceSpecific);
3992
4022
  this._urnParts.push(...namespaceSpecific);
3993
4023
  }
3994
4024
  else {
3995
- Guards.stringValue(Urn._CLASS_NAME, "namespaceSpecific", namespaceSpecific);
4025
+ Guards.stringValue(Urn.CLASS_NAME, "namespaceSpecific", namespaceSpecific);
3996
4026
  this._urnParts.push(...this.stripColons(namespaceSpecific).split(":"));
3997
4027
  }
3998
4028
  }
@@ -4092,13 +4122,15 @@ class Urn {
4092
4122
  * @param property Throw an exception if the urn property is invalid.
4093
4123
  * @param value The urn to parse.
4094
4124
  * @param failures The list of failures to add to.
4125
+ * @param fieldNameResource The optional human readable name for the field as an i18 resource.
4095
4126
  * @returns The formatted urn.
4096
4127
  */
4097
- static validate(property, value, failures) {
4128
+ static validate(property, value, failures, fieldNameResource) {
4098
4129
  if (!Is.stringValue(value)) {
4099
4130
  failures.push({
4100
4131
  property,
4101
- reason: "validation.notEmpty"
4132
+ reason: "validation.beNotEmpty",
4133
+ properties: { fieldName: fieldNameResource ?? "validation.defaultFieldName", value }
4102
4134
  });
4103
4135
  return false;
4104
4136
  }
@@ -4106,7 +4138,8 @@ class Urn {
4106
4138
  if (Is.undefined(result)) {
4107
4139
  failures.push({
4108
4140
  property,
4109
- reason: "validation.beUrn"
4141
+ reason: "validation.beUrn",
4142
+ properties: { fieldName: fieldNameResource ?? "validation.defaultFieldName", value }
4110
4143
  });
4111
4144
  return false;
4112
4145
  }
@@ -4352,9 +4385,8 @@ class AsyncCache {
4352
4385
  class Compression {
4353
4386
  /**
4354
4387
  * Runtime name for the class.
4355
- * @internal
4356
4388
  */
4357
- static _CLASS_NAME = "Compression";
4389
+ static CLASS_NAME = "Compression";
4358
4390
  /**
4359
4391
  * Compress bytes using GZIP.
4360
4392
  * @param bytes The bytes to compress.
@@ -4362,8 +4394,8 @@ class Compression {
4362
4394
  * @returns The compressed bytes.
4363
4395
  */
4364
4396
  static async compress(bytes, type) {
4365
- Guards.uint8Array(Compression._CLASS_NAME, "bytes", bytes);
4366
- Guards.arrayOneOf(Compression._CLASS_NAME, "type", type, Object.values(CompressionType));
4397
+ Guards.uint8Array(Compression.CLASS_NAME, "bytes", bytes);
4398
+ Guards.arrayOneOf(Compression.CLASS_NAME, "type", type, Object.values(CompressionType));
4367
4399
  const blob = new Blob([new Uint8Array(bytes)]);
4368
4400
  const compressionStream = new CompressionStream(type);
4369
4401
  const compressionPipe = blob.stream().pipeThrough(compressionStream);
@@ -4384,8 +4416,8 @@ class Compression {
4384
4416
  * @returns The decompressed bytes.
4385
4417
  */
4386
4418
  static async decompress(compressedBytes, type) {
4387
- Guards.uint8Array(Compression._CLASS_NAME, "compressedBytes", compressedBytes);
4388
- Guards.arrayOneOf(Compression._CLASS_NAME, "type", type, Object.values(CompressionType));
4419
+ Guards.uint8Array(Compression.CLASS_NAME, "compressedBytes", compressedBytes);
4420
+ Guards.arrayOneOf(Compression.CLASS_NAME, "type", type, Object.values(CompressionType));
4389
4421
  const blob = new Blob([new Uint8Array(compressedBytes)]);
4390
4422
  const decompressionStream = new DecompressionStream(type);
4391
4423
  const decompressionPipe = blob.stream().pipeThrough(decompressionStream);
@@ -4414,8 +4446,7 @@ class Validation {
4414
4446
  failures.push({
4415
4447
  property,
4416
4448
  reason: "validation.beEmpty",
4417
- fieldName: fieldNameResource ?? "validation.defaultFieldName",
4418
- properties: { value }
4449
+ properties: { fieldName: fieldNameResource ?? "validation.defaultFieldName", value }
4419
4450
  });
4420
4451
  }
4421
4452
  return is;