@rsc-kit/mcp 0.30.47 → 0.30.48

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.
@@ -91,6 +91,51 @@ pages out. A layout can export it too: the smallest value on the way down to
91
91
  the page wins, and `0` anywhere means the page is rendered per request as
92
92
  before. It must be a number literal the build can read.
93
93
 
94
+ To see whether the CDN answered, read `Cache-Status` (RFC 9211). A CDN that
95
+ sends it adds an entry under its own name, with `hit` when its copy answered.
96
+ `X-RSC-Kit` and `ETag` can't tell you: they were stored with the copy, so a hit
97
+ repeats them.
98
+
99
+ Homeport's edge adds this entry from its next engine release, so it isn't there
100
+ yet. See [what it will say](#cache-status-on-homeport).
101
+
102
+ ### `Cache-Status` on Homeport
103
+
104
+ This arrives with Homeport's next engine release. Until then a response has no
105
+ `homeport` entry.
106
+
107
+ The entry is named `homeport` and comes last, after any `Cache-Status` the app
108
+ sends. It is a separate header line, so `curl -I` can show two `Cache-Status`
109
+ lines, while `headers.get()` in `fetch` joins them with a comma.
110
+
111
+ | Answer | Value |
112
+ | --- | --- |
113
+ | Fresh copy | `homeport; hit; ttl=42` |
114
+ | Stale copy, refreshing in the background | `homeport; hit; ttl=-5; detail=stale` |
115
+ | Stale copy, app unreachable | `homeport; hit; detail=stale-if-error` |
116
+ | Stale copy, app answered 5xx | `homeport; fwd=stale; fwd-status=503; detail=stale-if-error` |
117
+ | From the app, being kept | `homeport; fwd=uri-miss; stored` |
118
+ | From the app, not kept | `homeport; fwd=uri-miss; detail=no-cdn-cache-control` |
119
+ | Cache switched off | `homeport; fwd=bypass; detail=off` |
120
+ | Preview | `homeport; fwd=bypass; detail=preview` |
121
+ | Not a GET or HEAD | `homeport; fwd=method; detail=request` |
122
+ | `Authorization`, `Range` or a request body | `homeport; fwd=bypass; detail=request` |
123
+
124
+ On the two "from the app" rows, `fwd` can also be `stale` or `vary-miss`:
125
+ `uri-miss` is only the plain case. A page that was not kept can also give
126
+ `no-store`, `private`, `no-cache`, `set-cookie`, `status` or `too-large` as its
127
+ `detail`.
128
+
129
+ - **Look for `hit` in the `homeport` entry**, not anywhere in the header: the
130
+ app's own entry can say `hit` too. The stale copy after a 5xx came from the
131
+ edge and does not say `hit`.
132
+ - **`stored` is not proof of a kept copy.** It is sent before the body, so a
133
+ body that fails or is too large can say `stored` and keep nothing. The next
134
+ request's `hit` is the proof.
135
+ - **A static page, a shell or an asset has no entry.** Those hits say
136
+ `X-Homeport-Edge: page`, `shell` or `asset`. Only `X-Homeport-Edge: cached`
137
+ is gone.
138
+
94
139
  ### Kept by the engine, too
95
140
 
96
141
  The host keeps a public `revalidate` page itself, so it is served without a
package/guides/go.md CHANGED
@@ -400,8 +400,9 @@ well; `reg.SetPurger` replaces it. Call it after your transaction commits.
400
400
 
401
401
  ## Public forms
402
402
 
403
- A contact form or a sign-up is `defineForm` in TypeScript, and `handle` calls a
404
- function registered here. `rsckit.InvalidField` shows under that field.
403
+ A contact form or a sign-up is `defineForm({ action: 'Contact.send' })` in
404
+ TypeScript: the fields come from the struct the function takes, with no schema
405
+ to write. `rsckit.InvalidField` shows under that field.
405
406
  [Public forms](/guides/public-forms#go) has the code.
406
407
 
407
408
  ## Production
package/guides/index.json CHANGED
@@ -192,7 +192,7 @@
192
192
  {
193
193
  "slug": "public-forms",
194
194
  "title": "Public forms",
195
- "description": "A contact form, a sign-up, a survey - drawn from a Standard Schema, checked in the browser and on the server, sent to any backend."
195
+ "description": "A contact form, a sign-up, a survey - drawn from a Standard Schema or a backend function, checked in the browser and on the server, sent to any backend."
196
196
  },
197
197
  {
198
198
  "slug": "pwa",
@@ -94,7 +94,6 @@ export default defineConfig({
94
94
  nitro({ preset: "bun", serveStatic: "inline" }),
95
95
  rscKit({
96
96
  sourceDir: "src",
97
- outDir: "build",
98
97
  offline: true,
99
98
  openapi: { info: { title: 'Example API', version: '1.0.0' } },
100
99
  // On every page, and still served from an edge: see the edge contract.
package/guides/isr.md CHANGED
@@ -41,7 +41,9 @@ a page twice:
41
41
  curl -sI http://localhost:3000/posts/hello | grep -iE 'x-rsc-kit|^age|cache-status'
42
42
  ```
43
43
 
44
- The second answer has `X-RSC-Kit: cached` and an `Age`.
44
+ The second answer has `X-RSC-Kit: cached` and an `Age`. On Homeport the edge
45
+ keeps the page instead. From its next engine release, its entry in
46
+ `Cache-Status` [says whether it answered](/guides/edge-caching#cache-status-on-homeport).
45
47
 
46
48
  If it has `Cache-Status: rsc-kit; fwd=bypass; detail=cookies` instead, the page
47
49
  was sent private, and `detail` says why. The server log says it once per page,
package/guides/laravel.md CHANGED
@@ -429,9 +429,9 @@ purges the CDN as well, after the transaction commits and the response has gone.
429
429
 
430
430
  ## Public forms
431
431
 
432
- A contact form or a sign-up is `defineForm` in TypeScript, and `handle` calls a
433
- class under `app/Rsc` whose `FormRequest` validates it. What the rules refuse
434
- shows under each field. [Public forms](/guides/public-forms#laravel) has the
432
+ A contact form or a sign-up is `defineForm({ action: 'Contact.send' })` in
433
+ TypeScript: the fields come from the `FormRequest` on that method, with no schema
434
+ to write. What the rules refuse shows under each field. [Public forms](/guides/public-forms#laravel) has the
435
435
  code.
436
436
 
437
437
  ## Route middleware
@@ -1,6 +1,6 @@
1
1
  # Public forms
2
2
 
3
- > A contact form, a sign-up, a survey - drawn from a Standard Schema, checked in the browser and on the server, sent to any backend.
3
+ > A contact form, a sign-up, a survey - drawn from a Standard Schema or a backend function, checked in the browser and on the server, sent to any backend.
4
4
 
5
5
  `@rsc-kit/press/forms` turns a Standard Schema into a form anyone may fill in.
6
6
  It is the panel's form without the panel: the same fields read from the same
@@ -74,34 +74,50 @@ handle: async ({ email }) => {
74
74
 
75
75
  ## A Laravel or Go backend
76
76
 
77
- The form stays in TypeScript, because the schema is what draws it and what the
78
- browser checks. `handle` hands the values to your backend with `rpc()`, and the
79
- backend validates and saves them. Only the `handle` line changes:
77
+ Name the function, and the form needs no schema of its own. The backend already
78
+ says what the function takes, so the fields and the browser's checks come from
79
+ there, and every check that counts is the backend's:
80
80
 
81
81
  ```ts title="resources/js/forms/contact.ts"
82
- import * as z from 'zod'
83
82
  import { defineForm } from '@rsc-kit/press/forms'
84
83
  import { shadcn } from '@rsc-kit/press/shadcn'
85
84
 
86
85
  export const contact = defineForm({
87
86
  name: 'contact',
88
- form: z.object({
89
- name: z.string().min(2),
90
- email: z.email(),
91
- message: z.string().min(10).max(2000),
92
- }),
87
+ action: 'Contact.send',
93
88
  fields: { message: { type: 'textarea' } },
94
89
  theme: shadcn,
95
90
  submit: 'Send message',
96
91
  done: 'Thanks - we will be in touch.',
97
- handle: (values) => rpc('Contact.send', values),
98
92
  })
99
93
  ```
100
94
 
95
+ `action` is typed from the backend's functions, so a misspelt name fails the
96
+ typecheck. `fields` still sets a label or a control, and the bot trap, `done`
97
+ and `redirect` work as on any form. There is no `handle`: the values go to the
98
+ function. Nothing reaches the browser but the form, and no validation library
99
+ is added to the server.
100
+
101
+ The function must take one object with named fields: a `FormRequest` in Laravel,
102
+ a struct in Go. A form calling anything else says so when it first renders. So
103
+ does a field it cannot draw, such as a file: an action's values travel as JSON,
104
+ so an upload needs `form` and `handle`. Give an open-typed field a control in
105
+ `fields`.
106
+
107
+ To check something in TypeScript first, or to shape the values on the way, keep
108
+ a schema and call the backend yourself:
109
+
110
+ ```ts
111
+ form: z.object({ email: z.email() }),
112
+ handle: (values) => rpc('Contact.send', values),
113
+ ```
114
+
115
+ The schema's checks then run first, so a submission it refuses never reaches the
116
+ backend.
117
+
101
118
  The values arrive as one object, keyed by field. What the backend refuses comes
102
119
  back under the field of the same name, with what was typed kept, and there is
103
- nothing to catch. The schema's checks run first, so a submission it refuses
104
- never reaches the backend.
120
+ nothing to catch.
105
121
 
106
122
  ### Laravel
107
123
 
@@ -151,8 +167,18 @@ and call `Validator::make($values, [...])->validate()`, or throw
151
167
  `ValidationException::withMessages(['email' => 'That address is blocked.'])`.
152
168
  Either lands the same way.
153
169
 
154
- Keep the class under `app/Rsc`, and `rpc('Contact.send', ...)` is typed from it
155
- at the next build.
170
+ Keep the class under `app/Rsc`, and `action` and `rpc('Contact.send', ...)` are
171
+ typed from it at the next build.
172
+
173
+ The form's fields are read from `rules()`, in order, at build time: `required`,
174
+ the type rules, `email`, `url`, `date`, `min`, `max`, `size`, `between`, and
175
+ `in` or `Rule::in()`, which draws a select. Anything else stays the server's
176
+ check alone, and its field a plain input: `regex` (PCRE is not the browser's
177
+ pattern), `Rule::enum()`, a closure. `rules()` runs with no request behind it,
178
+ so one that reads the request cannot be described: list the fields in `fields`.
179
+
180
+ `rsc:install` does not set up Tailwind or shadcn, so the `shadcn` theme comes out
181
+ unstyled until the app has both.
156
182
 
157
183
  ### Go
158
184
 
@@ -184,15 +210,34 @@ return rsckit.Invalid(map[string][]string{
184
210
  })
185
211
  ```
186
212
 
187
- `reg.WriteManifest("rsc-host.json")` types `rpc('Contact.send', ...)` for the
188
- app, as with any function.
213
+ `reg.WriteManifest("rsc-host.json")` types `action` and `rpc('Contact.send', ...)`
214
+ for the app, as with any function.
215
+
216
+ The form's fields are the struct's, in its order, and a field is required unless
217
+ its `json` tag says `omitempty`. A `validate` tag, in go-playground/validator's
218
+ spelling, adds what the browser can check: `required`, `omitempty`, `email`,
219
+ `url`, `min`, `max`, `len`, `gte`, `lte`, `oneof` (a select) and
220
+ `datetime=2006-01-02`.
221
+
222
+ ```go
223
+ type ContactInput struct {
224
+ Name string `json:"name" validate:"required,min=2"`
225
+ Email string `json:"email" validate:"required,email"`
226
+ Topic string `json:"topic" validate:"required,oneof=sales support"`
227
+ Message string `json:"message" validate:"required,min=10,max=2000"`
228
+ }
229
+ ```
230
+
231
+ **The tag is only read, never run.** `rsc-kit/go` depends on no validator, so
232
+ the function still checks what it was sent, with validator or by hand: a post
233
+ need not come from a browser.
189
234
 
190
235
  ### On a kept page
191
236
 
192
237
  A public form can sit in an [ISR](/guides/isr) page. The page is kept for
193
238
  everyone, and the post is the visitor's own: it needs no token, because the
194
239
  engine and Laravel 13 accept a same-origin post by its `Sec-Fetch-Site` header.
195
- The `rpc()` in `handle` runs in that post, so it carries the visitor's cookie,
240
+ The call to the backend runs in that post, so it carries the visitor's cookie,
196
241
  unlike the calls the kept page made while rendering.
197
242
 
198
243
  ## Once it is sent
@@ -323,6 +323,13 @@ are `optional`, a variadic `rest`, and its `result`, each a JSON Schema;
323
323
  "defs": { "Order": { "type": "object", "properties": { "id": { "type": "integer" } }, "required": ["id"] } }
324
324
  ```
325
325
 
326
+ A function taking one object with `properties` can be [a form with no
327
+ schema](/guides/public-forms#a-laravel-or-go-backend), read from these same
328
+ types: `required`, `format` (`email`, `date`), `minLength`, `maxLength`,
329
+ `minimum`, `maximum` and `enum` become its fields and browser checks. The
330
+ properties are drawn in the order written. If your language's JSON sorts a map,
331
+ say the order with `"x-order": ["name", "email"]` beside them.
332
+
326
333
  The build writes `server-actions.generated.ts` in the source directory
327
334
  exporting each action, so a client component imports `ordersCancel` and
328
335
  calls it, and types `rpc()`'s first argument with the functions. Have Vite
@@ -440,6 +447,8 @@ It checks the whole contract on this page:
440
447
  dotted paths and the form's under `""`, redirects, revalidation staying
441
448
  with its call, a crash staying a failure, and arguments that do not fit
442
449
  failing rather than refusing;
450
+ - **forms** - a function taking one object, its fields in order with the hints
451
+ a browser can check, and a refusal landing on its field;
443
452
  - **the request** - `Cookie` and `Authorization` forwarded, a cookie set by a
444
453
  call reaching the page, no secret or the wrong one refused with 403, an
445
454
  unknown function 404, a malformed body 400;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsc-kit/mcp",
3
- "version": "0.30.47",
3
+ "version": "0.30.48",
4
4
  "description": "An MCP server over what an rsc-kit build decided: the routes, why each one is static or not, and what it costs the browser.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@modelcontextprotocol/sdk": "^1.30.0",
37
- "create-rsc-kit": "^0.30.47",
37
+ "create-rsc-kit": "^0.30.48",
38
38
  "zod": "^3.25"
39
39
  },
40
40
  "devDependencies": {