@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/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Result
|
|
2
|
-
export { Result } from './result.js';
|
|
2
|
+
export { Result, resultAccessorNames } from './result.js';
|
|
3
|
+
export type { ResultAccessorName } from './result.js';
|
|
3
4
|
|
|
4
5
|
// Errors
|
|
5
6
|
export {
|
|
@@ -11,6 +12,7 @@ export {
|
|
|
11
12
|
AlreadyExistsError,
|
|
12
13
|
ConflictError,
|
|
13
14
|
PermissionError,
|
|
15
|
+
PermitError,
|
|
14
16
|
TimeoutError,
|
|
15
17
|
RateLimitError,
|
|
16
18
|
NetworkError,
|
|
@@ -18,6 +20,9 @@ export {
|
|
|
18
20
|
AuthError,
|
|
19
21
|
CancelledError,
|
|
20
22
|
DerivationError,
|
|
23
|
+
RecoverableCompletionError,
|
|
24
|
+
codesByCategory,
|
|
25
|
+
errorClasses,
|
|
21
26
|
errorCategories,
|
|
22
27
|
exitCodeMap,
|
|
23
28
|
statusCodeMap,
|
|
@@ -27,20 +32,40 @@ export {
|
|
|
27
32
|
isRetryable,
|
|
28
33
|
isTrailsError,
|
|
29
34
|
} from './errors.js';
|
|
30
|
-
export type {
|
|
35
|
+
export type {
|
|
36
|
+
DynamicErrorClassRegistryEntry,
|
|
37
|
+
ErrorCategory,
|
|
38
|
+
ErrorCategoryCodes,
|
|
39
|
+
ErrorClassConstructor,
|
|
40
|
+
ErrorClassRegistryEntry,
|
|
41
|
+
FixedErrorClassRegistryEntry,
|
|
42
|
+
} from './errors.js';
|
|
31
43
|
export {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
44
|
+
createSurfaceErrorMapper,
|
|
45
|
+
mapSurfaceError,
|
|
46
|
+
projectErrorClassSurface,
|
|
47
|
+
projectPublicSurfaceError,
|
|
48
|
+
projectSurfaceError,
|
|
49
|
+
surfaceErrorMap,
|
|
50
|
+
surfaceErrorRegistry,
|
|
51
|
+
surfaceNames,
|
|
37
52
|
} from './transport-error-map.js';
|
|
38
53
|
export type {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
54
|
+
ErrorClassSurfaceProjection,
|
|
55
|
+
SurfaceErrorCode,
|
|
56
|
+
SurfaceErrorMapper,
|
|
57
|
+
SurfaceErrorMappings,
|
|
58
|
+
SurfaceErrorProjection,
|
|
59
|
+
SurfaceName,
|
|
43
60
|
} from './transport-error-map.js';
|
|
61
|
+
export {
|
|
62
|
+
INTERNAL_ERROR_PUBLIC_MESSAGE,
|
|
63
|
+
projectErrorDiagnostics,
|
|
64
|
+
redactErrorContext,
|
|
65
|
+
redactErrorStack,
|
|
66
|
+
redactErrorString,
|
|
67
|
+
} from './error-projection.js';
|
|
68
|
+
export type { ErrorDiagnosticsProjection } from './error-projection.js';
|
|
44
69
|
|
|
45
70
|
// Types
|
|
46
71
|
export type {
|
|
@@ -52,14 +77,34 @@ export type {
|
|
|
52
77
|
CrossBatchOptions,
|
|
53
78
|
CrossFn,
|
|
54
79
|
FireFn,
|
|
55
|
-
|
|
80
|
+
LogLevel,
|
|
81
|
+
LogFormatter,
|
|
82
|
+
LogRecord,
|
|
83
|
+
LogSink,
|
|
56
84
|
PermitRequirement,
|
|
57
85
|
ProgressCallback,
|
|
58
86
|
ProgressEvent,
|
|
59
87
|
Logger,
|
|
60
88
|
ResourceLookup,
|
|
61
89
|
} from './types.js';
|
|
62
|
-
export {
|
|
90
|
+
export { basePermitSchema } from './permits.js';
|
|
91
|
+
export type { BasePermit } from './permits.js';
|
|
92
|
+
export {
|
|
93
|
+
LAYER_INPUTS_KEY,
|
|
94
|
+
SURFACE_KEY,
|
|
95
|
+
SURFACE_LAYER_NAMES_KEY,
|
|
96
|
+
} from './types.js';
|
|
97
|
+
export {
|
|
98
|
+
ACTIVATION_PROVENANCE_KEY,
|
|
99
|
+
buildActivationProvenanceTraceAttrs,
|
|
100
|
+
getActivationProvenance,
|
|
101
|
+
withActivationProvenance,
|
|
102
|
+
} from './activation-provenance.js';
|
|
103
|
+
export type {
|
|
104
|
+
ActivationProvenance,
|
|
105
|
+
ActivationProvenanceCarrier,
|
|
106
|
+
ActivationProvenanceSource,
|
|
107
|
+
} from './activation-provenance.js';
|
|
63
108
|
|
|
64
109
|
// Context factory
|
|
65
110
|
export { createTrailContext, passthroughTrace } from './context.js';
|
|
@@ -71,16 +116,48 @@ export {
|
|
|
71
116
|
isResource,
|
|
72
117
|
resource,
|
|
73
118
|
} from './resource.js';
|
|
119
|
+
export { drainResources, resolveResourceConfig } from './resource-config.js';
|
|
120
|
+
export type {
|
|
121
|
+
ResourceConfigValues,
|
|
122
|
+
ResourceDrainReport,
|
|
123
|
+
} from './resource-config.js';
|
|
74
124
|
export type {
|
|
75
125
|
AnyResource,
|
|
76
126
|
Resource,
|
|
77
127
|
ResourceContext,
|
|
78
128
|
ResourceOverrideMap,
|
|
79
129
|
ResourceSpec,
|
|
130
|
+
ResourceUnmockable,
|
|
80
131
|
} from './resource.js';
|
|
81
132
|
|
|
82
133
|
// Trail
|
|
83
|
-
export {
|
|
134
|
+
export {
|
|
135
|
+
activationSourceKinds,
|
|
136
|
+
getActivationWherePredicate,
|
|
137
|
+
isActivationEntrySpec,
|
|
138
|
+
isActivationSource,
|
|
139
|
+
isKnownActivationSourceKind,
|
|
140
|
+
} from './activation-source.js';
|
|
141
|
+
export type {
|
|
142
|
+
ActivationEntry,
|
|
143
|
+
ActivationEntrySpec,
|
|
144
|
+
ActivationSource,
|
|
145
|
+
ActivationSourceKind,
|
|
146
|
+
ActivationSourceMeta,
|
|
147
|
+
ActivationSourceRef,
|
|
148
|
+
ActivationWhere,
|
|
149
|
+
ActivationWhereExample,
|
|
150
|
+
ActivationWherePredicate,
|
|
151
|
+
ActivationWhereSpec,
|
|
152
|
+
BuiltinActivationSourceKind,
|
|
153
|
+
} from './activation-source.js';
|
|
154
|
+
export {
|
|
155
|
+
activationSourceDeclarationSignature,
|
|
156
|
+
activationSourceKey,
|
|
157
|
+
projectActivationSourceDeclaration,
|
|
158
|
+
} from './activation-source-projection.js';
|
|
159
|
+
export type { ActivationSourceProjection } from './activation-source-projection.js';
|
|
160
|
+
export { intentValues, trail } from './trail.js';
|
|
84
161
|
export type {
|
|
85
162
|
AnyTrail,
|
|
86
163
|
BlazeInput,
|
|
@@ -88,6 +165,7 @@ export type {
|
|
|
88
165
|
Trail,
|
|
89
166
|
TrailSpec,
|
|
90
167
|
TrailExample,
|
|
168
|
+
TrailExampleSignalAssertion,
|
|
91
169
|
TrailVisibility,
|
|
92
170
|
} from './trail.js';
|
|
93
171
|
export {
|
|
@@ -96,6 +174,31 @@ export {
|
|
|
96
174
|
shouldIncludeTrailForSurface,
|
|
97
175
|
} from './surface-filter.js';
|
|
98
176
|
export type { SurfaceFilterOptions } from './surface-filter.js';
|
|
177
|
+
export {
|
|
178
|
+
shouldValidateSurfaceTopo,
|
|
179
|
+
validateSurfaceTopo,
|
|
180
|
+
withSurfaceLayerNames,
|
|
181
|
+
withSurfaceMarker,
|
|
182
|
+
} from './surface-derivation.js';
|
|
183
|
+
export type {
|
|
184
|
+
BaseSurfaceOptions,
|
|
185
|
+
SurfaceConfigValues,
|
|
186
|
+
SurfaceSelectionOptions,
|
|
187
|
+
SurfaceMarkedContext,
|
|
188
|
+
SurfaceValidationOptions,
|
|
189
|
+
} from './surface-derivation.js';
|
|
190
|
+
export {
|
|
191
|
+
deriveStructuredSignalExamples,
|
|
192
|
+
deriveStructuredTrailExamples,
|
|
193
|
+
} from './structured-examples.js';
|
|
194
|
+
export type {
|
|
195
|
+
StructuredSignalExample,
|
|
196
|
+
StructuredSignalExampleProvenance,
|
|
197
|
+
StructuredTrailExample,
|
|
198
|
+
StructuredTrailExampleKind,
|
|
199
|
+
StructuredTrailExampleProvenance,
|
|
200
|
+
StructuredTrailExampleSignalAssertion,
|
|
201
|
+
} from './structured-examples.js';
|
|
99
202
|
|
|
100
203
|
// Type utilities
|
|
101
204
|
export type {
|
|
@@ -109,6 +212,100 @@ export { inputOf, outputOf } from './type-utils.js';
|
|
|
109
212
|
// Signal
|
|
110
213
|
export { signal } from './signal.js';
|
|
111
214
|
export type { AnySignal, Signal, SignalSpec } from './signal.js';
|
|
215
|
+
export { schedule, validateScheduleSource } from './schedule.js';
|
|
216
|
+
export type {
|
|
217
|
+
ScheduleSource,
|
|
218
|
+
ScheduleSpec,
|
|
219
|
+
ScheduleValidationIssue,
|
|
220
|
+
} from './schedule.js';
|
|
221
|
+
export {
|
|
222
|
+
getWebhookHeader,
|
|
223
|
+
getWebhookHeaders,
|
|
224
|
+
validateWebhookSource,
|
|
225
|
+
verifyWebhookRequest,
|
|
226
|
+
webhook,
|
|
227
|
+
webhookMethods,
|
|
228
|
+
} from './webhook.js';
|
|
229
|
+
export type {
|
|
230
|
+
WebhookMethod,
|
|
231
|
+
WebhookMethodInput,
|
|
232
|
+
WebhookSource,
|
|
233
|
+
WebhookSpec,
|
|
234
|
+
WebhookValidationIssue,
|
|
235
|
+
WebhookVerify,
|
|
236
|
+
WebhookVerifyHeaders,
|
|
237
|
+
WebhookVerifyRequest,
|
|
238
|
+
} from './webhook.js';
|
|
239
|
+
export { createScheduleRuntime } from './schedule-runtime.js';
|
|
240
|
+
export type {
|
|
241
|
+
ScheduleCronFactory,
|
|
242
|
+
ScheduleCronHandler,
|
|
243
|
+
ScheduleCronJob,
|
|
244
|
+
ScheduleRuntime,
|
|
245
|
+
ScheduleRuntimeLogger,
|
|
246
|
+
ScheduleRuntimeOptions,
|
|
247
|
+
ScheduleRuntimeRegistrationReport,
|
|
248
|
+
ScheduleRuntimeRunRecord,
|
|
249
|
+
ScheduleRuntimeRunStatus,
|
|
250
|
+
ScheduleRuntimeSkipReason,
|
|
251
|
+
ScheduleRuntimeStartReport,
|
|
252
|
+
ScheduleRuntimeState,
|
|
253
|
+
ScheduleRuntimeStopReport,
|
|
254
|
+
ScheduleRuntimeWarning,
|
|
255
|
+
ScheduleRuntimeWarningCode,
|
|
256
|
+
} from './schedule-runtime.js';
|
|
257
|
+
export {
|
|
258
|
+
SIGNAL_DIAGNOSTICS_SINK_KEY,
|
|
259
|
+
SIGNAL_DIAGNOSTICS_STRICT_MODE_KEY,
|
|
260
|
+
createSignalFireSuppressedDiagnostic,
|
|
261
|
+
createSignalHandlerFailedDiagnostic,
|
|
262
|
+
createSignalHandlerRejectedDiagnostic,
|
|
263
|
+
createSignalInvalidDiagnostic,
|
|
264
|
+
createSignalPredicateFailedDiagnostic,
|
|
265
|
+
createSignalUnknownDiagnostic,
|
|
266
|
+
recordSignalDiagnostic,
|
|
267
|
+
shouldPromoteSignalDiagnostic,
|
|
268
|
+
signalDiagnosticDefinitions,
|
|
269
|
+
summarizeSignalPayload,
|
|
270
|
+
} from './signal-diagnostics.js';
|
|
271
|
+
export type {
|
|
272
|
+
CreateSignalFireSuppressedDiagnosticInput,
|
|
273
|
+
CreateSignalHandlerDiagnosticInput,
|
|
274
|
+
CreateSignalInvalidDiagnosticInput,
|
|
275
|
+
SignalDiagnostic,
|
|
276
|
+
SignalDiagnosticCategory,
|
|
277
|
+
SignalDiagnosticCause,
|
|
278
|
+
SignalDiagnosticCode,
|
|
279
|
+
SignalDiagnosticCommonInput,
|
|
280
|
+
SignalDiagnosticContext,
|
|
281
|
+
SignalDiagnosticLevel,
|
|
282
|
+
SignalDiagnosticPathSegment,
|
|
283
|
+
SignalDiagnosticRecordResult,
|
|
284
|
+
SignalDiagnosticSchemaIssue,
|
|
285
|
+
SignalDiagnosticSink,
|
|
286
|
+
SignalDiagnosticOrigin,
|
|
287
|
+
SignalDiagnosticSourceLocation,
|
|
288
|
+
SignalDiagnosticStrictMode,
|
|
289
|
+
SignalFireSuppressedDiagnostic,
|
|
290
|
+
SignalHandlerFailedDiagnostic,
|
|
291
|
+
SignalHandlerRejectedDiagnostic,
|
|
292
|
+
SignalInvalidDiagnostic,
|
|
293
|
+
SignalPredicateFailedDiagnostic,
|
|
294
|
+
SignalPayloadShape,
|
|
295
|
+
SignalPayloadSummary,
|
|
296
|
+
SignalUnknownDiagnostic,
|
|
297
|
+
} from './signal-diagnostics.js';
|
|
298
|
+
export {
|
|
299
|
+
attachLateBoundSignalRef,
|
|
300
|
+
cloneSignalWithId,
|
|
301
|
+
createLateBoundSignalMarker,
|
|
302
|
+
getLateBoundSignalRef,
|
|
303
|
+
parseLateBoundSignalMarker,
|
|
304
|
+
} from './signal-ref.js';
|
|
305
|
+
export type {
|
|
306
|
+
LateBoundSignalMarker,
|
|
307
|
+
LateBoundSignalRef,
|
|
308
|
+
} from './signal-ref.js';
|
|
112
309
|
|
|
113
310
|
// Contour
|
|
114
311
|
export { contour } from './contour.js';
|
|
@@ -131,27 +328,24 @@ export type {
|
|
|
131
328
|
// Topo
|
|
132
329
|
export { topo } from './topo.js';
|
|
133
330
|
export type { Topo, TopoIdentity } from './topo.js';
|
|
331
|
+
|
|
332
|
+
// Generic trails-db helpers (shared framework infrastructure per ADR-0014).
|
|
333
|
+
// The topo-store public API that previously lived here moved to
|
|
334
|
+
// `@ontrails/topographer` per ADR-0042.
|
|
134
335
|
export {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
336
|
+
deriveTrailsDbPath,
|
|
337
|
+
deriveTrailsDir,
|
|
338
|
+
ensureSubsystemSchema,
|
|
339
|
+
ensureTrailsWorkspace,
|
|
340
|
+
openReadTrailsDb,
|
|
341
|
+
openWriteTrailsDb,
|
|
342
|
+
WORKSPACE_GITIGNORE_CONTENT,
|
|
343
|
+
WORKSPACE_GITIGNORE_LINES,
|
|
344
|
+
} from './trails-db.js';
|
|
143
345
|
export type {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
ReadOnlyTopoStore,
|
|
148
|
-
TopoSnapshot,
|
|
149
|
-
TopoStoreExportRecord,
|
|
150
|
-
TopoStoreResourceRecord,
|
|
151
|
-
TopoStoreRef,
|
|
152
|
-
TopoStoreTrailDetailRecord,
|
|
153
|
-
TopoStoreTrailRecord,
|
|
154
|
-
} from './topo-store.js';
|
|
346
|
+
EnsureSubsystemSchemaOptions,
|
|
347
|
+
TrailsDbLocationOptions,
|
|
348
|
+
} from './trails-db.js';
|
|
155
349
|
|
|
156
350
|
// Draft state
|
|
157
351
|
export {
|
|
@@ -174,7 +368,21 @@ export { validateEstablishedTopo } from './validate-established-topo.js';
|
|
|
174
368
|
|
|
175
369
|
// Layer
|
|
176
370
|
export { composeLayers } from './layer.js';
|
|
177
|
-
export type { Layer } from './layer.js';
|
|
371
|
+
export type { Layer, LayerInputSchema } from './layer.js';
|
|
372
|
+
export {
|
|
373
|
+
collectAttachedTypedLayers,
|
|
374
|
+
LAYER_FIELD_RESERVED_NAMES,
|
|
375
|
+
LAYER_FIELD_RESERVED_NAMES_KEBAB,
|
|
376
|
+
projectLayerFieldName,
|
|
377
|
+
} from './layer-projection.js';
|
|
378
|
+
export type {
|
|
379
|
+
AttachedLayerScope,
|
|
380
|
+
AttachedTypedLayer,
|
|
381
|
+
LayerFieldProjection,
|
|
382
|
+
LayerFieldRenameReason,
|
|
383
|
+
ProjectedLayerField,
|
|
384
|
+
RenamedLayerFieldProjection,
|
|
385
|
+
} from './layer-projection.js';
|
|
178
386
|
|
|
179
387
|
// Derive
|
|
180
388
|
export { deriveCliPath, deriveFields } from './derive.js';
|
|
@@ -182,28 +390,55 @@ export type { Field, FieldOverride } from './derive.js';
|
|
|
182
390
|
|
|
183
391
|
// Cross schema
|
|
184
392
|
export { buildCrossValidationSchema } from './cross-schema.js';
|
|
393
|
+
export {
|
|
394
|
+
claimNextCrossBatchIndex,
|
|
395
|
+
createCrossBatchValidationResults,
|
|
396
|
+
normalizeCrossBatchConcurrency,
|
|
397
|
+
} from './cross-batch.js';
|
|
185
398
|
|
|
186
399
|
// Execute
|
|
400
|
+
export { DETOUR_MAX_ATTEMPTS_CAP } from './detours.js';
|
|
187
401
|
export { executeTrail } from './execute.js';
|
|
188
402
|
export type { ExecuteTrailOptions } from './execute.js';
|
|
189
403
|
|
|
190
404
|
// Intrinsic tracing
|
|
191
405
|
export {
|
|
192
406
|
clearTraceSink,
|
|
407
|
+
createActivationTraceRecord,
|
|
193
408
|
createTraceRecord,
|
|
194
409
|
getTraceContext,
|
|
195
410
|
getTraceSink,
|
|
196
411
|
NOOP_SINK,
|
|
197
412
|
registerTraceSink,
|
|
198
413
|
TRACE_CONTEXT_KEY,
|
|
199
|
-
|
|
414
|
+
traceContextFromRecord,
|
|
415
|
+
writeActivationTraceRecord,
|
|
416
|
+
} from './tracing.js';
|
|
200
417
|
export type {
|
|
418
|
+
ActivationTraceRecordName,
|
|
419
|
+
SignalTraceRecordName,
|
|
201
420
|
TraceContext,
|
|
202
421
|
TraceRecord,
|
|
203
422
|
TraceSink,
|
|
204
|
-
} from './
|
|
423
|
+
} from './tracing.js';
|
|
205
424
|
export type { TraceFn } from './types.js';
|
|
206
425
|
|
|
426
|
+
// Observe
|
|
427
|
+
export {
|
|
428
|
+
createObserveLogger,
|
|
429
|
+
isLogSink,
|
|
430
|
+
isLogger,
|
|
431
|
+
isObserveInput,
|
|
432
|
+
isTraceSink,
|
|
433
|
+
normalizeObserve,
|
|
434
|
+
} from './observe.js';
|
|
435
|
+
export type {
|
|
436
|
+
ObserveCapabilities,
|
|
437
|
+
ObserveConfig,
|
|
438
|
+
ObserveInput,
|
|
439
|
+
TopoOptions,
|
|
440
|
+
} from './observe.js';
|
|
441
|
+
|
|
207
442
|
// Run
|
|
208
443
|
export { run } from './run.js';
|
|
209
444
|
export type { RunOptions } from './run.js';
|
|
@@ -226,6 +461,10 @@ export {
|
|
|
226
461
|
formatZodIssues,
|
|
227
462
|
zodToJsonSchema,
|
|
228
463
|
} from './validation.js';
|
|
464
|
+
export {
|
|
465
|
+
stripDefaultWrappers,
|
|
466
|
+
stripDefaultsFromShape,
|
|
467
|
+
} from './zod-wrappers.js';
|
|
229
468
|
|
|
230
469
|
// Serialization
|
|
231
470
|
export { serializeError, deserializeError } from './serialization.js';
|
|
@@ -272,8 +511,16 @@ export {
|
|
|
272
511
|
} from './workspace.js';
|
|
273
512
|
|
|
274
513
|
// Blob
|
|
275
|
-
export {
|
|
276
|
-
|
|
514
|
+
export {
|
|
515
|
+
BLOB_REF_SCHEMA_META_KEY,
|
|
516
|
+
blobRefDescriptorSchema,
|
|
517
|
+
blobRefJsonSchema,
|
|
518
|
+
blobRefSchema,
|
|
519
|
+
createBlobRef,
|
|
520
|
+
isBlobRef,
|
|
521
|
+
toBlobRefDescriptor,
|
|
522
|
+
} from './blob-ref.js';
|
|
523
|
+
export type { BlobRef, BlobRefDescriptor } from './blob-ref.js';
|
|
277
524
|
|
|
278
525
|
// Guards
|
|
279
526
|
export {
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared, surface-agnostic helpers for projecting typed layer `input` schemas
|
|
3
|
+
* onto a surface's native idiom.
|
|
4
|
+
*
|
|
5
|
+
* Layer projection has two halves:
|
|
6
|
+
* 1. **Collection** — walk the trail's effective layers (topo → surface →
|
|
7
|
+
* trail) and keep only the ones that declare an `input` schema. These
|
|
8
|
+
* are the layers a surface needs to project.
|
|
9
|
+
* 2. **Naming/collision policy** — when a layer field's projected name
|
|
10
|
+
* collides with a name already claimed by the trail, by another layer,
|
|
11
|
+
* or by a surface-reserved name, the field is renamed using the
|
|
12
|
+
* deterministic `<layerName>-<originalField>` rule. The collision-detection
|
|
13
|
+
* logic itself is surface-agnostic; the *shape* of the projected name
|
|
14
|
+
* (kebab-case CLI flag, camelCase MCP parameter, HTTP request field)
|
|
15
|
+
* stays per-surface.
|
|
16
|
+
*
|
|
17
|
+
* This module owns the surface-agnostic half. CLI/MCP/HTTP each layer their
|
|
18
|
+
* own projection on top: see `@ontrails/cli/build`, `@ontrails/mcp/build`,
|
|
19
|
+
* and `@ontrails/http/build`.
|
|
20
|
+
*
|
|
21
|
+
* @see TRL-473 for the CLI projection that introduced this contract.
|
|
22
|
+
* @see TRL-474 for the MCP and HTTP projections that lifted these helpers.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import type { Layer } from './layer.js';
|
|
26
|
+
import type { Topo } from './topo.js';
|
|
27
|
+
import type { AnyTrail } from './trail.js';
|
|
28
|
+
|
|
29
|
+
export const LAYER_FIELD_RESERVED_NAMES: ReadonlySet<string> = new Set([
|
|
30
|
+
'all',
|
|
31
|
+
'devPermit',
|
|
32
|
+
'dryRun',
|
|
33
|
+
'input',
|
|
34
|
+
'inputJson',
|
|
35
|
+
'json',
|
|
36
|
+
'jsonl',
|
|
37
|
+
'output',
|
|
38
|
+
'permit',
|
|
39
|
+
'quiet',
|
|
40
|
+
'token',
|
|
41
|
+
'trace',
|
|
42
|
+
'watch',
|
|
43
|
+
]);
|
|
44
|
+
|
|
45
|
+
const toKebabCase = (name: string): string =>
|
|
46
|
+
name.replaceAll(/[A-Z]/g, (ch) => `-${ch.toLowerCase()}`);
|
|
47
|
+
|
|
48
|
+
export const LAYER_FIELD_RESERVED_NAMES_KEBAB: ReadonlySet<string> = new Set(
|
|
49
|
+
[...LAYER_FIELD_RESERVED_NAMES].map(toKebabCase)
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
// ---------------------------------------------------------------------------
|
|
53
|
+
// Collection
|
|
54
|
+
// ---------------------------------------------------------------------------
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Source of a typed layer attached to a trail.
|
|
58
|
+
*
|
|
59
|
+
* Surfaces may want to know whether a layer came from topo-, surface-, or
|
|
60
|
+
* trail-scope (e.g. for descriptive errors). The collection helper preserves
|
|
61
|
+
* this information so callers don't have to recompute it.
|
|
62
|
+
*/
|
|
63
|
+
export type AttachedLayerScope = 'topo' | 'surface' | 'trail';
|
|
64
|
+
|
|
65
|
+
export interface AttachedTypedLayer {
|
|
66
|
+
readonly layer: Layer;
|
|
67
|
+
readonly scope: AttachedLayerScope;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Collect every typed layer attached to a trail in the same composition order
|
|
72
|
+
* the executor uses (topo → surface → trail). Layers without an `input`
|
|
73
|
+
* schema are skipped — they have nothing to project onto a surface.
|
|
74
|
+
*
|
|
75
|
+
* @param graph - The topo carrying topo-scope layers.
|
|
76
|
+
* @param trail - The trail whose effective layers we are projecting.
|
|
77
|
+
* @param surfaceLayers - Layers attached at surface scope (`options.layers`
|
|
78
|
+
* on the surface builder).
|
|
79
|
+
*/
|
|
80
|
+
export const collectAttachedTypedLayers = (
|
|
81
|
+
graph: Topo,
|
|
82
|
+
trail: AnyTrail,
|
|
83
|
+
surfaceLayers?: readonly Layer[] | undefined
|
|
84
|
+
): readonly AttachedTypedLayer[] => {
|
|
85
|
+
const layers: AttachedTypedLayer[] = [];
|
|
86
|
+
for (const layer of graph.layers) {
|
|
87
|
+
if (layer.input !== undefined) {
|
|
88
|
+
layers.push({ layer, scope: 'topo' });
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (surfaceLayers !== undefined) {
|
|
92
|
+
for (const layer of surfaceLayers) {
|
|
93
|
+
if (layer.input !== undefined) {
|
|
94
|
+
layers.push({ layer, scope: 'surface' });
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
for (const layer of trail.layers) {
|
|
99
|
+
if (layer.input !== undefined) {
|
|
100
|
+
layers.push({ layer, scope: 'trail' });
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return layers;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
// ---------------------------------------------------------------------------
|
|
107
|
+
// Collision rename rule
|
|
108
|
+
// ---------------------------------------------------------------------------
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Reason a layer field was renamed during projection.
|
|
112
|
+
*
|
|
113
|
+
* Surfaces map this onto their own warning/error idiom. CLI emits a stderr
|
|
114
|
+
* warning, while MCP/HTTP rely on the projected schema as the source of truth.
|
|
115
|
+
*/
|
|
116
|
+
export type LayerFieldRenameReason = 'reserved-name' | 'flag-collision';
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Outcome of projecting a single layer field's name.
|
|
120
|
+
*
|
|
121
|
+
* `claimedName` is the name the surface will publish to consumers; it is the
|
|
122
|
+
* field name when no collision was detected, or `<layerName>-<fieldName>` (or
|
|
123
|
+
* an analogous transformed form, depending on the surface's convention) when
|
|
124
|
+
* a collision required a rename. `routingTarget` is the original field name
|
|
125
|
+
* the value should be assigned back to inside the layer's runtime input.
|
|
126
|
+
*/
|
|
127
|
+
export interface LayerFieldProjection {
|
|
128
|
+
readonly claimedName: string;
|
|
129
|
+
readonly routingTarget: string;
|
|
130
|
+
readonly renamed: false;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export interface RenamedLayerFieldProjection {
|
|
134
|
+
readonly claimedName: string;
|
|
135
|
+
readonly routingTarget: string;
|
|
136
|
+
readonly renamed: true;
|
|
137
|
+
readonly originalName: string;
|
|
138
|
+
readonly reason: LayerFieldRenameReason;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export type ProjectedLayerField =
|
|
142
|
+
| LayerFieldProjection
|
|
143
|
+
| RenamedLayerFieldProjection;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Apply the deterministic collision rename rule to a single projected layer
|
|
147
|
+
* field name.
|
|
148
|
+
*
|
|
149
|
+
* @param layerName - The layer's logical name (used as the rename prefix).
|
|
150
|
+
* @param originalName - The layer field's name as authored on its schema.
|
|
151
|
+
* @param projectedName - The candidate name in the surface's native idiom
|
|
152
|
+
* (e.g. kebab-case for CLI, camelCase for MCP, request field for HTTP).
|
|
153
|
+
* @param renamedName - The fallback name applied when a collision is detected.
|
|
154
|
+
* Surfaces compute this with their own casing rule.
|
|
155
|
+
* @param claimedNames - Names already taken by the trail's input or by
|
|
156
|
+
* previous layer projections. Updated in place when a name is claimed.
|
|
157
|
+
* @param reservedNames - Framework-owned names that force a rename across
|
|
158
|
+
* surface projections.
|
|
159
|
+
*/
|
|
160
|
+
export const projectLayerFieldName = (
|
|
161
|
+
_layerName: string,
|
|
162
|
+
originalName: string,
|
|
163
|
+
projectedName: string,
|
|
164
|
+
renamedName: string,
|
|
165
|
+
claimedNames: Set<string>,
|
|
166
|
+
reservedNames: ReadonlySet<string>
|
|
167
|
+
): ProjectedLayerField => {
|
|
168
|
+
const collidesWithClaimed = claimedNames.has(projectedName);
|
|
169
|
+
const collidesWithReserved = reservedNames.has(projectedName);
|
|
170
|
+
|
|
171
|
+
if (!collidesWithClaimed && !collidesWithReserved) {
|
|
172
|
+
claimedNames.add(projectedName);
|
|
173
|
+
return {
|
|
174
|
+
claimedName: projectedName,
|
|
175
|
+
renamed: false,
|
|
176
|
+
routingTarget: originalName,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
let claimedName = renamedName;
|
|
181
|
+
for (let suffix = 2; claimedNames.has(claimedName); suffix += 1) {
|
|
182
|
+
claimedName = `${renamedName}${suffix}`;
|
|
183
|
+
}
|
|
184
|
+
claimedNames.add(claimedName);
|
|
185
|
+
return {
|
|
186
|
+
claimedName,
|
|
187
|
+
originalName: projectedName,
|
|
188
|
+
reason: collidesWithReserved ? 'reserved-name' : 'flag-collision',
|
|
189
|
+
renamed: true,
|
|
190
|
+
routingTarget: originalName,
|
|
191
|
+
};
|
|
192
|
+
};
|
package/src/layer.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
|
|
1
3
|
import type { AnyTrail } from './trail.js';
|
|
2
4
|
import type { Implementation } from './types.js';
|
|
3
5
|
|
|
@@ -5,11 +7,40 @@ import type { Implementation } from './types.js';
|
|
|
5
7
|
// Layer interface
|
|
6
8
|
// ---------------------------------------------------------------------------
|
|
7
9
|
|
|
8
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* A composable, named layer that wraps trail implementations.
|
|
12
|
+
*
|
|
13
|
+
* Layers attach at trail, surface, or topo scope and may declare an object
|
|
14
|
+
* `input` schema describing the configuration they need from the surrounding
|
|
15
|
+
* surface. Surface packages (CLI, MCP, HTTP) project this schema onto their
|
|
16
|
+
* native idioms — flags, tool parameters, query strings — alongside the
|
|
17
|
+
* trail's own input schema.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* The `input` schema is metadata for surface projection. It must be an object
|
|
21
|
+
* schema so every surface can project named fields consistently. It is
|
|
22
|
+
* optional; layers without an `input` schema behave as plain wrappers. The
|
|
23
|
+
* layer's `wrap` function is the runtime contract.
|
|
24
|
+
*/
|
|
25
|
+
export type LayerInputSchema = z.ZodObject<z.ZodRawShape>;
|
|
26
|
+
|
|
9
27
|
export interface Layer {
|
|
10
28
|
readonly name: string;
|
|
11
29
|
readonly description?: string | undefined;
|
|
12
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Authored configuration the layer needs from the surrounding surface.
|
|
33
|
+
*
|
|
34
|
+
* Surface packages project this schema onto their native idioms (CLI flags,
|
|
35
|
+
* MCP tool parameters, HTTP query strings) so a layer's input fields appear
|
|
36
|
+
* alongside the trail's own input fields. Optional — layers that wrap purely
|
|
37
|
+
* by behavior, with no surface-visible inputs, may omit it.
|
|
38
|
+
*
|
|
39
|
+
* @see TRL-473 for CLI flag projection.
|
|
40
|
+
* @see TRL-474 for MCP and HTTP projection.
|
|
41
|
+
*/
|
|
42
|
+
readonly input?: LayerInputSchema | undefined;
|
|
43
|
+
|
|
13
44
|
/**
|
|
14
45
|
* Wrap a trail's implementation, returning a new implementation.
|
|
15
46
|
*
|