@ontrails/core 1.0.0-beta.15 → 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 +63 -0
- package/README.md +61 -16
- package/package.json +9 -8
- 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/context.ts +4 -0
- package/src/{internal/cross-batch.ts → cross-batch.ts} +3 -11
- package/src/detours.ts +8 -0
- package/src/draft.ts +4 -0
- package/src/error-projection.ts +51 -0
- package/src/errors.ts +192 -39
- package/src/execute.ts +443 -44
- package/src/fire.ts +965 -91
- package/src/index.ts +285 -38
- package/src/layer-projection.ts +192 -0
- package/src/layer.ts +32 -1
- package/src/observe.ts +361 -0
- package/src/permits.ts +12 -0
- package/src/redaction/patterns.ts +6 -3
- package/src/resilience.ts +8 -8
- package/src/resource-config.ts +477 -44
- package/src/resource.ts +21 -1
- package/src/result.ts +18 -0
- package/src/run.ts +2 -2
- package/src/schedule-runtime.ts +689 -0
- package/src/schedule.ts +324 -0
- package/src/serialization.ts +90 -57
- package/src/signal-diagnostics.ts +633 -0
- package/src/{internal/signal-ref.ts → signal-ref.ts} +1 -1
- package/src/signal.ts +37 -0
- package/src/store/accessor-protocol.ts +5 -5
- package/src/structured-examples.ts +245 -0
- package/src/surface-derivation.ts +91 -0
- package/src/surface-filter.ts +7 -13
- package/src/topo.ts +386 -6
- package/src/tracing.ts +345 -0
- package/src/trail.ts +168 -22
- package/src/trails/derive-trail.ts +1 -1
- package/src/trails/ingest.ts +7 -15
- package/src/{internal/trails-db.ts → trails-db.ts} +42 -21
- package/src/transport-error-map.ts +146 -28
- package/src/types.ts +82 -28
- package/src/validate-established-topo.ts +6 -0
- package/src/validate-topo.ts +212 -5
- package/src/validation.ts +58 -1
- package/src/webhook.ts +276 -0
- package/src/{internal/zod-wrappers.ts → zod-wrappers.ts} +0 -6
- package/.turbo/turbo-build.log +0 -1
- package/.turbo/turbo-lint.log +0 -3
- package/.turbo/turbo-typecheck.log +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 -22
- package/dist/context.d.ts.map +0 -1
- package/dist/context.js +0 -37
- package/dist/context.js.map +0 -1
- package/dist/contour.d.ts +0 -81
- package/dist/contour.d.ts.map +0 -1
- package/dist/contour.js +0 -176
- package/dist/contour.js.map +0 -1
- package/dist/cross-schema.d.ts +0 -18
- package/dist/cross-schema.d.ts.map +0 -1
- package/dist/cross-schema.js +0 -29
- package/dist/cross-schema.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/draft.d.ts +0 -28
- package/dist/draft.d.ts.map +0 -1
- package/dist/draft.js +0 -157
- package/dist/draft.js.map +0 -1
- package/dist/errors.d.ts +0 -141
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -185
- package/dist/errors.js.map +0 -1
- package/dist/execute.d.ts +0 -52
- package/dist/execute.d.ts.map +0 -1
- package/dist/execute.js +0 -511
- 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/fire.d.ts +0 -43
- package/dist/fire.d.ts.map +0 -1
- package/dist/fire.js +0 -185
- package/dist/fire.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/index.d.ts +0 -59
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -61
- package/dist/index.js.map +0 -1
- package/dist/internal/cross-batch.d.ts +0 -44
- package/dist/internal/cross-batch.d.ts.map +0 -1
- package/dist/internal/cross-batch.js +0 -58
- package/dist/internal/cross-batch.js.map +0 -1
- package/dist/internal/fork-ctx.d.ts +0 -41
- package/dist/internal/fork-ctx.d.ts.map +0 -1
- package/dist/internal/fork-ctx.js +0 -47
- package/dist/internal/fork-ctx.js.map +0 -1
- package/dist/internal/signal-ref.d.ts +0 -15
- package/dist/internal/signal-ref.d.ts.map +0 -1
- package/dist/internal/signal-ref.js +0 -41
- package/dist/internal/signal-ref.js.map +0 -1
- package/dist/internal/topo-saves.d.ts +0 -53
- package/dist/internal/topo-saves.d.ts.map +0 -1
- package/dist/internal/topo-saves.js +0 -449
- package/dist/internal/topo-saves.js.map +0 -1
- package/dist/internal/topo-snapshots.d.ts +0 -57
- package/dist/internal/topo-snapshots.d.ts.map +0 -1
- package/dist/internal/topo-snapshots.js +0 -372
- package/dist/internal/topo-snapshots.js.map +0 -1
- package/dist/internal/topo-store-read.d.ts +0 -70
- package/dist/internal/topo-store-read.d.ts.map +0 -1
- package/dist/internal/topo-store-read.js +0 -221
- package/dist/internal/topo-store-read.js.map +0 -1
- package/dist/internal/topo-store.d.ts +0 -26
- package/dist/internal/topo-store.d.ts.map +0 -1
- package/dist/internal/topo-store.js +0 -621
- package/dist/internal/topo-store.js.map +0 -1
- package/dist/internal/tracing.d.ts +0 -98
- package/dist/internal/tracing.d.ts.map +0 -1
- package/dist/internal/tracing.js +0 -102
- package/dist/internal/tracing.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/internal/zod-wrappers.d.ts +0 -40
- package/dist/internal/zod-wrappers.d.ts.map +0 -1
- package/dist/internal/zod-wrappers.js +0 -59
- package/dist/internal/zod-wrappers.js.map +0 -1
- package/dist/layer.d.ts +0 -23
- 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/resource-config.d.ts +0 -22
- package/dist/resource-config.d.ts.map +0 -1
- package/dist/resource-config.js +0 -210
- package/dist/resource-config.js.map +0 -1
- package/dist/resource.d.ts +0 -74
- package/dist/resource.d.ts.map +0 -1
- package/dist/resource.js +0 -61
- package/dist/resource.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 -28
- package/dist/run.d.ts.map +0 -1
- package/dist/run.js +0 -35
- 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 -154
- package/dist/serialization.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/store/accessor-protocol.d.ts +0 -51
- package/dist/store/accessor-protocol.d.ts.map +0 -1
- package/dist/store/accessor-protocol.js +0 -2
- package/dist/store/accessor-protocol.js.map +0 -1
- package/dist/store/index.d.ts +0 -2
- package/dist/store/index.d.ts.map +0 -1
- package/dist/store/index.js +0 -2
- package/dist/store/index.js.map +0 -1
- package/dist/surface-filter.d.ts +0 -13
- package/dist/surface-filter.d.ts.map +0 -1
- package/dist/surface-filter.js +0 -76
- package/dist/surface-filter.js.map +0 -1
- package/dist/topo-store.d.ts +0 -62
- package/dist/topo-store.d.ts.map +0 -1
- package/dist/topo-store.js +0 -319
- package/dist/topo-store.js.map +0 -1
- package/dist/topo.d.ts +0 -39
- package/dist/topo.d.ts.map +0 -1
- package/dist/topo.js +0 -241
- package/dist/topo.js.map +0 -1
- package/dist/trail.d.ts +0 -163
- package/dist/trail.d.ts.map +0 -1
- package/dist/trail.js +0 -75
- package/dist/trail.js.map +0 -1
- package/dist/trails/derive-trail.d.ts +0 -66
- package/dist/trails/derive-trail.d.ts.map +0 -1
- package/dist/trails/derive-trail.js +0 -378
- package/dist/trails/derive-trail.js.map +0 -1
- package/dist/trails/index.d.ts +0 -5
- package/dist/trails/index.d.ts.map +0 -1
- package/dist/trails/index.js +0 -3
- package/dist/trails/index.js.map +0 -1
- package/dist/trails/ingest.d.ts +0 -24
- package/dist/trails/ingest.d.ts.map +0 -1
- package/dist/trails/ingest.js +0 -63
- package/dist/trails/ingest.js.map +0 -1
- package/dist/transport-error-map.d.ts +0 -106
- package/dist/transport-error-map.d.ts.map +0 -1
- package/dist/transport-error-map.js +0 -24
- package/dist/transport-error-map.js.map +0 -1
- package/dist/type-checks.test-d.d.ts +0 -71
- package/dist/type-checks.test-d.d.ts.map +0 -1
- package/dist/type-checks.test-d.js +0 -12
- package/dist/type-checks.test-d.js.map +0 -1
- package/dist/type-utils.d.ts +0 -33
- 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 -177
- 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 -193
- 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__/contour.test.ts +0 -263
- package/src/__tests__/derive-trail.test.ts +0 -668
- package/src/__tests__/derive.test.ts +0 -260
- package/src/__tests__/errors.test.ts +0 -427
- package/src/__tests__/execute.test.ts +0 -1563
- package/src/__tests__/fetch.test.ts +0 -217
- package/src/__tests__/fire.test.ts +0 -1056
- package/src/__tests__/fork-ctx.test.ts +0 -83
- package/src/__tests__/guards.test.ts +0 -102
- package/src/__tests__/ingest.test.ts +0 -191
- package/src/__tests__/layer.test.ts +0 -125
- 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__/resource.test.ts +0 -204
- 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 -224
- package/src/__tests__/signal.test.ts +0 -82
- package/src/__tests__/surface-filter.test.ts +0 -196
- package/src/__tests__/topo-store-read.test.ts +0 -256
- package/src/__tests__/topo-store.test.ts +0 -869
- package/src/__tests__/topo.test.ts +0 -573
- package/src/__tests__/trail-permit.test.ts +0 -60
- package/src/__tests__/trail.test.ts +0 -426
- package/src/__tests__/trails-db.test.ts +0 -198
- package/src/__tests__/transport-error-map.test.ts +0 -82
- package/src/__tests__/type-utils.test.ts +0 -118
- package/src/__tests__/validate-topo.test.ts +0 -611
- package/src/__tests__/validation.test.ts +0 -336
- package/src/__tests__/workspace.test.ts +0 -183
- package/src/__tests__/zod-wrappers.test.ts +0 -62
- package/src/internal/topo-snapshots.ts +0 -517
- package/src/internal/topo-store-read.ts +0 -481
- package/src/internal/topo-store.ts +0 -1192
- package/src/internal/tracing.ts +0 -187
- package/src/topo-store.ts +0 -510
- package/src/type-checks.test-d.ts +0 -106
- package/tsconfig.json +0 -9
- package/tsconfig.tests.json +0 -10
- package/tsconfig.tsbuildinfo +0 -1
package/dist/result.js
DELETED
|
@@ -1,156 +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
|
-
// Track the current ancestor chain, not every object ever visited.
|
|
122
|
-
// This allows shared references in a DAG while still detecting cycles.
|
|
123
|
-
const stack = [];
|
|
124
|
-
const keys = [];
|
|
125
|
-
const json = JSON.stringify(value, function json(key, val) {
|
|
126
|
-
if (stack.length > 0) {
|
|
127
|
-
// `this` is the object that contains `key`. Trim the stack back
|
|
128
|
-
// to `this` so we only track the current ancestor path.
|
|
129
|
-
const thisIndex = stack.lastIndexOf(this);
|
|
130
|
-
stack.splice(thisIndex + 1);
|
|
131
|
-
keys.splice(thisIndex);
|
|
132
|
-
}
|
|
133
|
-
if (typeof val === 'object' && val !== null) {
|
|
134
|
-
if (stack.includes(val)) {
|
|
135
|
-
return '[Circular]';
|
|
136
|
-
}
|
|
137
|
-
stack.push(val);
|
|
138
|
-
keys.push(key);
|
|
139
|
-
}
|
|
140
|
-
return val;
|
|
141
|
-
});
|
|
142
|
-
if (json === undefined) {
|
|
143
|
-
return new Err(new InternalError('Value is not JSON-serializable', {
|
|
144
|
-
context: { type: typeof value },
|
|
145
|
-
}));
|
|
146
|
-
}
|
|
147
|
-
return new Ok(json);
|
|
148
|
-
}
|
|
149
|
-
catch (error) {
|
|
150
|
-
return new Err(new InternalError('Failed to stringify value', {
|
|
151
|
-
cause: error instanceof Error ? error : new Error(String(error)),
|
|
152
|
-
}));
|
|
153
|
-
}
|
|
154
|
-
},
|
|
155
|
-
};
|
|
156
|
-
//# 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,OAAO,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;IAED,MAAM,CAAI,GAAoB;QAC5B,OAAO,IAAI,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,KAAK,CAAI,QAAuD;QAC9D,OAAO,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;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,MAAM,CAAC,KAAK,CAAC,CAAC;aACjE,CAAC,CACH,CAAC;QACJ,CAAC;IACH,CAAC;CACO,CAAC"}
|
package/dist/run.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Headless trail execution without mounting a trailhead.
|
|
3
|
-
*
|
|
4
|
-
* Looks up a trail by ID in a topo, then delegates to `executeTrail`.
|
|
5
|
-
* Returns a `Result` and never throws.
|
|
6
|
-
*/
|
|
7
|
-
import type { Topo } from './topo.js';
|
|
8
|
-
import type { ExecuteTrailOptions } from './execute.js';
|
|
9
|
-
import { Result } from './result.js';
|
|
10
|
-
/** Options forwarded to `executeTrail` from `run`. */
|
|
11
|
-
export type RunOptions = ExecuteTrailOptions;
|
|
12
|
-
/**
|
|
13
|
-
* Execute a trail by ID from a topo without mounting a trailhead.
|
|
14
|
-
*
|
|
15
|
-
* Resolves the trail from the topo, then runs it through the standard
|
|
16
|
-
* `executeTrail` pipeline with `topo` threaded so `ctx.fire()` is bound
|
|
17
|
-
* to the producer's context inside `executeTrail`. Returns
|
|
18
|
-
* `Result.err(NotFoundError)` if the trail ID is not registered. Never
|
|
19
|
-
* throws — unexpected exceptions are returned as `Result.err(InternalError)`.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```typescript
|
|
23
|
-
* const result = await run(myTopo, 'greet', { name: 'Alice' });
|
|
24
|
-
* if (result.isOk()) console.log(result.value);
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
export declare const run: (topo: Topo, id: string, input: unknown, options?: RunOptions) => Promise<Result<unknown, Error>>;
|
|
28
|
-
//# sourceMappingURL=run.d.ts.map
|
package/dist/run.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAExD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAMrC,sDAAsD;AACtD,MAAM,MAAM,UAAU,GAAG,mBAAmB,CAAC;AAM7C;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,GAAG,GACd,MAAM,IAAI,EACV,IAAI,MAAM,EACV,OAAO,OAAO,EACd,UAAU,UAAU,KACnB,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAUhC,CAAC"}
|
package/dist/run.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Headless trail execution without mounting a trailhead.
|
|
3
|
-
*
|
|
4
|
-
* Looks up a trail by ID in a topo, then delegates to `executeTrail`.
|
|
5
|
-
* Returns a `Result` and never throws.
|
|
6
|
-
*/
|
|
7
|
-
import { executeTrail } from './execute.js';
|
|
8
|
-
import { NotFoundError } from './errors.js';
|
|
9
|
-
import { Result } from './result.js';
|
|
10
|
-
// ---------------------------------------------------------------------------
|
|
11
|
-
// run()
|
|
12
|
-
// ---------------------------------------------------------------------------
|
|
13
|
-
/**
|
|
14
|
-
* Execute a trail by ID from a topo without mounting a trailhead.
|
|
15
|
-
*
|
|
16
|
-
* Resolves the trail from the topo, then runs it through the standard
|
|
17
|
-
* `executeTrail` pipeline with `topo` threaded so `ctx.fire()` is bound
|
|
18
|
-
* to the producer's context inside `executeTrail`. Returns
|
|
19
|
-
* `Result.err(NotFoundError)` if the trail ID is not registered. Never
|
|
20
|
-
* throws — unexpected exceptions are returned as `Result.err(InternalError)`.
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* ```typescript
|
|
24
|
-
* const result = await run(myTopo, 'greet', { name: 'Alice' });
|
|
25
|
-
* if (result.isOk()) console.log(result.value);
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
export const run = (topo, id, input, options) => {
|
|
29
|
-
const trail = topo.get(id);
|
|
30
|
-
if (trail === undefined) {
|
|
31
|
-
return Promise.resolve(Result.err(new NotFoundError(`Trail "${id}" not found in topo "${topo.name}"`)));
|
|
32
|
-
}
|
|
33
|
-
return executeTrail(trail, input, { ...options, topo });
|
|
34
|
-
};
|
|
35
|
-
//# sourceMappingURL=run.js.map
|
package/dist/run.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AASrC,8EAA8E;AAC9E,QAAQ;AACR,8EAA8E;AAE9E;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,CACjB,IAAU,EACV,EAAU,EACV,KAAc,EACd,OAAoB,EACa,EAAE;IACnC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC3B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,OAAO,CAAC,OAAO,CACpB,MAAM,CAAC,GAAG,CACR,IAAI,aAAa,CAAC,UAAU,EAAE,wBAAwB,IAAI,CAAC,IAAI,GAAG,CAAC,CACpE,CACF,CAAC;IACJ,CAAC;IACD,OAAO,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;AAC1D,CAAC,CAAC"}
|
package/dist/serialization.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
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,EAUf,aAAa,EAKd,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;AAsFD,2DAA2D;AAC3D,eAAO,MAAM,cAAc,GAAI,OAAO,KAAK,KAAG,eAmB7C,CAAC;AAEF,sDAAsD;AACtD,eAAO,MAAM,gBAAgB,GAAI,MAAM,eAAe,KAAG,WAkBxD,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,CAwC9B,CAAC"}
|
package/dist/serialization.js
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
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 { ValidationError, AmbiguousError, AssertionError, NotFoundError, AlreadyExistsError, ConflictError, PermissionError, TimeoutError, RateLimitError, NetworkError, InternalError, DerivationError, AuthError, CancelledError, isTrailsError, } from './errors.js';
|
|
8
|
-
import { Result } from './result.js';
|
|
9
|
-
// ---------------------------------------------------------------------------
|
|
10
|
-
// Internal helpers (defined before usage)
|
|
11
|
-
// ---------------------------------------------------------------------------
|
|
12
|
-
/** Build options object without including undefined context. */
|
|
13
|
-
const buildOpts = (context) => {
|
|
14
|
-
if (context !== undefined) {
|
|
15
|
-
return { context };
|
|
16
|
-
}
|
|
17
|
-
return {};
|
|
18
|
-
};
|
|
19
|
-
const errorFactories = {
|
|
20
|
-
auth: (msg, opts) => new AuthError(msg, opts),
|
|
21
|
-
cancelled: (msg, opts) => new CancelledError(msg, opts),
|
|
22
|
-
conflict: (msg, opts) => new ConflictError(msg, opts),
|
|
23
|
-
internal: (msg, opts) => new InternalError(msg, opts),
|
|
24
|
-
network: (msg, opts) => new NetworkError(msg, opts),
|
|
25
|
-
not_found: (msg, opts) => new NotFoundError(msg, opts),
|
|
26
|
-
permission: (msg, opts) => new PermissionError(msg, opts),
|
|
27
|
-
rate_limit: (msg, opts, retryAfter) => {
|
|
28
|
-
const rlOpts = {
|
|
29
|
-
...opts,
|
|
30
|
-
};
|
|
31
|
-
if (retryAfter !== undefined) {
|
|
32
|
-
rlOpts.retryAfter = retryAfter;
|
|
33
|
-
}
|
|
34
|
-
return new RateLimitError(msg, rlOpts);
|
|
35
|
-
},
|
|
36
|
-
timeout: (msg, opts) => new TimeoutError(msg, opts),
|
|
37
|
-
validation: (msg, opts) => new ValidationError(msg, opts),
|
|
38
|
-
};
|
|
39
|
-
const createErrorByCategory = (category, message, context, retryAfter) => {
|
|
40
|
-
const opts = buildOpts(context);
|
|
41
|
-
const factory = errorFactories[category] ?? errorFactories.internal;
|
|
42
|
-
return factory(message, opts, retryAfter);
|
|
43
|
-
};
|
|
44
|
-
/** Map error class names to their constructors for precise round-tripping. */
|
|
45
|
-
const errorConstructorsByName = {
|
|
46
|
-
AlreadyExistsError: (msg, opts) => new AlreadyExistsError(msg, opts),
|
|
47
|
-
AmbiguousError: (msg, opts) => new AmbiguousError(msg, opts),
|
|
48
|
-
AssertionError: (msg, opts) => new AssertionError(msg, opts),
|
|
49
|
-
AuthError: (msg, opts) => new AuthError(msg, opts),
|
|
50
|
-
CancelledError: (msg, opts) => new CancelledError(msg, opts),
|
|
51
|
-
ConflictError: (msg, opts) => new ConflictError(msg, opts),
|
|
52
|
-
DerivationError: (msg, opts) => new DerivationError(msg, opts),
|
|
53
|
-
InternalError: (msg, opts) => new InternalError(msg, opts),
|
|
54
|
-
NetworkError: (msg, opts) => new NetworkError(msg, opts),
|
|
55
|
-
NotFoundError: (msg, opts) => new NotFoundError(msg, opts),
|
|
56
|
-
PermissionError: (msg, opts) => new PermissionError(msg, opts),
|
|
57
|
-
RateLimitError: (msg, opts, retryAfter) => {
|
|
58
|
-
const rlOpts = {
|
|
59
|
-
...opts,
|
|
60
|
-
};
|
|
61
|
-
if (retryAfter !== undefined) {
|
|
62
|
-
rlOpts.retryAfter = retryAfter;
|
|
63
|
-
}
|
|
64
|
-
return new RateLimitError(msg, rlOpts);
|
|
65
|
-
},
|
|
66
|
-
TimeoutError: (msg, opts) => new TimeoutError(msg, opts),
|
|
67
|
-
ValidationError: (msg, opts) => new ValidationError(msg, opts),
|
|
68
|
-
};
|
|
69
|
-
// ---------------------------------------------------------------------------
|
|
70
|
-
// Error serialization
|
|
71
|
-
// ---------------------------------------------------------------------------
|
|
72
|
-
/** Extract structured data from an Error for transport. */
|
|
73
|
-
export const serializeError = (error) => {
|
|
74
|
-
const result = {
|
|
75
|
-
message: error.message,
|
|
76
|
-
name: error.name,
|
|
77
|
-
stack: error.stack,
|
|
78
|
-
};
|
|
79
|
-
if (isTrailsError(error)) {
|
|
80
|
-
return {
|
|
81
|
-
...result,
|
|
82
|
-
category: error.category,
|
|
83
|
-
context: error.context,
|
|
84
|
-
retryAfter: error instanceof RateLimitError ? error.retryAfter : undefined,
|
|
85
|
-
retryable: error.retryable,
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
return result;
|
|
89
|
-
};
|
|
90
|
-
/** Reconstruct a TrailsError from serialized data. */
|
|
91
|
-
export const deserializeError = (data) => {
|
|
92
|
-
const opts = buildOpts(data.context);
|
|
93
|
-
const nameFactory = errorConstructorsByName[data.name];
|
|
94
|
-
const error = nameFactory
|
|
95
|
-
? nameFactory(data.message, opts, data.retryAfter)
|
|
96
|
-
: createErrorByCategory(data.category ?? 'internal', data.message, data.context, data.retryAfter);
|
|
97
|
-
if (data.stack) {
|
|
98
|
-
error.stack = data.stack;
|
|
99
|
-
}
|
|
100
|
-
return error;
|
|
101
|
-
};
|
|
102
|
-
// ---------------------------------------------------------------------------
|
|
103
|
-
// Safe JSON
|
|
104
|
-
// ---------------------------------------------------------------------------
|
|
105
|
-
/** Parse a JSON string, returning a Result instead of throwing. */
|
|
106
|
-
export const safeParse = (json) => {
|
|
107
|
-
try {
|
|
108
|
-
return Result.ok(JSON.parse(json));
|
|
109
|
-
}
|
|
110
|
-
catch (error) {
|
|
111
|
-
return Result.err(new ValidationError('Invalid JSON', {
|
|
112
|
-
cause: error instanceof Error ? error : new Error(String(error)),
|
|
113
|
-
context: { input: json.slice(0, 200) },
|
|
114
|
-
}));
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
/** Stringify a value, returning a Result. Handles circular references. */
|
|
118
|
-
export const safeStringify = (value) => {
|
|
119
|
-
try {
|
|
120
|
-
// Track the current ancestor chain, not every object ever visited.
|
|
121
|
-
// This allows shared references in a DAG while still detecting cycles.
|
|
122
|
-
const stack = [];
|
|
123
|
-
const keys = [];
|
|
124
|
-
const json = JSON.stringify(value, function json(key, val) {
|
|
125
|
-
if (stack.length > 0) {
|
|
126
|
-
// `this` is the object that contains `key`. Trim the stack back
|
|
127
|
-
// to `this` so we only track the current ancestor path.
|
|
128
|
-
const thisIndex = stack.lastIndexOf(this);
|
|
129
|
-
stack.splice(thisIndex + 1);
|
|
130
|
-
keys.splice(thisIndex);
|
|
131
|
-
}
|
|
132
|
-
if (typeof val === 'object' && val !== null) {
|
|
133
|
-
if (stack.includes(val)) {
|
|
134
|
-
return '[Circular]';
|
|
135
|
-
}
|
|
136
|
-
stack.push(val);
|
|
137
|
-
keys.push(key);
|
|
138
|
-
}
|
|
139
|
-
return val;
|
|
140
|
-
});
|
|
141
|
-
if (json === undefined) {
|
|
142
|
-
return Result.err(new InternalError('Value is not JSON-serializable', {
|
|
143
|
-
context: { type: typeof value },
|
|
144
|
-
}));
|
|
145
|
-
}
|
|
146
|
-
return Result.ok(json);
|
|
147
|
-
}
|
|
148
|
-
catch (error) {
|
|
149
|
-
return Result.err(new InternalError('Failed to stringify value', {
|
|
150
|
-
cause: error instanceof Error ? error : new Error(String(error)),
|
|
151
|
-
}));
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
//# sourceMappingURL=serialization.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.js","sourceRoot":"","sources":["../src/serialization.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,eAAe,EACf,cAAc,EACd,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,aAAa,EACb,eAAe,EACf,SAAS,EACT,cAAc,EACd,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAgBrC,8EAA8E;AAC9E,0CAA0C;AAC1C,8EAA8E;AAE9E,gEAAgE;AAChE,MAAM,SAAS,GAAG,CAChB,OAA4C,EAG5C,EAAE;IACF,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,EAAE,OAAO,EAAE,CAAC;IACrB,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAQF,MAAM,cAAc,GAAwC;IAC1D,IAAI,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC;IAC7C,SAAS,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,cAAc,CAAC,GAAG,EAAE,IAAI,CAAC;IACvD,QAAQ,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC;IACrD,QAAQ,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,aAAa,CAA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0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Signal — a named payload schema with optional provenance meta.
|
|
3
|
-
*/
|
|
4
|
-
import type { z } from 'zod';
|
|
5
|
-
export interface SignalSpec<T> {
|
|
6
|
-
readonly payload: z.ZodType<T>;
|
|
7
|
-
readonly description?: string | undefined;
|
|
8
|
-
readonly meta?: Readonly<Record<string, unknown>> | undefined;
|
|
9
|
-
/** Trail IDs that produce this signal (e.g. the trails it originates from). */
|
|
10
|
-
readonly from?: readonly string[] | undefined;
|
|
11
|
-
}
|
|
12
|
-
export interface Signal<T> {
|
|
13
|
-
readonly id: string;
|
|
14
|
-
readonly kind: 'signal';
|
|
15
|
-
readonly payload: z.ZodType<T>;
|
|
16
|
-
readonly description?: string | undefined;
|
|
17
|
-
readonly meta?: Readonly<Record<string, unknown>> | undefined;
|
|
18
|
-
/** Trail IDs that produce this signal (e.g. the trails it originates from). */
|
|
19
|
-
readonly from?: readonly string[] | undefined;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Create a signal definition.
|
|
23
|
-
*
|
|
24
|
-
* A signal is a named payload schema describing something that happened.
|
|
25
|
-
* Returns a frozen object with `kind: "signal"` and all spec fields.
|
|
26
|
-
*/
|
|
27
|
-
export declare function signal<T>(id: string, spec: SignalSpec<T>): Signal<T>;
|
|
28
|
-
export declare function signal<T>(spec: SignalSpec<T> & {
|
|
29
|
-
readonly id: string;
|
|
30
|
-
}): Signal<T>;
|
|
31
|
-
/** Existential type for heterogeneous signal collections */
|
|
32
|
-
export type AnySignal = Signal<unknown>;
|
|
33
|
-
//# sourceMappingURL=signal.d.ts.map
|
package/dist/signal.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signal.d.ts","sourceRoot":"","sources":["../src/signal.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAM7B,MAAM,WAAW,UAAU,CAAC,CAA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ETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Signal — a named payload schema with optional provenance meta.
|
|
3
|
-
*/
|
|
4
|
-
export function signal(idOrSpec, maybeSpec) {
|
|
5
|
-
const resolvedId = typeof idOrSpec === 'string' ? idOrSpec : idOrSpec.id;
|
|
6
|
-
// oxlint-disable-next-line no-non-null-assertion -- overload guarantees maybeSpec when idOrSpec is string
|
|
7
|
-
const resolvedSpec = typeof idOrSpec === 'string' ? maybeSpec : idOrSpec;
|
|
8
|
-
return Object.freeze({
|
|
9
|
-
description: resolvedSpec.description,
|
|
10
|
-
from: resolvedSpec.from ? Object.freeze([...resolvedSpec.from]) : undefined,
|
|
11
|
-
id: resolvedId,
|
|
12
|
-
kind: 'signal',
|
|
13
|
-
meta: resolvedSpec.meta,
|
|
14
|
-
payload: resolvedSpec.payload,
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=signal.js.map
|
package/dist/signal.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signal.js","sourceRoot":"","sources":["../src/signal.ts"],"names":[],"mappings":"AAAA;;GAEG;AA4CH,MAAM,UAAU,MAAM,CACpB,QAA4D,EAC5D,SAAyB;IAEzB,MAAM,UAAU,GAAG,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;IACzE,0GAA0G;IAC1G,MAAM,YAAY,GAAG,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAU,CAAC,CAAC,CAAC,QAAQ,CAAC;IAC1E,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,WAAW,EAAE,YAAY,CAAC,WAAW;QACrC,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;QAC3E,EAAE,EAAE,UAAU;QACd,IAAI,EAAE,QAAiB;QACvB,IAAI,EAAE,YAAY,CAAC,IAAI;QACvB,OAAO,EAAE,YAAY,CAAC,OAAO;KAC9B,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Structural accessor protocol used by `deriveTrail()` to synthesize default
|
|
3
|
-
* blazes for standard CRUD operations without depending on `@ontrails/store`.
|
|
4
|
-
*
|
|
5
|
-
* @remarks
|
|
6
|
-
* This type is intentionally minimal and structural. `@ontrails/store`'s
|
|
7
|
-
* `StoreAccessor` / `StoreTableAccessor` interfaces satisfy this protocol
|
|
8
|
-
* through a compile-time extends check (see `packages/store/src/types.ts`).
|
|
9
|
-
* Keeping the protocol in core avoids a core → store dependency while still
|
|
10
|
-
* allowing the derivation helper to call accessors by convention.
|
|
11
|
-
*
|
|
12
|
-
* Required methods (`get`, `list`, `upsert`, `remove`) match the
|
|
13
|
-
* connector-agnostic write contract every bound store must expose. Optional
|
|
14
|
-
* methods (`insert`, `update`) are declared by tabular connectors that
|
|
15
|
-
* distinguish create-only and patch-only operations from the generalized
|
|
16
|
-
* `upsert` contract.
|
|
17
|
-
*/
|
|
18
|
-
export interface StoreAccessorProtocol<TInput, TEntity, TId, TFilters = unknown> {
|
|
19
|
-
/** Retrieve a single entity by identity. Returns `null` when not found. */
|
|
20
|
-
get(id: TId): Promise<TEntity | null>;
|
|
21
|
-
/** List entities, optionally filtered. Returns `[]` when no rows match. */
|
|
22
|
-
list(filters?: TFilters): Promise<readonly TEntity[]>;
|
|
23
|
-
/** Create-or-replace one entity using the connector-agnostic contract. */
|
|
24
|
-
upsert(input: TInput): Promise<TEntity>;
|
|
25
|
-
/**
|
|
26
|
-
* Remove an entity by identity. Returns `{ deleted: true }` when the row
|
|
27
|
-
* was found and removed, `{ deleted: false }` when no matching row
|
|
28
|
-
* existed (not an error).
|
|
29
|
-
*/
|
|
30
|
-
remove(id: TId): Promise<{
|
|
31
|
-
readonly deleted: boolean;
|
|
32
|
-
}>;
|
|
33
|
-
/**
|
|
34
|
-
* Optional insert — available on tabular connectors that distinguish
|
|
35
|
-
* create from update. When absent, synthesized blazes fall back to
|
|
36
|
-
* `upsert`.
|
|
37
|
-
*/
|
|
38
|
-
insert?(input: TInput): Promise<TEntity>;
|
|
39
|
-
/**
|
|
40
|
-
* Optional patch-by-identity — available on tabular connectors. Returns
|
|
41
|
-
* `null` when no row with the given identity exists. When absent,
|
|
42
|
-
* synthesized update blazes fall back to `get` + merge + `upsert`.
|
|
43
|
-
*/
|
|
44
|
-
update?(id: TId, patch: Partial<TInput>): Promise<TEntity | null>;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Record shape returned by a resource's `from(ctx)` call, keyed by accessor
|
|
48
|
-
* name. Used by `deriveTrail()` to resolve an accessor by contour name.
|
|
49
|
-
*/
|
|
50
|
-
export type StoreAccessorRecord = Readonly<Record<string, StoreAccessorProtocol<unknown, unknown, unknown, unknown>>>;
|
|
51
|
-
//# sourceMappingURL=accessor-protocol.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"accessor-protocol.d.ts","sourceRoot":"","sources":["../../src/store/accessor-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,qBAAqB,CACpC,MAAM,EACN,OAAO,EACP,GAAG,EACH,QAAQ,GAAG,OAAO;IAElB,2EAA2E;IAC3E,GAAG,CAAC,EAAE,EAAE,GAAG,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IACtC,2EAA2E;IAC3E,IAAI,CAAC,OAAO,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,OAAO,EAAE,CAAC,CAAC;IACtD,0EAA0E;IAC1E,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACxC;;;;OAIG;IACH,MAAM,CAAC,EAAE,EAAE,GAAG,GAAG,OAAO,CAAC;QAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACxD;;;;OAIG;IACH,MAAM,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACzC;;;;OAIG;IACH,MAAM,CAAC,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;CACnE;AAED;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CACxC,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAC1E,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"accessor-protocol.js","sourceRoot":"","sources":["../../src/store/accessor-protocol.ts"],"names":[],"mappings":""}
|
package/dist/store/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,wBAAwB,CAAC"}
|
package/dist/store/index.js
DELETED
package/dist/store/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":""}
|
package/dist/surface-filter.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Intent, Trail } from './trail.js';
|
|
2
|
-
export interface SurfaceFilterOptions {
|
|
3
|
-
/** Glob patterns that keep only matching trail IDs when provided. */
|
|
4
|
-
readonly include?: readonly string[] | undefined;
|
|
5
|
-
/** Glob patterns that remove matching trail IDs. */
|
|
6
|
-
readonly exclude?: readonly string[] | undefined;
|
|
7
|
-
/** Allowed intents for exposed trailheads. Empty arrays act as no filter. */
|
|
8
|
-
readonly intent?: readonly Intent[] | undefined;
|
|
9
|
-
}
|
|
10
|
-
export declare const matchesTrailPattern: (trailId: string, pattern: string) => boolean;
|
|
11
|
-
export declare const shouldIncludeTrailForSurface: (trail: Trail<unknown, unknown, unknown>, options?: SurfaceFilterOptions) => boolean;
|
|
12
|
-
export declare const filterSurfaceTrails: (trails: readonly Trail<unknown, unknown, unknown>[], options?: SurfaceFilterOptions) => Trail<unknown, unknown, unknown>[];
|
|
13
|
-
//# sourceMappingURL=surface-filter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"surface-filter.d.ts","sourceRoot":"","sources":["../src/surface-filter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAMhD,MAAM,WAAW,oBAAoB;IACnC,qEAAqE;IACrE,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IACjD,oDAAoD;IACpD,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IACjD,6EAA6E;IAC7E,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;CACjD;AAuED,eAAO,MAAM,mBAAmB,GAC9B,SAAS,MAAM,EACf,SAAS,MAAM,KACd,OAKF,CAAC;AA+DF,eAAO,MAAM,4BAA4B,GACvC,OAAO,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EACvC,UAAS,oBAAyB,KACjC,OAiBF,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,QAAQ,SAAS,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,EACnD,UAAS,oBAAyB,KACjC,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EACqC,CAAC"}
|