@rsc-kit/mcp 0.30.47 → 0.30.49
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/dist/recipes.js +19 -4
- package/dist/recipes.js.map +1 -1
- package/guides/edge-caching.md +45 -0
- package/guides/go.md +58 -3
- package/guides/index.json +1 -1
- package/guides/installation.md +0 -1
- package/guides/isr.md +3 -1
- package/guides/laravel.md +87 -4
- package/guides/public-forms.md +77 -22
- package/guides/your-own-backend.md +9 -0
- package/package.json +2 -2
package/guides/edge-caching.md
CHANGED
|
@@ -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,9 +400,64 @@ 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
|
|
404
|
-
|
|
405
|
-
|
|
403
|
+
A contact form or a sign-up anyone may fill in is an action that takes a
|
|
404
|
+
struct, and a few lines of TypeScript handing that action to a form. There is
|
|
405
|
+
no schema to write: the fields and the browser's checks come from the struct.
|
|
406
|
+
|
|
407
|
+
**1. The action.** Its `json` tags are the field names, a `validate` tag adds
|
|
408
|
+
what the browser can check, and `rsckit.InvalidField` is a refusal under that
|
|
409
|
+
field:
|
|
410
|
+
|
|
411
|
+
```go
|
|
412
|
+
type ContactInput struct {
|
|
413
|
+
Name string `json:"name" validate:"required,min=2"`
|
|
414
|
+
Email string `json:"email" validate:"required,email"`
|
|
415
|
+
Topic string `json:"topic" validate:"required,oneof=sales support"`
|
|
416
|
+
Message string `json:"message" validate:"required,min=10,max=2000"`
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
reg.HandleAction("contactSend", "Contact.send", func(ctx context.Context, in ContactInput) error {
|
|
420
|
+
if blocked(in.Email) {
|
|
421
|
+
return rsckit.InvalidField("email", "That address is blocked.")
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
return messages.Insert(ctx, in)
|
|
425
|
+
})
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
The tag is read, never run: check what was sent in the function too, since a
|
|
429
|
+
post need not come from a browser.
|
|
430
|
+
|
|
431
|
+
**2. The form.** The build generates `contactSend` from the manifest, and
|
|
432
|
+
`bunx rsc-kit make:form contactSend` writes the form around it:
|
|
433
|
+
|
|
434
|
+
```ts title="src/forms/contact.ts"
|
|
435
|
+
import { defineForm } from '@rsc-kit/press/forms'
|
|
436
|
+
import { shadcn } from '@rsc-kit/press/shadcn'
|
|
437
|
+
import { contactSend } from '../server-actions.generated'
|
|
438
|
+
|
|
439
|
+
export const contact = defineForm({
|
|
440
|
+
name: 'contact',
|
|
441
|
+
action: contactSend,
|
|
442
|
+
fields: { message: { type: 'textarea' } },
|
|
443
|
+
theme: shadcn,
|
|
444
|
+
done: 'Thanks - we will be in touch.',
|
|
445
|
+
})
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
Then place it in a page, which stays static:
|
|
449
|
+
|
|
450
|
+
```tsx title="src/app/contact/page.tsx"
|
|
451
|
+
import { contact } from '../../forms/contact'
|
|
452
|
+
|
|
453
|
+
export default function ContactPage() {
|
|
454
|
+
return <contact.Form />
|
|
455
|
+
}
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
`oneof` draws a select, and a field is required unless its `json` tag says
|
|
459
|
+
`omitempty`. [Public forms](/guides/public-forms#go) has every tag that is read.
|
|
460
|
+
It needs `@rsc-kit/press` 0.30.49 and `github.com/rsc-kit/go` v0.14.0.
|
|
406
461
|
|
|
407
462
|
## Production
|
|
408
463
|
|
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",
|
package/guides/installation.md
CHANGED
|
@@ -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,10 +429,93 @@ 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
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
432
|
+
A contact form or a sign-up anyone may fill in is declared in three places: the
|
|
433
|
+
rules in a `FormRequest`, the action that takes it, and a few lines of
|
|
434
|
+
TypeScript handing that action to a form. There is no schema to write: the fields and the browser's
|
|
435
|
+
checks are read from `rules()`.
|
|
436
|
+
|
|
437
|
+
**1. The rules.** `php artisan make:request SendContact`, and let anyone send it:
|
|
438
|
+
|
|
439
|
+
```php title="app/Http/Requests/SendContact.php"
|
|
440
|
+
namespace App\Http\Requests;
|
|
441
|
+
|
|
442
|
+
use Illuminate\Foundation\Http\FormRequest;
|
|
443
|
+
|
|
444
|
+
class SendContact extends FormRequest
|
|
445
|
+
{
|
|
446
|
+
public function authorize(): bool
|
|
447
|
+
{
|
|
448
|
+
return true; // make:request writes false, which refuses everyone
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
public function rules(): array
|
|
452
|
+
{
|
|
453
|
+
return [
|
|
454
|
+
'name' => ['required', 'string', 'min:2'],
|
|
455
|
+
'email' => ['required', 'email', 'unique:subscribers,email'],
|
|
456
|
+
'topic' => ['required', 'in:sales,support'],
|
|
457
|
+
'message' => ['required', 'string', 'min:10', 'max:2000'],
|
|
458
|
+
];
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
**2. The action.** Under `app/Rsc/Actions`, taking the request alone:
|
|
464
|
+
|
|
465
|
+
```php title="app/Rsc/Actions/Contact.php"
|
|
466
|
+
namespace App\Rsc\Actions;
|
|
467
|
+
|
|
468
|
+
use App\Http\Requests\SendContact;
|
|
469
|
+
use App\Models\Message;
|
|
470
|
+
|
|
471
|
+
class Contact
|
|
472
|
+
{
|
|
473
|
+
public function send(SendContact $request): void
|
|
474
|
+
{
|
|
475
|
+
Message::create($request->validated());
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
**3. The form.** The build generates `contactSend` from the method, and
|
|
481
|
+
`bunx rsc-kit make:form contactSend` writes the form around it:
|
|
482
|
+
|
|
483
|
+
```ts title="resources/js/forms/contact.ts"
|
|
484
|
+
import { defineForm } from '@rsc-kit/press/forms'
|
|
485
|
+
import { shadcn } from '@rsc-kit/press/shadcn'
|
|
486
|
+
import { contactSend } from '../server-actions.generated'
|
|
487
|
+
|
|
488
|
+
export const contact = defineForm({
|
|
489
|
+
name: 'contact',
|
|
490
|
+
action: contactSend,
|
|
491
|
+
fields: { message: { type: 'textarea' } },
|
|
492
|
+
theme: shadcn,
|
|
493
|
+
done: 'Thanks - we will be in touch.',
|
|
494
|
+
})
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
Then place it in a page, which stays static:
|
|
498
|
+
|
|
499
|
+
```tsx title="resources/js/app/contact/page.tsx"
|
|
500
|
+
import { contact } from '../../forms/contact'
|
|
501
|
+
|
|
502
|
+
export default function ContactPage() {
|
|
503
|
+
return <contact.Form />
|
|
504
|
+
}
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
The fields are drawn in the order of `rules()`. `email`, `url`, `date`, `min`,
|
|
508
|
+
`max`, `size` and `between` become the browser's checks, and `in` or `Rule::in()`
|
|
509
|
+
draws a select. Everything else, `unique` included, is checked by Laravel alone:
|
|
510
|
+
its 422 shows under the field, with what was typed kept. A field named in
|
|
511
|
+
`fields` that `rules()` does not have fails the typecheck.
|
|
512
|
+
|
|
513
|
+
A file field, or a check in TypeScript first, needs a schema and a `handle`
|
|
514
|
+
instead. [Public forms](/guides/public-forms#laravel) has the rest. `action`
|
|
515
|
+
taking the generated action, and `rsc-kit make:form`, need `@rsc-kit/press`
|
|
516
|
+
0.30.49, and the browser's checks from `rules()` need
|
|
517
|
+
`rsc-kit/laravel` 0.17; an older package draws the fields with `required` and
|
|
518
|
+
their types only.
|
|
436
519
|
|
|
437
520
|
## Route middleware
|
|
438
521
|
|
package/guides/public-forms.md
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
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
|
|
7
7
|
schema, the same browser checks, the same refusals under the same fields - and
|
|
8
8
|
a [theme](/guides/admin/#themes) to draw it. The `shadcn` theme draws both.
|
|
9
9
|
|
|
10
|
+
On a Laravel or Go backend there is no schema to write: name the backend's
|
|
11
|
+
function, and the form is drawn from what it takes. See
|
|
12
|
+
[A Laravel or Go backend](#a-laravel-or-go-backend).
|
|
13
|
+
|
|
10
14
|
```ts title="src/forms/contact.ts"
|
|
11
15
|
import * as z from 'zod'
|
|
12
16
|
import { defineForm } from '@rsc-kit/press/forms'
|
|
@@ -74,34 +78,56 @@ handle: async ({ email }) => {
|
|
|
74
78
|
|
|
75
79
|
## A Laravel or Go backend
|
|
76
80
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
Give it the backend's action, and the form needs no schema of its own. The
|
|
82
|
+
backend already says what the action takes, so the fields and the browser's
|
|
83
|
+
checks come from there, and every check that counts is the backend's. The
|
|
84
|
+
action is the one the build generated, imported like any other:
|
|
80
85
|
|
|
81
86
|
```ts title="resources/js/forms/contact.ts"
|
|
82
|
-
import * as z from 'zod'
|
|
83
87
|
import { defineForm } from '@rsc-kit/press/forms'
|
|
84
88
|
import { shadcn } from '@rsc-kit/press/shadcn'
|
|
89
|
+
import { contactSend } from '../server-actions.generated'
|
|
85
90
|
|
|
86
91
|
export const contact = defineForm({
|
|
87
92
|
name: 'contact',
|
|
88
|
-
|
|
89
|
-
name: z.string().min(2),
|
|
90
|
-
email: z.email(),
|
|
91
|
-
message: z.string().min(10).max(2000),
|
|
92
|
-
}),
|
|
93
|
+
action: contactSend,
|
|
93
94
|
fields: { message: { type: 'textarea' } },
|
|
94
95
|
theme: shadcn,
|
|
95
96
|
submit: 'Send message',
|
|
96
97
|
done: 'Thanks - we will be in touch.',
|
|
97
|
-
handle: (values) => rpc('Contact.send', values),
|
|
98
98
|
})
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
+
You need not write it: `bunx rsc-kit make:form contactSend` writes this file
|
|
102
|
+
from the action, and it is yours to edit from then on.
|
|
103
|
+
|
|
104
|
+
An action that is not there fails the import, and a field `fields` names that
|
|
105
|
+
the action does not take fails the typecheck. `fields` still sets a label or a control, and the bot trap, `done`
|
|
106
|
+
and `redirect` work as on any form. There is no `handle`: the values go to the
|
|
107
|
+
function. Nothing reaches the browser but the form, and no validation library
|
|
108
|
+
is added to the server.
|
|
109
|
+
|
|
110
|
+
The action must take one object with named fields: a `FormRequest` in Laravel,
|
|
111
|
+
a struct in Go. A form given anything else says so when it first renders, as
|
|
112
|
+
does one given a function the build did not generate. So
|
|
113
|
+
does a field it cannot draw, such as a file: an action's values travel as JSON,
|
|
114
|
+
so an upload needs `form` and `handle`. Give an open-typed field a control in
|
|
115
|
+
`fields`.
|
|
116
|
+
|
|
117
|
+
To check something in TypeScript first, or to shape the values on the way, keep
|
|
118
|
+
a schema and call the backend yourself:
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
form: z.object({ email: z.email() }),
|
|
122
|
+
handle: (values) => contactSend(values),
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
The schema's checks then run first, so a submission it refuses never reaches the
|
|
126
|
+
backend.
|
|
127
|
+
|
|
101
128
|
The values arrive as one object, keyed by field. What the backend refuses comes
|
|
102
129
|
back under the field of the same name, with what was typed kept, and there is
|
|
103
|
-
nothing to catch.
|
|
104
|
-
never reaches the backend.
|
|
130
|
+
nothing to catch.
|
|
105
131
|
|
|
106
132
|
### Laravel
|
|
107
133
|
|
|
@@ -131,8 +157,8 @@ class SendContact extends FormRequest
|
|
|
131
157
|
}
|
|
132
158
|
```
|
|
133
159
|
|
|
134
|
-
```php title="app/Rsc/Contact.php"
|
|
135
|
-
namespace App\Rsc;
|
|
160
|
+
```php title="app/Rsc/Actions/Contact.php"
|
|
161
|
+
namespace App\Rsc\Actions;
|
|
136
162
|
|
|
137
163
|
use App\Http\Requests\SendContact;
|
|
138
164
|
use App\Models\Message;
|
|
@@ -151,12 +177,22 @@ and call `Validator::make($values, [...])->validate()`, or throw
|
|
|
151
177
|
`ValidationException::withMessages(['email' => 'That address is blocked.'])`.
|
|
152
178
|
Either lands the same way.
|
|
153
179
|
|
|
154
|
-
Keep the class under `app/Rsc`,
|
|
155
|
-
at the next build.
|
|
180
|
+
Keep the class under `app/Rsc/Actions`, where every public method is an action:
|
|
181
|
+
`Contact::send` is `contactSend`, generated at the next build.
|
|
182
|
+
|
|
183
|
+
The form's fields are read from `rules()`, in order, at build time: `required`,
|
|
184
|
+
the type rules, `email`, `url`, `date`, `min`, `max`, `size`, `between`, and
|
|
185
|
+
`in` or `Rule::in()`, which draws a select. Anything else stays the server's
|
|
186
|
+
check alone, and its field a plain input: `regex` (PCRE is not the browser's
|
|
187
|
+
pattern), `Rule::enum()`, a closure. `rules()` runs with no request behind it,
|
|
188
|
+
so one that reads the request cannot be described: list the fields in `fields`.
|
|
189
|
+
|
|
190
|
+
`rsc:install` does not set up Tailwind or shadcn, so the `shadcn` theme comes out
|
|
191
|
+
unstyled until the app has both.
|
|
156
192
|
|
|
157
193
|
### Go
|
|
158
194
|
|
|
159
|
-
Register
|
|
195
|
+
Register an action that takes the values as a struct. Its `json` tags are the
|
|
160
196
|
form's field names, and `rsckit.InvalidField` or `rsckit.Invalid` is the 422.
|
|
161
197
|
|
|
162
198
|
```go
|
|
@@ -166,7 +202,7 @@ type ContactInput struct {
|
|
|
166
202
|
Message string `json:"message"`
|
|
167
203
|
}
|
|
168
204
|
|
|
169
|
-
reg.
|
|
205
|
+
reg.HandleAction("contactSend", "Contact.send", func(ctx context.Context, in ContactInput) error {
|
|
170
206
|
if blocked(in.Email) {
|
|
171
207
|
return rsckit.InvalidField("email", "That address is blocked.")
|
|
172
208
|
}
|
|
@@ -184,15 +220,34 @@ return rsckit.Invalid(map[string][]string{
|
|
|
184
220
|
})
|
|
185
221
|
```
|
|
186
222
|
|
|
187
|
-
`reg.WriteManifest("rsc-host.json")`
|
|
188
|
-
|
|
223
|
+
`reg.WriteManifest("rsc-host.json")` puts it in the manifest, and the build
|
|
224
|
+
generates `contactSend` from it, as for any action.
|
|
225
|
+
|
|
226
|
+
The form's fields are the struct's, in its order, and a field is required unless
|
|
227
|
+
its `json` tag says `omitempty`. A `validate` tag, in go-playground/validator's
|
|
228
|
+
spelling, adds what the browser can check: `required`, `omitempty`, `email`,
|
|
229
|
+
`url`, `min`, `max`, `len`, `gte`, `lte`, `oneof` (a select) and
|
|
230
|
+
`datetime=2006-01-02`.
|
|
231
|
+
|
|
232
|
+
```go
|
|
233
|
+
type ContactInput struct {
|
|
234
|
+
Name string `json:"name" validate:"required,min=2"`
|
|
235
|
+
Email string `json:"email" validate:"required,email"`
|
|
236
|
+
Topic string `json:"topic" validate:"required,oneof=sales support"`
|
|
237
|
+
Message string `json:"message" validate:"required,min=10,max=2000"`
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
**The tag is only read, never run.** `rsc-kit/go` depends on no validator, so
|
|
242
|
+
the function still checks what it was sent, with validator or by hand: a post
|
|
243
|
+
need not come from a browser.
|
|
189
244
|
|
|
190
245
|
### On a kept page
|
|
191
246
|
|
|
192
247
|
A public form can sit in an [ISR](/guides/isr) page. The page is kept for
|
|
193
248
|
everyone, and the post is the visitor's own: it needs no token, because the
|
|
194
249
|
engine and Laravel 13 accept a same-origin post by its `Sec-Fetch-Site` header.
|
|
195
|
-
The
|
|
250
|
+
The call to the backend runs in that post, so it carries the visitor's cookie,
|
|
196
251
|
unlike the calls the kept page made while rendering.
|
|
197
252
|
|
|
198
253
|
## 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.
|
|
3
|
+
"version": "0.30.49",
|
|
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.
|
|
37
|
+
"create-rsc-kit": "^0.30.49",
|
|
38
38
|
"zod": "^3.25"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|