Skip to content
2 changes: 1 addition & 1 deletion .agents/skills/data-client-rest-setup/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Override only what the app does today:
| Auth, CSRF or other headers (may be `async`, e.g. token refresh) | `getHeaders(headers)` |
| Auth token from React context (Okta, Auth0) | [`hookifyResource()`](references/hookifyResource.md); a base class can't read context |
| Cookies (axios `withCredentials`), other `RequestInit` | `async getRequestInit(body)` returning `{ ...(await super.getRequestInit(body)), credentials: 'include' }`. Without `await`, the spread drops `method`, `body` and headers, so every mutation is sent as a GET |
| A response interceptor reshapes the body without losing data: unwraps a `{ "data": ... }` with nothing beside it, converts key case | `async parseResponse(response)`, e.g. `return (await super.parseResponse(response))?.data` (null for a 204); `process()` would miss `resource().delete`. Fields the app reads, like `meta`, stay in the endpoint's schema |
| A response interceptor reshapes the body without losing data: unwraps a `{ "data": ... }` with nothing beside it, converts key case | `process(value)`, e.g. `return value?.data` (null for a 204). Fields the app reads, like `meta`, stay in the endpoint's schema |
| Date fields | Not `process()`: the Entity's `static schema`, e.g. `createdAt: Temporal.Instant.from` (skill "data-client-schema") |
| Status handling, like a 401 redirect | `async fetchResponse(input, init)`: `super.fetchResponse()` throws a `NetworkError` for any non-2xx status, so wrap it in `try`, check `error.status` in `catch`, and rethrow ([Server error messages](references/axios-migration.md#server-error-messages) shows it) |
| Arrays or nested objects in the query | `searchToString(searchParams)`, e.g. `qs.stringify(searchParams, { arrayFormat: 'brackets' })` |
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const getUsers = new RestEndpoint({
| `headers` option | `getHeaders()` |
| `searchParams` | `searchParams` type (same concept, different runtime) |
| `hooks.beforeRequest` | `getHeaders()` or `getRequestInit()` |
| `hooks.afterResponse` | `parseResponse()` in the base class (`resource().delete` replaces a base `process()`) |
| `hooks.afterResponse` | `process()` in the base class |
| `hooks.beforeError` | `fetchResponse()` override |
| `.json<T>()` | Automatic — RestEndpoint parses JSON by default |
| `retry` (got retries by default) | Delete it: Data Client has no retry loop, and a failed request is fetched again when a component next needs it after `errorExpiryLength` (default 1 second). Tell the user that automatic retries are dropped |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const getUsers = new ApiEndpoint({
| `prefixUrl` | `urlPrefix` |
| `headers` option | `getHeaders()` |
| `hooks.beforeRequest` | `getHeaders()` or `getRequestInit()` |
| `hooks.afterResponse` | `parseResponse()` in the base class (`resource().delete` replaces a base `process()`) |
| `hooks.afterResponse` | `process()` in the base class |
| `hooks.beforeError` | `fetchResponse()` override |
| `ky.create()` shared options | Base class overrides |
| `.json<T>()` | Automatic — RestEndpoint parses JSON by default |
Expand Down
12 changes: 7 additions & 5 deletions .agents/skills/data-client-rest-setup/references/resource.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions .agents/skills/data-client-rest-setup/references/resource.vue.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion .agents/skills/data-client-rest/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ step that owns the change, never `fetch` itself (that replaces the whole lifecyc
| The network call (retries, another client) | `fetchResponse(input, init)` |
| Non-JSON responses | `content` option (`'blob'`, `'text'`, …), else `parseResponse(response)` |
| Shape of the parsed data | `process(value, ...args)` |
| One Entity's fields, wherever it appears | `Entity.process()` (skill "data-client-schema") |

---

Expand Down Expand Up @@ -214,7 +215,7 @@ Each guide holds working code. Read the matching section before writing code.
| The next-page token is in a response header | "Tokens in HTTP Headers" in [pagination](references/pagination.md) | `parseResponse()` adds the header to the body |
| The UI changes before the server answers | [optimistic-updates](references/optimistic-updates.md);[_optimisticTransform.md](references/_optimisticTransform.md) | `optimistic: true` on a resource; `getOptimisticResponse()` on other endpoints |
| Responses can arrive out of order | "Compensating for Server timing variations" in [optimistic-updates](references/optimistic-updates.md) | compare `updatedAt` in `Entity.shouldReorder()` |
| The API's shape differs from the app's (key case, field types, primary key, headers) | [network-transform](references/network-transform.md) | `process()` / `getRequestInit()` / `parseResponse()` on the endpoint; `Entity.schema` for field types |
| The API's shape differs from the app's (key case, field types, primary key, headers) | [network-transform](references/network-transform.md) | `process()` / `getRequestInit()` / `parseResponse()` on the endpoint; `Entity.process()` for one Entity's fields wherever it appears; `Entity.schema` for field types |
| A response is not JSON | "File download" in [network-transform](references/network-transform.md#file-download) | `content: 'blob'` |
| How long data stays fresh, and refreshing it on demand | [expiry-policy](references/expiry-policy.md) | `dataExpiryLength`, `invalidIfStale`; `ctrl.fetch()` / `ctrl.expireAll()`; `ctrl.invalidate()` |
| What shows when a refetch fails | [error-policy](references/error-policy.md) | `errorPolicy()`: `'soft'` keeps the last data, `'hard'` replaces it with the error |
Expand Down
62 changes: 38 additions & 24 deletions .agents/skills/data-client-rest/references/network-transform.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading