@rsc-kit/mcp 0.40.0 → 0.41.0

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 CHANGED
@@ -129,7 +129,7 @@ Names that describe a shape build it: \`address.city\` nests, and
129
129
  \`items[0].name\` (or \`items[0][name]\`) makes an array of objects. That is
130
130
  the shape the schema was written against, and error() takes the same path.
131
131
 
132
- Binding a field - a rich editor, a Radix select, a value read as it is typed:
132
+ Binding a field - a rich editor, a select, a value read as it is typed:
133
133
 
134
134
  \`\`\`tsx
135
135
  <Form action={save} defaultValues={{ body: '' }}>
@@ -214,8 +214,10 @@ and point components.json at it.
214
214
 
215
215
  **shadcn/ui works as-is.** Input, Textarea, Button and Label are styled native
216
216
  elements, so \`name\` does what it always does. Select, Checkbox, Switch and
217
- RadioGroup are Radix underneath and render a hidden native control whenever
218
- given a \`name\` - omit it and they are invisible to the form.
217
+ RadioGroup render a hidden native control whenever given a \`name\`, on Base
218
+ UI and on Radix alike - omit it and they are invisible to the form. A Base UI
219
+ Select changes that control without an event; <Form> watches its controls, so
220
+ dirty and valid() still see the pick.
219
221
 
220
222
  Do NOT use shadcn's own Form/FormField/FormControl with this. Those wrap
221
223
  react-hook-form, a different system for the same job. One or the other.
@@ -1302,12 +1304,12 @@ data / validationErrors / serverError / redirected is set), so reading any
1302
1304
  field of it is safe. Do NOT wrap actions in a hook to catch
1303
1305
  ServerRedirectError; nothing throws.
1304
1306
 
1305
- A generated backend stub (Go/Laravel actions in server-actions.generated.ts) is
1307
+ A generated backend stub (Go/Laravel actions in src/server-actions/<class>.ts) is
1306
1308
  typed Promise<T | Redirected>, not an ActionResult: the redirect answer is
1307
1309
  { redirected } in place of T. Narrow with isRedirected from
1308
1310
  '@rsc-kit/core/errors' before reading it, and also before any "success" that
1309
1311
  follows an await of a void stub:
1310
- const secret = await databasesReveal(id)
1312
+ const secret = await databases.reveal(id)
1311
1313
  if (isRedirected(secret)) return
1312
1314
  Reading secret.Password first is a type error on purpose. A <Form> or
1313
1315
  useAction already skips onSuccess on a redirect.
@@ -1468,8 +1470,8 @@ WHAT EACH PIECE BECOMES
1468
1470
  router.visit / router.get -> visit(url) from @rsc-kit/core/router
1469
1471
  router.reload({ only }) -> Rsc::revalidate('orders') in the action re-renders that section with the answer
1470
1472
  router.post, useForm().post('/orders') -> a server action: php artisan make:rsc-action Orders --method=create --auth
1471
- --revalidate=orders, then <Form action={ordersCreate}> from @rsc-kit/core/form
1472
- (import ordersCreate from the generated actions module)
1473
+ --revalidate=orders, then <Form action={orders.create}> from @rsc-kit/core/form
1474
+ (import * as orders from './server-actions/orders', the module the build writes)
1473
1475
  useForm errors/processing -> <Form>'s errors (a FormRequest's ValidationException lands on the fields)
1474
1476
  and pending
1475
1477
  ->middleware(['auth','verified']) -> export const middleware = ['auth', 'verified'] in middleware.ts beside the page
@@ -1858,8 +1860,10 @@ A new app: bun create rsc-kit --backend=<url>, or rsc-kit init in an empty
1858
1860
  directory, which starts one there.
1859
1861
 
1860
1862
  The backend writes rsc-host.json at the project root (beside vite.config.ts):
1861
- { "actions": { jsName: "Function.name" }, "functions": ["Function.name", ...] }.
1862
- actions become "use server" stubs in src/server-actions.generated.ts;
1863
+ { "actions": { module: { export: "Function.name" } }, "functions": ["Function.name", ...] }.
1864
+ actions become "use server" modules, one per class: { "orders": { "create":
1865
+ "Orders.create" } } is src/server-actions/orders.ts exporting create, and an
1866
+ __invoke (or a Go function with no method) is the module's default export;
1863
1867
  functions type rpc()'s first argument, so a misspelt name fails tsc. rpc is a
1864
1868
  GLOBAL the build declares in .rsc-kit/rsc-env.d.ts - never import it. Have
1865
1869
  Vite write the manifest so it cannot go stale:
@@ -2008,8 +2012,11 @@ Server actions are classes in app/Rsc/Actions, found by reflection in PHP;
2008
2012
  functions } - and vite.config.ts runs it as dev and every build start:
2009
2013
  rscKit({ hostManifest: { command: ['php', 'artisan', 'rsc:host-manifest'] } }).
2010
2014
  functions types rpc()'s first argument, so a misspelt name fails tsc. The
2011
- build writes the "use server" stubs from actions - import ordersCancel from
2012
- the generated actions module in a client component. Rsc::revalidate('orders')
2015
+ build writes a "use server" module per class from actions - import * as
2016
+ orders from './server-actions/orders' in a client component, then
2017
+ orders.cancel(id); a nested class, Billing/Invoices, is server-actions/billing/invoices.
2018
+ An invokable class is the module's default: import sendInvite from
2019
+ './server-actions/send-invite'. server-actions/ is the build's: never edit it. Rsc::revalidate('orders')
2013
2020
  in the action returns the re-rendered region with the answer.
2014
2021
 
2015
2022
  Per url: if the React tree has it, React renders it, otherwise Laravel does
@@ -3020,7 +3027,7 @@ THE BACKEND'S ACTIONS AS THE FORM: when a FormRequest or a Go struct already
3020
3027
  says what a record takes, write NO schema. Give the generated actions instead
3021
3028
  of form, and the source only list/find/delete:
3022
3029
  source: { list, find, delete },
3023
- actions: { create: productsStore, update: productsUpdate },
3030
+ actions: { create: products.store, update: products.update }, // import * as products from '../server-actions/products'
3024
3031
  fields: { category_id: { relation: 'categories' } }, // the backend's names, typechecked
3025
3032
  form and actions are one or the other, never both. The create form is drawn
3026
3033
  from create's input, the edit form from update's. create(values); update(values,
@@ -3175,24 +3182,24 @@ create and update) saves the panel's records too, so source is only
3175
3182
  { list, find, delete }; one that does not needs a whole source. Say fields and
3176
3183
  actions on the blueprint, never again on the resource (that throws).
3177
3184
 
3178
- A BACKEND, WITH NO SCHEMA: defineBlueprint({ name, actions: { create: contactSend }, theme }),
3179
- with contactSend imported from the generated server-actions module - the
3185
+ A BACKEND, WITH NO SCHEMA: defineBlueprint({ name, actions: { create: send }, theme }),
3186
+ with import { send } from '../server-actions/contact' - the
3180
3187
  action itself, never its name as a string (a string throws). No form, no
3181
3188
  handle, no zod. actions is { create, update }, either or both: create's input
3182
3189
  draws the create form, update's the edit form, and update is called
3183
3190
  (values, key) - update(UpdateProfile $request, string $user) in Laravel,
3184
3191
  reading the key with $this->route('user'); func(ctx, in ProfileInput,
3185
- id string) in Go. bunx rsc-kit make:form contactSend writes forms/contact.ts.
3192
+ id string) in Go. bunx rsc-kit make:form Contact.send writes forms/contact.ts.
3186
3193
  The action is a Laravel class in app/Rsc/Actions (Contact::send is
3187
- contactSend; a class in app/Rsc is rpc only and has no action) or Go's
3188
- reg.HandleAction("contactSend", "Contact.send", fn). Fields and browser checks
3194
+ send in server-actions/contact; a class in app/Rsc is rpc only and has no action) or Go's
3195
+ reg.HandleAction("Contact.send", fn). Fields and browser checks
3189
3196
  come from what it takes (rsc-host.json): a Laravel FormRequest's rules(), or a
3190
3197
  Go struct, whose validate tags are read as hints and never run, so the Go
3191
3198
  function must still check. It takes one object; a file needs form and handle.
3192
3199
  A 422 from Laravel (a FormRequest type-hinted on the method, whose authorize()
3193
3200
  returns true) or Go (rsckit.InvalidField) lands under the same fields,
3194
3201
  uncaught. To check in TypeScript first, keep a schema and
3195
- handle: (values) => contactSend(values).
3202
+ handle: (values) => send(values).
3196
3203
 
3197
3204
  THE BOT TRAP: every form carries a hidden field named homepage. Filled in, the
3198
3205
  submission is answered as a success and dropped - handle() never runs. So a