@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/dist/recipes.js
CHANGED
|
@@ -689,8 +689,8 @@ cache(fn, { tags }) answer it used go out as Cache-Tag: posts,post:1, for a
|
|
|
689
689
|
CDN that purges by tag. changed(tag) calls the purge installed with
|
|
690
690
|
installPurge(async ({ tags }) => ...) from @rsc-kit/core/purge, after the
|
|
691
691
|
answer has gone - one hook, any CDN's API; a failure is logged, never fails
|
|
692
|
-
the change.
|
|
693
|
-
|
|
692
|
+
the change. With RSC_PURGE_URL set it is homeportPurge() with nothing to install; on
|
|
693
|
+
Homeport, which sets HOMEPORT_PURGE_URL, that is read when RSC_PURGE_URL is not. Rsc::changed() and reg.Changed() post their own purge
|
|
694
694
|
there, since a backend's change never passes through the engine. The host also keeps the page itself - ISR on every host: a
|
|
695
695
|
repeat request is answered from the kept copy (X-RSC-Kit: cached, Age); past
|
|
696
696
|
revalidate the stale copy goes out at once while one render replaces it;
|
|
@@ -1747,7 +1747,11 @@ app's 404 (and sign-in looped) - Laravel's /login and /auth/* as much as Go's
|
|
|
1747
1747
|
when the renderer is in front. Name the backend's prefixes, and they are
|
|
1748
1748
|
forwarded BEFORE any page is asked: rscKit({ backendPaths: ['/auth', '/github',
|
|
1749
1749
|
'/gitlab'] }). A prefix at a segment boundary (/auth, not /authors), every
|
|
1750
|
-
method; '/' and /
|
|
1750
|
+
method; '/', /_rsc and the host-call endpoint (/__rsc/host-call) are refused; a
|
|
1751
|
+
team called auth is then unreachable. The build lists them as backendPaths in
|
|
1752
|
+
.output/rsc-kit.json ([] when none), so a proxy in front sends them straight to
|
|
1753
|
+
the backend instead of through the renderer. The renderer never forwards a
|
|
1754
|
+
browser's request for the host-call endpoint: it answers with its not-found page. Do NOT
|
|
1751
1755
|
write catch-all route.ts files that forward by hand: that copies the forwarding.
|
|
1752
1756
|
A named prefix is also a DOCUMENT LOAD in the browser, never a page: a Link,
|
|
1753
1757
|
visit() or redirect('/gitlab/connect') to it loads the document and is
|
|
@@ -2721,7 +2725,7 @@ its own: where the data lives, who may see it, whose it is. Full guides:
|
|
|
2721
2725
|
admin, admin-plugins. There is no @rsc-kit/admin any more - do not import it.
|
|
2722
2726
|
@rsc-kit/press defineResource, memorySource, perTenant, definePlugin, types
|
|
2723
2727
|
@rsc-kit/press/admin definePanel, resourceParams, recordParams, listSearch, pluginsSearch, AdminTheme
|
|
2724
|
-
@rsc-kit/press/forms
|
|
2728
|
+
@rsc-kit/press/forms defineBlueprint - a form defined once, drawn in pages and panels (how_to blueprints)
|
|
2725
2729
|
@rsc-kit/press/pages definePages - pages an editor builds from blocks (how_to pages)
|
|
2726
2730
|
@rsc-kit/press/shadcn shadcn (the theme; it draws panels and public forms)
|
|
2727
2731
|
|
|
@@ -2906,18 +2910,20 @@ the save. Export a function of options returning the plugin. Publish with
|
|
|
2906
2910
|
rsc-kit-admin-plugin.`,
|
|
2907
2911
|
},
|
|
2908
2912
|
{
|
|
2909
|
-
topic: '
|
|
2910
|
-
summary: 'A
|
|
2911
|
-
body: `
|
|
2912
|
-
|
|
2913
|
-
|
|
2913
|
+
topic: 'blueprints',
|
|
2914
|
+
summary: 'A form defined once with defineBlueprint from @rsc-kit/press/forms - a contact form, a sign-up, an edit page, an admin resource\'s form - from a Standard Schema or the backend\'s actions: browser and server checks, a bot trap',
|
|
2915
|
+
body: `defineBlueprint turns a Standard Schema, or the backend's actions, into a
|
|
2916
|
+
form defined once - fields, checks, saves - drawn in any page with
|
|
2917
|
+
<contact.Form />, as an edit page with <profile.Form id={...} values={...} />,
|
|
2918
|
+
and as an admin resource's create and edit pages with
|
|
2919
|
+
defineResource({ form: profile }). Full guide: blueprints.
|
|
2914
2920
|
|
|
2915
2921
|
\`\`\`ts title="src/forms/contact.ts"
|
|
2916
2922
|
import * as z from 'zod'
|
|
2917
|
-
import {
|
|
2923
|
+
import { defineBlueprint } from '@rsc-kit/press/forms'
|
|
2918
2924
|
import { shadcn } from '@rsc-kit/press/shadcn'
|
|
2919
2925
|
|
|
2920
|
-
export const contact =
|
|
2926
|
+
export const contact = defineBlueprint({
|
|
2921
2927
|
name: 'contact', // unique; lowercase letters, digits, dashes
|
|
2922
2928
|
form: z.object({ name: z.string().min(2), email: z.email(), message: z.string().min(10) }),
|
|
2923
2929
|
fields: { message: { type: 'textarea' } }, // what the schema cannot say
|
|
@@ -2925,7 +2931,8 @@ export const contact = defineForm({
|
|
|
2925
2931
|
submit: 'Send message',
|
|
2926
2932
|
done: 'Thanks - we will be in touch.', // shown in place of the form
|
|
2927
2933
|
// redirect: '/thanks', // OR this; never both
|
|
2928
|
-
handle: async (values) => { await db.insert(messages).values(values) },
|
|
2934
|
+
handle: async (values) => { await db.insert(messages).values(values) }, // creates
|
|
2935
|
+
// update: async (values, key) => { ... }, // edits, when drawn with an id
|
|
2929
2936
|
})
|
|
2930
2937
|
\`\`\`
|
|
2931
2938
|
|
|
@@ -2946,10 +2953,28 @@ passed. A refusal handle() decides goes under its field:
|
|
|
2946
2953
|
import { fieldErrors } from '@rsc-kit/core/action'
|
|
2947
2954
|
if (await subscribed(email)) fieldErrors({ email: 'Already on the list.' })
|
|
2948
2955
|
|
|
2949
|
-
A
|
|
2956
|
+
EDITING A RECORD: give it update(values, key), and draw
|
|
2957
|
+
<profile.Form id={user.id} values={user} />. Only the blueprint's own fields
|
|
2958
|
+
of values reach the browser. THE KEY COMES BACK FROM THE BROWSER and anyone
|
|
2959
|
+
can post another: update must check the visitor may change that record (a
|
|
2960
|
+
FormRequest's authorize(), a comparison with the session's user). Drawn with
|
|
2961
|
+
an id and no update, or without one and no handle/create, it throws.
|
|
2962
|
+
honeypot: false drops the bot trap for a form only signed-in people reach.
|
|
2963
|
+
|
|
2964
|
+
IN A PANEL: defineResource<Row>()({ ..., form: blueprint }) - the panel's
|
|
2965
|
+
create and edit pages are the blueprint's form. A blueprint that saves (both
|
|
2966
|
+
create and update) saves the panel's records too, so source is only
|
|
2967
|
+
{ list, find, delete }; one that does not needs a whole source. Say fields and
|
|
2968
|
+
actions on the blueprint, never again on the resource (that throws).
|
|
2969
|
+
|
|
2970
|
+
A BACKEND, WITH NO SCHEMA: defineBlueprint({ name, actions: { create: contactSend }, theme }),
|
|
2950
2971
|
with contactSend imported from the generated server-actions module - the
|
|
2951
2972
|
action itself, never its name as a string (a string throws). No form, no
|
|
2952
|
-
handle, no zod.
|
|
2973
|
+
handle, no zod. actions is { create, update }, either or both: create's input
|
|
2974
|
+
draws the create form, update's the edit form, and update is called
|
|
2975
|
+
(values, key) - update(UpdateProfile $request, string $user) in Laravel,
|
|
2976
|
+
reading the key with $this->route('user'); func(ctx, in ProfileInput,
|
|
2977
|
+
id string) in Go. bunx rsc-kit make:form contactSend writes forms/contact.ts.
|
|
2953
2978
|
The action is a Laravel class in app/Rsc/Actions (Contact::send is
|
|
2954
2979
|
contactSend; a class in app/Rsc is rpc only and has no action) or Go's
|
|
2955
2980
|
reg.HandleAction("contactSend", "Contact.send", fn). Fields and browser checks
|
|
@@ -2970,8 +2995,19 @@ visitor ($request->ip()), as Go's rsckit.ClientIP(ctx) does. Behind a load
|
|
|
2970
2995
|
balancer or Cloudflare set RSC_TRUST_FORWARDED=1 on the renderer, or every
|
|
2971
2996
|
visitor arrives as the balancer.
|
|
2972
2997
|
|
|
2973
|
-
A THEME draws it with one component,
|
|
2974
|
-
@rsc-kit/press/forms)
|
|
2998
|
+
A THEME draws it with one component, BlueprintForm (type FormsTheme from
|
|
2999
|
+
@rsc-kit/press/forms), given action, fields, values, submit, done and
|
|
3000
|
+
honeypot; replace it with theme: { ...shadcn, BlueprintForm: Mine }.
|
|
3001
|
+
VISIBLE: fields: { company: { visible: { when: 'topic', is: 'sales' } } }
|
|
3002
|
+
shows a field only while another has one of the values in is (one or a
|
|
3003
|
+
list); not turns it round; neither means once the other is filled in or
|
|
3004
|
+
switched on. A hidden field is not sent or browser-checked, and the server
|
|
3005
|
+
drops one sent anyway, so the schema makes it optional. Laravel's
|
|
3006
|
+
required_if:topic,sales and Go's validate:"required_if=Topic sales" are read
|
|
3007
|
+
as visible, required when shown.
|
|
3008
|
+
FROM: fields: { slug: { from: { field: 'title' } } } fills the slug as the
|
|
3009
|
+
title is typed, until it is edited by hand; left empty, the server fills it.
|
|
3010
|
+
when and field name another field of the form, or startup fails.
|
|
2975
3011
|
SETUP is the panel's: bun add @rsc-kit/press, and
|
|
2976
3012
|
@import "@rsc-kit/press/shadcn.css" in the stylesheet.`,
|
|
2977
3013
|
},
|