@twin.org/core 0.0.3-next.4 → 0.0.3-next.40

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 (144) hide show
  1. package/README.md +1 -9
  2. package/dist/es/encoding/base32.js +1 -1
  3. package/dist/es/encoding/base32.js.map +1 -1
  4. package/dist/es/encoding/base64.js +1 -1
  5. package/dist/es/encoding/base64.js.map +1 -1
  6. package/dist/es/errors/alreadyExistsError.js +1 -1
  7. package/dist/es/errors/alreadyExistsError.js.map +1 -1
  8. package/dist/es/errors/baseError.js +1 -1
  9. package/dist/es/errors/baseError.js.map +1 -1
  10. package/dist/es/errors/conflictError.js +1 -1
  11. package/dist/es/errors/conflictError.js.map +1 -1
  12. package/dist/es/errors/generalError.js +1 -1
  13. package/dist/es/errors/generalError.js.map +1 -1
  14. package/dist/es/errors/guardError.js +1 -1
  15. package/dist/es/errors/guardError.js.map +1 -1
  16. package/dist/es/errors/notFoundError.js +1 -1
  17. package/dist/es/errors/notFoundError.js.map +1 -1
  18. package/dist/es/errors/notSupportedError.js +1 -1
  19. package/dist/es/errors/notSupportedError.js.map +1 -1
  20. package/dist/es/errors/unauthorizedError.js +2 -2
  21. package/dist/es/errors/unauthorizedError.js.map +1 -1
  22. package/dist/es/errors/unprocessableError.js +1 -1
  23. package/dist/es/errors/unprocessableError.js.map +1 -1
  24. package/dist/es/factories/factory.js +41 -0
  25. package/dist/es/factories/factory.js.map +1 -1
  26. package/dist/es/helpers/arrayHelper.js +2 -0
  27. package/dist/es/helpers/arrayHelper.js.map +1 -1
  28. package/dist/es/helpers/jsonHelper.js.map +1 -1
  29. package/dist/es/helpers/objectHelper.js +12 -36
  30. package/dist/es/helpers/objectHelper.js.map +1 -1
  31. package/dist/es/helpers/randomHelper.js +50 -2
  32. package/dist/es/helpers/randomHelper.js.map +1 -1
  33. package/dist/es/helpers/stringHelper.js +11 -0
  34. package/dist/es/helpers/stringHelper.js.map +1 -1
  35. package/dist/es/index.js +4 -1
  36. package/dist/es/index.js.map +1 -1
  37. package/dist/es/models/IComponent.js +0 -2
  38. package/dist/es/models/IComponent.js.map +1 -1
  39. package/dist/es/models/IError.js.map +1 -1
  40. package/dist/es/models/IHealth.js +2 -0
  41. package/dist/es/models/IHealth.js.map +1 -0
  42. package/dist/es/models/healthStatus.js +21 -0
  43. package/dist/es/models/healthStatus.js.map +1 -0
  44. package/dist/es/types/objectOrArray.js.map +1 -0
  45. package/dist/es/types/singleOccurrenceArray.js +2 -0
  46. package/dist/es/types/singleOccurrenceArray.js.map +1 -0
  47. package/dist/es/types/urn.js +1 -2
  48. package/dist/es/types/urn.js.map +1 -1
  49. package/dist/es/utils/asyncCache.js +102 -75
  50. package/dist/es/utils/asyncCache.js.map +1 -1
  51. package/dist/es/utils/guards.js +16 -0
  52. package/dist/es/utils/guards.js.map +1 -1
  53. package/dist/es/utils/i18n.js.map +1 -1
  54. package/dist/es/utils/is.js +16 -0
  55. package/dist/es/utils/is.js.map +1 -1
  56. package/dist/types/encoding/base32.d.ts +1 -1
  57. package/dist/types/errors/alreadyExistsError.d.ts +1 -1
  58. package/dist/types/errors/baseError.d.ts +1 -1
  59. package/dist/types/errors/conflictError.d.ts +1 -1
  60. package/dist/types/errors/generalError.d.ts +1 -1
  61. package/dist/types/errors/guardError.d.ts +1 -1
  62. package/dist/types/errors/notFoundError.d.ts +1 -1
  63. package/dist/types/errors/notSupportedError.d.ts +1 -1
  64. package/dist/types/errors/unauthorizedError.d.ts +2 -2
  65. package/dist/types/errors/unprocessableError.d.ts +1 -1
  66. package/dist/types/factories/factory.d.ts +23 -1
  67. package/dist/types/helpers/arrayHelper.d.ts +1 -8
  68. package/dist/types/helpers/objectHelper.d.ts +6 -16
  69. package/dist/types/helpers/randomHelper.d.ts +16 -0
  70. package/dist/types/helpers/stringHelper.d.ts +6 -0
  71. package/dist/types/index.d.ts +4 -1
  72. package/dist/types/models/IComponent.d.ts +12 -0
  73. package/dist/types/models/IError.d.ts +1 -1
  74. package/dist/types/models/IHealth.d.ts +32 -0
  75. package/dist/types/models/healthStatus.d.ts +21 -0
  76. package/dist/types/types/singleOccurrenceArray.d.ts +9 -0
  77. package/dist/types/utils/asyncCache.d.ts +7 -0
  78. package/dist/types/utils/guards.d.ts +10 -1
  79. package/dist/types/utils/is.d.ts +7 -0
  80. package/docs/changelog.md +870 -184
  81. package/docs/examples.md +308 -1
  82. package/docs/reference/classes/AlreadyExistsError.md +36 -36
  83. package/docs/reference/classes/ArrayHelper.md +10 -44
  84. package/docs/reference/classes/AsyncCache.md +8 -8
  85. package/docs/reference/classes/Base32.md +4 -4
  86. package/docs/reference/classes/Base58.md +3 -3
  87. package/docs/reference/classes/Base64.md +4 -4
  88. package/docs/reference/classes/Base64Url.md +3 -3
  89. package/docs/reference/classes/BaseError.md +35 -35
  90. package/docs/reference/classes/BitString.md +6 -6
  91. package/docs/reference/classes/Coerce.md +11 -11
  92. package/docs/reference/classes/Compression.md +3 -3
  93. package/docs/reference/classes/ConflictError.md +36 -36
  94. package/docs/reference/classes/Converter.md +18 -18
  95. package/docs/reference/classes/EnvHelper.md +1 -1
  96. package/docs/reference/classes/ErrorHelper.md +3 -3
  97. package/docs/reference/classes/Factory.md +112 -18
  98. package/docs/reference/classes/FilenameHelper.md +1 -1
  99. package/docs/reference/classes/GeneralError.md +36 -36
  100. package/docs/reference/classes/GuardError.md +36 -36
  101. package/docs/reference/classes/Guards.md +72 -30
  102. package/docs/reference/classes/HexHelper.md +6 -6
  103. package/docs/reference/classes/I18n.md +14 -14
  104. package/docs/reference/classes/Is.md +67 -39
  105. package/docs/reference/classes/JsonHelper.md +10 -10
  106. package/docs/reference/classes/NotFoundError.md +36 -36
  107. package/docs/reference/classes/NotImplementedError.md +35 -35
  108. package/docs/reference/classes/NotSupportedError.md +36 -36
  109. package/docs/reference/classes/NumberHelper.md +2 -2
  110. package/docs/reference/classes/ObjectHelper.md +49 -83
  111. package/docs/reference/classes/RandomHelper.md +53 -1
  112. package/docs/reference/classes/SharedStore.md +3 -3
  113. package/docs/reference/classes/StringHelper.md +45 -23
  114. package/docs/reference/classes/Uint8ArrayHelper.md +1 -1
  115. package/docs/reference/classes/UnauthorizedError.md +37 -37
  116. package/docs/reference/classes/UnprocessableError.md +36 -36
  117. package/docs/reference/classes/Url.md +8 -8
  118. package/docs/reference/classes/Urn.md +24 -24
  119. package/docs/reference/classes/Validation.md +25 -25
  120. package/docs/reference/classes/ValidationError.md +35 -35
  121. package/docs/reference/index.md +5 -0
  122. package/docs/reference/interfaces/IComponent.md +40 -4
  123. package/docs/reference/interfaces/IError.md +11 -11
  124. package/docs/reference/interfaces/IHealth.md +55 -0
  125. package/docs/reference/interfaces/II18nShared.md +4 -4
  126. package/docs/reference/interfaces/IKeyValue.md +2 -2
  127. package/docs/reference/interfaces/ILabelledValue.md +2 -2
  128. package/docs/reference/interfaces/ILocale.md +2 -2
  129. package/docs/reference/interfaces/ILocaleDictionary.md +1 -1
  130. package/docs/reference/interfaces/ILocalesIndex.md +1 -1
  131. package/docs/reference/interfaces/IPatchOperation.md +6 -6
  132. package/docs/reference/interfaces/IUrlParts.md +9 -9
  133. package/docs/reference/interfaces/IValidationFailure.md +4 -4
  134. package/docs/reference/type-aliases/HealthStatus.md +5 -0
  135. package/docs/reference/type-aliases/SingleOccurrenceArray.md +15 -0
  136. package/docs/reference/type-aliases/SingleOccurrenceArrayDepthHelper.md +19 -0
  137. package/docs/reference/variables/CoerceType.md +10 -10
  138. package/docs/reference/variables/CompressionType.md +2 -2
  139. package/docs/reference/variables/HealthStatus.md +25 -0
  140. package/locales/en.json +5 -2
  141. package/package.json +6 -6
  142. package/dist/es/models/objectOrArray.js.map +0 -1
  143. /package/dist/es/{models → types}/objectOrArray.js +0 -0
  144. /package/dist/types/{models → types}/objectOrArray.d.ts +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"is.js","sourceRoot":"","sources":["../../../src/utils/is.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACv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,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,KAAK,CAAC,KAAc;QACjC,OAAO,CACN,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC;YACrB,wHAAwH,CAAC,IAAI,CAC5H,KAAK,CACL,CACD,CAAC;IACH,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,OAAO,CAAc,KAAc;QAChD,yDAAyD;QACzD,gDAAgD;QAChD,OAAO,KAAK,YAAY,OAAO,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,MAAM,CAAC,KAAc;QAClC,wDAAwD;QACxD,gDAAgD;QAChD,OAAO,KAAK,YAAY,MAAM,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACH,8DAA8D;IACvD,MAAM,CAAC,KAAK,CAAc,GAAY;QAC5C,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE,CAAC;YAC/B,OAAO,KAAK,CAAC;QACd,CAAC;QACD,MAAM,GAAG,GAAG,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAClD,OAAO,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;CACD","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { HexHelper } from \"../helpers/hexHelper.js\";\n\n/**\n * Class to check types of objects.\n */\nexport class Is {\n\t/**\n\t * Is the property undefined.\n\t * @param value The value to test.\n\t * @returns True if the value is a empty.\n\t */\n\tpublic static undefined(value: unknown): value is undefined {\n\t\treturn value === undefined;\n\t}\n\n\t/**\n\t * Is the property null.\n\t * @param value The value to test.\n\t * @returns True if the value is a empty.\n\t */\n\tpublic static null(value: unknown): value is null {\n\t\treturn value === null;\n\t}\n\n\t/**\n\t * Is the property null or undefined.\n\t * @param value The value to test.\n\t * @returns True if the value is a empty.\n\t */\n\tpublic static empty(value: unknown): value is undefined | null {\n\t\treturn value === null || value === undefined;\n\t}\n\n\t/**\n\t * Is the property is not null or undefined.\n\t * @param value The value to test.\n\t * @returns True if the value is a not empty.\n\t */\n\tpublic static notEmpty(value: unknown): boolean {\n\t\treturn value !== null && value !== undefined;\n\t}\n\n\t/**\n\t * Is the value a string.\n\t * @param value The value to test.\n\t * @returns True if the value is a string.\n\t */\n\tpublic static string(value: unknown): value is string {\n\t\treturn typeof value === \"string\";\n\t}\n\n\t/**\n\t * Is the value a string.\n\t * @param value The value to test.\n\t * @returns True if the value is a string.\n\t */\n\tpublic static stringValue(value: unknown): value is string {\n\t\treturn Is.string(value) && value.trim().length > 0;\n\t}\n\n\t/**\n\t * Is the value a JSON string.\n\t * @param value The value to test.\n\t * @returns True if the value is a JSON string.\n\t */\n\tpublic static json(value: unknown): value is string {\n\t\tif (!Is.stringValue(value)) {\n\t\t\treturn false;\n\t\t}\n\n\t\ttry {\n\t\t\tconst json = JSON.parse(value);\n\t\t\treturn (\n\t\t\t\tIs.object(json) ||\n\t\t\t\tIs.array(json) ||\n\t\t\t\tIs.string(json) ||\n\t\t\t\tIs.number(json) ||\n\t\t\t\tIs.boolean(json) ||\n\t\t\t\tIs.null(json)\n\t\t\t);\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Is the value a base64 string.\n\t * @param value The value to test.\n\t * @returns True if the value is a base64 string.\n\t */\n\tpublic static stringBase64(value: unknown): value is string {\n\t\treturn (\n\t\t\tIs.stringValue(value) &&\n\t\t\t// eslint-disable-next-line unicorn/better-regex\n\t\t\t/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(value)\n\t\t);\n\t}\n\n\t/**\n\t * Is the value a base64 url string.\n\t * @param value The value to test.\n\t * @returns True if the value is a base64 string.\n\t */\n\tpublic static stringBase64Url(value: unknown): value is string {\n\t\treturn (\n\t\t\tIs.stringValue(value) &&\n\t\t\t// eslint-disable-next-line unicorn/better-regex\n\t\t\t/^([A-Za-z0-9-_])*$/.test(value)\n\t\t);\n\t}\n\n\t/**\n\t * Is the value a base58 string.\n\t * @param value The value to test.\n\t * @returns True if the value is a base58 string.\n\t */\n\tpublic static stringBase58(value: unknown): value is string {\n\t\treturn (\n\t\t\tIs.stringValue(value) &&\n\t\t\t// eslint-disable-next-line unicorn/better-regex\n\t\t\t/^[A-HJ-NP-Za-km-z1-9]*$/.test(value)\n\t\t);\n\t}\n\n\t/**\n\t * Is the value a hex string.\n\t * @param value The value to test.\n\t * @param allowPrefix Allow the hex to have the 0x prefix.\n\t * @returns True if the value is a hex string.\n\t */\n\tpublic static stringHex(value: unknown, allowPrefix: boolean = false): value is string {\n\t\treturn Is.string(value) && HexHelper.isHex(value, allowPrefix);\n\t}\n\n\t/**\n\t * Is the value a hex string of fixed length.\n\t * @param value The value to test.\n\t * @param length The length to test.\n\t * @param allowPrefix Allow the hex to have the 0x prefix.\n\t * @returns True if the value is a hex string of required length.\n\t */\n\tpublic static stringHexLength(\n\t\tvalue: unknown,\n\t\tlength: number,\n\t\tallowPrefix: boolean = false\n\t): value is string {\n\t\treturn Is.stringHex(value, allowPrefix) && value.length === length;\n\t}\n\n\t/**\n\t * Is the value a number.\n\t * @param value The value to test.\n\t * @returns True if the value is a number.\n\t */\n\tpublic static number(value: unknown): value is number {\n\t\treturn typeof value === \"number\" && Number.isFinite(value) && !Number.isNaN(value);\n\t}\n\n\t/**\n\t * Is the value an integer.\n\t * @param value The value to test.\n\t * @returns True if the value is an integer.\n\t */\n\tpublic static integer(value: unknown): value is number {\n\t\treturn Is.number(value) && Number.isInteger(value);\n\t}\n\n\t/**\n\t * Is the value a big integer.\n\t * @param value The value to test.\n\t * @returns True if the value is a big integer.\n\t */\n\tpublic static bigint(value: unknown): value is bigint {\n\t\treturn typeof value === \"bigint\";\n\t}\n\n\t/**\n\t * Is the value a boolean.\n\t * @param value The value to test.\n\t * @returns True if the value is a boolean.\n\t */\n\tpublic static boolean(value: unknown): value is boolean {\n\t\treturn typeof value === \"boolean\";\n\t}\n\n\t/**\n\t * Is the value a date.\n\t * @param value The value to test.\n\t * @returns True if the value is a date.\n\t */\n\tpublic static date(value: unknown): value is Date {\n\t\treturn (\n\t\t\tObject.prototype.toString.call(value) === \"[object Date]\" &&\n\t\t\t!Number.isNaN((value as Date).getTime())\n\t\t);\n\t}\n\n\t/**\n\t * Is the value an empty date.\n\t * @param value The value to test.\n\t * @returns True if the value is an empty date.\n\t */\n\tpublic static dateEmpty(value: unknown): boolean {\n\t\treturn (\n\t\t\tObject.prototype.toString.call(value) === \"[object Date]\" &&\n\t\t\tNumber.isNaN((value as Date).getTime())\n\t\t);\n\t}\n\n\t/**\n\t * Is the value a date string.\n\t * @param value The value to test.\n\t * @returns True if the value is a string in ISO 8601 date format.\n\t */\n\tpublic static dateString(value: unknown): boolean {\n\t\tif (typeof value !== \"string\" || value.length === 0 || value.includes(\"T\")) {\n\t\t\treturn false;\n\t\t}\n\t\treturn !Number.isNaN(Date.parse(value));\n\t}\n\n\t/**\n\t * Is the value a date string.\n\t * @param value The value to test.\n\t * @returns True if the value is a string in ISO 8601 date/time format.\n\t */\n\tpublic static dateTimeString(value: unknown): boolean {\n\t\tif (typeof value !== \"string\" || value.length === 0 || !value.includes(\"T\")) {\n\t\t\treturn false;\n\t\t}\n\t\treturn !Number.isNaN(Date.parse(value));\n\t}\n\n\t/**\n\t * Is the value a time string.\n\t * @param value The value to test.\n\t * @returns True if the value is a string in ISO 8601 time format.\n\t */\n\tpublic static timeString(value: unknown): boolean {\n\t\tif (typeof value !== \"string\" || value.length === 0 || value.includes(\"T\")) {\n\t\t\treturn false;\n\t\t}\n\t\treturn !Number.isNaN(Date.parse(`1970-01-01T${value}`));\n\t}\n\n\t/**\n\t * Is the value a timestamp in seconds.\n\t * @param value The value to test.\n\t * @returns True if the value is a date.\n\t */\n\tpublic static timestampSeconds(value: unknown): value is number {\n\t\tif (!Is.integer(value)) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn value.toString().length < 12;\n\t}\n\n\t/**\n\t * Is the value a timestamp in milliseconds.\n\t * @param value The value to test.\n\t * @returns True if the value is a date.\n\t */\n\tpublic static timestampMilliseconds(value: unknown): value is number {\n\t\tif (!Is.integer(value)) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn value.toString().length >= 12;\n\t}\n\n\t/**\n\t * Is the value an object.\n\t * @param value The value to test.\n\t * @returns True if the value is a object.\n\t */\n\tpublic static object<T = { [id: string]: unknown }>(value: unknown): value is T {\n\t\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n\t}\n\n\t/**\n\t * Is the value an object with at least one property.\n\t * @param value The value to test.\n\t * @returns True if the value is a object.\n\t */\n\tpublic static objectValue<T = { [id: string]: unknown }>(value: unknown): value is T {\n\t\treturn (\n\t\t\ttypeof value === \"object\" &&\n\t\t\tvalue !== null &&\n\t\t\t!Array.isArray(value) &&\n\t\t\tObject.keys(value).length > 0\n\t\t);\n\t}\n\n\t/**\n\t * Is the value an array.\n\t * @param value The value to test.\n\t * @returns True if the value is an array.\n\t */\n\tpublic static array<T>(value: unknown): value is T[] {\n\t\treturn Array.isArray(value);\n\t}\n\n\t/**\n\t * Is the value an array with at least one element.\n\t * @param value The value to test.\n\t * @returns True if the value is an array with at least one element.\n\t */\n\tpublic static arrayValue<T>(value: unknown): value is T[] {\n\t\treturn Array.isArray(value) && value.length > 0;\n\t}\n\n\t/**\n\t * Is the value an array with at least one element.\n\t * @param value The value to test.\n\t * @param options The options the value must be one of.\n\t * @returns True if the value is an element from the options array.\n\t */\n\tpublic static arrayOneOf<T>(value: T, options: T[]): value is T {\n\t\tif (Is.empty(value) || !Is.array<T>(options) || !options.includes(value)) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Is the value a Uint8Array.\n\t * @param value The value to test.\n\t * @returns True if the value is a Uint8Array.\n\t */\n\tpublic static uint8Array(value: unknown): value is Uint8Array {\n\t\t// This is the only way we can reliably check for Uint8Array\n\t\t// eslint-disable-next-line no-restricted-syntax\n\t\treturn value instanceof Uint8Array;\n\t}\n\n\t/**\n\t * Is the value a TypedArray.\n\t * @param value The value to test.\n\t * @returns True if the value is a TypedArray.\n\t */\n\tpublic static typedArray(\n\t\tvalue: unknown\n\t): value is\n\t\t| Uint8Array\n\t\t| Int8Array\n\t\t| Uint16Array\n\t\t| Int16Array\n\t\t| Uint32Array\n\t\t| Int32Array\n\t\t| Float32Array\n\t\t| Float64Array {\n\t\t// This is the only way we can reliably check for TypedArray\n\t\t// eslint-disable-next-line no-restricted-syntax\n\t\treturn value instanceof Object.getPrototypeOf(Uint8Array);\n\t}\n\n\t/**\n\t * Is the property a function.\n\t * @param value The value to test.\n\t * @returns True if the value is a function.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic static function<T extends (...args: any[]) => any = (...args: any[]) => any>(\n\t\tvalue: unknown\n\t): value is T {\n\t\treturn typeof value === \"function\";\n\t}\n\n\t/**\n\t * Is the value a string formatted as an email address.\n\t * @param value The value to test.\n\t * @returns True if the value is a string.\n\t */\n\tpublic static email(value: unknown): value is string {\n\t\treturn (\n\t\t\tIs.stringValue(value) &&\n\t\t\t/^[\\w!#$%&'*+./=?^`{|}~-]+@[\\dA-Za-z](?:[\\dA-Za-z-]{0,61}[\\dA-Za-z])?(?:\\.[\\dA-Za-z](?:[\\dA-Za-z-]{0,61}[\\dA-Za-z])?)*$/.test(\n\t\t\t\tvalue\n\t\t\t)\n\t\t);\n\t}\n\n\t/**\n\t * Is the value a promise.\n\t * @param value The value to test.\n\t * @returns True if the value is a promise.\n\t */\n\tpublic static promise<T = unknown>(value: unknown): value is Promise<T> {\n\t\t// This is the only way we can reliably check for Promise\n\t\t// eslint-disable-next-line no-restricted-syntax\n\t\treturn value instanceof Promise;\n\t}\n\n\t/**\n\t * Is the value a regexp.\n\t * @param value The value to test.\n\t * @returns True if the value is a regexp.\n\t */\n\tpublic static regexp(value: unknown): value is RegExp {\n\t\t// This is the only way we can reliably check for RegExp\n\t\t// eslint-disable-next-line no-restricted-syntax\n\t\treturn value instanceof RegExp;\n\t}\n\n\t/**\n\t * Is the provided object a class constructor.\n\t * @param obj The object to check.\n\t * @returns True if the object is a class, false otherwise.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic static class<T = unknown>(obj: unknown): obj is new (...args: any[]) => T {\n\t\tif (typeof obj !== \"function\") {\n\t\t\treturn false;\n\t\t}\n\t\tconst str = Function.prototype.toString.call(obj);\n\t\treturn /^class\\s/.test(str);\n\t}\n}\n"]}
