@cullet/erp-core 1.0.1 → 1.0.3
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 +24 -24
- package/dist/gate-engine-registry.js.map +1 -1
- package/dist/gate-v1-payload.schema.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/outcome.js.map +1 -1
- package/dist/policies/engines/v1/gate/index.js.map +1 -1
- package/dist/policy-service.js.map +1 -1
- package/dist/validation-code.js.map +1 -1
- package/dist/validation-error.js.map +1 -1
- package/dist/validation-field.js.map +1 -1
- package/meta.json +67 -62
- package/package.json +56 -56
- package/src/core/application/commands/command.ts +3 -3
- package/src/core/application/commands/requested-by.ts +60 -60
- package/src/core/application/index.ts +21 -21
- package/src/core/application/policy-error-mapper.ts +54 -54
- package/src/core/application/ports/index.ts +6 -6
- package/src/core/application/ports/logger.port.ts +4 -4
- package/src/core/application/ports/metrics.port.ts +3 -3
- package/src/core/application/ports/policy-port.ts +7 -7
- package/src/core/application/ports/repository.port.ts +3 -3
- package/src/core/application/ports/temporal-repository.port.ts +4 -4
- package/src/core/application/ports/tracer.port.ts +7 -7
- package/src/core/application/queries/query.ts +13 -13
- package/src/core/application/temporal/index.ts +7 -7
- package/src/core/application/temporal/temporal-context.ts +20 -20
- package/src/core/application/temporal/temporal-use-case.ts +22 -22
- package/src/core/application/use-case.ts +10 -10
- package/src/core/config/core-config.instance.ts +1 -1
- package/src/core/config/core-config.ts +59 -59
- package/src/core/config/index.ts +6 -6
- package/src/core/config/policy-reporter.ts +31 -31
- package/src/core/config/silent-policy-reporter.ts +1 -1
- package/src/core/domain/entity.ts +44 -44
- package/src/core/domain/rulesets/entity-ruleset.contracts.ts +6 -6
- package/src/core/domain/rulesets/ruleset-registry.ts +49 -49
- package/src/core/domain/rulesets/ruleset.contracts.ts +6 -6
- package/src/core/domain/rulesets/value-object-ruleset.contracts.ts +5 -5
- package/src/core/domain/temporal/index.ts +11 -11
- package/src/core/domain/temporal/temporal-range.ts +16 -16
- package/src/core/domain/temporal/temporal-snapshot.ts +24 -24
- package/src/core/domain/temporal/transaction-time.ts +30 -30
- package/src/core/domain/temporal/valid-time.ts +29 -29
- package/src/core/domain/value-object.ts +16 -16
- package/src/core/errors/app-error.ts +64 -64
- package/src/core/errors/authentication-error.ts +134 -134
- package/src/core/errors/authorization-error.ts +154 -154
- package/src/core/errors/business-rule-violation-error.ts +15 -15
- package/src/core/errors/conflict-error.ts +202 -201
- package/src/core/errors/error-codes.ts +48 -48
- package/src/core/errors/idempotency-error.ts +324 -320
- package/src/core/errors/index.ts +50 -50
- package/src/core/errors/integration-error.ts +120 -120
- package/src/core/errors/legacy-incompatible-error.ts +13 -13
- package/src/core/errors/not-found-error.ts +14 -14
- package/src/core/errors/serialization-error.ts +167 -167
- package/src/core/errors/temporal-error.ts +109 -107
- package/src/core/errors/types.ts +35 -35
- package/src/core/errors/unexpected-error.ts +10 -10
- package/src/core/errors/utils/index.ts +2 -2
- package/src/core/errors/utils/json-safe.ts +53 -53
- package/src/core/errors/validation-error.ts +18 -18
- package/src/core/exceptions/business-rule-violation-exception.ts +6 -6
- package/src/core/exceptions/domain-exception.ts +5 -5
- package/src/core/exceptions/entity-not-found-exception.ts +6 -6
- package/src/core/exceptions/invalid-state-transition-exception.ts +8 -8
- package/src/core/exceptions/invariant-violation-exception.ts +3 -3
- package/src/core/exceptions/validation-code.ts +35 -29
- package/src/core/exceptions/validation-exception.ts +19 -19
- package/src/core/exceptions/validation-field.ts +20 -19
- package/src/core/index.ts +7 -7
- package/src/core/policies/asof/asof.ts +47 -47
- package/src/core/policies/catalog/catalog.instance.ts +8 -6
- package/src/core/policies/catalog/index.ts +4 -4
- package/src/core/policies/catalog/policy-catalog-entry.ts +199 -197
- package/src/core/policies/catalog/policy-catalog.ts +101 -101
- package/src/core/policies/catalog/policy-key.ts +51 -51
- package/src/core/policies/context/context-builder.ts +335 -313
- package/src/core/policies/context/context-registry.instance.ts +9 -9
- package/src/core/policies/context/context-registry.ts +61 -61
- package/src/core/policies/context/context-resolver.ts +12 -12
- package/src/core/policies/context/context-seed.ts +19 -15
- package/src/core/policies/context/index.ts +9 -9
- package/src/core/policies/context/path.ts +135 -128
- package/src/core/policies/defs/in-memory-policy-definition-repo.ts +56 -55
- package/src/core/policies/defs/index.ts +10 -10
- package/src/core/policies/defs/policy-definition-repository.ts +3 -3
- package/src/core/policies/defs/policy-definition.ts +143 -142
- package/src/core/policies/defs/policy-scope.ts +21 -19
- package/src/core/policies/defs/policy-semver.ts +51 -51
- package/src/core/policies/engines/compute-engine-registry.ts +43 -43
- package/src/core/policies/engines/compute-evaluator-registry.ts +20 -20
- package/src/core/policies/engines/compute-registry.ts +45 -45
- package/src/core/policies/engines/compute-types.ts +15 -15
- package/src/core/policies/engines/condition-evaluator-reporter.ts +17 -17
- package/src/core/policies/engines/gate-engine-registry.ts +27 -25
- package/src/core/policies/engines/gate-types.ts +28 -28
- package/src/core/policies/engines/index.ts +28 -28
- package/src/core/policies/engines/parse-compute-payload.ts +51 -45
- package/src/core/policies/engines/parse-gate-payload.ts +42 -42
- package/src/core/policies/engines/v1/compute/compute-engine-v1.ts +39 -37
- package/src/core/policies/engines/v1/compute/compute-payload.schema.ts +43 -41
- package/src/core/policies/engines/v1/compute/index.ts +6 -6
- package/src/core/policies/engines/v1/compute/resolve-decision-table-v1.ts +41 -39
- package/src/core/policies/engines/v1/condition-evaluator.ts +547 -505
- package/src/core/policies/engines/v1/condition-schema.ts +35 -35
- package/src/core/policies/engines/v1/condition-types.ts +21 -21
- package/src/core/policies/engines/v1/gate/gate-engine-v1.ts +134 -130
- package/src/core/policies/engines/v1/gate/gate-types-v1.ts +5 -5
- package/src/core/policies/engines/v1/gate/gate-v1-payload.schema.ts +32 -30
- package/src/core/policies/engines/v1/gate/index.ts +4 -4
- package/src/core/policies/engines/v1/index.ts +8 -8
- package/src/core/policies/index.ts +72 -72
- package/src/core/policies/package/policy-package.ts +3 -3
- package/src/core/policies/policy-ids.ts +25 -25
- package/src/core/policies/resolver/policy-resolver.ts +34 -34
- package/src/core/policies/service/index.ts +6 -6
- package/src/core/policies/service/policy-evaluation-error.ts +141 -133
- package/src/core/policies/service/policy-service.ts +432 -419
- package/src/core/policies/utils/date.ts +3 -3
- package/src/core/policies/utils/hash.ts +61 -61
- package/src/core/result/outcome.ts +131 -126
- package/src/core/result/result.ts +130 -127
- package/src/core/shared/aggregate-version.ts +5 -5
- package/src/core/shared/hashing.ts +18 -18
- package/src/core/shared/immutable.ts +29 -29
- package/src/core/shared/temporal-guards.ts +9 -9
- package/src/core/versioning/domain-event-contracts.ts +40 -40
- package/src/core/versioning/version.ts +19 -19
- package/src/examples/rulesets/entity/order-creation-rules-v1.ts +18 -18
- package/src/examples/rulesets/entity/order-invariants-v1.ts +31 -29
- package/src/examples/rulesets/entity/order-invariants-v2.ts +12 -12
- package/src/examples/rulesets/entity/order.ts +127 -127
- package/src/examples/rulesets/value-object/cpf-rules-v1.ts +41 -39
- package/src/examples/rulesets/value-object/cpf-rules-v2.ts +14 -12
- package/src/examples/rulesets/value-object/cpf.ts +24 -24
- package/src/examples/rulesets/value-object/customer.ts +42 -39
- package/src/examples/rulesets/value-object/person-name-rules-v1.ts +27 -27
- package/src/examples/rulesets/value-object/person-name-rules-v2.ts +13 -13
- package/src/examples/rulesets/value-object/person-name.ts +29 -26
- package/src/index.ts +2 -2
- package/src/version.ts +1 -1
|
@@ -9,77 +9,77 @@ import { assertJsonSafeMetadata } from "./utils";
|
|
|
9
9
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
10
10
|
|
|
11
11
|
abstract class AppError extends Error {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
12
|
+
public readonly code: string;
|
|
13
|
+
public readonly cause?: unknown;
|
|
14
|
+
public readonly metadata?: JsonSafeRecord;
|
|
15
|
+
public readonly type?: string;
|
|
16
|
+
public readonly severity?: ErrorSeverity;
|
|
17
|
+
public readonly createdAtIso: string;
|
|
18
|
+
public readonly publicMessage?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Identifies a single execution "story" in the system. All operations
|
|
21
|
+
* related to the same logical flow must share the same correlationId.
|
|
22
|
+
*/
|
|
23
|
+
public readonly correlationId?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Identifies a specific technical request attempt (each retry may produce
|
|
26
|
+
* a new requestId), even when the correlationId stays the same.
|
|
27
|
+
*/
|
|
28
|
+
public readonly requestId?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Marks the business intent / idempotency key; stays the same across
|
|
31
|
+
* technical retries and multiple requests that represent the same intent.
|
|
32
|
+
*/
|
|
33
|
+
public readonly commandId?: string;
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
protected constructor(
|
|
36
|
+
message: string,
|
|
37
|
+
code: string,
|
|
38
|
+
options?: AppErrorOptions,
|
|
39
|
+
) {
|
|
40
|
+
super(message);
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
42
|
+
this.name = new.target.name;
|
|
43
|
+
this.code = code;
|
|
44
|
+
this.cause = options?.cause;
|
|
45
|
+
this.type = options?.type;
|
|
46
|
+
this.severity = options?.severity;
|
|
47
|
+
this.correlationId = options?.correlationId;
|
|
48
|
+
this.requestId = options?.requestId;
|
|
49
|
+
this.commandId = options?.commandId;
|
|
50
|
+
this.createdAtIso = options?.createdAtIso ?? new Date().toISOString();
|
|
51
|
+
this.publicMessage = options?.publicMessage;
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
this.metadata = options?.metadata
|
|
54
|
+
? assertJsonSafeMetadata(options.metadata)
|
|
55
|
+
: undefined;
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
58
|
+
}
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Returns a JSON-safe representation of the error.
|
|
62
|
+
* Does NOT include `cause` by default (to avoid leaking internal details).
|
|
63
|
+
*/
|
|
64
|
+
public toJSON(): Record<string, unknown> {
|
|
65
|
+
const payload: Record<string, unknown> = {
|
|
66
|
+
name: this.name,
|
|
67
|
+
code: this.code,
|
|
68
|
+
type: this.type,
|
|
69
|
+
severity: this.severity,
|
|
70
|
+
message: this.message,
|
|
71
|
+
publicMessage: this.publicMessage,
|
|
72
|
+
createdAtIso: this.createdAtIso,
|
|
73
|
+
metadata: this.metadata,
|
|
74
|
+
};
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
if (this.correlationId !== undefined)
|
|
77
|
+
payload.correlationId = this.correlationId;
|
|
78
|
+
if (this.requestId !== undefined) payload.requestId = this.requestId;
|
|
79
|
+
if (this.commandId !== undefined) payload.commandId = this.commandId;
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
return payload;
|
|
82
|
+
}
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
export { AppError };
|
|
@@ -7,137 +7,137 @@ import type { AppErrorOptions, ErrorSeverity } from "./types";
|
|
|
7
7
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
8
8
|
|
|
9
9
|
type AuthenticationErrorReason =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
| "missing_token"
|
|
11
|
+
| "malformed_token"
|
|
12
|
+
| "invalid_token"
|
|
13
|
+
| "expired_token"
|
|
14
|
+
| "revoked_token"
|
|
15
|
+
| "invalid_credentials"
|
|
16
|
+
| "session_not_found"
|
|
17
|
+
| "session_expired"
|
|
18
|
+
| "unknown";
|
|
19
19
|
|
|
20
20
|
type AuthenticationErrorMetadata = {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
reason: AuthenticationErrorReason;
|
|
22
|
+
authScheme?: "bearer" | "cookie" | "basic" | "unknown";
|
|
23
|
+
tokenLocation?: "header" | "cookie" | "query" | "unknown";
|
|
24
|
+
expiresAtIso?: string;
|
|
25
|
+
correlationId?: string;
|
|
26
|
+
requestId?: string;
|
|
27
|
+
details?: string;
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
type AuthenticationErrorFactoryOptions = Omit<
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
AuthenticationErrorMetadata,
|
|
32
|
+
"reason"
|
|
33
33
|
> &
|
|
34
|
-
|
|
34
|
+
Omit<AppErrorOptions, "metadata">;
|
|
35
35
|
|
|
36
36
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
37
37
|
// AuthenticationError
|
|
38
38
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
39
39
|
|
|
40
40
|
class AuthenticationError extends AppError {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
41
|
+
public readonly reason: AuthenticationErrorReason;
|
|
42
|
+
|
|
43
|
+
private constructor(params: {
|
|
44
|
+
message: string;
|
|
45
|
+
code: string;
|
|
46
|
+
reason: AuthenticationErrorReason;
|
|
47
|
+
metadata?: Omit<AuthenticationErrorMetadata, "reason">;
|
|
48
|
+
cause?: unknown;
|
|
49
|
+
type?: string;
|
|
50
|
+
severity?: ErrorSeverity;
|
|
51
|
+
correlationId?: string;
|
|
52
|
+
requestId?: string;
|
|
53
|
+
commandId?: string;
|
|
54
|
+
createdAtIso?: string;
|
|
55
|
+
publicMessage?: string;
|
|
56
|
+
}) {
|
|
57
|
+
super(params.message, params.code, {
|
|
58
|
+
cause: params.cause,
|
|
59
|
+
metadata: {
|
|
60
|
+
reason: params.reason,
|
|
61
|
+
...(params.metadata ?? {}),
|
|
62
|
+
},
|
|
63
|
+
type: params.type,
|
|
64
|
+
severity: params.severity,
|
|
65
|
+
correlationId: params.correlationId,
|
|
66
|
+
requestId: params.requestId,
|
|
67
|
+
commandId: params.commandId,
|
|
68
|
+
createdAtIso: params.createdAtIso,
|
|
69
|
+
publicMessage: params.publicMessage,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
this.reason = params.reason;
|
|
73
|
+
Object.freeze(this);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
77
|
+
// Factory methods
|
|
78
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
79
|
+
|
|
80
|
+
static missingToken(
|
|
81
|
+
options?: AuthenticationErrorFactoryOptions,
|
|
82
|
+
): AuthenticationError {
|
|
83
|
+
return new AuthenticationError({
|
|
84
|
+
message: "Missing credentials",
|
|
85
|
+
code: ErrorCodes.authentication.missingToken,
|
|
86
|
+
reason: "missing_token",
|
|
87
|
+
metadata: compactMetadata(options),
|
|
88
|
+
...extractAppErrorOptions(options),
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
static invalidToken(
|
|
93
|
+
options?: AuthenticationErrorFactoryOptions & { cause?: unknown },
|
|
94
|
+
): AuthenticationError {
|
|
95
|
+
return new AuthenticationError({
|
|
96
|
+
message: "Invalid credentials",
|
|
97
|
+
code: ErrorCodes.authentication.invalidToken,
|
|
98
|
+
reason: "invalid_token",
|
|
99
|
+
metadata: compactMetadata({
|
|
100
|
+
authScheme: options?.authScheme,
|
|
101
|
+
tokenLocation: options?.tokenLocation,
|
|
102
|
+
details: options?.details,
|
|
103
|
+
correlationId: options?.correlationId,
|
|
104
|
+
requestId: options?.requestId,
|
|
105
|
+
}),
|
|
106
|
+
...extractAppErrorOptions(options),
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
static expiredToken(
|
|
111
|
+
options?: AuthenticationErrorFactoryOptions & { sessionId?: string },
|
|
112
|
+
): AuthenticationError {
|
|
113
|
+
return new AuthenticationError({
|
|
114
|
+
message: "Expired credentials",
|
|
115
|
+
code: ErrorCodes.authentication.expiredToken,
|
|
116
|
+
reason: "expired_token",
|
|
117
|
+
metadata: compactMetadata(options),
|
|
118
|
+
...extractAppErrorOptions(options),
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
static invalidCredentials(
|
|
123
|
+
options?: Pick<
|
|
124
|
+
AuthenticationErrorFactoryOptions,
|
|
125
|
+
| "correlationId"
|
|
126
|
+
| "requestId"
|
|
127
|
+
| "type"
|
|
128
|
+
| "severity"
|
|
129
|
+
| "createdAtIso"
|
|
130
|
+
| "publicMessage"
|
|
131
|
+
>,
|
|
132
|
+
): AuthenticationError {
|
|
133
|
+
return new AuthenticationError({
|
|
134
|
+
message: "Invalid username or password",
|
|
135
|
+
code: ErrorCodes.authentication.invalidCredentials,
|
|
136
|
+
reason: "invalid_credentials",
|
|
137
|
+
metadata: compactMetadata(options),
|
|
138
|
+
...extractAppErrorOptions(options),
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
@@ -145,26 +145,26 @@ class AuthenticationError extends AppError {
|
|
|
145
145
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
146
146
|
|
|
147
147
|
function extractAppErrorOptions(options?: Partial<AppErrorOptions>) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
148
|
+
return {
|
|
149
|
+
cause: options?.cause,
|
|
150
|
+
type: options?.type,
|
|
151
|
+
severity: options?.severity,
|
|
152
|
+
correlationId: options?.correlationId,
|
|
153
|
+
requestId: options?.requestId,
|
|
154
|
+
commandId: options?.commandId,
|
|
155
|
+
createdAtIso: options?.createdAtIso,
|
|
156
|
+
publicMessage: options?.publicMessage,
|
|
157
|
+
};
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
function compactMetadata<T extends Record<string, unknown>>(
|
|
161
|
-
|
|
161
|
+
input?: T,
|
|
162
162
|
): T | undefined {
|
|
163
|
-
|
|
163
|
+
if (!input) return undefined;
|
|
164
164
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
165
|
+
return Object.fromEntries(
|
|
166
|
+
Object.entries(input).filter(([, value]) => value !== undefined),
|
|
167
|
+
) as T;
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
export { AuthenticationError };
|