@cullet/erp-core 1.3.0 → 1.4.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/KIT_CONTEXT.md +5 -3
- package/README.md +160 -0
- package/dist/abac/index.cjs +7 -0
- package/dist/abac/index.d.cts +2 -0
- package/dist/abac/index.d.ts +2 -0
- package/dist/abac/index.js +2 -0
- package/dist/app-error.cjs +193 -0
- package/dist/app-error.cjs.map +1 -0
- package/dist/app-error.js +170 -0
- package/dist/app-error.js.map +1 -0
- package/dist/application/index.cjs +2 -1
- package/dist/application/index.d.cts +2 -1
- package/dist/application/index.d.ts +2 -1
- package/dist/application/index.js +2 -1
- package/dist/authorization-error.cjs +157 -0
- package/dist/authorization-error.cjs.map +1 -0
- package/dist/authorization-error.d.cts +113 -0
- package/dist/authorization-error.d.ts +113 -0
- package/dist/authorization-error.js +152 -0
- package/dist/authorization-error.js.map +1 -0
- package/dist/authorizer.port.d.cts +130 -0
- package/dist/authorizer.port.d.ts +130 -0
- package/dist/composite-authorizer.d.cts +216 -0
- package/dist/composite-authorizer.d.ts +216 -0
- package/dist/condition-evaluator.cjs +565 -0
- package/dist/condition-evaluator.cjs.map +1 -0
- package/dist/condition-evaluator.js +536 -0
- package/dist/condition-evaluator.js.map +1 -0
- package/dist/{gate-types.d.ts → core-config.d.cts} +78 -77
- package/dist/{gate-types.d.cts → core-config.d.ts} +78 -77
- package/dist/domain/index.cjs +2 -1
- package/dist/domain/index.d.cts +2 -1
- package/dist/domain/index.d.ts +2 -1
- package/dist/domain/index.js +2 -1
- package/dist/domain-event-contracts.cjs +3 -2
- package/dist/domain-event-contracts.cjs.map +1 -1
- package/dist/domain-event-contracts.js +2 -1
- package/dist/domain-event-contracts.js.map +1 -1
- package/dist/entity.cjs +126 -0
- package/dist/entity.cjs.map +1 -0
- package/dist/entity.js +115 -0
- package/dist/entity.js.map +1 -0
- package/dist/errors/index.cjs +8 -6
- package/dist/errors/index.d.cts +2 -1
- package/dist/errors/index.d.ts +2 -1
- package/dist/errors/index.js +4 -2
- package/dist/gate-engine-registry.cjs +5 -4
- package/dist/gate-engine-registry.cjs.map +1 -1
- package/dist/gate-engine-registry.d.cts +3 -2
- package/dist/gate-engine-registry.d.ts +3 -2
- package/dist/gate-engine-registry.js +2 -1
- package/dist/gate-engine-registry.js.map +1 -1
- package/dist/gate-v1-payload.schema.cjs +0 -562
- package/dist/gate-v1-payload.schema.cjs.map +1 -1
- package/dist/gate-v1-payload.schema.js +1 -533
- package/dist/gate-v1-payload.schema.js.map +1 -1
- package/dist/index.cjs +34 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -12
- package/dist/index.d.ts +19 -12
- package/dist/index.js +15 -9
- package/dist/index.js.map +1 -1
- package/dist/not-found-error.cjs +5 -5
- package/dist/not-found-error.cjs.map +1 -1
- package/dist/not-found-error.js +1 -1
- package/dist/outcome.d.cts +1 -83
- package/dist/outcome.d.ts +1 -83
- package/dist/parse-gate-payload.d.cts +2 -2
- package/dist/parse-gate-payload.d.ts +2 -2
- package/dist/path.d.cts +2 -2
- package/dist/path.d.ts +2 -2
- package/dist/policies/engines/index.d.cts +1 -1
- package/dist/policies/engines/index.d.ts +1 -1
- package/dist/policies/engines/v1/gate/index.cjs +5 -4
- package/dist/policies/engines/v1/gate/index.cjs.map +1 -1
- package/dist/policies/engines/v1/gate/index.d.cts +2 -2
- package/dist/policies/engines/v1/gate/index.d.ts +2 -2
- package/dist/policies/engines/v1/gate/index.js +2 -1
- package/dist/policies/engines/v1/gate/index.js.map +1 -1
- package/dist/policies/index.cjs +5 -5
- package/dist/policies/index.d.cts +3 -2
- package/dist/policies/index.d.ts +3 -2
- package/dist/policies/index.js +2 -2
- package/dist/policy-bridge.cjs +437 -0
- package/dist/policy-bridge.cjs.map +1 -0
- package/dist/policy-bridge.d.cts +185 -0
- package/dist/policy-bridge.d.ts +185 -0
- package/dist/policy-bridge.js +396 -0
- package/dist/policy-bridge.js.map +1 -0
- package/dist/policy-service.cjs +239 -239
- package/dist/policy-service.cjs.map +1 -1
- package/dist/policy-service.d.cts +2 -2
- package/dist/policy-service.d.ts +2 -2
- package/dist/policy-service.js +239 -239
- package/dist/policy-service.js.map +1 -1
- package/dist/rbac/index.cjs +9 -0
- package/dist/rbac/index.d.cts +3 -0
- package/dist/rbac/index.d.ts +3 -0
- package/dist/rbac/index.js +2 -0
- package/dist/requested-by.cjs +54 -0
- package/dist/requested-by.cjs.map +1 -0
- package/dist/requested-by.d.cts +25 -0
- package/dist/requested-by.d.ts +25 -0
- package/dist/requested-by.js +49 -0
- package/dist/requested-by.js.map +1 -0
- package/dist/result/index.d.cts +2 -1
- package/dist/result/index.d.ts +2 -1
- package/dist/result.d.cts +84 -0
- package/dist/result.d.ts +84 -0
- package/dist/rule.cjs +327 -0
- package/dist/rule.cjs.map +1 -0
- package/dist/rule.js +298 -0
- package/dist/rule.js.map +1 -0
- package/dist/temporal-use-case.cjs +1 -53
- package/dist/temporal-use-case.cjs.map +1 -1
- package/dist/temporal-use-case.d.cts +5 -27
- package/dist/temporal-use-case.d.ts +5 -27
- package/dist/temporal-use-case.js +2 -48
- package/dist/temporal-use-case.js.map +1 -1
- package/dist/unexpected-error.cjs +3 -192
- package/dist/unexpected-error.cjs.map +1 -1
- package/dist/unexpected-error.js +2 -167
- package/dist/unexpected-error.js.map +1 -1
- package/dist/uuid-identifier.d.cts +2 -85
- package/dist/uuid-identifier.d.ts +2 -85
- package/dist/validation-error.cjs +33 -166
- package/dist/validation-error.cjs.map +1 -1
- package/dist/validation-error.d.cts +2 -98
- package/dist/validation-error.d.ts +2 -98
- package/dist/validation-error.js +7 -134
- package/dist/validation-error.js.map +1 -1
- package/dist/value-object.cjs +0 -123
- package/dist/value-object.cjs.map +1 -1
- package/dist/value-object.d.cts +89 -0
- package/dist/value-object.d.ts +89 -0
- package/dist/value-object.js +1 -112
- package/dist/value-object.js.map +1 -1
- package/meta.json +18 -4
- package/package.json +27 -1
- package/src/abac/index.ts +1 -0
- package/src/core/abac/abac-request.ts +29 -0
- package/src/core/abac/attributes.ts +39 -0
- package/src/core/abac/authorizer.ts +108 -0
- package/src/core/abac/combining.ts +63 -0
- package/src/core/abac/composite-authorizer.ts +45 -0
- package/src/core/abac/domain/policy-set.ts +52 -0
- package/src/core/abac/domain/rule.ts +197 -0
- package/src/core/abac/index.ts +21 -0
- package/src/core/application/ports/abac-authorizer.port.ts +20 -0
- package/src/core/application/ports/authorizer.port.ts +22 -0
- package/src/core/errors/authorization-error.ts +26 -0
- package/src/core/errors/error-codes.ts +1 -0
- package/src/core/index.ts +7 -0
- package/src/core/rbac/access-request.ts +32 -0
- package/src/core/rbac/authorizer.ts +91 -0
- package/src/core/rbac/domain/grant.ts +96 -0
- package/src/core/rbac/domain/permission-set.ts +67 -0
- package/src/core/rbac/domain/permission.ts +119 -0
- package/src/core/rbac/domain/role.ts +101 -0
- package/src/core/rbac/domain/scope.ts +84 -0
- package/src/core/rbac/index.ts +15 -0
- package/src/core/rbac/policy-bridge.ts +44 -0
- package/src/examples/application/authorize-cancel-order-abac.example.ts +107 -0
- package/src/examples/application/authorize-cancel-order.example.ts +101 -0
- package/src/rbac/index.ts +1 -0
- package/src/version.ts +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_app_error = require("./app-error.cjs");
|
|
2
2
|
//#region src/core/errors/authentication-error.ts
|
|
3
|
-
var AuthenticationError = class AuthenticationError extends
|
|
3
|
+
var AuthenticationError = class AuthenticationError extends require_app_error.AppError {
|
|
4
4
|
constructor(params) {
|
|
5
5
|
super(params.message, params.code, {
|
|
6
6
|
cause: params.cause,
|
|
@@ -22,16 +22,16 @@ var AuthenticationError = class AuthenticationError extends require_unexpected_e
|
|
|
22
22
|
static missingToken(options) {
|
|
23
23
|
return new AuthenticationError({
|
|
24
24
|
message: "Missing credentials",
|
|
25
|
-
code:
|
|
25
|
+
code: require_app_error.ErrorCodes.authentication.missingToken,
|
|
26
26
|
reason: "missing_token",
|
|
27
27
|
metadata: compactMetadata$1(options),
|
|
28
|
-
...extractAppErrorOptions
|
|
28
|
+
...extractAppErrorOptions(options)
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
static invalidToken(options) {
|
|
32
32
|
return new AuthenticationError({
|
|
33
33
|
message: "Invalid credentials",
|
|
34
|
-
code:
|
|
34
|
+
code: require_app_error.ErrorCodes.authentication.invalidToken,
|
|
35
35
|
reason: "invalid_token",
|
|
36
36
|
metadata: compactMetadata$1({
|
|
37
37
|
authScheme: options?.authScheme,
|
|
@@ -40,29 +40,29 @@ var AuthenticationError = class AuthenticationError extends require_unexpected_e
|
|
|
40
40
|
correlationId: options?.correlationId,
|
|
41
41
|
requestId: options?.requestId
|
|
42
42
|
}),
|
|
43
|
-
...extractAppErrorOptions
|
|
43
|
+
...extractAppErrorOptions(options)
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
static expiredToken(options) {
|
|
47
47
|
return new AuthenticationError({
|
|
48
48
|
message: "Expired credentials",
|
|
49
|
-
code:
|
|
49
|
+
code: require_app_error.ErrorCodes.authentication.expiredToken,
|
|
50
50
|
reason: "expired_token",
|
|
51
51
|
metadata: compactMetadata$1(options),
|
|
52
|
-
...extractAppErrorOptions
|
|
52
|
+
...extractAppErrorOptions(options)
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
static invalidCredentials(options) {
|
|
56
56
|
return new AuthenticationError({
|
|
57
57
|
message: "Invalid username or password",
|
|
58
|
-
code:
|
|
58
|
+
code: require_app_error.ErrorCodes.authentication.invalidCredentials,
|
|
59
59
|
reason: "invalid_credentials",
|
|
60
60
|
metadata: compactMetadata$1(options),
|
|
61
|
-
...extractAppErrorOptions
|
|
61
|
+
...extractAppErrorOptions(options)
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
|
-
function extractAppErrorOptions
|
|
65
|
+
function extractAppErrorOptions(options) {
|
|
66
66
|
return {
|
|
67
67
|
cause: options?.cause,
|
|
68
68
|
type: options?.type,
|
|
@@ -79,133 +79,6 @@ function compactMetadata$1(input) {
|
|
|
79
79
|
return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== void 0));
|
|
80
80
|
}
|
|
81
81
|
//#endregion
|
|
82
|
-
//#region src/core/errors/authorization-error.ts
|
|
83
|
-
/**
|
|
84
|
-
* Raised when an authenticated actor is not allowed to perform a business
|
|
85
|
-
* action — the "you may not" error, distinct from authentication ("who are
|
|
86
|
-
* you"). Maps to an HTTP 403 at the edge.
|
|
87
|
-
*
|
|
88
|
-
* The discriminating {@link reason} records *why* access was denied (a flat
|
|
89
|
-
* forbid, a missing role/capability, an out-of-scope target, or a policy
|
|
90
|
-
* decision) so the boundary can shape the response without re-deriving it. The
|
|
91
|
-
* metadata is deliberately built around a stable business `action` and a
|
|
92
|
-
* type/id resource reference rather than an HTTP route or full payload, keeping
|
|
93
|
-
* sensitive data out of logs. Instances are frozen. Construct through the
|
|
94
|
-
* static factories, never directly.
|
|
95
|
-
*/
|
|
96
|
-
var AuthorizationError = class AuthorizationError extends require_unexpected_error.AppError {
|
|
97
|
-
constructor(params) {
|
|
98
|
-
super(params.message, params.code, {
|
|
99
|
-
cause: params.cause,
|
|
100
|
-
metadata: params.metadata,
|
|
101
|
-
type: params.type,
|
|
102
|
-
severity: params.severity,
|
|
103
|
-
correlationId: params.correlationId,
|
|
104
|
-
requestId: params.requestId,
|
|
105
|
-
commandId: params.commandId,
|
|
106
|
-
createdAtIso: params.createdAtIso,
|
|
107
|
-
publicMessage: params.publicMessage
|
|
108
|
-
});
|
|
109
|
-
this.reason = params.reason;
|
|
110
|
-
Object.freeze(this);
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* A flat denial with no more specific reason — the actor simply may not
|
|
114
|
-
* perform this action. Reach for a more precise factory
|
|
115
|
-
* ({@link AuthorizationError.missingCapability}, {@link AuthorizationError.outOfScope},
|
|
116
|
-
* {@link AuthorizationError.policyDenied}) when the cause is known.
|
|
117
|
-
*/
|
|
118
|
-
static forbidden(input) {
|
|
119
|
-
return new AuthorizationError({
|
|
120
|
-
message: "Action not allowed",
|
|
121
|
-
code: require_unexpected_error.ErrorCodes.authorization.forbidden,
|
|
122
|
-
reason: "forbidden",
|
|
123
|
-
metadata: {
|
|
124
|
-
reason: "forbidden",
|
|
125
|
-
...extractMetadataOnly(input)
|
|
126
|
-
},
|
|
127
|
-
...extractAppErrorOptions(input)
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* The action was denied by an evaluated policy. Captures the deciding
|
|
132
|
-
* policy's id, version, and evaluation instant into the metadata (with
|
|
133
|
-
* `decision: "deny"`) so the denial is auditable back to the exact policy
|
|
134
|
-
* that produced it.
|
|
135
|
-
*
|
|
136
|
-
* @param input - Factory options plus the required `policyId`,
|
|
137
|
-
* `policyVersion`, and `evaluatedAtIso` of the deciding policy.
|
|
138
|
-
*/
|
|
139
|
-
static policyDenied(input) {
|
|
140
|
-
return new AuthorizationError({
|
|
141
|
-
message: "Action denied by policy",
|
|
142
|
-
code: require_unexpected_error.ErrorCodes.authorization.policyDenied,
|
|
143
|
-
reason: "policy_denied",
|
|
144
|
-
metadata: {
|
|
145
|
-
reason: "policy_denied",
|
|
146
|
-
...extractMetadataOnly(input),
|
|
147
|
-
decision: "deny"
|
|
148
|
-
},
|
|
149
|
-
...extractAppErrorOptions(input)
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* The actor lacks a required role or capability. The expected
|
|
154
|
-
* {@link AuthorizationRequirement} is recorded so the boundary can tell the
|
|
155
|
-
* caller precisely what grant is missing.
|
|
156
|
-
*
|
|
157
|
-
* @param input - Factory options plus the `required` role/capability/scope.
|
|
158
|
-
*/
|
|
159
|
-
static missingCapability(input) {
|
|
160
|
-
return new AuthorizationError({
|
|
161
|
-
message: "Insufficient capability to perform the action",
|
|
162
|
-
code: require_unexpected_error.ErrorCodes.authorization.missingCapability,
|
|
163
|
-
reason: "missing_capability",
|
|
164
|
-
metadata: {
|
|
165
|
-
reason: "missing_capability",
|
|
166
|
-
...extractMetadataOnly(input)
|
|
167
|
-
},
|
|
168
|
-
...extractAppErrorOptions(input)
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* The actor may perform the action in general, but not on *this* target —
|
|
173
|
-
* the resource falls outside the actor's permitted scope (e.g. a different
|
|
174
|
-
* school or tenant than the one they are bound to).
|
|
175
|
-
*
|
|
176
|
-
* @param input - Factory options plus the optional `required` scope that the
|
|
177
|
-
* target failed to satisfy.
|
|
178
|
-
*/
|
|
179
|
-
static outOfScope(input) {
|
|
180
|
-
return new AuthorizationError({
|
|
181
|
-
message: "Action outside the allowed scope",
|
|
182
|
-
code: require_unexpected_error.ErrorCodes.authorization.outOfScope,
|
|
183
|
-
reason: "out_of_scope",
|
|
184
|
-
metadata: {
|
|
185
|
-
reason: "out_of_scope",
|
|
186
|
-
...extractMetadataOnly(input)
|
|
187
|
-
},
|
|
188
|
-
...extractAppErrorOptions(input)
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
function extractAppErrorOptions(options) {
|
|
193
|
-
return {
|
|
194
|
-
cause: options?.cause,
|
|
195
|
-
type: options?.type,
|
|
196
|
-
severity: options?.severity,
|
|
197
|
-
correlationId: options?.correlationId,
|
|
198
|
-
requestId: options?.requestId,
|
|
199
|
-
commandId: options?.commandId,
|
|
200
|
-
createdAtIso: options?.createdAtIso,
|
|
201
|
-
publicMessage: options?.publicMessage
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
function extractMetadataOnly(input) {
|
|
205
|
-
const { cause, type, severity, correlationId, requestId, commandId, createdAtIso, publicMessage, ...metadata } = input;
|
|
206
|
-
return metadata;
|
|
207
|
-
}
|
|
208
|
-
//#endregion
|
|
209
82
|
//#region src/core/errors/conflict-error.ts
|
|
210
83
|
/**
|
|
211
84
|
* Base for errors that signal a state conflict — the request collides with data
|
|
@@ -218,7 +91,7 @@ function extractMetadataOnly(input) {
|
|
|
218
91
|
* message, and metadata. Instances are frozen, so a conflict error can be shared
|
|
219
92
|
* and rethrown without risk of tampering.
|
|
220
93
|
*/
|
|
221
|
-
var ConflictError = class extends
|
|
94
|
+
var ConflictError = class extends require_app_error.AppError {
|
|
222
95
|
constructor(params) {
|
|
223
96
|
super(params.message, params.code, {
|
|
224
97
|
...params,
|
|
@@ -240,7 +113,7 @@ var AlreadyExistsError = class AlreadyExistsError extends ConflictError {
|
|
|
240
113
|
constructor(input) {
|
|
241
114
|
super({
|
|
242
115
|
message: "A matching record already exists for the requested operation",
|
|
243
|
-
code:
|
|
116
|
+
code: require_app_error.ErrorCodes.conflict.alreadyExists,
|
|
244
117
|
kind: "already_exists",
|
|
245
118
|
...input
|
|
246
119
|
});
|
|
@@ -283,7 +156,7 @@ var DuplicateError = class DuplicateError extends ConflictError {
|
|
|
283
156
|
constructor(input) {
|
|
284
157
|
super({
|
|
285
158
|
message: "Conflict: an existing record violates uniqueness",
|
|
286
|
-
code:
|
|
159
|
+
code: require_app_error.ErrorCodes.conflict.duplicate,
|
|
287
160
|
kind: "duplicate",
|
|
288
161
|
...input
|
|
289
162
|
});
|
|
@@ -327,7 +200,7 @@ var UniqueConstraintViolationError = class UniqueConstraintViolationError extend
|
|
|
327
200
|
constructor(input) {
|
|
328
201
|
super({
|
|
329
202
|
message: "Uniqueness violation in storage",
|
|
330
|
-
code:
|
|
203
|
+
code: require_app_error.ErrorCodes.conflict.uniqueViolation,
|
|
331
204
|
kind: "unique_violation",
|
|
332
205
|
...input
|
|
333
206
|
});
|
|
@@ -387,7 +260,7 @@ function translateUniqueViolationToDuplicate(input) {
|
|
|
387
260
|
}
|
|
388
261
|
//#endregion
|
|
389
262
|
//#region src/core/errors/idempotency-error.ts
|
|
390
|
-
var IdempotencyError = class extends
|
|
263
|
+
var IdempotencyError = class extends require_app_error.AppError {
|
|
391
264
|
constructor(input) {
|
|
392
265
|
super(input.message, input.code, {
|
|
393
266
|
cause: input.cause,
|
|
@@ -416,7 +289,7 @@ var IdempotencyKeyMissingError = class IdempotencyKeyMissingError extends Idempo
|
|
|
416
289
|
constructor(input) {
|
|
417
290
|
super({
|
|
418
291
|
message: "Idempotency key/commandId missing for the requested operation",
|
|
419
|
-
code:
|
|
292
|
+
code: require_app_error.ErrorCodes.idempotency.keyMissing,
|
|
420
293
|
kind: "key_missing",
|
|
421
294
|
metadata: input.metadata,
|
|
422
295
|
cause: input.cause
|
|
@@ -443,7 +316,7 @@ var IdempotencyInProgressError = class IdempotencyInProgressError extends Idempo
|
|
|
443
316
|
constructor(input) {
|
|
444
317
|
super({
|
|
445
318
|
message: "The same business intent is already being processed",
|
|
446
|
-
code:
|
|
319
|
+
code: require_app_error.ErrorCodes.idempotency.inProgress,
|
|
447
320
|
kind: "in_progress",
|
|
448
321
|
metadata: input.metadata,
|
|
449
322
|
cause: input.cause
|
|
@@ -474,7 +347,7 @@ var IdempotencyPayloadMismatchError = class IdempotencyPayloadMismatchError exte
|
|
|
474
347
|
constructor(input) {
|
|
475
348
|
super({
|
|
476
349
|
message: "The idempotency key was reused with a different payload",
|
|
477
|
-
code:
|
|
350
|
+
code: require_app_error.ErrorCodes.idempotency.payloadMismatch,
|
|
478
351
|
kind: "payload_mismatch",
|
|
479
352
|
metadata: input.metadata,
|
|
480
353
|
cause: input.cause
|
|
@@ -507,7 +380,7 @@ var IdempotencyReplayNotSupportedError = class IdempotencyReplayNotSupportedErro
|
|
|
507
380
|
constructor(input) {
|
|
508
381
|
super({
|
|
509
382
|
message: "Re-execution detected, but replay of the previous result is not implemented",
|
|
510
|
-
code:
|
|
383
|
+
code: require_app_error.ErrorCodes.idempotency.replayNotSupported,
|
|
511
384
|
kind: "replay_not_supported",
|
|
512
385
|
metadata: input.metadata,
|
|
513
386
|
cause: input.cause
|
|
@@ -554,7 +427,7 @@ function resolveKeyIdentity(key, keyHash, keyPreview) {
|
|
|
554
427
|
* {@link reason} lets callers decide whether a failure is worth retrying.
|
|
555
428
|
* Instances are frozen; construct through the static factories.
|
|
556
429
|
*/
|
|
557
|
-
var IntegrationError = class IntegrationError extends
|
|
430
|
+
var IntegrationError = class IntegrationError extends require_app_error.AppError {
|
|
558
431
|
constructor(params) {
|
|
559
432
|
const { message, code, metadata, ...rest } = params;
|
|
560
433
|
super(message, code, {
|
|
@@ -571,7 +444,7 @@ var IntegrationError = class IntegrationError extends require_unexpected_error.A
|
|
|
571
444
|
static timeout(options) {
|
|
572
445
|
return new IntegrationError({
|
|
573
446
|
message: "Timeout while integrating with external provider",
|
|
574
|
-
code:
|
|
447
|
+
code: require_app_error.ErrorCodes.integration.timeout,
|
|
575
448
|
reason: "timeout",
|
|
576
449
|
metadata: buildMetadata({
|
|
577
450
|
reason: "timeout",
|
|
@@ -587,7 +460,7 @@ var IntegrationError = class IntegrationError extends require_unexpected_error.A
|
|
|
587
460
|
static unreachable(options) {
|
|
588
461
|
return new IntegrationError({
|
|
589
462
|
message: "Provider unavailable",
|
|
590
|
-
code:
|
|
463
|
+
code: require_app_error.ErrorCodes.integration.unreachable,
|
|
591
464
|
reason: "unreachable",
|
|
592
465
|
metadata: buildMetadata({
|
|
593
466
|
reason: "unreachable",
|
|
@@ -604,7 +477,7 @@ var IntegrationError = class IntegrationError extends require_unexpected_error.A
|
|
|
604
477
|
static badResponse(options) {
|
|
605
478
|
return new IntegrationError({
|
|
606
479
|
message: "Unexpected response from provider",
|
|
607
|
-
code:
|
|
480
|
+
code: require_app_error.ErrorCodes.integration.badResponse,
|
|
608
481
|
reason: "bad_response",
|
|
609
482
|
metadata: buildMetadata({
|
|
610
483
|
reason: "bad_response",
|
|
@@ -647,13 +520,13 @@ function compactMetadata(input) {
|
|
|
647
520
|
}
|
|
648
521
|
//#endregion
|
|
649
522
|
//#region src/core/errors/legacy-incompatible-error.ts
|
|
650
|
-
var LegacyIncompatibleError = class extends
|
|
523
|
+
var LegacyIncompatibleError = class extends require_app_error.AppError {
|
|
651
524
|
constructor(message, context, options) {
|
|
652
525
|
const mergedMetadata = options?.metadata ? {
|
|
653
526
|
...context ?? {},
|
|
654
527
|
...options.metadata
|
|
655
528
|
} : context;
|
|
656
|
-
super(message,
|
|
529
|
+
super(message, require_app_error.ErrorCodes.legacyIncompatible, {
|
|
657
530
|
...options,
|
|
658
531
|
metadata: mergedMetadata
|
|
659
532
|
});
|
|
@@ -661,7 +534,7 @@ var LegacyIncompatibleError = class extends require_unexpected_error.AppError {
|
|
|
661
534
|
};
|
|
662
535
|
//#endregion
|
|
663
536
|
//#region src/core/errors/serialization-error.ts
|
|
664
|
-
var SerializationError = class extends
|
|
537
|
+
var SerializationError = class extends require_app_error.AppError {
|
|
665
538
|
constructor(input) {
|
|
666
539
|
super(input.message ?? "Serialization failure", input.code, {
|
|
667
540
|
cause: input.cause,
|
|
@@ -717,7 +590,7 @@ var SerializationOutError = class SerializationOutError extends SerializationErr
|
|
|
717
590
|
};
|
|
718
591
|
var SerializationCodes = class {
|
|
719
592
|
static code(direction, category) {
|
|
720
|
-
return
|
|
593
|
+
return require_app_error.serializationErrorCode(direction, category);
|
|
721
594
|
}
|
|
722
595
|
};
|
|
723
596
|
var SerializationMessages = class {
|
|
@@ -746,7 +619,7 @@ function safePreview(value, limit = 240) {
|
|
|
746
619
|
}
|
|
747
620
|
//#endregion
|
|
748
621
|
//#region src/core/errors/temporal-error.ts
|
|
749
|
-
var TemporalError = class extends
|
|
622
|
+
var TemporalError = class extends require_app_error.AppError {
|
|
750
623
|
constructor(input) {
|
|
751
624
|
super(input.message, input.code, {
|
|
752
625
|
...input,
|
|
@@ -768,7 +641,7 @@ var ExpiredError = class ExpiredError extends TemporalError {
|
|
|
768
641
|
static detected(input) {
|
|
769
642
|
return new ExpiredError({
|
|
770
643
|
message: "The validity of the resource/action has expired",
|
|
771
|
-
code:
|
|
644
|
+
code: require_app_error.ErrorCodes.temporal.expired,
|
|
772
645
|
kind: "expired",
|
|
773
646
|
metadata: {
|
|
774
647
|
...input,
|
|
@@ -792,7 +665,7 @@ var NotYetValidError = class NotYetValidError extends TemporalError {
|
|
|
792
665
|
static detected(input) {
|
|
793
666
|
return new NotYetValidError({
|
|
794
667
|
message: "The resource/action is not yet valid",
|
|
795
|
-
code:
|
|
668
|
+
code: require_app_error.ErrorCodes.temporal.notYetValid,
|
|
796
669
|
kind: "not_yet_valid",
|
|
797
670
|
metadata: {
|
|
798
671
|
...input,
|
|
@@ -842,7 +715,7 @@ function evaluateTemporalWindow(input) {
|
|
|
842
715
|
* validation failures uniformly while still distinguishing the specific rule
|
|
843
716
|
* through `validationCode`.
|
|
844
717
|
*/
|
|
845
|
-
var ValidationError = class extends
|
|
718
|
+
var ValidationError = class extends require_app_error.AppError {
|
|
846
719
|
/**
|
|
847
720
|
* @param field - The input that failed validation; surfaced as `metadata.field`.
|
|
848
721
|
* @param code - The specific rule that was violated; surfaced as `metadata.validationCode`.
|
|
@@ -859,7 +732,7 @@ var ValidationError = class extends require_unexpected_error.AppError {
|
|
|
859
732
|
...baseMetadata,
|
|
860
733
|
...options.metadata
|
|
861
734
|
} : baseMetadata;
|
|
862
|
-
super(message,
|
|
735
|
+
super(message, require_app_error.ErrorCodes.validation, {
|
|
863
736
|
...options,
|
|
864
737
|
metadata: mergedMetadata
|
|
865
738
|
});
|
|
@@ -878,12 +751,6 @@ Object.defineProperty(exports, "AuthenticationError", {
|
|
|
878
751
|
return AuthenticationError;
|
|
879
752
|
}
|
|
880
753
|
});
|
|
881
|
-
Object.defineProperty(exports, "AuthorizationError", {
|
|
882
|
-
enumerable: true,
|
|
883
|
-
get: function() {
|
|
884
|
-
return AuthorizationError;
|
|
885
|
-
}
|
|
886
|
-
});
|
|
887
754
|
Object.defineProperty(exports, "ConflictError", {
|
|
888
755
|
enumerable: true,
|
|
889
756
|
get: function() {
|