@venizia/ignis-inversion 0.4.6-1 → 0.4.6
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.
|
@@ -28,5 +28,4 @@ export declare const fromError: (opts: {
|
|
|
28
28
|
* An error from a copy older than 0.2.2-0 matches but has no `toFilledText()`.
|
|
29
29
|
*/
|
|
30
30
|
export declare const isApplicationError: (error: unknown) => error is ApplicationError;
|
|
31
|
-
export type TApplicationError = ApplicationError;
|
|
32
31
|
//# sourceMappingURL=app-error.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-error.d.ts","sourceRoot":"","sources":["../../../../src/modules/error/app-error.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAgB1F,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,gBAAgB,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,QAAQ,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAC;gBAEvB,IAAI,EAAE,MAAM;IA2CxB;;;;OAIG;IACH,YAAY,IAAI,MAAM;IAItB,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM;IAI5B,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,eAAe,CAAA;KAAE,GAAG,gBAAgB;CAcrE;AAED,eAAO,MAAM,QAAQ,GAAI,MAAM,MAAM,KAAG,gBAAmD,CAAC;AAE5F,eAAO,MAAM,SAAS,GAAI,MAAM;IAAE,KAAK,EAAE,eAAe,CAAA;CAAE,KAAG,gBAC3B,CAAC;AAEnC;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,gBAa5D,CAAC
|
|
1
|
+
{"version":3,"file":"app-error.d.ts","sourceRoot":"","sources":["../../../../src/modules/error/app-error.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAgB1F,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,gBAAgB,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,QAAQ,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAC;gBAEvB,IAAI,EAAE,MAAM;IA2CxB;;;;OAIG;IACH,YAAY,IAAI,MAAM;IAItB,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM;IAI5B,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,eAAe,CAAA;KAAE,GAAG,gBAAgB;CAcrE;AAED,eAAO,MAAM,QAAQ,GAAI,MAAM,MAAM,KAAG,gBAAmD,CAAC;AAE5F,eAAO,MAAM,SAAS,GAAI,MAAM;IAAE,KAAK,EAAE,eAAe,CAAA;CAAE,KAAG,gBAC3B,CAAC;AAEnC;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,gBAa5D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-error.js","sourceRoot":"","sources":["../../../../src/modules/error/app-error.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrD,yDAAyD;AACzD,MAAM,UAAU,GAAG;IACjB,OAAO;IACP,SAAS;IACT,aAAa;IACb,YAAY;IACZ,aAAa;IACb,OAAO;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ClB,GAAG,CAAC,KAAK,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC;SACzE,CAAC,CAAC;IACL,CAAC;CACF;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAoB,EAAE,CAAC,gBAAgB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAE5F,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,IAAgC,EAAoB,EAAE,CAC9E,gBAAgB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AAEnC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAc,EAA6B,EAAE;IAC9E,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,IAAI,CAAC,CAAC,YAAY,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,YAAY,IAAI,KAAK,CAAC,EAAE,CAAC;QACtF,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;IACzC,OAAO,CACL,OAAO,UAAU,KAAK,QAAQ;QAC9B,OAAO,UAAU,KAAK,QAAQ;QAC9B,UAAU,KAAK,IAAI;QACnB,MAAM,IAAI,UAAU;QACpB,OAAO,UAAU,CAAC,IAAI,KAAK,QAAQ,CACpC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { type TNullable } from '@/common/types';\nimport { ObjectUtility } from '@/common/utilities';\nimport { MessageCode } from './message-code';\nimport { MessageTemplate } from './message-template';\nimport type { TError, TErrorLogLevel, TErrorNormalized, TResponsedError } from './common';\n\n/** Consumed keys. Everything else rides into `extra`. */\nconst KNOWN_KEYS = [\n 'error',\n 'message',\n 'messageCode',\n 'statusCode',\n 'messageArgs',\n 'cause',\n 'extra',\n 'transform',\n 'logLevel',\n 'name',\n] as const;\n\nexport class ApplicationError extends Error {\n statusCode: number;\n normalized: TErrorNormalized;\n extra?: Record<string, unknown>;\n readonly logLevel?: TErrorLogLevel;\n\n constructor(opts: TError) {\n const { statusCode, messageArgs, cause, extra, transform, logLevel } = opts;\n\n // Index signature defeats `in` narrowing - read the discriminant and cast.\n const definition = 'error' in opts ? opts.error : undefined;\n\n const input = opts.message;\n const override = typeof input === 'string' ? { text: input } : input;\n\n // `?.message?.` has to guard BOTH: `error` reaches here from an untyped call site as anything at all, and a bare `definition?.message.text` throws on a malformed one.\n const message = override?.text ?? definition?.message?.text ?? '';\n const messageCode = MessageCode.resolve(\n override?.code ?? definition?.message?.code ?? (opts.messageCode as TNullable<string>),\n );\n const args = override?.args ?? messageArgs ?? definition?.message?.args;\n\n super(message, cause === undefined ? undefined : { cause });\n\n this.statusCode = statusCode ?? definition?.statusCode ?? 400;\n this.logLevel = logLevel;\n\n // Explicit `extra` wins over swept keys.\n const merged = {\n ...ObjectUtility.omit({ source: opts, keys: KNOWN_KEYS }),\n ...extra,\n };\n this.extra = Object.keys(merged).length > 0 ? merged : undefined;\n\n const normalized: TErrorNormalized = {\n text: message,\n code: messageCode,\n args: args ?? {},\n };\n\n this.normalized = transform\n ? transform({\n message: normalized,\n statusCode: this.statusCode,\n extra: this.extra,\n })\n : normalized;\n }\n\n /**\n * The message with its args filled in: `Only 2 left of TRA-01`. `message` itself stays the template,\n * so a log or an error tracker never prints a value outside the args it redacts by key - call this\n * where a plain reader stores or shows the text, such as a queue's failure reason.\n */\n toFilledText(): string {\n return MessageTemplate.render({ text: this.message, args: this.normalized.args }).text;\n }\n\n static getError(opts: TError) {\n return new ApplicationError(opts);\n }\n\n static fromError(opts: { error: TResponsedError }): ApplicationError {\n const { error } = opts;\n\n return this.getError({\n message: {\n text: error.normalized?.text ?? error.message ?? '',\n code: error.normalized?.code,\n args: error.normalized?.args,\n },\n statusCode: error.statusCode,\n extra: error.extra,\n ...(error.requestId === undefined ? {} : { requestId: error.requestId }),\n });\n }\n}\n\nexport const getError = (opts: TError): ApplicationError => ApplicationError.getError(opts);\n\nexport const fromError = (opts: { error: TResponsedError }): ApplicationError =>\n ApplicationError.fromError(opts);\n\n/**\n * An `ApplicationError` by shape - a numeric `statusCode` and a `normalized` with its `text` - so it\n * holds across the CJS and ESM copies of this class, where `instanceof` does not. A plain `Error`\n * that merely carries a `statusCode` (an HTTP client's, an engine's) is not one.\n *\n * An error from a copy older than 0.2.2-0 matches but has no `toFilledText()`.\n */\nexport const isApplicationError = (error: unknown): error is ApplicationError => {\n if (!(error instanceof Error) || !('statusCode' in error) || !('normalized' in error)) {\n return false;\n }\n\n const { statusCode, normalized } = error;\n return (\n typeof statusCode === 'number' &&\n typeof normalized === 'object' &&\n normalized !== null &&\n 'text' in normalized &&\n typeof normalized.text === 'string'\n );\n};\n
|
|
1
|
+
{"version":3,"file":"app-error.js","sourceRoot":"","sources":["../../../../src/modules/error/app-error.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrD,yDAAyD;AACzD,MAAM,UAAU,GAAG;IACjB,OAAO;IACP,SAAS;IACT,aAAa;IACb,YAAY;IACZ,aAAa;IACb,OAAO;IACP,OAAO;IACP,WAAW;IACX,UAAU;IACV,MAAM;CACE,CAAC;AAEX,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAMzC,YAAY,IAAY;QACtB,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;QAE5E,2EAA2E;QAC3E,MAAM,UAAU,GAAG,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;QAE5D,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC;QA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AEnC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAc,EAA6B,EAAE;IAC9E,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,IAAI,CAAC,CAAC,YAAY,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,YAAY,IAAI,KAAK,CAAC,EAAE,CAAC;QACtF,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;IACzC,OAAO,CACL,OAAO,UAAU,KAAK,QAAQ;QAC9B,OAAO,UAAU,KAAK,QAAQ;QAC9B,UAAU,KAAK,IAAI;QACnB,MAAM,IAAI,UAAU;QACpB,OAAO,UAAU,CAAC,IAAI,KAAK,QAAQ,CACpC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { type TNullable } from '@/common/types';\nimport { ObjectUtility } from '@/common/utilities';\nimport { MessageCode } from './message-code';\nimport { MessageTemplate } from './message-template';\nimport type { TError, TErrorLogLevel, TErrorNormalized, TResponsedError } from './common';\n\n/** Consumed keys. Everything else rides into `extra`. */\nconst KNOWN_KEYS = [\n 'error',\n 'message',\n 'messageCode',\n 'statusCode',\n 'messageArgs',\n 'cause',\n 'extra',\n 'transform',\n 'logLevel',\n 'name',\n] as const;\n\nexport class ApplicationError extends Error {\n statusCode: number;\n normalized: TErrorNormalized;\n extra?: Record<string, unknown>;\n readonly logLevel?: TErrorLogLevel;\n\n constructor(opts: TError) {\n const { statusCode, messageArgs, cause, extra, transform, logLevel } = opts;\n\n // Index signature defeats `in` narrowing - read the discriminant and cast.\n const definition = 'error' in opts ? opts.error : undefined;\n\n const input = opts.message;\n const override = typeof input === 'string' ? { text: input } : input;\n\n // `?.message?.` has to guard BOTH: `error` reaches here from an untyped call site as anything at all, and a bare `definition?.message.text` throws on a malformed one.\n const message = override?.text ?? definition?.message?.text ?? '';\n const messageCode = MessageCode.resolve(\n override?.code ?? definition?.message?.code ?? (opts.messageCode as TNullable<string>),\n );\n const args = override?.args ?? messageArgs ?? definition?.message?.args;\n\n super(message, cause === undefined ? undefined : { cause });\n\n this.statusCode = statusCode ?? definition?.statusCode ?? 400;\n this.logLevel = logLevel;\n\n // Explicit `extra` wins over swept keys.\n const merged = {\n ...ObjectUtility.omit({ source: opts, keys: KNOWN_KEYS }),\n ...extra,\n };\n this.extra = Object.keys(merged).length > 0 ? merged : undefined;\n\n const normalized: TErrorNormalized = {\n text: message,\n code: messageCode,\n args: args ?? {},\n };\n\n this.normalized = transform\n ? transform({\n message: normalized,\n statusCode: this.statusCode,\n extra: this.extra,\n })\n : normalized;\n }\n\n /**\n * The message with its args filled in: `Only 2 left of TRA-01`. `message` itself stays the template,\n * so a log or an error tracker never prints a value outside the args it redacts by key - call this\n * where a plain reader stores or shows the text, such as a queue's failure reason.\n */\n toFilledText(): string {\n return MessageTemplate.render({ text: this.message, args: this.normalized.args }).text;\n }\n\n static getError(opts: TError) {\n return new ApplicationError(opts);\n }\n\n static fromError(opts: { error: TResponsedError }): ApplicationError {\n const { error } = opts;\n\n return this.getError({\n message: {\n text: error.normalized?.text ?? error.message ?? '',\n code: error.normalized?.code,\n args: error.normalized?.args,\n },\n statusCode: error.statusCode,\n extra: error.extra,\n ...(error.requestId === undefined ? {} : { requestId: error.requestId }),\n });\n }\n}\n\nexport const getError = (opts: TError): ApplicationError => ApplicationError.getError(opts);\n\nexport const fromError = (opts: { error: TResponsedError }): ApplicationError =>\n ApplicationError.fromError(opts);\n\n/**\n * An `ApplicationError` by shape - a numeric `statusCode` and a `normalized` with its `text` - so it\n * holds across the CJS and ESM copies of this class, where `instanceof` does not. A plain `Error`\n * that merely carries a `statusCode` (an HTTP client's, an engine's) is not one.\n *\n * An error from a copy older than 0.2.2-0 matches but has no `toFilledText()`.\n */\nexport const isApplicationError = (error: unknown): error is ApplicationError => {\n if (!(error instanceof Error) || !('statusCode' in error) || !('normalized' in error)) {\n return false;\n }\n\n const { statusCode, normalized } = error;\n return (\n typeof statusCode === 'number' &&\n typeof normalized === 'object' &&\n normalized !== null &&\n 'text' in normalized &&\n typeof normalized.text === 'string'\n );\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@venizia/ignis-inversion",
|
|
3
|
-
"version": "0.4.6
|
|
3
|
+
"version": "0.4.6",
|
|
4
4
|
"description": "A small, standalone Dependency Injection and Inversion of Control container for TypeScript. Features decorator-based constructor and property injection, fluent Binding API, singleton/transient scoping, namespace auto-tagging, Provider pattern, tag-based discovery, and reflect-metadata integration. Zero framework lock-in — works standalone or with Ignis.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"architecture",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
},
|
|
89
89
|
"devDependencies": {
|
|
90
90
|
"@types/bun": "^1.4.3",
|
|
91
|
-
"@venizia/dev-configs": "0.4.7
|
|
91
|
+
"@venizia/dev-configs": "0.4.7",
|
|
92
92
|
"eslint": "^10.13.0",
|
|
93
93
|
"oxlint": "1.89.0",
|
|
94
94
|
"oxlint-tsgolint": "7.0.2004",
|