@twin.org/core 0.0.3-next.32 → 0.0.3-next.34
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.
- package/dist/es/errors/alreadyExistsError.js +1 -1
- package/dist/es/errors/alreadyExistsError.js.map +1 -1
- package/dist/es/errors/baseError.js +1 -1
- package/dist/es/errors/baseError.js.map +1 -1
- package/dist/es/errors/conflictError.js +1 -1
- package/dist/es/errors/conflictError.js.map +1 -1
- package/dist/es/errors/generalError.js +1 -1
- package/dist/es/errors/generalError.js.map +1 -1
- package/dist/es/errors/guardError.js +1 -1
- package/dist/es/errors/guardError.js.map +1 -1
- package/dist/es/errors/notFoundError.js +1 -1
- package/dist/es/errors/notFoundError.js.map +1 -1
- package/dist/es/errors/notSupportedError.js +1 -1
- package/dist/es/errors/notSupportedError.js.map +1 -1
- package/dist/es/errors/unauthorizedError.js +2 -2
- package/dist/es/errors/unauthorizedError.js.map +1 -1
- package/dist/es/errors/unprocessableError.js +1 -1
- package/dist/es/errors/unprocessableError.js.map +1 -1
- package/dist/es/index.js +2 -0
- package/dist/es/index.js.map +1 -1
- package/dist/es/models/IComponent.js +0 -2
- package/dist/es/models/IComponent.js.map +1 -1
- package/dist/es/models/IError.js.map +1 -1
- package/dist/es/models/IHealth.js +2 -0
- package/dist/es/models/IHealth.js.map +1 -0
- package/dist/es/models/healthStatus.js +21 -0
- package/dist/es/models/healthStatus.js.map +1 -0
- package/dist/types/errors/alreadyExistsError.d.ts +1 -1
- package/dist/types/errors/baseError.d.ts +1 -1
- package/dist/types/errors/conflictError.d.ts +1 -1
- package/dist/types/errors/generalError.d.ts +1 -1
- package/dist/types/errors/guardError.d.ts +1 -1
- package/dist/types/errors/notFoundError.d.ts +1 -1
- package/dist/types/errors/notSupportedError.d.ts +1 -1
- package/dist/types/errors/unauthorizedError.d.ts +2 -2
- package/dist/types/errors/unprocessableError.d.ts +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/models/IComponent.d.ts +6 -0
- package/dist/types/models/IError.d.ts +1 -1
- package/dist/types/models/IHealth.d.ts +32 -0
- package/dist/types/models/healthStatus.d.ts +21 -0
- package/docs/changelog.md +39 -0
- package/docs/reference/classes/AlreadyExistsError.md +1 -1
- package/docs/reference/classes/BaseError.md +1 -1
- package/docs/reference/classes/ConflictError.md +1 -1
- package/docs/reference/classes/GeneralError.md +1 -1
- package/docs/reference/classes/GuardError.md +1 -1
- package/docs/reference/classes/NotFoundError.md +1 -1
- package/docs/reference/classes/NotSupportedError.md +1 -1
- package/docs/reference/classes/UnauthorizedError.md +2 -2
- package/docs/reference/classes/UnprocessableError.md +1 -1
- package/docs/reference/index.md +3 -0
- package/docs/reference/interfaces/IComponent.md +14 -0
- package/docs/reference/interfaces/IError.md +1 -1
- package/docs/reference/interfaces/IHealth.md +55 -0
- package/docs/reference/type-aliases/HealthStatus.md +5 -0
- package/docs/reference/variables/HealthStatus.md +25 -0
- package/package.json +2 -2
|
@@ -10,7 +10,7 @@ export 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
|
|
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.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alreadyExistsError.js","sourceRoot":"","sources":["../../../src/errors/alreadyExistsError.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,SAAS;IAChD;;OAEG;IACI,MAAM,CAAU,UAAU,wBAAwC;IAEzE;;;;;;;OAOG;IACH,YACC,MAAc,EACd,OAAe,EACf,UAAmB,EACnB,UAAsC,EACtC,KAAe;QAEf,KAAK,CAAC,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,UAAU,EAAE,GAAG,UAAU,EAAE,EAAE,KAAK,CAAC,CAAC;IAC7F,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { nameof } from \"@twin.org/nameof\";\nimport { BaseError } from \"./baseError.js\";\n\n/**\n * Class to handle errors which are triggered by data already existing.\n */\nexport class AlreadyExistsError extends BaseError {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<AlreadyExistsError>();\n\n\t/**\n\t * Create a new instance of AlreadyExistsError.\n\t * @param source The source of the error.\n\t * @param message The message as
|
|
1
|
+
{"version":3,"file":"alreadyExistsError.js","sourceRoot":"","sources":["../../../src/errors/alreadyExistsError.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,SAAS;IAChD;;OAEG;IACI,MAAM,CAAU,UAAU,wBAAwC;IAEzE;;;;;;;OAOG;IACH,YACC,MAAc,EACd,OAAe,EACf,UAAmB,EACnB,UAAsC,EACtC,KAAe;QAEf,KAAK,CAAC,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,UAAU,EAAE,GAAG,UAAU,EAAE,EAAE,KAAK,CAAC,CAAC;IAC7F,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { nameof } from \"@twin.org/nameof\";\nimport { BaseError } from \"./baseError.js\";\n\n/**\n * Class to handle errors which are triggered by data already existing.\n */\nexport class AlreadyExistsError extends BaseError {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<AlreadyExistsError>();\n\n\t/**\n\t * Create a new instance of AlreadyExistsError.\n\t * @param source The source of the error.\n\t * @param message The message as an i18n key.\n\t * @param existingId The id for the item.\n\t * @param properties Any additional information for the error.\n\t * @param cause The cause of the error if we have wrapped another error.\n\t */\n\tconstructor(\n\t\tsource: string,\n\t\tmessage: string,\n\t\texistingId?: string,\n\t\tproperties?: { [id: string]: unknown },\n\t\tcause?: unknown\n\t) {\n\t\tsuper(AlreadyExistsError.CLASS_NAME, source, message, { existingId, ...properties }, cause);\n\t}\n}\n"]}
|
|
@@ -22,7 +22,7 @@ export class BaseError extends Error {
|
|
|
22
22
|
* Create a new instance of BaseError.
|
|
23
23
|
* @param name The name of the error.
|
|
24
24
|
* @param source The source of the error.
|
|
25
|
-
* @param message The message as
|
|
25
|
+
* @param message The message as an i18n key.
|
|
26
26
|
* @param properties Any additional information for the error.
|
|
27
27
|
* @param cause The cause of error if we have wrapped another error.
|
|
28
28
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseError.js","sourceRoot":"","sources":["../../../src/errors/baseError.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAEpC;;GAEG;AACH,MAAM,OAAO,SAAU,SAAQ,KAAK;IACnC;;OAEG;IACI,MAAM,CAAU;IAEvB;;OAEG;IACI,UAAU,CAA6B;IAE9C;;OAEG;IACI,KAAK,CAAU;IAEtB;;;;;;;OAOG;IACH,YACC,IAAY,EACZ,MAAc,EACd,OAAe,EACf,UAAsC,EACtC,KAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,IAAI,CAA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,IAAI,CAAC,IAAI,CAAC;QACtB,CAAC;QACD,IAAI,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YACjC,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,CAAC;QACD,IAAI,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YAClC,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,CAAC;QACD,IAAI,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YAChC,GAAG,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAClC,CAAC;QACD,IAAI,CAAC,iBAAiB,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAChE,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACxB,CAAC;QACD,IAAI,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAC7B,GAAG,CAAC,KAAK,GAAG,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;QAC7E,CAAC;QACD,OAAO,GAAa,CAAC;IACtB,CAAC;CACD","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { StringHelper } from \"../helpers/stringHelper.js\";\nimport type { IError } from \"../models/IError.js\";\nimport { Is } from \"../utils/is.js\";\n\n/**\n * Class to handle errors.\n */\nexport class BaseError extends Error implements IError {\n\t/**\n\t * The source of the error.\n\t */\n\tpublic source?: string;\n\n\t/**\n\t * Any additional information for the error.\n\t */\n\tpublic properties?: { [id: string]: unknown };\n\n\t/**\n\t * The cause of the error.\n\t */\n\tpublic cause?: IError;\n\n\t/**\n\t * Create a new instance of BaseError.\n\t * @param name The name of the error.\n\t * @param source The source of the error.\n\t * @param message The message as a code.\n\t * @param properties Any additional information for the error.\n\t * @param cause The cause of error if we have wrapped another error.\n\t */\n\tconstructor(\n\t\tname: string,\n\t\tsource: string,\n\t\tmessage: string,\n\t\tproperties?: { [id: string]: unknown },\n\t\tcause?: unknown\n\t) {\n\t\tsuper(message);\n\t\tthis.name = name;\n\t\tthis.source = source;\n\t\tthis.cause = Is.notEmpty(cause) ? BaseError.fromError(cause).toJsonObject(true) : undefined;\n\t\tthis.properties = properties;\n\n\t\t// If the message is camel case but has no namespace then prefix it\n\t\t// with the source name in camel case.\n\t\tif (\n\t\t\tIs.stringValue(source) &&\n\t\t\tIs.stringValue(message) &&\n\t\t\t!message.includes(\".\") &&\n\t\t\t// This comparison checks that it is most likely a camel case name\n\t\t\t// and not a free text error with a dot in it\n\t\t\tStringHelper.camelCase(message) === message\n\t\t) {\n\t\t\tthis.message = `${StringHelper.camelCase(source)}.${message}`;\n\t\t}\n\t}\n\n\t/**\n\t * Construct an error from an existing one.\n\t * @param err The existing error.\n\t * @returns The new instance.\n\t */\n\tpublic static fromError(err: unknown): BaseError {\n\t\tlet name = \"Base\";\n\t\tlet message;\n\t\tlet source;\n\t\tlet properties;\n\t\tlet cause;\n\t\tlet stack;\n\n\t\tif (Is.object<{ error: string }>(err) && Is.stringValue(err.error)) {\n\t\t\tmessage = err.error;\n\t\t} else if (Is.object<BaseError>(err)) {\n\t\t\tif (Is.stringValue(err.name)) {\n\t\t\t\tname = err.name;\n\t\t\t}\n\t\t\tif (Is.stringValue(err.source)) {\n\t\t\t\tsource = err.source;\n\t\t\t}\n\t\t\tif (Is.stringValue(err.message)) {\n\t\t\t\tmessage = err.message;\n\t\t\t}\n\t\t\tif (Is.notEmpty(err.properties)) {\n\t\t\t\tproperties = err.properties;\n\t\t\t}\n\t\t\tif (BaseError.isAggregateError(err)) {\n\t\t\t\tproperties ??= {};\n\t\t\t\tproperties.errors = err.errors;\n\t\t\t}\n\t\t\tif (Is.notEmpty(err.cause)) {\n\t\t\t\tcause = err.cause;\n\t\t\t}\n\t\t\tif (Is.notEmpty(err.stack)) {\n\t\t\t\tstack = err.stack;\n\t\t\t}\n\t\t} else if (Is.stringValue(err)) {\n\t\t\tmessage = err;\n\t\t} else {\n\t\t\tmessage = JSON.stringify(err);\n\t\t}\n\n\t\tconst baseError = new BaseError(name, source ?? \"\", message ?? \"\", properties, cause);\n\n\t\tbaseError.stack = stack;\n\n\t\treturn baseError;\n\t}\n\n\t/**\n\t * Flatten an error tree.\n\t * @param err The starting error.\n\t * @returns The list of all internal errors.\n\t */\n\tpublic static flatten(err: unknown): IError[] {\n\t\tconst flattened: IError[] = [];\n\n\t\tlet e: IError | undefined = BaseError.fromError(err).toJsonObject(true);\n\n\t\twhile (e) {\n\t\t\tconst cause: IError | undefined = e.cause;\n\t\t\te.cause = undefined;\n\t\t\tflattened.push(e);\n\t\t\te = cause;\n\t\t}\n\n\t\treturn flattened;\n\t}\n\n\t/**\n\t * Expand an error tree.\n\t * @param errors The list of errors to expand.\n\t * @returns The first level error.\n\t */\n\tpublic static expand(errors: IError[] | undefined): IError | undefined {\n\t\tlet first: IError | undefined;\n\n\t\tif (Is.arrayValue(errors)) {\n\t\t\tfirst = errors[0];\n\t\t\tlet current = first;\n\t\t\tfor (let i = 1; i < errors.length; i++) {\n\t\t\t\tcurrent.cause = errors[i];\n\t\t\t\tcurrent = current.cause;\n\t\t\t}\n\t\t}\n\n\t\treturn first;\n\t}\n\n\t/**\n\t * Test to see if the error has the specified error name.\n\t * @param error The error to test.\n\t * @param name The name to check for.\n\t * @returns True if the error has the name.\n\t */\n\tpublic static isErrorName(error: unknown, name: string | RegExp): error is BaseError {\n\t\treturn (\n\t\t\tIs.object<{ name: string }>(error) &&\n\t\t\t(Is.string(name) ? error.name === name : name.test(error.name))\n\t\t);\n\t}\n\n\t/**\n\t * Test to see if the error has the specified error message.\n\t * @param error The error to test.\n\t * @param message The message to check for.\n\t * @returns True if the error has the name.\n\t */\n\tpublic static isErrorMessage(error: unknown, message: string | RegExp): error is BaseError {\n\t\treturn (\n\t\t\tIs.object<{ message: string }>(error) &&\n\t\t\t(Is.string(message) ? error.message === message : message.test(error.message))\n\t\t);\n\t}\n\n\t/**\n\t * Test to see if the error has the specified error code.\n\t * @param error The error to test.\n\t * @param code The code to check for.\n\t * @returns True if the error has the code.\n\t */\n\tpublic static isErrorCode(error: unknown, code: string | RegExp): boolean {\n\t\treturn (\n\t\t\tIs.object<{ code: string }>(error) &&\n\t\t\t(Is.string(code) ? error.code === code : code.test(error.code))\n\t\t);\n\t}\n\n\t/**\n\t * Test to see if any of the errors or children have the given error name.\n\t * @param error The error to test.\n\t * @param name The name to check for.\n\t * @returns True if the error has the name.\n\t */\n\tpublic static someErrorName(error: unknown, name: string | RegExp): error is BaseError {\n\t\treturn BaseError.flatten(error).some(e => BaseError.isErrorName(e, name));\n\t}\n\n\t/**\n\t * Test to see if any of the errors or children have the given error message.\n\t * @param error The error to test.\n\t * @param message The message to check for.\n\t * @returns True if the error has the name.\n\t */\n\tpublic static someErrorMessage(error: unknown, message: string | RegExp): error is BaseError {\n\t\treturn BaseError.flatten(error).some(e => BaseError.isErrorMessage(e, message));\n\t}\n\n\t/**\n\t * Test to see if any of the errors or children are from a specific class.\n\t * @param error The error to test.\n\t * @param cls The class to check for.\n\t * @returns True if the error has the specific class.\n\t */\n\tpublic static someErrorClass(error: unknown, cls: string): error is BaseError {\n\t\tconst errorClass = StringHelper.camelCase(cls);\n\t\tconst regExp = new RegExp(`^${errorClass}\\\\.`);\n\t\treturn BaseError.flatten(error).some(e => BaseError.isErrorMessage(e, regExp));\n\t}\n\n\t/**\n\t * Test to see if any of the errors or children have the given error code.\n\t * @param error The error to test.\n\t * @param code The code to check for.\n\t * @returns True if the error has the name.\n\t */\n\tpublic static someErrorCode(error: unknown, code: string | RegExp): error is BaseError {\n\t\treturn BaseError.flatten(error).some(e => BaseError.isErrorCode(e, code));\n\t}\n\n\t/**\n\t * Is the error empty, i.e. does it have no message, source, properties, or cause?\n\t * @param err The error to check for being empty.\n\t * @returns True if the error is empty.\n\t */\n\tpublic static isEmpty(err: IError): boolean {\n\t\treturn (\n\t\t\t!Is.stringValue(err.message) &&\n\t\t\t!Is.stringValue(err.source) &&\n\t\t\t!Is.objectValue(err.properties) &&\n\t\t\tIs.empty(err.cause)\n\t\t);\n\t}\n\n\t/**\n\t * Is the error an aggregate error.\n\t * @param err The error to check for being an aggregate error.\n\t * @returns True if the error is an aggregate error.\n\t */\n\tpublic static isAggregateError(err: unknown): err is AggregateError {\n\t\t// This is the only way we can reliably check for AggregateError\n\t\t// eslint-disable-next-line no-restricted-syntax\n\t\treturn err instanceof AggregateError;\n\t}\n\n\t/**\n\t * Convert the aggregate error to an array of errors.\n\t * @param err The error to convert.\n\t * @param includeStackTrace Whether to include the error stack in the model, defaults to false.\n\t * @returns The array of errors.\n\t */\n\tpublic static fromAggregate(err: unknown, includeStackTrace?: boolean): IError[] {\n\t\tif (BaseError.isAggregateError(err)) {\n\t\t\treturn err.errors.map(e => BaseError.fromError(e).toJsonObject(includeStackTrace));\n\t\t}\n\t\treturn [BaseError.fromError(err).toJsonObject(includeStackTrace)];\n\t}\n\n\t/**\n\t * Serialize the error to the error model.\n\t * @param includeStackTrace Whether to include the error stack in the model, defaults to false.\n\t * @returns The error model.\n\t */\n\tpublic toJsonObject(includeStackTrace?: boolean): IError {\n\t\tconst err: Partial<IError> = {};\n\t\tif (Is.stringValue(this.name)) {\n\t\t\terr.name = this.name;\n\t\t}\n\t\tif (Is.stringValue(this.source)) {\n\t\t\terr.source = this.source;\n\t\t}\n\t\tif (Is.stringValue(this.message)) {\n\t\t\terr.message = this.message;\n\t\t}\n\t\tif (Is.object(this.properties)) {\n\t\t\terr.properties = this.properties;\n\t\t}\n\t\tif ((includeStackTrace ?? false) && Is.stringValue(this.stack)) {\n\t\t\terr.stack = this.stack;\n\t\t}\n\t\tif (Is.notEmpty(this.cause)) {\n\t\t\terr.cause = BaseError.fromError(this.cause).toJsonObject(includeStackTrace);\n\t\t}\n\t\treturn err as IError;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"baseError.js","sourceRoot":"","sources":["../../../src/errors/baseError.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAEpC;;GAEG;AACH,MAAM,OAAO,SAAU,SAAQ,KAAK;IACnC;;OAEG;IACI,MAAM,CAAU;IAEvB;;OAEG;IACI,UAAU,CAA6B;IAE9C;;OAEG;IACI,KAAK,CAAU;IAEtB;;;;;;;OAOG;IACH,YACC,IAAY,EACZ,MAAc,EACd,OAAe,EACf,UAAsC,EACtC,KAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC5F,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAE7B,mEAAmE;QACnE,sCAAsC;QACtC,IACC,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC;YACtB,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC;YACvB,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;YACtB,kEAAkE;YAClE,6CAA6C;YAC7C,YAAY,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,OAAO,EAC1C,CAAC;YACF,IAAI,CAAC,OAAO,GAAG,GAAG,YAAY,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QAC/D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C,CAAC;QACD,IAAI,CAAC,iBAAiB,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAChE,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACxB,CAAC;QACD,IAAI,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAC7B,GAAG,CAAC,KAAK,GAAG,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;QAC7E,CAAC;QACD,OAAO,GAAa,CAAC;IACtB,CAAC;CACD","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { StringHelper } from \"../helpers/stringHelper.js\";\nimport type { IError } from \"../models/IError.js\";\nimport { Is } from \"../utils/is.js\";\n\n/**\n * Class to handle errors.\n */\nexport class BaseError extends Error implements IError {\n\t/**\n\t * The source of the error.\n\t */\n\tpublic source?: string;\n\n\t/**\n\t * Any additional information for the error.\n\t */\n\tpublic properties?: { [id: string]: unknown };\n\n\t/**\n\t * The cause of the error.\n\t */\n\tpublic cause?: IError;\n\n\t/**\n\t * Create a new instance of BaseError.\n\t * @param name The name of the error.\n\t * @param source The source of the error.\n\t * @param message The message as an i18n key.\n\t * @param properties Any additional information for the error.\n\t * @param cause The cause of error if we have wrapped another error.\n\t */\n\tconstructor(\n\t\tname: string,\n\t\tsource: string,\n\t\tmessage: string,\n\t\tproperties?: { [id: string]: unknown },\n\t\tcause?: unknown\n\t) {\n\t\tsuper(message);\n\t\tthis.name = name;\n\t\tthis.source = source;\n\t\tthis.cause = Is.notEmpty(cause) ? BaseError.fromError(cause).toJsonObject(true) : undefined;\n\t\tthis.properties = properties;\n\n\t\t// If the message is camel case but has no namespace then prefix it\n\t\t// with the source name in camel case.\n\t\tif (\n\t\t\tIs.stringValue(source) &&\n\t\t\tIs.stringValue(message) &&\n\t\t\t!message.includes(\".\") &&\n\t\t\t// This comparison checks that it is most likely a camel case name\n\t\t\t// and not a free text error with a dot in it\n\t\t\tStringHelper.camelCase(message) === message\n\t\t) {\n\t\t\tthis.message = `${StringHelper.camelCase(source)}.${message}`;\n\t\t}\n\t}\n\n\t/**\n\t * Construct an error from an existing one.\n\t * @param err The existing error.\n\t * @returns The new instance.\n\t */\n\tpublic static fromError(err: unknown): BaseError {\n\t\tlet name = \"Base\";\n\t\tlet message;\n\t\tlet source;\n\t\tlet properties;\n\t\tlet cause;\n\t\tlet stack;\n\n\t\tif (Is.object<{ error: string }>(err) && Is.stringValue(err.error)) {\n\t\t\tmessage = err.error;\n\t\t} else if (Is.object<BaseError>(err)) {\n\t\t\tif (Is.stringValue(err.name)) {\n\t\t\t\tname = err.name;\n\t\t\t}\n\t\t\tif (Is.stringValue(err.source)) {\n\t\t\t\tsource = err.source;\n\t\t\t}\n\t\t\tif (Is.stringValue(err.message)) {\n\t\t\t\tmessage = err.message;\n\t\t\t}\n\t\t\tif (Is.notEmpty(err.properties)) {\n\t\t\t\tproperties = err.properties;\n\t\t\t}\n\t\t\tif (BaseError.isAggregateError(err)) {\n\t\t\t\tproperties ??= {};\n\t\t\t\tproperties.errors = err.errors;\n\t\t\t}\n\t\t\tif (Is.notEmpty(err.cause)) {\n\t\t\t\tcause = err.cause;\n\t\t\t}\n\t\t\tif (Is.notEmpty(err.stack)) {\n\t\t\t\tstack = err.stack;\n\t\t\t}\n\t\t} else if (Is.stringValue(err)) {\n\t\t\tmessage = err;\n\t\t} else {\n\t\t\tmessage = JSON.stringify(err);\n\t\t}\n\n\t\tconst baseError = new BaseError(name, source ?? \"\", message ?? \"\", properties, cause);\n\n\t\tbaseError.stack = stack;\n\n\t\treturn baseError;\n\t}\n\n\t/**\n\t * Flatten an error tree.\n\t * @param err The starting error.\n\t * @returns The list of all internal errors.\n\t */\n\tpublic static flatten(err: unknown): IError[] {\n\t\tconst flattened: IError[] = [];\n\n\t\tlet e: IError | undefined = BaseError.fromError(err).toJsonObject(true);\n\n\t\twhile (e) {\n\t\t\tconst cause: IError | undefined = e.cause;\n\t\t\te.cause = undefined;\n\t\t\tflattened.push(e);\n\t\t\te = cause;\n\t\t}\n\n\t\treturn flattened;\n\t}\n\n\t/**\n\t * Expand an error tree.\n\t * @param errors The list of errors to expand.\n\t * @returns The first level error.\n\t */\n\tpublic static expand(errors: IError[] | undefined): IError | undefined {\n\t\tlet first: IError | undefined;\n\n\t\tif (Is.arrayValue(errors)) {\n\t\t\tfirst = errors[0];\n\t\t\tlet current = first;\n\t\t\tfor (let i = 1; i < errors.length; i++) {\n\t\t\t\tcurrent.cause = errors[i];\n\t\t\t\tcurrent = current.cause;\n\t\t\t}\n\t\t}\n\n\t\treturn first;\n\t}\n\n\t/**\n\t * Test to see if the error has the specified error name.\n\t * @param error The error to test.\n\t * @param name The name to check for.\n\t * @returns True if the error has the name.\n\t */\n\tpublic static isErrorName(error: unknown, name: string | RegExp): error is BaseError {\n\t\treturn (\n\t\t\tIs.object<{ name: string }>(error) &&\n\t\t\t(Is.string(name) ? error.name === name : name.test(error.name))\n\t\t);\n\t}\n\n\t/**\n\t * Test to see if the error has the specified error message.\n\t * @param error The error to test.\n\t * @param message The message to check for.\n\t * @returns True if the error has the name.\n\t */\n\tpublic static isErrorMessage(error: unknown, message: string | RegExp): error is BaseError {\n\t\treturn (\n\t\t\tIs.object<{ message: string }>(error) &&\n\t\t\t(Is.string(message) ? error.message === message : message.test(error.message))\n\t\t);\n\t}\n\n\t/**\n\t * Test to see if the error has the specified error code.\n\t * @param error The error to test.\n\t * @param code The code to check for.\n\t * @returns True if the error has the code.\n\t */\n\tpublic static isErrorCode(error: unknown, code: string | RegExp): boolean {\n\t\treturn (\n\t\t\tIs.object<{ code: string }>(error) &&\n\t\t\t(Is.string(code) ? error.code === code : code.test(error.code))\n\t\t);\n\t}\n\n\t/**\n\t * Test to see if any of the errors or children have the given error name.\n\t * @param error The error to test.\n\t * @param name The name to check for.\n\t * @returns True if the error has the name.\n\t */\n\tpublic static someErrorName(error: unknown, name: string | RegExp): error is BaseError {\n\t\treturn BaseError.flatten(error).some(e => BaseError.isErrorName(e, name));\n\t}\n\n\t/**\n\t * Test to see if any of the errors or children have the given error message.\n\t * @param error The error to test.\n\t * @param message The message to check for.\n\t * @returns True if the error has the name.\n\t */\n\tpublic static someErrorMessage(error: unknown, message: string | RegExp): error is BaseError {\n\t\treturn BaseError.flatten(error).some(e => BaseError.isErrorMessage(e, message));\n\t}\n\n\t/**\n\t * Test to see if any of the errors or children are from a specific class.\n\t * @param error The error to test.\n\t * @param cls The class to check for.\n\t * @returns True if the error has the specific class.\n\t */\n\tpublic static someErrorClass(error: unknown, cls: string): error is BaseError {\n\t\tconst errorClass = StringHelper.camelCase(cls);\n\t\tconst regExp = new RegExp(`^${errorClass}\\\\.`);\n\t\treturn BaseError.flatten(error).some(e => BaseError.isErrorMessage(e, regExp));\n\t}\n\n\t/**\n\t * Test to see if any of the errors or children have the given error code.\n\t * @param error The error to test.\n\t * @param code The code to check for.\n\t * @returns True if the error has the name.\n\t */\n\tpublic static someErrorCode(error: unknown, code: string | RegExp): error is BaseError {\n\t\treturn BaseError.flatten(error).some(e => BaseError.isErrorCode(e, code));\n\t}\n\n\t/**\n\t * Is the error empty, i.e. does it have no message, source, properties, or cause?\n\t * @param err The error to check for being empty.\n\t * @returns True if the error is empty.\n\t */\n\tpublic static isEmpty(err: IError): boolean {\n\t\treturn (\n\t\t\t!Is.stringValue(err.message) &&\n\t\t\t!Is.stringValue(err.source) &&\n\t\t\t!Is.objectValue(err.properties) &&\n\t\t\tIs.empty(err.cause)\n\t\t);\n\t}\n\n\t/**\n\t * Is the error an aggregate error.\n\t * @param err The error to check for being an aggregate error.\n\t * @returns True if the error is an aggregate error.\n\t */\n\tpublic static isAggregateError(err: unknown): err is AggregateError {\n\t\t// This is the only way we can reliably check for AggregateError\n\t\t// eslint-disable-next-line no-restricted-syntax\n\t\treturn err instanceof AggregateError;\n\t}\n\n\t/**\n\t * Convert the aggregate error to an array of errors.\n\t * @param err The error to convert.\n\t * @param includeStackTrace Whether to include the error stack in the model, defaults to false.\n\t * @returns The array of errors.\n\t */\n\tpublic static fromAggregate(err: unknown, includeStackTrace?: boolean): IError[] {\n\t\tif (BaseError.isAggregateError(err)) {\n\t\t\treturn err.errors.map(e => BaseError.fromError(e).toJsonObject(includeStackTrace));\n\t\t}\n\t\treturn [BaseError.fromError(err).toJsonObject(includeStackTrace)];\n\t}\n\n\t/**\n\t * Serialize the error to the error model.\n\t * @param includeStackTrace Whether to include the error stack in the model, defaults to false.\n\t * @returns The error model.\n\t */\n\tpublic toJsonObject(includeStackTrace?: boolean): IError {\n\t\tconst err: Partial<IError> = {};\n\t\tif (Is.stringValue(this.name)) {\n\t\t\terr.name = this.name;\n\t\t}\n\t\tif (Is.stringValue(this.source)) {\n\t\t\terr.source = this.source;\n\t\t}\n\t\tif (Is.stringValue(this.message)) {\n\t\t\terr.message = this.message;\n\t\t}\n\t\tif (Is.object(this.properties)) {\n\t\t\terr.properties = this.properties;\n\t\t}\n\t\tif ((includeStackTrace ?? false) && Is.stringValue(this.stack)) {\n\t\t\terr.stack = this.stack;\n\t\t}\n\t\tif (Is.notEmpty(this.cause)) {\n\t\t\terr.cause = BaseError.fromError(this.cause).toJsonObject(includeStackTrace);\n\t\t}\n\t\treturn err as IError;\n\t}\n}\n"]}
|
|
@@ -10,7 +10,7 @@ export 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
|
|
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.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conflictError.js","sourceRoot":"","sources":["../../../src/errors/conflictError.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,SAAS;IAC3C;;OAEG;IACI,MAAM,CAAU,UAAU,mBAAmC;IAEpE;;;;;;;;OAQG;IACH,YACC,MAAc,EACd,OAAe,EACf,UAAmB,EACnB,SAAoB,EACpB,UAAsC,EACtC,KAAe;QAEf,KAAK,CACJ,aAAa,CAAC,UAAU,EACxB,MAAM,EACN,OAAO,EACP,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,UAAU,EAAE,EACxC,KAAK,CACL,CAAC;IACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { nameof } from \"@twin.org/nameof\";\nimport { BaseError } from \"./baseError.js\";\n\n/**\n * Class to handle errors which are triggered by conflicting data.\n */\nexport class ConflictError extends BaseError {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<ConflictError>();\n\n\t/**\n\t * Create a new instance of ConflictError.\n\t * @param source The source of the error.\n\t * @param message The message as
|
|
1
|
+
{"version":3,"file":"conflictError.js","sourceRoot":"","sources":["../../../src/errors/conflictError.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,SAAS;IAC3C;;OAEG;IACI,MAAM,CAAU,UAAU,mBAAmC;IAEpE;;;;;;;;OAQG;IACH,YACC,MAAc,EACd,OAAe,EACf,UAAmB,EACnB,SAAoB,EACpB,UAAsC,EACtC,KAAe;QAEf,KAAK,CACJ,aAAa,CAAC,UAAU,EACxB,MAAM,EACN,OAAO,EACP,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,UAAU,EAAE,EACxC,KAAK,CACL,CAAC;IACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { nameof } from \"@twin.org/nameof\";\nimport { BaseError } from \"./baseError.js\";\n\n/**\n * Class to handle errors which are triggered by conflicting data.\n */\nexport class ConflictError extends BaseError {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<ConflictError>();\n\n\t/**\n\t * Create a new instance of ConflictError.\n\t * @param source The source of the error.\n\t * @param message The message as an i18n key.\n\t * @param conflictId The id that has conflicts.\n\t * @param conflicts The conflicts that occurred.\n\t * @param properties Any additional information for the error.\n\t * @param cause The cause or the error if we have wrapped another error.\n\t */\n\tconstructor(\n\t\tsource: string,\n\t\tmessage: string,\n\t\tconflictId?: string,\n\t\tconflicts?: string[],\n\t\tproperties?: { [id: string]: unknown },\n\t\tcause?: unknown\n\t) {\n\t\tsuper(\n\t\t\tConflictError.CLASS_NAME,\n\t\t\tsource,\n\t\t\tmessage,\n\t\t\t{ conflictId, conflicts, ...properties },\n\t\t\tcause\n\t\t);\n\t}\n}\n"]}
|
|
@@ -10,7 +10,7 @@ export 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
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generalError.js","sourceRoot":"","sources":["../../../src/errors/generalError.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,SAAS;IAC1C;;OAEG;IACI,MAAM,CAAU,UAAU,kBAAkC;IAEnE;;;;;;OAMG;IACH,YACC,MAAc,EACd,OAAe,EACf,UAAsC,EACtC,KAAe;QAEf,KAAK,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;IACpE,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { nameof } from \"@twin.org/nameof\";\nimport { BaseError } from \"./baseError.js\";\n\n/**\n * Class to handle errors.\n */\nexport class GeneralError extends BaseError {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<GeneralError>();\n\n\t/**\n\t * Create a new instance of GeneralError.\n\t * @param source The source of the error.\n\t * @param message The message as
|
|
1
|
+
{"version":3,"file":"generalError.js","sourceRoot":"","sources":["../../../src/errors/generalError.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,SAAS;IAC1C;;OAEG;IACI,MAAM,CAAU,UAAU,kBAAkC;IAEnE;;;;;;OAMG;IACH,YACC,MAAc,EACd,OAAe,EACf,UAAsC,EACtC,KAAe;QAEf,KAAK,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;IACpE,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { nameof } from \"@twin.org/nameof\";\nimport { BaseError } from \"./baseError.js\";\n\n/**\n * Class to handle errors.\n */\nexport class GeneralError extends BaseError {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<GeneralError>();\n\n\t/**\n\t * Create a new instance of GeneralError.\n\t * @param source The source of the error.\n\t * @param message The message as an i18n key.\n\t * @param properties Any additional information for the error.\n\t * @param cause The cause of the error if we have wrapped another error.\n\t */\n\tconstructor(\n\t\tsource: string,\n\t\tmessage: string,\n\t\tproperties?: { [id: string]: unknown },\n\t\tcause?: unknown\n\t) {\n\t\tsuper(GeneralError.CLASS_NAME, source, message, properties, cause);\n\t}\n}\n"]}
|
|
@@ -11,7 +11,7 @@ export class GuardError extends BaseError {
|
|
|
11
11
|
/**
|
|
12
12
|
* Create a new instance of GuardError.
|
|
13
13
|
* @param source The source of the error.
|
|
14
|
-
* @param message The message as
|
|
14
|
+
* @param message The message as an i18n key.
|
|
15
15
|
* @param propertyName The property which triggered the guard error for the item.
|
|
16
16
|
* @param propertyValue The property value which triggered the guard error for the item.
|
|
17
17
|
* @param propertyOptions The property options which might be allowed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guardError.js","sourceRoot":"","sources":["../../../src/errors/guardError.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAEpC;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,SAAS;IACxC;;OAEG;IACI,MAAM,CAAU,UAAU,gBAAgC;IAEjE;;;;;;;OAOG;IACH,YACC,MAAc,EACd,OAAe,EACf,YAAoB,EACpB,aAAsB,EACtB,eAAwB;QAExB,KAAK,CAAC,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE;YAC7C,QAAQ,EAAE,YAAY,IAAI,UAAU;YACpC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,aAAa;YAChE,OAAO,EAAE,eAAe;SACxB,CAAC,CAAC;IACJ,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { nameof } from \"@twin.org/nameof\";\nimport { BaseError } from \"./baseError.js\";\nimport { Is } from \"../utils/is.js\";\n\n/**\n * Class to handle errors which are triggered by data guards.\n */\nexport class GuardError extends BaseError {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<GuardError>();\n\n\t/**\n\t * Create a new instance of GuardError.\n\t * @param source The source of the error.\n\t * @param message The message as
|
|
1
|
+
{"version":3,"file":"guardError.js","sourceRoot":"","sources":["../../../src/errors/guardError.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAEpC;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,SAAS;IACxC;;OAEG;IACI,MAAM,CAAU,UAAU,gBAAgC;IAEjE;;;;;;;OAOG;IACH,YACC,MAAc,EACd,OAAe,EACf,YAAoB,EACpB,aAAsB,EACtB,eAAwB;QAExB,KAAK,CAAC,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE;YAC7C,QAAQ,EAAE,YAAY,IAAI,UAAU;YACpC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,aAAa;YAChE,OAAO,EAAE,eAAe;SACxB,CAAC,CAAC;IACJ,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { nameof } from \"@twin.org/nameof\";\nimport { BaseError } from \"./baseError.js\";\nimport { Is } from \"../utils/is.js\";\n\n/**\n * Class to handle errors which are triggered by data guards.\n */\nexport class GuardError extends BaseError {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<GuardError>();\n\n\t/**\n\t * Create a new instance of GuardError.\n\t * @param source The source of the error.\n\t * @param message The message as an i18n key.\n\t * @param propertyName The property which triggered the guard error for the item.\n\t * @param propertyValue The property value which triggered the guard error for the item.\n\t * @param propertyOptions The property options which might be allowed.\n\t */\n\tconstructor(\n\t\tsource: string,\n\t\tmessage: string,\n\t\tpropertyName: string,\n\t\tpropertyValue: unknown,\n\t\tpropertyOptions?: string\n\t) {\n\t\tsuper(GuardError.CLASS_NAME, source, message, {\n\t\t\tproperty: propertyName ?? \"property\",\n\t\t\tvalue: Is.undefined(propertyValue) ? \"undefined\" : propertyValue,\n\t\t\toptions: propertyOptions\n\t\t});\n\t}\n}\n"]}
|
|
@@ -10,7 +10,7 @@ export 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
|
|
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.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notFoundError.js","sourceRoot":"","sources":["../../../src/errors/notFoundError.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,SAAS;IAC3C;;OAEG;IACI,MAAM,CAAU,UAAU,mBAAmC;IAEpE;;;;;;;OAOG;IACH,YACC,MAAc,EACd,OAAe,EACf,UAAmB,EACnB,UAAsC,EACtC,KAAe;QAEf,KAAK,CAAC,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,UAAU,EAAE,GAAG,UAAU,EAAE,EAAE,KAAK,CAAC,CAAC;IACxF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { nameof } from \"@twin.org/nameof\";\nimport { BaseError } from \"./baseError.js\";\n\n/**\n * Class to handle errors which are triggered by data not being found.\n */\nexport class NotFoundError extends BaseError {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<NotFoundError>();\n\n\t/**\n\t * Create a new instance of NotFoundError.\n\t * @param source The source of the error.\n\t * @param message The message as
|
|
1
|
+
{"version":3,"file":"notFoundError.js","sourceRoot":"","sources":["../../../src/errors/notFoundError.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,SAAS;IAC3C;;OAEG;IACI,MAAM,CAAU,UAAU,mBAAmC;IAEpE;;;;;;;OAOG;IACH,YACC,MAAc,EACd,OAAe,EACf,UAAmB,EACnB,UAAsC,EACtC,KAAe;QAEf,KAAK,CAAC,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,UAAU,EAAE,GAAG,UAAU,EAAE,EAAE,KAAK,CAAC,CAAC;IACxF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { nameof } from \"@twin.org/nameof\";\nimport { BaseError } from \"./baseError.js\";\n\n/**\n * Class to handle errors which are triggered by data not being found.\n */\nexport class NotFoundError extends BaseError {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<NotFoundError>();\n\n\t/**\n\t * Create a new instance of NotFoundError.\n\t * @param source The source of the error.\n\t * @param message The message as an i18n key.\n\t * @param notFoundId The id for the item.\n\t * @param properties Any additional information for the error.\n\t * @param cause The cause of the error if we have wrapped another error.\n\t */\n\tconstructor(\n\t\tsource: string,\n\t\tmessage: string,\n\t\tnotFoundId?: string,\n\t\tproperties?: { [id: string]: unknown },\n\t\tcause?: unknown\n\t) {\n\t\tsuper(NotFoundError.CLASS_NAME, source, message, { notFoundId, ...properties }, cause);\n\t}\n}\n"]}
|
|
@@ -10,7 +10,7 @@ export 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
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notSupportedError.js","sourceRoot":"","sources":["../../../src/errors/notSupportedError.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,SAAS;IAC/C;;OAEG;IACI,MAAM,CAAU,UAAU,uBAAuC;IAExE;;;;;;OAMG;IACH,YACC,MAAc,EACd,OAAe,EACf,UAAsC,EACtC,KAAe;QAEf,KAAK,CAAC,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;IACzE,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { nameof } from \"@twin.org/nameof\";\nimport { BaseError } from \"./baseError.js\";\n\n/**\n * Class to handle errors when a feature is unsupported.\n */\nexport class NotSupportedError extends BaseError {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<NotSupportedError>();\n\n\t/**\n\t * Create a new instance of NotSupportedError.\n\t * @param source The source of the error.\n\t * @param message The message as
|
|
1
|
+
{"version":3,"file":"notSupportedError.js","sourceRoot":"","sources":["../../../src/errors/notSupportedError.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,SAAS;IAC/C;;OAEG;IACI,MAAM,CAAU,UAAU,uBAAuC;IAExE;;;;;;OAMG;IACH,YACC,MAAc,EACd,OAAe,EACf,UAAsC,EACtC,KAAe;QAEf,KAAK,CAAC,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;IACzE,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { nameof } from \"@twin.org/nameof\";\nimport { BaseError } from \"./baseError.js\";\n\n/**\n * Class to handle errors when a feature is unsupported.\n */\nexport class NotSupportedError extends BaseError {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<NotSupportedError>();\n\n\t/**\n\t * Create a new instance of NotSupportedError.\n\t * @param source The source of the error.\n\t * @param message The message as an i18n key.\n\t * @param properties Any additional information for the error.\n\t * @param cause The cause of the error if we have wrapped another error.\n\t */\n\tconstructor(\n\t\tsource: string,\n\t\tmessage: string,\n\t\tproperties?: { [id: string]: unknown },\n\t\tcause?: unknown\n\t) {\n\t\tsuper(NotSupportedError.CLASS_NAME, source, message, properties, cause);\n\t}\n}\n"]}
|
|
@@ -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
|
|
3
|
+
* Class to handle errors which are triggered by access not being authorized.
|
|
4
4
|
*/
|
|
5
5
|
export class UnauthorizedError extends BaseError {
|
|
6
6
|
/**
|
|
@@ -10,7 +10,7 @@ export 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
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unauthorizedError.js","sourceRoot":"","sources":["../../../src/errors/unauthorizedError.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,SAAS;IAC/C;;OAEG;IACI,MAAM,CAAU,UAAU,uBAAuC;IAExE;;;;;;OAMG;IACH,YACC,MAAc,EACd,OAAe,EACf,UAAsC,EACtC,KAAe;QAEf,KAAK,CAAC,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;IACzE,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { nameof } from \"@twin.org/nameof\";\nimport { BaseError } from \"./baseError.js\";\n\n/**\n * Class to handle errors which are triggered by access not being
|
|
1
|
+
{"version":3,"file":"unauthorizedError.js","sourceRoot":"","sources":["../../../src/errors/unauthorizedError.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,SAAS;IAC/C;;OAEG;IACI,MAAM,CAAU,UAAU,uBAAuC;IAExE;;;;;;OAMG;IACH,YACC,MAAc,EACd,OAAe,EACf,UAAsC,EACtC,KAAe;QAEf,KAAK,CAAC,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;IACzE,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { nameof } from \"@twin.org/nameof\";\nimport { BaseError } from \"./baseError.js\";\n\n/**\n * Class to handle errors which are triggered by access not being authorized.\n */\nexport class UnauthorizedError extends BaseError {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<UnauthorizedError>();\n\n\t/**\n\t * Create a new instance of UnauthorizedError.\n\t * @param source The source of the error.\n\t * @param message The message as an i18n key.\n\t * @param properties Any additional information for the error.\n\t * @param cause The cause of the error if we have wrapped another error.\n\t */\n\tconstructor(\n\t\tsource: string,\n\t\tmessage: string,\n\t\tproperties?: { [id: string]: unknown },\n\t\tcause?: unknown\n\t) {\n\t\tsuper(UnauthorizedError.CLASS_NAME, source, message, properties, cause);\n\t}\n}\n"]}
|
|
@@ -10,7 +10,7 @@ export 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
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unprocessableError.js","sourceRoot":"","sources":["../../../src/errors/unprocessableError.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,SAAS;IAChD;;OAEG;IACI,MAAM,CAAU,UAAU,wBAAwC;IAEzE;;;;;;OAMG;IACH,YACC,MAAc,EACd,OAAe,EACf,UAAsC,EACtC,KAAe;QAEf,KAAK,CAAC,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;IAC1E,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { nameof } from \"@twin.org/nameof\";\nimport { BaseError } from \"./baseError.js\";\n\n/**\n * Class to handle errors when some data can not be processed.\n */\nexport class UnprocessableError extends BaseError {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<UnprocessableError>();\n\n\t/**\n\t * Create a new instance of UnprocessableError.\n\t * @param source The source of the error.\n\t * @param message The message as
|
|
1
|
+
{"version":3,"file":"unprocessableError.js","sourceRoot":"","sources":["../../../src/errors/unprocessableError.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,SAAS;IAChD;;OAEG;IACI,MAAM,CAAU,UAAU,wBAAwC;IAEzE;;;;;;OAMG;IACH,YACC,MAAc,EACd,OAAe,EACf,UAAsC,EACtC,KAAe;QAEf,KAAK,CAAC,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;IAC1E,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { nameof } from \"@twin.org/nameof\";\nimport { BaseError } from \"./baseError.js\";\n\n/**\n * Class to handle errors when some data can not be processed.\n */\nexport class UnprocessableError extends BaseError {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<UnprocessableError>();\n\n\t/**\n\t * Create a new instance of UnprocessableError.\n\t * @param source The source of the error.\n\t * @param message The message as an i18n key.\n\t * @param properties Any additional information for the error.\n\t * @param cause The cause of the error if we have wrapped another error.\n\t */\n\tconstructor(\n\t\tsource: string,\n\t\tmessage: string,\n\t\tproperties?: { [id: string]: unknown },\n\t\tcause?: unknown\n\t) {\n\t\tsuper(UnprocessableError.CLASS_NAME, source, message, properties, cause);\n\t}\n}\n"]}
|
package/dist/es/index.js
CHANGED
|
@@ -30,8 +30,10 @@ export * from "./helpers/stringHelper.js";
|
|
|
30
30
|
export * from "./helpers/uint8ArrayHelper.js";
|
|
31
31
|
export * from "./models/coerceType.js";
|
|
32
32
|
export * from "./models/compressionType.js";
|
|
33
|
+
export * from "./models/healthStatus.js";
|
|
33
34
|
export * from "./models/IComponent.js";
|
|
34
35
|
export * from "./models/IError.js";
|
|
36
|
+
export * from "./models/IHealth.js";
|
|
35
37
|
export * from "./models/II18nShared.js";
|
|
36
38
|
export * from "./models/IKeyValue.js";
|
|
37
39
|
export * from "./models/ILabelledValue.js";
|
package/dist/es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,s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tC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./encoding/base32.js\";\nexport * from \"./encoding/base58.js\";\nexport * from \"./encoding/base64.js\";\nexport * from \"./encoding/base64Url.js\";\nexport * from \"./errors/alreadyExistsError.js\";\nexport * from \"./errors/baseError.js\";\nexport * from \"./errors/conflictError.js\";\nexport * from \"./errors/generalError.js\";\nexport * from \"./errors/guardError.js\";\nexport * from \"./errors/notFoundError.js\";\nexport * from \"./errors/notImplementedError.js\";\nexport * from \"./errors/notSupportedError.js\";\nexport * from \"./errors/unauthorizedError.js\";\nexport * from \"./errors/unprocessableError.js\";\nexport * from \"./errors/validationError.js\";\nexport * from \"./factories/componentFactory.js\";\nexport * from \"./factories/factory.js\";\nexport * from \"./helpers/arrayHelper.js\";\nexport * from \"./helpers/envHelper.js\";\nexport * from \"./helpers/errorHelper.js\";\nexport * from \"./helpers/filenameHelper.js\";\nexport * from \"./helpers/hexHelper.js\";\nexport * from \"./helpers/jsonHelper.js\";\nexport * from \"./helpers/numberHelper.js\";\nexport * from \"./helpers/objectHelper.js\";\nexport * from \"./helpers/randomHelper.js\";\nexport * from \"./helpers/stringHelper.js\";\nexport * from \"./helpers/uint8ArrayHelper.js\";\nexport * from \"./models/coerceType.js\";\nexport * from \"./models/compressionType.js\";\nexport * from \"./models/IComponent.js\";\nexport * from \"./models/IError.js\";\nexport * from \"./models/II18nShared.js\";\nexport * from \"./models/IKeyValue.js\";\nexport * from \"./models/ILabelledValue.js\";\nexport * from \"./models/ILocale.js\";\nexport * from \"./models/ILocaleDictionary.js\";\nexport * from \"./models/ILocalesIndex.js\";\nexport * from \"./models/IPatchOperation.js\";\nexport * from \"./models/IUrlParts.js\";\nexport * from \"./models/IValidationFailure.js\";\nexport * from \"./types/bitString.js\";\nexport * from \"./types/objectOrArray.js\";\nexport * from \"./types/singleOccurrenceArray.js\";\nexport * from \"./types/url.js\";\nexport * from \"./types/urn.js\";\nexport * from \"./utils/asyncCache.js\";\nexport * from \"./utils/coerce.js\";\nexport * from \"./utils/compression.js\";\nexport * from \"./utils/converter.js\";\nexport * from \"./utils/guards.js\";\nexport * from \"./utils/i18n.js\";\nexport * from \"./utils/is.js\";\nexport * from \"./utils/sharedStore.js\";\nexport * from \"./utils/validation.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iCAAiC,CAAC;AAChD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./encoding/base32.js\";\nexport * from \"./encoding/base58.js\";\nexport * from \"./encoding/base64.js\";\nexport * from \"./encoding/base64Url.js\";\nexport * from \"./errors/alreadyExistsError.js\";\nexport * from \"./errors/baseError.js\";\nexport * from \"./errors/conflictError.js\";\nexport * from \"./errors/generalError.js\";\nexport * from \"./errors/guardError.js\";\nexport * from \"./errors/notFoundError.js\";\nexport * from \"./errors/notImplementedError.js\";\nexport * from \"./errors/notSupportedError.js\";\nexport * from \"./errors/unauthorizedError.js\";\nexport * from \"./errors/unprocessableError.js\";\nexport * from \"./errors/validationError.js\";\nexport * from \"./factories/componentFactory.js\";\nexport * from \"./factories/factory.js\";\nexport * from \"./helpers/arrayHelper.js\";\nexport * from \"./helpers/envHelper.js\";\nexport * from \"./helpers/errorHelper.js\";\nexport * from \"./helpers/filenameHelper.js\";\nexport * from \"./helpers/hexHelper.js\";\nexport * from \"./helpers/jsonHelper.js\";\nexport * from \"./helpers/numberHelper.js\";\nexport * from \"./helpers/objectHelper.js\";\nexport * from \"./helpers/randomHelper.js\";\nexport * from \"./helpers/stringHelper.js\";\nexport * from \"./helpers/uint8ArrayHelper.js\";\nexport * from \"./models/coerceType.js\";\nexport * from \"./models/compressionType.js\";\nexport * from \"./models/healthStatus.js\";\nexport * from \"./models/IComponent.js\";\nexport * from \"./models/IError.js\";\nexport * from \"./models/IHealth.js\";\nexport * from \"./models/II18nShared.js\";\nexport * from \"./models/IKeyValue.js\";\nexport * from \"./models/ILabelledValue.js\";\nexport * from \"./models/ILocale.js\";\nexport * from \"./models/ILocaleDictionary.js\";\nexport * from \"./models/ILocalesIndex.js\";\nexport * from \"./models/IPatchOperation.js\";\nexport * from \"./models/IUrlParts.js\";\nexport * from \"./models/IValidationFailure.js\";\nexport * from \"./types/bitString.js\";\nexport * from \"./types/objectOrArray.js\";\nexport * from \"./types/singleOccurrenceArray.js\";\nexport * from \"./types/url.js\";\nexport * from \"./types/urn.js\";\nexport * from \"./utils/asyncCache.js\";\nexport * from \"./utils/coerce.js\";\nexport * from \"./utils/compression.js\";\nexport * from \"./utils/converter.js\";\nexport * from \"./utils/guards.js\";\nexport * from \"./utils/i18n.js\";\nexport * from \"./utils/is.js\";\nexport * from \"./utils/sharedStore.js\";\nexport * from \"./utils/validation.js\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IComponent.js","sourceRoot":"","sources":["../../../src/models/IComponent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"IComponent.js","sourceRoot":"","sources":["../../../src/models/IComponent.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IHealth } from \"./IHealth.js\";\n\n/**\n * Interface describing a component which can be bootstrapped, started and stopped.\n */\nexport interface IComponent {\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tclassName(): string;\n\n\t/**\n\t * Bootstrap the component by creating and initializing any resources it needs.\n\t * @param nodeLoggingComponentType The node logging component type.\n\t * @returns True if the bootstrapping process was successful.\n\t */\n\tbootstrap?(nodeLoggingComponentType?: string): Promise<boolean>;\n\n\t/**\n\t * The component needs to be started when the node is initialized.\n\t * @param nodeLoggingComponentType The node logging component type.\n\t * @returns Nothing.\n\t */\n\tstart?(nodeLoggingComponentType?: string): Promise<void>;\n\n\t/**\n\t * The component needs to be stopped when the node is closed.\n\t * @param nodeLoggingComponentType The node logging component type.\n\t * @returns Nothing.\n\t */\n\tstop?(nodeLoggingComponentType?: string): Promise<void>;\n\n\t/**\n\t * Returns the health status of the component.\n\t * @returns The health status of the component, can return multiple entries for elements within the component.\n\t */\n\thealth?(): Promise<IHealth[]>;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IError.js","sourceRoot":"","sources":["../../../src/models/IError.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Model to describe serialized error.\n */\nexport interface IError {\n\t/**\n\t * The name for the error.\n\t */\n\tname: string;\n\n\t/**\n\t * The message for the error.\n\t */\n\tmessage: string;\n\n\t/**\n\t * The source of the error.\n\t */\n\tsource?: string;\n\n\t/**\n\t * Any additional information for the error.\n\t */\n\tproperties?: { [id: string]: unknown };\n\n\t/**\n\t * The stack trace for the error.\n\t */\n\tstack?: string;\n\n\t/**\n\t * The cause of the error if there was one.\n\t */\n\tcause?: IError;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"IError.js","sourceRoot":"","sources":["../../../src/models/IError.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Model to describe serialized error.\n */\nexport interface IError {\n\t/**\n\t * The name for the error.\n\t */\n\tname: string;\n\n\t/**\n\t * The message for the error as an i18n key.\n\t */\n\tmessage: string;\n\n\t/**\n\t * The source of the error.\n\t */\n\tsource?: string;\n\n\t/**\n\t * Any additional information for the error.\n\t */\n\tproperties?: { [id: string]: unknown };\n\n\t/**\n\t * The stack trace for the error.\n\t */\n\tstack?: string;\n\n\t/**\n\t * The cause of the error if there was one.\n\t */\n\tcause?: IError;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IHealth.js","sourceRoot":"","sources":["../../../src/models/IHealth.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { HealthStatus } from \"./healthStatus.js\";\n\n/**\n * Provides health information for a component.\n */\nexport interface IHealth {\n\t/**\n\t * The name of the component.\n\t */\n\tname: string;\n\n\t/**\n\t * The description of the component as an i18n key.\n\t */\n\tdescription?: string;\n\n\t/**\n\t * The overall status of the component, the entries can also report their own health.\n\t */\n\tstatus: HealthStatus;\n\n\t/**\n\t * The details for the status if there are further details to provide as an i18n key.\n\t */\n\tdetails?: string;\n\n\t/**\n\t * Properties to substitute in the i18n key for the details.\n\t */\n\tproperties?: { [id: string]: unknown };\n\n\t/**\n\t * The grouped child components, if any.\n\t */\n\tgrouped?: IHealth[];\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Copyright 2024 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
/**
|
|
4
|
+
* The health status of the component.
|
|
5
|
+
*/
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
7
|
+
export const HealthStatus = {
|
|
8
|
+
/**
|
|
9
|
+
* OK.
|
|
10
|
+
*/
|
|
11
|
+
Ok: "ok",
|
|
12
|
+
/**
|
|
13
|
+
* Warning.
|
|
14
|
+
*/
|
|
15
|
+
Warning: "warning",
|
|
16
|
+
/**
|
|
17
|
+
* Error.
|
|
18
|
+
*/
|
|
19
|
+
Error: "error"
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=healthStatus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"healthStatus.js","sourceRoot":"","sources":["../../../src/models/healthStatus.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AAEvC;;GAEG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,YAAY,GAAG;IAC3B;;OAEG;IACH,EAAE,EAAE,IAAI;IAER;;OAEG;IACH,OAAO,EAAE,SAAS;IAElB;;OAEG;IACH,KAAK,EAAE,OAAO;CACL,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * The health status of the component.\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const HealthStatus = {\n\t/**\n\t * OK.\n\t */\n\tOk: \"ok\",\n\n\t/**\n\t * Warning.\n\t */\n\tWarning: \"warning\",\n\n\t/**\n\t * Error.\n\t */\n\tError: \"error\"\n} as const;\n\n/**\n * The health status of the component.\n */\nexport type HealthStatus = (typeof HealthStatus)[keyof typeof HealthStatus];\n"]}
|
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
*/
|
package/dist/types/index.d.ts
CHANGED
|
@@ -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";
|
|
@@ -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
|
*/
|
|
@@ -25,4 +26,9 @@ export interface IComponent {
|
|
|
25
26
|
* @returns Nothing.
|
|
26
27
|
*/
|
|
27
28
|
stop?(nodeLoggingComponentType?: string): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Returns the health status of the component.
|
|
31
|
+
* @returns The health status of the component, can return multiple entries for elements within the component.
|
|
32
|
+
*/
|
|
33
|
+
health?(): Promise<IHealth[]>;
|
|
28
34
|
}
|
|
@@ -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 name of the component.
|
|
8
|
+
*/
|
|
9
|
+
name: 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 details for the status if there are further details to provide as an i18n key.
|
|
20
|
+
*/
|
|
21
|
+
details?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Properties to substitute in the i18n key for the details.
|
|
24
|
+
*/
|
|
25
|
+
properties?: {
|
|
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];
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.3-next.34](https://github.com/twinfoundation/twin-framework/compare/core-v0.0.3-next.33...core-v0.0.3-next.34) (2026-05-06)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* health status grouping ([5007c29](https://github.com/twinfoundation/twin-framework/commit/5007c29fe4123fe56f754450b993dbe5dc32a057))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/nameof bumped from 0.0.3-next.33 to 0.0.3-next.34
|
|
16
|
+
* devDependencies
|
|
17
|
+
* @twin.org/nameof-transformer bumped from 0.0.3-next.33 to 0.0.3-next.34
|
|
18
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.33 to 0.0.3-next.34
|
|
19
|
+
|
|
20
|
+
## [0.0.3-next.33](https://github.com/twinfoundation/twin-framework/compare/core-v0.0.3-next.32...core-v0.0.3-next.33) (2026-05-05)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Features
|
|
24
|
+
|
|
25
|
+
* add health method to components ([a88016d](https://github.com/twinfoundation/twin-framework/commit/a88016d90d172413e5bc5238dc1b3e35f82fcc2c))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* improve jsdoc comments ([f7c8e43](https://github.com/twinfoundation/twin-framework/commit/f7c8e43fab9803dffa6461950d5b9979e25bcd24))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Dependencies
|
|
34
|
+
|
|
35
|
+
* The following workspace dependencies were updated
|
|
36
|
+
* dependencies
|
|
37
|
+
* @twin.org/nameof bumped from 0.0.3-next.32 to 0.0.3-next.33
|
|
38
|
+
* devDependencies
|
|
39
|
+
* @twin.org/nameof-transformer bumped from 0.0.3-next.32 to 0.0.3-next.33
|
|
40
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.32 to 0.0.3-next.33
|
|
41
|
+
|
|
3
42
|
## [0.0.3-next.32](https://github.com/twinfoundation/twin-framework/compare/core-v0.0.3-next.31...core-v0.0.3-next.32) (2026-04-30)
|
|
4
43
|
|
|
5
44
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Class: UnauthorizedError
|
|
2
2
|
|
|
3
|
-
Class to handle errors which are triggered by access not being
|
|
3
|
+
Class to handle errors which are triggered by access not being authorized.
|
|
4
4
|
|
|
5
5
|
## Extends
|
|
6
6
|
|
|
@@ -26,7 +26,7 @@ The source of the error.
|
|
|
26
26
|
|
|
27
27
|
`string`
|
|
28
28
|
|
|
29
|
-
The message as
|
|
29
|
+
The message as an i18n key.
|
|
30
30
|
|
|
31
31
|
##### properties?
|
|
32
32
|
|
package/docs/reference/index.md
CHANGED
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
|
|
47
47
|
- [IComponent](interfaces/IComponent.md)
|
|
48
48
|
- [IError](interfaces/IError.md)
|
|
49
|
+
- [IHealth](interfaces/IHealth.md)
|
|
49
50
|
- [II18nShared](interfaces/II18nShared.md)
|
|
50
51
|
- [IKeyValue](interfaces/IKeyValue.md)
|
|
51
52
|
- [ILabelledValue](interfaces/ILabelledValue.md)
|
|
@@ -60,6 +61,7 @@
|
|
|
60
61
|
|
|
61
62
|
- [CoerceType](type-aliases/CoerceType.md)
|
|
62
63
|
- [CompressionType](type-aliases/CompressionType.md)
|
|
64
|
+
- [HealthStatus](type-aliases/HealthStatus.md)
|
|
63
65
|
- [ObjectOrArray](type-aliases/ObjectOrArray.md)
|
|
64
66
|
- [SingleOccurrenceArrayDepthHelper](type-aliases/SingleOccurrenceArrayDepthHelper.md)
|
|
65
67
|
- [SingleOccurrenceArray](type-aliases/SingleOccurrenceArray.md)
|
|
@@ -69,3 +71,4 @@
|
|
|
69
71
|
- [ComponentFactory](variables/ComponentFactory.md)
|
|
70
72
|
- [CoerceType](variables/CoerceType.md)
|
|
71
73
|
- [CompressionType](variables/CompressionType.md)
|
|
74
|
+
- [HealthStatus](variables/HealthStatus.md)
|
|
@@ -81,3 +81,17 @@ The node logging component type.
|
|
|
81
81
|
`Promise`\<`void`\>
|
|
82
82
|
|
|
83
83
|
Nothing.
|
|
84
|
+
|
|
85
|
+
***
|
|
86
|
+
|
|
87
|
+
### health()? {#health}
|
|
88
|
+
|
|
89
|
+
> `optional` **health**(): `Promise`\<[`IHealth`](IHealth.md)[]\>
|
|
90
|
+
|
|
91
|
+
Returns the health status of the component.
|
|
92
|
+
|
|
93
|
+
#### Returns
|
|
94
|
+
|
|
95
|
+
`Promise`\<[`IHealth`](IHealth.md)[]\>
|
|
96
|
+
|
|
97
|
+
The health status of the component, can return multiple entries for elements within the component.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Interface: IHealth
|
|
2
|
+
|
|
3
|
+
Provides health information for a component.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### name {#name}
|
|
8
|
+
|
|
9
|
+
> **name**: `string`
|
|
10
|
+
|
|
11
|
+
The name of the component.
|
|
12
|
+
|
|
13
|
+
***
|
|
14
|
+
|
|
15
|
+
### description? {#description}
|
|
16
|
+
|
|
17
|
+
> `optional` **description?**: `string`
|
|
18
|
+
|
|
19
|
+
The description of the component as an i18n key.
|
|
20
|
+
|
|
21
|
+
***
|
|
22
|
+
|
|
23
|
+
### status {#status}
|
|
24
|
+
|
|
25
|
+
> **status**: [`HealthStatus`](../type-aliases/HealthStatus.md)
|
|
26
|
+
|
|
27
|
+
The overall status of the component, the entries can also report their own health.
|
|
28
|
+
|
|
29
|
+
***
|
|
30
|
+
|
|
31
|
+
### details? {#details}
|
|
32
|
+
|
|
33
|
+
> `optional` **details?**: `string`
|
|
34
|
+
|
|
35
|
+
The details for the status if there are further details to provide as an i18n key.
|
|
36
|
+
|
|
37
|
+
***
|
|
38
|
+
|
|
39
|
+
### properties? {#properties}
|
|
40
|
+
|
|
41
|
+
> `optional` **properties?**: `object`
|
|
42
|
+
|
|
43
|
+
Properties to substitute in the i18n key for the details.
|
|
44
|
+
|
|
45
|
+
#### Index Signature
|
|
46
|
+
|
|
47
|
+
\[`id`: `string`\]: `unknown`
|
|
48
|
+
|
|
49
|
+
***
|
|
50
|
+
|
|
51
|
+
### grouped? {#grouped}
|
|
52
|
+
|
|
53
|
+
> `optional` **grouped?**: `IHealth`[]
|
|
54
|
+
|
|
55
|
+
The grouped child components, if any.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Variable: HealthStatus
|
|
2
|
+
|
|
3
|
+
> `const` **HealthStatus**: `object`
|
|
4
|
+
|
|
5
|
+
The health status of the component.
|
|
6
|
+
|
|
7
|
+
## Type Declaration
|
|
8
|
+
|
|
9
|
+
### Ok {#ok}
|
|
10
|
+
|
|
11
|
+
> `readonly` **Ok**: `"ok"` = `"ok"`
|
|
12
|
+
|
|
13
|
+
OK.
|
|
14
|
+
|
|
15
|
+
### Warning {#warning}
|
|
16
|
+
|
|
17
|
+
> `readonly` **Warning**: `"warning"` = `"warning"`
|
|
18
|
+
|
|
19
|
+
Warning.
|
|
20
|
+
|
|
21
|
+
### Error {#error}
|
|
22
|
+
|
|
23
|
+
> `readonly` **Error**: `"error"` = `"error"`
|
|
24
|
+
|
|
25
|
+
Error.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/core",
|
|
3
|
-
"version": "0.0.3-next.
|
|
3
|
+
"version": "0.0.3-next.34",
|
|
4
4
|
"description": "Helper methods/classes for data type checking/validation/guarding/error handling",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@twin.org/nameof": "0.0.3-next.
|
|
17
|
+
"@twin.org/nameof": "0.0.3-next.34",
|
|
18
18
|
"intl-messageformat": "11.2.0",
|
|
19
19
|
"rfc6902": "5.2.0"
|
|
20
20
|
},
|