@cullet/erp-core 1.0.2 → 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 -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 +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
|
@@ -11,236 +11,237 @@ type ConflictKind = "already_exists" | "duplicate" | "unique_violation";
|
|
|
11
11
|
* Metadata attached to conflicts without exposing sensitive values.
|
|
12
12
|
*/
|
|
13
13
|
type ConflictErrorMetadata = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
14
|
+
kind: ConflictKind;
|
|
15
|
+
entity: string;
|
|
16
|
+
operation?: string;
|
|
17
|
+
field?: string;
|
|
18
|
+
constraintName?: string;
|
|
19
|
+
existingId?: string;
|
|
20
|
+
valueHash?: string;
|
|
21
|
+
valuePreview?: string;
|
|
22
|
+
detectedAtIso?: string;
|
|
23
|
+
correlationId?: string;
|
|
24
|
+
requestId?: string;
|
|
25
|
+
commandId?: string;
|
|
26
|
+
hint?: string;
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
type UniqueConstraintViolation = {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
kind: "unique_violation";
|
|
31
|
+
constraintName?: string;
|
|
32
|
+
table?: string;
|
|
33
|
+
columns?: string[];
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
abstract class ConflictError extends AppError {
|
|
37
|
-
|
|
37
|
+
public readonly kind: ConflictKind;
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
39
|
+
protected constructor(
|
|
40
|
+
params: {
|
|
41
|
+
message: string;
|
|
42
|
+
code: string;
|
|
43
|
+
kind: ConflictKind;
|
|
44
|
+
metadata: Omit<ConflictErrorMetadata, "kind">;
|
|
45
|
+
cause?: unknown;
|
|
46
|
+
} & AppErrorOptions,
|
|
47
|
+
) {
|
|
48
|
+
super(params.message, params.code, {
|
|
49
|
+
...params,
|
|
50
|
+
metadata: {
|
|
51
|
+
kind: params.kind,
|
|
52
|
+
...params.metadata,
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
this.kind = params.kind;
|
|
57
|
+
Object.freeze(this);
|
|
58
|
+
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
class AlreadyExistsError extends ConflictError {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
62
|
+
private constructor(
|
|
63
|
+
input: {
|
|
64
|
+
metadata: Omit<ConflictErrorMetadata, "kind">;
|
|
65
|
+
cause?: unknown;
|
|
66
|
+
} & AppErrorOptions,
|
|
67
|
+
) {
|
|
68
|
+
super({
|
|
69
|
+
message:
|
|
70
|
+
"A matching record already exists for the requested operation",
|
|
71
|
+
code: ErrorCodes.conflict.alreadyExists,
|
|
72
|
+
kind: "already_exists",
|
|
73
|
+
...input,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
75
76
|
|
|
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
|
-
|
|
77
|
+
static detected(input: {
|
|
78
|
+
entity: string;
|
|
79
|
+
operation?: string;
|
|
80
|
+
field?: string;
|
|
81
|
+
existingId?: string;
|
|
82
|
+
valueHash?: string;
|
|
83
|
+
valuePreview?: string;
|
|
84
|
+
detectedAtIso?: string;
|
|
85
|
+
correlationId?: string;
|
|
86
|
+
requestId?: string;
|
|
87
|
+
commandId?: string;
|
|
88
|
+
hint?: string;
|
|
89
|
+
cause?: unknown;
|
|
90
|
+
}): AlreadyExistsError {
|
|
91
|
+
return new AlreadyExistsError({
|
|
92
|
+
metadata: {
|
|
93
|
+
entity: input.entity,
|
|
94
|
+
operation: input.operation ?? "create",
|
|
95
|
+
field: input.field,
|
|
96
|
+
existingId: input.existingId,
|
|
97
|
+
valueHash: input.valueHash,
|
|
98
|
+
valuePreview: input.valuePreview,
|
|
99
|
+
detectedAtIso: input.detectedAtIso,
|
|
100
|
+
correlationId: input.correlationId,
|
|
101
|
+
requestId: input.requestId,
|
|
102
|
+
commandId: input.commandId,
|
|
103
|
+
hint: input.hint ?? "Verify existing records before retrying.",
|
|
104
|
+
},
|
|
105
|
+
cause: input.cause,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
107
108
|
}
|
|
108
109
|
|
|
109
110
|
class DuplicateError extends ConflictError {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
111
|
+
private constructor(
|
|
112
|
+
input: {
|
|
113
|
+
metadata: Omit<ConflictErrorMetadata, "kind">;
|
|
114
|
+
cause?: unknown;
|
|
115
|
+
} & AppErrorOptions,
|
|
116
|
+
) {
|
|
117
|
+
super({
|
|
118
|
+
message: "Conflict: an existing record violates uniqueness",
|
|
119
|
+
code: ErrorCodes.conflict.duplicate,
|
|
120
|
+
kind: "duplicate",
|
|
121
|
+
...input,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
123
124
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
125
|
+
static detected(input: {
|
|
126
|
+
entity: string;
|
|
127
|
+
operation?: string;
|
|
128
|
+
field?: string;
|
|
129
|
+
constraintName?: string;
|
|
130
|
+
existingId?: string;
|
|
131
|
+
valueHash?: string;
|
|
132
|
+
valuePreview?: string;
|
|
133
|
+
detectedAtIso?: string;
|
|
134
|
+
correlationId?: string;
|
|
135
|
+
requestId?: string;
|
|
136
|
+
commandId?: string;
|
|
137
|
+
hint?: string;
|
|
138
|
+
cause?: unknown;
|
|
139
|
+
}): DuplicateError {
|
|
140
|
+
return new DuplicateError({
|
|
141
|
+
metadata: {
|
|
142
|
+
entity: input.entity,
|
|
143
|
+
operation: input.operation,
|
|
144
|
+
field: input.field,
|
|
145
|
+
constraintName: input.constraintName,
|
|
146
|
+
existingId: input.existingId,
|
|
147
|
+
valueHash: input.valueHash,
|
|
148
|
+
valuePreview: input.valuePreview,
|
|
149
|
+
detectedAtIso: input.detectedAtIso,
|
|
150
|
+
correlationId: input.correlationId,
|
|
151
|
+
requestId: input.requestId,
|
|
152
|
+
commandId: input.commandId,
|
|
153
|
+
hint:
|
|
154
|
+
input.hint ??
|
|
155
|
+
"Adjust the data so it does not duplicate existing records.",
|
|
156
|
+
},
|
|
157
|
+
cause: input.cause,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
159
160
|
}
|
|
160
161
|
|
|
161
162
|
class UniqueConstraintViolationError extends ConflictError {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
163
|
+
private constructor(
|
|
164
|
+
input: {
|
|
165
|
+
metadata: Omit<ConflictErrorMetadata, "kind"> & {
|
|
166
|
+
violation: UniqueConstraintViolation;
|
|
167
|
+
};
|
|
168
|
+
cause?: unknown;
|
|
169
|
+
} & AppErrorOptions,
|
|
170
|
+
) {
|
|
171
|
+
super({
|
|
172
|
+
message: "Uniqueness violation in storage",
|
|
173
|
+
code: ErrorCodes.conflict.uniqueViolation,
|
|
174
|
+
kind: "unique_violation",
|
|
175
|
+
...input,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
static detected(input: {
|
|
180
|
+
entity: string;
|
|
181
|
+
operation?: string;
|
|
182
|
+
constraintName?: string;
|
|
183
|
+
table?: string;
|
|
184
|
+
columns?: string[];
|
|
185
|
+
detectedAtIso?: string;
|
|
186
|
+
correlationId?: string;
|
|
187
|
+
requestId?: string;
|
|
188
|
+
commandId?: string;
|
|
189
|
+
cause?: unknown;
|
|
190
|
+
}): UniqueConstraintViolationError {
|
|
191
|
+
return new UniqueConstraintViolationError({
|
|
192
|
+
metadata: {
|
|
193
|
+
entity: input.entity,
|
|
194
|
+
operation: input.operation,
|
|
195
|
+
constraintName: input.constraintName,
|
|
196
|
+
detectedAtIso: input.detectedAtIso,
|
|
197
|
+
correlationId: input.correlationId,
|
|
198
|
+
requestId: input.requestId,
|
|
199
|
+
commandId: input.commandId,
|
|
200
|
+
violation: {
|
|
201
|
+
kind: "unique_violation",
|
|
202
|
+
constraintName: input.constraintName,
|
|
203
|
+
table: input.table,
|
|
204
|
+
columns: input.columns,
|
|
205
|
+
},
|
|
206
|
+
hint: "Uniqueness conflict detected in the database.",
|
|
207
|
+
},
|
|
208
|
+
cause: input.cause,
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
}
|
|
177
212
|
|
|
178
|
-
|
|
213
|
+
function translateUniqueViolationToDuplicate(input: {
|
|
179
214
|
entity: string;
|
|
180
215
|
operation?: string;
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
216
|
+
violation: UniqueConstraintViolation;
|
|
217
|
+
field?: string;
|
|
218
|
+
ctx?: {
|
|
219
|
+
correlationId?: string;
|
|
220
|
+
requestId?: string;
|
|
221
|
+
commandId?: string;
|
|
222
|
+
nowIso?: string;
|
|
223
|
+
};
|
|
188
224
|
cause?: unknown;
|
|
189
|
-
|
|
190
|
-
return
|
|
191
|
-
metadata: {
|
|
225
|
+
}): DuplicateError {
|
|
226
|
+
return DuplicateError.detected({
|
|
192
227
|
entity: input.entity,
|
|
193
228
|
operation: input.operation,
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
constraintName: input.constraintName,
|
|
202
|
-
table: input.table,
|
|
203
|
-
columns: input.columns,
|
|
204
|
-
},
|
|
205
|
-
hint: "Uniqueness conflict detected in the database.",
|
|
206
|
-
},
|
|
207
|
-
cause: input.cause,
|
|
229
|
+
field: input.field,
|
|
230
|
+
constraintName: input.violation.constraintName,
|
|
231
|
+
detectedAtIso: input.ctx?.nowIso,
|
|
232
|
+
correlationId: input.ctx?.correlationId,
|
|
233
|
+
requestId: input.ctx?.requestId,
|
|
234
|
+
commandId: input.ctx?.commandId,
|
|
235
|
+
cause: input.cause,
|
|
208
236
|
});
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
function translateUniqueViolationToDuplicate(input: {
|
|
213
|
-
entity: string;
|
|
214
|
-
operation?: string;
|
|
215
|
-
violation: UniqueConstraintViolation;
|
|
216
|
-
field?: string;
|
|
217
|
-
ctx?: {
|
|
218
|
-
correlationId?: string;
|
|
219
|
-
requestId?: string;
|
|
220
|
-
commandId?: string;
|
|
221
|
-
nowIso?: string;
|
|
222
|
-
};
|
|
223
|
-
cause?: unknown;
|
|
224
|
-
}): DuplicateError {
|
|
225
|
-
return DuplicateError.detected({
|
|
226
|
-
entity: input.entity,
|
|
227
|
-
operation: input.operation,
|
|
228
|
-
field: input.field,
|
|
229
|
-
constraintName: input.violation.constraintName,
|
|
230
|
-
detectedAtIso: input.ctx?.nowIso,
|
|
231
|
-
correlationId: input.ctx?.correlationId,
|
|
232
|
-
requestId: input.ctx?.requestId,
|
|
233
|
-
commandId: input.ctx?.commandId,
|
|
234
|
-
cause: input.cause,
|
|
235
|
-
});
|
|
236
237
|
}
|
|
237
238
|
|
|
238
239
|
export {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
240
|
+
AlreadyExistsError,
|
|
241
|
+
ConflictError,
|
|
242
|
+
DuplicateError,
|
|
243
|
+
translateUniqueViolationToDuplicate,
|
|
244
|
+
UniqueConstraintViolationError,
|
|
244
245
|
};
|
|
245
246
|
|
|
246
247
|
export type { ConflictErrorMetadata, ConflictKind, UniqueConstraintViolation };
|
|
@@ -1,59 +1,59 @@
|
|
|
1
1
|
const ErrorCodes = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
2
|
+
authentication: {
|
|
3
|
+
missingToken: "sec.authn.missing_token",
|
|
4
|
+
invalidToken: "sec.authn.invalid_token",
|
|
5
|
+
expiredToken: "sec.authn.expired_token",
|
|
6
|
+
invalidCredentials: "sec.authn.invalid_credentials",
|
|
7
|
+
},
|
|
8
|
+
authorization: {
|
|
9
|
+
forbidden: "sec.authz.forbidden",
|
|
10
|
+
policyDenied: "sec.authz.policy_denied",
|
|
11
|
+
missingCapability: "sec.authz.missing_capability",
|
|
12
|
+
outOfScope: "sec.authz.out_of_scope",
|
|
13
|
+
},
|
|
14
|
+
businessRuleViolation: "business_rule_violation",
|
|
15
|
+
conflict: {
|
|
16
|
+
alreadyExists: "conf.already_exists",
|
|
17
|
+
duplicate: "conf.duplicate",
|
|
18
|
+
uniqueViolation: "conf.unique_violation",
|
|
19
|
+
},
|
|
20
|
+
idempotency: {
|
|
21
|
+
keyMissing: "idemp.key_missing",
|
|
22
|
+
inProgress: "idemp.in_progress",
|
|
23
|
+
payloadMismatch: "idemp.payload_mismatch",
|
|
24
|
+
replayNotSupported: "idemp.replay_not_supported",
|
|
25
|
+
},
|
|
26
|
+
integration: {
|
|
27
|
+
timeout: "int.timeout",
|
|
28
|
+
unreachable: "int.unreachable",
|
|
29
|
+
badResponse: "int.bad_response",
|
|
30
|
+
},
|
|
31
|
+
legacyIncompatible: "legacy_incompatible",
|
|
32
|
+
notFound: "not_found",
|
|
33
|
+
serialization: {
|
|
34
|
+
deserializePrefix: "ser.des",
|
|
35
|
+
serializePrefix: "ser.ser",
|
|
36
|
+
},
|
|
37
|
+
temporal: {
|
|
38
|
+
expired: "tmp.expired",
|
|
39
|
+
notYetValid: "tmp.not_yet_valid",
|
|
40
|
+
},
|
|
41
|
+
unexpected: "unexpected",
|
|
42
|
+
validation: "validation_error",
|
|
43
43
|
} as const;
|
|
44
44
|
|
|
45
45
|
type SerializationCodeDirection = "deserialize" | "serialize";
|
|
46
46
|
|
|
47
47
|
function serializationErrorCode(
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
direction: SerializationCodeDirection,
|
|
49
|
+
category: string,
|
|
50
50
|
): string {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
const prefix =
|
|
52
|
+
direction === "deserialize"
|
|
53
|
+
? ErrorCodes.serialization.deserializePrefix
|
|
54
|
+
: ErrorCodes.serialization.serializePrefix;
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
return `${prefix}.${category}`;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
export { ErrorCodes, serializationErrorCode };
|