@ontrails/http 1.0.0-beta.39 → 1.0.0-beta.41
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 +15 -0
- package/README.md +3 -3
- package/package.json +7 -2
- package/src/build.ts +1 -1
- package/src/bun.ts +1 -1
- package/src/testing.ts +8 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @ontrails/http
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.41
|
|
4
|
+
|
|
5
|
+
## 1.0.0-beta.40
|
|
6
|
+
|
|
7
|
+
### Minor Changes
|
|
8
|
+
|
|
9
|
+
- [`5adb995`](https://github.com/outfitter-dev/trails/commit/5adb99551c2dda6190d46cce7f60bb08d63c99aa): Complete the v1 hard cutover from the authored `blaze` field to
|
|
10
|
+
`implementation` across trail contracts, surface projections, tests, examples,
|
|
11
|
+
and public source-analysis helpers. Existing applications must rename authored
|
|
12
|
+
trail behavior fields and direct trail-object access before upgrading.
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [`9bf592d`](https://github.com/outfitter-dev/trails/commit/9bf592ddba46aa12e3f4e6ffc0f772f7a41ed3df): Declare verified first-party adapter metadata for Drizzle, HTTP/Bun, and Store/Jsonfile so shared adapter checks can dogfood real owner targets.
|
|
17
|
+
|
|
3
18
|
## 1.0.0-beta.39
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ const greet = trail('greet', {
|
|
|
13
13
|
input: z.object({ name: z.string().describe('Who to greet') }),
|
|
14
14
|
output: z.object({ message: z.string() }),
|
|
15
15
|
intent: 'read',
|
|
16
|
-
|
|
16
|
+
implementation: (input) => Result.ok({ message: `Hello, ${input.name}!` }),
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
const graph = topo('myapp', { greet });
|
|
@@ -114,7 +114,7 @@ Trail IDs map to paths: `entity.show` becomes `/entity/show`. Dots become slashe
|
|
|
114
114
|
|
|
115
115
|
## Resource resolution
|
|
116
116
|
|
|
117
|
-
Declared resources on each trail are resolved into the context before the
|
|
117
|
+
Declared resources on each trail are resolved into the context before the implementation receives input.
|
|
118
118
|
|
|
119
119
|
## Filtering
|
|
120
120
|
|
|
@@ -142,7 +142,7 @@ Each route definition produced by `deriveHttpRoutes` includes:
|
|
|
142
142
|
| `trailId` | `string` | The trail ID this route was derived from |
|
|
143
143
|
| `inputSource` | `'query' \| 'body'` | Where to read input |
|
|
144
144
|
| `trail` | `Trail` | The original trail definition |
|
|
145
|
-
| `execute` | `(input, requestId?, abortSignal?, context?) => Promise<Result>` | Validates, layers, resolves request auth when configured, and runs the
|
|
145
|
+
| `execute` | `(input, requestId?, abortSignal?, context?) => Promise<Result>` | Validates, layers, resolves request auth when configured, and runs the trail |
|
|
146
146
|
|
|
147
147
|
For GET routes on the Hono surface, repeated query keys are passed through as arrays (`?tag=one&tag=two` -> `{ tag: ['one', 'two'] }`) while a single occurrence stays a scalar string. The adapter does not coerce singleton query values into arrays.
|
|
148
148
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ontrails/http",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.41",
|
|
4
4
|
"files": [
|
|
5
5
|
"src/**/*.ts",
|
|
6
6
|
"!src/**/__tests__/**",
|
|
@@ -25,12 +25,17 @@
|
|
|
25
25
|
"clean": "rm -rf dist *.tsbuildinfo"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@ontrails/core": "^1.0.0-beta.
|
|
28
|
+
"@ontrails/core": "^1.0.0-beta.41"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"zod": "^4.3.5"
|
|
32
32
|
},
|
|
33
33
|
"trails": {
|
|
34
|
+
"adapters": {
|
|
35
|
+
"./bun": {
|
|
36
|
+
"target": "http"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
34
39
|
"adapterTargets": {
|
|
35
40
|
"http": {
|
|
36
41
|
"conformance": {
|
package/src/build.ts
CHANGED
|
@@ -133,7 +133,7 @@ export interface HttpRouteDefinition {
|
|
|
133
133
|
| undefined;
|
|
134
134
|
readonly webhookSource?: WebhookSource | undefined;
|
|
135
135
|
/**
|
|
136
|
-
* Validate input, compose layers, and run the
|
|
136
|
+
* Validate input, compose layers, and run the trail implementation.
|
|
137
137
|
*
|
|
138
138
|
* The caller is responsible for parsing raw input from the request and
|
|
139
139
|
* mapping the Result to an HTTP response. This function is framework-agnostic.
|
package/src/bun.ts
CHANGED
|
@@ -109,7 +109,7 @@ const bodylessHeadResponse = (response: Response): Response =>
|
|
|
109
109
|
const caughtErrors = new Map<string, Error>();
|
|
110
110
|
const caughtErrorInput = z.object({ errorId: z.string() });
|
|
111
111
|
const caughtErrorTrail = trail('__ontrails.http.bun.error', {
|
|
112
|
-
|
|
112
|
+
implementation: () =>
|
|
113
113
|
Result.err(new InternalError('Bun error fallback executed directly')),
|
|
114
114
|
input: caughtErrorInput,
|
|
115
115
|
intent: 'read',
|
package/src/testing.ts
CHANGED
|
@@ -41,21 +41,21 @@ export interface HttpAdapterConformanceCase {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
const echoTrail = trail('echo', {
|
|
44
|
-
|
|
44
|
+
implementation: (input) => Result.ok({ reply: input.message }),
|
|
45
45
|
input: z.object({ message: z.string() }),
|
|
46
46
|
intent: 'read',
|
|
47
47
|
output: z.object({ reply: z.string() }),
|
|
48
48
|
});
|
|
49
49
|
|
|
50
50
|
const tagsTrail = trail('tags', {
|
|
51
|
-
|
|
51
|
+
implementation: (input) => Result.ok({ tags: input.tags }),
|
|
52
52
|
input: z.object({ tags: z.array(z.string()) }),
|
|
53
53
|
intent: 'read',
|
|
54
54
|
output: z.object({ tags: z.array(z.string()) }),
|
|
55
55
|
});
|
|
56
56
|
|
|
57
57
|
const echoBodyTrail = trail('echo.body', {
|
|
58
|
-
|
|
58
|
+
implementation: (input) => Result.ok({ length: input.message.length }),
|
|
59
59
|
input: z.object({ message: z.string() }),
|
|
60
60
|
intent: 'write',
|
|
61
61
|
output: z.object({ length: z.number() }),
|
|
@@ -65,14 +65,14 @@ const genericRedactionError = (): Error =>
|
|
|
65
65
|
new Error('database password=secret');
|
|
66
66
|
|
|
67
67
|
const genericErrorTrail = trail('generic.error', {
|
|
68
|
-
|
|
68
|
+
implementation: () => Result.err(genericRedactionError()),
|
|
69
69
|
input: z.object({}),
|
|
70
70
|
intent: 'read',
|
|
71
71
|
output: z.object({ ok: z.boolean() }),
|
|
72
72
|
});
|
|
73
73
|
|
|
74
74
|
const protectedTrail = trail('permit.scope', {
|
|
75
|
-
|
|
75
|
+
implementation: (_input, ctx) =>
|
|
76
76
|
Result.ok({
|
|
77
77
|
permitId: ctx.permit?.id,
|
|
78
78
|
requestId: ctx.requestId,
|
|
@@ -87,7 +87,8 @@ const protectedTrail = trail('permit.scope', {
|
|
|
87
87
|
});
|
|
88
88
|
|
|
89
89
|
const abortingTrail = trail('abort.check', {
|
|
90
|
-
|
|
90
|
+
implementation: (_input, ctx) =>
|
|
91
|
+
Result.ok({ aborted: ctx.abortSignal.aborted }),
|
|
91
92
|
input: z.object({}),
|
|
92
93
|
intent: 'read',
|
|
93
94
|
output: z.object({ aborted: z.boolean() }),
|
|
@@ -104,7 +105,7 @@ const paymentWebhook = webhook('webhook.payment.received', {
|
|
|
104
105
|
});
|
|
105
106
|
|
|
106
107
|
const paymentWebhookTrail = trail('payment.receive', {
|
|
107
|
-
|
|
108
|
+
implementation: (input) => Result.ok({ paymentId: input.paymentId }),
|
|
108
109
|
input: z.object({ paymentId: z.string() }),
|
|
109
110
|
on: [paymentWebhook],
|
|
110
111
|
output: z.object({ paymentId: z.string() }),
|