@rsc-kit/mcp 0.30.51 → 0.30.53
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 +52 -16
- package/dist/recipes.js.map +1 -1
- package/guides/admin.md +35 -2
- package/guides/backend-answered-pages.md +5 -1
- package/guides/{public-forms.md → blueprints.md} +126 -23
- package/guides/deployment.md +28 -3
- package/guides/edge-caching.md +7 -3
- package/guides/go.md +7 -6
- package/guides/index.json +5 -5
- package/guides/isr.md +1 -1
- package/guides/laravel.md +10 -5
- package/guides/pages.md +1 -1
- package/guides/where-it-runs.md +1 -1
- package/guides/your-own-backend.md +4 -4
- package/package.json +2 -2
package/guides/admin.md
CHANGED
|
@@ -12,7 +12,7 @@ The package has three entry points:
|
|
|
12
12
|
|
|
13
13
|
- `@rsc-kit/press` - resources, data sources, tenants, plugins and blocks. Nothing here draws.
|
|
14
14
|
- `@rsc-kit/press/admin` - `definePanel`, and the url schemas its routes export.
|
|
15
|
-
- `@rsc-kit/press/forms` - `
|
|
15
|
+
- `@rsc-kit/press/forms` - `defineBlueprint`, for [blueprints](/guides/blueprints/): a form defined once, drawn in any page and as a resource's form.
|
|
16
16
|
- `@rsc-kit/press/pages` - `definePages`, for [pages an editor builds from blocks](/guides/pages/).
|
|
17
17
|
- `@rsc-kit/press/shadcn` - the shadcn theme, which draws both.
|
|
18
18
|
|
|
@@ -254,6 +254,39 @@ record, and so is a `create` that takes a key.
|
|
|
254
254
|
The backend does every check. The panel still refuses a relation the visitor
|
|
255
255
|
cannot see before the backend is asked.
|
|
256
256
|
|
|
257
|
+
### A blueprint as the form
|
|
258
|
+
|
|
259
|
+
The same form is often wanted outside the panel too: a settings page where
|
|
260
|
+
people edit their own profile, a sign-up that creates what the panel lists.
|
|
261
|
+
Define it once as a [blueprint](/guides/blueprints/), and hand it to the
|
|
262
|
+
resource as its `form`:
|
|
263
|
+
|
|
264
|
+
```ts
|
|
265
|
+
import { defineBlueprint } from '@rsc-kit/press/forms'
|
|
266
|
+
|
|
267
|
+
export const product = defineBlueprint({
|
|
268
|
+
name: 'product',
|
|
269
|
+
theme: shadcn,
|
|
270
|
+
actions: { create: productsStore, update: productsUpdate },
|
|
271
|
+
fields: { category_id: { relation: 'categories' } },
|
|
272
|
+
})
|
|
273
|
+
|
|
274
|
+
export const products = defineResource<Product>()({
|
|
275
|
+
name: 'products',
|
|
276
|
+
key: 'id',
|
|
277
|
+
title: 'name',
|
|
278
|
+
source: { list, find, delete: remove },
|
|
279
|
+
table: (col) => [col.text('name'), col.money('price')],
|
|
280
|
+
form: product,
|
|
281
|
+
})
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
The panel's create and edit pages are then the blueprint's fields, saved with
|
|
285
|
+
the blueprint's actions - or a schema blueprint's `handle` and `update` - and a
|
|
286
|
+
page draws the same form with `<product.Form />`, or
|
|
287
|
+
`<product.Form id={p.id} values={p} />` to edit. A blueprint that does not
|
|
288
|
+
save leaves it to a whole source.
|
|
289
|
+
|
|
257
290
|
### Choices that read as words
|
|
258
291
|
|
|
259
292
|
An enum's options are shown humanized - `'in_stock'` reads "In stock" in the
|
|
@@ -322,7 +355,7 @@ and, when the schema allows `null`, a **Remove** button that saves `null`.
|
|
|
322
355
|
names, does that.
|
|
323
356
|
|
|
324
357
|
The field works the same in a [block](/guides/pages/) and in a
|
|
325
|
-
[
|
|
358
|
+
[blueprint's form](/guides/blueprints/).
|
|
326
359
|
|
|
327
360
|
## Relations
|
|
328
361
|
|
|
@@ -108,7 +108,11 @@ browser → renderer ──render──▶ React
|
|
|
108
108
|
the React tree has it, React renders it; otherwise the backend does. Nothing
|
|
109
109
|
is half-and-half on one url. A dynamic root route that would also match one
|
|
110
110
|
of the backend's urls does not get it: name the backend's prefixes with
|
|
111
|
-
`backendPaths` and they go first.
|
|
111
|
+
`backendPaths` and they go first. The build lists them in
|
|
112
|
+
`.output/rsc-kit.json`, so a proxy in front can send them straight to the
|
|
113
|
+
backend without going through the renderer
|
|
114
|
+
([deployment](/hosts/deployment/#sending-the-backends-urls-past-the-renderer)).
|
|
115
|
+
A named prefix is also never a page to the
|
|
112
116
|
browser: a `Link`, `visit()` or `redirect()` to it loads the document and is
|
|
113
117
|
never prefetched, so it may bounce on to another site, as an OAuth start does
|
|
114
118
|
([redirects](/guides/redirects/#leaving-the-app)).
|
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Blueprints
|
|
2
2
|
|
|
3
|
-
> A
|
|
3
|
+
> A form defined once - fields, checks and saves - and drawn anywhere it is needed - a contact page, an edit page, an admin panel - from a Standard Schema or a backend's own actions.
|
|
4
4
|
|
|
5
|
-
`@rsc-kit/press/forms` turns a Standard Schema
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
`@rsc-kit/press/forms` turns a Standard Schema, or a backend's actions, into a
|
|
6
|
+
**blueprint**: a form's fields, its checks and what saving it does, defined
|
|
7
|
+
once. A page draws it with `<contact.Form />`, an edit page with
|
|
8
|
+
`<profile.Form id={user.id} values={user} />`, and an
|
|
9
|
+
[admin panel](/guides/admin/) draws its create and edit pages from it with
|
|
10
|
+
`defineResource({ form: profile })` - the same fields, the same browser
|
|
11
|
+
checks, the same refusals under the same fields. A
|
|
12
|
+
[theme](/guides/admin/#themes) draws it; the `shadcn` theme draws both.
|
|
9
13
|
|
|
10
|
-
On a Laravel or Go backend there is no schema to write:
|
|
11
|
-
|
|
14
|
+
On a Laravel or Go backend there is no schema to write: hand it the backend's
|
|
15
|
+
actions, and the form is drawn from what they take. See
|
|
12
16
|
[A Laravel or Go backend](#a-laravel-or-go-backend).
|
|
13
17
|
|
|
14
18
|
```ts title="src/forms/contact.ts"
|
|
15
19
|
import * as z from 'zod'
|
|
16
|
-
import {
|
|
20
|
+
import { defineBlueprint } from '@rsc-kit/press/forms'
|
|
17
21
|
import { shadcn } from '@rsc-kit/press/shadcn'
|
|
18
22
|
|
|
19
|
-
export const contact =
|
|
23
|
+
export const contact = defineBlueprint({
|
|
20
24
|
name: 'contact',
|
|
21
25
|
form: z.object({
|
|
22
26
|
name: z.string().min(2),
|
|
@@ -55,6 +59,65 @@ Install is the panel's: `bun add @rsc-kit/press`, and the
|
|
|
55
59
|
`@import "@rsc-kit/press/shadcn.css"` line in the app's stylesheet, as in
|
|
56
60
|
[Admin panels](/guides/admin/#install).
|
|
57
61
|
|
|
62
|
+
## Editing a record
|
|
63
|
+
|
|
64
|
+
Give the blueprint an `update`, and `<profile.Form />` with an `id` edits that
|
|
65
|
+
record instead of creating one, starting from `values`:
|
|
66
|
+
|
|
67
|
+
```ts title="src/forms/profile.ts"
|
|
68
|
+
export const profile = defineBlueprint({
|
|
69
|
+
name: 'profile',
|
|
70
|
+
form: z.object({ name: z.string().min(2), email: z.email() }),
|
|
71
|
+
theme: shadcn,
|
|
72
|
+
honeypot: false,
|
|
73
|
+
done: 'Saved.',
|
|
74
|
+
update: async (values, key) => {
|
|
75
|
+
await db.update(users).set(values).where(eq(users.id, key))
|
|
76
|
+
},
|
|
77
|
+
})
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
```tsx title="src/app/settings/page.tsx"
|
|
81
|
+
export default async function Settings() {
|
|
82
|
+
const user = await currentUser()
|
|
83
|
+
|
|
84
|
+
return <profile.Form id={user.id} values={user} />
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Only the blueprint's own fields of `values` reach the browser, so handing it
|
|
89
|
+
a whole row does not put its password hash in the page.
|
|
90
|
+
|
|
91
|
+
**The key comes back from the browser**, like every field, and anyone can post
|
|
92
|
+
another. `update` must check the visitor may change that record - here, by
|
|
93
|
+
comparing it with the session's user; in Laravel, the `FormRequest`'s
|
|
94
|
+
`authorize()`. A blueprint may have `handle`, `update` or both, and drawing it
|
|
95
|
+
for one it does not have says so.
|
|
96
|
+
|
|
97
|
+
`honeypot: false` drops the bot trap for a form only signed-in people reach.
|
|
98
|
+
|
|
99
|
+
## In an admin panel
|
|
100
|
+
|
|
101
|
+
A resource takes the blueprint as its `form`, and its create and edit pages are
|
|
102
|
+
that blueprint's form:
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
export const people = defineResource<User>()({
|
|
106
|
+
name: 'people',
|
|
107
|
+
key: 'id',
|
|
108
|
+
title: 'name',
|
|
109
|
+
source: { list, find, delete: remove },
|
|
110
|
+
table: (col) => [col.text('name'), col.text('email')],
|
|
111
|
+
form: profile,
|
|
112
|
+
})
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
A blueprint that saves - a backend's `create` and `update`, or a schema's
|
|
116
|
+
`handle` and `update` - saves the panel's records too, so the source only
|
|
117
|
+
lists, finds and deletes. One that does not leaves saving to a whole
|
|
118
|
+
[source](/guides/admin/). `fields` and `actions` are said on the blueprint,
|
|
119
|
+
not again on the resource.
|
|
120
|
+
|
|
58
121
|
## What is checked, and where
|
|
59
122
|
|
|
60
123
|
The schema's constraints become the browser's - `required`, `minlength`,
|
|
@@ -76,21 +139,48 @@ handle: async ({ email }) => {
|
|
|
76
139
|
},
|
|
77
140
|
```
|
|
78
141
|
|
|
142
|
+
## Fields that depend on others
|
|
143
|
+
|
|
144
|
+
Two things a field can say about another, in `fields`, as plain data: the
|
|
145
|
+
browser applies them while the visitor types, and the server applies them again
|
|
146
|
+
to what was sent.
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
fields: {
|
|
150
|
+
company: { visible: { when: 'topic', is: 'sales' } },
|
|
151
|
+
slug: { from: { field: 'title' } },
|
|
152
|
+
},
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**`visible`** shows a field only while another has one of the values in `is` -
|
|
156
|
+
one value or a list. `not` turns it round, and with neither the field shows
|
|
157
|
+
once the other is filled in, or a switch is on. A hidden field is not sent, and
|
|
158
|
+
the browser does not check it; if a post sends one anyway, the server drops it
|
|
159
|
+
before the schema sees it. So a field asked only sometimes is optional to the
|
|
160
|
+
schema - `z.string().min(2).optional()` - and checked whenever it is there.
|
|
161
|
+
|
|
162
|
+
**`from`** fills a field with the slug of another - "Café & Bar" is
|
|
163
|
+
`cafe-bar` - as the other is typed. Once someone edits it by hand it is left
|
|
164
|
+
alone, and one left empty is filled the same way on the server.
|
|
165
|
+
|
|
166
|
+
`when` and `field` name another of the form's fields, and one that does not
|
|
167
|
+
exist fails at startup.
|
|
168
|
+
|
|
79
169
|
## A Laravel or Go backend
|
|
80
170
|
|
|
81
|
-
Give it the backend's
|
|
82
|
-
backend already says what
|
|
83
|
-
|
|
84
|
-
|
|
171
|
+
Give it the backend's actions, and the form needs no schema of its own. The
|
|
172
|
+
backend already says what each takes, so the fields and the browser's checks
|
|
173
|
+
come from there, and every check that counts is the backend's. The actions are
|
|
174
|
+
the ones the build generated, imported like any other:
|
|
85
175
|
|
|
86
176
|
```ts title="resources/js/forms/contact.ts"
|
|
87
|
-
import {
|
|
177
|
+
import { defineBlueprint } from '@rsc-kit/press/forms'
|
|
88
178
|
import { shadcn } from '@rsc-kit/press/shadcn'
|
|
89
179
|
import { contactSend } from '../server-actions.generated'
|
|
90
180
|
|
|
91
|
-
export const contact =
|
|
181
|
+
export const contact = defineBlueprint({
|
|
92
182
|
name: 'contact',
|
|
93
|
-
|
|
183
|
+
actions: { create: contactSend },
|
|
94
184
|
fields: { message: { type: 'textarea' } },
|
|
95
185
|
theme: shadcn,
|
|
96
186
|
submit: 'Send message',
|
|
@@ -98,6 +188,13 @@ export const contact = defineForm({
|
|
|
98
188
|
})
|
|
99
189
|
```
|
|
100
190
|
|
|
191
|
+
`actions` is `{ create, update }`, either or both. The create form is drawn
|
|
192
|
+
from what `create` takes and the edit form from what `update` takes, so a
|
|
193
|
+
password required to sign up can be optional to edit. `update` is called with
|
|
194
|
+
the record's key after the values: `update(UpdateProfile $request, string
|
|
195
|
+
$user)` in Laravel, where `$this->route('user')` reads it in `rules()` and
|
|
196
|
+
`authorize()`, and `func(ctx, in ProfileInput, id string)` in Go.
|
|
197
|
+
|
|
101
198
|
You need not write it: `bunx rsc-kit make:form contactSend` writes this file
|
|
102
199
|
from the action, and it is yours to edit from then on.
|
|
103
200
|
|
|
@@ -187,6 +284,9 @@ check alone, and its field a plain input: `regex` (PCRE is not the browser's
|
|
|
187
284
|
pattern), `Rule::enum()`, a closure. `rules()` runs with no request behind it,
|
|
188
285
|
so one that reads the request cannot be described: list the fields in `fields`.
|
|
189
286
|
|
|
287
|
+
`required_if:topic,support` is read as `visible`: the field shows while `topic`
|
|
288
|
+
is `support`, or any of the values listed after it, and is required then.
|
|
289
|
+
|
|
190
290
|
`rsc:install` does not set up Tailwind or shadcn, so the `shadcn` theme comes out
|
|
191
291
|
unstyled until the app has both.
|
|
192
292
|
|
|
@@ -227,7 +327,9 @@ The form's fields are the struct's, in its order, and a field is required unless
|
|
|
227
327
|
its `json` tag says `omitempty`. A `validate` tag, in go-playground/validator's
|
|
228
328
|
spelling, adds what the browser can check: `required`, `omitempty`, `email`,
|
|
229
329
|
`url`, `min`, `max`, `len`, `gte`, `lte`, `oneof` (a select) and
|
|
230
|
-
`datetime=2006-01-02`.
|
|
330
|
+
`datetime=2006-01-02`. `required_if=Topic support` is read as `visible`: the
|
|
331
|
+
field shows while `topic` is `support`, and is required then. Only one field and
|
|
332
|
+
one value - several pairs must all hold, which a form cannot show as one.
|
|
231
333
|
|
|
232
334
|
```go
|
|
233
335
|
type ContactInput struct {
|
|
@@ -244,7 +346,7 @@ need not come from a browser.
|
|
|
244
346
|
|
|
245
347
|
### On a kept page
|
|
246
348
|
|
|
247
|
-
A
|
|
349
|
+
A blueprint's form can sit in an [ISR](/guides/isr) page. The page is kept for
|
|
248
350
|
everyone, and the post is the visitor's own: it needs no token, because the
|
|
249
351
|
engine and Laravel 13 accept a same-origin post by its `Sec-Fetch-Site` header.
|
|
250
352
|
The call to the backend runs in that post, so it carries the visitor's cookie,
|
|
@@ -275,11 +377,12 @@ The trap is named `homepage`, so a form cannot have a field of that name.
|
|
|
275
377
|
|
|
276
378
|
## Drawing it yourself
|
|
277
379
|
|
|
278
|
-
The theme's part is one component, `
|
|
380
|
+
The theme's part is one component, `BlueprintForm`, typed `FormsTheme` from
|
|
279
381
|
`@rsc-kit/press/forms`. It is given the bound `action`, the `fields`, the
|
|
280
|
-
`submit` words, `done`, and the `honeypot` field's
|
|
281
|
-
|
|
382
|
+
starting `values`, the `submit` words, `done`, and the `honeypot` field's
|
|
383
|
+
name to render hidden - absent when the blueprint turned it off. Replace it
|
|
384
|
+
as you would a panel page:
|
|
282
385
|
|
|
283
386
|
```ts
|
|
284
|
-
theme: { ...shadcn,
|
|
387
|
+
theme: { ...shadcn, BlueprintForm: MyForm },
|
|
285
388
|
```
|
package/guides/deployment.md
CHANGED
|
@@ -293,9 +293,34 @@ code that decided; refuse a deploy where the two disagree:
|
|
|
293
293
|
both.
|
|
294
294
|
- **`output: "export"`** - `dir` is the static site; serve it as files.
|
|
295
295
|
|
|
296
|
-
|
|
297
|
-
`commands`, the app's [commands](/guides/commands)
|
|
298
|
-
`info`.
|
|
296
|
+
Two fields are only in the build's file, because only the build knows them:
|
|
297
|
+
`commands`, the app's [commands](/guides/commands), and `backendPaths`. Compare
|
|
298
|
+
the rest with `info`.
|
|
299
|
+
|
|
300
|
+
### Sending the backend's urls past the renderer
|
|
301
|
+
|
|
302
|
+
`backendPaths` is the app's
|
|
303
|
+
[`rscKit({ backendPaths })`](/hosts/backend-answered-pages/), normalised, and
|
|
304
|
+
`[]` when it names none, so a proxy can tell "none" from a build too old to say
|
|
305
|
+
(before 0.30.53). The renderer forwards those urls to the backend anyway, but
|
|
306
|
+
every request it forwards costs its CPU and memory and is cut off by its
|
|
307
|
+
timeouts. A proxy in front can send them straight to the backend:
|
|
308
|
+
|
|
309
|
+
```json
|
|
310
|
+
{ "version": "0.30.53", "output": "server", "backendPaths": ["/auth", "/github"] }
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
- A path equal to a prefix, or under it (`/auth`, `/auth/callback`, but not
|
|
314
|
+
`/authors`), goes to the backend, for every method.
|
|
315
|
+
- Everything else goes to the renderer.
|
|
316
|
+
- The host-call endpoint (`/__rsc/host-call`, or `RSC_HOST_CALL_PATH`) is
|
|
317
|
+
refused from outside. Only the renderer calls it, straight to the backend.
|
|
318
|
+
The build refuses a `backendPaths` entry that would cover it, and the
|
|
319
|
+
renderer answers a browser's request for it with its not-found page instead
|
|
320
|
+
of forwarding it.
|
|
321
|
+
|
|
322
|
+
The same list is `build.backendPaths` in the `routes.json` beside the entries,
|
|
323
|
+
for a host that reads the route table.
|
|
299
324
|
|
|
300
325
|
### Pages an edge may serve from its cache
|
|
301
326
|
|
package/guides/edge-caching.md
CHANGED
|
@@ -211,11 +211,15 @@ vendors. A purge that fails is logged and never fails the change: the CDN
|
|
|
211
211
|
still drops its copy at its `max-age` in `CDN-Cache-Control`. `purge({ tags, paths, all })` sends
|
|
212
212
|
one yourself, from a deploy step or a webhook.
|
|
213
213
|
|
|
214
|
-
|
|
215
|
-
|
|
214
|
+
With `RSC_PURGE_URL` set, the hook is `homeportPurge()`, posting
|
|
215
|
+
`{"tags": [...]}` there, unless you installed another. On Homeport there is
|
|
216
|
+
nothing to set: it gives its apps `HOMEPORT_PURGE_URL`, which is read when
|
|
217
|
+
`RSC_PURGE_URL` is not. `RSC_PURGE_URL` is read from `@rsc-kit/core` 0.30.53,
|
|
218
|
+
`rsc-kit/go` v0.16.1 and `rsc-kit/laravel` 0.20.1; before those, only
|
|
219
|
+
`HOMEPORT_PURGE_URL` is. With a Laravel or Go
|
|
216
220
|
backend, the change is made there - `Rsc::changed()`, `reg.Changed()` - and
|
|
217
221
|
never passes through the engine, so the backend posts the purge itself; both
|
|
218
|
-
do when `
|
|
222
|
+
do when `RSC_PURGE_URL` is set. A tag with a comma or a space cannot go in the header, and
|
|
219
223
|
is left out with a warning.
|
|
220
224
|
|
|
221
225
|
Homeport's edge is stricter about what it keeps than the page's headers alone
|
package/guides/go.md
CHANGED
|
@@ -428,7 +428,7 @@ has the whole picture.
|
|
|
428
428
|
`export const revalidate = 60` keeps a page and refreshes it behind the visitor,
|
|
429
429
|
and `reg.Changed(ctx, "posts")` renders it again at once on every instance, when
|
|
430
430
|
it read that tag through `cache()`. A kept page calls Go as nobody: no `Cookie`,
|
|
431
|
-
no `Authorization`. With `
|
|
431
|
+
no `Authorization`. With `RSC_PURGE_URL` set, `Changed` purges the CDN as
|
|
432
432
|
well; `reg.SetPurger` replaces it. Call it after your transaction commits.
|
|
433
433
|
[ISR](/guides/isr) has the whole of it.
|
|
434
434
|
|
|
@@ -466,13 +466,13 @@ post need not come from a browser.
|
|
|
466
466
|
`bunx rsc-kit make:form contactSend` writes the form around it:
|
|
467
467
|
|
|
468
468
|
```ts title="src/forms/contact.ts"
|
|
469
|
-
import {
|
|
469
|
+
import { defineBlueprint } from '@rsc-kit/press/forms'
|
|
470
470
|
import { shadcn } from '@rsc-kit/press/shadcn'
|
|
471
471
|
import { contactSend } from '../server-actions.generated'
|
|
472
472
|
|
|
473
|
-
export const contact =
|
|
473
|
+
export const contact = defineBlueprint({
|
|
474
474
|
name: 'contact',
|
|
475
|
-
|
|
475
|
+
actions: { create: contactSend },
|
|
476
476
|
fields: { message: { type: 'textarea' } },
|
|
477
477
|
theme: shadcn,
|
|
478
478
|
done: 'Thanks - we will be in touch.',
|
|
@@ -490,8 +490,9 @@ export default function ContactPage() {
|
|
|
490
490
|
```
|
|
491
491
|
|
|
492
492
|
`oneof` draws a select, and a field is required unless its `json` tag says
|
|
493
|
-
`omitempty`.
|
|
494
|
-
|
|
493
|
+
`omitempty`. `required_if=Topic support` shows the field only while `topic` is
|
|
494
|
+
`support`. [Blueprints](/guides/blueprints#go) has every tag that is read.
|
|
495
|
+
It needs `@rsc-kit/press` 0.30.52 and `github.com/rsc-kit/go` v0.16.0.
|
|
495
496
|
|
|
496
497
|
## Production
|
|
497
498
|
|
package/guides/index.json
CHANGED
|
@@ -29,6 +29,11 @@
|
|
|
29
29
|
"title": "BAP vs Inertia",
|
|
30
30
|
"description": "Two ways to put React in front of Laravel, and when each is the right one."
|
|
31
31
|
},
|
|
32
|
+
{
|
|
33
|
+
"slug": "blueprints",
|
|
34
|
+
"title": "Blueprints",
|
|
35
|
+
"description": "A form defined once - fields, checks and saves - and drawn anywhere it is needed - a contact page, an edit page, an admin panel - from a Standard Schema or a backend's own actions."
|
|
36
|
+
},
|
|
32
37
|
{
|
|
33
38
|
"slug": "bun",
|
|
34
39
|
"title": "Running on Bun",
|
|
@@ -189,11 +194,6 @@
|
|
|
189
194
|
"title": "Partial prerendering",
|
|
190
195
|
"description": "Storing what every visitor sees the same, and rendering the rest per request."
|
|
191
196
|
},
|
|
192
|
-
{
|
|
193
|
-
"slug": "public-forms",
|
|
194
|
-
"title": "Public forms",
|
|
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
|
-
},
|
|
197
197
|
{
|
|
198
198
|
"slug": "pwa",
|
|
199
199
|
"title": "Progressive web apps",
|
package/guides/isr.md
CHANGED
|
@@ -147,7 +147,7 @@ and no `Authorization`, and a cookie the backend sets is dropped. In Laravel,
|
|
|
147
147
|
goes to every visitor. A page that shows who is signed in is not one to keep.
|
|
148
148
|
|
|
149
149
|
A form in a kept page still works: a same-origin post needs no token. See
|
|
150
|
-
[
|
|
150
|
+
[blueprints](/guides/blueprints#on-a-kept-page).
|
|
151
151
|
|
|
152
152
|
## On several instances
|
|
153
153
|
|
package/guides/laravel.md
CHANGED
|
@@ -423,7 +423,7 @@ sent after the transaction commits.
|
|
|
423
423
|
`export const revalidate = 60` keeps a page and refreshes it behind the visitor,
|
|
424
424
|
and `Rsc::changed('posts')` renders it again at once on every instance, when it
|
|
425
425
|
read that tag through `cache()`. A kept page calls PHP as nobody, so
|
|
426
|
-
`auth()->user()` is null there. With `
|
|
426
|
+
`auth()->user()` is null there. With `RSC_PURGE_URL` set, `Rsc::changed()`
|
|
427
427
|
purges the CDN as well, after the transaction commits and the response has gone.
|
|
428
428
|
[ISR](/guides/isr) has the whole of it.
|
|
429
429
|
|
|
@@ -483,13 +483,13 @@ class Contact
|
|
|
483
483
|
`bunx rsc-kit make:form contactSend` writes the form around it:
|
|
484
484
|
|
|
485
485
|
```ts title="resources/js/forms/contact.ts"
|
|
486
|
-
import {
|
|
486
|
+
import { defineBlueprint } from '@rsc-kit/press/forms'
|
|
487
487
|
import { shadcn } from '@rsc-kit/press/shadcn'
|
|
488
488
|
import { contactSend } from '../server-actions.generated'
|
|
489
489
|
|
|
490
|
-
export const contact =
|
|
490
|
+
export const contact = defineBlueprint({
|
|
491
491
|
name: 'contact',
|
|
492
|
-
|
|
492
|
+
actions: { create: contactSend },
|
|
493
493
|
fields: { message: { type: 'textarea' } },
|
|
494
494
|
theme: shadcn,
|
|
495
495
|
done: 'Thanks - we will be in touch.',
|
|
@@ -513,7 +513,7 @@ its 422 shows under the field, with what was typed kept. A field named in
|
|
|
513
513
|
`fields` that `rules()` does not have fails the typecheck.
|
|
514
514
|
|
|
515
515
|
A file field, or a check in TypeScript first, needs a schema and a `handle`
|
|
516
|
-
instead. [
|
|
516
|
+
instead. [Blueprints](/guides/blueprints#laravel) has the rest. `action`
|
|
517
517
|
taking the generated action, and `rsc-kit make:form`, need `@rsc-kit/press`
|
|
518
518
|
0.30.49, and the browser's checks from `rules()` need
|
|
519
519
|
`rsc-kit/laravel` 0.17; an older package draws the fields with `required` and
|
|
@@ -527,6 +527,11 @@ request's route parameter under that name, so
|
|
|
527
527
|
own value. [The admin guide](/guides/admin#the-backends-actions-as-the-form)
|
|
528
528
|
has it; it needs `@rsc-kit/press` 0.30.51 and `rsc-kit/laravel` 0.19.
|
|
529
529
|
|
|
530
|
+
A rule `required_if:topic,support` shows its field only while `topic` is
|
|
531
|
+
`support`, and requires it then; it needs `@rsc-kit/press` 0.30.52 and
|
|
532
|
+
`rsc-kit/laravel` 0.20. [Blueprints](/guides/blueprints#fields-that-depend-on-others)
|
|
533
|
+
has the rest.
|
|
534
|
+
|
|
530
535
|
## Route middleware
|
|
531
536
|
|
|
532
537
|
The renderer owns the route table, but Laravel still decides whether a route
|
package/guides/pages.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
`@rsc-kit/press/pages` lets an editor build pages in the [admin panel](/guides/admin/)
|
|
6
6
|
from blocks the app defines - a hero, a feature grid, a call to action, a
|
|
7
|
-
[
|
|
7
|
+
[blueprint's form](/guides/blueprints/) - and serves them from one catch-all
|
|
8
8
|
route. The blocks are the app's code and look like the rest of the site; what
|
|
9
9
|
is on a page, and in what order, is the editor's.
|
|
10
10
|
|
package/guides/where-it-runs.md
CHANGED
|
@@ -333,7 +333,7 @@ network. Off by default, and covered in [Offline](/guides/offline#surviving-with
|
|
|
333
333
|
The generated `package.json` pins an exact version rather than a range:
|
|
334
334
|
|
|
335
335
|
```json
|
|
336
|
-
"nitro": "3.0.
|
|
336
|
+
"nitro": "3.0.261103-rc"
|
|
337
337
|
```
|
|
338
338
|
|
|
339
339
|
Nitro's own `latest` tag is a dated prerelease, and it sorts **above** the plain
|
|
@@ -314,7 +314,7 @@ so no authorization is needed here beyond the secret.
|
|
|
314
314
|
**A purge, when a CDN keeps pages.** A `revalidate` page goes out with the
|
|
315
315
|
`Cache-Tag` of every `cache()` answer it used, and the names you change are
|
|
316
316
|
those tags. A change you make never passes through the renderer, so when
|
|
317
|
-
`
|
|
317
|
+
`RSC_PURGE_URL` is set, your backend tells the CDN itself: after the
|
|
318
318
|
version has moved - after the transaction commits, and after the call has
|
|
319
319
|
answered if you can - post
|
|
320
320
|
|
|
@@ -353,7 +353,7 @@ are `optional`, a variadic `rest`, and its `result`, each a JSON Schema;
|
|
|
353
353
|
```
|
|
354
354
|
|
|
355
355
|
A function taking one object with `properties` can be [a form with no
|
|
356
|
-
schema](/guides/
|
|
356
|
+
schema](/guides/blueprints#a-laravel-or-go-backend), read from these same
|
|
357
357
|
types: `required`, `format` (`email`, `date`), `minLength`, `maxLength`,
|
|
358
358
|
`minimum`, `maximum` and `enum` become its fields and browser checks. The
|
|
359
359
|
properties are drawn in the order written. If your language's JSON sorts a map,
|
|
@@ -461,7 +461,7 @@ visitor to `/conformance-login`, and `conformance-page`, which passes only when
|
|
|
461
461
|
the page it is asked about is `/conformance/orders/7` with `{order}` bound to
|
|
462
462
|
`"7"`. Then serve them and run:
|
|
463
463
|
|
|
464
|
-
Start it with `
|
|
464
|
+
Start it with `RSC_PURGE_URL=http://127.0.0.1:8790/`, where the suite
|
|
465
465
|
listens for its purges, then:
|
|
466
466
|
|
|
467
467
|
```sh
|
|
@@ -493,7 +493,7 @@ It checks the whole contract on this page:
|
|
|
493
493
|
- **live data** - a name never changed at 0, a change moving it to a time in
|
|
494
494
|
milliseconds that never comes round again, only the names that differ
|
|
495
495
|
answered, and a held call bounded by `wait`;
|
|
496
|
-
- **purges** - a change posted to `
|
|
496
|
+
- **purges** - a change posted to `RSC_PURGE_URL` as its tag, as JSON,
|
|
497
497
|
only once the version has moved. Without `--purge-port` these fail: every
|
|
498
498
|
adapter purges.
|
|
499
499
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsc-kit/mcp",
|
|
3
|
-
"version": "0.30.
|
|
3
|
+
"version": "0.30.53",
|
|
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.53",
|
|
38
38
|
"zod": "^3.25"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|