@ontrails/core 1.0.0-beta.14 → 1.0.0-beta.16
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 +74 -0
- package/README.md +73 -24
- package/package.json +11 -4
- 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/context.ts +28 -4
- package/src/contour.ts +344 -0
- package/src/cross-batch.ts +69 -0
- package/src/cross-schema.ts +36 -0
- package/src/detours.ts +8 -0
- package/src/draft.ts +60 -52
- package/src/error-projection.ts +51 -0
- package/src/errors.ts +245 -48
- package/src/execute.ts +1250 -40
- package/src/fire.ts +1169 -0
- package/src/index.ts +383 -49
- package/src/internal/fork-ctx.ts +69 -0
- package/src/layer-projection.ts +192 -0
- package/src/layer.ts +81 -0
- 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 +175 -0
- package/src/result.ts +18 -0
- package/src/run.ts +7 -6
- package/src/schedule-runtime.ts +689 -0
- package/src/schedule.ts +324 -0
- package/src/serialization.ts +90 -55
- package/src/signal-diagnostics.ts +633 -0
- package/src/signal-ref.ts +87 -0
- package/src/signal.ts +37 -0
- package/src/store/accessor-protocol.ts +56 -0
- package/src/store/index.ts +4 -0
- package/src/structured-examples.ts +245 -0
- package/src/surface-derivation.ts +91 -0
- package/src/surface-filter.ts +176 -0
- package/src/topo.ts +710 -59
- package/src/tracing.ts +345 -0
- package/src/trail.ts +347 -33
- package/src/trails/derive-trail.ts +842 -0
- package/src/trails/index.ts +9 -0
- package/src/trails/ingest.ts +138 -0
- package/src/{internal/trails-db.ts → trails-db.ts} +50 -31
- package/src/transport-error-map.ts +174 -0
- package/src/type-utils.ts +17 -2
- package/src/types.ts +208 -17
- package/src/validate-established-topo.ts +8 -2
- package/src/validate-topo.ts +244 -13
- package/src/validation.ts +58 -1
- package/src/webhook.ts +276 -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 -21
- package/dist/context.js.map +0 -1
- package/dist/derive.d.ts +0 -44
- package/dist/derive.d.ts.map +0 -1
- package/dist/derive.js +0 -149
- package/dist/derive.js.map +0 -1
- package/dist/dispatch.d.ts +0 -27
- package/dist/dispatch.d.ts.map +0 -1
- package/dist/dispatch.js +0 -34
- package/dist/dispatch.js.map +0 -1
- package/dist/draft.d.ts +0 -28
- package/dist/draft.d.ts.map +0 -1
- package/dist/draft.js +0 -156
- package/dist/draft.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 -8
- package/dist/event.d.ts.map +0 -1
- package/dist/event.js +0 -7
- package/dist/event.js.map +0 -1
- package/dist/execute.d.ts +0 -35
- package/dist/execute.d.ts.map +0 -1
- package/dist/execute.js +0 -90
- package/dist/execute.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/gate.d.ts +0 -17
- package/dist/gate.d.ts.map +0 -1
- package/dist/gate.js +0 -21
- package/dist/gate.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/index.d.ts +0 -48
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -51
- package/dist/index.js.map +0 -1
- package/dist/internal/topo-saves.d.ts +0 -47
- package/dist/internal/topo-saves.d.ts.map +0 -1
- package/dist/internal/topo-saves.js +0 -310
- package/dist/internal/topo-saves.js.map +0 -1
- package/dist/internal/topo-store-read.d.ts +0 -67
- package/dist/internal/topo-store-read.d.ts.map +0 -1
- package/dist/internal/topo-store-read.js +0 -222
- package/dist/internal/topo-store-read.js.map +0 -1
- package/dist/internal/topo-store.d.ts +0 -12
- package/dist/internal/topo-store.d.ts.map +0 -1
- package/dist/internal/topo-store.js +0 -571
- package/dist/internal/topo-store.js.map +0 -1
- package/dist/internal/trails-db.d.ts +0 -16
- package/dist/internal/trails-db.d.ts.map +0 -1
- package/dist/internal/trails-db.js +0 -118
- package/dist/internal/trails-db.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 -6
- package/dist/layer.d.ts.map +0 -1
- package/dist/layer.js +0 -4
- 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/provision-config.d.ts +0 -22
- package/dist/provision-config.d.ts.map +0 -1
- package/dist/provision-config.js +0 -210
- package/dist/provision-config.js.map +0 -1
- package/dist/provision.d.ts +0 -71
- package/dist/provision.d.ts.map +0 -1
- package/dist/provision.js +0 -56
- package/dist/provision.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 -156
- package/dist/result.js.map +0 -1
- package/dist/run.d.ts +0 -27
- package/dist/run.d.ts.map +0 -1
- package/dist/run.js +0 -34
- package/dist/run.js.map +0 -1
- package/dist/serialization.d.ts +0 -27
- package/dist/serialization.d.ts.map +0 -1
- package/dist/serialization.js +0 -153
- package/dist/serialization.js.map +0 -1
- package/dist/service-config.d.ts +0 -22
- package/dist/service-config.d.ts.map +0 -1
- package/dist/service-config.js +0 -210
- package/dist/service-config.js.map +0 -1
- package/dist/service.d.ts +0 -71
- package/dist/service.d.ts.map +0 -1
- package/dist/service.js +0 -56
- package/dist/service.js.map +0 -1
- package/dist/signal.d.ts +0 -33
- package/dist/signal.d.ts.map +0 -1
- package/dist/signal.js +0 -17
- package/dist/signal.js.map +0 -1
- package/dist/topo-store.d.ts +0 -48
- package/dist/topo-store.d.ts.map +0 -1
- package/dist/topo-store.js +0 -175
- package/dist/topo-store.js.map +0 -1
- package/dist/topo.d.ts +0 -25
- package/dist/topo.d.ts.map +0 -1
- package/dist/topo.js +0 -112
- package/dist/topo.js.map +0 -1
- package/dist/trail.d.ts +0 -96
- package/dist/trail.d.ts.map +0 -1
- package/dist/trail.js +0 -20
- package/dist/trail.js.map +0 -1
- package/dist/type-utils.d.ts +0 -24
- package/dist/type-utils.d.ts.map +0 -1
- package/dist/type-utils.js +0 -12
- package/dist/type-utils.js.map +0 -1
- package/dist/types.d.ts +0 -71
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -3
- package/dist/types.js.map +0 -1
- package/dist/validate-established-topo.d.ts +0 -76
- package/dist/validate-established-topo.d.ts.map +0 -1
- package/dist/validate-established-topo.js +0 -43
- package/dist/validate-established-topo.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 -176
- 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 -165
- 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 -77
- package/src/__tests__/derive.test.ts +0 -260
- package/src/__tests__/errors.test.ts +0 -309
- package/src/__tests__/execute.test.ts +0 -525
- package/src/__tests__/fetch.test.ts +0 -217
- package/src/__tests__/gate.test.ts +0 -125
- package/src/__tests__/guards.test.ts +0 -102
- 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__/run.test.ts +0 -181
- package/src/__tests__/serialization.test.ts +0 -401
- package/src/__tests__/service-config.test.ts +0 -228
- package/src/__tests__/service.test.ts +0 -197
- package/src/__tests__/signal.test.ts +0 -82
- package/src/__tests__/topo-store-read.test.ts +0 -251
- package/src/__tests__/topo-store.test.ts +0 -469
- package/src/__tests__/topo.test.ts +0 -277
- package/src/__tests__/trail-permit.test.ts +0 -60
- package/src/__tests__/trail.test.ts +0 -261
- package/src/__tests__/trails-db.test.ts +0 -191
- package/src/__tests__/type-utils.test.ts +0 -90
- package/src/__tests__/validate-topo.test.ts +0 -489
- package/src/__tests__/validation.test.ts +0 -336
- package/src/__tests__/workspace.test.ts +0 -183
- package/src/event.ts +0 -15
- package/src/gate.ts +0 -44
- package/src/internal/topo-saves.ts +0 -429
- package/src/internal/topo-store-read.ts +0 -473
- package/src/internal/topo-store.ts +0 -1087
- package/src/provision-config.ts +0 -373
- package/src/provision.ts +0 -148
- package/src/topo-store.ts +0 -301
- package/tsconfig.json +0 -9
- package/tsconfig.tsbuildinfo +0 -1
package/dist/errors.d.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Error taxonomy for @ontrails/core
|
|
3
|
-
*
|
|
4
|
-
* Provides a structured error hierarchy with category-based mapping
|
|
5
|
-
* to exit codes, HTTP status codes, and JSON-RPC error codes.
|
|
6
|
-
*/
|
|
7
|
-
export type ErrorCategory = 'validation' | 'not_found' | 'conflict' | 'permission' | 'timeout' | 'rate_limit' | 'network' | 'internal' | 'auth' | 'cancelled';
|
|
8
|
-
export declare abstract class TrailsError extends Error {
|
|
9
|
-
abstract readonly category: ErrorCategory;
|
|
10
|
-
abstract readonly retryable: boolean;
|
|
11
|
-
readonly context?: Record<string, unknown> | undefined;
|
|
12
|
-
constructor(message: string, options?: {
|
|
13
|
-
cause?: Error;
|
|
14
|
-
context?: Record<string, unknown>;
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
export declare class ValidationError extends TrailsError {
|
|
18
|
-
readonly category: "validation";
|
|
19
|
-
readonly retryable: false;
|
|
20
|
-
}
|
|
21
|
-
export declare class AmbiguousError extends TrailsError {
|
|
22
|
-
readonly category: "validation";
|
|
23
|
-
readonly retryable: false;
|
|
24
|
-
}
|
|
25
|
-
export declare class AssertionError extends TrailsError {
|
|
26
|
-
readonly category: "internal";
|
|
27
|
-
readonly retryable: false;
|
|
28
|
-
}
|
|
29
|
-
export declare class NotFoundError extends TrailsError {
|
|
30
|
-
readonly category: "not_found";
|
|
31
|
-
readonly retryable: false;
|
|
32
|
-
}
|
|
33
|
-
export declare class AlreadyExistsError extends TrailsError {
|
|
34
|
-
readonly category: "conflict";
|
|
35
|
-
readonly retryable: false;
|
|
36
|
-
}
|
|
37
|
-
export declare class ConflictError extends TrailsError {
|
|
38
|
-
readonly category: "conflict";
|
|
39
|
-
readonly retryable: false;
|
|
40
|
-
}
|
|
41
|
-
export declare class PermissionError extends TrailsError {
|
|
42
|
-
readonly category: "permission";
|
|
43
|
-
readonly retryable: false;
|
|
44
|
-
}
|
|
45
|
-
export declare class TimeoutError extends TrailsError {
|
|
46
|
-
readonly category: "timeout";
|
|
47
|
-
readonly retryable: true;
|
|
48
|
-
}
|
|
49
|
-
export declare class RateLimitError extends TrailsError {
|
|
50
|
-
readonly category: "rate_limit";
|
|
51
|
-
readonly retryable: true;
|
|
52
|
-
readonly retryAfter?: number | undefined;
|
|
53
|
-
constructor(message: string, options?: {
|
|
54
|
-
cause?: Error;
|
|
55
|
-
context?: Record<string, unknown>;
|
|
56
|
-
retryAfter?: number;
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
export declare class NetworkError extends TrailsError {
|
|
60
|
-
readonly category: "network";
|
|
61
|
-
readonly retryable: true;
|
|
62
|
-
}
|
|
63
|
-
export declare class InternalError extends TrailsError {
|
|
64
|
-
readonly category: "internal";
|
|
65
|
-
readonly retryable: false;
|
|
66
|
-
}
|
|
67
|
-
export declare class AuthError extends TrailsError {
|
|
68
|
-
readonly category: "auth";
|
|
69
|
-
readonly retryable: false;
|
|
70
|
-
}
|
|
71
|
-
export declare class CancelledError extends TrailsError {
|
|
72
|
-
readonly category: "cancelled";
|
|
73
|
-
readonly retryable: false;
|
|
74
|
-
}
|
|
75
|
-
export declare const exitCodeMap: Record<ErrorCategory, number>;
|
|
76
|
-
export declare const statusCodeMap: Record<ErrorCategory, number>;
|
|
77
|
-
export declare const jsonRpcCodeMap: Record<ErrorCategory, number>;
|
|
78
|
-
export declare const retryableMap: Record<ErrorCategory, boolean>;
|
|
79
|
-
/** Type guard: narrows unknown to TrailsError */
|
|
80
|
-
export declare const isTrailsError: (error?: unknown) => error is TrailsError;
|
|
81
|
-
/** Returns true if the error is retryable (TrailsError with retryable category). */
|
|
82
|
-
export declare const isRetryable: (error: Error) => boolean;
|
|
83
|
-
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AAMH,MAAM,MAAM,aAAa,GACrB,YAAY,GACZ,WAAW,GACX,UAAU,GACV,YAAY,GACZ,SAAS,GACT,YAAY,GACZ,SAAS,GACT,UAAU,GACV,MAAM,GACN,WAAW,CAAC;AAMhB,8BAAsB,WAAY,SAAQ,KAAK;IAC7C,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;IAC1C,QAAQ,CAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IACrC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;gBAGrD,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,KAAK,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE;CAMjE;AAMD,qBAAa,eAAgB,SAAQ,WAAW;IAC9C,QAAQ,CAAC,QAAQ,EAAG,YAAY,CAAU;IAC1C,QAAQ,CAAC,SAAS,EAAG,KAAK,CAAU;CACrC;AAED,qBAAa,cAAe,SAAQ,WAAW;IAC7C,QAAQ,CAAC,QAAQ,EAAG,YAAY,CAAU;IAC1C,QAAQ,CAAC,SAAS,EAAG,KAAK,CAAU;CACrC;AAED,qBAAa,cAAe,SAAQ,WAAW;IAC7C,QAAQ,CAAC,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Ac,SAAQ,WAAW;IAC5C,QAAQ,CAAC,QAAQ,EAAG,UAAU,CAAU;IACxC,QAAQ,CAAC,SAAS,EAAG,KAAK,CAAU;CACrC;AAED,qBAAa,SAAU,SAAQ,WAAW;IACxC,QAAQ,CAAC,QAAQ,EAAG,MAAM,CAAU;IACpC,QAAQ,CAAC,SAAS,EAAG,KAAK,CAAU;CACrC;AAED,qBAAa,cAAe,SAAQ,WAAW;IAC7C,QAAQ,CAAC,QAAQ,EAAG,WAAW,CAAU;IACzC,QAAQ,CAAC,SAAS,EAAG,KAAK,CAAU;CACrC;AAMD,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,aAAa,EAAE,MAAM,CAW5C,CAAC;AAEX,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,aAAa,EAAE,MAAM,CAW9C,CAAC;AAEX,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,aAAa,EAAE,MAAM,CAW/C,CAAC;AAEX,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,aAAa,EAAE,OAAO,CAW9C,CAAC;AAMX,iDAAiD;AACjD,eAAO,MAAM,aAAa,GAAI,QAAQ,OAAO,KAAG,KAAK,IAAI,WAC3B,CAAC;AAE/B,oFAAoF;AACpF,eAAO,MAAM,WAAW,GAAI,OAAO,KAAK,KAAG,OAK1C,CAAC"}
|
package/dist/errors.js
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
/* oxlint-disable max-classes-per-file -- error taxonomy requires co-located class definitions */
|
|
2
|
-
/**
|
|
3
|
-
* Error taxonomy for @ontrails/core
|
|
4
|
-
*
|
|
5
|
-
* Provides a structured error hierarchy with category-based mapping
|
|
6
|
-
* to exit codes, HTTP status codes, and JSON-RPC error codes.
|
|
7
|
-
*/
|
|
8
|
-
// ---------------------------------------------------------------------------
|
|
9
|
-
// Base class
|
|
10
|
-
// ---------------------------------------------------------------------------
|
|
11
|
-
export class TrailsError extends Error {
|
|
12
|
-
context;
|
|
13
|
-
constructor(message, options) {
|
|
14
|
-
super(message, { cause: options?.cause });
|
|
15
|
-
this.name = this.constructor.name;
|
|
16
|
-
this.context = options?.context;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
// ---------------------------------------------------------------------------
|
|
20
|
-
// Concrete error classes
|
|
21
|
-
// ---------------------------------------------------------------------------
|
|
22
|
-
export class ValidationError extends TrailsError {
|
|
23
|
-
category = 'validation';
|
|
24
|
-
retryable = false;
|
|
25
|
-
}
|
|
26
|
-
export class AmbiguousError extends TrailsError {
|
|
27
|
-
category = 'validation';
|
|
28
|
-
retryable = false;
|
|
29
|
-
}
|
|
30
|
-
export class AssertionError extends TrailsError {
|
|
31
|
-
category = 'internal';
|
|
32
|
-
retryable = false;
|
|
33
|
-
}
|
|
34
|
-
export class NotFoundError extends TrailsError {
|
|
35
|
-
category = 'not_found';
|
|
36
|
-
retryable = false;
|
|
37
|
-
}
|
|
38
|
-
export class AlreadyExistsError extends TrailsError {
|
|
39
|
-
category = 'conflict';
|
|
40
|
-
retryable = false;
|
|
41
|
-
}
|
|
42
|
-
export class ConflictError extends TrailsError {
|
|
43
|
-
category = 'conflict';
|
|
44
|
-
retryable = false;
|
|
45
|
-
}
|
|
46
|
-
export class PermissionError extends TrailsError {
|
|
47
|
-
category = 'permission';
|
|
48
|
-
retryable = false;
|
|
49
|
-
}
|
|
50
|
-
export class TimeoutError extends TrailsError {
|
|
51
|
-
category = 'timeout';
|
|
52
|
-
retryable = true;
|
|
53
|
-
}
|
|
54
|
-
export class RateLimitError extends TrailsError {
|
|
55
|
-
category = 'rate_limit';
|
|
56
|
-
retryable = true;
|
|
57
|
-
retryAfter;
|
|
58
|
-
constructor(message, options) {
|
|
59
|
-
super(message, options);
|
|
60
|
-
this.retryAfter = options?.retryAfter;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
export class NetworkError extends TrailsError {
|
|
64
|
-
category = 'network';
|
|
65
|
-
retryable = true;
|
|
66
|
-
}
|
|
67
|
-
export class InternalError extends TrailsError {
|
|
68
|
-
category = 'internal';
|
|
69
|
-
retryable = false;
|
|
70
|
-
}
|
|
71
|
-
export class AuthError extends TrailsError {
|
|
72
|
-
category = 'auth';
|
|
73
|
-
retryable = false;
|
|
74
|
-
}
|
|
75
|
-
export class CancelledError extends TrailsError {
|
|
76
|
-
category = 'cancelled';
|
|
77
|
-
retryable = false;
|
|
78
|
-
}
|
|
79
|
-
// ---------------------------------------------------------------------------
|
|
80
|
-
// Taxonomy maps
|
|
81
|
-
// ---------------------------------------------------------------------------
|
|
82
|
-
export const exitCodeMap = {
|
|
83
|
-
auth: 9,
|
|
84
|
-
cancelled: 130,
|
|
85
|
-
conflict: 3,
|
|
86
|
-
internal: 8,
|
|
87
|
-
network: 7,
|
|
88
|
-
not_found: 2,
|
|
89
|
-
permission: 4,
|
|
90
|
-
rate_limit: 6,
|
|
91
|
-
timeout: 5,
|
|
92
|
-
validation: 1,
|
|
93
|
-
};
|
|
94
|
-
export const statusCodeMap = {
|
|
95
|
-
auth: 401,
|
|
96
|
-
cancelled: 499,
|
|
97
|
-
conflict: 409,
|
|
98
|
-
internal: 500,
|
|
99
|
-
network: 502,
|
|
100
|
-
not_found: 404,
|
|
101
|
-
permission: 403,
|
|
102
|
-
rate_limit: 429,
|
|
103
|
-
timeout: 504,
|
|
104
|
-
validation: 400,
|
|
105
|
-
};
|
|
106
|
-
export const jsonRpcCodeMap = {
|
|
107
|
-
auth: -32_600,
|
|
108
|
-
cancelled: -32_603,
|
|
109
|
-
conflict: -32_603,
|
|
110
|
-
internal: -32_603,
|
|
111
|
-
network: -32_603,
|
|
112
|
-
not_found: -32_601,
|
|
113
|
-
permission: -32_600,
|
|
114
|
-
rate_limit: -32_603,
|
|
115
|
-
timeout: -32_603,
|
|
116
|
-
validation: -32_602,
|
|
117
|
-
};
|
|
118
|
-
export const retryableMap = {
|
|
119
|
-
auth: false,
|
|
120
|
-
cancelled: false,
|
|
121
|
-
conflict: false,
|
|
122
|
-
internal: false,
|
|
123
|
-
network: true,
|
|
124
|
-
not_found: false,
|
|
125
|
-
permission: false,
|
|
126
|
-
rate_limit: true,
|
|
127
|
-
timeout: true,
|
|
128
|
-
validation: false,
|
|
129
|
-
};
|
|
130
|
-
// ---------------------------------------------------------------------------
|
|
131
|
-
// Helper functions
|
|
132
|
-
// ---------------------------------------------------------------------------
|
|
133
|
-
/** Type guard: narrows unknown to TrailsError */
|
|
134
|
-
export const isTrailsError = (error) => error instanceof TrailsError;
|
|
135
|
-
/** Returns true if the error is retryable (TrailsError with retryable category). */
|
|
136
|
-
export const isRetryable = (error) => {
|
|
137
|
-
if (isTrailsError(error)) {
|
|
138
|
-
return retryableMap[error.category];
|
|
139
|
-
}
|
|
140
|
-
return false;
|
|
141
|
-
};
|
|
142
|
-
//# sourceMappingURL=errors.js.map
|
package/dist/errors.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG;;;;;GAKG;AAkBH,8EAA8E;AAC9E,aAAa;AACb,8EAA8E;AAE9E,MAAM,OAAgB,WAAY,SAAQ,KAAK;IAGpC,OAAO,CAAuC;IAEvD,YACE,OAAe,EACf,OAA8D;QAE9D,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QAC1C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,OAAO,EAAE,OAAO,CAAC;IAClC,CAAC;CACF;AAED,8EAA8E;AAC9E,yBAAyB;AACzB,8EAA8E;AAE9E,MAAM,OAAO,eAAgB,SAAQ,WAAW;IACrC,QAAQ,GAAG,YAAqB,CAAC;IACjC,SAAS,GAAG,KAAc,CAAC;CACrC;AAED,MAAM,OAAO,cAAe,SAAQ,WAAW;IACpC,QAAQ,GAAG,YAAqB,CAAC;IACjC,SAAS,GA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;IACb,SAAS,EAAE,KAAK;IAChB,UAAU,EAAE,KAAK;IACjB,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,IAAI;IACb,UAAU,EAAE,KAAK;CACT,CAAC;AAEX,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E,iDAAiD;AACjD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAe,EAAwB,EAAE,CACrE,KAAK,YAAY,WAAW,CAAC;AAE/B,oFAAoF;AACpF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAY,EAAW,EAAE;IACnD,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,YAAY,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
|
package/dist/event.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Legacy event aliases for the signal model.
|
|
3
|
-
*
|
|
4
|
-
* Keep this file as a compatibility seam while the repo-wide cutover lands.
|
|
5
|
-
*/
|
|
6
|
-
export { signal as event } from './signal.js';
|
|
7
|
-
export type { AnySignal, AnySignal as AnyEvent, Signal, Signal as Event, SignalSpec, SignalSpec as EventSpec, } from './signal.js';
|
|
8
|
-
//# sourceMappingURL=event.d.ts.map
|
package/dist/event.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../src/event.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,IAAI,KAAK,EAAE,MAAM,aAAa,CAAC;AAC9C,YAAY,EACV,SAAS,EACT,SAAS,IAAI,QAAQ,EACrB,MAAM,EACN,MAAM,IAAI,KAAK,EACf,UAAU,EACV,UAAU,IAAI,SAAS,GACxB,MAAM,aAAa,CAAC"}
|
package/dist/event.js
DELETED
package/dist/event.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"event.js","sourceRoot":"","sources":["../src/event.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,IAAI,KAAK,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/execute.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Centralized trail execution pipeline.
|
|
3
|
-
*
|
|
4
|
-
* Validates input, builds context, composes gates, and runs the
|
|
5
|
-
* implementation. Surfaces (CLI, MCP, HTTP) delegate here instead
|
|
6
|
-
* of reimplementing the pipeline.
|
|
7
|
-
*/
|
|
8
|
-
import type { AnyTrail } from './trail.js';
|
|
9
|
-
import type { Gate } from './gate.js';
|
|
10
|
-
import type { ProvisionOverrideMap } from './provision.js';
|
|
11
|
-
import type { TrailContextInit } from './types.js';
|
|
12
|
-
import { Result } from './result.js';
|
|
13
|
-
/** Options for executeTrail. */
|
|
14
|
-
export interface ExecuteTrailOptions {
|
|
15
|
-
/** Partial context overrides merged on top of the base context. */
|
|
16
|
-
readonly ctx?: Partial<TrailContextInit> | undefined;
|
|
17
|
-
/** AbortSignal override (takes final precedence over ctx and factory). */
|
|
18
|
-
readonly abortSignal?: AbortSignal | undefined;
|
|
19
|
-
/** Gates to compose around the implementation. */
|
|
20
|
-
readonly gates?: readonly Gate[] | undefined;
|
|
21
|
-
/** Factory that produces a base TrailContext (takes precedence over defaults). */
|
|
22
|
-
readonly createContext?: (() => TrailContextInit | Promise<TrailContextInit>) | undefined;
|
|
23
|
-
/** Explicit provision instance overrides keyed by provision ID. */
|
|
24
|
-
readonly provisions?: ProvisionOverrideMap | undefined;
|
|
25
|
-
/** Config values for provisions that declare a `config` schema, keyed by provision ID. */
|
|
26
|
-
readonly configValues?: Readonly<Record<string, Record<string, unknown>>> | undefined;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Execute a trail through the standard validate-context-gates-run pipeline.
|
|
30
|
-
*
|
|
31
|
-
* The function never throws -- unexpected exceptions are caught and
|
|
32
|
-
* returned as `Result.err(InternalError)`.
|
|
33
|
-
*/
|
|
34
|
-
export declare const executeTrail: (trail: AnyTrail, rawInput: unknown, options?: ExecuteTrailOptions) => Promise<Result<unknown, Error>>;
|
|
35
|
-
//# sourceMappingURL=execute.d.ts.map
|
package/dist/execute.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../src/execute.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,KAAK,EAAgB,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAKjE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAarC,gCAAgC;AAChC,MAAM,WAAW,mBAAmB;IAClC,mEAAmE;IACnE,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,SAAS,CAAC;IACrD,0EAA0E;IAC1E,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAC/C,kDAAkD;IAClD,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,IAAI,EAAE,GAAG,SAAS,CAAC;IAC7C,kFAAkF;IAClF,QAAQ,CAAC,aAAa,CAAC,EACnB,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,GACpD,SAAS,CAAC;IACd,mEAAmE;IACnE,QAAQ,CAAC,UAAU,CAAC,EAAE,oBAAoB,GAAG,SAAS,CAAC;IACvD,0FAA0F;IAC1F,QAAQ,CAAC,YAAY,CAAC,EAClB,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,GACjD,SAAS,CAAC;CACf;AAsFD;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GACvB,OAAO,QAAQ,EACf,UAAU,OAAO,EACjB,UAAU,mBAAmB,KAC5B,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAsBhC,CAAC"}
|
package/dist/execute.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Centralized trail execution pipeline.
|
|
3
|
-
*
|
|
4
|
-
* Validates input, builds context, composes gates, and runs the
|
|
5
|
-
* implementation. Surfaces (CLI, MCP, HTTP) delegate here instead
|
|
6
|
-
* of reimplementing the pipeline.
|
|
7
|
-
*/
|
|
8
|
-
import { composeGates } from './gate.js';
|
|
9
|
-
import { createTrailContext } from './context.js';
|
|
10
|
-
import { InternalError } from './errors.js';
|
|
11
|
-
import { Result } from './result.js';
|
|
12
|
-
import { createProvisionLookup } from './provision.js';
|
|
13
|
-
import { resolveProvisions } from './provision-config.js';
|
|
14
|
-
import { validateInput } from './validation.js';
|
|
15
|
-
// ---------------------------------------------------------------------------
|
|
16
|
-
// Context resolution
|
|
17
|
-
// ---------------------------------------------------------------------------
|
|
18
|
-
const applyContextOverrides = (base, options) => {
|
|
19
|
-
const withOverrides = options?.ctx
|
|
20
|
-
? {
|
|
21
|
-
...base,
|
|
22
|
-
...options.ctx,
|
|
23
|
-
extensions: { ...base.extensions, ...options.ctx.extensions },
|
|
24
|
-
}
|
|
25
|
-
: base;
|
|
26
|
-
return options?.abortSignal
|
|
27
|
-
? { ...withOverrides, abortSignal: options.abortSignal }
|
|
28
|
-
: withOverrides;
|
|
29
|
-
};
|
|
30
|
-
const bindProvisionLookup = (resolved, options) => {
|
|
31
|
-
if (options?.ctx?.extensions === undefined &&
|
|
32
|
-
resolved.provision !== undefined) {
|
|
33
|
-
return resolved;
|
|
34
|
-
}
|
|
35
|
-
const bound = { ...resolved };
|
|
36
|
-
const lookup = createProvisionLookup(() => bound);
|
|
37
|
-
bound.provision = lookup;
|
|
38
|
-
return bound;
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Build a TrailContext from options.
|
|
42
|
-
*
|
|
43
|
-
* Resolution order:
|
|
44
|
-
* 1. Factory (`createContext`) or `createTrailContext()` defaults.
|
|
45
|
-
* 2. Partial `ctx` overrides merged on top.
|
|
46
|
-
* 3. `abortSignal` override takes final precedence.
|
|
47
|
-
*/
|
|
48
|
-
const resolveContext = async (options) => {
|
|
49
|
-
const seed = options?.createContext
|
|
50
|
-
? await options.createContext()
|
|
51
|
-
: createTrailContext();
|
|
52
|
-
const base = seed.provision ? seed : createTrailContext(seed);
|
|
53
|
-
const resolved = applyContextOverrides(base, options);
|
|
54
|
-
return bindProvisionLookup(resolved, options);
|
|
55
|
-
};
|
|
56
|
-
const prepareContext = async (trail, options) => {
|
|
57
|
-
const baseCtx = await resolveContext(options);
|
|
58
|
-
return await resolveProvisions(trail, baseCtx, options?.provisions, options?.configValues);
|
|
59
|
-
};
|
|
60
|
-
const runTrail = async (trail, input, ctx, gates) => {
|
|
61
|
-
const impl = composeGates([...gates], trail, trail.blaze);
|
|
62
|
-
return await impl(input, ctx);
|
|
63
|
-
};
|
|
64
|
-
// ---------------------------------------------------------------------------
|
|
65
|
-
// Pipeline
|
|
66
|
-
// ---------------------------------------------------------------------------
|
|
67
|
-
/**
|
|
68
|
-
* Execute a trail through the standard validate-context-gates-run pipeline.
|
|
69
|
-
*
|
|
70
|
-
* The function never throws -- unexpected exceptions are caught and
|
|
71
|
-
* returned as `Result.err(InternalError)`.
|
|
72
|
-
*/
|
|
73
|
-
export const executeTrail = async (trail, rawInput, options) => {
|
|
74
|
-
try {
|
|
75
|
-
const validated = validateInput(trail.input, rawInput);
|
|
76
|
-
if (validated.isErr()) {
|
|
77
|
-
return validated;
|
|
78
|
-
}
|
|
79
|
-
const resolvedCtx = await prepareContext(trail, options);
|
|
80
|
-
if (resolvedCtx.isErr()) {
|
|
81
|
-
return resolvedCtx;
|
|
82
|
-
}
|
|
83
|
-
return await runTrail(trail, validated.value, resolvedCtx.value, options?.gates ?? []);
|
|
84
|
-
}
|
|
85
|
-
catch (error) {
|
|
86
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
87
|
-
return Result.err(new InternalError(message));
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
//# sourceMappingURL=execute.js.map
|
package/dist/execute.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../src/execute.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AA8BhD,8EAA8E;AAC9E,qBAAqB;AACrB,8EAA8E;AAE9E,MAAM,qBAAqB,GAAG,CAC5B,IAAsB,EACtB,OAA6B,EACX,EAAE;IACpB,MAAM,aAAa,GAAG,OAAO,EAAE,GAAG;QAChC,CAAC,CAAC;YACE,GAAG,IAAI;YACP,GAAG,OAAO,CAAC,GAAG;YACd,UAAU,EAAE,EAAE,GAAG,IAAI,CAAC,UAAU,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE;SAC9D;QACH,CAAC,CAAC,IAAI,CAAC;IAET,OAAO,OAAO,EAAE,WAAW;QACzB,CAAC,CAAC,EAAE,GAAG,aAAa,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE;QACxD,CAAC,CAAC,aAAa,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the standard fetch API, mapping errors and HTTP status codes
|
|
5
|
-
* to the TrailsError taxonomy.
|
|
6
|
-
*/
|
|
7
|
-
import { Result } from './result.js';
|
|
8
|
-
/**
|
|
9
|
-
* Wrap a fetch call in a Result, mapping failures to TrailsError subclasses.
|
|
10
|
-
*
|
|
11
|
-
* Network errors become NetworkError. Abort signals become CancelledError.
|
|
12
|
-
* HTTP error status codes map to the appropriate error category.
|
|
13
|
-
*/
|
|
14
|
-
export declare const fromFetch: (input: string | URL | Request, init?: RequestInit) => Promise<Result<Response, Error>>;
|
|
15
|
-
//# sourceMappingURL=fetch.d.ts.map
|
package/dist/fetch.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAcH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AA+FrC;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GACpB,OAAO,MAAM,GAAG,GAAG,GAAG,OAAO,EAC7B,OAAO,WAAW,KACjB,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,CAcjC,CAAC"}
|
package/dist/fetch.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Fetch utilities for @ontrails/core
|
|
3
|
-
*
|
|
4
|
-
* Wraps the standard fetch API, mapping errors and HTTP status codes
|
|
5
|
-
* to the TrailsError taxonomy.
|
|
6
|
-
*/
|
|
7
|
-
import { AuthError, CancelledError, ConflictError, InternalError, NetworkError, NotFoundError, PermissionError, RateLimitError, TimeoutError, ValidationError, } from './errors.js';
|
|
8
|
-
import { Result } from './result.js';
|
|
9
|
-
// ---------------------------------------------------------------------------
|
|
10
|
-
// Internal helpers (defined before usage)
|
|
11
|
-
// ---------------------------------------------------------------------------
|
|
12
|
-
const toError = (err) => err instanceof Error ? err : new Error(String(err));
|
|
13
|
-
const parseRetryAfter = (header) => {
|
|
14
|
-
if (!header) {
|
|
15
|
-
return undefined;
|
|
16
|
-
}
|
|
17
|
-
const seconds = Number(header);
|
|
18
|
-
if (Number.isFinite(seconds) && seconds > 0) {
|
|
19
|
-
return seconds;
|
|
20
|
-
}
|
|
21
|
-
// Try parsing as HTTP-date
|
|
22
|
-
const date = Date.parse(header);
|
|
23
|
-
if (!Number.isNaN(date)) {
|
|
24
|
-
const delta = Math.ceil((date - Date.now()) / 1000);
|
|
25
|
-
return delta > 0 ? delta : undefined;
|
|
26
|
-
}
|
|
27
|
-
return undefined;
|
|
28
|
-
};
|
|
29
|
-
const mapFetchError = (err) => {
|
|
30
|
-
if (err instanceof DOMException && err.name === 'AbortError') {
|
|
31
|
-
return new CancelledError('Request was aborted', { cause: toError(err) });
|
|
32
|
-
}
|
|
33
|
-
// TypeError is thrown for network failures in the fetch spec
|
|
34
|
-
if (err instanceof TypeError) {
|
|
35
|
-
return new NetworkError('Network request failed', { cause: err });
|
|
36
|
-
}
|
|
37
|
-
return new NetworkError('Network request failed', {
|
|
38
|
-
cause: toError(err),
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
const statusMappers = {
|
|
42
|
-
401: (ctx) => new AuthError('Unauthorized', { context: ctx }),
|
|
43
|
-
403: (ctx) => new PermissionError('Forbidden', { context: ctx }),
|
|
44
|
-
404: (ctx) => new NotFoundError('Not found', { context: ctx }),
|
|
45
|
-
429: (ctx, response) => {
|
|
46
|
-
const retryAfter = parseRetryAfter(response.headers.get('retry-after'));
|
|
47
|
-
const opts = {
|
|
48
|
-
context: ctx,
|
|
49
|
-
};
|
|
50
|
-
if (retryAfter !== undefined) {
|
|
51
|
-
opts.retryAfter = retryAfter;
|
|
52
|
-
}
|
|
53
|
-
return new RateLimitError('Rate limited', opts);
|
|
54
|
-
},
|
|
55
|
-
500: (ctx) => new InternalError('Internal server error', { context: ctx }),
|
|
56
|
-
502: (ctx) => new NetworkError('Bad gateway', { context: ctx }),
|
|
57
|
-
504: (ctx) => new TimeoutError('Gateway timeout', { context: ctx }),
|
|
58
|
-
};
|
|
59
|
-
/** Map 4xx status codes not in the explicit mapper to appropriate error types. */
|
|
60
|
-
const mapClientError = (status, context) => {
|
|
61
|
-
if (status === 400 || status === 422) {
|
|
62
|
-
return new ValidationError(`Validation error (${status})`, { context });
|
|
63
|
-
}
|
|
64
|
-
if (status === 409) {
|
|
65
|
-
return new ConflictError(`Conflict (${status})`, { context });
|
|
66
|
-
}
|
|
67
|
-
return new InternalError(`HTTP error (${status})`, { context });
|
|
68
|
-
};
|
|
69
|
-
const mapStatusCode = (response) => {
|
|
70
|
-
const context = { status: response.status, url: response.url };
|
|
71
|
-
const mapper = statusMappers[response.status];
|
|
72
|
-
if (mapper) {
|
|
73
|
-
return mapper(context, response);
|
|
74
|
-
}
|
|
75
|
-
if (response.status >= 500) {
|
|
76
|
-
return new InternalError(`Server error (${response.status})`, { context });
|
|
77
|
-
}
|
|
78
|
-
return mapClientError(response.status, context);
|
|
79
|
-
};
|
|
80
|
-
// ---------------------------------------------------------------------------
|
|
81
|
-
// fromFetch
|
|
82
|
-
// ---------------------------------------------------------------------------
|
|
83
|
-
/**
|
|
84
|
-
* Wrap a fetch call in a Result, mapping failures to TrailsError subclasses.
|
|
85
|
-
*
|
|
86
|
-
* Network errors become NetworkError. Abort signals become CancelledError.
|
|
87
|
-
* HTTP error status codes map to the appropriate error category.
|
|
88
|
-
*/
|
|
89
|
-
export const fromFetch = async (input, init) => {
|
|
90
|
-
let response;
|
|
91
|
-
try {
|
|
92
|
-
response = await fetch(input, init);
|
|
93
|
-
}
|
|
94
|
-
catch (error) {
|
|
95
|
-
return Result.err(mapFetchError(error));
|
|
96
|
-
}
|
|
97
|
-
if (response.ok) {
|
|
98
|
-
return Result.ok(response);
|
|
99
|
-
}
|
|
100
|
-
return Result.err(mapStatusCode(response));
|
|
101
|
-
};
|
|
102
|
-
//# sourceMappingURL=fetch.js.map
|
package/dist/fetch.js.map
DELETED
|
@@ -1 +0,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EAAE,CAAC;QAC3B,OAAO,IAAI,aAAa,CAAC,iBAAiB,QAAQ,CAAC,MAAM,GAAG,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,cAAc,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAClD,CAAC,CAAC;AAEF,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAC5B,KAA6B,EAC7B,IAAkB,EACgB,EAAE;IACpC,IAAI,QAAkB,CAAC;IAEvB,IAAI,CAAC;QACH,QAAQ,GAAG,MAAM,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACtC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;IAC1C,CAAC;IAED,IAAI,QAAQ,CAAC,EAAE,EAAE,CAAC;QAChB,OAAO,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC;IAED,OAAO,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC7C,CAAC,CAAC"}
|
package/dist/gate.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { Trail } from './trail.js';
|
|
2
|
-
import type { Implementation } from './types.js';
|
|
3
|
-
/** A composable gate that wraps trail implementations. */
|
|
4
|
-
export interface Gate {
|
|
5
|
-
readonly name: string;
|
|
6
|
-
readonly description?: string | undefined;
|
|
7
|
-
/** Wrap a trail's implementation, returning a new implementation. */
|
|
8
|
-
wrap<I, O>(trail: Trail<I, O>, implementation: Implementation<I, O>): Implementation<I, O>;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Apply gates outermost-first: gates[0] wraps gates[1] wraps ... wraps
|
|
12
|
-
* the base implementation.
|
|
13
|
-
*
|
|
14
|
-
* An empty gates array returns the implementation unchanged.
|
|
15
|
-
*/
|
|
16
|
-
export declare const composeGates: <I, O>(gates: readonly Gate[], trail: Trail<I, O>, implementation: Implementation<I, O>) => Implementation<I, O>;
|
|
17
|
-
//# sourceMappingURL=gate.d.ts.map
|
package/dist/gate.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gate.d.ts","sourceRoot":"","sources":["../src/gate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAMjD,0DAA0D;AAC1D,MAAM,WAAW,IAAI;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE1C,qEAAqE;IACrE,IAAI,CAAC,CAAC,EAAE,CAAC,EACP,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAClB,cAAc,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,GACnC,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CACzB;AAMD;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,EAAE,CAAC,EAC/B,OAAO,SAAS,IAAI,EAAE,EACtB,OAAO,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAClB,gBAAgB,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,KACnC,cAAc,CAAC,CAAC,EAAE,CAAC,CAUrB,CAAC"}
|
package/dist/gate.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// ---------------------------------------------------------------------------
|
|
2
|
-
// Composition
|
|
3
|
-
// ---------------------------------------------------------------------------
|
|
4
|
-
/**
|
|
5
|
-
* Apply gates outermost-first: gates[0] wraps gates[1] wraps ... wraps
|
|
6
|
-
* the base implementation.
|
|
7
|
-
*
|
|
8
|
-
* An empty gates array returns the implementation unchanged.
|
|
9
|
-
*/
|
|
10
|
-
export const composeGates = (gates, trail, implementation) => {
|
|
11
|
-
// Fold right so gates[0] is the outermost wrapper.
|
|
12
|
-
let result = implementation;
|
|
13
|
-
for (let i = gates.length - 1; i >= 0; i -= 1) {
|
|
14
|
-
const gate = gates[i];
|
|
15
|
-
if (gate) {
|
|
16
|
-
result = gate.wrap(trail, result);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
//# sourceMappingURL=gate.js.map
|
package/dist/gate.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gate.js","sourceRoot":"","sources":["../src/gate.ts"],"names":[],"mappings":"AAmBA,8EAA8E;AAC9E,cAAc;AACd,8EAA8E;AAE9E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,KAAsB,EACtB,KAAkB,EAClB,cAAoC,EACd,EAAE;IACxB,mDAAmD;IACnD,IAAI,MAAM,GAAG,cAAc,CAAC;IAC5B,KAAK,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9C,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACtB,IAAI,IAAI,EAAE,CAAC;YACT,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
package/dist/guards.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type guards and assertion helpers for @ontrails/core.
|
|
3
|
-
*/
|
|
4
|
-
/** Narrows `T | null | undefined` to `T`. */
|
|
5
|
-
export declare const isDefined: <T>(value?: T | null | undefined) => value is T;
|
|
6
|
-
/** Returns true when `value` is a string with length > 0. */
|
|
7
|
-
export declare const isNonEmptyString: (value?: unknown) => value is string;
|
|
8
|
-
/** Returns true when `value` is a plain object (not an array, Date, etc.). */
|
|
9
|
-
export declare const isPlainObject: (value: unknown) => value is Record<string, unknown>;
|
|
10
|
-
/** Checks that `obj` is an object with the given key present. */
|
|
11
|
-
export declare const hasProperty: <K extends string>(obj: unknown, key: K) => obj is Record<K, unknown>;
|
|
12
|
-
/**
|
|
13
|
-
* Exhaustive switch helper. Place in the `default` branch to get a compile
|
|
14
|
-
* error when a union case is unhandled.
|
|
15
|
-
*/
|
|
16
|
-
export declare const assertNever: (value: never) => never;
|
|
17
|
-
//# sourceMappingURL=guards.d.ts.map
|
package/dist/guards.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"guards.d.ts","sourceRoot":"","sources":["../src/guards.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,6CAA6C;AAC7C,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,QAAQ,CAAC,GAAG,IAAI,GAAG,SAAS,KAAG,KAAK,IAAI,CAC9B,CAAC;AAExC,6DAA6D;AAC7D,eAAO,MAAM,gBAAgB,GAAI,QAAQ,OAAO,KAAG,KAAK,IAAI,MACb,CAAC;AAEhD,8EAA8E;AAC9E,eAAO,MAAM,aAAa,GACxB,OAAO,OAAO,KACb,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAMjC,CAAC;AAEF,iEAAiE;AACjE,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,MAAM,EAC1C,KAAK,OAAO,EACZ,KAAK,CAAC,KACL,GAAG,IAAI,MAAM,CAAC,CAAC,EAAE,OAAO,CAC4B,CAAC;AAExD;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,KAAK,KAAG,KAE1C,CAAC"}
|
package/dist/guards.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type guards and assertion helpers for @ontrails/core.
|
|
3
|
-
*/
|
|
4
|
-
/** Narrows `T | null | undefined` to `T`. */
|
|
5
|
-
export const isDefined = (value) => value !== null && value !== undefined;
|
|
6
|
-
/** Returns true when `value` is a string with length > 0. */
|
|
7
|
-
export const isNonEmptyString = (value) => typeof value === 'string' && value.length > 0;
|
|
8
|
-
/** Returns true when `value` is a plain object (not an array, Date, etc.). */
|
|
9
|
-
export const isPlainObject = (value) => {
|
|
10
|
-
if (typeof value !== 'object' || value === null) {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
const proto = Object.getPrototypeOf(value);
|
|
14
|
-
return proto === Object.prototype || proto === null;
|
|
15
|
-
};
|
|
16
|
-
/** Checks that `obj` is an object with the given key present. */
|
|
17
|
-
export const hasProperty = (obj, key) => typeof obj === 'object' && obj !== null && key in obj;
|
|
18
|
-
/**
|
|
19
|
-
* Exhaustive switch helper. Place in the `default` branch to get a compile
|
|
20
|
-
* error when a union case is unhandled.
|
|
21
|
-
*/
|
|
22
|
-
export const assertNever = (value) => {
|
|
23
|
-
throw new Error(`Unexpected value: ${String(value)}`);
|
|
24
|
-
};
|
|
25
|
-
//# sourceMappingURL=guards.js.map
|
package/dist/guards.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"guards.js","sourceRoot":"","sources":["../src/guards.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,6CAA6C;AAC7C,MAAM,CAAC,MAAM,SAAS,GAAG,CAAI,KAA4B,EAAc,EAAE,CACvE,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC;AAExC,6DAA6D;AAC7D,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAe,EAAmB,EAAE,CACnE,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AAEhD,8EAA8E;AAC9E,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,KAAc,EACoB,EAAE;IACpC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAY,CAAC;IACtD,OAAO,KAAK,KAAK,MAAM,CAAC,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC;AACtD,CAAC,CAAC;AAEF,iEAAiE;AACjE,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,GAAY,EACZ,GAAM,EACqB,EAAE,CAC7B,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,CAAC;AAExD;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAY,EAAS,EAAE;IACjD,MAAM,IAAI,KAAK,CAAC,qBAAqB,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AACxD,CAAC,CAAC"}
|