@ontrails/core 1.0.0-beta.13 → 1.0.0-beta.15
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/.turbo/turbo-lint.log +1 -1
- package/CHANGELOG.md +17 -0
- package/README.md +19 -14
- package/dist/branded.d.ts +1 -1
- package/dist/branded.d.ts.map +1 -1
- package/dist/branded.js +1 -1
- package/dist/branded.js.map +1 -1
- package/dist/context.d.ts +13 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +19 -3
- package/dist/context.js.map +1 -1
- package/dist/contour.d.ts +81 -0
- package/dist/contour.d.ts.map +1 -0
- package/dist/contour.js +176 -0
- package/dist/contour.js.map +1 -0
- package/dist/cross-schema.d.ts +18 -0
- package/dist/cross-schema.d.ts.map +1 -0
- package/dist/cross-schema.js +29 -0
- package/dist/cross-schema.js.map +1 -0
- package/dist/derive.d.ts +6 -0
- package/dist/derive.d.ts.map +1 -1
- package/dist/derive.js +29 -5
- package/dist/derive.js.map +1 -1
- package/dist/draft.d.ts +28 -0
- package/dist/draft.d.ts.map +1 -0
- package/dist/draft.js +157 -0
- package/dist/draft.js.map +1 -0
- package/dist/errors.d.ts +62 -4
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +44 -1
- package/dist/errors.js.map +1 -1
- package/dist/execute.d.ts +26 -9
- package/dist/execute.d.ts.map +1 -1
- package/dist/execute.js +441 -20
- package/dist/execute.js.map +1 -1
- package/dist/fire.d.ts +43 -0
- package/dist/fire.d.ts.map +1 -0
- package/dist/fire.js +185 -0
- package/dist/fire.js.map +1 -0
- package/dist/index.d.ts +33 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -12
- package/dist/index.js.map +1 -1
- package/dist/internal/cross-batch.d.ts +44 -0
- package/dist/internal/cross-batch.d.ts.map +1 -0
- package/dist/internal/cross-batch.js +58 -0
- package/dist/internal/cross-batch.js.map +1 -0
- package/dist/internal/fork-ctx.d.ts +41 -0
- package/dist/internal/fork-ctx.d.ts.map +1 -0
- package/dist/internal/fork-ctx.js +47 -0
- package/dist/internal/fork-ctx.js.map +1 -0
- package/dist/internal/signal-ref.d.ts +15 -0
- package/dist/internal/signal-ref.d.ts.map +1 -0
- package/dist/internal/signal-ref.js +41 -0
- package/dist/internal/signal-ref.js.map +1 -0
- package/dist/internal/topo-saves.d.ts +53 -0
- package/dist/internal/topo-saves.d.ts.map +1 -0
- package/dist/internal/topo-saves.js +449 -0
- package/dist/internal/topo-saves.js.map +1 -0
- package/dist/internal/topo-snapshots.d.ts +57 -0
- package/dist/internal/topo-snapshots.d.ts.map +1 -0
- package/dist/internal/topo-snapshots.js +372 -0
- package/dist/internal/topo-snapshots.js.map +1 -0
- package/dist/internal/topo-store-read.d.ts +70 -0
- package/dist/internal/topo-store-read.d.ts.map +1 -0
- package/dist/internal/topo-store-read.js +221 -0
- package/dist/internal/topo-store-read.js.map +1 -0
- package/dist/internal/topo-store.d.ts +26 -0
- package/dist/internal/topo-store.d.ts.map +1 -0
- package/dist/internal/topo-store.js +621 -0
- package/dist/internal/topo-store.js.map +1 -0
- package/dist/internal/tracing.d.ts +98 -0
- package/dist/internal/tracing.d.ts.map +1 -0
- package/dist/internal/tracing.js +102 -0
- package/dist/internal/tracing.js.map +1 -0
- package/dist/internal/trails-db.d.ts +16 -0
- package/dist/internal/trails-db.d.ts.map +1 -0
- package/dist/internal/trails-db.js +118 -0
- package/dist/internal/trails-db.js.map +1 -0
- package/dist/internal/zod-wrappers.d.ts +40 -0
- package/dist/internal/zod-wrappers.d.ts.map +1 -0
- package/dist/internal/zod-wrappers.js +59 -0
- package/dist/internal/zod-wrappers.js.map +1 -0
- package/dist/layer.d.ts +22 -5
- package/dist/layer.d.ts.map +1 -1
- package/dist/layer.js +20 -3
- package/dist/layer.js.map +1 -1
- package/dist/path-security.d.ts +1 -1
- package/dist/path-security.d.ts.map +1 -1
- package/dist/path-security.js +1 -1
- package/dist/path-security.js.map +1 -1
- package/dist/resilience.d.ts +1 -1
- package/dist/resilience.d.ts.map +1 -1
- package/dist/resilience.js +3 -3
- package/dist/resilience.js.map +1 -1
- package/dist/resource-config.d.ts +22 -0
- package/dist/resource-config.d.ts.map +1 -0
- package/dist/resource-config.js +210 -0
- package/dist/resource-config.js.map +1 -0
- package/dist/resource.d.ts +74 -0
- package/dist/resource.d.ts.map +1 -0
- package/dist/resource.js +61 -0
- package/dist/resource.js.map +1 -0
- package/dist/run.d.ts +4 -3
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +5 -4
- package/dist/run.js.map +1 -1
- package/dist/serialization.d.ts.map +1 -1
- package/dist/serialization.js +2 -1
- package/dist/serialization.js.map +1 -1
- package/dist/store/accessor-protocol.d.ts +51 -0
- package/dist/store/accessor-protocol.d.ts.map +1 -0
- package/dist/store/accessor-protocol.js +2 -0
- package/dist/store/accessor-protocol.js.map +1 -0
- package/dist/store/index.d.ts +2 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +2 -0
- package/dist/store/index.js.map +1 -0
- package/dist/surface-filter.d.ts +13 -0
- package/dist/surface-filter.d.ts.map +1 -0
- package/dist/surface-filter.js +76 -0
- package/dist/surface-filter.js.map +1 -0
- package/dist/topo-store.d.ts +62 -0
- package/dist/topo-store.d.ts.map +1 -0
- package/dist/topo-store.js +319 -0
- package/dist/topo-store.js.map +1 -0
- package/dist/topo.d.ts +23 -9
- package/dist/topo.d.ts.map +1 -1
- package/dist/topo.js +175 -46
- package/dist/topo.js.map +1 -1
- package/dist/trail.d.ts +86 -19
- package/dist/trail.d.ts.map +1 -1
- package/dist/trail.js +59 -4
- package/dist/trail.js.map +1 -1
- package/dist/trails/derive-trail.d.ts +66 -0
- package/dist/trails/derive-trail.d.ts.map +1 -0
- package/dist/trails/derive-trail.js +378 -0
- package/dist/trails/derive-trail.js.map +1 -0
- package/dist/trails/index.d.ts +5 -0
- package/dist/trails/index.d.ts.map +1 -0
- package/dist/trails/index.js +3 -0
- package/dist/trails/index.js.map +1 -0
- package/dist/trails/ingest.d.ts +24 -0
- package/dist/trails/ingest.d.ts.map +1 -0
- package/dist/trails/ingest.js +63 -0
- package/dist/trails/ingest.js.map +1 -0
- package/dist/transport-error-map.d.ts +106 -0
- package/dist/transport-error-map.d.ts.map +1 -0
- package/dist/transport-error-map.js +24 -0
- package/dist/transport-error-map.js.map +1 -0
- package/dist/type-checks.test-d.d.ts +71 -0
- package/dist/type-checks.test-d.d.ts.map +1 -0
- package/dist/type-checks.test-d.js +12 -0
- package/dist/type-checks.test-d.js.map +1 -0
- package/dist/type-utils.d.ts +11 -2
- package/dist/type-utils.d.ts.map +1 -1
- package/dist/type-utils.js.map +1 -1
- package/dist/types.d.ts +113 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/validate-established-topo.d.ts +76 -0
- package/dist/validate-established-topo.d.ts.map +1 -0
- package/dist/validate-established-topo.js +43 -0
- package/dist/validate-established-topo.js.map +1 -0
- package/dist/validate-topo.d.ts.map +1 -1
- package/dist/validate-topo.js +27 -8
- package/dist/validate-topo.js.map +1 -1
- package/dist/workspace.d.ts +1 -1
- package/dist/workspace.d.ts.map +1 -1
- package/dist/workspace.js +1 -1
- package/dist/workspace.js.map +1 -1
- package/package.json +10 -1
- package/src/__tests__/branded.test.ts +5 -5
- package/src/__tests__/context.test.ts +3 -3
- package/src/__tests__/contour.test.ts +263 -0
- package/src/__tests__/derive-trail.test.ts +668 -0
- package/src/__tests__/derive.test.ts +58 -1
- package/src/__tests__/errors.test.ts +118 -0
- package/src/__tests__/execute.test.ts +1179 -141
- package/src/__tests__/fire.test.ts +1056 -0
- package/src/__tests__/fork-ctx.test.ts +83 -0
- package/src/__tests__/ingest.test.ts +191 -0
- package/src/__tests__/{gate.test.ts → layer.test.ts} +21 -21
- package/src/__tests__/path-security.test.ts +7 -7
- package/src/__tests__/resilience.test.ts +8 -8
- package/src/__tests__/resource.test.ts +204 -0
- package/src/__tests__/run.test.ts +13 -13
- package/src/__tests__/service-config.test.ts +28 -32
- package/src/__tests__/surface-filter.test.ts +196 -0
- package/src/__tests__/topo-store-read.test.ts +256 -0
- package/src/__tests__/topo-store.test.ts +869 -0
- package/src/__tests__/topo.test.ts +350 -54
- package/src/__tests__/trail.test.ts +189 -24
- package/src/__tests__/trails-db.test.ts +198 -0
- package/src/__tests__/transport-error-map.test.ts +82 -0
- package/src/__tests__/type-utils.test.ts +29 -1
- package/src/__tests__/validate-topo.test.ts +305 -16
- package/src/__tests__/workspace.test.ts +6 -6
- package/src/__tests__/zod-wrappers.test.ts +62 -0
- package/src/branded.ts +1 -1
- package/src/context.ts +24 -4
- package/src/contour.ts +344 -0
- package/src/cross-schema.ts +36 -0
- package/src/derive.ts +39 -8
- package/src/draft.ts +338 -0
- package/src/errors.ts +62 -18
- package/src/execute.ts +840 -29
- package/src/fire.ts +295 -0
- package/src/index.ts +142 -26
- package/src/internal/cross-batch.ts +77 -0
- package/src/internal/fork-ctx.ts +69 -0
- package/src/internal/signal-ref.ts +87 -0
- package/src/internal/topo-snapshots.ts +517 -0
- package/src/internal/topo-store-read.ts +481 -0
- package/src/internal/topo-store.ts +1192 -0
- package/src/internal/tracing.ts +187 -0
- package/src/internal/trails-db.ts +187 -0
- package/src/internal/zod-wrappers.ts +78 -0
- package/src/layer.ts +50 -0
- package/src/path-security.ts +1 -1
- package/src/resilience.ts +3 -3
- package/src/{provision-config.ts → resource-config.ts} +109 -123
- package/src/resource.ts +155 -0
- package/src/run.ts +5 -4
- package/src/serialization.ts +2 -0
- package/src/store/accessor-protocol.ts +56 -0
- package/src/store/index.ts +4 -0
- package/src/surface-filter.ts +182 -0
- package/src/topo-store.ts +510 -0
- package/src/topo.ts +328 -57
- package/src/trail.ts +199 -31
- package/src/trails/derive-trail.ts +842 -0
- package/src/trails/index.ts +9 -0
- package/src/trails/ingest.ts +146 -0
- package/src/transport-error-map.ts +56 -0
- package/src/type-checks.test-d.ts +106 -0
- package/src/type-utils.ts +17 -2
- package/src/types.ts +148 -11
- package/src/validate-established-topo.ts +63 -0
- package/src/validate-topo.ts +37 -9
- package/src/workspace.ts +1 -1
- package/tsconfig.tests.json +10 -0
- package/tsconfig.tsbuildinfo +1 -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/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/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/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/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/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/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/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/src/__tests__/service.test.ts +0 -197
- package/src/event.ts +0 -15
- package/src/gate.ts +0 -44
- package/src/provision.ts +0 -148
package/.turbo/turbo-lint.log
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @ontrails/core
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.15
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 4ad6b25: Lexicon rename cleanup (ADR-0023). Breaking for `@ontrails/core`, `@ontrails/cli`, and `@ontrails/tracing` at the boundary; internal-only churn for `@ontrails/warden`.
|
|
8
|
+
|
|
9
|
+
- **core**: the topo store schema renames `topo_provisions` / `topo_trail_provisions` → `topo_resources` / `topo_trail_resources` and `provision_count` → `resource_count`. Schema version bumped v4→v5. Stores still carrying the legacy schema are detected on open, dropped, and recreated from the new DDL — previous topo saves are cleared. Stored-data helpers `listTopoStoreProvisions` / `getTopoStoreProvision` / `readProvisionUsage` / `mapProvisionRow` renamed to their `resource` counterparts. TS row types `TopoTrailProvisionRow` / `TopoProvisionRow` renamed to `TopoTrailResourceRow` / `TopoResourceRow`.
|
|
10
|
+
- **cli**: CLI output mode env vars are now derived from the topo name per ADR-0023. Legacy globals `TRAILS_JSON` / `TRAILS_JSONL` are no longer honored — a topo named `stash` reads `STASH_JSON` / `STASH_JSONL`. `ActionResultContext` gains a `topoName: string` field; `resolveOutputMode(flags, topoName)` takes a topo name argument.
|
|
11
|
+
- **tracing**: legacy `.trails/dev/tracker.db` migration path removed. Any user still running a pre-rename beta build with a `tracker.db` should delete it or migrate before upgrading.
|
|
12
|
+
- **warden**: internal-only rename of `provisionDeclarations` / `provisionExists` rules and their trails to `resourceDeclarations` / `resourceExists`. No behavior change.
|
|
13
|
+
|
|
14
|
+
## 1.0.0-beta.14
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- 69057e9: Add hierarchical CLI command trees and structured input, enforce established-only topo exports across trailheads, move developer topo and tracker state onto shared `trails.db` with pins and maintenance flows, and ship schema-derived stores through `@ontrails/store` and its Drizzle runtime.
|
|
19
|
+
|
|
3
20
|
## 1.0.0-beta.13
|
|
4
21
|
|
|
5
22
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ const greet = trail('greet', {
|
|
|
18
18
|
blaze: (input) => Result.ok({ message: `Hello, ${input.name}!` }),
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
-
const
|
|
21
|
+
const graph = topo('myapp', { greet });
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
Trails compose other trails through `crosses` and `ctx.cross()`:
|
|
@@ -43,23 +43,24 @@ const onboard = trail('entity.onboard', {
|
|
|
43
43
|
| --- | --- |
|
|
44
44
|
| `trail(id, spec)` | Define a unit of work with typed input and `Result` output; use `crosses` for composition |
|
|
45
45
|
| `signal(id, spec)` | Define a server-originated notification with a typed data schema |
|
|
46
|
-
| `
|
|
46
|
+
| `resource(id, spec)` | Define an infrastructure dependency with `create`, `dispose`, and optional `mock` |
|
|
47
47
|
| `topo(name, ...modules)` | Collect trail modules into a queryable topology |
|
|
48
|
+
| `deriveTrail(contour, operation, spec)` | Derive CRUD-shaped trail contracts from a contour on the `@ontrails/core/trails` subpath |
|
|
48
49
|
| `validateTopo(topo)` | Structural validation: cross targets exist, no cycles, examples parse, output schemas present |
|
|
49
50
|
|
|
50
51
|
### Execution
|
|
51
52
|
|
|
52
53
|
| Export | What it does |
|
|
53
54
|
| --- | --- |
|
|
54
|
-
| `executeTrail(trail, rawInput, options?)` | Centralized execution pipeline: validates input, builds context, composes
|
|
55
|
+
| `executeTrail(trail, rawInput, options?)` | Centralized execution pipeline: validates input, builds context, composes layers, runs the implementation. Never throws -- exceptions become `Result.err(InternalError)`. |
|
|
55
56
|
| `run(topo, id, input, options?)` | Headless trail execution by ID. Looks up the trail in the topo, then delegates to `executeTrail`. Returns `Result.err(NotFoundError)` if the ID is not registered. |
|
|
56
57
|
|
|
57
58
|
```typescript
|
|
58
|
-
// executeTrail —
|
|
59
|
+
// executeTrail — surfaces use this directly
|
|
59
60
|
const result = await executeTrail(greet, { name: 'Alice' });
|
|
60
61
|
|
|
61
|
-
// run —
|
|
62
|
-
const result = await run(
|
|
62
|
+
// run — headless execution by trail ID
|
|
63
|
+
const result = await run(graph, 'greet', { name: 'Alice' });
|
|
63
64
|
if (result.isOk()) console.log(result.value);
|
|
64
65
|
```
|
|
65
66
|
|
|
@@ -89,7 +90,7 @@ Beyond the `trail(id, spec)` builder, `Topo` exposes these accessors:
|
|
|
89
90
|
|
|
90
91
|
| Type | What it describes |
|
|
91
92
|
| --- | --- |
|
|
92
|
-
| `ExecuteTrailOptions` | Options for `executeTrail`: `ctx`, `abortSignal`, `
|
|
93
|
+
| `ExecuteTrailOptions` | Options for `executeTrail`: `ctx`, `abortSignal`, `layers`, `createContext` |
|
|
93
94
|
| `RunOptions` | Same shape as `ExecuteTrailOptions`; forwarded by `run` |
|
|
94
95
|
|
|
95
96
|
### Result
|
|
@@ -112,33 +113,37 @@ result.unwrapOr(fallback); // Value or fallback
|
|
|
112
113
|
|
|
113
114
|
### Error taxonomy
|
|
114
115
|
|
|
115
|
-
|
|
116
|
+
15 error classes across 10 categories. Each maps deterministically to exit codes, HTTP status, and JSON-RPC codes on every surface.
|
|
116
117
|
|
|
117
118
|
| Category | Classes | HTTP | Retryable |
|
|
118
119
|
| --- | --- | --- | --- |
|
|
119
|
-
| `validation` | `ValidationError`, `AmbiguousError
|
|
120
|
+
| `validation` | `ValidationError`, `AmbiguousError` | 400 | No |
|
|
120
121
|
| `not_found` | `NotFoundError` | 404 | No |
|
|
121
122
|
| `conflict` | `AlreadyExistsError`, `ConflictError` | 409 | No |
|
|
122
123
|
| `permission` | `PermissionError` | 403 | No |
|
|
123
124
|
| `timeout` | `TimeoutError` | 504 | Yes |
|
|
124
125
|
| `rate_limit` | `RateLimitError` | 429 | Yes |
|
|
125
126
|
| `network` | `NetworkError` | 502 | Yes |
|
|
126
|
-
| `internal` | `InternalError` | 500 | No |
|
|
127
|
+
| `internal` | `InternalError`, `DerivationError`, `AssertionError` | 500 | No |
|
|
127
128
|
| `auth` | `AuthError` | 401 | No |
|
|
128
129
|
| `cancelled` | `CancelledError` | 499 | No |
|
|
129
130
|
|
|
130
|
-
|
|
131
|
+
`RetryExhaustedError` wraps another `TrailsError`, inherits the wrapped error's category for surface mappings, and always reports `retryable: false`.
|
|
132
|
+
|
|
133
|
+
The developer returns `Result.err(new NotFoundError(...))`. The framework maps it to the right code on every surface.
|
|
131
134
|
|
|
132
135
|
### Other exports
|
|
133
136
|
|
|
134
|
-
- **Schema derivation** -- `deriveFields(schema)` extracts
|
|
137
|
+
- **Schema derivation** -- `deriveFields(schema)` extracts faithfully
|
|
138
|
+
representable field metadata from Zod for prompts and forms
|
|
135
139
|
- **Validation** -- `validateInput`, `formatZodIssues`, `zodToJsonSchema`
|
|
136
|
-
- **Resilience** -- `retry`, `withTimeout`, `shouldRetry`, `
|
|
140
|
+
- **Resilience** -- `retry`, `withTimeout`, `shouldRetry`, `deriveBackoffDelay`
|
|
137
141
|
- **Serialization** -- `serializeError`, `deserializeError`
|
|
138
142
|
- **Branded types** -- `uuid`, `email`, `nonEmptyString`, `positiveInt`
|
|
139
|
-
- **
|
|
143
|
+
- **Layers** -- cross-cutting layers via `composeLayers`
|
|
140
144
|
- **Guards and collections** -- `isDefined`, `chunk`, `dedupe`, `groupBy`, `sortBy`
|
|
141
145
|
- **Patterns** (`@ontrails/core/patterns`) -- reusable Zod schemas for pagination, bulk ops, timestamps, sorting
|
|
146
|
+
- **Trail factories** (`@ontrails/core/trails`) -- derive CRUD-shaped trail contracts from contours without re-authoring IDs, schemas, examples, or intents
|
|
142
147
|
- **Redaction** (`@ontrails/core/redaction`) -- strip sensitive data before logging
|
|
143
148
|
|
|
144
149
|
See the [API Reference](../../docs/api-reference.md) for the full list.
|
package/dist/branded.d.ts
CHANGED
|
@@ -32,5 +32,5 @@ export declare const shortId: (length?: number) => string;
|
|
|
32
32
|
* Produce a deterministic hex hash from an input string.
|
|
33
33
|
* Uses a simple FNV-1a 32-bit hash — good enough for non-cryptographic IDs.
|
|
34
34
|
*/
|
|
35
|
-
export declare const
|
|
35
|
+
export declare const deriveIdHash: (input: string) => string;
|
|
36
36
|
//# sourceMappingURL=branded.d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AAK,GAAI,OAAO,MAAM,KAAG,MAAM,CAAC,KAAK,EAAE,eAAe,CASlE,CAAC;AAEF,eAAO,MAAM,cAAc,GACzB,OAAO,MAAM,KACZ,MAAM,CAAC,cAAc,EAAE,eAAe,CAKxC,CAAC;AAEF,eAAO,MAAM,WAAW,GACtB,OAAO,MAAM,KACZ,MAAM,CAAC,WAAW,EAAE,eAAe,CASrC,CAAC;AASF;;;GAGG;AACH,eAAO,MAAM,OAAO,GAAI,eAAU,KAAG,MAWpC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,KAAG,MAY5C,CAAC"}
|
package/dist/branded.js
CHANGED
|
@@ -73,7 +73,7 @@ export const shortId = (length = 8) => {
|
|
|
73
73
|
* Produce a deterministic hex hash from an input string.
|
|
74
74
|
* Uses a simple FNV-1a 32-bit hash — good enough for non-cryptographic IDs.
|
|
75
75
|
*/
|
|
76
|
-
export const
|
|
76
|
+
export const deriveIdHash = (input) => {
|
|
77
77
|
// FNV offset basis
|
|
78
78
|
let hash = 2_166_136_261;
|
|
79
79
|
for (let i = 0; i < input.length; i += 1) {
|
package/dist/branded.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"branded.js","sourceRoot":"","sources":["../src/branded.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,aAAa,CAAC;AAS1C,kFAAkF;AAClF,MAAM,CAAC,MAAM,KAAK,GAAG,CACnB,IAAS,EACT,KAAQ,EACS,EAAE,CAAC,KAAwB,CAAC;AAE/C,wDAAwD;AACxD,MAAM,CAAC,MAAM,OAAO,GAAG,CAAI,KAAyB,EAAK,EAAE,CAAC,KAAU,CAAC;AAWvE,8EAA8E;AAC9E,sBAAsB;AACtB,8EAA8E;AAE9E,MAAM,OAAO,GACX,4EAA4E,CAAC;A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EAAE,CAAC;QACzC,kEAAkE;QAClE,IAAI,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAClC,YAAY;QACZ,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;IACxC,CAAC;IACD,sCAAsC;IACtC,6IAA6I;IAC7I,OAAO,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACpD,CAAC,CAAC"}
|
package/dist/context.d.ts
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
import type { TrailContext, TrailContextInit } from './types.js';
|
|
1
|
+
import type { TrailContext, TrailContextInit, TraceFn } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Default passthrough `trace` used when a context is built outside
|
|
4
|
+
* `executeTrail`. `executeTrail` replaces this with a real sink-writing
|
|
5
|
+
* implementation. The passthrough runs `fn` without recording anything so
|
|
6
|
+
* direct `createTrailContext()` callers (tests, ad-hoc compositions) don't
|
|
7
|
+
* crash when invoking `ctx.trace(...)`.
|
|
8
|
+
*
|
|
9
|
+
* Declared `async` so both synchronous throws and async rejections from `fn`
|
|
10
|
+
* propagate as a rejected promise to the caller — matching the real
|
|
11
|
+
* sink-writing implementation's error semantics.
|
|
12
|
+
*/
|
|
13
|
+
export declare const passthroughTrace: TraceFn;
|
|
2
14
|
/**
|
|
3
15
|
* Create a TrailContext with sensible defaults.
|
|
4
16
|
*
|
package/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAM1E;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,EAAE,OAGJ,CAAC;AAE5B;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAC7B,YAAY,OAAO,CAAC,gBAAgB,CAAC,KACpC,YAeF,CAAC"}
|
package/dist/context.js
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createResourceLookup } from './resource.js';
|
|
2
|
+
/**
|
|
3
|
+
* Default passthrough `trace` used when a context is built outside
|
|
4
|
+
* `executeTrail`. `executeTrail` replaces this with a real sink-writing
|
|
5
|
+
* implementation. The passthrough runs `fn` without recording anything so
|
|
6
|
+
* direct `createTrailContext()` callers (tests, ad-hoc compositions) don't
|
|
7
|
+
* crash when invoking `ctx.trace(...)`.
|
|
8
|
+
*
|
|
9
|
+
* Declared `async` so both synchronous throws and async rejections from `fn`
|
|
10
|
+
* propagate as a rejected promise to the caller — matching the real
|
|
11
|
+
* sink-writing implementation's error semantics.
|
|
12
|
+
*/
|
|
13
|
+
export const passthroughTrace = async (_label, fn) => await fn();
|
|
2
14
|
/**
|
|
3
15
|
* Create a TrailContext with sensible defaults.
|
|
4
16
|
*
|
|
@@ -12,10 +24,14 @@ export const createTrailContext = (overrides) => {
|
|
|
12
24
|
cwd: process.cwd(),
|
|
13
25
|
env: process.env,
|
|
14
26
|
requestId: Bun.randomUUIDv7(),
|
|
27
|
+
trace: passthroughTrace,
|
|
15
28
|
...overrides,
|
|
16
29
|
};
|
|
17
|
-
const lookup = overrides?.
|
|
18
|
-
ctx.
|
|
30
|
+
const lookup = overrides?.resource ?? createResourceLookup(() => ctx);
|
|
31
|
+
ctx.resource = lookup;
|
|
32
|
+
if (ctx.trace === undefined) {
|
|
33
|
+
ctx.trace = passthroughTrace;
|
|
34
|
+
}
|
|
19
35
|
return ctx;
|
|
20
36
|
};
|
|
21
37
|
//# sourceMappingURL=context.js.map
|
package/dist/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAOrD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAY,KAAK,EAC5C,MAAc,EACd,EAAwB,EACZ,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC;AAE5B;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,SAAqC,EACvB,EAAE;IAChB,MAAM,GAAG,GAAG;QACV,WAAW,EAAE,IAAI,eAAe,EAAE,CAAC,MAAM;QACzC,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;QAClB,GAAG,EAAE,OAAO,CAAC,GAAyC;QACtD,SAAS,EAAE,GAAG,CAAC,YAAY,EAAE;QAC7B,KAAK,EAAE,gBAAgB;QACvB,GAAG,SAAS;KACU,CAAC;IACzB,MAAM,MAAM,GAAG,SAAS,EAAE,QAAQ,IAAI,oBAAoB,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;IACtE,GAAG,CAAC,QAAQ,GAAG,MAAM,CAAC;IACtB,IAAI,GAAG,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC5B,GAAG,CAAC,KAAK,GAAG,gBAAgB,CAAC;IAC/B,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { Branded } from './branded.js';
|
|
3
|
+
/**
|
|
4
|
+
* Runtime options for a contour declaration.
|
|
5
|
+
*/
|
|
6
|
+
export interface ContourOptions<TShape extends z.ZodRawShape, TIdentity extends keyof TShape & string> {
|
|
7
|
+
/** Field name that acts as the contour's primary identity. */
|
|
8
|
+
readonly identity: TIdentity;
|
|
9
|
+
/** Example instances validated against the contour schema at declaration time. */
|
|
10
|
+
readonly examples?: readonly z.output<z.ZodObject<TShape>>[] | undefined;
|
|
11
|
+
}
|
|
12
|
+
/** Type-level brand name applied to a contour's identity schema. */
|
|
13
|
+
export type ContourIdBrand<TName extends string> = `${Capitalize<TName>}Id`;
|
|
14
|
+
type BrandedSchema<TSchema extends z.core.$ZodType, TBrand extends string> = TSchema & z.ZodType<Branded<z.output<TSchema>, TBrand>>;
|
|
15
|
+
/** Output value of a branded contour identity schema. */
|
|
16
|
+
export type ContourIdValue<TSchema extends z.core.$ZodType, TName extends string> = Branded<z.output<TSchema>, ContourIdBrand<TName>>;
|
|
17
|
+
/** Runtime metadata attached to schemas returned from `contour.id()`. */
|
|
18
|
+
export interface ContourIdMetadata<TName extends string = string, TIdentity extends string = string> {
|
|
19
|
+
readonly contour: TName;
|
|
20
|
+
readonly identity: TIdentity;
|
|
21
|
+
}
|
|
22
|
+
/** A structural contour reference declared by another contour field schema. */
|
|
23
|
+
export interface ContourReference<TName extends string = string, TIdentity extends string = string> extends ContourIdMetadata<TName, TIdentity> {
|
|
24
|
+
readonly field: string;
|
|
25
|
+
}
|
|
26
|
+
/** Symbol used to tag branded contour reference schemas at runtime. */
|
|
27
|
+
export declare const CONTOUR_ID_METADATA: unique symbol;
|
|
28
|
+
/**
|
|
29
|
+
* A contour identity schema branded for one contour and tagged with runtime
|
|
30
|
+
* metadata so the topo layer can recognize declared references later on.
|
|
31
|
+
*/
|
|
32
|
+
export type ContourIdSchema<TSchema extends z.core.$ZodType = z.core.$ZodType, TName extends string = string, TIdentity extends string = string> = BrandedSchema<TSchema, ContourIdBrand<TName>> & {
|
|
33
|
+
/** @deprecated Use `getContourIdMetadata()` — metadata lives in a WeakMap, not on the schema. */
|
|
34
|
+
readonly [CONTOUR_ID_METADATA]?: ContourIdMetadata<TName, TIdentity>;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* A first-class domain object with schema, identity metadata, and examples.
|
|
38
|
+
*
|
|
39
|
+
* A contour behaves like the `ZodObject` it wraps, so standard Zod composition
|
|
40
|
+
* helpers such as `.pick()`, `.extend()`, and `.array()` continue to work.
|
|
41
|
+
*/
|
|
42
|
+
export type Contour<TName extends string = string, TShape extends z.ZodRawShape = z.ZodRawShape, TIdentity extends keyof TShape & string = keyof TShape & string> = z.ZodObject<TShape> & {
|
|
43
|
+
readonly kind: 'contour';
|
|
44
|
+
readonly name: TName;
|
|
45
|
+
readonly identity: TIdentity;
|
|
46
|
+
readonly identitySchema: TShape[TIdentity];
|
|
47
|
+
readonly id: () => ContourIdSchema<TShape[TIdentity], TName, TIdentity>;
|
|
48
|
+
readonly examples?: readonly z.output<z.ZodObject<TShape>>[] | undefined;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Read contour-reference metadata from a schema returned by `contour.id()`.
|
|
52
|
+
*
|
|
53
|
+
* When the schema is wrapped by Zod combinators (`.optional()`, `.nullable()`,
|
|
54
|
+
* `.default()`, `.nullish()`, etc.) the `CONTOUR_ID_METADATA` symbol lives on
|
|
55
|
+
* the inner schema, not on the wrapper. The unwrap handles arbitrarily nested
|
|
56
|
+
* wrapper levels.
|
|
57
|
+
*/
|
|
58
|
+
export declare const getContourIdMetadata: (schema: unknown) => ContourIdMetadata | undefined;
|
|
59
|
+
/** Inspect a contour schema for fields that reference other contours via `.id()`. */
|
|
60
|
+
export declare const getContourReferences: (contour: AnyContour) => readonly ContourReference[];
|
|
61
|
+
/**
|
|
62
|
+
* Create a contour definition from a raw Zod object shape.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* const user = contour(
|
|
67
|
+
* 'user',
|
|
68
|
+
* {
|
|
69
|
+
* id: z.string().uuid(),
|
|
70
|
+
* email: z.string().email(),
|
|
71
|
+
* name: z.string(),
|
|
72
|
+
* },
|
|
73
|
+
* { identity: 'id' }
|
|
74
|
+
* );
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export declare const contour: <TName extends string, TShape extends z.ZodRawShape, TIdentity extends keyof TShape & string>(name: TName, shape: TShape, options: ContourOptions<TShape, TIdentity>) => Contour<TName, TShape, TIdentity>;
|
|
78
|
+
/** Existential type for heterogeneous contour collections. */
|
|
79
|
+
export type AnyContour = Contour<string, z.ZodRawShape, string>;
|
|
80
|
+
export {};
|
|
81
|
+
//# sourceMappingURL=contour.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contour.d.ts","sourceRoot":"","sources":["../src/contour.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,cAAc,CAC7B,MAAM,SAAS,CAAC,CAAC,WAAW,EAC5B,SAAS,SAAS,MAAM,MAAM,GAAG,MAAM;IAEvC,8DAA8D;IAC9D,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAC7B,kFAAkF;IAClF,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC;CAC1E;AAED,oEAAoE;AACpE,MAAM,MAAM,cAAc,CAAC,KAAK,SAAS,MAAM,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC;AAE5E,KAAK,aAAa,CAChB,OAAO,SAAS,CAAC,CAAC,IAAI,CAAC,QAAQ,EAC/B,MAAM,SAAS,MAAM,IACnB,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;AAM5D,yDAAyD;AACz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+
/** Symbol used to tag branded contour reference schemas at runtime. */
|
|
3
|
+
export const CONTOUR_ID_METADATA = Symbol.for('@ontrails/core/contour-id');
|
|
4
|
+
/**
|
|
5
|
+
* Module-level WeakMap storing contour identity metadata keyed by schema object.
|
|
6
|
+
*
|
|
7
|
+
* First-write-wins: when multiple contours share the same underlying schema
|
|
8
|
+
* (e.g. `contour('admin', { id: user.shape.id }, ...)`), the first contour to
|
|
9
|
+
* brand the schema claims it. Subsequent calls skip the write to prevent
|
|
10
|
+
* silent metadata corruption.
|
|
11
|
+
*/
|
|
12
|
+
const contourIdMetadata = new WeakMap();
|
|
13
|
+
const formatExampleIssues = (issues) => issues
|
|
14
|
+
.map((issue) => {
|
|
15
|
+
const path = issue.path.length > 0 ? issue.path.join('.') : '<root>';
|
|
16
|
+
return `${path}: ${issue.message}`;
|
|
17
|
+
})
|
|
18
|
+
.join('; ');
|
|
19
|
+
const assertIdentityField = (name, shape, identity) => {
|
|
20
|
+
if (!Object.hasOwn(shape, identity)) {
|
|
21
|
+
throw new TypeError(`contour("${name}") identity "${identity}" must match a declared field`);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const assertExamples = (name, schema, examples) => {
|
|
25
|
+
for (const [index, example] of examples.entries()) {
|
|
26
|
+
const parsed = schema.safeParse(example);
|
|
27
|
+
if (!parsed.success) {
|
|
28
|
+
throw new TypeError(`contour("${name}") example ${index} is invalid: ${formatExampleIssues(parsed.error.issues)}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const validateExamples = (name, schema, examples) => {
|
|
33
|
+
if (examples) {
|
|
34
|
+
assertExamples(name, schema, examples);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const brandIdentitySchema = (contour, identity, schema) => {
|
|
38
|
+
const branded = schema.brand();
|
|
39
|
+
// First-write-wins: if another contour already claimed this schema object
|
|
40
|
+
// (possible when Zod v4 brand() returns `this`), preserve the original
|
|
41
|
+
// metadata rather than silently overwriting it.
|
|
42
|
+
if (!contourIdMetadata.has(branded)) {
|
|
43
|
+
contourIdMetadata.set(branded, {
|
|
44
|
+
contour,
|
|
45
|
+
identity,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return branded;
|
|
49
|
+
};
|
|
50
|
+
const attachContourMetadata = (schema, metadata) => {
|
|
51
|
+
Object.defineProperties(schema, {
|
|
52
|
+
examples: {
|
|
53
|
+
enumerable: true,
|
|
54
|
+
value: metadata.examples,
|
|
55
|
+
writable: false,
|
|
56
|
+
},
|
|
57
|
+
id: {
|
|
58
|
+
enumerable: true,
|
|
59
|
+
value: () => metadata.idSchema,
|
|
60
|
+
writable: false,
|
|
61
|
+
},
|
|
62
|
+
identity: {
|
|
63
|
+
enumerable: true,
|
|
64
|
+
value: metadata.identity,
|
|
65
|
+
writable: false,
|
|
66
|
+
},
|
|
67
|
+
identitySchema: {
|
|
68
|
+
enumerable: true,
|
|
69
|
+
value: metadata.identitySchema,
|
|
70
|
+
writable: false,
|
|
71
|
+
},
|
|
72
|
+
kind: {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
value: 'contour',
|
|
75
|
+
writable: false,
|
|
76
|
+
},
|
|
77
|
+
name: {
|
|
78
|
+
enumerable: true,
|
|
79
|
+
value: metadata.name,
|
|
80
|
+
writable: false,
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
/** Read contour identity metadata from the module-level WeakMap, if present. */
|
|
85
|
+
const readMetadata = (schema) => typeof schema === 'object' && schema !== null
|
|
86
|
+
? contourIdMetadata.get(schema)
|
|
87
|
+
: undefined;
|
|
88
|
+
/** Resolve the inner schema from a Zod wrapper (ZodOptional, ZodNullable, etc.). */
|
|
89
|
+
const unwrapInner = (schema) => {
|
|
90
|
+
const def = schema._def;
|
|
91
|
+
return (def?.['innerType'] ?? def?.['schema']);
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Walk through Zod wrapper layers searching for `CONTOUR_ID_METADATA`.
|
|
95
|
+
*
|
|
96
|
+
* `.nullish()` produces `ZodOptional<ZodNullable<T>>` — two wrapper levels —
|
|
97
|
+
* so a single-step unwrap is insufficient. This iterates until it finds the
|
|
98
|
+
* metadata or exhausts all wrapper layers.
|
|
99
|
+
*/
|
|
100
|
+
const unwrapToMetadata = (schema) => {
|
|
101
|
+
let current = schema;
|
|
102
|
+
while (typeof current === 'object' && current !== null) {
|
|
103
|
+
const inner = unwrapInner(current);
|
|
104
|
+
if (typeof inner !== 'object' || inner === null) {
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
const metadata = readMetadata(inner);
|
|
108
|
+
if (metadata !== undefined) {
|
|
109
|
+
return metadata;
|
|
110
|
+
}
|
|
111
|
+
current = inner;
|
|
112
|
+
}
|
|
113
|
+
return undefined;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Read contour-reference metadata from a schema returned by `contour.id()`.
|
|
117
|
+
*
|
|
118
|
+
* When the schema is wrapped by Zod combinators (`.optional()`, `.nullable()`,
|
|
119
|
+
* `.default()`, `.nullish()`, etc.) the `CONTOUR_ID_METADATA` symbol lives on
|
|
120
|
+
* the inner schema, not on the wrapper. The unwrap handles arbitrarily nested
|
|
121
|
+
* wrapper levels.
|
|
122
|
+
*/
|
|
123
|
+
export const getContourIdMetadata = (schema) => readMetadata(schema) ?? unwrapToMetadata(schema);
|
|
124
|
+
/** Inspect a contour schema for fields that reference other contours via `.id()`. */
|
|
125
|
+
export const getContourReferences = (contour) => Object.entries(contour.shape)
|
|
126
|
+
.flatMap(([field, schema]) => {
|
|
127
|
+
if (field === contour.identity) {
|
|
128
|
+
return [];
|
|
129
|
+
}
|
|
130
|
+
const metadata = getContourIdMetadata(schema);
|
|
131
|
+
if (metadata === undefined) {
|
|
132
|
+
return [];
|
|
133
|
+
}
|
|
134
|
+
return [{ field, ...metadata }];
|
|
135
|
+
})
|
|
136
|
+
.toSorted((left, right) => left.field === right.field
|
|
137
|
+
? left.contour.localeCompare(right.contour)
|
|
138
|
+
: left.field.localeCompare(right.field));
|
|
139
|
+
/**
|
|
140
|
+
* Create a contour definition from a raw Zod object shape.
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* const user = contour(
|
|
145
|
+
* 'user',
|
|
146
|
+
* {
|
|
147
|
+
* id: z.string().uuid(),
|
|
148
|
+
* email: z.string().email(),
|
|
149
|
+
* name: z.string(),
|
|
150
|
+
* },
|
|
151
|
+
* { identity: 'id' }
|
|
152
|
+
* );
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
export const contour = (name, shape, options) => {
|
|
156
|
+
assertIdentityField(name, shape, options.identity);
|
|
157
|
+
const schema = z.object(shape);
|
|
158
|
+
validateExamples(name, schema, options.examples);
|
|
159
|
+
const identitySchema = shape[options.identity];
|
|
160
|
+
if (!identitySchema) {
|
|
161
|
+
throw new TypeError(`contour("${name}") identity "${options.identity}" must resolve to a schema`);
|
|
162
|
+
}
|
|
163
|
+
const idSchema = brandIdentitySchema(name, options.identity, identitySchema);
|
|
164
|
+
const examples = options.examples
|
|
165
|
+
? Object.freeze([...options.examples])
|
|
166
|
+
: undefined;
|
|
167
|
+
attachContourMetadata(schema, {
|
|
168
|
+
examples,
|
|
169
|
+
idSchema,
|
|
170
|
+
identity: options.identity,
|
|
171
|
+
identitySchema,
|
|
172
|
+
name,
|
|
173
|
+
});
|
|
174
|
+
return schema;
|
|
175
|
+
};
|
|
176
|
+
//# sourceMappingURL=contour.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contour.js","sourceRoot":"","sources":["../src/contour.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAoDxB,uEAAuE;AACvE,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;AAE3E;;;;;;;GAOG;AACH,MAAM,iBAAiB,GA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CACjB,YAAY,IAAI,gBAAgB,OAAO,CAAC,QAAQ,4BAA4B,CAC7E,CAAC;IACJ,CAAC;IAED,MAAM,QAAQ,GAAG,mBAAmB,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;IAC7E,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ;QAC/B,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;QACtC,CAAC,CAAC,SAAS,CAAC;IAEd,qBAAqB,CAAC,MAAM,EAAE;QAC5B,QAAQ;QACR,QAAQ;QACR,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,cAAc;QACd,IAAI;KACL,CAAC,CAAC;IAEH,OAAO,MAA2C,CAAC;AACrD,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-invocation schema merging for trails with `crossInput`.
|
|
3
|
+
*
|
|
4
|
+
* When a trail declares `crossInput`, callers via `ctx.cross()` pass both
|
|
5
|
+
* public input and composition-only fields. The merged schema validates the
|
|
6
|
+
* combined shape so `executeTrail` doesn't reject the extra fields.
|
|
7
|
+
*/
|
|
8
|
+
import { z } from 'zod';
|
|
9
|
+
import type { AnyTrail } from './trail.js';
|
|
10
|
+
/**
|
|
11
|
+
* Build the validation schema for a cross-invoked trail.
|
|
12
|
+
*
|
|
13
|
+
* When the target trail declares `crossInput`, returns the intersection of
|
|
14
|
+
* `trail.input` and `trail.crossInput`. Returns `undefined` when no
|
|
15
|
+
* `crossInput` is declared, signaling that normal input validation suffices.
|
|
16
|
+
*/
|
|
17
|
+
export declare const buildCrossValidationSchema: (trailDef: AnyTrail) => z.ZodType | undefined;
|
|
18
|
+
//# sourceMappingURL=cross-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cross-schema.d.ts","sourceRoot":"","sources":["../src/cross-schema.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,GACrC,UAAU,QAAQ,KACjB,CAAC,CAAC,OAAO,GAAG,SAcd,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-invocation schema merging for trails with `crossInput`.
|
|
3
|
+
*
|
|
4
|
+
* When a trail declares `crossInput`, callers via `ctx.cross()` pass both
|
|
5
|
+
* public input and composition-only fields. The merged schema validates the
|
|
6
|
+
* combined shape so `executeTrail` doesn't reject the extra fields.
|
|
7
|
+
*/
|
|
8
|
+
import { z } from 'zod';
|
|
9
|
+
/**
|
|
10
|
+
* Build the validation schema for a cross-invoked trail.
|
|
11
|
+
*
|
|
12
|
+
* When the target trail declares `crossInput`, returns the intersection of
|
|
13
|
+
* `trail.input` and `trail.crossInput`. Returns `undefined` when no
|
|
14
|
+
* `crossInput` is declared, signaling that normal input validation suffices.
|
|
15
|
+
*/
|
|
16
|
+
export const buildCrossValidationSchema = (trailDef) => {
|
|
17
|
+
if (!trailDef.crossInput) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
// Prefer .merge() for ZodObject pairs — produces a proper merged object
|
|
21
|
+
// schema that strips unknown keys and exposes .shape. Fall back to
|
|
22
|
+
// z.intersection for non-object schemas.
|
|
23
|
+
if (trailDef.input instanceof z.ZodObject &&
|
|
24
|
+
trailDef.crossInput instanceof z.ZodObject) {
|
|
25
|
+
return trailDef.input.merge(trailDef.crossInput);
|
|
26
|
+
}
|
|
27
|
+
return z.intersection(trailDef.input, trailDef.crossInput);
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=cross-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cross-schema.js","sourceRoot":"","sources":["../src/cross-schema.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACxC,QAAkB,EACK,EAAE;IACzB,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;QACzB,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,wEAAwE;IACxE,mEAAmE;IACnE,yCAAyC;IACzC,IACE,QAAQ,CAAC,KAAK,YAAY,CAAC,CAAC,SAAS;QACrC,QAAQ,CAAC,UAAU,YAAY,CAAC,CAAC,SAAS,EAC1C,CAAC;QACD,OAAO,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IACnD,CAAC;IACD,OAAO,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;AAC7D,CAAC,CAAC"}
|
package/dist/derive.d.ts
CHANGED
|
@@ -29,6 +29,12 @@ export interface FieldOverride {
|
|
|
29
29
|
hint?: string | undefined;
|
|
30
30
|
}[] | undefined;
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Derive the canonical ordered CLI path from a trail ID.
|
|
34
|
+
*
|
|
35
|
+
* @throws {ValidationError} if the trail ID contains empty segments (e.g. consecutive dots).
|
|
36
|
+
*/
|
|
37
|
+
export declare const deriveCliPath: (trailId: string) => string[];
|
|
32
38
|
/**
|
|
33
39
|
* Derive a runtime-agnostic Field[] from a Zod object schema.
|
|
34
40
|
*
|
package/dist/derive.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"derive.d.ts","sourceRoot":"","sources":["../src/derive.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"derive.d.ts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