@zudojs/errors 1.0.1 → 1.1.0
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/README.md +9 -2
- package/dist/base/core/baseError.core.d.ts +18 -4
- package/dist/base/core/baseError.core.js +31 -46
- package/dist/base/core/baseError.serialize.d.ts +53 -0
- package/dist/base/core/baseError.serialize.js +109 -0
- package/dist/base/core/errorCause.redact.d.ts +20 -0
- package/dist/base/core/errorCause.redact.js +64 -0
- package/dist/base/types/errorCode.type.d.ts +10 -1
- package/dist/base/types/errorCode.type.js +11 -0
- package/dist/domain/access/authError.base.d.ts +25 -0
- package/dist/domain/access/authError.base.js +26 -0
- package/dist/domain/access/index.d.ts +2 -0
- package/dist/domain/access/index.js +2 -0
- package/dist/domain/access/oauthError.base.d.ts +24 -0
- package/dist/domain/access/oauthError.base.js +30 -0
- package/dist/domain/cli/cliError.base.d.ts +24 -0
- package/dist/domain/cli/cliError.base.js +34 -0
- package/dist/domain/cli/index.d.ts +7 -0
- package/dist/domain/cli/index.js +7 -0
- package/dist/domain/constant/constantError.base.d.ts +21 -0
- package/dist/domain/constant/constantError.base.js +31 -0
- package/dist/domain/constant/index.d.ts +7 -0
- package/dist/domain/constant/index.js +7 -0
- package/dist/domain/cqrs/cqrsError.base.d.ts +14 -0
- package/dist/domain/cqrs/cqrsError.base.js +26 -0
- package/dist/domain/cqrs/index.d.ts +7 -0
- package/dist/domain/cqrs/index.js +7 -0
- package/dist/domain/index.d.ts +6 -0
- package/dist/domain/index.js +6 -0
- package/dist/domain/openapi/index.d.ts +7 -0
- package/dist/domain/openapi/index.js +7 -0
- package/dist/domain/openapi/openApiError.base.d.ts +20 -0
- package/dist/domain/openapi/openApiError.base.js +24 -0
- package/dist/domain/schema/schemaError.base.js +1 -1
- package/dist/domain/shared/domainError.helpers.d.ts +3 -2
- package/dist/domain/shared/domainError.helpers.js +32 -8
- package/dist/domain/state/validationError.base.d.ts +4 -3
- package/dist/domain/state/validationError.base.js +5 -4
- package/dist/domain/transaction/index.d.ts +10 -0
- package/dist/domain/transaction/index.js +10 -0
- package/dist/domain/transaction/transactionError.base.d.ts +18 -0
- package/dist/domain/transaction/transactionError.base.js +21 -0
- package/dist/domain/transaction/transactionError.misc.d.ts +26 -0
- package/dist/domain/transaction/transactionError.misc.js +47 -0
- package/dist/domain/transaction/transactionError.types.d.ts +33 -0
- package/dist/domain/transaction/transactionError.types.js +62 -0
- package/dist/domain/traversal/index.d.ts +7 -0
- package/dist/domain/traversal/index.js +7 -0
- package/dist/domain/traversal/traversalLimit.error.d.ts +37 -0
- package/dist/domain/traversal/traversalLimit.error.js +39 -0
- package/dist/infrastructure/httpPipeline/httpMiddleware.error.d.ts +26 -0
- package/dist/infrastructure/httpPipeline/httpMiddleware.error.js +43 -0
- package/dist/infrastructure/httpPipeline/httpRequestGuard.error.d.ts +21 -0
- package/dist/infrastructure/httpPipeline/httpRequestGuard.error.js +28 -0
- package/dist/infrastructure/httpPipeline/index.d.ts +8 -0
- package/dist/infrastructure/httpPipeline/index.js +8 -0
- package/dist/infrastructure/index.d.ts +1 -0
- package/dist/infrastructure/index.js +1 -0
- package/dist/infrastructure/middleware/index.d.ts +1 -0
- package/dist/infrastructure/middleware/index.js +1 -0
- package/dist/infrastructure/middleware/middlewareError.types.d.ts +28 -0
- package/dist/infrastructure/middleware/middlewareError.types.js +44 -0
- package/dist/system/index.d.ts +1 -0
- package/dist/system/index.js +1 -0
- package/dist/system/observability/index.d.ts +7 -0
- package/dist/system/observability/index.js +7 -0
- package/dist/system/observability/observabilityError.base.d.ts +16 -0
- package/dist/system/observability/observabilityError.base.js +23 -0
- package/dist/utils/errorMapper.mappers.d.ts +1 -1
- package/dist/utils/errorSerializer.core.d.ts +10 -2
- package/dist/utils/errorSerializer.core.js +30 -76
- package/package.json +1 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Errors raised by the `zudojs-cli` scaffolding and generation commands.
|
|
3
|
+
*
|
|
4
|
+
* Owned here so the CLI (and tools that drive it) can match them with
|
|
5
|
+
* `instanceof` against a single class hierarchy.
|
|
6
|
+
*/
|
|
7
|
+
import { ApplicationError } from "../app/application.error.js";
|
|
8
|
+
/** Invalid user input to a CLI command (bad name, unknown option value). */
|
|
9
|
+
export class CLIValidationError extends ApplicationError {
|
|
10
|
+
constructor(message) {
|
|
11
|
+
super(message, { isOperational: true });
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/** A generator or scaffolder failed while producing files. */
|
|
15
|
+
export class CLIGenerationError extends ApplicationError {
|
|
16
|
+
constructor(message, cause) {
|
|
17
|
+
super(message, { cause });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/** The command needs a Zudojs project but was run outside one. */
|
|
21
|
+
export class CLINotInProjectError extends ApplicationError {
|
|
22
|
+
constructor() {
|
|
23
|
+
super("This command must be run inside a Zudojs project directory.", {
|
|
24
|
+
isOperational: true,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/** A template could not be found or rendered. */
|
|
29
|
+
export class CLITemplateError extends ApplicationError {
|
|
30
|
+
constructor(message) {
|
|
31
|
+
super(message);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=cliError.base.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Errors raised by `@zudojs/constants` branded-type factories and
|
|
3
|
+
* environment helpers.
|
|
4
|
+
*/
|
|
5
|
+
import { BaseError } from "../../base/core/baseError.core.js";
|
|
6
|
+
import { ErrorCode } from "../../base/types/errorCode.type.js";
|
|
7
|
+
import type { ErrorMetadata } from "../../base/core/errorMetadata.type.js";
|
|
8
|
+
/** Error thrown when an invalid constant value is used. */
|
|
9
|
+
export declare class InvalidConstantError extends BaseError {
|
|
10
|
+
constructor(message: string, options?: {
|
|
11
|
+
readonly code?: ErrorCode;
|
|
12
|
+
readonly metadata?: ErrorMetadata;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
/** Error thrown when a constant is used outside its valid context. */
|
|
16
|
+
export declare class ConstantContextError extends BaseError {
|
|
17
|
+
constructor(message: string, options?: {
|
|
18
|
+
readonly metadata?: ErrorMetadata;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=constantError.base.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Errors raised by `@zudojs/constants` branded-type factories and
|
|
3
|
+
* environment helpers.
|
|
4
|
+
*/
|
|
5
|
+
import { BaseError } from "../../base/core/baseError.core.js";
|
|
6
|
+
import { ErrorCategory } from "../../base/types/errorCategory.type.js";
|
|
7
|
+
import { ErrorCode } from "../../base/types/errorCode.type.js";
|
|
8
|
+
import { ErrorSeverity } from "../../base/types/errorSeverity.type.js";
|
|
9
|
+
/** Error thrown when an invalid constant value is used. */
|
|
10
|
+
export class InvalidConstantError extends BaseError {
|
|
11
|
+
constructor(message, options) {
|
|
12
|
+
super(message, {
|
|
13
|
+
code: options?.code ?? ErrorCode.CONFIGURATION_INVALID,
|
|
14
|
+
category: ErrorCategory.VALIDATION,
|
|
15
|
+
severity: ErrorSeverity.ERROR,
|
|
16
|
+
metadata: options?.metadata,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/** Error thrown when a constant is used outside its valid context. */
|
|
21
|
+
export class ConstantContextError extends BaseError {
|
|
22
|
+
constructor(message, options) {
|
|
23
|
+
super(message, {
|
|
24
|
+
code: ErrorCode.INVALID_INPUT,
|
|
25
|
+
category: ErrorCategory.VALIDATION,
|
|
26
|
+
severity: ErrorSeverity.ERROR,
|
|
27
|
+
metadata: options?.metadata,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=constantError.base.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base CQRS error, owned here so `@zudojs/cqrs` can extend or re-export it.
|
|
3
|
+
*/
|
|
4
|
+
import type { BaseErrorOptions } from "../../base/types/baseError.type.js";
|
|
5
|
+
import { BaseError } from "../../base/core/baseError.core.js";
|
|
6
|
+
/**
|
|
7
|
+
* Base error for failures originating from the CQRS package.
|
|
8
|
+
*
|
|
9
|
+
* Defaults: `ErrorCode.INTERNAL_ERROR`, category `system`, 500, not exposed.
|
|
10
|
+
*/
|
|
11
|
+
export declare class CqrsError extends BaseError {
|
|
12
|
+
constructor(message: string, options?: BaseErrorOptions);
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=cqrsError.base.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base CQRS error, owned here so `@zudojs/cqrs` can extend or re-export it.
|
|
3
|
+
*/
|
|
4
|
+
import { BaseError } from "../../base/core/baseError.core.js";
|
|
5
|
+
import { ErrorCategory } from "../../base/types/errorCategory.type.js";
|
|
6
|
+
import { ErrorCode } from "../../base/types/errorCode.type.js";
|
|
7
|
+
import { ErrorSeverity } from "../../base/types/errorSeverity.type.js";
|
|
8
|
+
/**
|
|
9
|
+
* Base error for failures originating from the CQRS package.
|
|
10
|
+
*
|
|
11
|
+
* Defaults: `ErrorCode.INTERNAL_ERROR`, category `system`, 500, not exposed.
|
|
12
|
+
*/
|
|
13
|
+
export class CqrsError extends BaseError {
|
|
14
|
+
constructor(message, options = {}) {
|
|
15
|
+
super(message, {
|
|
16
|
+
...options,
|
|
17
|
+
code: options.code ?? ErrorCode.INTERNAL_ERROR,
|
|
18
|
+
category: options.category ?? ErrorCategory.SYSTEM,
|
|
19
|
+
severity: options.severity ?? ErrorSeverity.ERROR,
|
|
20
|
+
statusCode: options.statusCode ?? 500,
|
|
21
|
+
expose: options.expose ?? false,
|
|
22
|
+
isOperational: options.isOperational ?? true,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=cqrsError.base.js.map
|
package/dist/domain/index.d.ts
CHANGED
|
@@ -17,4 +17,10 @@ export * from "./rpc/index.js";
|
|
|
17
17
|
export * from "./scheduler/index.js";
|
|
18
18
|
export * from "./documentation/index.js";
|
|
19
19
|
export * from "./plugin/index.js";
|
|
20
|
+
export * from "./transaction/index.js";
|
|
21
|
+
export * from "./traversal/index.js";
|
|
22
|
+
export * from "./openapi/index.js";
|
|
23
|
+
export * from "./cqrs/index.js";
|
|
24
|
+
export * from "./constant/index.js";
|
|
25
|
+
export * from "./cli/index.js";
|
|
20
26
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/domain/index.js
CHANGED
|
@@ -17,4 +17,10 @@ export * from "./rpc/index.js";
|
|
|
17
17
|
export * from "./scheduler/index.js";
|
|
18
18
|
export * from "./documentation/index.js";
|
|
19
19
|
export * from "./plugin/index.js";
|
|
20
|
+
export * from "./transaction/index.js";
|
|
21
|
+
export * from "./traversal/index.js";
|
|
22
|
+
export * from "./openapi/index.js";
|
|
23
|
+
export * from "./cqrs/index.js";
|
|
24
|
+
export * from "./constant/index.js";
|
|
25
|
+
export * from "./cli/index.js";
|
|
20
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base OpenAPI error. Server-side defaults (500, not exposed): a document
|
|
3
|
+
* that fails to build is an operator's problem, not a client's.
|
|
4
|
+
*/
|
|
5
|
+
import { BaseError } from "../../base/core/baseError.core.js";
|
|
6
|
+
/** Options for creating an OpenAPI error. */
|
|
7
|
+
export interface OpenAPIErrorOptions {
|
|
8
|
+
readonly code?: string;
|
|
9
|
+
/** Overrides the default status (500). */
|
|
10
|
+
readonly statusCode?: number;
|
|
11
|
+
/** Overrides the default exposure (false). */
|
|
12
|
+
readonly expose?: boolean;
|
|
13
|
+
readonly cause?: unknown;
|
|
14
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
15
|
+
}
|
|
16
|
+
/** Base error for all OpenAPI subsystem failures. */
|
|
17
|
+
export declare class OpenAPIError extends BaseError {
|
|
18
|
+
constructor(message: string, options?: OpenAPIErrorOptions);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=openApiError.base.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base OpenAPI error. Server-side defaults (500, not exposed): a document
|
|
3
|
+
* that fails to build is an operator's problem, not a client's.
|
|
4
|
+
*/
|
|
5
|
+
import { BaseError } from "../../base/core/baseError.core.js";
|
|
6
|
+
import { ErrorCategory } from "../../base/types/errorCategory.type.js";
|
|
7
|
+
import { ErrorCode } from "../../base/types/errorCode.type.js";
|
|
8
|
+
import { ErrorSeverity } from "../../base/types/errorSeverity.type.js";
|
|
9
|
+
/** Base error for all OpenAPI subsystem failures. */
|
|
10
|
+
export class OpenAPIError extends BaseError {
|
|
11
|
+
constructor(message, options = {}) {
|
|
12
|
+
super(message, {
|
|
13
|
+
code: options.code ?? ErrorCode.OPENAPI_DOCUMENT,
|
|
14
|
+
category: ErrorCategory.OPENAPI,
|
|
15
|
+
severity: ErrorSeverity.ERROR,
|
|
16
|
+
statusCode: options.statusCode ?? 500,
|
|
17
|
+
expose: options.expose ?? false,
|
|
18
|
+
cause: options.cause,
|
|
19
|
+
metadata: options.metadata,
|
|
20
|
+
});
|
|
21
|
+
this.name = "OpenAPIError";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=openApiError.base.js.map
|
|
@@ -48,8 +48,9 @@ export declare function normalizeRetryAfterSeconds(value: number, name?: string)
|
|
|
48
48
|
export declare function mergeMetadata(callerMetadata: ErrorMetadata | undefined, own: ErrorMetadata): ErrorMetadata;
|
|
49
49
|
/**
|
|
50
50
|
* Removes submitted values from a list of issue objects so they can be
|
|
51
|
-
* exposed to clients. Values are replaced by a type/size
|
|
52
|
-
* `<key>Type
|
|
51
|
+
* exposed to clients or logged. Values are replaced by a type/size
|
|
52
|
+
* description under `<key>Type`; `__proto__`, `constructor` and `prototype`
|
|
53
|
+
* keys are dropped.
|
|
53
54
|
*/
|
|
54
55
|
export declare function redactIssueValues<T>(issues: readonly T[]): readonly T[];
|
|
55
56
|
/**
|
|
@@ -7,9 +7,15 @@
|
|
|
7
7
|
*/
|
|
8
8
|
/** Default maximum length for untrusted strings embedded in messages. */
|
|
9
9
|
export const MAX_MESSAGE_FRAGMENT_LENGTH = 200;
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Characters that must not reach logs: C0, DEL and C1 controls, the Unicode
|
|
12
|
+
* line and paragraph separators (U+2028/U+2029, which break log lines in
|
|
13
|
+
* viewers that honour them), and the bidirectional marks, embeddings,
|
|
14
|
+
* overrides and isolates (U+061C, U+200E/F, U+202A-E, U+2066-9), which can
|
|
15
|
+
* visually reorder a log line.
|
|
16
|
+
*/
|
|
11
17
|
// eslint-disable-next-line no-control-regex
|
|
12
|
-
const CONTROL_CHARS = /[\u0000-\u001f\u007f-\u009f]/g;
|
|
18
|
+
const CONTROL_CHARS = /[\u0000-\u001f\u007f-\u009f\u061c\u200e\u200f\u2028\u2029\u202a-\u202e\u2066-\u2069]/g;
|
|
13
19
|
/** Default maximum length for untrusted strings stored in metadata. */
|
|
14
20
|
export const MAX_METADATA_FRAGMENT_LENGTH = 1024;
|
|
15
21
|
/**
|
|
@@ -48,16 +54,22 @@ export function safeStringify(value, maxLength = MAX_METADATA_FRAGMENT_LENGTH) {
|
|
|
48
54
|
text = "undefined";
|
|
49
55
|
}
|
|
50
56
|
else {
|
|
51
|
-
|
|
52
|
-
|
|
57
|
+
// Track the ancestor path, not every object visited: a sub-object
|
|
58
|
+
// shared by two siblings is repeated data, not a cycle.
|
|
59
|
+
const ancestors = [];
|
|
60
|
+
const json = JSON.stringify(value, function replacer(_key, item) {
|
|
53
61
|
if (typeof item === "bigint")
|
|
54
62
|
return `${item.toString()}n`;
|
|
55
63
|
if (typeof item === "symbol")
|
|
56
64
|
return item.toString();
|
|
57
65
|
if (typeof item === "object" && item !== null) {
|
|
58
|
-
|
|
66
|
+
while (ancestors.length > 0 &&
|
|
67
|
+
ancestors[ancestors.length - 1] !== this) {
|
|
68
|
+
ancestors.pop();
|
|
69
|
+
}
|
|
70
|
+
if (ancestors.includes(item))
|
|
59
71
|
return "[Circular]";
|
|
60
|
-
|
|
72
|
+
ancestors.push(item);
|
|
61
73
|
}
|
|
62
74
|
return item;
|
|
63
75
|
});
|
|
@@ -150,12 +162,22 @@ export function normalizeRetryAfterSeconds(value, name = "retryAfterSeconds") {
|
|
|
150
162
|
export function mergeMetadata(callerMetadata, own) {
|
|
151
163
|
return { ...(callerMetadata ?? {}), ...own };
|
|
152
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* Keys never copied into a redacted issue: assigning an own `__proto__` key
|
|
167
|
+
* (which a JSON round-trip creates) to a plain object replaces its prototype.
|
|
168
|
+
*/
|
|
169
|
+
const FORBIDDEN_ISSUE_KEYS = new Set([
|
|
170
|
+
"__proto__",
|
|
171
|
+
"constructor",
|
|
172
|
+
"prototype",
|
|
173
|
+
]);
|
|
153
174
|
/** Keys that hold submitted values inside validation/schema issues. */
|
|
154
175
|
const VALUE_KEYS = new Set(["value", "received", "input", "actual"]);
|
|
155
176
|
/**
|
|
156
177
|
* Removes submitted values from a list of issue objects so they can be
|
|
157
|
-
* exposed to clients. Values are replaced by a type/size
|
|
158
|
-
* `<key>Type
|
|
178
|
+
* exposed to clients or logged. Values are replaced by a type/size
|
|
179
|
+
* description under `<key>Type`; `__proto__`, `constructor` and `prototype`
|
|
180
|
+
* keys are dropped.
|
|
159
181
|
*/
|
|
160
182
|
export function redactIssueValues(issues) {
|
|
161
183
|
return issues.map((issue) => {
|
|
@@ -164,6 +186,8 @@ export function redactIssueValues(issues) {
|
|
|
164
186
|
}
|
|
165
187
|
const out = {};
|
|
166
188
|
for (const [key, val] of Object.entries(issue)) {
|
|
189
|
+
if (FORBIDDEN_ISSUE_KEYS.has(key))
|
|
190
|
+
continue;
|
|
167
191
|
if (VALUE_KEYS.has(key)) {
|
|
168
192
|
out[`${key}Type`] = describeValue(val);
|
|
169
193
|
}
|
|
@@ -34,9 +34,10 @@ export declare class ValidationError extends BaseError {
|
|
|
34
34
|
/**
|
|
35
35
|
* Returns a serialized representation including validation issues.
|
|
36
36
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* such as passwords are never echoed to
|
|
37
|
+
* Submitted values inside issues (`value`, `received`, `input`, `actual`)
|
|
38
|
+
* are always replaced by a type/size description, whether or not the error
|
|
39
|
+
* is exposable, so that secrets such as passwords are never echoed to
|
|
40
|
+
* clients or written to logs. The raw values remain on `error.issues`. The
|
|
40
41
|
* output is always JSON-safe (BigInt and cyclic values are stringified).
|
|
41
42
|
*/
|
|
42
43
|
toJSON(): {
|
|
@@ -35,16 +35,17 @@ export class ValidationError extends BaseError {
|
|
|
35
35
|
/**
|
|
36
36
|
* Returns a serialized representation including validation issues.
|
|
37
37
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* such as passwords are never echoed to
|
|
38
|
+
* Submitted values inside issues (`value`, `received`, `input`, `actual`)
|
|
39
|
+
* are always replaced by a type/size description, whether or not the error
|
|
40
|
+
* is exposable, so that secrets such as passwords are never echoed to
|
|
41
|
+
* clients or written to logs. The raw values remain on `error.issues`. The
|
|
41
42
|
* output is always JSON-safe (BigInt and cyclic values are stringified).
|
|
42
43
|
*/
|
|
43
44
|
toJSON() {
|
|
44
45
|
const safeIssues = toJsonSafeIssues(this.issues);
|
|
45
46
|
return {
|
|
46
47
|
...super.toJSON(),
|
|
47
|
-
issues:
|
|
48
|
+
issues: redactIssueValues(safeIssues),
|
|
48
49
|
};
|
|
49
50
|
}
|
|
50
51
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @zudojs/errors/domain/transaction
|
|
3
|
+
*
|
|
4
|
+
* Transaction lifecycle errors (state, timeout, commit, rollback, adapter,
|
|
5
|
+
* propagation, isolation, savepoint, presence, capability).
|
|
6
|
+
*/
|
|
7
|
+
export * from "./transactionError.base.js";
|
|
8
|
+
export * from "./transactionError.types.js";
|
|
9
|
+
export * from "./transactionError.misc.js";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @zudojs/errors/domain/transaction
|
|
3
|
+
*
|
|
4
|
+
* Transaction lifecycle errors (state, timeout, commit, rollback, adapter,
|
|
5
|
+
* propagation, isolation, savepoint, presence, capability).
|
|
6
|
+
*/
|
|
7
|
+
export * from "./transactionError.base.js";
|
|
8
|
+
export * from "./transactionError.types.js";
|
|
9
|
+
export * from "./transactionError.misc.js";
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base transaction error, owned here so `@zudojs/transactions` can re-export
|
|
3
|
+
* it and `instanceof` matches across both import paths.
|
|
4
|
+
*/
|
|
5
|
+
import { BaseError } from "../../base/core/baseError.core.js";
|
|
6
|
+
import { ErrorCode } from "../../base/types/errorCode.type.js";
|
|
7
|
+
import type { ErrorMetadata } from "../../base/core/errorMetadata.type.js";
|
|
8
|
+
/** Options accepted by {@link TransactionError}. */
|
|
9
|
+
export interface TransactionErrorOptions {
|
|
10
|
+
readonly code?: ErrorCode;
|
|
11
|
+
readonly metadata?: ErrorMetadata;
|
|
12
|
+
readonly cause?: unknown;
|
|
13
|
+
}
|
|
14
|
+
/** Base error for all transaction-related failures. */
|
|
15
|
+
export declare class TransactionError extends BaseError {
|
|
16
|
+
constructor(message: string, options?: TransactionErrorOptions);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=transactionError.base.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base transaction error, owned here so `@zudojs/transactions` can re-export
|
|
3
|
+
* it and `instanceof` matches across both import paths.
|
|
4
|
+
*/
|
|
5
|
+
import { BaseError } from "../../base/core/baseError.core.js";
|
|
6
|
+
import { ErrorCategory } from "../../base/types/errorCategory.type.js";
|
|
7
|
+
import { ErrorCode } from "../../base/types/errorCode.type.js";
|
|
8
|
+
import { ErrorSeverity } from "../../base/types/errorSeverity.type.js";
|
|
9
|
+
/** Base error for all transaction-related failures. */
|
|
10
|
+
export class TransactionError extends BaseError {
|
|
11
|
+
constructor(message, options) {
|
|
12
|
+
super(message, {
|
|
13
|
+
code: options?.code ?? ErrorCode.OPERATION_FAILED,
|
|
14
|
+
category: ErrorCategory.DATABASE,
|
|
15
|
+
severity: ErrorSeverity.ERROR,
|
|
16
|
+
metadata: options?.metadata,
|
|
17
|
+
cause: options?.cause,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=transactionError.base.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remaining transaction error subclasses (isolation, savepoints, presence,
|
|
3
|
+
* capabilities).
|
|
4
|
+
*/
|
|
5
|
+
import { TransactionError } from "./transactionError.base.js";
|
|
6
|
+
/** Required isolation level is not supported by the adapter. */
|
|
7
|
+
export declare class TransactionIsolationError extends TransactionError {
|
|
8
|
+
constructor(level: string);
|
|
9
|
+
}
|
|
10
|
+
/** Savepoint operation failed. */
|
|
11
|
+
export declare class SavepointError extends TransactionError {
|
|
12
|
+
constructor(message: string, cause?: unknown);
|
|
13
|
+
}
|
|
14
|
+
/** A transaction is required but none exists. */
|
|
15
|
+
export declare class TransactionRequiredError extends TransactionError {
|
|
16
|
+
constructor();
|
|
17
|
+
}
|
|
18
|
+
/** A transaction exists but none was expected. */
|
|
19
|
+
export declare class TransactionUnexpectedError extends TransactionError {
|
|
20
|
+
constructor();
|
|
21
|
+
}
|
|
22
|
+
/** The adapter does not support the requested capability. */
|
|
23
|
+
export declare class TransactionCapabilityError extends TransactionError {
|
|
24
|
+
constructor(capability: string);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=transactionError.misc.d.ts.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remaining transaction error subclasses (isolation, savepoints, presence,
|
|
3
|
+
* capabilities).
|
|
4
|
+
*/
|
|
5
|
+
import { ErrorCode } from "../../base/types/errorCode.type.js";
|
|
6
|
+
import { TransactionError } from "./transactionError.base.js";
|
|
7
|
+
/** Required isolation level is not supported by the adapter. */
|
|
8
|
+
export class TransactionIsolationError extends TransactionError {
|
|
9
|
+
constructor(level) {
|
|
10
|
+
super(`Isolation level "${level}" is not supported by the adapter`, {
|
|
11
|
+
code: ErrorCode.VALIDATION_FAILED,
|
|
12
|
+
metadata: { level },
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/** Savepoint operation failed. */
|
|
17
|
+
export class SavepointError extends TransactionError {
|
|
18
|
+
constructor(message, cause) {
|
|
19
|
+
super(message, { code: ErrorCode.OPERATION_FAILED, cause });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/** A transaction is required but none exists. */
|
|
23
|
+
export class TransactionRequiredError extends TransactionError {
|
|
24
|
+
constructor() {
|
|
25
|
+
super("A transaction is required but none exists", {
|
|
26
|
+
code: ErrorCode.PRECONDITION_FAILED,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/** A transaction exists but none was expected. */
|
|
31
|
+
export class TransactionUnexpectedError extends TransactionError {
|
|
32
|
+
constructor() {
|
|
33
|
+
super("A transaction already exists but none was expected", {
|
|
34
|
+
code: ErrorCode.CONFLICT,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/** The adapter does not support the requested capability. */
|
|
39
|
+
export class TransactionCapabilityError extends TransactionError {
|
|
40
|
+
constructor(capability) {
|
|
41
|
+
super(`Adapter does not support: ${capability}`, {
|
|
42
|
+
code: ErrorCode.NOT_IMPLEMENTED,
|
|
43
|
+
metadata: { capability },
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=transactionError.misc.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Specific transaction error subclasses. Constructor signatures and codes
|
|
3
|
+
* match the classes `@zudojs/transactions` defined locally.
|
|
4
|
+
*/
|
|
5
|
+
import { TransactionError } from "./transactionError.base.js";
|
|
6
|
+
/** Transaction is in an invalid state for the requested operation. */
|
|
7
|
+
export declare class TransactionStateError extends TransactionError {
|
|
8
|
+
constructor(state: string, operation: string);
|
|
9
|
+
}
|
|
10
|
+
/** Transaction exceeded its timeout. */
|
|
11
|
+
export declare class TransactionTimeoutError extends TransactionError {
|
|
12
|
+
constructor(transactionId: string, timeoutMs: number);
|
|
13
|
+
}
|
|
14
|
+
/** Transaction commit failed. */
|
|
15
|
+
export declare class TransactionCommitError extends TransactionError {
|
|
16
|
+
constructor(transactionId: string, cause?: unknown);
|
|
17
|
+
}
|
|
18
|
+
/** Transaction rollback failed. */
|
|
19
|
+
export declare class TransactionRollbackError extends TransactionError {
|
|
20
|
+
constructor(transactionId: string, options?: {
|
|
21
|
+
readonly cause?: unknown;
|
|
22
|
+
readonly originalError?: unknown;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
/** The underlying adapter threw an error. */
|
|
26
|
+
export declare class TransactionAdapterError extends TransactionError {
|
|
27
|
+
constructor(message: string, cause?: unknown);
|
|
28
|
+
}
|
|
29
|
+
/** Propagation strategy violation. */
|
|
30
|
+
export declare class TransactionPropagationError extends TransactionError {
|
|
31
|
+
constructor(message: string);
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=transactionError.types.d.ts.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Specific transaction error subclasses. Constructor signatures and codes
|
|
3
|
+
* match the classes `@zudojs/transactions` defined locally.
|
|
4
|
+
*/
|
|
5
|
+
import { ErrorCode } from "../../base/types/errorCode.type.js";
|
|
6
|
+
import { TransactionError } from "./transactionError.base.js";
|
|
7
|
+
/** Transaction is in an invalid state for the requested operation. */
|
|
8
|
+
export class TransactionStateError extends TransactionError {
|
|
9
|
+
constructor(state, operation) {
|
|
10
|
+
super(`Cannot ${operation} transaction in state "${state}"`, {
|
|
11
|
+
code: ErrorCode.LIFECYCLE_STATE,
|
|
12
|
+
metadata: { state, operation },
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/** Transaction exceeded its timeout. */
|
|
17
|
+
export class TransactionTimeoutError extends TransactionError {
|
|
18
|
+
constructor(transactionId, timeoutMs) {
|
|
19
|
+
super(`Transaction "${transactionId}" timed out after ${timeoutMs}ms`, {
|
|
20
|
+
code: ErrorCode.TIMEOUT,
|
|
21
|
+
metadata: { transactionId, timeoutMs },
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/** Transaction commit failed. */
|
|
26
|
+
export class TransactionCommitError extends TransactionError {
|
|
27
|
+
constructor(transactionId, cause) {
|
|
28
|
+
super(`Transaction "${transactionId}" commit failed`, {
|
|
29
|
+
code: ErrorCode.DATABASE_TRANSACTION,
|
|
30
|
+
cause,
|
|
31
|
+
metadata: { transactionId },
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/** Transaction rollback failed. */
|
|
36
|
+
export class TransactionRollbackError extends TransactionError {
|
|
37
|
+
constructor(transactionId, options) {
|
|
38
|
+
super(`Transaction "${transactionId}" rollback failed`, {
|
|
39
|
+
code: ErrorCode.DATABASE_TRANSACTION,
|
|
40
|
+
cause: options?.cause,
|
|
41
|
+
metadata: {
|
|
42
|
+
transactionId,
|
|
43
|
+
originalError: options?.originalError instanceof Error
|
|
44
|
+
? options.originalError.message
|
|
45
|
+
: String(options?.originalError ?? "unknown"),
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/** The underlying adapter threw an error. */
|
|
51
|
+
export class TransactionAdapterError extends TransactionError {
|
|
52
|
+
constructor(message, cause) {
|
|
53
|
+
super(message, { code: ErrorCode.ADAPTER_OPERATION_FAILED, cause });
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/** Propagation strategy violation. */
|
|
57
|
+
export class TransactionPropagationError extends TransactionError {
|
|
58
|
+
constructor(message) {
|
|
59
|
+
super(message, { code: ErrorCode.VALIDATION_FAILED });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=transactionError.types.js.map
|