@rsc-kit/mcp 0.30.51 → 0.30.52
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 +45 -13
- package/dist/recipes.js.map +1 -1
- package/guides/admin.md +35 -2
- package/guides/{public-forms.md → blueprints.md} +126 -23
- package/guides/go.md +6 -5
- package/guides/index.json +5 -5
- package/guides/isr.md +1 -1
- package/guides/laravel.md +9 -4
- package/guides/pages.md +1 -1
- package/guides/your-own-backend.md +1 -1
- package/package.json +2 -2
package/dist/recipes.js
CHANGED
|
@@ -2721,7 +2721,7 @@ its own: where the data lives, who may see it, whose it is. Full guides:
|
|
|
2721
2721
|
admin, admin-plugins. There is no @rsc-kit/admin any more - do not import it.
|
|
2722
2722
|
@rsc-kit/press defineResource, memorySource, perTenant, definePlugin, types
|
|
2723
2723
|
@rsc-kit/press/admin definePanel, resourceParams, recordParams, listSearch, pluginsSearch, AdminTheme
|
|
2724
|
-
@rsc-kit/press/forms
|
|
2724
|
+
@rsc-kit/press/forms defineBlueprint - a form defined once, drawn in pages and panels (how_to blueprints)
|
|
2725
2725
|
@rsc-kit/press/pages definePages - pages an editor builds from blocks (how_to pages)
|
|
2726
2726
|
@rsc-kit/press/shadcn shadcn (the theme; it draws panels and public forms)
|
|
2727
2727
|
|
|
@@ -2906,18 +2906,20 @@ the save. Export a function of options returning the plugin. Publish with
|
|
|
2906
2906
|
rsc-kit-admin-plugin.`,
|
|
2907
2907
|
},
|
|
2908
2908
|
{
|
|
2909
|
-
topic: '
|
|
2910
|
-
summary: 'A
|
|
2911
|
-
body: `
|
|
2912
|
-
|
|
2913
|
-
|
|
2909
|
+
topic: 'blueprints',
|
|
2910
|
+
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',
|
|
2911
|
+
body: `defineBlueprint turns a Standard Schema, or the backend's actions, into a
|
|
2912
|
+
form defined once - fields, checks, saves - drawn in any page with
|
|
2913
|
+
<contact.Form />, as an edit page with <profile.Form id={...} values={...} />,
|
|
2914
|
+
and as an admin resource's create and edit pages with
|
|
2915
|
+
defineResource({ form: profile }). Full guide: blueprints.
|
|
2914
2916
|
|
|
2915
2917
|
\`\`\`ts title="src/forms/contact.ts"
|
|
2916
2918
|
import * as z from 'zod'
|
|
2917
|
-
import {
|
|
2919
|
+
import { defineBlueprint } from '@rsc-kit/press/forms'
|
|
2918
2920
|
import { shadcn } from '@rsc-kit/press/shadcn'
|
|
2919
2921
|
|
|
2920
|
-
export const contact =
|
|
2922
|
+
export const contact = defineBlueprint({
|
|
2921
2923
|
name: 'contact', // unique; lowercase letters, digits, dashes
|
|
2922
2924
|
form: z.object({ name: z.string().min(2), email: z.email(), message: z.string().min(10) }),
|
|
2923
2925
|
fields: { message: { type: 'textarea' } }, // what the schema cannot say
|
|
@@ -2925,7 +2927,8 @@ export const contact = defineForm({
|
|
|
2925
2927
|
submit: 'Send message',
|
|
2926
2928
|
done: 'Thanks - we will be in touch.', // shown in place of the form
|
|
2927
2929
|
// redirect: '/thanks', // OR this; never both
|
|
2928
|
-
handle: async (values) => { await db.insert(messages).values(values) },
|
|
2930
|
+
handle: async (values) => { await db.insert(messages).values(values) }, // creates
|
|
2931
|
+
// update: async (values, key) => { ... }, // edits, when drawn with an id
|
|
2929
2932
|
})
|
|
2930
2933
|
\`\`\`
|
|
2931
2934
|
|
|
@@ -2946,10 +2949,28 @@ passed. A refusal handle() decides goes under its field:
|
|
|
2946
2949
|
import { fieldErrors } from '@rsc-kit/core/action'
|
|
2947
2950
|
if (await subscribed(email)) fieldErrors({ email: 'Already on the list.' })
|
|
2948
2951
|
|
|
2949
|
-
A
|
|
2952
|
+
EDITING A RECORD: give it update(values, key), and draw
|
|
2953
|
+
<profile.Form id={user.id} values={user} />. Only the blueprint's own fields
|
|
2954
|
+
of values reach the browser. THE KEY COMES BACK FROM THE BROWSER and anyone
|
|
2955
|
+
can post another: update must check the visitor may change that record (a
|
|
2956
|
+
FormRequest's authorize(), a comparison with the session's user). Drawn with
|
|
2957
|
+
an id and no update, or without one and no handle/create, it throws.
|
|
2958
|
+
honeypot: false drops the bot trap for a form only signed-in people reach.
|
|
2959
|
+
|
|
2960
|
+
IN A PANEL: defineResource<Row>()({ ..., form: blueprint }) - the panel's
|
|
2961
|
+
create and edit pages are the blueprint's form. A blueprint that saves (both
|
|
2962
|
+
create and update) saves the panel's records too, so source is only
|
|
2963
|
+
{ list, find, delete }; one that does not needs a whole source. Say fields and
|
|
2964
|
+
actions on the blueprint, never again on the resource (that throws).
|
|
2965
|
+
|
|
2966
|
+
A BACKEND, WITH NO SCHEMA: defineBlueprint({ name, actions: { create: contactSend }, theme }),
|
|
2950
2967
|
with contactSend imported from the generated server-actions module - the
|
|
2951
2968
|
action itself, never its name as a string (a string throws). No form, no
|
|
2952
|
-
handle, no zod.
|
|
2969
|
+
handle, no zod. actions is { create, update }, either or both: create's input
|
|
2970
|
+
draws the create form, update's the edit form, and update is called
|
|
2971
|
+
(values, key) - update(UpdateProfile $request, string $user) in Laravel,
|
|
2972
|
+
reading the key with $this->route('user'); func(ctx, in ProfileInput,
|
|
2973
|
+
id string) in Go. bunx rsc-kit make:form contactSend writes forms/contact.ts.
|
|
2953
2974
|
The action is a Laravel class in app/Rsc/Actions (Contact::send is
|
|
2954
2975
|
contactSend; a class in app/Rsc is rpc only and has no action) or Go's
|
|
2955
2976
|
reg.HandleAction("contactSend", "Contact.send", fn). Fields and browser checks
|
|
@@ -2970,8 +2991,19 @@ visitor ($request->ip()), as Go's rsckit.ClientIP(ctx) does. Behind a load
|
|
|
2970
2991
|
balancer or Cloudflare set RSC_TRUST_FORWARDED=1 on the renderer, or every
|
|
2971
2992
|
visitor arrives as the balancer.
|
|
2972
2993
|
|
|
2973
|
-
A THEME draws it with one component,
|
|
2974
|
-
@rsc-kit/press/forms)
|
|
2994
|
+
A THEME draws it with one component, BlueprintForm (type FormsTheme from
|
|
2995
|
+
@rsc-kit/press/forms), given action, fields, values, submit, done and
|
|
2996
|
+
honeypot; replace it with theme: { ...shadcn, BlueprintForm: Mine }.
|
|
2997
|
+
VISIBLE: fields: { company: { visible: { when: 'topic', is: 'sales' } } }
|
|
2998
|
+
shows a field only while another has one of the values in is (one or a
|
|
2999
|
+
list); not turns it round; neither means once the other is filled in or
|
|
3000
|
+
switched on. A hidden field is not sent or browser-checked, and the server
|
|
3001
|
+
drops one sent anyway, so the schema makes it optional. Laravel's
|
|
3002
|
+
required_if:topic,sales and Go's validate:"required_if=Topic sales" are read
|
|
3003
|
+
as visible, required when shown.
|
|
3004
|
+
FROM: fields: { slug: { from: { field: 'title' } } } fills the slug as the
|
|
3005
|
+
title is typed, until it is edited by hand; left empty, the server fills it.
|
|
3006
|
+
when and field name another field of the form, or startup fails.
|
|
2975
3007
|
SETUP is the panel's: bun add @rsc-kit/press, and
|
|
2976
3008
|
@import "@rsc-kit/press/shadcn.css" in the stylesheet.`,
|
|
2977
3009
|
},
|