@cullet/erp-core 1.0.2 → 1.0.4
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 +5 -0
- 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.d.ts +1 -0
- 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 -67
- 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 +557 -504
- 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
package/src/core/errors/index.ts
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
4
4
|
|
|
5
5
|
export type {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
AppErrorOptions,
|
|
7
|
+
ErrorSeverity,
|
|
8
|
+
JsonSafePrimitive,
|
|
9
|
+
JsonSafeRecord,
|
|
10
|
+
JsonSafeValue,
|
|
11
11
|
} from "./types";
|
|
12
12
|
|
|
13
13
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
@@ -23,77 +23,77 @@ export { assertJsonSafeMetadata } from "./utils";
|
|
|
23
23
|
|
|
24
24
|
export { AppError } from "./app-error";
|
|
25
25
|
export type {
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
AuthenticationErrorMetadata,
|
|
27
|
+
AuthenticationErrorReason,
|
|
28
28
|
} from "./authentication-error";
|
|
29
29
|
export { AuthenticationError } from "./authentication-error";
|
|
30
30
|
export type {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
AuthorizationErrorMetadata,
|
|
32
|
+
AuthorizationErrorReason,
|
|
33
|
+
AuthorizationRequirement,
|
|
34
34
|
} from "./authorization-error";
|
|
35
35
|
export { AuthorizationError } from "./authorization-error";
|
|
36
36
|
export { BusinessRuleViolationError } from "./business-rule-violation-error";
|
|
37
37
|
export type {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
ConflictErrorMetadata,
|
|
39
|
+
ConflictKind,
|
|
40
|
+
UniqueConstraintViolation,
|
|
41
41
|
} from "./conflict-error";
|
|
42
42
|
export {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
AlreadyExistsError,
|
|
44
|
+
ConflictError,
|
|
45
|
+
DuplicateError,
|
|
46
|
+
translateUniqueViolationToDuplicate,
|
|
47
|
+
UniqueConstraintViolationError,
|
|
48
48
|
} from "./conflict-error";
|
|
49
49
|
export type {
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
IdempotencyErrorMetadata,
|
|
51
|
+
IdempotencyFailureKind,
|
|
52
52
|
} from "./idempotency-error";
|
|
53
53
|
export {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
54
|
+
IdempotencyError,
|
|
55
|
+
IdempotencyInProgressError,
|
|
56
|
+
IdempotencyKeyMissingError,
|
|
57
|
+
IdempotencyPayloadMismatchError,
|
|
58
|
+
IdempotencyReplayNotSupportedError,
|
|
59
|
+
payloadHash,
|
|
60
|
+
sha256Hex,
|
|
61
|
+
stableStringify,
|
|
62
62
|
} from "./idempotency-error";
|
|
63
63
|
export type {
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
IntegrationErrorMetadata,
|
|
65
|
+
IntegrationErrorReason,
|
|
66
66
|
} from "./integration-error";
|
|
67
67
|
export { IntegrationError } from "./integration-error";
|
|
68
68
|
export { LegacyIncompatibleError } from "./legacy-incompatible-error";
|
|
69
69
|
export { NotFoundError } from "./not-found-error";
|
|
70
70
|
export type {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
SerializationBoundary,
|
|
72
|
+
SerializationDirection,
|
|
73
|
+
SerializationErrorMetadata,
|
|
74
|
+
SerializationFailureCategory,
|
|
75
75
|
} from "./serialization-error";
|
|
76
76
|
export {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
77
|
+
SerializationInError as DeserializationError,
|
|
78
|
+
safePreview,
|
|
79
|
+
SerializationCodes,
|
|
80
|
+
SerializationError,
|
|
81
|
+
SerializationInError,
|
|
82
|
+
SerializationMessages,
|
|
83
|
+
SerializationOutError,
|
|
84
84
|
} from "./serialization-error";
|
|
85
85
|
export type {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
TemporalErrorMetadata as ExpiredErrorMetadata,
|
|
87
|
+
TemporalPrecision as ExpiredErrorPrecision,
|
|
88
|
+
TemporalErrorMetadata,
|
|
89
|
+
TemporalKind,
|
|
90
|
+
TemporalPrecision,
|
|
91
91
|
} from "./temporal-error";
|
|
92
92
|
export {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
evaluateTemporalWindow,
|
|
94
|
+
ExpiredError,
|
|
95
|
+
NotYetValidError,
|
|
96
|
+
TemporalError,
|
|
97
97
|
} from "./temporal-error";
|
|
98
98
|
export { UnexpectedError } from "./unexpected-error";
|
|
99
99
|
export { ValidationError } from "./validation-error";
|
|
@@ -3,154 +3,154 @@ import { AppError } from "./app-error";
|
|
|
3
3
|
import { ErrorCodes } from "./error-codes";
|
|
4
4
|
|
|
5
5
|
type IntegrationErrorReason =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
| "timeout"
|
|
7
|
+
| "unreachable"
|
|
8
|
+
| "bad_response"
|
|
9
|
+
| "unknown";
|
|
10
10
|
|
|
11
11
|
type IntegrationErrorMetadata = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
12
|
+
reason: IntegrationErrorReason;
|
|
13
|
+
provider: string;
|
|
14
|
+
operation: string;
|
|
15
|
+
startedAtIso: string;
|
|
16
|
+
durationMs: number;
|
|
17
|
+
detectedAtIso?: string;
|
|
18
|
+
correlationId?: string;
|
|
19
|
+
requestId?: string;
|
|
20
|
+
commandId?: string;
|
|
21
|
+
details?: string;
|
|
22
|
+
statusCode?: number;
|
|
23
|
+
responseCode?: string;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
type IntegrationErrorAppOptions = Pick<
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
AppErrorOptions,
|
|
28
|
+
| "cause"
|
|
29
|
+
| "type"
|
|
30
|
+
| "severity"
|
|
31
|
+
| "correlationId"
|
|
32
|
+
| "requestId"
|
|
33
|
+
| "commandId"
|
|
34
|
+
| "createdAtIso"
|
|
35
|
+
| "publicMessage"
|
|
36
36
|
>;
|
|
37
37
|
|
|
38
38
|
type IntegrationErrorConstructorParams = {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
message: string;
|
|
40
|
+
code: string;
|
|
41
|
+
reason: IntegrationErrorReason;
|
|
42
|
+
metadata: IntegrationErrorMetadata;
|
|
43
43
|
} & IntegrationErrorAppOptions;
|
|
44
44
|
|
|
45
45
|
class IntegrationError extends AppError {
|
|
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
|
-
|
|
46
|
+
public readonly reason: IntegrationErrorReason;
|
|
47
|
+
|
|
48
|
+
private constructor(params: IntegrationErrorConstructorParams) {
|
|
49
|
+
const { message, code, metadata, ...rest } = params;
|
|
50
|
+
super(message, code, {
|
|
51
|
+
...rest,
|
|
52
|
+
metadata,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
this.reason = params.reason;
|
|
56
|
+
Object.freeze(this);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
static timeout(options: IntegrationErrorTimeoutOptions): IntegrationError {
|
|
60
|
+
return new IntegrationError({
|
|
61
|
+
message: "Timeout while integrating with external provider",
|
|
62
|
+
code: ErrorCodes.integration.timeout,
|
|
63
|
+
reason: "timeout",
|
|
64
|
+
metadata: buildMetadata({ reason: "timeout", ...options }),
|
|
65
|
+
...pickAppErrorFields(options),
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
static unreachable(
|
|
70
|
+
options: IntegrationErrorEndpointOptions,
|
|
71
|
+
): IntegrationError {
|
|
72
|
+
return new IntegrationError({
|
|
73
|
+
message: "Provider unavailable",
|
|
74
|
+
code: ErrorCodes.integration.unreachable,
|
|
75
|
+
reason: "unreachable",
|
|
76
|
+
metadata: buildMetadata({ reason: "unreachable", ...options }),
|
|
77
|
+
...pickAppErrorFields(options),
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
static badResponse(
|
|
82
|
+
options: IntegrationErrorEndpointOptions,
|
|
83
|
+
): IntegrationError {
|
|
84
|
+
return new IntegrationError({
|
|
85
|
+
message: "Unexpected response from provider",
|
|
86
|
+
code: ErrorCodes.integration.badResponse,
|
|
87
|
+
reason: "bad_response",
|
|
88
|
+
metadata: buildMetadata({ reason: "bad_response", ...options }),
|
|
89
|
+
...pickAppErrorFields(options),
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
type IntegrationErrorBaseOptions = {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
95
|
+
provider: string;
|
|
96
|
+
operation: string;
|
|
97
|
+
startedAtIso: string;
|
|
98
|
+
durationMs: number;
|
|
99
|
+
detectedAtIso?: string;
|
|
100
|
+
correlationId?: string;
|
|
101
|
+
requestId?: string;
|
|
102
|
+
commandId?: string;
|
|
103
|
+
details?: string;
|
|
104
|
+
statusCode?: number;
|
|
105
|
+
responseCode?: string;
|
|
106
|
+
cause?: unknown;
|
|
107
|
+
type?: string;
|
|
108
|
+
severity?: ErrorSeverity;
|
|
109
|
+
createdAtIso?: string;
|
|
110
|
+
publicMessage?: string;
|
|
111
111
|
};
|
|
112
112
|
|
|
113
113
|
type IntegrationErrorTimeoutOptions = IntegrationErrorBaseOptions;
|
|
114
114
|
type IntegrationErrorEndpointOptions = IntegrationErrorBaseOptions;
|
|
115
115
|
|
|
116
116
|
function buildMetadata(
|
|
117
|
-
|
|
117
|
+
input: IntegrationErrorBaseOptions & { reason: IntegrationErrorReason },
|
|
118
118
|
): IntegrationErrorMetadata {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
119
|
+
return compactMetadata({
|
|
120
|
+
reason: input.reason,
|
|
121
|
+
provider: input.provider,
|
|
122
|
+
operation: input.operation,
|
|
123
|
+
startedAtIso: input.startedAtIso,
|
|
124
|
+
durationMs: input.durationMs,
|
|
125
|
+
detectedAtIso: input.detectedAtIso,
|
|
126
|
+
correlationId: input.correlationId,
|
|
127
|
+
requestId: input.requestId,
|
|
128
|
+
commandId: input.commandId,
|
|
129
|
+
details: input.details,
|
|
130
|
+
statusCode: input.statusCode,
|
|
131
|
+
responseCode: input.responseCode,
|
|
132
|
+
}) as IntegrationErrorMetadata;
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
function pickAppErrorFields(
|
|
136
|
-
|
|
136
|
+
options: IntegrationErrorBaseOptions,
|
|
137
137
|
): IntegrationErrorAppOptions {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
138
|
+
return {
|
|
139
|
+
cause: options.cause,
|
|
140
|
+
type: options.type,
|
|
141
|
+
severity: options.severity,
|
|
142
|
+
correlationId: options.correlationId,
|
|
143
|
+
requestId: options.requestId,
|
|
144
|
+
commandId: options.commandId,
|
|
145
|
+
createdAtIso: options.createdAtIso,
|
|
146
|
+
publicMessage: options.publicMessage,
|
|
147
|
+
};
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
function compactMetadata<T extends Record<string, unknown>>(input: T): T {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
151
|
+
return Object.fromEntries(
|
|
152
|
+
Object.entries(input).filter(([, value]) => value !== undefined),
|
|
153
|
+
) as T;
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
export { IntegrationError };
|
|
@@ -7,20 +7,20 @@ import type { AppErrorOptions } from "./types";
|
|
|
7
7
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
8
8
|
|
|
9
9
|
class LegacyIncompatibleError extends AppError {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
constructor(
|
|
11
|
+
message: string,
|
|
12
|
+
context?: Record<string, unknown>,
|
|
13
|
+
options?: AppErrorOptions,
|
|
14
|
+
) {
|
|
15
|
+
const mergedMetadata = options?.metadata
|
|
16
|
+
? { ...(context ?? {}), ...options.metadata }
|
|
17
|
+
: context;
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
super(message, ErrorCodes.legacyIncompatible, {
|
|
20
|
+
...options,
|
|
21
|
+
metadata: mergedMetadata,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export { LegacyIncompatibleError };
|
|
@@ -7,21 +7,21 @@ import type { AppErrorOptions } from "./types";
|
|
|
7
7
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
8
8
|
|
|
9
9
|
class NotFoundError extends AppError {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
constructor(
|
|
11
|
+
resource: string,
|
|
12
|
+
criteria?: Record<string, unknown>,
|
|
13
|
+
options?: AppErrorOptions,
|
|
14
|
+
) {
|
|
15
|
+
const baseMetadata = criteria ? { resource, criteria } : { resource };
|
|
16
|
+
const mergedMetadata = options?.metadata
|
|
17
|
+
? { ...baseMetadata, ...options.metadata }
|
|
18
|
+
: baseMetadata;
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
super(`${resource} not found`, ErrorCodes.notFound, {
|
|
21
|
+
...options,
|
|
22
|
+
metadata: mergedMetadata,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export { NotFoundError };
|