@rsc-kit/mcp 0.43.1 → 0.45.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 +31 -6
- package/dist/recipes.js.map +1 -1
- package/guides/coming-from-inertia.md +3 -3
- package/guides/errors.md +4 -0
- package/guides/forms.md +8 -4
- package/guides/redirects.md +9 -0
- package/guides/server-actions.md +3 -0
- package/package.json +2 -2
package/dist/recipes.js
CHANGED
|
@@ -542,7 +542,8 @@ useOptimisticAction through React's useOptimistic):
|
|
|
542
542
|
|
|
543
543
|
execute never throws (a thrown failure becomes serverError); a redirect runs no
|
|
544
544
|
callback and sets no state; execute keeps one identity and reads the newest
|
|
545
|
-
callbacks.
|
|
545
|
+
callbacks. A backend's generated stub takes useAction too -
|
|
546
|
+
useAction(verification.send) - and onSuccess gets what the backend returned.
|
|
546
547
|
|
|
547
548
|
An action body - arguments and any uploaded files, read whole - is capped at
|
|
548
549
|
8 MB; over it the answer is 413 before a byte is kept. rscKit({ maxActionBody })
|
|
@@ -1328,7 +1329,9 @@ follows an await of a void stub:
|
|
|
1328
1329
|
const secret = await databases.reveal(id)
|
|
1329
1330
|
if (isRedirected(secret)) return
|
|
1330
1331
|
Reading secret.Password first is a type error on purpose. A <Form> or
|
|
1331
|
-
useAction already skips onSuccess on a redirect
|
|
1332
|
+
useAction already skips onSuccess on a redirect - except one back to the page
|
|
1333
|
+
it was called from (Laravel's back(), Fortify's 2FA enable), which is the
|
|
1334
|
+
save succeeding: onSuccess runs and resetOnSuccess resets.
|
|
1332
1335
|
|
|
1333
1336
|
tsc does NOT see a redirect read as text: a template literal around a
|
|
1334
1337
|
string | Redirected compiles and goes to /t/[object Object]. The type-aware oxlint rules
|
|
@@ -1939,6 +1942,9 @@ A server ACTION that fails in development opens Vite's error overlay on the
|
|
|
1939
1942
|
page: the backend's exception as the heading, the app's own file:line (e.g.
|
|
1940
1943
|
app/Rsc/Actions/Notification.php:20) as its file, dependency frames counted.
|
|
1941
1944
|
Production answers a bare 500. Fix the line it names; the overlay is not a bug.
|
|
1945
|
+
An action answered by something other than the renderer (a 502 because the
|
|
1946
|
+
renderer is not running, a proxy's error) opens the overlay with the status and
|
|
1947
|
+
the answer's text. A page that throws opens it too, even reached by a link.
|
|
1942
1948
|
A failed rpc() in a server component: catch and check
|
|
1943
1949
|
error instanceof ServerAuthenticationError (401) / ServerAuthorizationError (403)
|
|
1944
1950
|
from '@rsc-kit/core/errors'; rethrow anything else.
|
|
@@ -2020,9 +2026,23 @@ Reach PHP from a server component - rpc() is a global, typed in
|
|
|
2020
2026
|
const orders = await rpc<Order[]>('Orders.recent', 5)
|
|
2021
2027
|
|
|
2022
2028
|
The call runs AS THE VISITOR (their cookie is forwarded; auth()->user() is
|
|
2023
|
-
them). Refuse with
|
|
2024
|
-
#[Middleware('
|
|
2025
|
-
|
|
2029
|
+
them). Refuse with Laravel's own attributes, as on a controller
|
|
2030
|
+
(Illuminate\\Routing\\Attributes\\Controllers): #[Middleware('auth')],
|
|
2031
|
+
#[Authorize('update', Order::class)], #[Middleware('throttle:60,1')]. Before
|
|
2032
|
+
rsc-kit/laravel 0.28 #[Authorize] guarded nothing; there, use
|
|
2033
|
+
#[Middleware('can:update,App\\Models\\Order')]. A method takes services and
|
|
2034
|
+
#[CurrentUser] beside its arguments (0.28), and a call never sends
|
|
2035
|
+
them. logout(Request $request) works as in a controller (0.29): the form is its
|
|
2036
|
+
input, the visitor's session and user are on it; request() is the host call's.
|
|
2037
|
+
An action's guards run against the page its form was posted from (core 0.44,
|
|
2038
|
+
laravel 0.30): #[Middleware('signed')] on verify(EmailVerificationRequest
|
|
2039
|
+
$request) checks the link the visitor followed, and $request->route('id') is
|
|
2040
|
+
the page's {id}. A model param is bound from the page: publish(Post $post) with
|
|
2041
|
+
#[Middleware(['auth', 'can:update,post'])] is the page's {post}, the one the
|
|
2042
|
+
policy saw (404 from no page). An action is a POST endpoint: the page's guards
|
|
2043
|
+
never run for it, and the caller picks the page, so every action carries its
|
|
2044
|
+
own auth and authorizes the record it changes.
|
|
2045
|
+
A ValidationException lands on the form as validationErrors; Authentication/Authorization exceptions answer 401/403. An
|
|
2026
2046
|
action shows an abort()'s message to the visitor as written, so give it one -
|
|
2027
2047
|
abort(429, 'Slow down'); without one the form says "Refused.". Only a failure
|
|
2028
2048
|
is replaced by onError's generic message.
|
|
@@ -2039,7 +2059,12 @@ Route::bind or Route::model, since a page has no controller signature for
|
|
|
2039
2059
|
implicit binding. auth sends a guest to route('login'); an app with no route
|
|
2040
2060
|
of that name fails with "Route [login] not defined" - set
|
|
2041
2061
|
$middleware->redirectGuestsTo('/login') in bootstrap/app.php (a full url when
|
|
2042
|
-
login is on another host).
|
|
2062
|
+
login is on another host). A page is named by its path (app/orders/[id] is
|
|
2063
|
+
orders.id, the root is home); one Laravel's code asks for by name declares it
|
|
2064
|
+
in the page: export const name = 'verification.verify' (or 'login',
|
|
2065
|
+
'password.reset', 'verification.notice') - the notification's link is then the
|
|
2066
|
+
page, no routes/web.php route, no createUrlUsing. A route.ts may declare one
|
|
2067
|
+
too; a name routes/web.php also gives a route elsewhere fails at boot. In Go, a guard reads rsckit.PageFrom(ctx) (URL, and Params:
|
|
2043
2068
|
only the route's own, never the query) and rsckit.ClientIP(ctx).
|
|
2044
2069
|
|
|
2045
2070
|
Make one: php artisan make:rsc-action Orders --method=cancel --auth
|