@ontrails/core 1.0.0-beta.2 → 1.0.0-beta.21
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/CHANGELOG.md +283 -5
- package/README.md +113 -33
- package/package.json +11 -1
- package/src/activation-provenance.ts +111 -0
- package/src/activation-source-compatibility.ts +430 -0
- package/src/activation-source-projection.ts +221 -0
- package/src/activation-source.ts +91 -0
- package/src/blob-ref.ts +51 -0
- package/src/branded.ts +1 -1
- package/src/compose-batch.ts +69 -0
- package/src/compose-schema.ts +36 -0
- package/src/context.ts +44 -10
- package/src/contour.ts +346 -0
- package/src/derive.ts +59 -18
- package/src/detours.ts +8 -0
- package/src/draft.ts +342 -0
- package/src/error-projection.ts +51 -0
- package/src/errors.ts +309 -48
- package/src/execute.ts +1577 -0
- package/src/fire.ts +1169 -0
- package/src/index.ts +477 -32
- package/src/internal/fork-ctx.ts +69 -0
- package/src/layer-projection.ts +193 -0
- package/src/layer.ts +43 -6
- package/src/observe.ts +361 -0
- package/src/path-security.ts +1 -1
- package/src/permits.ts +12 -0
- package/src/redaction/patterns.ts +6 -3
- package/src/resilience.ts +11 -11
- package/src/resource-config.ts +792 -0
- package/src/resource.ts +194 -0
- package/src/result.ts +36 -4
- package/src/run.ts +76 -0
- package/src/schedule-runtime.ts +689 -0
- package/src/schedule.ts +326 -0
- package/src/serialization.ts +119 -39
- package/src/signal-diagnostics.ts +633 -0
- package/src/signal-ref.ts +87 -0
- package/src/signal.ts +104 -0
- package/src/store/accessor-protocol.ts +56 -0
- package/src/store/index.ts +4 -0
- package/src/structured-examples.ts +248 -0
- package/src/surface-derivation.ts +91 -0
- package/src/surface-filter.ts +176 -0
- package/src/surface-versioning.ts +42 -0
- package/src/topo.ts +769 -57
- package/src/tracing.ts +345 -0
- package/src/trail.ts +1161 -29
- package/src/trails/derive-trail.ts +842 -0
- package/src/trails/index.ts +9 -0
- package/src/trails/ingest.ts +139 -0
- package/src/trails-db.ts +208 -0
- package/src/transport-error-map.ts +174 -0
- package/src/type-utils.ts +87 -0
- package/src/types.ts +254 -12
- package/src/validate-established-topo.ts +69 -0
- package/src/validate-topo.ts +442 -35
- package/src/validation.ts +152 -4
- package/src/version-marker.ts +716 -0
- package/src/version-resolution.ts +308 -0
- package/src/version-runtime.ts +120 -0
- package/src/webhook.ts +278 -0
- package/src/workspace.ts +1 -1
- package/src/zod-wrappers.ts +72 -0
- package/.turbo/turbo-build.log +0 -1
- package/.turbo/turbo-lint.log +0 -3
- package/.turbo/turbo-typecheck.log +0 -1
- package/dist/adapters.d.ts +0 -39
- package/dist/adapters.d.ts.map +0 -1
- package/dist/adapters.js +0 -2
- package/dist/adapters.js.map +0 -1
- package/dist/blob-ref.d.ts +0 -20
- package/dist/blob-ref.d.ts.map +0 -1
- package/dist/blob-ref.js +0 -22
- package/dist/blob-ref.js.map +0 -1
- package/dist/branded.d.ts +0 -36
- package/dist/branded.d.ts.map +0 -1
- package/dist/branded.js +0 -89
- package/dist/branded.js.map +0 -1
- package/dist/collections.d.ts +0 -31
- package/dist/collections.d.ts.map +0 -1
- package/dist/collections.js +0 -60
- package/dist/collections.js.map +0 -1
- package/dist/context.d.ts +0 -10
- package/dist/context.d.ts.map +0 -1
- package/dist/context.js +0 -15
- package/dist/context.js.map +0 -1
- package/dist/derive.d.ts +0 -33
- package/dist/derive.d.ts.map +0 -1
- package/dist/derive.js +0 -122
- package/dist/derive.js.map +0 -1
- package/dist/errors.d.ts +0 -83
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -142
- package/dist/errors.js.map +0 -1
- package/dist/event.d.ts +0 -45
- package/dist/event.d.ts.map +0 -1
- package/dist/event.js +0 -17
- package/dist/event.js.map +0 -1
- package/dist/fetch.d.ts +0 -15
- package/dist/fetch.d.ts.map +0 -1
- package/dist/fetch.js +0 -102
- package/dist/fetch.js.map +0 -1
- package/dist/guards.d.ts +0 -17
- package/dist/guards.d.ts.map +0 -1
- package/dist/guards.js +0 -25
- package/dist/guards.js.map +0 -1
- package/dist/health.d.ts +0 -18
- package/dist/health.d.ts.map +0 -1
- package/dist/health.js +0 -5
- package/dist/health.js.map +0 -1
- package/dist/hike.d.ts +0 -36
- package/dist/hike.d.ts.map +0 -1
- package/dist/hike.js +0 -20
- package/dist/hike.js.map +0 -1
- package/dist/index.d.ts +0 -34
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -38
- package/dist/index.js.map +0 -1
- package/dist/job.d.ts +0 -24
- package/dist/job.d.ts.map +0 -1
- package/dist/job.js +0 -17
- package/dist/job.js.map +0 -1
- package/dist/layer.d.ts +0 -17
- package/dist/layer.d.ts.map +0 -1
- package/dist/layer.js +0 -21
- package/dist/layer.js.map +0 -1
- package/dist/path-security.d.ts +0 -28
- package/dist/path-security.d.ts.map +0 -1
- package/dist/path-security.js +0 -63
- package/dist/path-security.js.map +0 -1
- package/dist/patterns/bulk.d.ts +0 -15
- package/dist/patterns/bulk.d.ts.map +0 -1
- package/dist/patterns/bulk.js +0 -14
- package/dist/patterns/bulk.js.map +0 -1
- package/dist/patterns/change.d.ts +0 -10
- package/dist/patterns/change.d.ts.map +0 -1
- package/dist/patterns/change.js +0 -10
- package/dist/patterns/change.js.map +0 -1
- package/dist/patterns/date-range.d.ts +0 -10
- package/dist/patterns/date-range.d.ts.map +0 -1
- package/dist/patterns/date-range.js +0 -10
- package/dist/patterns/date-range.js.map +0 -1
- package/dist/patterns/index.d.ts +0 -9
- package/dist/patterns/index.d.ts.map +0 -1
- package/dist/patterns/index.js +0 -9
- package/dist/patterns/index.js.map +0 -1
- package/dist/patterns/pagination.d.ts +0 -18
- package/dist/patterns/pagination.d.ts.map +0 -1
- package/dist/patterns/pagination.js +0 -18
- package/dist/patterns/pagination.js.map +0 -1
- package/dist/patterns/progress.d.ts +0 -11
- package/dist/patterns/progress.d.ts.map +0 -1
- package/dist/patterns/progress.js +0 -11
- package/dist/patterns/progress.js.map +0 -1
- package/dist/patterns/sorting.d.ts +0 -13
- package/dist/patterns/sorting.d.ts.map +0 -1
- package/dist/patterns/sorting.js +0 -10
- package/dist/patterns/sorting.js.map +0 -1
- package/dist/patterns/status.d.ts +0 -15
- package/dist/patterns/status.d.ts.map +0 -1
- package/dist/patterns/status.js +0 -9
- package/dist/patterns/status.js.map +0 -1
- package/dist/patterns/timestamps.d.ts +0 -10
- package/dist/patterns/timestamps.d.ts.map +0 -1
- package/dist/patterns/timestamps.js +0 -10
- package/dist/patterns/timestamps.js.map +0 -1
- package/dist/redaction/index.d.ts +0 -4
- package/dist/redaction/index.d.ts.map +0 -1
- package/dist/redaction/index.js +0 -3
- package/dist/redaction/index.js.map +0 -1
- package/dist/redaction/patterns.d.ts +0 -9
- package/dist/redaction/patterns.d.ts.map +0 -1
- package/dist/redaction/patterns.js +0 -39
- package/dist/redaction/patterns.js.map +0 -1
- package/dist/redaction/redactor.d.ts +0 -27
- package/dist/redaction/redactor.d.ts.map +0 -1
- package/dist/redaction/redactor.js +0 -89
- package/dist/redaction/redactor.js.map +0 -1
- package/dist/resilience.d.ts +0 -34
- package/dist/resilience.d.ts.map +0 -1
- package/dist/resilience.js +0 -164
- package/dist/resilience.js.map +0 -1
- package/dist/result.d.ts +0 -57
- package/dist/result.d.ts.map +0 -1
- package/dist/result.js +0 -145
- package/dist/result.js.map +0 -1
- package/dist/serialization.d.ts +0 -27
- package/dist/serialization.d.ts.map +0 -1
- package/dist/serialization.js +0 -115
- package/dist/serialization.js.map +0 -1
- package/dist/topo.d.ts +0 -18
- package/dist/topo.d.ts.map +0 -1
- package/dist/topo.js +0 -74
- package/dist/topo.js.map +0 -1
- package/dist/trail.d.ts +0 -83
- package/dist/trail.d.ts.map +0 -1
- package/dist/trail.js +0 -16
- package/dist/trail.js.map +0 -1
- package/dist/types.d.ts +0 -46
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/validate-topo.d.ts +0 -24
- package/dist/validate-topo.d.ts.map +0 -1
- package/dist/validate-topo.js +0 -108
- package/dist/validate-topo.js.map +0 -1
- package/dist/validation.d.ts +0 -27
- package/dist/validation.d.ts.map +0 -1
- package/dist/validation.js +0 -134
- package/dist/validation.js.map +0 -1
- package/dist/workspace.d.ts +0 -25
- package/dist/workspace.d.ts.map +0 -1
- package/dist/workspace.js +0 -57
- package/dist/workspace.js.map +0 -1
- package/src/__tests__/blob-ref.test.ts +0 -103
- package/src/__tests__/branded.test.ts +0 -148
- package/src/__tests__/collections.test.ts +0 -126
- package/src/__tests__/context.test.ts +0 -66
- package/src/__tests__/derive.test.ts +0 -159
- package/src/__tests__/errors.test.ts +0 -309
- package/src/__tests__/event.test.ts +0 -82
- package/src/__tests__/fetch.test.ts +0 -217
- package/src/__tests__/guards.test.ts +0 -102
- package/src/__tests__/hike.test.ts +0 -117
- package/src/__tests__/job.test.ts +0 -98
- package/src/__tests__/layer.test.ts +0 -224
- package/src/__tests__/path-security.test.ts +0 -114
- package/src/__tests__/patterns.test.ts +0 -273
- package/src/__tests__/redaction.test.ts +0 -244
- package/src/__tests__/resilience.test.ts +0 -246
- package/src/__tests__/result.test.ts +0 -155
- package/src/__tests__/serialization.test.ts +0 -236
- package/src/__tests__/topo.test.ts +0 -184
- package/src/__tests__/trail.test.ts +0 -179
- package/src/__tests__/validate-topo.test.ts +0 -201
- package/src/__tests__/validation.test.ts +0 -283
- package/src/__tests__/workspace.test.ts +0 -183
- package/src/adapters.ts +0 -68
- package/src/event.ts +0 -77
- package/src/health.ts +0 -23
- package/src/hike.ts +0 -77
- package/src/job.ts +0 -20
- package/tsconfig.json +0 -9
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Default redaction patterns and sensitive key lists.
|
|
3
|
-
*
|
|
4
|
-
* These are used by {@link createRedactor} to strip secrets from strings
|
|
5
|
-
* and object values before they reach logs, traces, or error payloads.
|
|
6
|
-
*/
|
|
7
|
-
// ---------------------------------------------------------------------------
|
|
8
|
-
// Regex patterns that match sensitive values inside arbitrary strings
|
|
9
|
-
// ---------------------------------------------------------------------------
|
|
10
|
-
export const DEFAULT_PATTERNS = [
|
|
11
|
-
// Credit card numbers: 4 groups of 4 digits separated by spaces or dashes
|
|
12
|
-
/\b\d{4}[- ]\d{4}[- ]\d{4}[- ]\d{4}\b/g,
|
|
13
|
-
// SSN: XXX-XX-XXXX
|
|
14
|
-
/\b\d{3}-\d{2}-\d{4}\b/g,
|
|
15
|
-
// Bearer tokens
|
|
16
|
-
/Bearer\s+[A-Za-z0-9\-._~+/]+=*/g,
|
|
17
|
-
// Basic auth
|
|
18
|
-
/Basic\s+[A-Za-z0-9+/]+=*/g,
|
|
19
|
-
// API keys: sk-*, pk_*, sk_* prefixed tokens
|
|
20
|
-
/\b(?:sk-|pk_|sk_)[A-Za-z0-9_-]{8,}\b/g,
|
|
21
|
-
// JWT tokens: eyJ... (three base64url segments separated by dots)
|
|
22
|
-
/\beyJ[A-Za-z0-9_-]+\.eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/g,
|
|
23
|
-
];
|
|
24
|
-
// ---------------------------------------------------------------------------
|
|
25
|
-
// Object keys whose values should always be redacted
|
|
26
|
-
// ---------------------------------------------------------------------------
|
|
27
|
-
export const DEFAULT_SENSITIVE_KEYS = [
|
|
28
|
-
'password',
|
|
29
|
-
'secret',
|
|
30
|
-
'token',
|
|
31
|
-
'apiKey',
|
|
32
|
-
'api_key',
|
|
33
|
-
'authorization',
|
|
34
|
-
'cookie',
|
|
35
|
-
'ssn',
|
|
36
|
-
'creditCard',
|
|
37
|
-
'credit_card',
|
|
38
|
-
];
|
|
39
|
-
//# sourceMappingURL=patterns.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"patterns.js","sourceRoot":"","sources":["../../src/redaction/patterns.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,8EAA8E;AAC9E,sEAAsE;AACtE,8EAA8E;AAE9E,MAAM,CAAC,MAAM,gBAAgB,GAAa;IACxC,0EAA0E;IAC1E,uCAAuC;IAEvC,mBAAmB;IACnB,wBAAwB;IAExB,gBAAgB;IAChB,iCAAiC;IAEjC,aAAa;IACb,2BAA2B;IAE3B,6CAA6C;IAC7C,uCAAuC;IAEvC,kEAAkE;IAClE,2DAA2D;CAC5D,CAAC;AAEF,8EAA8E;AAC9E,qDAAqD;AACrD,8EAA8E;AAE9E,MAAM,CAAC,MAAM,sBAAsB,GAAa;IAC9C,UAAU;IACV,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,SAAS;IACT,eAAe;IACf,QAAQ;IACR,KAAK;IACL,YAAY;IACZ,aAAa;CACd,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Redactor — strips sensitive data from strings and objects.
|
|
3
|
-
*
|
|
4
|
-
* @example
|
|
5
|
-
* ```ts
|
|
6
|
-
* const r = createRedactor();
|
|
7
|
-
* r.redact("token: Bearer abc123"); // "token: [REDACTED]"
|
|
8
|
-
* r.redactObject({ password: "s3cret" }); // { password: "[REDACTED]" }
|
|
9
|
-
* ```
|
|
10
|
-
*/
|
|
11
|
-
export interface RedactorConfig {
|
|
12
|
-
readonly patterns?: RegExp[];
|
|
13
|
-
readonly sensitiveKeys?: string[];
|
|
14
|
-
readonly replacement?: string;
|
|
15
|
-
}
|
|
16
|
-
export interface Redactor {
|
|
17
|
-
/** Replace all pattern matches in a string with the replacement. */
|
|
18
|
-
redact(value: string): string;
|
|
19
|
-
/**
|
|
20
|
-
* Deep-clone `obj` and redact:
|
|
21
|
-
* 1. Values whose key matches a sensitive key (case-insensitive).
|
|
22
|
-
* 2. All remaining string values that match a pattern.
|
|
23
|
-
*/
|
|
24
|
-
redactObject<T extends Record<string, unknown>>(obj: T): T;
|
|
25
|
-
}
|
|
26
|
-
export declare const createRedactor: (config?: RedactorConfig) => Redactor;
|
|
27
|
-
//# sourceMappingURL=redactor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"redactor.d.ts","sourceRoot":"","sources":["../../src/redaction/redactor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAQH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,WAAW,QAAQ;IACvB,oEAAoE;IACpE,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAE9B;;;;OAIG;IACH,YAAY,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;CAC5D;AA8HD,eAAO,MAAM,cAAc,GAAI,SAAS,cAAc,KAAG,QAkBxD,CAAC"}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Redactor — strips sensitive data from strings and objects.
|
|
3
|
-
*
|
|
4
|
-
* @example
|
|
5
|
-
* ```ts
|
|
6
|
-
* const r = createRedactor();
|
|
7
|
-
* r.redact("token: Bearer abc123"); // "token: [REDACTED]"
|
|
8
|
-
* r.redactObject({ password: "s3cret" }); // { password: "[REDACTED]" }
|
|
9
|
-
* ```
|
|
10
|
-
*/
|
|
11
|
-
import { DEFAULT_PATTERNS, DEFAULT_SENSITIVE_KEYS } from './patterns.js';
|
|
12
|
-
// ---------------------------------------------------------------------------
|
|
13
|
-
// Helpers
|
|
14
|
-
// ---------------------------------------------------------------------------
|
|
15
|
-
const resetPatterns = (patterns) => {
|
|
16
|
-
for (const p of patterns) {
|
|
17
|
-
p.lastIndex = 0;
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
const applyPatterns = (value, patterns, replacement) => {
|
|
21
|
-
let result = value;
|
|
22
|
-
for (const pattern of patterns) {
|
|
23
|
-
// Reset in case the regex is stateful (global flag)
|
|
24
|
-
pattern.lastIndex = 0;
|
|
25
|
-
result = result.replace(pattern, replacement);
|
|
26
|
-
}
|
|
27
|
-
return result;
|
|
28
|
-
};
|
|
29
|
-
const isSensitiveKey = (key, sensitiveKeysLower) => key !== undefined && sensitiveKeysLower.has(key.toLowerCase());
|
|
30
|
-
const mapObjectValues = (value, visit) => {
|
|
31
|
-
const result = {};
|
|
32
|
-
for (const [key, item] of Object.entries(value)) {
|
|
33
|
-
result[key] = visit(item, key);
|
|
34
|
-
}
|
|
35
|
-
return result;
|
|
36
|
-
};
|
|
37
|
-
/** Track and guard against circular references in object graphs. */
|
|
38
|
-
const trackOrCircular = (value, seen) => {
|
|
39
|
-
if (seen.has(value)) {
|
|
40
|
-
return '[Circular]';
|
|
41
|
-
}
|
|
42
|
-
seen.add(value);
|
|
43
|
-
return null;
|
|
44
|
-
};
|
|
45
|
-
/* oxlint-disable no-use-before-define -- mutual recursion between redactCompound and deepRedact */
|
|
46
|
-
/** Redact a compound value (array or object), delegating scalars back to deepRedact. */
|
|
47
|
-
const redactCompound = (value, sensitiveKeysLower, patterns, replacement, seen) => {
|
|
48
|
-
const circular = trackOrCircular(value, seen);
|
|
49
|
-
if (circular) {
|
|
50
|
-
return circular;
|
|
51
|
-
}
|
|
52
|
-
if (Array.isArray(value)) {
|
|
53
|
-
return value.map((item) => deepRedact(item, sensitiveKeysLower, patterns, replacement, undefined, seen));
|
|
54
|
-
}
|
|
55
|
-
return mapObjectValues(value, (item, key) => deepRedact(item, sensitiveKeysLower, patterns, replacement, key, seen));
|
|
56
|
-
};
|
|
57
|
-
const deepRedact = (value, sensitiveKeysLower, patterns, replacement, currentKey, seen = new WeakSet()) => {
|
|
58
|
-
if (isSensitiveKey(currentKey, sensitiveKeysLower)) {
|
|
59
|
-
return replacement;
|
|
60
|
-
}
|
|
61
|
-
if (typeof value === 'string') {
|
|
62
|
-
return applyPatterns(value, patterns, replacement);
|
|
63
|
-
}
|
|
64
|
-
if (value !== null && typeof value === 'object') {
|
|
65
|
-
return redactCompound(value, sensitiveKeysLower, patterns, replacement, seen);
|
|
66
|
-
}
|
|
67
|
-
return value;
|
|
68
|
-
};
|
|
69
|
-
/* oxlint-enable no-use-before-define */
|
|
70
|
-
// ---------------------------------------------------------------------------
|
|
71
|
-
// Factory
|
|
72
|
-
// ---------------------------------------------------------------------------
|
|
73
|
-
export const createRedactor = (config) => {
|
|
74
|
-
const patterns = config?.patterns ?? DEFAULT_PATTERNS;
|
|
75
|
-
const sensitiveKeys = config?.sensitiveKeys ?? DEFAULT_SENSITIVE_KEYS;
|
|
76
|
-
const replacement = config?.replacement ?? '[REDACTED]';
|
|
77
|
-
const sensitiveKeysLower = new Set(sensitiveKeys.map((k) => k.toLowerCase()));
|
|
78
|
-
return {
|
|
79
|
-
redact(value) {
|
|
80
|
-
resetPatterns(patterns);
|
|
81
|
-
return applyPatterns(value, patterns, replacement);
|
|
82
|
-
},
|
|
83
|
-
redactObject(obj) {
|
|
84
|
-
resetPatterns(patterns);
|
|
85
|
-
return deepRedact(obj, sensitiveKeysLower, patterns, replacement);
|
|
86
|
-
},
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
//# sourceMappingURL=redactor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"redactor.js","sourceRoot":"","sources":["../../src/redaction/redactor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAwBzE,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E,MAAM,aAAa,GAAG,CAAC,QAAkB,EAAQ,EAAE;IACjD,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;QACzB,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,CACpB,KAAa,EACb,QAAkB,EAClB,W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BAAgB,CAAC;IACtD,MAAM,aAAa,GAAG,MAAM,EAAE,aAAa,IAAI,sBAAsB,CAAC;IACtE,MAAM,WAAW,GAAG,MAAM,EAAE,WAAW,IAAI,YAAY,CAAC;IAExD,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IAE9E,OAAO;QACL,MAAM,CAAC,KAAa;YAClB,aAAa,CAAC,QAAQ,CAAC,CAAC;YACxB,OAAO,aAAa,CAAC,KAAK,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;QACrD,CAAC;QAED,YAAY,CAAoC,GAAM;YACpD,aAAa,CAAC,QAAQ,CAAC,CAAC;YACxB,OAAO,UAAU,CAAC,GAAG,EAAE,kBAAkB,EAAE,QAAQ,EAAE,WAAW,CAAM,CAAC;QACzE,CAAC;KACF,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/resilience.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Resilience utilities for @ontrails/core
|
|
3
|
-
*
|
|
4
|
-
* Retry with exponential backoff and timeout wrappers,
|
|
5
|
-
* all returning Result types.
|
|
6
|
-
*/
|
|
7
|
-
import { Result } from './result.js';
|
|
8
|
-
export interface RetryOptions {
|
|
9
|
-
/** Maximum number of attempts (default: 3) */
|
|
10
|
-
readonly maxAttempts?: number | undefined;
|
|
11
|
-
/** Base delay in ms before first retry (default: 1000) */
|
|
12
|
-
readonly baseDelay?: number | undefined;
|
|
13
|
-
/** Maximum delay in ms (default: 30000) */
|
|
14
|
-
readonly maxDelay?: number | undefined;
|
|
15
|
-
/** Exponential backoff factor (default: 2) */
|
|
16
|
-
readonly backoffFactor?: number | undefined;
|
|
17
|
-
/** Custom predicate — defaults to isRetryable from error taxonomy */
|
|
18
|
-
readonly shouldRetry?: ((error: Error) => boolean) | undefined;
|
|
19
|
-
/** AbortSignal for cancellation */
|
|
20
|
-
readonly signal?: AbortSignal | undefined;
|
|
21
|
-
}
|
|
22
|
-
/** Default retry predicate using the error taxonomy. */
|
|
23
|
-
export declare const shouldRetry: (error: Error) => boolean;
|
|
24
|
-
/** Compute exponential backoff delay with full jitter. */
|
|
25
|
-
export declare const getBackoffDelay: (attempt: number, options?: Pick<RetryOptions, "baseDelay" | "maxDelay" | "backoffFactor">) => number;
|
|
26
|
-
export declare const retry: <T>(fn: () => Promise<Result<T, Error>>, options?: RetryOptions) => Promise<Result<T, Error>>;
|
|
27
|
-
/**
|
|
28
|
-
* Run an async Result-returning function with a timeout.
|
|
29
|
-
*
|
|
30
|
-
* If the timeout fires first, returns a TimeoutError result.
|
|
31
|
-
* Also respects an external AbortSignal.
|
|
32
|
-
*/
|
|
33
|
-
export declare const withTimeout: <T>(fn: () => Promise<Result<T, Error>>, ms: number, signal?: AbortSignal) => Promise<Result<T, Error>>;
|
|
34
|
-
//# sourceMappingURL=resilience.d.ts.map
|
package/dist/resilience.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resilience.d.ts","sourceRoot":"","sources":["../src/resilience.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAMrC,MAAM,WAAW,YAAY;IAC3B,8CAA8C;IAC9C,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C,0DAA0D;IAC1D,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,2CAA2C;IAC3C,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,8CAA8C;IAC9C,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5C,qEAAqE;IACrE,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,GAAG,SAAS,CAAC;IAC/D,mCAAmC;IACnC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;CAC3C;AAgCD,wDAAwD;AACxD,eAAO,MAAM,WAAW,GAAI,OAAO,KAAK,KAAG,OAA6B,CAAC;AAMzE,0DAA0D;AAC1D,eAAO,MAAM,eAAe,GAC1B,SAAS,MAAM,EACf,UAAU,IAAI,CAAC,YAAY,EAAE,WAAW,GAAG,UAAU,GAAG,eAAe,CAAC,KACvE,MAQF,CAAC;AA8CF,eAAO,MAAM,KAAK,GAAU,CAAC,EAC3B,IAAI,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EACnC,UAAU,YAAY,KACrB,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAsB1B,CAAC;AAMF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,EAC3B,IAAI,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EACnC,IAAI,MAAM,EACV,SAAS,WAAW,KACnB,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAoE1B,CAAC"}
|
package/dist/resilience.js
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Resilience utilities for @ontrails/core
|
|
3
|
-
*
|
|
4
|
-
* Retry with exponential backoff and timeout wrappers,
|
|
5
|
-
* all returning Result types.
|
|
6
|
-
*/
|
|
7
|
-
import { CancelledError, TimeoutError, isRetryable } from './errors.js';
|
|
8
|
-
import { Result } from './result.js';
|
|
9
|
-
// ---------------------------------------------------------------------------
|
|
10
|
-
// Helpers (defined before usage)
|
|
11
|
-
// ---------------------------------------------------------------------------
|
|
12
|
-
const sleep = (ms, signal) =>
|
|
13
|
-
// oxlint-disable-next-line avoid-new -- Promise constructor needed for setTimeout-based sleep
|
|
14
|
-
new Promise((resolve) => {
|
|
15
|
-
if (signal?.aborted) {
|
|
16
|
-
resolve();
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
let settled = false;
|
|
20
|
-
const done = () => {
|
|
21
|
-
if (!settled) {
|
|
22
|
-
settled = true;
|
|
23
|
-
resolve();
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
const timer = setTimeout(done, ms);
|
|
27
|
-
const onAbort = () => {
|
|
28
|
-
clearTimeout(timer);
|
|
29
|
-
done();
|
|
30
|
-
};
|
|
31
|
-
signal?.addEventListener('abort', onAbort, { once: true });
|
|
32
|
-
});
|
|
33
|
-
// ---------------------------------------------------------------------------
|
|
34
|
-
// shouldRetry (default)
|
|
35
|
-
// ---------------------------------------------------------------------------
|
|
36
|
-
/** Default retry predicate using the error taxonomy. */
|
|
37
|
-
export const shouldRetry = (error) => isRetryable(error);
|
|
38
|
-
// ---------------------------------------------------------------------------
|
|
39
|
-
// getBackoffDelay
|
|
40
|
-
// ---------------------------------------------------------------------------
|
|
41
|
-
/** Compute exponential backoff delay with full jitter. */
|
|
42
|
-
export const getBackoffDelay = (attempt, options) => {
|
|
43
|
-
const base = options?.baseDelay ?? 1000;
|
|
44
|
-
const max = options?.maxDelay ?? 30_000;
|
|
45
|
-
const factor = options?.backoffFactor ?? 2;
|
|
46
|
-
const exponential = base * factor ** attempt;
|
|
47
|
-
const capped = Math.min(exponential, max);
|
|
48
|
-
// Full jitter: random value in [0, capped]
|
|
49
|
-
return Math.floor(Math.random() * capped);
|
|
50
|
-
};
|
|
51
|
-
// ---------------------------------------------------------------------------
|
|
52
|
-
// retry
|
|
53
|
-
// ---------------------------------------------------------------------------
|
|
54
|
-
/**
|
|
55
|
-
* Retry an async function that returns a Result.
|
|
56
|
-
*
|
|
57
|
-
* On each failure, checks whether the error is retryable and whether the
|
|
58
|
-
* attempt budget remains. Applies exponential backoff with jitter between
|
|
59
|
-
* retries.
|
|
60
|
-
*/
|
|
61
|
-
/** Attempt a single retry iteration. Returns the result to stop, or undefined to continue. */
|
|
62
|
-
const tryAttempt = async (fn, attempt, maxAttempts, retryPredicate, options) => {
|
|
63
|
-
const result = await fn();
|
|
64
|
-
if (result.isOk()) {
|
|
65
|
-
return { done: true, result };
|
|
66
|
-
}
|
|
67
|
-
const isLast = attempt === maxAttempts - 1;
|
|
68
|
-
if (isLast || !retryPredicate(result.error)) {
|
|
69
|
-
return { done: true, result };
|
|
70
|
-
}
|
|
71
|
-
const delay = getBackoffDelay(attempt, options);
|
|
72
|
-
if (delay > 0) {
|
|
73
|
-
await sleep(delay, options?.signal);
|
|
74
|
-
}
|
|
75
|
-
return { done: false, result };
|
|
76
|
-
};
|
|
77
|
-
/** Resolve retry options to concrete values. */
|
|
78
|
-
const resolveRetryOptions = (options) => ({
|
|
79
|
-
maxAttempts: options?.maxAttempts ?? 3,
|
|
80
|
-
retryPredicate: options?.shouldRetry ?? shouldRetry,
|
|
81
|
-
signal: options?.signal,
|
|
82
|
-
});
|
|
83
|
-
export const retry = async (fn, options) => {
|
|
84
|
-
const { maxAttempts, retryPredicate, signal } = resolveRetryOptions(options);
|
|
85
|
-
let lastResult;
|
|
86
|
-
for (let attempt = 0; attempt < maxAttempts; attempt += 1) {
|
|
87
|
-
if (signal?.aborted) {
|
|
88
|
-
return Result.err(new CancelledError('Retry cancelled'));
|
|
89
|
-
}
|
|
90
|
-
const outcome = await tryAttempt(fn, attempt, maxAttempts, retryPredicate, options);
|
|
91
|
-
lastResult = outcome.result;
|
|
92
|
-
if (outcome.done) {
|
|
93
|
-
return outcome.result;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return lastResult ?? Result.err(new CancelledError('Retry exhausted'));
|
|
97
|
-
};
|
|
98
|
-
// ---------------------------------------------------------------------------
|
|
99
|
-
// withTimeout
|
|
100
|
-
// ---------------------------------------------------------------------------
|
|
101
|
-
/**
|
|
102
|
-
* Run an async Result-returning function with a timeout.
|
|
103
|
-
*
|
|
104
|
-
* If the timeout fires first, returns a TimeoutError result.
|
|
105
|
-
* Also respects an external AbortSignal.
|
|
106
|
-
*/
|
|
107
|
-
export const withTimeout = (fn, ms, signal) => {
|
|
108
|
-
if (signal?.aborted) {
|
|
109
|
-
return Promise.resolve(Result.err(new CancelledError('Already cancelled')));
|
|
110
|
-
}
|
|
111
|
-
// oxlint-disable-next-line avoid-new, promise/no-multiple-resolved -- Promise constructor needed for timeout race; settled guard ensures single resolution
|
|
112
|
-
return new Promise((resolve) => {
|
|
113
|
-
let settled = false;
|
|
114
|
-
// oxlint-disable-next-line prefer-const -- assigned after declaration
|
|
115
|
-
let timer;
|
|
116
|
-
const onAbort = () => {
|
|
117
|
-
if (settled) {
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
settled = true;
|
|
121
|
-
clearTimeout(timer);
|
|
122
|
-
signal?.removeEventListener('abort', onAbort);
|
|
123
|
-
// oxlint-disable-next-line promise/no-multiple-resolved -- settled guard ensures single resolution
|
|
124
|
-
resolve(Result.err(new CancelledError('Operation cancelled')));
|
|
125
|
-
};
|
|
126
|
-
signal?.addEventListener('abort', onAbort, { once: true });
|
|
127
|
-
timer = setTimeout(() => {
|
|
128
|
-
if (settled) {
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
settled = true;
|
|
132
|
-
signal?.removeEventListener('abort', onAbort);
|
|
133
|
-
// oxlint-disable-next-line promise/no-multiple-resolved -- settled guard ensures single resolution
|
|
134
|
-
resolve(Result.err(new TimeoutError(`Operation timed out after ${ms}ms`, {
|
|
135
|
-
context: { timeoutMs: ms },
|
|
136
|
-
})));
|
|
137
|
-
}, ms);
|
|
138
|
-
// oxlint-disable-next-line prefer-await-to-then, no-void -- .then() needed inside Promise constructor; void discards unhandled rejection
|
|
139
|
-
void fn().then(
|
|
140
|
-
// oxlint-disable-next-line prefer-await-to-callbacks -- callback required inside .then()
|
|
141
|
-
(result) => {
|
|
142
|
-
if (settled) {
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
settled = true;
|
|
146
|
-
clearTimeout(timer);
|
|
147
|
-
signal?.removeEventListener('abort', onAbort);
|
|
148
|
-
// oxlint-disable-next-line promise/no-multiple-resolved -- settled guard ensures single resolution
|
|
149
|
-
resolve(result);
|
|
150
|
-
},
|
|
151
|
-
// oxlint-disable-next-line prefer-await-to-callbacks -- rejection handler required inside .then()
|
|
152
|
-
(error) => {
|
|
153
|
-
if (settled) {
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
settled = true;
|
|
157
|
-
clearTimeout(timer);
|
|
158
|
-
signal?.removeEventListener('abort', onAbort);
|
|
159
|
-
// oxlint-disable-next-line promise/no-multiple-resolved -- settled guard ensures single resolution
|
|
160
|
-
resolve(Result.err(error instanceof Error ? error : new Error(String(error))));
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
};
|
|
164
|
-
//# sourceMappingURL=resilience.js.map
|
package/dist/resilience.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resilience.js","sourceRoot":"","sources":["../src/resilience.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAqBrC,8EAA8E;AAC9E,iCAAiC;AACjC,8EAA8E;AAE9E,MAAM,KAAK,GAAG,CAAC,EAAU,EAAE,MAAoB,EAAiB,EAAE;AAChE,8FAA8F;AAC9F,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;IACtB,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;QACpB,OAAO,EAAE,CAAC;QACV,OAAO;IACT,CAAC;IACD,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,MAAM,IAAI,GAAG,GAAG,EAAE;QAChB,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,GAAG,IAAI,CAAC;YACf,OAAO,EAAE,CAAC;QACZ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CAAC,CACtE,CAAC;QACJ,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
package/dist/result.d.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A type-safe Result monad for representing success/failure without exceptions.
|
|
3
|
-
*/
|
|
4
|
-
import { InternalError, ValidationError } from './errors.js';
|
|
5
|
-
declare class Ok<T, E> {
|
|
6
|
-
readonly value: T;
|
|
7
|
-
constructor(value: T);
|
|
8
|
-
isOk(): this is Ok<T, E>;
|
|
9
|
-
isErr(): this is Err<E>;
|
|
10
|
-
map<U>(fn: (value: T) => U): Result<U, E>;
|
|
11
|
-
flatMap<U, F = E>(fn: (value: T) => Result<U, F>): Result<U, E | F>;
|
|
12
|
-
mapErr<F>(_fn: (error: E) => F): Result<T, F>;
|
|
13
|
-
match<U>(handlers: {
|
|
14
|
-
ok: (value: T) => U;
|
|
15
|
-
err: (error: E) => U;
|
|
16
|
-
}): U;
|
|
17
|
-
unwrap(): T;
|
|
18
|
-
unwrapOr(_fallback: T): T;
|
|
19
|
-
}
|
|
20
|
-
declare class Err<E> {
|
|
21
|
-
readonly error: E;
|
|
22
|
-
constructor(error: E);
|
|
23
|
-
isOk(): this is Ok<never, E>;
|
|
24
|
-
isErr(): this is Err<E>;
|
|
25
|
-
map<U>(_fn: (value: never) => U): Result<U, E>;
|
|
26
|
-
flatMap<U, F = E>(_fn: (value: never) => Result<U, F>): Result<U, E | F>;
|
|
27
|
-
mapErr<F>(fn: (error: E) => F): Result<never, F>;
|
|
28
|
-
match<U>(handlers: {
|
|
29
|
-
ok: (value: never) => U;
|
|
30
|
-
err: (error: E) => U;
|
|
31
|
-
}): U;
|
|
32
|
-
unwrap(): never;
|
|
33
|
-
unwrapOr<T>(fallback: T): T;
|
|
34
|
-
}
|
|
35
|
-
export type Result<T, E = Error> = Ok<T, E> | Err<E>;
|
|
36
|
-
export declare const Result: {
|
|
37
|
-
readonly combine: <T, E>(results: readonly Result<T, E>[]) => Result<T[], E>;
|
|
38
|
-
readonly err: <E>(error: E) => Err<E>;
|
|
39
|
-
/**
|
|
40
|
-
* Wrap a fetch call in a Result, mapping failures to TrailsError subclasses.
|
|
41
|
-
*
|
|
42
|
-
* Network errors become NetworkError. Abort signals become CancelledError.
|
|
43
|
-
* HTTP error status codes map to the appropriate error category.
|
|
44
|
-
*/
|
|
45
|
-
readonly fromFetch: (input: string | URL | Request, init?: RequestInit) => Promise<Result<Response, Error>>;
|
|
46
|
-
/**
|
|
47
|
-
* Parse a JSON string, returning a Result instead of throwing.
|
|
48
|
-
*/
|
|
49
|
-
readonly fromJson: (json: string) => Result<unknown, ValidationError>;
|
|
50
|
-
readonly ok: <T = void>(value?: T) => Result<T, never>;
|
|
51
|
-
/**
|
|
52
|
-
* Stringify a value to JSON, returning a Result. Handles circular references.
|
|
53
|
-
*/
|
|
54
|
-
readonly toJson: (value: unknown) => Result<string, InternalError>;
|
|
55
|
-
};
|
|
56
|
-
export {};
|
|
57
|
-
//# sourceMappingURL=result.d.ts.map
|
package/dist/result.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE7D,cAAM,EAAE,CAAC,CAAC,EAAE,CAAC;IACX,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;gBAEN,KAAK,EAAE,CAAC;IAKpB,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IAKxB,KAAK,IAAI,IAAI,IAAI,GAAG,CAAC,CAAC,CAAC;IAIvB,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;IAIzC,OAAO,CAAC,CAAC,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AQ,EAAE;QAAE,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,CAAC,CAAC;QAAC,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAA;KAAE,GAAG,CAAC;IAIxE,MAAM,IAAI,KAAK;IAOf,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC;CAG5B;AAED,MAAM,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;AAGrD,eAAO,MAAM,MAAM;uBACT,CAAC,EAAE,CAAC,WAAW,SAAS,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,KAAG,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;mBAW3D,CAAC,SAAS,CAAC,KAAG,GAAG,CAAC,CAAC,CAAC;IAIxB;;;;;OAKG;gCAEM,MAAM,GAAG,GAAG,GAAG,OAAO,SACtB,WAAW,KACjB,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAMnC;;OAEG;8BACY,MAAM,KAAG,MAAM,CAAC,OAAO,EAAE,eAAe,CAAC;kBAarD,CAAC,iBAAiB,CAAC,KAAG,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC;IAIzC;;OAEG;6BACW,OAAO,KAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;CA4B7C,CAAC"}
|
package/dist/result.js
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A type-safe Result monad for representing success/failure without exceptions.
|
|
3
|
-
*/
|
|
4
|
-
import { InternalError, ValidationError } from './errors.js';
|
|
5
|
-
class Ok {
|
|
6
|
-
value;
|
|
7
|
-
constructor(value) {
|
|
8
|
-
this.value = value;
|
|
9
|
-
}
|
|
10
|
-
// oxlint-disable-next-line class-methods-use-this -- type guard for Result discriminated union
|
|
11
|
-
isOk() {
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
// oxlint-disable-next-line class-methods-use-this -- type guard for Result discriminated union
|
|
15
|
-
isErr() {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
map(fn) {
|
|
19
|
-
return new Ok(fn(this.value));
|
|
20
|
-
}
|
|
21
|
-
flatMap(fn) {
|
|
22
|
-
return fn(this.value);
|
|
23
|
-
}
|
|
24
|
-
mapErr(_fn) {
|
|
25
|
-
return new Ok(this.value);
|
|
26
|
-
}
|
|
27
|
-
match(handlers) {
|
|
28
|
-
return handlers.ok(this.value);
|
|
29
|
-
}
|
|
30
|
-
unwrap() {
|
|
31
|
-
return this.value;
|
|
32
|
-
}
|
|
33
|
-
unwrapOr(_fallback) {
|
|
34
|
-
return this.value;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
// oxlint-disable-next-line max-classes-per-file -- Result monad requires paired Ok/Err classes
|
|
38
|
-
class Err {
|
|
39
|
-
error;
|
|
40
|
-
constructor(error) {
|
|
41
|
-
this.error = error;
|
|
42
|
-
}
|
|
43
|
-
// oxlint-disable-next-line class-methods-use-this -- type guard for Result discriminated union
|
|
44
|
-
isOk() {
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
// oxlint-disable-next-line class-methods-use-this -- type guard for Result discriminated union
|
|
48
|
-
isErr() {
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
|
-
map(_fn) {
|
|
52
|
-
return new Err(this.error);
|
|
53
|
-
}
|
|
54
|
-
flatMap(_fn) {
|
|
55
|
-
return new Err(this.error);
|
|
56
|
-
}
|
|
57
|
-
mapErr(fn) {
|
|
58
|
-
return new Err(fn(this.error));
|
|
59
|
-
}
|
|
60
|
-
match(handlers) {
|
|
61
|
-
return handlers.err(this.error);
|
|
62
|
-
}
|
|
63
|
-
unwrap() {
|
|
64
|
-
throw this.error instanceof Error
|
|
65
|
-
? this.error
|
|
66
|
-
: new Error(String(this.error));
|
|
67
|
-
}
|
|
68
|
-
// oxlint-disable-next-line class-methods-use-this -- symmetric API with Ok.unwrapOr
|
|
69
|
-
unwrapOr(fallback) {
|
|
70
|
-
return fallback;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
74
|
-
export const Result = {
|
|
75
|
-
combine(results) {
|
|
76
|
-
const values = [];
|
|
77
|
-
for (const result of results) {
|
|
78
|
-
if (result.isErr()) {
|
|
79
|
-
return new Err(result.error);
|
|
80
|
-
}
|
|
81
|
-
values.push(result.value);
|
|
82
|
-
}
|
|
83
|
-
return new Ok(values);
|
|
84
|
-
},
|
|
85
|
-
err(error) {
|
|
86
|
-
return new Err(error);
|
|
87
|
-
},
|
|
88
|
-
/**
|
|
89
|
-
* Wrap a fetch call in a Result, mapping failures to TrailsError subclasses.
|
|
90
|
-
*
|
|
91
|
-
* Network errors become NetworkError. Abort signals become CancelledError.
|
|
92
|
-
* HTTP error status codes map to the appropriate error category.
|
|
93
|
-
*/
|
|
94
|
-
async fromFetch(input, init) {
|
|
95
|
-
// Lazy import avoids a circular dependency (fetch.ts imports Result)
|
|
96
|
-
const { fromFetch: fetchImpl } = await import('./fetch.js');
|
|
97
|
-
return fetchImpl(input, init);
|
|
98
|
-
},
|
|
99
|
-
/**
|
|
100
|
-
* Parse a JSON string, returning a Result instead of throwing.
|
|
101
|
-
*/
|
|
102
|
-
fromJson(json) {
|
|
103
|
-
try {
|
|
104
|
-
return new Ok(JSON.parse(json));
|
|
105
|
-
}
|
|
106
|
-
catch (error) {
|
|
107
|
-
return new Err(new ValidationError('Invalid JSON', {
|
|
108
|
-
cause: error instanceof Error ? error : new Error(String(error)),
|
|
109
|
-
context: { input: json.slice(0, 200) },
|
|
110
|
-
}));
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
ok(value) {
|
|
114
|
-
return new Ok(value);
|
|
115
|
-
},
|
|
116
|
-
/**
|
|
117
|
-
* Stringify a value to JSON, returning a Result. Handles circular references.
|
|
118
|
-
*/
|
|
119
|
-
toJson(value) {
|
|
120
|
-
try {
|
|
121
|
-
const seen = new WeakSet();
|
|
122
|
-
const json = JSON.stringify(value, (_key, val) => {
|
|
123
|
-
if (typeof val === 'object' && val !== null) {
|
|
124
|
-
if (seen.has(val)) {
|
|
125
|
-
return '[Circular]';
|
|
126
|
-
}
|
|
127
|
-
seen.add(val);
|
|
128
|
-
}
|
|
129
|
-
return val;
|
|
130
|
-
});
|
|
131
|
-
if (json === undefined) {
|
|
132
|
-
return new Err(new InternalError('Value is not JSON-serializable', {
|
|
133
|
-
context: { type: typeof value },
|
|
134
|
-
}));
|
|
135
|
-
}
|
|
136
|
-
return new Ok(json);
|
|
137
|
-
}
|
|
138
|
-
catch (error) {
|
|
139
|
-
return new Err(new InternalError('Failed to stringify value', {
|
|
140
|
-
cause: error instanceof Error ? error : new Error(String(error)),
|
|
141
|
-
}));
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
};
|
|
145
|
-
//# sourceMappingURL=result.js.map
|
package/dist/result.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result.js","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE7D,MAAM,EAAE;IACG,KAAK,CAAI;IAElB,YAAY,KAAQ;QAClB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,+FAA+F;IAC/F,IAAI;QACF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,+FAA+F;IAC/F,KAAK;QACH,OAAO,KAAK,CAAC;IACf,CAAC;IAED,GAAG,CAAI,EAAmB;QACxB,OAAO,IAAI,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAChC,CAAC;IAED,OAAO,CAAW,EAA8B;QAC9C,OA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@
|
|
|
1
|
-
/**
|
|
2
|
-
* Serialization utilities for @ontrails/core
|
|
3
|
-
*
|
|
4
|
-
* Safe JSON parsing/stringifying and error serialization/deserialization
|
|
5
|
-
* for transport across process boundaries.
|
|
6
|
-
*/
|
|
7
|
-
import type { ErrorCategory, TrailsError } from './errors.js';
|
|
8
|
-
import { ValidationError, InternalError } from './errors.js';
|
|
9
|
-
import { Result } from './result.js';
|
|
10
|
-
export interface SerializedError {
|
|
11
|
-
readonly name: string;
|
|
12
|
-
readonly message: string;
|
|
13
|
-
readonly category?: ErrorCategory | undefined;
|
|
14
|
-
readonly retryable?: boolean | undefined;
|
|
15
|
-
readonly retryAfter?: number | undefined;
|
|
16
|
-
readonly context?: Record<string, unknown> | undefined;
|
|
17
|
-
readonly stack?: string | undefined;
|
|
18
|
-
}
|
|
19
|
-
/** Extract structured data from an Error for transport. */
|
|
20
|
-
export declare const serializeError: (error: Error) => SerializedError;
|
|
21
|
-
/** Reconstruct a TrailsError from serialized data. */
|
|
22
|
-
export declare const deserializeError: (data: SerializedError) => TrailsError;
|
|
23
|
-
/** Parse a JSON string, returning a Result instead of throwing. */
|
|
24
|
-
export declare const safeParse: (json: string) => Result<unknown, ValidationError>;
|
|
25
|
-
/** Stringify a value, returning a Result. Handles circular references. */
|
|
26
|
-
export declare const safeStringify: (value: unknown) => Result<string, InternalError>;
|
|
27
|
-
//# sourceMappingURL=serialization.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../src/serialization.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EACL,eAAe,EAOf,aAAa,EAId,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAMrC,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IAC9C,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACzC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IACvD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC;AA4DD,2DAA2D;AAC3D,eAAO,MAAM,cAAc,GAAI,OAAO,KAAK,KAAG,eAmB7C,CAAC;AAEF,sDAAsD;AACtD,eAAO,MAAM,gBAAgB,GAAI,MAAM,eAAe,KAAG,WAcxD,CAAC;AAMF,mEAAmE;AACnE,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,KAAG,MAAM,CAAC,OAAO,EAAE,eAAe,CAWvE,CAAC;AAEF,0EAA0E;AAC1E,eAAO,MAAM,aAAa,GACxB,OAAO,OAAO,KACb,MAAM,CAAC,MAAM,EAAE,aAAa,CA2B9B,CAAC"}
|