@timber-js/app 0.2.0-alpha.218 → 0.2.0-alpha.219
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/agent-skill.md +5 -5
- package/dist/_chunks/{actions-CUh3cClk.js → actions-BwkmAYXq.js} +8 -1
- package/dist/_chunks/{actions-CUh3cClk.js.map → actions-BwkmAYXq.js.map} +1 -1
- package/dist/client/form.d.ts +34 -37
- package/dist/client/form.d.ts.map +1 -1
- package/dist/client/index.d.ts +3 -3
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +40 -75
- package/dist/client/index.js.map +1 -1
- package/dist/client/{use-form-field.d.ts → use-field-state.d.ts} +10 -7
- package/dist/client/use-field-state.d.ts.map +1 -0
- package/dist/config-types.d.ts +15 -18
- package/dist/config-types.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/plugins/shims.d.ts.map +1 -1
- package/dist/server/action-client.d.ts +11 -172
- package/dist/server/action-client.d.ts.map +1 -1
- package/dist/server/action-handler.d.ts +0 -7
- package/dist/server/action-handler.d.ts.map +1 -1
- package/dist/server/action-schema.d.ts +126 -0
- package/dist/server/action-schema.d.ts.map +1 -0
- package/dist/server/action-types.d.ts +108 -0
- package/dist/server/action-types.d.ts.map +1 -0
- package/dist/server/form-data.d.ts +7 -0
- package/dist/server/form-data.d.ts.map +1 -1
- package/dist/server/index.d.ts +3 -2
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +511 -148
- package/dist/server/index.js.map +1 -1
- package/dist/server/internal.js +1 -1
- package/dist/server/rsc-entry/action-dispatcher.d.ts +0 -3
- package/dist/server/rsc-entry/action-dispatcher.d.ts.map +1 -1
- package/dist/server/rsc-entry/index.d.ts.map +1 -1
- package/dist/server/schema-introspection.d.ts +68 -0
- package/dist/server/schema-introspection.d.ts.map +1 -0
- package/dist/server/sensitive-fields.d.ts +40 -26
- package/dist/server/sensitive-fields.d.ts.map +1 -1
- package/docs/api/31-api-client.mdx +19 -18
- package/docs/api/34-api-config.mdx +1 -1
- package/docs/learn/08-forms-and-actions.mdx +57 -23
- package/package.json +1 -1
- package/src/client/form.tsx +57 -108
- package/src/client/index.ts +3 -3
- package/src/client/{use-form-field.ts → use-field-state.ts} +20 -8
- package/src/config-types.ts +15 -18
- package/src/plugins/shims.ts +0 -1
- package/src/server/action-client.ts +82 -307
- package/src/server/action-handler.ts +1 -42
- package/src/server/action-schema.ts +203 -0
- package/src/server/action-types.ts +145 -0
- package/src/server/form-data.ts +7 -0
- package/src/server/index.ts +5 -3
- package/src/server/rsc-entry/action-dispatcher.ts +0 -4
- package/src/server/rsc-entry/index.ts +1 -2
- package/src/server/schema-introspection.ts +393 -0
- package/src/server/sensitive-fields.ts +115 -58
- package/dist/client/use-form-field.d.ts.map +0 -1
package/agent-skill.md
CHANGED
|
@@ -50,7 +50,7 @@ import { deny, redirect, getHeaders, getCookieJar, getSegmentParams,
|
|
|
50
50
|
waitUntil, getTraceId, withSpan } from '@timber-js/app/server';
|
|
51
51
|
|
|
52
52
|
// Client (client components)
|
|
53
|
-
import { Link, useRouter, usePathname,
|
|
53
|
+
import { Link, useRouter, usePathname, readFormErrors,
|
|
54
54
|
useSegmentParams, usePendingNavigation, useLinkStatus,
|
|
55
55
|
useSelectedLayoutSegment } from '@timber-js/app/client';
|
|
56
56
|
|
|
@@ -167,16 +167,16 @@ export const createTodo = actionClient
|
|
|
167
167
|
// app/todos/todo-form.tsx
|
|
168
168
|
'use client';
|
|
169
169
|
import { useActionState } from 'react';
|
|
170
|
-
import {
|
|
170
|
+
import { readFormErrors } from '@timber-js/app/client';
|
|
171
171
|
import { createTodo } from './actions';
|
|
172
172
|
|
|
173
173
|
export function TodoForm() {
|
|
174
174
|
const [state, formAction, pending] = useActionState(createTodo, null);
|
|
175
|
-
const errors =
|
|
175
|
+
const errors = readFormErrors(state);
|
|
176
176
|
return (
|
|
177
177
|
<form action={formAction}>
|
|
178
178
|
<input name="title" required />
|
|
179
|
-
{errors.
|
|
179
|
+
{errors.field('title') && <p>{errors.field('title')}</p>}
|
|
180
180
|
<button disabled={pending}>{pending ? 'Adding...' : 'Add'}</button>
|
|
181
181
|
</form>
|
|
182
182
|
);
|
|
@@ -328,7 +328,7 @@ router.refresh();
|
|
|
328
328
|
5. **`access.ts` exports a default function** — not a named export.
|
|
329
329
|
6. **Root layout must include `<html>` and `<body>`** — timber doesn't add these.
|
|
330
330
|
7. **`getSegmentParams` uses ALS** — works in server components, middleware, access, actions. No prop drilling needed.
|
|
331
|
-
8. **`useActionState` comes from `react`** — timber has no wrapper. Read errors with `
|
|
331
|
+
8. **`useActionState` comes from `react`** — timber has no wrapper. Read errors with `readFormErrors(state)` from `@timber-js/app/client`: `errors.field('sets.0.name')` (typed from the schema), `errors.form`, `errors.server`. JS-only fields (chip lists, comboboxes) use `useFieldState`.
|
|
332
332
|
9. **Middleware has one arg** — `middleware(ctx: MiddlewareContext)`, not `(req, res)`.
|
|
333
333
|
10. **Don't use `next/` imports** — use `@timber-js/app/server`, `@timber-js/app/client`, etc.
|
|
334
334
|
|
|
@@ -859,6 +859,13 @@ function waitUntil(promise) {
|
|
|
859
859
|
* - **Empty Files → undefined**: File inputs with no selection become `undefined`
|
|
860
860
|
* - **Strips `$ACTION_*` fields**: React's internal hidden fields are excluded
|
|
861
861
|
* - **Drops `__proto__` paths and names deeper than 32 segments**
|
|
862
|
+
*
|
|
863
|
+
* A field's shape follows its count: a name sent once is a scalar, several
|
|
864
|
+
* times an array, never at all absent. A `createActionClient` action with a
|
|
865
|
+
* schema then gives every field the schema declares as a list one shape
|
|
866
|
+
* (`normalizeListFields` in `schema-introspection.ts`). A raw call, and a raw
|
|
867
|
+
* `'use server'` action that calls this itself, keep the count-dependent
|
|
868
|
+
* shape.
|
|
862
869
|
*/
|
|
863
870
|
function parseFormData(formData) {
|
|
864
871
|
const flat = {};
|
|
@@ -1233,4 +1240,4 @@ function revalidationPathMatches(revalidatedPath, requestPathname, requestSearch
|
|
|
1233
1240
|
//#endregion
|
|
1234
1241
|
export { setMutableCookieContext as C, setMatchedSegmentPath as S, runOutsideReactCacheScope as T, getHeaders as _, parseFormData as a, markResponseFlushed as b, deny as c, waitUntil as d, getCookie as f, getHeader as g, applyRequestHeaderOverlay as h, coerce as i, redirect as l, getSetCookieHeaders as m, revalidatePath as n, DenySignal as o, getCookieJar as p, revalidateTag as r, RedirectSignal as s, executeAction as t, redirectExternal as u, getSearchParams as v, setSegmentParams as w, runWithRequestContext as x, getSegmentParams as y };
|
|
1235
1242
|
|
|
1236
|
-
//# sourceMappingURL=actions-
|
|
1243
|
+
//# sourceMappingURL=actions-BwkmAYXq.js.map
|