1
+ {"version":3,"file":"is.js","sourceRoot":"","sources":["../../../src/utils/is.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD;;GAEG;AACH,MAAM,OAAO,EAAE;IACd;;;;OAIG;IACI,MAAM,CAAC,SAAS,CAAC,KAAc;QACrC,OAAO,KAAK,KAAK,SAAS,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,IAAI,CAAC,KAAc;QAChC,OAAO,KAAK,KAAK,IAAI,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,KAAK,CAAC,KAAc;QACjC,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC;IAC9C,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,QAAQ,CAAC,KAAc;QACpC,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC;IAC9C,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,MAAM,CAAC,KAAc;QAClC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,WAAW,CAAC,KAAc;QACvC,OAAO,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;IACpD,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A+B;QACnE,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YAC1B,uBAAuB;YACvB,kDAAkD;YAClD,2DAA2D;YAC3D,OAAO,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,4CAA4C,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1F,CAAC;QAED,OAAO,CACN,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC;YACrB,mEAAmE,CAAC,IAAI,CAAC,KAAK,CAAC,CAC/E,CAAC;IACH,CAAC;CACD","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { HexHelper } from \"../helpers/hexHelper.js\";\n\n/**\n * Class to check types of objects.\n */\nexport class Is {\n\t/**\n\t * Is the property undefined.\n\t * @param value The value to test.\n\t * @returns True if the value is a empty.\n\t */\n\tpublic static undefined(value: unknown): value is undefined {\n\t\treturn value === undefined;\n\t}\n\n\t/**\n\t * Is the property null.\n\t * @param value The value to test.\n\t * @returns True if the value is a empty.\n\t */\n\tpublic static null(value: unknown): value is null {\n\t\treturn value === null;\n\t}\n\n\t/**\n\t * Is the property null or undefined.\n\t * @param value The value to test.\n\t * @returns True if the value is a empty.\n\t */\n\tpublic static empty(value: unknown): value is undefined | null {\n\t\treturn value === null || value === undefined;\n\t}\n\n\t/**\n\t * Is the property is not null or undefined.\n\t * @param value The value to test.\n\t * @returns True if the value is a not empty.\n\t */\n\tpublic static notEmpty(value: unknown): boolean {\n\t\treturn value !== null && value !== undefined;\n\t}\n\n\t/**\n\t * Is the value a string.\n\t * @param value The value to test.\n\t * @returns True if the value is a string.\n\t */\n\tpublic static string(value: unknown): value is string {\n\t\treturn typeof value === \"string\";\n\t}\n\n\t/**\n\t * Is the value a string.\n\t * @param value The value to test.\n\t * @returns True if the value is a string.\n\t */\n\tpublic static stringValue(value: unknown): value is string {\n\t\treturn Is.string(value) && value.trim().length > 0;\n\t}\n\n\t/**\n\t * Is the value a JSON string.\n\t * @param value The value to test.\n\t * @returns True if the value is a JSON string.\n\t */\n\tpublic static json(value: unknown): value is string {\n\t\tif (!Is.stringValue(value)) {\n\t\t\treturn false;\n\t\t}\n\n\t\ttry {\n\t\t\tconst json = JSON.parse(value);\n\t\t\treturn (\n\t\t\t\tIs.object(json) ||\n\t\t\t\tIs.array(json) ||\n\t\t\t\tIs.string(json) ||\n\t\t\t\tIs.number(json) ||\n\t\t\t\tIs.boolean(json) ||\n\t\t\t\tIs.null(json)\n\t\t\t);\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Is the value a base64 string.\n\t * @param value The value to test.\n\t * @returns True if the value is a base64 string.\n\t */\n\tpublic static stringBase64(value: unknown): value is string {\n\t\treturn (\n\t\t\tIs.stringValue(value) &&\n\t\t\t// eslint-disable-next-line unicorn/better-regex\n\t\t\t/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(value)\n\t\t);\n\t}\n\n\t/**\n\t * Is the value a base64 url string.\n\t * @param value The value to test.\n\t * @returns True if the value is a base64 string.\n\t */\n\tpublic static stringBase64Url(value: unknown): value is string {\n\t\treturn (\n\t\t\tIs.stringValue(value) &&\n\t\t\t// eslint-disable-next-line unicorn/better-regex\n\t\t\t/^([A-Za-z0-9-_])*$/.test(value)\n\t\t);\n\t}\n\n\t/**\n\t * Is the value a base58 string.\n\t * @param value The value to test.\n\t * @returns True if the value is a base58 string.\n\t */\n\tpublic static stringBase58(value: unknown): value is string {\n\t\treturn (\n\t\t\tIs.stringValue(value) &&\n\t\t\t// eslint-disable-next-line unicorn/better-regex\n\t\t\t/^[A-HJ-NP-Za-km-z1-9]*$/.test(value)\n\t\t);\n\t}\n\n\t/**\n\t * Is the value a hex string.\n\t * @param value The value to test.\n\t * @param allowPrefix Allow the hex to have the 0x prefix.\n\t * @returns True if the value is a hex string.\n\t */\n\tpublic static stringHex(value: unknown, allowPrefix: boolean = false): value is string {\n\t\treturn Is.string(value) && HexHelper.isHex(value, allowPrefix);\n\t}\n\n\t/**\n\t * Is the value a hex string of fixed length.\n\t * @param value The value to test.\n\t * @param length The length to test.\n\t * @param allowPrefix Allow the hex to have the 0x prefix.\n\t * @returns True if the value is a hex string of required length.\n\t */\n\tpublic static stringHexLength(\n\t\tvalue: unknown,\n\t\tlength: number,\n\t\tallowPrefix: boolean = false\n\t): value is string {\n\t\treturn Is.stringHex(value, allowPrefix) && value.length === length;\n\t}\n\n\t/**\n\t * Is the value a number.\n\t * @param value The value to test.\n\t * @returns True if the value is a number.\n\t */\n\tpublic static number(value: unknown): value is number {\n\t\treturn typeof value === \"number\" && Number.isFinite(value) && !Number.isNaN(value);\n\t}\n\n\t/**\n\t * Is the value an integer.\n\t * @param value The value to test.\n\t * @returns True if the value is an integer.\n\t */\n\tpublic static integer(value: unknown): value is number {\n\t\treturn Is.number(value) && Number.isInteger(value);\n\t}\n\n\t/**\n\t * Is the value a big integer.\n\t * @param value The value to test.\n\t * @returns True if the value is a big integer.\n\t */\n\tpublic static bigint(value: unknown): value is bigint {\n\t\treturn typeof value === \"bigint\";\n\t}\n\n\t/**\n\t * Is the value a boolean.\n\t * @param value The value to test.\n\t * @returns True if the value is a boolean.\n\t */\n\tpublic static boolean(value: unknown): value is boolean {\n\t\treturn typeof value === \"boolean\";\n\t}\n\n\t/**\n\t * Is the value a date.\n\t * @param value The value to test.\n\t * @returns True if the value is a date.\n\t */\n\tpublic static date(value: unknown): value is Date {\n\t\treturn (\n\t\t\tObject.prototype.toString.call(value) === \"[object Date]\" &&\n\t\t\t!Number.isNaN((value as Date).getTime())\n\t\t);\n\t}\n\n\t/**\n\t * Is the value an empty date.\n\t * @param value The value to test.\n\t * @returns True if the value is an empty date.\n\t */\n\tpublic static dateEmpty(value: unknown): boolean {\n\t\treturn (\n\t\t\tObject.prototype.toString.call(value) === \"[object Date]\" &&\n\t\t\tNumber.isNaN((value as Date).getTime())\n\t\t);\n\t}\n\n\t/**\n\t * Is the value a date string.\n\t * @param value The value to test.\n\t * @returns True if the value is a string in ISO 8601 date format.\n\t */\n\tpublic static dateString(value: unknown): boolean {\n\t\tif (typeof value !== \"string\" || value.length === 0 || value.includes(\"T\")) {\n\t\t\treturn false;\n\t\t}\n\t\treturn !Number.isNaN(Date.parse(value));\n\t}\n\n\t/**\n\t * Is the value a date string.\n\t * @param value The value to test.\n\t * @returns True if the value is a string in ISO 8601 date/time format.\n\t */\n\tpublic static dateTimeString(value: unknown): boolean {\n\t\tif (typeof value !== \"string\" || value.length === 0 || !value.includes(\"T\")) {\n\t\t\treturn false;\n\t\t}\n\t\treturn !Number.isNaN(Date.parse(value));\n\t}\n\n\t/**\n\t * Is the value a time string.\n\t * @param value The value to test.\n\t * @returns True if the value is a string in ISO 8601 time format.\n\t */\n\tpublic static timeString(value: unknown): boolean {\n\t\tif (typeof value !== \"string\" || value.length === 0 || value.includes(\"T\")) {\n\t\t\treturn false;\n\t\t}\n\t\treturn !Number.isNaN(Date.parse(`1970-01-01T${value}`));\n\t}\n\n\t/**\n\t * Is the value a timestamp in seconds.\n\t * @param value The value to test.\n\t * @returns True if the value is a date.\n\t */\n\tpublic static timestampSeconds(value: unknown): value is number {\n\t\tif (!Is.integer(value)) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn value.toString().length < 12;\n\t}\n\n\t/**\n\t * Is the value a timestamp in milliseconds.\n\t * @param value The value to test.\n\t * @returns True if the value is a date.\n\t */\n\tpublic static timestampMilliseconds(value: unknown): value is number {\n\t\tif (!Is.integer(value)) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn value.toString().length >= 12;\n\t}\n\n\t/**\n\t * Is the value an object.\n\t * @param value The value to test.\n\t * @returns True if the value is a object.\n\t */\n\tpublic static object<T = { [id: string]: unknown }>(value: unknown): value is T {\n\t\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n\t}\n\n\t/**\n\t * Is the value an object with at least one property.\n\t * @param value The value to test.\n\t * @returns True if the value is a object.\n\t */\n\tpublic static objectValue<T = { [id: string]: unknown }>(value: unknown): value is T {\n\t\treturn (\n\t\t\ttypeof value === \"object\" &&\n\t\t\tvalue !== null &&\n\t\t\t!Array.isArray(value) &&\n\t\t\tObject.keys(value).length > 0\n\t\t);\n\t}\n\n\t/**\n\t * Is the value an array.\n\t * @param value The value to test.\n\t * @returns True if the value is an array.\n\t */\n\tpublic static array<T>(value: unknown): value is T[] {\n\t\treturn Array.isArray(value);\n\t}\n\n\t/**\n\t * Is the value an array with at least one element.\n\t * @param value The value to test.\n\t * @returns True if the value is an array with at least one element.\n\t */\n\tpublic static arrayValue<T>(value: unknown): value is T[] {\n\t\treturn Array.isArray(value) && value.length > 0;\n\t}\n\n\t/**\n\t * Is the value an array with at least one element.\n\t * @param value The value to test.\n\t * @param options The options the value must be one of.\n\t * @returns True if the value is an element from the options array.\n\t */\n\tpublic static arrayOneOf<T>(value: T, options: T[]): value is T {\n\t\tif (Is.empty(value) || !Is.array<T>(options) || !options.includes(value)) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Is the value a Uint8Array.\n\t * @param value The value to test.\n\t * @returns True if the value is a Uint8Array.\n\t */\n\tpublic static uint8Array(value: unknown): value is Uint8Array {\n\t\t// This is the only way we can reliably check for Uint8Array\n\t\t// eslint-disable-next-line no-restricted-syntax\n\t\treturn value instanceof Uint8Array;\n\t}\n\n\t/**\n\t * Is the value a TypedArray.\n\t * @param value The value to test.\n\t * @returns True if the value is a TypedArray.\n\t */\n\tpublic static typedArray(\n\t\tvalue: unknown\n\t): value is\n\t\t| Uint8Array\n\t\t| Int8Array\n\t\t| Uint16Array\n\t\t| Int16Array\n\t\t| Uint32Array\n\t\t| Int32Array\n\t\t| Float32Array\n\t\t| Float64Array {\n\t\t// This is the only way we can reliably check for TypedArray\n\t\t// eslint-disable-next-line no-restricted-syntax\n\t\treturn value instanceof Object.getPrototypeOf(Uint8Array);\n\t}\n\n\t/**\n\t * Is the property a function.\n\t * @param value The value to test.\n\t * @returns True if the value is a function.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic static function<T extends (...args: any[]) => any = (...args: any[]) => any>(\n\t\tvalue: unknown\n\t): value is T {\n\t\treturn typeof value === \"function\";\n\t}\n\n\t/**\n\t * Is the value a string formatted as an email address.\n\t * @param value The value to test.\n\t * @returns True if the value is a string.\n\t */\n\tpublic static email(value: unknown): value is string {\n\t\treturn (\n\t\t\tIs.stringValue(value) &&\n\t\t\t/^[\\w!#$%&'*+./=?^`{|}~-]+@[\\dA-Za-z](?:[\\dA-Za-z-]{0,61}[\\dA-Za-z])?(?:\\.[\\dA-Za-z](?:[\\dA-Za-z-]{0,61}[\\dA-Za-z])?)*$/.test(\n\t\t\t\tvalue\n\t\t\t)\n\t\t);\n\t}\n\n\t/**\n\t * Is the value a promise.\n\t * @param value The value to test.\n\t * @returns True if the value is a promise.\n\t */\n\tpublic static promise<T = unknown>(value: unknown): value is Promise<T> {\n\t\t// This is the only way we can reliably check for Promise\n\t\t// eslint-disable-next-line no-restricted-syntax\n\t\treturn value instanceof Promise;\n\t}\n\n\t/**\n\t * Is the value a regexp.\n\t * @param value The value to test.\n\t * @returns True if the value is a regexp.\n\t */\n\tpublic static regexp(value: unknown): value is RegExp {\n\t\t// This is the only way we can reliably check for RegExp\n\t\t// eslint-disable-next-line no-restricted-syntax\n\t\treturn value instanceof RegExp;\n\t}\n\n\t/**\n\t * Is the provided object a class constructor.\n\t * @param obj The object to check.\n\t * @returns True if the object is a class, false otherwise.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic static class<T = unknown>(obj: unknown): obj is new (...args: any[]) => T {\n\t\tif (typeof obj !== \"function\") {\n\t\t\treturn false;\n\t\t}\n\t\tconst str = Function.prototype.toString.call(obj);\n\t\treturn /^class\\s/.test(str);\n\t}\n\n\t/**\n\t * Is the value a uuidV7 string.\n\t * @param value The value to test.\n\t * @param format The format of the UUIDv7 string.\n\t * @returns True if the value is a uuidV7 string.\n\t */\n\tpublic static uuidV7(value: unknown, format?: \"standard\" | \"compact\"): value is string {\n\t\tif (format === \"compact\") {\n\t\t\t// 32 hex chars, where:\n\t\t\t// - char 13 (0-based index 12) is the version (7)\n\t\t\t// - char 17 (0-based index 16) is the variant (8, 9, a, b)\n\t\t\treturn Is.stringValue(value) && /^[\\da-f]{12}7[\\da-f]{3}[89ab][\\da-f]{15}$/i.test(value);\n\t\t}\n\n\t\treturn (\n\t\t\tIs.stringValue(value) &&\n\t\t\t/^[\\da-f]{8}-[\\da-f]{4}-7[\\da-f]{3}-[89ab][\\da-f]{3}-[\\da-f]{12}$/i.test(value)\n\t\t);\n\t}\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Class to help with base63 Encoding/Decoding.
2
+ * Class to help with base32 Encoding/Decoding.
3
3
  */
4
4
  export declare class Base32 {
5
5
  /**
@@ -10,7 +10,7 @@ export declare class AlreadyExistsError extends BaseError {
10
10
  /**
11
11
  * Create a new instance of AlreadyExistsError.
12
12
  * @param source The source of the error.
13
- * @param message The message as a code.
13
+ * @param message The message as an i18n key.
14
14
  * @param existingId The id for the item.
15
15
  * @param properties Any additional information for the error.
16
16
  * @param cause The cause of the error if we have wrapped another error.
@@ -21,7 +21,7 @@ export declare class BaseError extends Error implements IError {
21
21
  * Create a new instance of BaseError.
22
22
  * @param name The name of the error.
23
23
  * @param source The source of the error.
24
- * @param message The message as a code.
24
+ * @param message The message as an i18n key.
25
25
  * @param properties Any additional information for the error.
26
26
  * @param cause The cause of error if we have wrapped another error.
27
27
  */
@@ -10,7 +10,7 @@ export declare class ConflictError extends BaseError {
10
10
  /**
11
11
  * Create a new instance of ConflictError.
12
12
  * @param source The source of the error.
13
- * @param message The message as a code.
13
+ * @param message The message as an i18n key.
14
14
  * @param conflictId The id that has conflicts.
15
15
  * @param conflicts The conflicts that occurred.
16
16
  * @param properties Any additional information for the error.
@@ -10,7 +10,7 @@ export declare class GeneralError extends BaseError {
10
10
  /**
11
11
  * Create a new instance of GeneralError.
12
12
  * @param source The source of the error.
13
- * @param message The message as a code.
13
+ * @param message The message as an i18n key.
14
14
  * @param properties Any additional information for the error.
15
15
  * @param cause The cause of the error if we have wrapped another error.
16
16
  */
@@ -10,7 +10,7 @@ export declare class GuardError extends BaseError {
10
10
  /**
11
11
  * Create a new instance of GuardError.
12
12
  * @param source The source of the error.
13
- * @param message The message as a code.
13
+ * @param message The message as an i18n key.
14
14
  * @param propertyName The property which triggered the guard error for the item.
15
15
  * @param propertyValue The property value which triggered the guard error for the item.
16
16
  * @param propertyOptions The property options which might be allowed.
@@ -10,7 +10,7 @@ export declare class NotFoundError extends BaseError {
10
10
  /**
11
11
  * Create a new instance of NotFoundError.
12
12
  * @param source The source of the error.
13
- * @param message The message as a code.
13
+ * @param message The message as an i18n key.
14
14
  * @param notFoundId The id for the item.
15
15
  * @param properties Any additional information for the error.
16
16
  * @param cause The cause of the error if we have wrapped another error.
@@ -10,7 +10,7 @@ export declare class NotSupportedError extends BaseError {
10
10
  /**
11
11
  * Create a new instance of NotSupportedError.
12
12
  * @param source The source of the error.
13
- * @param message The message as a code.
13
+ * @param message The message as an i18n key.
14
14
  * @param properties Any additional information for the error.
15
15
  * @param cause The cause of the error if we have wrapped another error.
16
16
  */
@@ -1,6 +1,6 @@
1
1
  import { BaseError } from "./baseError.js";
2
2
  /**
3
- * Class to handle errors which are triggered by access not being unauthorized.
3
+ * Class to handle errors which are triggered by access not being authorized.
4
4
  */
5
5
  export declare class UnauthorizedError extends BaseError {
6
6
  /**
@@ -10,7 +10,7 @@ export declare class UnauthorizedError extends BaseError {
10
10
  /**
11
11
  * Create a new instance of UnauthorizedError.
12
12
  * @param source The source of the error.
13
- * @param message The message as a code.
13
+ * @param message The message as an i18n key.
14
14
  * @param properties Any additional information for the error.
15
15
  * @param cause The cause of the error if we have wrapped another error.
16
16
  */
@@ -10,7 +10,7 @@ export declare class UnprocessableError extends BaseError {
10
10
  /**
11
11
  * Create a new instance of UnprocessableError.
12
12
  * @param source The source of the error.
13
- * @param message The message as a code.
13
+ * @param message The message as an i18n key.
14
14
  * @param properties Any additional information for the error.
15
15
  * @param cause The cause of the error if we have wrapped another error.
16
16
  */
@@ -29,12 +29,17 @@ export declare class Factory<T> {
29
29
  * Clear all the factories, which removes anything registered with the factories.
30
30
  */
31
31
  static clearFactories(): void;
32
+ /**
33
+ * Get the type name of the factory.
34
+ * @returns The type name of the factory.
35
+ */
36
+ typeName(): string;
32
37
  /**
33
38
  * Register a new generator.
34
39
  * @param name The name of the generator.
35
40
  * @param generator The function to create an instance.
36
41
  */
37
- register<U extends T>(name: string, generator: () => U): void;
42
+ register<U extends T>(name: string, generator: (args?: unknown) => U): void;
38
43
  /**
39
44
  * Unregister a generator.
40
45
  * @param name The name of the generator to unregister.
@@ -56,6 +61,23 @@ export declare class Factory<T> {
56
61
  * @returns An instance of the item or undefined if it does not exist.
57
62
  */
58
63
  getIfExists<U extends T>(name?: string): U | undefined;
64
+ /**
65
+ * Create a new instance without caching it.
66
+ * @param name The name of the instance to generate.
67
+ * @param args The arguments to pass to the generator.
68
+ * @returns A new instance of the item.
69
+ * @throws GuardError if the parameters are invalid.
70
+ * @throws GeneralError if no item exists to create.
71
+ */
72
+ create<U extends T>(name: string, args?: unknown): U;
73
+ /**
74
+ * Create a new instance without caching it if it exists.
75
+ * @param name The name of the instance to generate.
76
+ * @param args The arguments to pass to the generator.
77
+ * @returns A new instance of the item if it exists.
78
+ * @throws GuardError if the parameters are invalid.
79
+ */
80
+ createIfExists<U extends T>(name: string, args?: unknown): U | undefined;
59
81
  /**
60
82
  * Remove all the instances and leave the generators intact.
61
83
  */
@@ -1,4 +1,3 @@
1
- import type { ObjectOrArray } from "../models/objectOrArray.js";
2
1
  /**
3
2
  * Class to help with arrays.
4
3
  */
@@ -15,11 +14,5 @@ export declare class ArrayHelper {
15
14
  * @param value The object or array to convert.
16
15
  * @returns The array.
17
16
  */
18
- static fromObjectOrArray<T = unknown>(value: undefined): undefined;
19
- /**
20
- * Convert an object or array to an array.
21
- * @param value The object or array to convert.
22
- * @returns The array.
23
- */
24
- static fromObjectOrArray<T = unknown>(value: ObjectOrArray<T>): T[];
17
+ static fromObjectOrArray<T = unknown>(value: T | T[] | undefined): T extends undefined ? undefined : T[];
25
18
  }
@@ -58,8 +58,8 @@ export declare class ObjectHelper {
58
58
  static propertySet(obj: unknown, property: string, value: unknown): void;
59
59
  /**
60
60
  * Delete the property of an unknown object.
61
- * @param obj The object to set the property from.
62
- * @param property The property to set
61
+ * @param obj The object to delete the property from.
62
+ * @param property The property to delete.
63
63
  */
64
64
  static propertyDelete(obj: unknown, property: string): void;
65
65
  /**
@@ -74,26 +74,16 @@ export declare class ObjectHelper {
74
74
  * Pick a subset of properties from an object.
75
75
  * @param obj The object to pick the properties from.
76
76
  * @param keys The property keys to pick.
77
- * @returns The partial object.
77
+ * @returns The picked object, or undefined if the input was undefined.
78
78
  */
79
- static pick<T>(obj: T | undefined, keys?: (keyof T)[]): Partial<T>;
79
+ static pick<T extends object, K extends keyof T>(obj: T | undefined, keys: readonly K[]): T extends undefined ? undefined : Pick<T, K>;
80
80
  /**
81
81
  * Omit a subset of properties from an object.
82
82
  * @param obj The object to omit the properties from.
83
83
  * @param keys The property keys to omit.
84
- * @returns The partial object.
85
- */
86
- static omit<T>(obj: T | undefined, keys?: (keyof T)[]): Partial<T>;
87
- /**
88
- * Split an object into two with the specified keys.
89
- * @param obj The object to split.
90
- * @param keys The property keys to split.
91
- * @returns The two partial objects.
84
+ * @returns The object without the omitted keys, or undefined if the input was undefined.
92
85
  */
93
- static split<T>(obj: T | undefined, keys?: (keyof T)[]): {
94
- picked: Partial<T> | undefined;
95
- omitted: Partial<T> | undefined;
96
- };
86
+ static omit<T, K extends keyof T>(obj: T | undefined, keys: readonly K[]): T extends undefined ? undefined : Omit<T, K>;
97
87
  /**
98
88
  * Converter the non JSON primitives to extended types.
99
89
  * @param obj The object to convert.
@@ -2,10 +2,26 @@
2
2
  * Class to help with random generation.
3
3
  */
4
4
  export declare class RandomHelper {
5
+ /**
6
+ * Runtime name for the class.
7
+ */
8
+ static readonly CLASS_NAME: string;
5
9
  /**
6
10
  * Generate a new random array.
7
11
  * @param length The length of buffer to create.
8
12
  * @returns The random array.
9
13
  */
10
14
  static generate(length: number): Uint8Array;
15
+ /**
16
+ * Generate a new UUIDv7.
17
+ * @param format The format of the UUIDv7 string.
18
+ * @returns The UUIDv7 string.
19
+ */
20
+ static generateUuidV7(format?: "standard" | "compact"): string;
21
+ /**
22
+ * Extract the unix timestamp (ms) from a UUIDv7.
23
+ * @param uuid The UUIDv7 string.
24
+ * @returns The unix timestamp in milliseconds.
25
+ */
26
+ static uuidV7ExtractTimestamp(uuid: string): number;
11
27
  }
@@ -14,6 +14,12 @@ export declare class StringHelper {
14
14
  * @returns The trimmed string or the original.
15
15
  */
16
16
  static trimLeadingSlashes(value: string): string;
17
+ /**
18
+ * Trim both leading and trailing slashes from a string.
19
+ * @param value The value to trim.
20
+ * @returns The trimmed string or the original.
21
+ */
22
+ static trimLeadingAndTrailingSlashes(value: string): string;
17
23
  /**
18
24
  * Convert the input string to kebab case.
19
25
  * @param input The input to convert.
@@ -28,8 +28,10 @@ export * from "./helpers/stringHelper.js";
28
28
  export * from "./helpers/uint8ArrayHelper.js";
29
29
  export * from "./models/coerceType.js";
30
30
  export * from "./models/compressionType.js";
31
+ export * from "./models/healthStatus.js";
31
32
  export * from "./models/IComponent.js";
32
33
  export * from "./models/IError.js";
34
+ export * from "./models/IHealth.js";
33
35
  export * from "./models/II18nShared.js";
34
36
  export * from "./models/IKeyValue.js";
35
37
  export * from "./models/ILabelledValue.js";
@@ -39,8 +41,9 @@ export * from "./models/ILocalesIndex.js";
39
41
  export * from "./models/IPatchOperation.js";
40
42
  export * from "./models/IUrlParts.js";
41
43
  export * from "./models/IValidationFailure.js";
42
- export * from "./models/objectOrArray.js";
43
44
  export * from "./types/bitString.js";
45
+ export * from "./types/objectOrArray.js";
46
+ export * from "./types/singleOccurrenceArray.js";
44
47
  export * from "./types/url.js";
45
48
  export * from "./types/urn.js";
46
49
  export * from "./utils/asyncCache.js";
@@ -1,3 +1,4 @@
1
+ import type { IHealth } from "./IHealth.js";
1
2
  /**
2
3
  * Interface describing a component which can be bootstrapped, started and stopped.
3
4
  */
@@ -13,6 +14,12 @@ export interface IComponent {
13
14
  * @returns True if the bootstrapping process was successful.
14
15
  */
15
16
  bootstrap?(nodeLoggingComponentType?: string): Promise<boolean>;
17
+ /**
18
+ * Teardown the component by releasing any resources it holds.
19
+ * @param nodeLoggingComponentType The node logging component type.
20
+ * @returns True if the teardown process was successful.
21
+ */
22
+ teardown?(nodeLoggingComponentType?: string): Promise<boolean>;
16
23
  /**
17
24
  * The component needs to be started when the node is initialized.
18
25
  * @param nodeLoggingComponentType The node logging component type.
@@ -25,4 +32,9 @@ export interface IComponent {
25
32
  * @returns Nothing.
26
33
  */
27
34
  stop?(nodeLoggingComponentType?: string): Promise<void>;
35
+ /**
36
+ * Returns the health status of the component.
37
+ * @returns The health status of the component, can return multiple entries for elements within the component.
38
+ */
39
+ health?(): Promise<IHealth[]>;
28
40
  }
@@ -7,7 +7,7 @@ export interface IError {
7
7
  */
8
8
  name: string;
9
9
  /**
10
- * The message for the error.
10
+ * The message for the error as an i18n key.
11
11
  */
12
12
  message: string;
13
13
  /**
@@ -0,0 +1,32 @@
1
+ import type { HealthStatus } from "./healthStatus.js";
2
+ /**
3
+ * Provides health information for a component.
4
+ */
5
+ export interface IHealth {
6
+ /**
7
+ * The source of the health information.
8
+ */
9
+ source: string;
10
+ /**
11
+ * The description of the component as an i18n key.
12
+ */
13
+ description?: string;
14
+ /**
15
+ * The overall status of the component, the entries can also report their own health.
16
+ */
17
+ status: HealthStatus;
18
+ /**
19
+ * The message for the status if there are further details to provide as an i18n key.
20
+ */
21
+ message?: string;
22
+ /**
23
+ * Data to substitute in the i18n key for the message.
24
+ */
25
+ data?: {
26
+ [id: string]: unknown;
27
+ };
28
+ /**
29
+ * The grouped child components, if any.
30
+ */
31
+ grouped?: IHealth[];
32
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The health status of the component.
3
+ */
4
+ export declare const HealthStatus: {
5
+ /**
6
+ * OK.
7
+ */
8
+ readonly Ok: "ok";
9
+ /**
10
+ * Warning.
11
+ */
12
+ readonly Warning: "warning";
13
+ /**
14
+ * Error.
15
+ */
16
+ readonly Error: "error";
17
+ };
18
+ /**
19
+ * The health status of the component.
20
+ */
21
+ export type HealthStatus = (typeof HealthStatus)[keyof typeof HealthStatus];
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Helper with bounded recursion depth to keep type instantiation tractable.
3
+ */
4
+ export type SingleOccurrenceArrayDepthHelper<T, U, Depth extends 0[]> = Depth["length"] extends 16 ? [U, ...T[]] : [U, ...T[]] | [T, ...SingleOccurrenceArrayDepthHelper<T, U, [0, ...Depth]>];
5
+ /**
6
+ * Utility type to create a non-empty array with values of type T and exactly one value of type U.
7
+ */
8
+ export type SingleOccurrenceArray<T = unknown, U = never> = SingleOccurrenceArrayDepthHelper<T, U, [
9
+ ]>;
@@ -39,4 +39,11 @@ export declare class AsyncCache {
39
39
  * Perform a cleanup of the expired entries in the cache.
40
40
  */
41
41
  static cleanupExpired(): void;
42
+ /**
43
+ * Resolve a waiter by re-running its request method safely.
44
+ * @param requestMethod The method to execute.
45
+ * @param resolve The resolver for the waiter.
46
+ * @param reject The rejector for the waiter.
47
+ */
48
+ private static resolveWaiter;
42
49
  }
@@ -1,4 +1,4 @@
1
- import type { ObjectOrArray } from "../models/objectOrArray.js";
1
+ import type { ObjectOrArray } from "../types/objectOrArray.js";
2
2
  /**
3
3
  * Class to handle guard operations for parameters.
4
4
  */
@@ -221,4 +221,13 @@ export declare class Guards {
221
221
  * @throws GuardError If the value does not match the assertion.
222
222
  */
223
223
  static email(source: string, property: string, value: unknown): asserts value is string;
224
+ /**
225
+ * Is the property a string containing uuidV7.
226
+ * @param source The source of the error.
227
+ * @param property The name of the property.
228
+ * @param value The value to test.
229
+ * @param format The format of the uuidV7, either standard or compact.
230
+ * @throws GuardError If the value does not match the assertion.
231
+ */
232
+ static uuidV7(source: string, property: string, value: unknown, format?: "standard" | "compact"): asserts value is string;
224
233
  }
@@ -220,4 +220,11 @@ export declare class Is {
220
220
  * @returns True if the object is a class, false otherwise.
221
221
  */
222
222
  static class<T = unknown>(obj: unknown): obj is new (...args: any[]) => T;
223
+ /**
224
+ * Is the value a uuidV7 string.
225
+ * @param value The value to test.
226
+ * @param format The format of the UUIDv7 string.
227
+ * @returns True if the value is a uuidV7 string.
228
+ */
229
+ static uuidV7(value: unknown, format?: "standard" | "compact"): value is string;
223
230
  }