diff --git a/AGENTS.md b/AGENTS.md index 935ec1f..8da3b79 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -93,9 +93,13 @@ Cached queries, mutations and invalidation, built on `effect/reactivity` and `readonly foo?: T | undefined`. - The build is plain `tsc` (`scripts/build.mjs`), not a bundler. Bundlers rewrite `export * as Query` into a synthetic namespace whose name shows up - in consumers' hovers. Stay on TypeScript 6: TypeScript 7 ships no compiler - API, which `check-docs.mjs`, `editor-check.mjs` and the Effect language - service need. + in consumers' hovers. After `tsc`, the build rewrites `dist/index.d.ts` + to declare each namespace with its JSDoc + (`declare namespace Query { export { … } }`), since TypeScript shows no + JSDoc for `export * as` in a hover. `pnpm run dev` (`tsc --watch`) + skips that step, so run `pnpm run build` before checking hovers. Stay on + TypeScript 6: TypeScript 7 ships no compiler API, which `check-docs.mjs`, `editor-check.mjs` and + the Effect language service need. ## Testing diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ef8026..a82e899 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,65 @@ All notable changes to `@monarcode/effetch-query`, newest first. +## 0.1.0-rc.5 + +Additive: opt-in entity sync, two exported errors, named types for +`api.query`, and namespace docs in editor hovers. It works with +`@monarcode/effetch` 0.1.0-rc.4 and later in 0.1, as rc.4 does. One fix +can surface in your app: `useRefetch` with a key that holds a query now +throws `Query.KeyHoldsTargetError` instead of doing nothing (see Fixed). + +### Added + +- `Query.KeyHoldsTargetError` and, from `@monarcode/effetch-query/effetch`, + `EndpointQueryError` are exported, so you can check for them with + `instanceof` and name their types. They were thrown before, but only + their `_tag` could be matched. Their tags and messages are unchanged, + and their fields (`key`; `route` and `cause`) are documented. +- Named types for what `api.query` takes and gives: + `EndpointQueryValue`, `EndpointQueryCallError` and + `EndpointQueryOptionsFor`. `api.query`'s declaration uses them in place + of inline conditional types, so Go to Definition and its hover read + more simply. The types they resolve to, at each call, are unchanged. +- `api.query`, `api.infiniteQuery` and `api.mutation` have examples in + their hovers. +- Entity sync: `QueryClient.make({ entities: { sync: [Todos] } })` keeps + the cached copies of those entities in sync. When a query's fetch + succeeds, each copy in its value goes over the older copies with the + same id in every other query that holds the entity, so a details + refetch updates the list rows, and a list fetch updates the cached + details, with no other fetch. The newer copy wins, by when its fetch + started (each page's own request, for an infinite query's refetch), and + loading the next page sends only that page. A write counts as newer than fetches in flight, but only + fetched copies are synced to other queries. A query opts out with + `entities: { sync: false }` (`Query.EntitiesOptions`). See "Keep copies + in sync" in the README. +- The README explains decoding an endpoint's own response shape to an + entity's schema ("Responses in other shapes"), and what server + rendering needs from a schema that transforms ("Schemas that + transform"): a query whose schema can't encode its value is left out + of `dehydrate` with no error, and the browser fetches it again. + +### Fixed + +- `useRefetch` with a key that holds a query, a family or a group, such as + `useRefetch([todos, profile])`, now throws `Query.KeyHoldsTargetError` as + it renders, as the README said it fails. Before, its `refetch` did + nothing and the error was lost. Pass a `Query.group` instead. + +### Changed + +- Hovers on the core namespaces (`Entity`, `InfiniteQuery`, `Mutation`, + `Query`, `QueryClient` and `Signals`) show their docs. Before, a hover + showed only the module's path, such as + `(alias) module ".../dist/Query"`. A member's hover now reads + `(alias) const Query.make: …`, with its docs as before. Go to Definition + on a namespace lands on `index.d.ts`; on a member, it still lands on the + member's own declaration. Completions after `Query.` list each member as + an alias, as Effetch's `Fetch.` does. +- Developed and tested against `effect` 4.1.5 (and `@effect/atom-react` + 4.1.5). The peer ranges are unchanged. + ## 0.1.0-rc.4 Released alongside `@monarcode/effetch` 0.1.0-rc.4, which it needs: upgrade diff --git a/README.md b/README.md index 00df2b5..dca5dcf 100644 --- a/README.md +++ b/README.md @@ -741,7 +741,8 @@ Pass the targets one by one, not as an array. An array of queries is a key, not a group, and as a key it would match nothing, so `Query.GroupTargets` makes `Query.group([todos, todo])` a type error. Where a target is expected, though, `[todos, todo]` compiles, since it's a -valid key, and fails at run time with a `KeyHoldsTargetError` defect. +valid key, and fails at run time with a `Query.KeyHoldsTargetError` +defect. Combine targets with `Query.group`. #### Keys from a query schema @@ -774,7 +775,7 @@ searchTodos({ query: { due: new Date("2026-11-16"), page: 2 } }); // keyed ["todos", "search", { due: "2026-11-16T00:00:00.000Z", page: "2" }] ``` -A call throws an `EndpointQueryError` (its `_tag`) when its query doesn't +A call throws an `EndpointQueryError` when its query doesn't match the schema, when a field encodes to an object or when a field is `Redacted`: the key would hold the secret and send it to the browser, so send secrets in a header. The schema's encoding can't need services, @@ -1073,21 +1074,22 @@ query fresh for 30 seconds this way. `api.query`, `Query.make` and `Query.family` take the following options: -| Option | Default | What it does | -| -------------------- | --------- | ------------------------------------------------------------------------------------------------------- | -| `staleTime` | `0` | How long a value counts as fresh (a `Duration.Input`, such as `"1 minute"`). | -| `gcTime` | 5 minutes | How long a query not in use keeps its value. | -| `retry` | none | A `Schedule` to retry failed fetches with. | -| `refetchOnMount` | `true` | Refetch a stale query when a component starts using it. | -| `retryOnMount` | `true` | Refetch a failed query when a component starts using it. | -| `refetchOnFocus` | `true` | Refetch stale queries in use when the app comes back into focus. | -| `refetchOnReconnect` | `true` | Refetch stale queries in use when the device comes back online. | -| `refetchInterval` | none | Refetch on this interval while the query is in use. | -| `reactivityKeys` | none | Also refetch when these `Reactivity` keys are invalidated (`effect/reactivity`). | -| `placeholder` | none | A value to show until the query has one ([Placeholders](#placeholders)). | -| `live` | none | Server pushes that keep the value up to date ([Pushes on a fetched query](#pushes-on-a-fetched-query)). | -| `schema` | none | `Query.make` and `Query.family` only: how the value crosses to the browser. | -| `headers`, `plugins` | none | `api.query` only: what Effetch's `client.bind` takes, for every call. | +| Option | Default | What it does | +| -------------------- | --------- | ----------------------------------------------------------------------------------------------------------------- | +| `staleTime` | `0` | How long a value counts as fresh (a `Duration.Input`, such as `"1 minute"`). | +| `gcTime` | 5 minutes | How long a query not in use keeps its value. | +| `retry` | none | A `Schedule` to retry failed fetches with. | +| `refetchOnMount` | `true` | Refetch a stale query when a component starts using it. | +| `retryOnMount` | `true` | Refetch a failed query when a component starts using it. | +| `refetchOnFocus` | `true` | Refetch stale queries in use when the app comes back into focus. | +| `refetchOnReconnect` | `true` | Refetch stale queries in use when the device comes back online. | +| `refetchInterval` | none | Refetch on this interval while the query is in use. | +| `reactivityKeys` | none | Also refetch when these `Reactivity` keys are invalidated (`effect/reactivity`). | +| `entities` | in sync | `{ sync: false }` leaves the query out of the client's entity sync ([Keep copies in sync](#keep-copies-in-sync)). | +| `placeholder` | none | A value to show until the query has one ([Placeholders](#placeholders)). | +| `live` | none | Server pushes that keep the value up to date ([Pushes on a fetched query](#pushes-on-a-fetched-query)). | +| `schema` | none | `Query.make` and `Query.family` only: how the value crosses to the browser. | +| `headers`, `plugins` | none | `api.query` only: what Effetch's `client.bind` takes, for every call. | `schema` is what [Server rendering](#server-rendering) sends the value with; an endpoint's `output` is its schema already @@ -1694,8 +1696,9 @@ export function HomeRefresh() { ``` Pass the group, not an array: `useRefetch([todos, profile])` compiles, -because an array is a key, but a key that holds queries refetches nothing -and fails with a `KeyHoldsTargetError` defect. +because an array is a key, but a key that holds queries would refetch +nothing, so `useRefetch` throws a `Query.KeyHoldsTargetError` as it +renders. ### Atoms @@ -2011,7 +2014,7 @@ variables that returns them. A failed run invalidates nothing. Each entry of the list is one target. An entry that's an array holding a query, a family or a group is a key, and matches nothing: `invalidates: [[todos, todo]]` is a mistake. In a list, the run dies with -a `KeyHoldsTargetError` before it starts. From the function, the change is +a `Query.KeyHoldsTargetError` before it starts. From the function, the change is already saved, so the target is logged and skipped. Write `invalidates: [todos, todo]` instead, or `Query.group(todos, todo)` where one target is needed ([Targets](#targets)). @@ -2282,6 +2285,184 @@ on `Query.make`, `Query.family` and infinite queries. So: - It isn't found inside `Option`, `Map` or other such types. - A value sent from the server is reached once a query reads it. +#### Responses in other shapes + +Endpoints often return one record in different shapes: a search row with +its own field names, a detail wrapped in `data`. Decode each one to the +entity's schema with `Schema.decodeTo`. An entity is found on the decoded +side of a schema, so it's found in every query whose schema decodes to +it, whatever the wire shape: + +```ts +import * as Schema from "effect/Schema"; +import * as SchemaTransformation from "effect/SchemaTransformation"; + +import { Fetch } from "@monarcode/effetch"; + +import { Todo } from "./api.js"; +import { api } from "./todos.js"; + +// What GET /search/todos sends for each todo. Only the fields that are +// read are declared: a response's other fields are ignored. +const SearchRow = Schema.Struct({ + todo_id: Schema.Finite, + label: Schema.String, + completed: Schema.Boolean, +}); + +// A search row as a Todo, so the Todos entity finds it. +export const TodoFromSearchRow = SearchRow.pipe( + Schema.decodeTo( + Todo, + SchemaTransformation.transform({ + decode: (row) => ({ + id: row.todo_id, + title: row.label, + done: row.completed, + }), + // The mirror of decode, for server rendering. + encode: (todo) => ({ + todo_id: todo.id, + label: todo.title, + completed: todo.done, + }), + }), + ), +); + +export const searchResults = api.query( + Fetch.endpoint("GET /search/todos", { + output: Schema.Array(TodoFromSearchRow), + }), +); +``` + +`Entity.update(Todos, …)` now writes the search results too, and +`Entity.get` reads them. Three things make it work: + +- **Decode to the entity's own schema.** Import the one `Todo` the entity + was made with. Another schema with the same fields isn't the entity. +- **Decode IDs to one type.** IDs are compared with `Equal.equals`, so a + todo whose ID is `"1"` in one response and `1` in another is two todos. +- **Write `encode` too, if you render on the server.** A query's value is + sent to the browser in its wire shape, so its schema must encode the + todo back ([Schemas that transform](#schemas-that-transform)). In an app + that only runs in the browser, `encode` is never called. + +#### Keep copies in sync + +A write reaches every copy, but a fetch only updates its own query: a +todo's detail refetches and shows it done, while the lists still show it +open until they refetch. Give the client the entities to keep in sync, +and each fetch writes its copies over the older ones everywhere: + +```ts +import { QueryClient } from "@monarcode/effetch-query"; + +import { ApiClientLive } from "./api.js"; +import { Todos } from "./entities.js"; + +export const syncedClient = QueryClient.make({ + layer: ApiClientLive, + entities: { sync: [Todos] }, +}); +``` + +Now when any query's fetch succeeds, each todo in its value is written +over the older copies with the same ID, in every other cached query whose +schema holds `Todo`. No other query fetches, and each one written keeps +its own age, so a stale list still refetches when it's next used. + +**An example.** Say an app has a list of the five most recent todos on +its home screen, a detail screen that opens when a todo is tapped, and a +page that lists every todo with an infinite query: + +1. The home screen fetches the five todos. Nothing else is cached yet. +2. A tap opens the detail screen. Its placeholder, `Entity.get`, shows the + list's copy at once ([Placeholders](#placeholders)). The detail's fetch + lands with the todo now done, and the sync writes it over the home + list's copy. Back on the home screen, the todo shows as done. +3. The "all todos" page loads its first page. Its todos are newer than + the copies cached so far, so the sync writes them over the detail and + the home list. Loading the next page sends only that page's todos; the + pages already loaded aren't counted as new. + +**The newer copy wins.** A copy is as new as the fetch it came from, by +when that fetch started: + +- A slow response that lands after a newer one doesn't overwrite it, and + the query that fetched it shows the newer copy instead. A retry counts + from when it started. A refetch of an infinite query requests its pages + one after the other, and each page counts from when its own request + started. +- A write, such as `Entity.set` with a mutation's result, `Query.set` or + a `live` push, counts as newer than every fetch already in flight, so + none of them overwrites it. A sync doesn't copy a written todo to other + queries, though: an entity write already reached every query that held + it, and an optimistic one may be rolled back. So after `Entity.set`, a + detail fetch that was already in flight shows what it fetched. +- A value sent from the server ([Server rendering](#server-rendering)) is + older than any fetch in the browser. +- If a mutation's `optimistic` changed a copy that a newer fetch then + synced over, and the mutation fails, the rollback puts the synced copy + back. + +**What syncs, and what doesn't:** + +- Only a fetch syncs. Writes, `live` pushes and + [stream queries](#a-query-from-a-stream) don't, so a sync never starts + another sync. +- A query that's invalidated and not in use, that shows a failure, that + has no value or no schema, or that opted out, is neither read nor + written: it's left to its next fetch. +- A query that doesn't hold a todo doesn't gain it. A sync never adds a + row to a list, so invalidate the lists a new todo should join, as with + `Entity.set`. +- A copy equal to the newer one (`Equal.equals`) isn't written, so its + readers don't render again. +- A fetch doesn't write the queries it read through `ctx.result`, so it + doesn't start itself again. A query that reads a written query through + `ctx.result` refetches, as after any write + ([Queries that read other queries](#queries-that-read-other-queries)). +- An `id` that throws, or a listener that throws as a query is written, + is logged with `Effect.logError`. The fetch keeps its value. + +**Copies are replaced whole, not merged.** A sync writes the newer todo +over the older one; it doesn't combine their fields. If some endpoint's +todos are partial, such as a list whose `decode` fills the fields it +doesn't send with defaults, a fetch of that list writes its partial todos +over the full ones in the cached details. Make every decoded `Todo` +complete, or opt the partial queries out: + +```ts +import * as Schema from "effect/Schema"; + +import { Fetch } from "@monarcode/effetch"; + +import { Todo } from "./api.js"; +import { api } from "./todos.js"; + +// Served from a search index that lags behind the database. +export const searchTodos = api.query( + Fetch.endpoint("GET /todos/search", { output: Schema.Array(Todo) }), + { entities: { sync: false } }, +); +``` + +A query that opts out is left out both ways: its fetches write no other +query, and no other query's fetch writes it. `Entity` writes still reach +it. + +**`Entity.get` placeholders still help.** A sync runs after a fetch, and a +placeholder fills a detail screen before its first fetch, from the copy +already cached. Use both. + +**Cost.** Each fetch of a query that holds a synced entity reads every +cached query that holds it, once per synced entity: about one `id` call +and one lookup per cached copy. For a few lists of tens of rows, that's +nothing. For an entity held in many large lists, or a query that polls +often, opt out the queries that don't need it. + ### Run modes When a component starts a run while its previous run is in progress, @@ -2496,7 +2677,8 @@ export const onRefresh = () => queryClient.refetch(todos); ``` Without a target, `invalidate`, `refetch`, `reset` and `clear` act on every -query. They reject only with a defect, such as a `KeyHoldsTargetError` for +query. They reject only with a defect, such as a +`Query.KeyHoldsTargetError` for a key that holds queries. On a disposed client, they do nothing. `fetch` and `prefetch` take `{ signal }` to stop waiting when it aborts. @@ -3281,7 +3463,9 @@ then [Frameworks](#frameworks). needs a schema to encode its value on the server and decode it in the browser. An Effetch endpoint's `output` is its schema, so endpoint queries need nothing more; an endpoint without an `output` isn't sent. A -query of your own needs a `schema` ([Without Effetch](#without-effetch)). +query of your own needs a `schema` ([Without Effetch](#without-effetch)). A +schema that transforms must encode as well as decode +([Schemas that transform](#schemas-that-transform)). **Failures stay on the server.** By default a failed query is left out, so server errors never reach the page, and the browser fetches it again. @@ -3373,7 +3557,8 @@ Here's what each part does: browser. **What `dehydrate` sends.** Each query with a schema, encoded with it. A -value its schema can't encode is left out, and so is a +value its schema can't encode is left out, with no error +([Schemas that transform](#schemas-that-transform)), and so is a [placeholder](#placeholders), which is never cached. On the server, `Query.prefetch` runs a [stream query](#a-query-from-a-stream) to its first element, which `dehydrate` sends when the query has a @@ -3412,6 +3597,81 @@ argument: | `pending` | A query still loading: `"promise"` sends a promise of its result ([Streaming](#streaming)); `"omit"` leaves it out, and the browser fetches it. Default: `"omit"`. | | `failures` | A failed query: `"include"` sends it with its error; `"omit"` leaves it out. Default: `"omit"`. | +#### Schemas that transform + +A value crosses to the browser in its wire shape. `dehydrate` encodes it +with the query's schema, from the decoded value back to what the server +sent, and the browser decodes it with the same schema. For a plain +`Schema.Struct` that's nothing to think about. For a schema that +transforms, such as a `Schema.decodeTo` that maps a response to your own +type ([Responses in other shapes](#responses-in-other-shapes)), it means +the transformation must encode as well as decode. + +A transformation that can't encode, such as one whose `encode` is +`SchemaGetter.forbidden`, makes `dehydrate` leave the query out, with no +error. The page still renders on the server, but the browser has no value +for that query: + +- the browser fetches it again, a second request for data the server + already had; +- `useSuspenseQuery` waits for that fetch while React hydrates; +- a plain `useQuery` starts out pending in the browser, though the server + rendered the data, which can show a loading state or a hydration + mismatch. + +So write `encode` as the mirror of `decode`. It doesn't have to rebuild +the whole response: only a wire value that `decode` turns back into the +same value. Declare only the fields you read in the wire schema, since a +response's other fields are ignored when decoding, and `encode` then has +only those to write: + +```ts +import * as Schema from "effect/Schema"; +import * as SchemaTransformation from "effect/SchemaTransformation"; + +// The API sends amounts in minor units, under its own names. +const PaymentWire = Schema.Struct({ + ref: Schema.String, + amount_minor: Schema.Finite, +}); + +export const Payment = Schema.Struct({ + id: Schema.String, + amount: Schema.Finite, +}); + +export const PaymentFromWire = PaymentWire.pipe( + Schema.decodeTo( + Payment, + SchemaTransformation.transform({ + decode: (wire) => ({ id: wire.ref, amount: wire.amount_minor / 100 }), + encode: (payment) => ({ + ref: payment.id, + amount_minor: Math.round(payment.amount * 100), + }), + }), + ), +); +``` + +The same goes for an entity's copies that a write or a sync put into a +query: they're sent encoded with that query's own schema. + +To check that a query is sent, dehydrate it on its own while you build +the page: + +```ts +import { QueryClient } from "@monarcode/effetch-query"; + +import { todos } from "./todos.js"; + +declare const client: QueryClient.QueryClient; + +// 0 when no todos query is sent: none is cached, or its schema can't +// encode it, or there's no schema. +export const sent = QueryClient.dehydrate(client, { queries: todos }).length; +``` + ### Load it in the browser **3. Render the same tree under a `HydrationBoundary`.** Give it what the @@ -4007,6 +4267,7 @@ layer's scope closes. | `signals` | Where the client hears that the app regained focus or the device came back online. | `Signals.browser` | | `queries` | `defaults` for every query, and the `onSuccess`, `onFailure` and `onSettled` hooks. | No defaults, no hooks | | `mutations` | `defaults` (`retry`, `concurrent`) for every mutation, and the `onMutate`, `onSuccess`, `onFailure` and `onSettled` hooks. | No defaults, no hooks | +| `entities` | `sync`: the entities whose cached copies a fetch keeps in sync ([Keep copies in sync](#keep-copies-in-sync)). | None | If `layer` fails to build, everything that needs it dies with that failure. @@ -4014,7 +4275,7 @@ failure. In types, `QueryClient.Options` is one of two shapes. `LayerOptions` gives the client a `layer` (and optionally a `memoMap`), which it builds itself. `RuntimeOptions` gives it a `runtime` instead. Both extend -`CommonOptions`: `signals`, `queries` and `mutations`. +`CommonOptions`: `signals`, `queries`, `mutations` and `entities`. `QueryClient.OptionalOptions` is the parameter list of `make` and `layer`. An app that declares no services in `Register` can leave out @@ -4312,6 +4573,7 @@ maps TanStack Query's APIs to effetch-query's: | `getNextPageParam`, `getPreviousPageParam` | `nextPageParam`, `previousPageParam` (return `undefined` / `null` for none) | | `setQueriesData` | `Query.update(family, (value, args) => …)` | | A record in many queries (normalized caches, TanStack DB) | `Entity.update`, `Entity.set`, `Entity.remove`, `Entity.get` | +| `setQueryData` on other queries in a query's `onSuccess` | `entities: { sync: [Todos] }` on the client ([Keep copies in sync](#keep-copies-in-sync)) | | `experimental_streamedQuery` | `Query.stream`, `Query.streamFamily`; `api.query` of an SSE or NDJSON endpoint | | `setQueryData` from a WebSocket's messages | `live` on `api.query`, `Query.make` / `Query.family` | | `cancelQueries`, devtools | Not in 0.1 | @@ -4338,6 +4600,7 @@ It exports the following: | `Query.family`, `Query.FamilyOptions`, `Query.Family` | Defines a family: one query per argument, each cached on its own. | [3. Define your queries](#3-define-your-queries) | | `Query.Query` | A cached query: an atom whose value is the query's `AsyncResult`, with a key. | [Queries](#queries) | | `Query.Options` | The options every query takes besides `key` and `run`. | [Query options](#query-options) | +| `Query.EntitiesOptions` | A query's `entities` option: whether the client's entity sync reads and writes it. | [Keep copies in sync](#keep-copies-in-sync) | | `Query.Key` | Identifies a query in the cache. | [Keys](#keys) | | `Query.RunContext` | What a query's `run` receives, for reading other queries. | [Queries that read other queries](#queries-that-read-other-queries) | | `Query.Schema` | How a query's value, and optionally its error, is sent from the server to the browser. | [Send the cache](#send-the-cache) | @@ -4355,6 +4618,7 @@ It exports the following: | `Query.clear` | Drops the matching queries' values without fetching. | [From Effect](#from-effect) | | `Query.Target` | What `invalidate`, `refetch`, `reset` and `clear` act on: a query, a family, a key or a group. | [Targets](#targets) | | `Query.group`, `Query.Group`, `Query.GroupTargets` | Combines targets into one group, for acting on unrelated queries together; `GroupTargets` is what it takes. | [Targets](#targets) | +| `Query.KeyHoldsTargetError` | Thrown when a key holds a query, a family or a group (a defect from Effects): pass a `Query.group`. | [Targets](#targets) | | `Query.TypeId`, `Query.isQuery` | The property that marks a query, and a check for whether a value is one. | [Queries](#queries) | **`InfiniteQuery`** defines queries whose value is a list of pages. It @@ -4409,6 +4673,7 @@ browser and holds the types for your services. It exports the following: | `QueryClient.QueriesOptions`, `QueryClient.QueryDefaults` | The `queries` group of options, and the defaults it sets for every query. | [The client](#the-client) | | `QueryClient.QuerySucceeded`, `QueryClient.QueryFailed`, `QueryClient.QuerySettled` | What the `queries` hooks receive. | [The client](#the-client) | | `QueryClient.MutationsOptions`, `QueryClient.MutationDefaults` | The `mutations` group of options, and the defaults it sets for every mutation. | [The client](#the-client) | +| `QueryClient.EntitiesOptions` | The `entities` group of options: the entities a fetch keeps in sync across the cache. | [Keep copies in sync](#keep-copies-in-sync) | | `QueryClient.MutationStarted`, `QueryClient.MutationSucceeded`, `QueryClient.MutationFailed`, `QueryClient.MutationSettled` | What the `mutations` hooks receive. | [The client](#the-client) | | `QueryClient.Hook` | An app-wide hook: it receives an event and runs with your services and the client. | [The client](#the-client) | | `QueryClient.Register`, `QueryClient.Services`, `QueryClient.Requirements` | Declares your services, and reads them back for typing Effects. | [The client](#the-client) | @@ -4478,7 +4743,10 @@ mutations. It exports the following: | `Endpoints` | Queries and mutations for one Effetch client, made by `fromClient`. | [Queries from endpoints](#queries-from-endpoints) | | `endpoints` | Deprecated: the former name of `fromClient`, which works the same. It goes in 0.2.0. | [Queries from endpoints](#queries-from-endpoints) | | `EndpointQuery`, `EndpointQueryOptions` | A family of queries with one per call of an endpoint, and its options. | [Queries from endpoints](#queries-from-endpoints) | +| `EndpointQueryValue`, `EndpointQueryCallError` | A query's value and error from an endpoint: its decoded `output`, or a stream's latest element, and the call's errors. | [Queries from endpoints](#queries-from-endpoints) | +| `EndpointQueryOptionsFor` | The options `api.query` takes for an endpoint: `EndpointStreamOptions` for a stream endpoint, else `EndpointQueryOptions`. | [Queries from endpoints](#queries-from-endpoints) | | `EndpointQueryArgs` | What a query from a route takes: the path's params, and a query object. | [Queries from endpoints](#queries-from-endpoints) | +| `EndpointQueryError` | Thrown when a call's `query` can't be part of its key: it doesn't match the schema, or holds an object or a `Redacted`. | [Keys](#keys) | | `RegisteredSchema` | A schema whose decoding and encoding need nothing outside your registered services and the client. | [Queries from endpoints](#queries-from-endpoints) | | `KeyQuerySchema` | A `query` schema an endpoint query can be keyed by: one whose encoding needs no services. | [Keys](#keys) | | `ErrorSchema` | The schema a bound endpoint decodes error bodies with: its own, or the client's `defaultError`. | [Errors](#errors) | diff --git a/package.json b/package.json index 3219476..6ff3619 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@monarcode/effetch-query", - "version": "0.1.0-rc.4", + "version": "0.1.0-rc.5", "description": "Effectful queries and mutations for Effect 4, inspired by TanStack Query. Cached, kept fresh, typed end to end, and made to pair with effetch.", "keywords": [ "TanStack", @@ -83,32 +83,32 @@ }, "devDependencies": { "@arethetypeswrong/cli": "0.18.5", - "@effect/atom-react": "4.1.1", + "@effect/atom-react": "4.1.5", "@effect/language-service": "0.87.5", - "@effect/vitest": "4.1.1", + "@effect/vitest": "4.1.5", "@monarcode/effetch": "0.1.0-rc.4", - "@react-router/dev": "8.5.1", + "@react-router/dev": "8.5.2", "@tanstack/react-router": "1.170.46", - "@tanstack/react-start": "1.169.4", + "@tanstack/react-start": "1.169.7", "@testing-library/dom": "10.4.2", "@testing-library/react": "16.3.3", "@types/node": "26.6.6", "@types/react": "19.3.0", "@types/react-dom": "19.3.0", - "@vitejs/plugin-react": "6.1.2", - "effect": "4.1.1", + "@vitejs/plugin-react": "6.3.0", + "effect": "4.1.5", "happy-dom": "21.0.4", "husky": "9.1.7", - "oxfmt": "0.75.0", - "oxlint": "1.90.0", + "oxfmt": "0.79.0", + "oxlint": "1.94.0", "publint": "0.3.25", "react": "19.3.1", "react-dom": "19.3.1", - "react-router": "8.5.1", + "react-router": "8.5.2", "scheduler": "0.28.0", "typescript": "6.0.3", - "vite": "8.3.5", - "vitest": "5.0.5" + "vite": "8.3.8", + "vitest": "5.1.1" }, "peerDependencies": { "@effect/atom-react": "^4.1.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0f57e96..bf0eacc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,26 +12,26 @@ importers: specifier: 0.18.5 version: 0.18.5 '@effect/atom-react': - specifier: 4.1.1 - version: 4.1.1(effect@4.1.1)(react@19.3.1)(scheduler@0.28.0) + specifier: 4.1.5 + version: 4.1.5(effect@4.1.5)(react@19.3.1)(scheduler@0.28.0) '@effect/language-service': specifier: 0.87.5 version: 0.87.5 '@effect/vitest': - specifier: 4.1.1 - version: 4.1.1(effect@4.1.1)(vitest@5.0.5(@types/node@26.6.6)(happy-dom@21.0.4)(vite@8.3.5(@types/node@26.6.6)(jiti@2.7.0))) + specifier: 4.1.5 + version: 4.1.5(effect@4.1.5)(vitest@5.1.1(@types/node@26.6.6)(happy-dom@21.0.4)(vite@8.3.8(@types/node@26.6.6)(jiti@2.7.0))) '@monarcode/effetch': specifier: 0.1.0-rc.4 - version: 0.1.0-rc.4(effect@4.1.1) + version: 0.1.0-rc.4(effect@4.1.5) '@react-router/dev': - specifier: 8.5.1 - version: 8.5.1(react-router@8.5.1(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(typescript@6.0.3)(vite@8.3.5(@types/node@26.6.6)(jiti@2.7.0)) + specifier: 8.5.2 + version: 8.5.2(react-router@8.5.2(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(typescript@6.0.3)(vite@8.3.8(@types/node@26.6.6)(jiti@2.7.0)) '@tanstack/react-router': specifier: 1.170.46 version: 1.170.46(react-dom@19.3.1(react@19.3.1))(react@19.3.1) '@tanstack/react-start': - specifier: 1.169.4 - version: 1.169.4(react-dom@19.3.1(react@19.3.1))(react@19.3.1)(rolldown@1.2.16)(vite@8.3.5(@types/node@26.6.6)(jiti@2.7.0)) + specifier: 1.169.7 + version: 1.169.7(react-dom@19.3.1(react@19.3.1))(react@19.3.1)(rolldown@1.2.19)(vite@8.3.8(@types/node@26.6.6)(jiti@2.7.0)) '@testing-library/dom': specifier: 10.4.2 version: 10.4.2 @@ -48,11 +48,11 @@ importers: specifier: 19.3.0 version: 19.3.0(@types/react@19.3.0) '@vitejs/plugin-react': - specifier: 6.1.2 - version: 6.1.2(vite@8.3.5(@types/node@26.6.6)(jiti@2.7.0)) + specifier: 6.3.0 + version: 6.3.0(vite@8.3.8(@types/node@26.6.6)(jiti@2.7.0)) effect: - specifier: 4.1.1 - version: 4.1.1 + specifier: 4.1.5 + version: 4.1.5 happy-dom: specifier: 21.0.4 version: 21.0.4 @@ -60,11 +60,11 @@ importers: specifier: 9.1.7 version: 9.1.7 oxfmt: - specifier: 0.75.0 - version: 0.75.0 + specifier: 0.79.0 + version: 0.79.0 oxlint: - specifier: 1.90.0 - version: 1.90.0 + specifier: 1.94.0 + version: 1.94.0 publint: specifier: 0.3.25 version: 0.3.25 @@ -75,8 +75,8 @@ importers: specifier: 19.3.1 version: 19.3.1(react@19.3.1) react-router: - specifier: 8.5.1 - version: 8.5.1(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.1(react@19.3.1))(react@19.3.1) + specifier: 8.5.2 + version: 8.5.2(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.1(react@19.3.1))(react@19.3.1) scheduler: specifier: 0.28.0 version: 0.28.0 @@ -84,11 +84,11 @@ importers: specifier: 6.0.3 version: 6.0.3 vite: - specifier: 8.3.5 - version: 8.3.5(@types/node@26.6.6)(jiti@2.7.0) + specifier: 8.3.8 + version: 8.3.8(@types/node@26.6.6)(jiti@2.7.0) vitest: - specifier: 5.0.5 - version: 5.0.5(@types/node@26.6.6)(happy-dom@21.0.4)(vite@8.3.5(@types/node@26.6.6)(jiti@2.7.0)) + specifier: 5.1.1 + version: 5.1.1(@types/node@26.6.6)(happy-dom@21.0.4)(vite@8.3.8(@types/node@26.6.6)(jiti@2.7.0)) packages: @@ -112,16 +112,16 @@ packages: resolution: {integrity: sha512-locTkQyKvwIEgBzVrn8693ebc97F2U8ZHjbXwDXJ5Fn2TCpNwTlKcaKLkdHop5c/icOFE7qt7Q9JC5hnKNa6Gg==} engines: {node: '>=6.9.0'} - '@babel/core@7.29.7': - resolution: {integrity: sha512-RgHBCvtjbOK2gXSNBNIkNoEc9qoVEtau3hj8gEqKQuL3HZAibKarWFEI3Lfm6EYKkLalOh8eSrj9b+ch9H/VBA==} + '@babel/core@7.29.13': + resolution: {integrity: sha512-j1nvOQCZYSgp7HLmisnCXFTpVvFODiijQ9QHkORfGKWH6YDtskTEeCJS7eV545GZ9UBzrq0e2xsOd5QQ5PjIqw==} engines: {node: '>=6.9.0'} - '@babel/generator@7.29.12': - resolution: {integrity: sha512-2W76mhjrpQFO1lK5e8IvGYB2D0YZ7S2R1Z2BjO2ZUYuW+amcpK/z60U6ZZmzskwoa7sJ6XohP/Wg8H5KxXI/IA==} + '@babel/generator@7.29.15': + resolution: {integrity: sha512-gNWJUX0FlevflramOkaInywOMhU1lkln38gAC7TFZv2tsWbLYbN/2WZFGcq8zbX0Z55e4vGa27IB/NaeZoauWQ==} engines: {node: '>=6.9.0'} - '@babel/helper-compilation-targets@7.29.7': - resolution: {integrity: sha512-wem6WaBj4NaVYVdNhLPPVacES6ZJ+KBBfSkTMD3YZxbP3rm3Di85tJU5ljaUNhaOynt+Aj0xruhYuzQBt8n71g==} + '@babel/helper-compilation-targets@7.29.13': + resolution: {integrity: sha512-8WxJ4/Vmes3ghacj8VOJy3NW8eyHiFY/4thU/LSBuBE470+igjR/j1ZTNn8fV5VdNrLx6iXUwig526UdOvfP0w==} engines: {node: '>=6.9.0'} '@babel/helper-globals@7.29.7': @@ -132,14 +132,14 @@ packages: resolution: {integrity: sha512-ejHwrQQYcm9xnTivShn2IDOlIzInN34AXskvq9QicvCtEzq1Vzclu/tKF8Jq1Cg8JG2GL6/EmjgsCT7lXepE3g==} engines: {node: '>=6.9.0'} - '@babel/helper-module-transforms@7.29.7': - resolution: {integrity: sha512-UPUVSyXbOh627KiCIGQSgwWzGeBKLkaJ9PJEdrngIwMSzxLR4jS4+f1f1jb7VzBbg8nFLaYotvVPFCTqdrmTAg==} + '@babel/helper-module-transforms@7.29.14': + resolution: {integrity: sha512-2XDvQVd9JESaOgGc4jT2/jquTAO7ppA5noTZQqH+MmZ89yjCzScLwtCPbWtkPZylL+TLWR49IwWmk+QkRR4GsA==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0 - '@babel/helper-string-parser@7.29.11': - resolution: {integrity: sha512-snZbO7MEDOof+hvNa97EjEY7qD7h2kwvQr5AJC3ZhQudKW5dnej6k3kP9NQV88hJwaS8vDqRLFo9rivLEhle2g==} + '@babel/helper-string-parser@7.29.15': + resolution: {integrity: sha512-C2FuapQ2Kh1OnVHAoLi5rD3GBJ8COb9Q609T6HEpLqaBAo560PDP5OxBE5dCI/h951MBO/+bCUYU5SZ+8ZlV+w==} engines: {node: '>=6.9.0'} '@babel/helper-validator-identifier@7.29.7': @@ -150,12 +150,12 @@ packages: resolution: {integrity: sha512-N9ZErrD+yW5geCDtBqnOoxmR8+tNKiGuxKlDpuJxfsqpa2dFcexaziGAE/qoHLiDDreVNMupxGmSoNlyvsA3gw==} engines: {node: '>=6.9.0'} - '@babel/helpers@7.29.10': - resolution: {integrity: sha512-EMCx3AGZ3WfAl6ht7AyQoPm2Lh+BGYEMdc4Q6Hf7uSCDOZFuLq44qNwL+iaim8VlyYhRAo4X43+weadK8ZB4Yg==} + '@babel/helpers@7.29.15': + resolution: {integrity: sha512-l+ezV2czw3t2d2ELq+3CwPL4WLKK5O8IywBXb9/gpmbCOVZFmRYJPmHVqSCv2k+8iKbE30Zf54siOoIZ52XOxA==} engines: {node: '>=6.9.0'} - '@babel/parser@7.29.12': - resolution: {integrity: sha512-WJ7JBp/Q4+z/ImydtI7jS6NVco5++632ExBemSX+Ysb+G1lCwQ5BVo3SY+jGGOcZXI4ZccbZSUSJLNBW6eEpJg==} + '@babel/parser@7.29.15': + resolution: {integrity: sha512-RpKWyisHoP81twtSCgmE02iU0RnPcq1DN5bBEbpUePrjA9Q3wXhufnCJrrayPpoZieqFh3zyZQqwtSK0gGccRA==} engines: {node: '>=6.0.0'} hasBin: true @@ -167,12 +167,12 @@ packages: resolution: {integrity: sha512-puq+Gf35oI24FeN11LkoUQFqv9uwNeWpxXZi/Ji3rRIoKAzKnxRaZ+Gkj0vKS9ZCiTESfng1N9LyOyXvo+m+Gg==} engines: {node: '>=6.9.0'} - '@babel/traverse@7.29.12': - resolution: {integrity: sha512-MscXe/NAZcOkYEsRajHZFt3ynsb22PUi6CTrp5U7+RYycR9By84mn9mFN54YgfITiqK4hFx3Ju3tZSyzfpS5ew==} + '@babel/traverse@7.29.15': + resolution: {integrity: sha512-ZfawBo2i8vvt+BTt37dWDKBPjUfm/H+bw+ltwsCRhW7gPtyNVwUXuNo54eO2Xo+P4VXpalPFfFISbBTRKC8SOQ==} engines: {node: '>=6.9.0'} - '@babel/types@7.29.11': - resolution: {integrity: sha512-WCsemW40Cpc6gouC1SrY6PBaZ+oLRlEVY9XBvZBI7il/HyUrb2nJ505wE1MHEFyDZNnrWDEuy4jL50WVHfTTSQ==} + '@babel/types@7.29.15': + resolution: {integrity: sha512-/XKpKDakL//LZ66bq1XsZOswuqeI5MZqPLDu18o3XdkU1fNJ7bdPtzgnc4ZNS+bBGHV0FJG8jjb8SwcC3nNVQQ==} engines: {node: '>=6.9.0'} '@braidai/lang@1.1.2': @@ -182,10 +182,10 @@ packages: resolution: {integrity: sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==} engines: {node: '>=0.1.90'} - '@effect/atom-react@4.1.1': - resolution: {integrity: sha512-62YWG+Wg93SMYAbYx1zc74VE0u+MHWl5EthFXk0WUP7Kv1qb2Mvfg2C75jnp2oce7vN5WA9uiQZrgXjdqMYChw==} + '@effect/atom-react@4.1.5': + resolution: {integrity: sha512-7bFJUOa4hatIE4LD4EmuOSS7+jNniZxaltX3TRExBCYAFqMd6vjZs9G/Ez3u24oUaJnkschmjfG3EwVzzebgig==} peerDependencies: - effect: ^4.1.1 + effect: ^4.1.5 react: '>=19.0.0 <20.0.0' scheduler: '>=0.25.0 <0.29.0' @@ -193,20 +193,29 @@ packages: resolution: {integrity: sha512-np/zJgk71/PyHxtoqyUKLYcpQhoRBI+L6+1Z0ILk35JSQ/lvXzwlwOwddYZLDkeC4bdF2ukKekqKlla/F88R5w==} hasBin: true - '@effect/vitest@4.1.1': - resolution: {integrity: sha512-VkE9EUXE4G7mXMmV3X3Iu+6k3pZswWjOf7PB2qiaHMoFAZAPtHp+eUZo9oJM4Ip5z+ghQ9K0IDAQM2iG6+w5MA==} + '@effect/vitest@4.1.5': + resolution: {integrity: sha512-18u1013wkJtSelk1ZYLc/5aUnluTQyDfi2hAemkJW1GQ9qXw4mtPSiSf0AXZPhesmGCvG1Dk2C4JYD2sz+R72w==} peerDependencies: - effect: ^4.1.1 + effect: ^4.1.5 vitest: '>=5.0.0 <6.0.0' + '@emnapi/core@2.0.0-beta.2': + resolution: {integrity: sha512-MzCVoWtcg4Pm2B3je5mMvYMvj3MmBKw+fU7vbsJc9/iT8ip6/eYIHo/Dsm/mr+wsHB6SEyJDuxB09Yy6r/8+4A==} + + '@emnapi/runtime@2.0.0-beta.2': + resolution: {integrity: sha512-JcrSPzPvZuNZvJqPTF9Fw25LbOJ8avzFVlaf2grmH4Cku0oGP47tRgqPZadcfj3YoZMHkFVnCYFbQM8I+i5QEw==} + + '@emnapi/wasi-threads@2.2.0': + resolution: {integrity: sha512-JP7OYH38Q7+pyTAe14raZHLQIK7BDKbdwji+Xi3pcd/6QkJYQH3SX4wu6EplGrGJWRepoNzedfm0G3B9Z4e9Rw==} + '@jridgewell/gen-mapping@0.3.13': resolution: {integrity: sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==} '@jridgewell/remapping@2.3.5': resolution: {integrity: sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==} - '@jridgewell/resolve-uri@3.1.2': - resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==} + '@jridgewell/resolve-uri@3.1.3': + resolution: {integrity: sha512-lhTtjtoEArWBjismtfS761S9Hlyn+nIZqOZVYoZ1Xn82PMNMVnk+jj/NhC4fAXGTs7ydONcJiR5vyQBTMDu27g==} engines: {node: '>=6.0.0'} '@jridgewell/sourcemap-codec@1.6.0': @@ -224,6 +233,13 @@ packages: peerDependencies: effect: ^4.0.0 + '@napi-rs/wasm-runtime@1.2.6': + resolution: {integrity: sha512-mRyDmEw9/fCDXCGfL1sbgIw/GUK0PVxRW4YwgPN61F3LQ+fSyoBFarJVzgGyhF6kRzEQZ0FejDqm4WLXSeqQmw==} + engines: {node: ^20.19.0 || ^22.13.0 || >=23.5.0} + peerDependencies: + '@emnapi/core': ^1.7.1 || 2.0.0-beta.2 + '@emnapi/runtime': ^1.7.1 || 2.0.0-beta.2 + '@oozcitak/dom@2.0.2': resolution: {integrity: sha512-GjpKhkSYC3Mj4+lfwEyI1dqnsKTgwGy48ytZEhm4A/xnH/8z9M3ZVXKr/YGQi3uCLs1AEBS+x5T2JPiueEDW8w==} engines: {node: '>=20.0'} @@ -243,230 +259,230 @@ packages: '@oxc-project/types@0.156.0': resolution: {integrity: sha512-1Duyg48TdJNdyhEB8Xn1L36bT9Pv6GUtlKjHxOys8xkaF/rQq3XJE+bAurSK/AgIz5mGFsb77cn9Pb20+WCScw==} - '@oxfmt/binding-android-arm-eabi@0.75.0': - resolution: {integrity: sha512-zHJ7LcTN46/5mtoLxsUu14pdF9ixFwDURtmxZ0CeNwqom5qB5NRVqU6o2GRZ7QPdNBW8G6j9UTJzQ+EDevMH0w==} + '@oxfmt/binding-android-arm-eabi@0.79.0': + resolution: {integrity: sha512-xOCQ/rvokUXs8SxOQY5Wy2ukPaZJZ0PmdJovN0ryB1c8DVEtbcvliLdYtINUYh8QOTpmBOctIisSJk9tvh+J6w==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm] os: [android] - '@oxfmt/binding-android-arm64@0.75.0': - resolution: {integrity: sha512-IdxsKZJvHZUvI7q6kLmzXdEFpFiBEDQw/WJtSp1QlzNXBw1JlLN3tY50WwWd4doPnq86XW4P+7BsQwu6meCW+w==} + '@oxfmt/binding-android-arm64@0.79.0': + resolution: {integrity: sha512-WMLDvCjjchUYtI6zXKOdzTDGm72BaYZiz1/VhB1rrxdakUZRlJh1aMr3CT6ui51uHcWVBycULIXSZHpw6u2pTQ==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [android] - '@oxfmt/binding-darwin-arm64@0.75.0': - resolution: {integrity: sha512-vyiqZilO5jal/nXZ0143NyKcP6TkzjaQdVEWU/kwgyWqugAgIRgAbrnO3MOF+e6LkQu3CrtrkPoc3mrsZZY6cA==} + '@oxfmt/binding-darwin-arm64@0.79.0': + resolution: {integrity: sha512-+LzSN7w7tULz96ntS1Uqe5oI00XZ0o/m/t3+eSfiQp3aTPnj2eGUafqEWryMLk84j7x9NiF+GEP2YT4/BfClgA==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [darwin] - '@oxfmt/binding-darwin-x64@0.75.0': - resolution: {integrity: sha512-oua7eVqVe769mDam6ORcavygxTzG3ovo5QRQ1kJCPaEbnWXPYhtAiYDj8pajVmFjO7j8Elf3gInnWpTX0LLYtg==} + '@oxfmt/binding-darwin-x64@0.79.0': + resolution: {integrity: sha512-KFiMRhKeiiooaS1dKc4r8AZgOrfOhwVe1yf/aRef+8BajJwtVjMtlsQl/BNRxtkFbq13GjEo/4Q+9YhFGU4o6g==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [darwin] - '@oxfmt/binding-freebsd-x64@0.75.0': - resolution: {integrity: sha512-NWkbezhg7mx2Ep94g/TysR3c1bsISsU4lQ6t5xI4841PAk0Kqcn1+UEe+BoFH2/UK2YegPXq+OF+0bUcSvUalA==} + '@oxfmt/binding-freebsd-x64@0.79.0': + resolution: {integrity: sha512-lHVIp0g8ZOFKiqVscvttp+3HJkkRH6XkGgfAA0lVexIlE1mMFVp4V7RBdxz/P9p7T8pSNsYdapFWvdT21Mib9w==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [freebsd] - '@oxfmt/binding-linux-arm-gnueabihf@0.75.0': - resolution: {integrity: sha512-CAHX87kJplTq2E0OWP7opG8gEVlHc7CeLEi4nMJOyx3psuqBKf84HZ3UIkX2guWEJ5UljU2zJF0o46XylywVVA==} + '@oxfmt/binding-linux-arm-gnueabihf@0.79.0': + resolution: {integrity: sha512-Pt35GoxiMUfnr+23cuzk07XQVvISDFxxPcp/aFVB87+RQvJoQaBo/XN7Re9XxgElvbELdyxTLnV9XM2aTfJeUA==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm] os: [linux] - '@oxfmt/binding-linux-arm-musleabihf@0.75.0': - resolution: {integrity: sha512-jmxYOiQzx2fp+OwQb7717K1zI8AMKEykw04sfr95/mU8SIL/oKgQq8nXH42sEznEquBL2RU7nLY36eBnYFT+vg==} + '@oxfmt/binding-linux-arm-musleabihf@0.79.0': + resolution: {integrity: sha512-zPi9Dni58VKp3r1QUcFvnbJNfBr49qyecq0vlM4SaX/MSjmguq77VngirghDua5tyhIDfqdUMTCK2KRlnZFp/g==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm] os: [linux] - '@oxfmt/binding-linux-arm64-gnu@0.75.0': - resolution: {integrity: sha512-eimaiAhx08dbOg12Fj3PYhymXY8vRbaiJB505vDXMy6ohne3Y1qTS0e5KEwFMq3LmDjEO+16BX38c/oXFI/SAQ==} + '@oxfmt/binding-linux-arm64-gnu@0.79.0': + resolution: {integrity: sha512-XhRehATEWjwX7VVEgDUD+7pfHYncQIJaEU0qsHvEKtu9XX0QYzcKvXhU9+URfiGX9WRh3wy2Ow+YCc3EeHtImg==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [linux] - '@oxfmt/binding-linux-arm64-musl@0.75.0': - resolution: {integrity: sha512-bjSONIG1ba2xugr9oHQau0E6oPFYOMjPaa5hK/wpVC/Q1pcgf2BZMKwbuA8/cWzhWX5QV/UdPzD+rw1kQHpikQ==} + '@oxfmt/binding-linux-arm64-musl@0.79.0': + resolution: {integrity: sha512-gbVjFZYug0MEyqvuTAzXGNxFJmBqBO32o1Fud1lG8bGs6oVz48ZtNQyEcAzqrOwaaG+Sxtv4gVzcsfht9aqmkg==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [linux] - '@oxfmt/binding-linux-ppc64-gnu@0.75.0': - resolution: {integrity: sha512-wDksWQXC/KZucISyqlhBtvpW+pyHh8z0Cjm6Qxiv22XlllM2Bx5gJGDnPYjV+H0lL+o1iqLlEli8jmBuRCLcjw==} + '@oxfmt/binding-linux-ppc64-gnu@0.79.0': + resolution: {integrity: sha512-0N0sD3vnllyuiNh1r6zKvNXWE/CakcPKJAespg7XE2+sfvxpz5Q1iFah8sF5aedsOmVvbZaOPZcSHVmMosT1fA==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [ppc64] os: [linux] - '@oxfmt/binding-linux-riscv64-gnu@0.75.0': - resolution: {integrity: sha512-5JkNwViqaVuk4I+9+zgVrEYiHOAPXFxgDgP6iDnpdOBjm7XAHAOjSvolHZZAokWPx7CGOw8tKteXmn4WPIInaQ==} + '@oxfmt/binding-linux-riscv64-gnu@0.79.0': + resolution: {integrity: sha512-YtjqUHolcX6cv0ZMZuKQCM4H0ae/okcowy0wGcPHJk4O+8zjy3TvNhzDQ1/KGCkMJO8Fwulm1JcPJsraVJ3p+w==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [riscv64] os: [linux] - '@oxfmt/binding-linux-riscv64-musl@0.75.0': - resolution: {integrity: sha512-1EVqRIE0eZLB08j3ZCVN47Ors7LCXGmOI+3xJYgyoFUKUerD3Glxb+Q1Bp3lK8NeT5R3ZdS9uhX/wobNBYZ6jw==} + '@oxfmt/binding-linux-riscv64-musl@0.79.0': + resolution: {integrity: sha512-H2gb9bEBr5tcdP5FU8JYTfgOavXDorWcAAlwci/zEKF2jzgh/oEr/SAw6aHB9n3FLEvnKvOh0A1fjku+vgYoUA==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [riscv64] os: [linux] - '@oxfmt/binding-linux-s390x-gnu@0.75.0': - resolution: {integrity: sha512-UJWRVNT6Yuw4ssLv2BwaBUWU1GWtByE+EnoHu8I+P1t8Kn+WozYU5WYOqb5aj8gbXJJ8gGZt+w40Hi/7L6iVLw==} + '@oxfmt/binding-linux-s390x-gnu@0.79.0': + resolution: {integrity: sha512-aZUbyWW5dSOxT/u6suWc4S9GVDt7YPPNMKQon+z79M8dpXmosadcFHAb7jBhpU7Hdsd2GN6/y3nd0JFTsGddZw==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [s390x] os: [linux] - '@oxfmt/binding-linux-x64-gnu@0.75.0': - resolution: {integrity: sha512-FHdvHhyz8ChBctBUvVGti49kSEwANd1PZQwlXUEoF9Ed4plxXxk/wWc0mfZmrze2lRgmME7ytDmVIOixYauQhg==} + '@oxfmt/binding-linux-x64-gnu@0.79.0': + resolution: {integrity: sha512-5pW/ZHYfjjQ71gQR+EKzDz8ZzWIDHlTUtWtxVFNgZbKxVZnRxiSXVrllbjpJtx1q8VtSPZ+Lyg9BLny3yw+PTA==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [linux] - '@oxfmt/binding-linux-x64-musl@0.75.0': - resolution: {integrity: sha512-6MjtsF96s9mSBV0GEwUe4pOFPP2Mz7ahcHPAit0DSKL5fM6oMM7RG1zvYxwB7+SBkIxsWBRhhxuqmy7pibNwsA==} + '@oxfmt/binding-linux-x64-musl@0.79.0': + resolution: {integrity: sha512-3IVUerTDB7Dvd90c1EurAzlVnlE9Azl7Wn8e33qX3wL/IqnslF+P7HvwkD+VeMbHxRtuw0EEBGSArZFXpUAZrQ==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [linux] - '@oxfmt/binding-openharmony-arm64@0.75.0': - resolution: {integrity: sha512-1D6T6aL1Pj+U5GLxqwV1fKjUJ5+FFm+bn7UrqNDMveZmWs0jo/3vc+dzzuV/jF/FdVo12gowODk3SnAO2YOwLg==} + '@oxfmt/binding-openharmony-arm64@0.79.0': + resolution: {integrity: sha512-C5QDgJBtu9+/2BQScoP7ynv54PLOqfoSqhRWwI0D0RPOwYD4tYj0TUdJbXMO1fNegL/5zJiSOxkq6II2xvttWg==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [openharmony] - '@oxfmt/binding-win32-arm64-msvc@0.75.0': - resolution: {integrity: sha512-RX2eUmy7J/nM8+tnM3nzR8t1eqkwj1q8Kgo7beA+4DVgKYYHHyrEa3qEmthxw7Z+HqpCCEOWuoqa+jelo9/w2Q==} + '@oxfmt/binding-win32-arm64-msvc@0.79.0': + resolution: {integrity: sha512-zlW1m8M49vNGgqQF/ze80KW8pZMicnW2XDZGBHuYtXTRYn4ewvgpqN9wwoqb6uLZZfb1R1zaQWKEB8cs7KYjwA==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [win32] - '@oxfmt/binding-win32-ia32-msvc@0.75.0': - resolution: {integrity: sha512-UpKta0iSZmPLII0dYXYdbzdBTsGREUbSHLqgLdtKcqBvs40qjmUz+cgUcaU1smPx13DfbEG4XqnaSn5MoFN0og==} + '@oxfmt/binding-win32-ia32-msvc@0.79.0': + resolution: {integrity: sha512-wbb7hFv2wK3SCTfu8dl1ydNsXM5dmH+PJMU3sojCkfKcG29VDpITL5/AtouCzXjkOc90QRkcAZcg36gP0KqoHA==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [ia32] os: [win32] - '@oxfmt/binding-win32-x64-msvc@0.75.0': - resolution: {integrity: sha512-pjiLiCk0QMCWxs0n5XiNU85YLAKA+wJxPjxlDVygmr4bP4glcfTU2nOpso5nR4Rdi2Pxv5YwakD4UE+eh7M0BQ==} + '@oxfmt/binding-win32-x64-msvc@0.79.0': + resolution: {integrity: sha512-JLaeaQ+4LkQiVXY06JIV1dBFEDJzssvDieK/3Poi6CsY+c4UxghZVrrsfcKGJ5R/0F2Sw3C5Lf5Hu0sM5qJfPw==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [win32] - '@oxlint/binding-android-arm-eabi@1.90.0': - resolution: {integrity: sha512-sgfalb1HuxYjiAa4wESZ626z1FGusqNcXYHyB5oIOEprS2sbPg0UYEfo83uF1GNG70DIfZxHkXuE6KFrlSdn8Q==} + '@oxlint/binding-android-arm-eabi@1.94.0': + resolution: {integrity: sha512-730FKSBsKg/NawYnpI3gXRroXptOVqY32iYBPLUZaSx0vgYzOeiNtwojZL4gJdzo9wDvHUlstShmGRHrWcbRYg==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm] os: [android] - '@oxlint/binding-android-arm64@1.90.0': - resolution: {integrity: sha512-RcKhz1ETMq+fazE9TKS2+5NIRGwigm/nW8egqF0LI+A8Yw2iW5r0E/C3XAPRiwIm/vcPiutIRIa6IQCIKhZsTQ==} + '@oxlint/binding-android-arm64@1.94.0': + resolution: {integrity: sha512-8v8TICIiZpXLot1HSq5+vsG9NEKQ5czQBYlUqJR75OVfFDr3cGOmRU/CtHDWnS4tm8nW+Z4Y357qGToSfYqFvA==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [android] - '@oxlint/binding-darwin-arm64@1.90.0': - resolution: {integrity: sha512-PSrxMvP6mx+p1karZcUxLdy9lpaP+JWQPti4al9FgTaPhxE+pT/BjhGExloVVSWgZgIfOlLOjVyyq8BXlodhLQ==} + '@oxlint/binding-darwin-arm64@1.94.0': + resolution: {integrity: sha512-NePcRMO/ltt1Pnytohl6pl0bd/QyRX8HbpptuDz9LK7FTsFD4lKxDMBt7di9k6IFLO0J05jO2nm7wGqIh6dRHA==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [darwin] - '@oxlint/binding-darwin-x64@1.90.0': - resolution: {integrity: sha512-OLbU9qsrV2Q8QxT2OEzOPdO8zCCpyI8qB+hDI8yr6RsYELtkf0FAZhJdfjM/RnLHKzt44HWwAPnk92vBtKofvw==} + '@oxlint/binding-darwin-x64@1.94.0': + resolution: {integrity: sha512-QV+m+OaEgLmYyillvP1wKXhMm6tDZEWx3vG7Wjmx9ybg15+6YMfqzvp6e+uPukC6zNywuule0vMn0fZgihZzZA==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [darwin] - '@oxlint/binding-freebsd-x64@1.90.0': - resolution: {integrity: sha512-fBA4pWyVDARmNucQqpyFuPC49xYf1r+sX7dxPL5fNPQrSMLum39Sn56tZ9JPleWC7FzLPwSQ7plYYfirYBHF8A==} + '@oxlint/binding-freebsd-x64@1.94.0': + resolution: {integrity: sha512-KVZjca581nrV6P71kZ9M1otBib9LH0IMn9rr4mrnbRp18V0HiZhBHbU26gji/Ieq2G34qMacnMc3zrmKmvWqWA==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [freebsd] - '@oxlint/binding-linux-arm-gnueabihf@1.90.0': - resolution: {integrity: sha512-zhxH78eP2nR6/pGdhBc7MIfjhhcgATeu8fkmkFJbuzfk6Cj0FzBxyEhL85yDqrCybjx+G2YDzZGsxIO9kvO4Iw==} + '@oxlint/binding-linux-arm-gnueabihf@1.94.0': + resolution: {integrity: sha512-AMQtgQJk8DgdIV+qaQ5sFoHAko4iKa8zo+gYqELy2grtU8hXWB08DAGB3u90aQL1YSxbd3zqHjgcODBHDFyzBQ==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm] os: [linux] - '@oxlint/binding-linux-arm-musleabihf@1.90.0': - resolution: {integrity: sha512-MvYmpHyJqUJjEvkZbJHdwfdL45cGn8EVBkYmoXFiaYFW9suoD3dbJl5mBdpy0DVgdjlyddmldbRtk3cCgETadQ==} + '@oxlint/binding-linux-arm-musleabihf@1.94.0': + resolution: {integrity: sha512-ZLzoGVGAmQkp9leeB5rNxAXLcvlmkmd/GY71LKd5uikk+28NEApY3S2FB3pq6MkfOCFFnFg6QgD9lJIjd07D0Q==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm] os: [linux] - '@oxlint/binding-linux-arm64-gnu@1.90.0': - resolution: {integrity: sha512-L13Sy+Kg0nZhwTsToniqjUFPA2TuM6962qCZ5Wp5KeB517Tw7ApdLTTtlb+bF86fcZZa2EtvCVvAJxk4Dya/MQ==} + '@oxlint/binding-linux-arm64-gnu@1.94.0': + resolution: {integrity: sha512-N1dW6o7cY90hLVkDsvz8nWIFOwbO+n272pvW7uLYB7u47HagJVnLChfK6QA9dWFdiPudud9zfksVUOciHc5PNA==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [linux] - '@oxlint/binding-linux-arm64-musl@1.90.0': - resolution: {integrity: sha512-wFDdZWGpzIPFdJFjSLWnKB0TGzFriTKUIrl04iMqMyM9BBIJTuerfCHYa0WpDSjr5x3lcW/CHLyacSt886WpGg==} + '@oxlint/binding-linux-arm64-musl@1.94.0': + resolution: {integrity: sha512-7tCF4OV/bGDQ2xxgb+sDI97SpmmDrUII4JxTG553voJVA9cnkbXSGSXzo78Ax73BuhEOPoQc2Qi6VrfT0cDG2A==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [linux] - '@oxlint/binding-linux-ppc64-gnu@1.90.0': - resolution: {integrity: sha512-FRywfn+MoKn8xpBSzgNwNVliSKRI2QXkxi/iF7o6FEQs8Bh8z2RpVTaFAcO3pchXjvB2eGNFIoLLQABIQ+u7VA==} + '@oxlint/binding-linux-ppc64-gnu@1.94.0': + resolution: {integrity: sha512-B5vUHE4wNisVEuaYxwFUn6tY+vw7A+9APxxqGKI+UmP3yKLpkhnt0qsaCrzjpX55F8rCRHBaTvIDdYo32NE36g==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [ppc64] os: [linux] - '@oxlint/binding-linux-riscv64-gnu@1.90.0': - resolution: {integrity: sha512-IS2PaUgpc/qeLADTyhUNmdx3x4ijs9pjJdPKBYHaT+mAE7k3FsjnHPTjhpsak1b++h6CIPhv6WX9Z+y7Pw0voQ==} + '@oxlint/binding-linux-riscv64-gnu@1.94.0': + resolution: {integrity: sha512-/U0b15+c4hTodo8YhEqDlQ6OjnGKvc8igjM/mh23ukqqCUBKiBCaxqUV8bcaofK9uZ+f8wCygkyXLS6LN25YSA==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [riscv64] os: [linux] - '@oxlint/binding-linux-riscv64-musl@1.90.0': - resolution: {integrity: sha512-s7JFKRkGS8O7i2ZVODfuO++NC7sH6HDqpMn8lYxw91w0SXJOxnAVjQ8utvmDwLMMT0jaSkuOKuUYJDGDtu4sHQ==} + '@oxlint/binding-linux-riscv64-musl@1.94.0': + resolution: {integrity: sha512-ba94Vwl0qOnwXIXNDR33AEbLXuX++ckM74t+9Te7CiPSPAHivhOYyeEkUAicrvOEei1pxXkWggLbFeBFFBTuHA==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [riscv64] os: [linux] - '@oxlint/binding-linux-s390x-gnu@1.90.0': - resolution: {integrity: sha512-b0GxrOQr5VONCkd7KLSqmP6b6nqZuTpuS8QPQHzltmqdXP5bY0Jl0CZ0QmlCTrS3ExaLYbioFYOARzNbYvcApQ==} + '@oxlint/binding-linux-s390x-gnu@1.94.0': + resolution: {integrity: sha512-GVwwwms3O8pdgbCiPavwq2vltyB4661GkDz6kJduZ0E5nsSJUDJ0svaP+ePYpuDVYi4+K1qhCKnWa/Ec8I4LUA==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [s390x] os: [linux] - '@oxlint/binding-linux-x64-gnu@1.90.0': - resolution: {integrity: sha512-iaJeShJtgUp8rZbt9YUdTAGOpmX5KogCLba17Jp1tWdJ3F4M3D2g2TKUyI1FMTHxKH9NNHuQcuC2kZRg6IV7yQ==} + '@oxlint/binding-linux-x64-gnu@1.94.0': + resolution: {integrity: sha512-iUfCFJN8ZIresSnpTfiIkhF3s8X+XA4I9KJ249QwR2QYTMwh0+pla1pj1xaFi+HtR9McjM4Jaemf70HzX7ilOQ==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [linux] - '@oxlint/binding-linux-x64-musl@1.90.0': - resolution: {integrity: sha512-/aZoXnL5WBLCXuzfHqvEFXcm4iwYmr/cYByHDTXzLFzJdE5DC7bm6phpWqHv6BeqpVgY9IpBAxGDv2WEkl5JCg==} + '@oxlint/binding-linux-x64-musl@1.94.0': + resolution: {integrity: sha512-RqWVeWpDACS4Oh0m21OBmy+CQ50CbbhuHFmNNPVS2P/4R3d188MjEuEuV7So82/tAM8UAT+UuMDtRDESd9NJ7g==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [linux] - '@oxlint/binding-openharmony-arm64@1.90.0': - resolution: {integrity: sha512-SMhk7ozwoxYDKfYqGZCQEfULOKDneF9uhaoIf2neoDLWvNtjY9yVeL7YHmE5L9WdKvMpWNwwZxhenxBu6AgfOg==} + '@oxlint/binding-openharmony-arm64@1.94.0': + resolution: {integrity: sha512-K/2DHOUoypwYVqzxJMRPdMuBKjAetZEAsGPP7rHimd+2+5J1TxM+17pG8kw+ayH4+rqBXiPd+H9wgPcU+fF77A==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [openharmony] - '@oxlint/binding-win32-arm64-msvc@1.90.0': - resolution: {integrity: sha512-KBvR3A9fO7fCi2vCP8ifWvlia7tGEQV9NaYh+IGwa/7Groy48Mt/UaYqMK9/zOtAWl20BUCf6RPqzJ32fRw33Q==} + '@oxlint/binding-win32-arm64-msvc@1.94.0': + resolution: {integrity: sha512-hYOCaOJiB4ZCGswBWKl3JQrhqu6mnC5DCUw/1UMNzRXgsHIJ0V226J43LAVICVIDGlhFUZTYShFW+wHWpt6qCQ==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [win32] - '@oxlint/binding-win32-ia32-msvc@1.90.0': - resolution: {integrity: sha512-+x42rDHQGbTCuT3EzpWAzhP3NoVPE/cJsG4gnrakOSg0olV+GCdMpPU23Nvrl3zZMnXxFZdTtDv4D3SuaA5ZeQ==} + '@oxlint/binding-win32-ia32-msvc@1.94.0': + resolution: {integrity: sha512-1l1FDlzbPmAeDoZ8UGspOE2dOmz1ZL6SlDsvOmRCmWSQjCdTy5LzUepS8mO/SGpAoz4D6WAt/yNZAUyHqbkmkQ==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [ia32] os: [win32] - '@oxlint/binding-win32-x64-msvc@1.90.0': - resolution: {integrity: sha512-30JiaFEBUB9peEOcvVM8ggo88SoN/IdSr9DW505JdBji/R6dM66gKEiG65hw6qcaF2f4mO0cEJ+RwRZprmun9g==} + '@oxlint/binding-win32-x64-msvc@1.94.0': + resolution: {integrity: sha512-I3eZdd4bemIJQDNv9XDV/FEofDxIoN32tzCv98wIgLdW05EqxZb5hF4AwPrRzHD/dQhl0n7KgPy5AQPfM0HWrA==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [win32] @@ -475,14 +491,14 @@ packages: resolution: {integrity: sha512-4EDEmvxWtgsCnnVeBvtFIFZtUhPPt1+bA9JrSwU4Sa//6oKtzCSlGGXYJr44OD9aGISymbieJ4mCKHUygUDU+g==} engines: {node: '>=18'} - '@react-router/dev@8.5.1': - resolution: {integrity: sha512-1NQ/lP8m7Kd9G4cGKPoEMZe0qcWOnRkf8QxpAcnX/3V5wJp+/mDvM9QUqwUxI+RywytNNGtc4uuDFhwt0xMLbg==} + '@react-router/dev@8.5.2': + resolution: {integrity: sha512-G1Xg/oh9haQCFQIeVMSuE6jUltSbV0XInSpyj4ckfRN68tkRYI9HH3cVu8tOh5qhsIgNBQTFHzMw/nvWdz5WRQ==} engines: {node: '>=22.22.0'} hasBin: true peerDependencies: - '@react-router/serve': ^8.5.1 - '@vitejs/plugin-rsc': ~0.5.26 - react-router: ^8.5.1 + '@react-router/serve': ^8.5.2 + '@vitejs/plugin-rsc': ~0.5.38 + react-router: ^8.5.2 react-server-dom-webpack: ^19.2.7 typescript: ^5.1.0 || ^6.0.0 || ^7.0.0 vite: ^7.0.0 || ^8.0.0 @@ -499,11 +515,11 @@ packages: wrangler: optional: true - '@react-router/node@8.5.1': - resolution: {integrity: sha512-hEr3YFQaSoQL8T85+DqNOpdDLfuD2mKEeGdQAEvfix2bQdCtcpatE0uzB3zYidIUex0iEJG/eOZdAjLrzlJrjA==} + '@react-router/node@8.5.2': + resolution: {integrity: sha512-cCL++xjTaVV82WYXT1j3tYqDmiKXL3fFA7tS7iXyGTJmcvHMvAxmK9v7CMUZbHIdO686V9HB0ULCr2PCu/S9CA==} engines: {node: '>=22.22.0'} peerDependencies: - react-router: 8.5.1 + react-router: 8.5.2 typescript: ^5.1.0 || ^6.0.0 || ^7.0.0 peerDependenciesMeta: typescript: @@ -515,98 +531,103 @@ packages: '@remix-run/route-pattern@0.22.1': resolution: {integrity: sha512-czdGJWh09Lapvcqt7Vb09KlrU2PhRJ8xQaI+AItTuD9aDJ5MAgxnS38lnys6Ll+6RJEqPiaUqTwIQhVLwFvv+w==} - '@rolldown/binding-android-arm-eabi@1.2.16': - resolution: {integrity: sha512-ia3DwAs0OsMGS7+IConptSiyk9pEXkOx/AbJ2n/lAGxH3QkWQus1t8d7gnAT38FCU2sQu8lUbeR6AiZFv4JxaA==} + '@rolldown/binding-android-arm-eabi@1.2.19': + resolution: {integrity: sha512-e+Ebe0WT+9tbXmNKPIiC8YrWAHYwug3m6i4p3rZGGulfZri1jtI4HslT+OZnFf/OIHowWF71DTlHwXBP2SiA7A==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm] os: [android] - '@rolldown/binding-android-arm64@1.2.16': - resolution: {integrity: sha512-kx5wBiMB6E7TEvpl2B9gjLU004BkvEm2Dr941BFjx/SontPwSzNuQUIoVKxHHoSjpFIfHMmcguyLOtyn0hObRg==} + '@rolldown/binding-android-arm64@1.2.19': + resolution: {integrity: sha512-hOombrTJ+szt2ciEzS7oCA78lMPBgF5UMQWCJIyNfnrI7GLl8HYoFqCnpL2gcPOaXMqryGCU5ExdQKyDDcC+yA==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [android] - '@rolldown/binding-darwin-arm64@1.2.16': - resolution: {integrity: sha512-qslZrXnKJU4cUpjoAmtAo/KQM9e2IRMlmpig6Zpwj+8KWxW8v+nkAf9216Bsek9lOC1jvg2yCjygCFo2f83msQ==} + '@rolldown/binding-darwin-arm64@1.2.19': + resolution: {integrity: sha512-XoMA2pwCKGTQzUjPgtRwkedH4WmXhdIPKT6l6oOxd1PUbNodGI6DcBekgN7EC//+x3pfBYX/qL1gNmZAqivw5g==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [darwin] - '@rolldown/binding-darwin-x64@1.2.16': - resolution: {integrity: sha512-FdF+y48ND13eAyM2mQn+85kvAqNlvRWROy2rhgA463X/0Gv4vGtazZtfaF1mRBLscYvtOlh4QnLjOWiFzX69OQ==} + '@rolldown/binding-darwin-x64@1.2.19': + resolution: {integrity: sha512-zo8EsSSwMZCY/e+fRnGaX02YGgvJD0yvhNi/9hpGPA2MJ9ZF8dPCw75UGfpI6OpQ/myR/dIYmogRvqiZD0TrXg==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [darwin] - '@rolldown/binding-freebsd-x64@1.2.16': - resolution: {integrity: sha512-ddjqFM5e95AgLbUPtKIS7V1KTVlA0RUgCVr5mn+/IEhsdy3pr+Vuj/HZ7nlMN2FyxIwUktOH1LEPIQXO1v9y1Q==} + '@rolldown/binding-freebsd-x64@1.2.19': + resolution: {integrity: sha512-O8ISAOfI1nj7AuBPd30FSF47z7f7lzlk5poQVGgiikvQuGEBFYvW8ki+UEnT+YJPnNGjQzn304klt4O9FUE7mA==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [freebsd] - '@rolldown/binding-linux-arm-gnueabihf@1.2.16': - resolution: {integrity: sha512-tHdKWbFkFBI687iim3LIyIvyL7j66VvQYkDPss5Stn/qyE2tWkR1YD0dXmXPFKKqT/o5ZEJVsaRsWS2meQwGOA==} + '@rolldown/binding-linux-arm-gnueabihf@1.2.19': + resolution: {integrity: sha512-/lYCba5NO0yq4S0jGMH8QTBtkvQxoXjoQWzF5BcWp9MjB9jxVRD1GQDNofkVjcOj30DWyhLIN/4Oe60JKzaONw==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm] os: [linux] - '@rolldown/binding-linux-arm64-gnu@1.2.16': - resolution: {integrity: sha512-FJiLGAblPBMlBEdbOqw6kW6QcXDWAf/oJu7gYs9ZJZwmg+K+/zjFLxPTIY9izJUzxzc24FHvmseyA0IvJSl17w==} + '@rolldown/binding-linux-arm64-gnu@1.2.19': + resolution: {integrity: sha512-pm/apFMBnSbFb3O6nG5pHO1iqHhZrjGDFEjSm+ot9J17XXPvH9L90y5h+jgfHCE+Qdlsvy8qKEcU4VKxgjD+vA==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [linux] - '@rolldown/binding-linux-arm64-musl@1.2.16': - resolution: {integrity: sha512-hrJpblMsrQ58U9veWpbXzkhV5zStunds6HWLprqq1qauvgBr1E6P+24kLj6lSLI9vjRn/RYpjprhkHQPKGWpNg==} + '@rolldown/binding-linux-arm64-musl@1.2.19': + resolution: {integrity: sha512-K1SmQp3FFichn8oqrNIwvFoZ5wcvjC7goBzpaMNvLf9FZc+QB/QvLmnpJZgAAGHiD980tP8FZZnXk2K94rvlxg==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [linux] - '@rolldown/binding-linux-ppc64-gnu@1.2.16': - resolution: {integrity: sha512-qJd/dC6j6CwLG9/s/RP2nb1RZ0GIgj7Ioj7x/SYa3RzjVrlzrmH0fhIOpfvqQDeIsdP0loi+kHaMhJzY1PBIaA==} + '@rolldown/binding-linux-ppc64-gnu@1.2.19': + resolution: {integrity: sha512-I0xwD57jP/3A7+5UPZin2w8Y7XHEmEM5zqpYZOcQ45MlNW6tUJUziymV3yRr7rL4vwyfEcRsRksC4a7Kc08p5Q==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [ppc64] os: [linux] - '@rolldown/binding-linux-s390x-gnu@1.2.16': - resolution: {integrity: sha512-Vx7Xg5uUJuNcujJjI70OICaH0EYj80BtOLZTSN7uOYg8QOLlyKnaG0IW7Fn/J0IpJsaKzmDKMhOQv1JBM9m9vg==} + '@rolldown/binding-linux-s390x-gnu@1.2.19': + resolution: {integrity: sha512-BrtEHT24SNXj9HiXqy+s/kXiSiQGt6EKCPUlRirAoIioVxKGnbXBUEkbZASAei7iZJB0/Ynm+0JP00Ipx7AnSw==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [s390x] os: [linux] - '@rolldown/binding-linux-x64-gnu@1.2.16': - resolution: {integrity: sha512-TNKhgE3uJTsTzatUSSYt0Kgo+Oa2uSlSjz4r1aEIea7HX6ULBym4fAlYUhG1i6pjNf2njfCUAfKwr6C3E9Xg1w==} + '@rolldown/binding-linux-x64-gnu@1.2.19': + resolution: {integrity: sha512-rm75/9DkHKeU2WnA8w4X94WGYgLlDCFCfkQC+4bguVJmC/jvDRv2B+2wLOYhyE0fVuv7//Ckk39OoOufyCu76Q==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [linux] - '@rolldown/binding-linux-x64-musl@1.2.16': - resolution: {integrity: sha512-7chXdpjXZ8qG0+mIxECN3cT9kvhZ3/oZhMX6Pp876P7CDrIy8nJswva6Mq357JR7eYXfuskwZxMeV1SzoZdHrA==} + '@rolldown/binding-linux-x64-musl@1.2.19': + resolution: {integrity: sha512-irh/4+iYFM4GAzpluDErgjz89bj6NDtqqMAG/6O1LG38Ed3NpyebzCpcVNkFW8uhy+/3/BocUvnXDR33CXWe9A==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [linux] - '@rolldown/binding-openharmony-arm64@1.2.16': - resolution: {integrity: sha512-Kwjt+7uNTJK5/MDkGWGVO2KQPnj8yAV75dMpfwyHZrJSXWHrniOB0aUEWlVYf3H1hOqFLIStLdM5QXq6bnKmOQ==} + '@rolldown/binding-openharmony-arm64@1.2.19': + resolution: {integrity: sha512-+KWTWNoPt+CfSq94CiceWu3yPE+QzkaG+phPyz9G60tmZLwfQkcA4AeksafzvJAw4pvg1mcd5a1TkUqVv0s4JA==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [openharmony] - '@rolldown/binding-win32-arm64-msvc@1.2.16': - resolution: {integrity: sha512-/LH6WfjDRXXJz/p5xl4TmU+jpcnwcxbKEQBW/GZE0JHfN0lGIyTtsUEGaQ/q/GikkGJ2yLKe6pwm7AnEWO8pdw==} + '@rolldown/binding-wasm32-wasi@1.2.19': + resolution: {integrity: sha512-7EH+skOsl5qpWnK0vzamgJFhOv1cwxQpsxm8tI883K9fur5c27p8q87fzEO6BbBPabA2/+s/zR63/pLc137iOg==} + engines: {node: ^20.19.0 || ^22.13.0 || >=23.5.0} + cpu: [wasm32] + + '@rolldown/binding-win32-arm64-msvc@1.2.19': + resolution: {integrity: sha512-3Q1Yg1Q7tEvBWoZf5rFvG/GKZQPgwfru+p4wBajDfJFBs0SHCpL++dfTjW9gyAKd1T7ZpIYvdaUax7Pa/IhFVQ==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [win32] - '@rolldown/binding-win32-x64-msvc@1.2.16': - resolution: {integrity: sha512-1lv1KvX0Z871zfk7vw+dnXMMnHNyDwMzWG8Kv3HxDXMOhzCX4SHc7HK319fInP0i+0p9D8brkfzL7pJOaGl+tw==} + '@rolldown/binding-win32-x64-msvc@1.2.19': + resolution: {integrity: sha512-y/sqRRc6d7hECzOFc5n3LSeqctmIp9mMjY1Kq4s14uLPd/LZ4z7i1zrW6fMtp2mPeuQIC4e6ULMcwQzMomqQag==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [win32] - '@rolldown/pluginutils@1.0.1': - resolution: {integrity: sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==} + '@rolldown/pluginutils@1.1.1': + resolution: {integrity: sha512-glFIJDvLNDtJhT9qrMFWLPbvS+skxgt4L0K8Ei2YtnhPysAJnsI7nyxSJxKj4ADeKX0OLjC4ntRkwpLOoS3rwA==} '@sindresorhus/is@4.6.0': resolution: {integrity: sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw==} @@ -623,22 +644,22 @@ packages: react: '>=18.0.0 || >=19.0.0' react-dom: '>=18.0.0 || >=19.0.0' - '@tanstack/react-start-client@1.168.44': - resolution: {integrity: sha512-WvrYhQ0EgwYpxnP9mFCCo+jctqXV3qq8GfIyiSGLiZzz4GDyw+GuQ2lyA3BTN64wbNNNVeMll+9PV5OlGYi2/w==} + '@tanstack/react-start-client@1.168.45': + resolution: {integrity: sha512-DzTCJS+TVFIEs08w9RQGOEp7dtVCEIUU3y6Oay+mXOqoRk62T0olohHbNR9A4Z1my2b3hVdMjg9KG18WOckQYg==} engines: {node: '>=22.12.0'} peerDependencies: react: '>=18.0.0 || >=19.0.0' react-dom: '>=18.0.0 || >=19.0.0' - '@tanstack/react-start-rsc@0.1.65': - resolution: {integrity: sha512-5MmzmQoADjMA/d2XawkwKAkgBaQFrfifw/wn8qwCaLIntGYd2jkrCga/KdQW2xdjBu9IoP98WFhZilm7DfI/4g==} + '@tanstack/react-start-rsc@0.1.68': + resolution: {integrity: sha512-vwJ41g2HMlxeF1ctnzORXBcpiXBij/IqENHKl1zOv8hsS0mslvqfio5SdCFo/4GKAOjcZWmxqG5GJoJWmryDbg==} engines: {node: '>=22.12.0'} peerDependencies: '@rspack/core': '>=2.0.0-0' - '@vitejs/plugin-rsc': '>=0.5.30' + '@vitejs/plugin-rsc': '>=0.5.38' react: '>=18.0.0 || >=19.0.0' react-dom: '>=18.0.0 || >=19.0.0' - react-server-dom-rspack: '>=0.0.2' + react-server-dom-rspack: '>=0.1.1' peerDependenciesMeta: '@rspack/core': optional: true @@ -654,11 +675,11 @@ packages: react: '>=18.0.0 || >=19.0.0' react-dom: '>=18.0.0 || >=19.0.0' - '@tanstack/react-start@1.169.4': - resolution: {integrity: sha512-+DmlNPeQ1rsvo025I79GrlNgDm+zVCVAGg9gMIGmAevK2TJRMpKahgEKZZ1j4VSxDxjfTpkfLyuXiUxxjMJCaw==} + '@tanstack/react-start@1.169.7': + resolution: {integrity: sha512-8/Qg9iVC2oTtAqSdLdML2K+MZ8eBZe00pe6k54CkWYA4nRmrNyN/n2zbMW+rtjDbLAPeQck/1hgS6QBlblPGnw==} engines: {node: '>=22.12.0'} peerDependencies: - '@rsbuild/core': ^2.0.0 + '@rsbuild/core': ^2.0.5 '@vitejs/plugin-rsc': '*' react: '>=18.0.0 || >=19.0.0' react-dom: '>=18.0.0 || >=19.0.0' @@ -681,17 +702,17 @@ packages: resolution: {integrity: sha512-qUhoJ0meuSUqGYQbHbcJYdASr06YtK+bulbj6vtrhKYFkLgkSsZ6tXmMyym7sFxiSJSPYgasgozrL01LyyR/6A==} engines: {node: '>=20.19'} - '@tanstack/router-generator@1.167.46': - resolution: {integrity: sha512-JSailAThcqPvqBzE3+MhNh6zQyZM2IdmIsHOxZgAc061Lh++SZqamNm/Whe7QNXWK5sLP4E0J1F8AI0hP8wTSw==} - engines: {node: '>=20.19'} + '@tanstack/router-generator@1.168.0': + resolution: {integrity: sha512-Ty3y1g96Nq4yMojTH+OTgRFp0oa14LBKhiDW8+SrsdgW2mCpPRzZ8Ix7jjztxmkS8O+AKc2WaLkSskGUe3oEDQ==} + engines: {node: ^20.19.0 || >=22.12.0} - '@tanstack/router-plugin@1.168.48': - resolution: {integrity: sha512-oLDEZO/vhvF5JLrQ6qMNYcCjMMhlHA0Byx6ZXl9AHJ6qVLRxUeCU41vlZQ4buisONY2p0Zl9O09/qwLiVrIBCQ==} - engines: {node: '>=20.19'} + '@tanstack/router-plugin@1.169.0': + resolution: {integrity: sha512-aulFJmvW/rN5zQg/IM1Z5iUueX9dnYjBKxNpFWstpHxbatdlRlEwtSrc57VlBmfzRuckVxpZLi6wH3O40DMLgw==} + engines: {node: ^20.19.0 || >=22.12.0} peerDependencies: '@rsbuild/core': '>=1.0.2 || ^2.0.0' '@tanstack/react-router': ^1.170.46 - vite: '>=5.0.0 || >=6.0.0 || >=7.0.0 || >=8.0.0' + vite: '>=6.0.0' vite-plugin-solid: ^2.11.10 || ^3.0.0-0 webpack: '>=5.92.0' peerDependenciesMeta: @@ -706,9 +727,9 @@ packages: webpack: optional: true - '@tanstack/router-utils@1.162.4': - resolution: {integrity: sha512-3TSH3rwAQTqQOtTBF8IXMFXmGNJWnjwIm+l87uguyC/of0pSRKcU9GJrozaf0fY9it8dLQvUZJA2MOlfqbW1sA==} - engines: {node: '>=20.19'} + '@tanstack/router-utils@1.163.0': + resolution: {integrity: sha512-OMeFv8aRwk9Xtf3JhRmQrjtMxCj7qqfnsueASuL8xUgItoblIL9eCIyt4Zv0hk3LBp/s7NqviZgQhiAfDhJb/A==} + engines: {node: ^20.19.0 || >=22.12.0} '@tanstack/start-client-core@1.170.39': resolution: {integrity: sha512-G0VJbZFf9/dYomQjZkWapaTjkjEI4vbk1jnxhhVtQ3nTRb3sIRc196j+S+qZcySfEV5W9TJHu4KatjSzjZZQwQ==} @@ -718,11 +739,11 @@ packages: resolution: {integrity: sha512-QWfUZ3Yo923tdQn38LyKMU8rcTw69zc+T4dAvgTWV4O56SqFRsGfS0lSWIMhJRwXIx/bvdi7nTUBDdZtTHtpTQ==} engines: {node: '>=22.12.0'} - '@tanstack/start-plugin-core@1.171.55': - resolution: {integrity: sha512-8FjTuuxIE8MNJoveXahZPBCfEpm8p9tMFyWTvbllfqlysdhry34rw/nCwULfcVwTG39ezXEu/RYE83NSV+miog==} + '@tanstack/start-plugin-core@1.172.0': + resolution: {integrity: sha512-8VbVDauTOvlersYJcJe/wlIQ3LqPV1oQnWiGwMKilA2Z9r1sDhts+7SCIHBHqr9BjK0Z8w1+X0CKvCygNeD/5g==} engines: {node: '>=22.12.0'} peerDependencies: - '@rsbuild/core': ^2.0.0 + '@rsbuild/core': ^2.0.5 vite: '>=8.0.0' peerDependenciesMeta: '@rsbuild/core': @@ -764,6 +785,9 @@ packages: '@types/react-dom': optional: true + '@tybys/wasm-util@0.10.5': + resolution: {integrity: sha512-dOGOPxlaNV+G046mZzN+9C0dAcQZeSKcXiVaM0TYy/LM4ttTmgSBDxYfovcYI8Em3+eAbiAYpvWLOv8+ZVRJKA==} + '@types/aria-query@5.0.4': resolution: {integrity: sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==} @@ -793,13 +817,13 @@ packages: '@types/ws@8.18.2': resolution: {integrity: sha512-67MQl+fpWKVTT1NYdnmo3U4sc/xPo/zQBncVnI74qmQa0z/b+1g6iYqNmGCPbxO+zz2aklb08a0oHfegiVd0/w==} - '@vitejs/plugin-react@6.1.2': - resolution: {integrity: sha512-fhJNGUdscQa4HkI0xFxwonWyhnVReCPDbXI7FH7jmzpnVCrFQI7PRrhWecO263610vOrs9tr2Y4xcf8uAdFxbw==} + '@vitejs/plugin-react@6.3.0': + resolution: {integrity: sha512-H9E955aVvD2F4zNHCw4eIZbIfF6xKldlh7MNu+hSU7xwQzh65lI/N+CJWqmfhi0PEjDXIt/H7T7J/4wU63KJiw==} engines: {node: ^20.19.0 || >=22.12.0} peerDependencies: - '@rolldown/plugin-babel': ^0.1.7 || ^0.2.0 + '@rolldown/plugin-babel': ^0.1.7 || ^0.2.0 || ^0.3.0 babel-plugin-react-compiler: ^1.0.0 - oxc-transform-react: ^0.152.0 + oxc-transform-react: '>=0.152.0 <0.157.0' vite: ^8.0.0 peerDependenciesMeta: '@rolldown/plugin-babel': @@ -809,8 +833,8 @@ packages: oxc-transform-react: optional: true - '@vitest/mocker@5.0.5': - resolution: {integrity: sha512-xLL3lkDegJZw+MGoGaCCsFayDZthGgpAtr3Vziyfc4p7xH89K7KRPcRBBh/kEYm0Aqkt5DtTmkYpBtRV/FrHZg==} + '@vitest/mocker@5.1.1': + resolution: {integrity: sha512-b2OgTB4+3ImWIVafXKazJXwLKwQxUNnix6b3xUvUTMh7RyXlrtzoxfZr8aEz9zkHOMAS4K5lu3TvFWoiVeVTQg==} peerDependencies: msw: ^2.4.9 || ^3.0.0 vite: ^6.0.0 || ^7.0.0 || ^8.0.0 @@ -820,8 +844,8 @@ packages: vite: optional: true - '@vitest/spy@5.0.5': - resolution: {integrity: sha512-lwJRExuH417257Q5wv9QYugN9IMJkoxcrKrYxGPQkBzl7wlNpTUxD/5yNX4ESKVUIShKPgkGchYPFMWOOk0wzw==} + '@vitest/spy@5.1.1': + resolution: {integrity: sha512-6K8C6alQG1/Yc8/ZI22iJS7JEsxPdVzqtqDq+/xM4Z0mGVykemMVjLhqMy/q6/IHYG3kKD8hKSwRen/ZdyI9vQ==} ansi-escapes@7.3.0: resolution: {integrity: sha512-BvU8nYgGQBxcmMuEeUEmNTvrMVjJNSH7RgW24vXexN4Ven6qCvy4TntnvlnwnMLTVlcRQQdbRY8NKnaIoeWDNg==} @@ -843,8 +867,8 @@ packages: resolution: {integrity: sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==} engines: {node: '>=10'} - ansis@4.4.0: - resolution: {integrity: sha512-9k3v7xcHwgdO/DruxGIg4HtjvlAZlcnsX/mzqUb1t3NkYnl9kK2UJ+Gq0io+vQf7iT//BD/HB/NBkUR1LWxoeA==} + ansis@4.5.0: + resolution: {integrity: sha512-KwIVkfFfJSSzBmZhDGuTmkhWqTdyB5oNVzzznBJbBZ5bZtHiqSrcugRF0RKJKT4Ss3d7ZrcjnlFVDlQNmtWfWw==} engines: {node: '>=14'} any-promise@1.3.0: @@ -863,13 +887,13 @@ packages: babel-dead-code-elimination@1.0.12: resolution: {integrity: sha512-GERT7L2TiYcYDtYk1IpD+ASAYXjKbLTDPhBtYj7X1NuRMDTMtAx9kyBenub1Ev41lo91OHCKdmP+egTDmfQ7Ig==} - baseline-browser-mapping@2.11.34: - resolution: {integrity: sha512-Aqr8mA1kIvyJ3UY5YAY7ib8LSo1DmDMbMnVqGPtsKW1LxaFQFwn9Eb3yvq2fUKJsRvaXjnAV7R5osqETapzNiA==} + baseline-browser-mapping@2.11.39: + resolution: {integrity: sha512-Q9buOYhr2ggrEZpImICecZTJHCCd8yXkRUokFlUEQ8uiD6oP82F4W4jWnhOHZYV+wlvrC51V7Wy0ULyWjil5Wg==} engines: {node: '>=6.0.0'} hasBin: true - browserslist@4.29.5: - resolution: {integrity: sha512-khTmKu5NGYTotqcYo8Bew2k4RAE9PuXRSFRXG2lQBrCEQHyeQ/vX6gKMxfokwywBsLiXZMnHsmWMG1pnO8J7uQ==} + browserslist@4.29.6: + resolution: {integrity: sha512-CmVVIQ3RVc5HxYEc9X84GvxK/C8C1wH8TlKAiO7uTxF8PDwt7r8t9Qk3J9NkMOVzX5O/HbLv3yzxZg9HPrnI9w==} engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} hasBin: true @@ -877,8 +901,8 @@ packages: resolution: {integrity: sha512-nEh+kZOPY1w+gcCMobZ6ETUp9WfibndnosbpwB1iJk/8Gt5ZF2bhS6+B6bPYz424KtwsR6Rflc3tCz1/ghX2dQ==} engines: {node: '>=4.0'} - caniuse-lite@1.0.30001820: - resolution: {integrity: sha512-gfWD6MxqVCqAOwmODfZf7DchWvlrA+SRdNX7ceLfg3xRqe5ssjjpF7EgslC/0tiLiNTajdaNN/q8c/5u/7Gz8w==} + caniuse-lite@1.0.30001826: + resolution: {integrity: sha512-wTB+9tIbLro/BCXwLuNV1meHE4L9dS6dArMDwgYfNBPMYScqClHyGunhkCSDtHhe/69Xl0sHlKgBVZ+fNsYtWA==} chai@6.3.0: resolution: {integrity: sha512-XWAtwJ6OHO+tj0EKCs0Y2UamnyOxseZWltU4x2U2wh8g4AigdjwvtUjvLP2tqkA/avxHEtzxNaqGq/YGNwckKg==} @@ -970,11 +994,11 @@ packages: dom-accessibility-api@0.5.16: resolution: {integrity: sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==} - effect@4.1.1: - resolution: {integrity: sha512-XYu65BrcmNqu5i7PPvP4dqL+R5ma37zIsfuSPjcn78mog+6e5PkilNg7Xo+pBpjXJYlWEIpH4j91tMrfW05CMw==} + effect@4.1.5: + resolution: {integrity: sha512-xyR20KhQI0vg2gD8ILUSQRTTESEYJ0JKdP+QD8J37xbwPTqXRxFM/l0+vUVD9fuSvoYruoTqyt33C4FZv1s4TQ==} - electron-to-chromium@1.5.472: - resolution: {integrity: sha512-s4+nfT29b0FKpVKoaIxl2pWsoNcn7A/nMPSrxayw4T3BsmPeV2lF9Y06BsAQeMGhCTQ4nYJ5XST7jkqe4ZEqFw==} + electron-to-chromium@1.5.492: + resolution: {integrity: sha512-4uMs7omhajKiud0GqALLTazS/zyvHLTLmDWVTR+e6BnyJo5bSNrph/JoRWEFJJmY75ct9hCiSGsbFF9fLe5gDw==} emoji-regex@8.0.0: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} @@ -1063,6 +1087,10 @@ packages: resolution: {integrity: sha512-iQcBXcd+Rv/pkubRyGh2utW2j1oPG5hZY6TUhVPpqK4G+o3IbxpJNx04hgksjc/N7GK5pEorUxDeg31cFgEk/w==} engines: {node: '>=18'} + isbot@5.2.3: + resolution: {integrity: sha512-e8gGz3VzAuImtTMnB5PqNRRWGAswObTc+X+X5a8PttKT78VSSFec98w9ZwUoy6jJdlvJkVdLiN+WMgA8TewoZg==} + engines: {node: '>=18'} + jiti@2.7.0: resolution: {integrity: sha512-AC/7JofJvZGrrneWNaEnJeOLUx+JlGt7tNa0wZiRPT4MY1wmfKjt2+6O2p2uz2+skll8OZZmJMNqeke7kKbNgQ==} hasBin: true @@ -1204,8 +1232,8 @@ packages: resolution: {integrity: sha512-Z3lTE9pLaJF47NyMhd4ww1yFTAP8YhYI8SleJiHzM46Fgpm5cnNzSl9XfzFNqbaz+VlJrIj3fXQ4DeN1Rjm6cw==} engines: {node: '>=18'} - node-releases@2.0.63: - resolution: {integrity: sha512-6li2QanLsAXpIH2R6j77MzRyvOyrvdTqlKtO4CgBdHGNvN99ZZfyxszHc5o5+IZBWD5u6Hzwg83JoGXmqZNG9Q==} + node-releases@2.0.65: + resolution: {integrity: sha512-PfvofsGQ+MiOQIPkX9fU8ELUWmy5zL74CdQaph/ismKszfFkfwXaw0cGiwbwym2hT9k5+mdyl8O5WQ1MD8EHmA==} engines: {node: '>=18'} object-assign@4.1.1: @@ -1216,8 +1244,8 @@ packages: resolution: {integrity: sha512-5vvB5+W7ePv+p3uqxi+RcW1XAzLW0/hxt3/4X4Lc4qHudzOhmBiBwOY6DRob4WnanAEGvNcLjF+KNOufrUoEQw==} engines: {node: '>=12.20.0'} - oxfmt@0.75.0: - resolution: {integrity: sha512-/ZKvY5asfsVi9hdkOmRIumqOPu6kxlTgiJSZf54uq29kKew+Gu1FFAnEkGePyvLVW+MAYu41D6XggnzoElQzPw==} + oxfmt@0.79.0: + resolution: {integrity: sha512-92iLHGxAgtYk6jLp/1ZBnEeABveNduHZgMDQj7tyqO9iafuJG3q+YHJq0R5Aa4YT+E6xswMQXdmPZYMwynS8ig==} engines: {node: ^20.19.0 || >=22.12.0} hasBin: true peerDependencies: @@ -1232,12 +1260,12 @@ packages: vite-plus: optional: true - oxlint@1.90.0: - resolution: {integrity: sha512-RkTN9EmgIUpLuhNoLhO3OliMGJlvb3Dk7XVjBZnfoMCHrVpuz5ESd97klfiyYeV7XfA2lNLnDCPMkUI+Qw5How==} + oxlint@1.94.0: + resolution: {integrity: sha512-Fnt+3wSKRhtLmvgRfxgRX0excSPCoyiXRol4eWKZLtXxWMQtwQ3KjKQUYXOw5loyinfnZfGzh4RCYf7opfL0vw==} engines: {node: ^20.19.0 || >=22.12.0} hasBin: true peerDependencies: - oxlint-tsgolint: '>=7.0.2005' + oxlint-tsgolint: '>=7.0.2007' vite-plus: '*' peerDependenciesMeta: oxlint-tsgolint: @@ -1274,12 +1302,12 @@ packages: pkg-types@2.4.0: resolution: {integrity: sha512-07Fys7iVx0X6TcviMOgogM1Lk33ZyqOezMnU79S+kffWqwolG/5W9V8EgQSeYCIfFTYVgssRbnH630Oa2+soBA==} - postcss@8.5.32: - resolution: {integrity: sha512-LJlKCCAUFKOuZxipUdYw1NzIITEsPcgyOG9LkvRJvuKj/bRzbuRY0ARXvL0pWGpsZvn8jku+LMep2eU0seHp8g==} + postcss@8.5.33: + resolution: {integrity: sha512-RVHEU9/Pp1Fnjr/MpAJsZoADukCKhfIi15OunEYiGktIkYLkPVvC1sioWolGDS7XByMTx9m/IGbro0Js13zhnQ==} engines: {node: ^10 || ^12 || >=14} - prettier@3.9.10: - resolution: {integrity: sha512-skGHTH1Yb9QvaTC4hWnRTzEYtCpApF0UMBPz+t/0ZPzP8ihefo/btKd+QA7pUE0fEwA1SbS/NmhyEcstdXOIdA==} + prettier@3.10.1: + resolution: {integrity: sha512-70vp3ZUYoPlFbF9uiTdXHUUCGEIp7d4+6p+8DYbkm2jP7x/3i/paXVF6dopSI3zd/CEitrZN1rc4i85xWmmXlg==} engines: {node: '>=14'} hasBin: true @@ -1304,8 +1332,8 @@ packages: resolution: {integrity: sha512-QgT5//D3jfjJb6Gsjxv0Slpj23ip+HtOpnNgnb2S5zU3CB26G/IDPGoy4RJB42wzFE46DRsstbW6tKHoKbhAxw==} engines: {node: '>=0.10.0'} - react-router@8.5.1: - resolution: {integrity: sha512-5u1eQ46QjuXjNfEnLwzrnou1Bm5dquO3xjVYkkMYCudtkicD2AQHtx+fvXzPATtPJx8TW6DR1x1TDRqsfHyZBw==} + react-router@8.5.2: + resolution: {integrity: sha512-luPXqNUAIZAmCHbeBysc2KO7VJjckIMZk4ByEetS7Jotit8R6lLSVVeC76UE//AYK6QD6tAnVAPGkvmqMd+b1w==} engines: {node: '>=22.22.0'} peerDependencies: '@types/react': '>=19.2.0' @@ -1332,8 +1360,8 @@ packages: resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==} engines: {node: '>=0.10.0'} - rolldown@1.2.16: - resolution: {integrity: sha512-bWvlMpFKiTfDKfnK7FC2MPgPeWCf/Kpwsq49ApdW+FQaBZb6O6dZ4MAPbPUjp7hYQrw/RobqCzn64BRrQecGHw==} + rolldown@1.2.19: + resolution: {integrity: sha512-QIiV1J9d0pzN4jeeTH4sjPy0AZ6cAy2cG0ExeoE1+U8Rvj+hR3gYkokx0YbeUNGlZqiQJJ2utcETe0oKXwzsuA==} engines: {node: ^20.19.0 || >=22.12.0} hasBin: true @@ -1344,8 +1372,8 @@ packages: scheduler@0.28.0: resolution: {integrity: sha512-juorfCmIkIw8tT+p5BXSm6PJjQF/ycEYmKyzURCIt/RaZIhL+PulbQ9Yu2z1HdOJDdqDTlxA1+xKBmHXJsczAw==} - semver@6.3.1: - resolution: {integrity: sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==} + semver@6.3.2: + resolution: {integrity: sha512-GYrCADwpu6yV5OAvchkQ27Z5wwMxWAEMg5NNWjyHh/5DboFFqbdbvYNIvZouQpxXyeMPoTOh0vdPYKlf0ZswdQ==} hasBin: true semver@7.8.5: @@ -1353,6 +1381,11 @@ packages: engines: {node: '>=10'} hasBin: true + semver@7.8.6: + resolution: {integrity: sha512-9lpSSU4Mly3mrtruwLs1eLK6+gzbzqeBFwRNjIjE+9LuDpWdYctrQlQ3ej1Ilgi7gknpsTRnPoLP8DpCHqHIJw==} + engines: {node: '>=10'} + hasBin: true + seroval-plugins@1.7.6: resolution: {integrity: sha512-/TPCAd6q5stAZnugD2fsvNKtM2UpgwrS8/fO1cXTgPC0EqCsGB+UfkEEsToFCfg35CDTMlWkppfr/zWnLJGpBA==} engines: {node: '>=20'} @@ -1363,13 +1396,21 @@ packages: resolution: {integrity: sha512-oKNe6A8I3lSA5J0xg9xsrWCWDpET6CFhCMVuIsCmqrjNpBXzQXDAAQI5UfuC4Ner4DIR+VAtSw7TC0AmRMqFFQ==} engines: {node: '>=20'} + seroval@1.8.2: + resolution: {integrity: sha512-zmMxi/9MdLK1MKazLmIP6Rk39RuK0Xydd+QHeOYntS37olJeTjB3+nwVj4ce/ZWiZJeRhcO5htfxt0mUzQBscQ==} + engines: {node: '>=20'} + + signal-exit@4.1.0: + resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} + engines: {node: '>=14'} + skin-tone@2.0.0: resolution: {integrity: sha512-kUMbT1oBJCpgrnKoSr0o6wPtvRWT9W9UKvGLwfJYO2WuahZRHOpEyL1ckyMGgMWh0UdpmaoFqKKD29WTomNEGA==} engines: {node: '>=8'} - source-map-js@1.2.2: - resolution: {integrity: sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==} - engines: {node: '>=0.10.0'} + source-map-js@1.2.4: + resolution: {integrity: sha512-J7ZjMvHd9O1fcT/5V09QWaaSl2BbWx3F6O08spde82Namf9UB0GxRVIPiNbVsdKkoizHiSpTodo3vp2bAy91MA==} + engines: {node: '>=6.0.0'} source-map@0.7.6: resolution: {integrity: sha512-i5uvt8C3ikiWeNZSVZNWcfZPItFQOsYTUAOkcUPGd8DqDy1uOUikjt5dG+uRlwyvR108Fb9DOd4GvXfT0N2/uQ==} @@ -1406,8 +1447,8 @@ packages: thenify@3.3.1: resolution: {integrity: sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==} - tinybench@6.2.2: - resolution: {integrity: sha512-nIZ2N2dFpjBsg2hgitKu7mA+FvsIJuGJOwysRngmVRRmWgR/UyPjwJj8c/fT/dhm8EkHnF5EOogRf+0Z2qrimA==} + tinybench@6.2.4: + resolution: {integrity: sha512-SQ52jEncXxbMCzJuY2A/jGIbbAu6NYsBWW7grz2pNE+EnzQdoGaoBfpk4qC/opE7qiUcGmGgaGIz5EoHdS1O9w==} engines: {node: '>=20.0.0'} tinyexec@1.3.1: @@ -1422,6 +1463,9 @@ packages: resolution: {integrity: sha512-jBrmx4lYmaC9k/mgPbylxs7kBUxHtD8256up+HjLaDFfXScKJQyil+SWXSvhAtT7XHo+yTVlpB81PGmHP8oLSQ==} engines: {node: ^20.0.0 || >=22.0.0} + tslib@2.9.1: + resolution: {integrity: sha512-a4Ux9VKuIMHsOS7ENbEq6hK2ZGYIT27Rtl0E4eD9KqwxhKiQeMZE/9xb3IdYwWaSOyIBQLExhQgXDTYoiCxnWA==} + typescript@5.6.1-rc: resolution: {integrity: sha512-E3b2+1zEFu84jB0YQi9BORDjz9+jGbwwy1Zi3G0LUNw7a7cePUrHMRNy8aPh53nXpkFGVHSxIZo5vKTfYaFiBQ==} engines: {node: '>=14.17'} @@ -1478,8 +1522,8 @@ packages: webpack: optional: true - update-browserslist-db@1.3.4: - resolution: {integrity: sha512-t8wonIOdQyOjtPd2VktlBu6QjTVTks6v8bSi7kd0r2Vll8TK1JYDZtRRdbmCHOAMphkZgrzK+L+vXK4pyZ8t4A==} + update-browserslist-db@1.4.0: + resolution: {integrity: sha512-WPJuOnjI9FWDct4fB+ej4Mz8opLaw5CDcZ2t44tFZ0vIQVYWzBhWR3mkixuUj/A7+vY4V9+ApOZ2YYLwdgq46w==} hasBin: true peerDependencies: browserslist: '>= 4.21.0' @@ -1501,8 +1545,8 @@ packages: resolution: {integrity: sha512-OljLrQ9SQdOUqTaQxqL5dEfZWrXExyyWsozYlAWFawPVNuD83igl7uJD2RTkNMbniIYgt8l81eCJGIdQF7avLQ==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} - vite@8.3.5: - resolution: {integrity: sha512-z1YpjieJ9g0ebTmQpLBv/oq9E3F9EIlOe+7LahW8SrE3LTiG3udBRUXQOlYXP9b+IC2q2phHeVxj9xGlw34OEQ==} + vite@8.3.8: + resolution: {integrity: sha512-LzOn3h9rG/0vhLdXrV4yJ4QFA9eEoqCl+Yx+kGJd7aB9w6nfNgVHKSYwLPZUHrz4ZGa+t+kXjV9itvcHDLQouA==} engines: {node: ^20.19.0 || >=22.12.0} hasBin: true peerDependencies: @@ -1544,28 +1588,28 @@ packages: yaml: optional: true - vitefu@1.1.3: - resolution: {integrity: sha512-ub4okH7Z5KLjb6hDyjqrGXqWtWvoYdU3IGm/NorpgHncKoLTCfRIbvlhBm7r0YstIaQRYlp4yEbFqDcKSzXSSg==} + vitefu@1.1.4: + resolution: {integrity: sha512-qbEIDswfXH3x3IYRMScl/bf1AVW0dn7Z8qkr7g7nohkusfuC7tcFa7t5EoTOz60AunosLM9sDrDjHxsX+Up+CQ==} peerDependencies: vite: ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 peerDependenciesMeta: vite: optional: true - vitest@5.0.5: - resolution: {integrity: sha512-cPODOMF8YnkiiYtDdHo6n4wWmBrOBBbOIYH2d33M4l3CdNn72h+qMmO6uXffUN6A5AZFXNND/d+krS9mgkXRfg==} + vitest@5.1.1: + resolution: {integrity: sha512-trVmzUFOSraCZcI3uZIMD5FqBh4atFkC/XuJP/IU7qtyQay0FCs3Ia+0QiQ2JJwGyWG/xrcBoJNel2+O7kEZ0g==} engines: {node: ^22.12.0 || ^24.0.0 || >=26.0.0} hasBin: true peerDependencies: '@edge-runtime/vm': '*' '@opentelemetry/api': ^1.9.0 '@types/node': ^22.0.0 || >=24.0.0 - '@vitest/browser-playwright': 5.0.5 - '@vitest/browser-preview': 5.0.5 + '@vitest/browser-playwright': 5.1.1 + '@vitest/browser-preview': 5.1.1 '@vitest/browser-webdriverio': ^5.0.0-beta.5 || >=5.0.0 - '@vitest/coverage-istanbul': 5.0.5 - '@vitest/coverage-v8': 5.0.5 - '@vitest/ui': 5.0.5 + '@vitest/coverage-istanbul': 5.1.1 + '@vitest/coverage-v8': 5.1.1 + '@vitest/ui': 5.1.1 happy-dom: '*' jsdom: '*' vite: ^6.4.0 || ^7.0.0 || ^8.0.0 @@ -1676,98 +1720,98 @@ snapshots: '@babel/compat-data@7.29.7': {} - '@babel/core@7.29.7': + '@babel/core@7.29.13': dependencies: '@babel/code-frame': 7.29.7 - '@babel/generator': 7.29.12 - '@babel/helper-compilation-targets': 7.29.7 - '@babel/helper-module-transforms': 7.29.7(@babel/core@7.29.7) - '@babel/helpers': 7.29.10 - '@babel/parser': 7.29.12 + '@babel/generator': 7.29.15 + '@babel/helper-compilation-targets': 7.29.13 + '@babel/helper-module-transforms': 7.29.14(@babel/core@7.29.13) + '@babel/helpers': 7.29.15 + '@babel/parser': 7.29.15 '@babel/template': 7.29.7 - '@babel/traverse': 7.29.12 - '@babel/types': 7.29.11 + '@babel/traverse': 7.29.15 + '@babel/types': 7.29.15 '@jridgewell/remapping': 2.3.5 convert-source-map: 2.0.0 debug: 4.4.3 gensync: 1.0.0-beta.2 json5: 2.2.3 - semver: 6.3.1 + semver: 6.3.2 transitivePeerDependencies: - supports-color - '@babel/generator@7.29.12': + '@babel/generator@7.29.15': dependencies: - '@babel/parser': 7.29.12 - '@babel/types': 7.29.11 + '@babel/parser': 7.29.15 + '@babel/types': 7.29.15 '@jridgewell/gen-mapping': 0.3.13 '@jridgewell/trace-mapping': 0.3.31 jsesc: 3.1.0 - '@babel/helper-compilation-targets@7.29.7': + '@babel/helper-compilation-targets@7.29.13': dependencies: '@babel/compat-data': 7.29.7 '@babel/helper-validator-option': 7.29.7 - browserslist: 4.29.5 + browserslist: 4.29.6 lru-cache: 5.1.1 - semver: 6.3.1 + semver: 6.3.2 '@babel/helper-globals@7.29.7': {} '@babel/helper-module-imports@7.29.7': dependencies: - '@babel/traverse': 7.29.12 - '@babel/types': 7.29.11 + '@babel/traverse': 7.29.15 + '@babel/types': 7.29.15 transitivePeerDependencies: - supports-color - '@babel/helper-module-transforms@7.29.7(@babel/core@7.29.7)': + '@babel/helper-module-transforms@7.29.14(@babel/core@7.29.13)': dependencies: - '@babel/core': 7.29.7 + '@babel/core': 7.29.13 '@babel/helper-module-imports': 7.29.7 '@babel/helper-validator-identifier': 7.29.7 - '@babel/traverse': 7.29.12 + '@babel/traverse': 7.29.15 transitivePeerDependencies: - supports-color - '@babel/helper-string-parser@7.29.11': {} + '@babel/helper-string-parser@7.29.15': {} '@babel/helper-validator-identifier@7.29.7': {} '@babel/helper-validator-option@7.29.7': {} - '@babel/helpers@7.29.10': + '@babel/helpers@7.29.15': dependencies: '@babel/template': 7.29.7 - '@babel/types': 7.29.11 + '@babel/types': 7.29.15 - '@babel/parser@7.29.12': + '@babel/parser@7.29.15': dependencies: - '@babel/types': 7.29.11 + '@babel/types': 7.29.15 '@babel/runtime@7.29.10': {} '@babel/template@7.29.7': dependencies: '@babel/code-frame': 7.29.7 - '@babel/parser': 7.29.12 - '@babel/types': 7.29.11 + '@babel/parser': 7.29.15 + '@babel/types': 7.29.15 - '@babel/traverse@7.29.12': + '@babel/traverse@7.29.15': dependencies: '@babel/code-frame': 7.29.7 - '@babel/generator': 7.29.12 + '@babel/generator': 7.29.15 '@babel/helper-globals': 7.29.7 - '@babel/parser': 7.29.12 + '@babel/parser': 7.29.15 '@babel/template': 7.29.7 - '@babel/types': 7.29.11 + '@babel/types': 7.29.15 debug: 4.4.3 transitivePeerDependencies: - supports-color - '@babel/types@7.29.11': + '@babel/types@7.29.15': dependencies: - '@babel/helper-string-parser': 7.29.11 + '@babel/helper-string-parser': 7.29.15 '@babel/helper-validator-identifier': 7.29.7 '@braidai/lang@1.1.2': {} @@ -1775,18 +1819,34 @@ snapshots: '@colors/colors@1.5.0': optional: true - '@effect/atom-react@4.1.1(effect@4.1.1)(react@19.3.1)(scheduler@0.28.0)': + '@effect/atom-react@4.1.5(effect@4.1.5)(react@19.3.1)(scheduler@0.28.0)': dependencies: - effect: 4.1.1 + effect: 4.1.5 react: 19.3.1 scheduler: 0.28.0 '@effect/language-service@0.87.5': {} - '@effect/vitest@4.1.1(effect@4.1.1)(vitest@5.0.5(@types/node@26.6.6)(happy-dom@21.0.4)(vite@8.3.5(@types/node@26.6.6)(jiti@2.7.0)))': + '@effect/vitest@4.1.5(effect@4.1.5)(vitest@5.1.1(@types/node@26.6.6)(happy-dom@21.0.4)(vite@8.3.8(@types/node@26.6.6)(jiti@2.7.0)))': + dependencies: + effect: 4.1.5 + vitest: 5.1.1(@types/node@26.6.6)(happy-dom@21.0.4)(vite@8.3.8(@types/node@26.6.6)(jiti@2.7.0)) + + '@emnapi/core@2.0.0-beta.2': dependencies: - effect: 4.1.1 - vitest: 5.0.5(@types/node@26.6.6)(happy-dom@21.0.4)(vite@8.3.5(@types/node@26.6.6)(jiti@2.7.0)) + '@emnapi/wasi-threads': 2.2.0 + tslib: 2.9.1 + optional: true + + '@emnapi/runtime@2.0.0-beta.2': + dependencies: + tslib: 2.9.1 + optional: true + + '@emnapi/wasi-threads@2.2.0': + dependencies: + tslib: 2.9.1 + optional: true '@jridgewell/gen-mapping@0.3.13': dependencies: @@ -1798,22 +1858,29 @@ snapshots: '@jridgewell/gen-mapping': 0.3.13 '@jridgewell/trace-mapping': 0.3.31 - '@jridgewell/resolve-uri@3.1.2': {} + '@jridgewell/resolve-uri@3.1.3': {} '@jridgewell/sourcemap-codec@1.6.0': {} '@jridgewell/trace-mapping@0.3.31': dependencies: - '@jridgewell/resolve-uri': 3.1.2 + '@jridgewell/resolve-uri': 3.1.3 '@jridgewell/sourcemap-codec': 1.6.0 '@loaderkit/resolve@1.0.6': dependencies: '@braidai/lang': 1.1.2 - '@monarcode/effetch@0.1.0-rc.4(effect@4.1.1)': + '@monarcode/effetch@0.1.0-rc.4(effect@4.1.5)': dependencies: - effect: 4.1.1 + effect: 4.1.5 + + '@napi-rs/wasm-runtime@1.2.6(@emnapi/core@2.0.0-beta.2)(@emnapi/runtime@2.0.0-beta.2)': + dependencies: + '@emnapi/core': 2.0.0-beta.2 + '@emnapi/runtime': 2.0.0-beta.2 + '@tybys/wasm-util': 0.10.5 + optional: true '@oozcitak/dom@2.0.2': dependencies: @@ -1834,139 +1901,139 @@ snapshots: '@oxc-project/types@0.156.0': {} - '@oxfmt/binding-android-arm-eabi@0.75.0': + '@oxfmt/binding-android-arm-eabi@0.79.0': optional: true - '@oxfmt/binding-android-arm64@0.75.0': + '@oxfmt/binding-android-arm64@0.79.0': optional: true - '@oxfmt/binding-darwin-arm64@0.75.0': + '@oxfmt/binding-darwin-arm64@0.79.0': optional: true - '@oxfmt/binding-darwin-x64@0.75.0': + '@oxfmt/binding-darwin-x64@0.79.0': optional: true - '@oxfmt/binding-freebsd-x64@0.75.0': + '@oxfmt/binding-freebsd-x64@0.79.0': optional: true - '@oxfmt/binding-linux-arm-gnueabihf@0.75.0': + '@oxfmt/binding-linux-arm-gnueabihf@0.79.0': optional: true - '@oxfmt/binding-linux-arm-musleabihf@0.75.0': + '@oxfmt/binding-linux-arm-musleabihf@0.79.0': optional: true - '@oxfmt/binding-linux-arm64-gnu@0.75.0': + '@oxfmt/binding-linux-arm64-gnu@0.79.0': optional: true - '@oxfmt/binding-linux-arm64-musl@0.75.0': + '@oxfmt/binding-linux-arm64-musl@0.79.0': optional: true - '@oxfmt/binding-linux-ppc64-gnu@0.75.0': + '@oxfmt/binding-linux-ppc64-gnu@0.79.0': optional: true - '@oxfmt/binding-linux-riscv64-gnu@0.75.0': + '@oxfmt/binding-linux-riscv64-gnu@0.79.0': optional: true - '@oxfmt/binding-linux-riscv64-musl@0.75.0': + '@oxfmt/binding-linux-riscv64-musl@0.79.0': optional: true - '@oxfmt/binding-linux-s390x-gnu@0.75.0': + '@oxfmt/binding-linux-s390x-gnu@0.79.0': optional: true - '@oxfmt/binding-linux-x64-gnu@0.75.0': + '@oxfmt/binding-linux-x64-gnu@0.79.0': optional: true - '@oxfmt/binding-linux-x64-musl@0.75.0': + '@oxfmt/binding-linux-x64-musl@0.79.0': optional: true - '@oxfmt/binding-openharmony-arm64@0.75.0': + '@oxfmt/binding-openharmony-arm64@0.79.0': optional: true - '@oxfmt/binding-win32-arm64-msvc@0.75.0': + '@oxfmt/binding-win32-arm64-msvc@0.79.0': optional: true - '@oxfmt/binding-win32-ia32-msvc@0.75.0': + '@oxfmt/binding-win32-ia32-msvc@0.79.0': optional: true - '@oxfmt/binding-win32-x64-msvc@0.75.0': + '@oxfmt/binding-win32-x64-msvc@0.79.0': optional: true - '@oxlint/binding-android-arm-eabi@1.90.0': + '@oxlint/binding-android-arm-eabi@1.94.0': optional: true - '@oxlint/binding-android-arm64@1.90.0': + '@oxlint/binding-android-arm64@1.94.0': optional: true - '@oxlint/binding-darwin-arm64@1.90.0': + '@oxlint/binding-darwin-arm64@1.94.0': optional: true - '@oxlint/binding-darwin-x64@1.90.0': + '@oxlint/binding-darwin-x64@1.94.0': optional: true - '@oxlint/binding-freebsd-x64@1.90.0': + '@oxlint/binding-freebsd-x64@1.94.0': optional: true - '@oxlint/binding-linux-arm-gnueabihf@1.90.0': + '@oxlint/binding-linux-arm-gnueabihf@1.94.0': optional: true - '@oxlint/binding-linux-arm-musleabihf@1.90.0': + '@oxlint/binding-linux-arm-musleabihf@1.94.0': optional: true - '@oxlint/binding-linux-arm64-gnu@1.90.0': + '@oxlint/binding-linux-arm64-gnu@1.94.0': optional: true - '@oxlint/binding-linux-arm64-musl@1.90.0': + '@oxlint/binding-linux-arm64-musl@1.94.0': optional: true - '@oxlint/binding-linux-ppc64-gnu@1.90.0': + '@oxlint/binding-linux-ppc64-gnu@1.94.0': optional: true - '@oxlint/binding-linux-riscv64-gnu@1.90.0': + '@oxlint/binding-linux-riscv64-gnu@1.94.0': optional: true - '@oxlint/binding-linux-riscv64-musl@1.90.0': + '@oxlint/binding-linux-riscv64-musl@1.94.0': optional: true - '@oxlint/binding-linux-s390x-gnu@1.90.0': + '@oxlint/binding-linux-s390x-gnu@1.94.0': optional: true - '@oxlint/binding-linux-x64-gnu@1.90.0': + '@oxlint/binding-linux-x64-gnu@1.94.0': optional: true - '@oxlint/binding-linux-x64-musl@1.90.0': + '@oxlint/binding-linux-x64-musl@1.94.0': optional: true - '@oxlint/binding-openharmony-arm64@1.90.0': + '@oxlint/binding-openharmony-arm64@1.94.0': optional: true - '@oxlint/binding-win32-arm64-msvc@1.90.0': + '@oxlint/binding-win32-arm64-msvc@1.94.0': optional: true - '@oxlint/binding-win32-ia32-msvc@1.90.0': + '@oxlint/binding-win32-ia32-msvc@1.94.0': optional: true - '@oxlint/binding-win32-x64-msvc@1.90.0': + '@oxlint/binding-win32-x64-msvc@1.94.0': optional: true '@publint/pack@0.1.7': dependencies: tinyexec: 1.3.1 - '@react-router/dev@8.5.1(react-router@8.5.1(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(typescript@6.0.3)(vite@8.3.5(@types/node@26.6.6)(jiti@2.7.0))': + '@react-router/dev@8.5.2(react-router@8.5.2(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(typescript@6.0.3)(vite@8.3.8(@types/node@26.6.6)(jiti@2.7.0))': dependencies: - '@babel/core': 7.29.7 - '@babel/generator': 7.29.12 - '@babel/parser': 7.29.12 - '@babel/traverse': 7.29.12 - '@babel/types': 7.29.11 - '@react-router/node': 8.5.1(react-router@8.5.1(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(typescript@6.0.3) + '@babel/core': 7.29.13 + '@babel/generator': 7.29.15 + '@babel/parser': 7.29.15 + '@babel/traverse': 7.29.15 + '@babel/types': 7.29.15 + '@react-router/node': 8.5.2(react-router@8.5.2(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(typescript@6.0.3) '@remix-run/node-fetch-server': 0.14.2 babel-dead-code-elimination: 1.0.12 chokidar: 5.0.0 dedent: 1.7.2 es-module-lexer: 2.3.2 exit-hook: 5.1.0 - isbot: 5.2.2 + isbot: 5.2.3 jsesc: 3.1.0 lodash: 4.18.1 p-map: 7.1.1 @@ -1974,21 +2041,22 @@ snapshots: picocolors: 1.1.1 pkg-types: 2.4.0 react-refresh: 0.18.0 - react-router: 8.5.1(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.1(react@19.3.1))(react@19.3.1) - semver: 7.8.5 + react-router: 8.5.2(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.1(react@19.3.1))(react@19.3.1) + semver: 7.8.6 + signal-exit: 4.1.0 tinyglobby: 0.2.17 valibot: 1.5.0(typescript@6.0.3) - vite: 8.3.5(@types/node@26.6.6)(jiti@2.7.0) + vite: 8.3.8(@types/node@26.6.6)(jiti@2.7.0) optionalDependencies: typescript: 6.0.3 transitivePeerDependencies: - babel-plugin-macros - supports-color - '@react-router/node@8.5.1(react-router@8.5.1(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(typescript@6.0.3)': + '@react-router/node@8.5.2(react-router@8.5.2(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(typescript@6.0.3)': dependencies: '@remix-run/node-fetch-server': 0.14.2 - react-router: 8.5.1(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.1(react@19.3.1))(react@19.3.1) + react-router: 8.5.2(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.1(react@19.3.1))(react@19.3.1) optionalDependencies: typescript: 6.0.3 @@ -1996,52 +2064,59 @@ snapshots: '@remix-run/route-pattern@0.22.1': {} - '@rolldown/binding-android-arm-eabi@1.2.16': + '@rolldown/binding-android-arm-eabi@1.2.19': optional: true - '@rolldown/binding-android-arm64@1.2.16': + '@rolldown/binding-android-arm64@1.2.19': optional: true - '@rolldown/binding-darwin-arm64@1.2.16': + '@rolldown/binding-darwin-arm64@1.2.19': optional: true - '@rolldown/binding-darwin-x64@1.2.16': + '@rolldown/binding-darwin-x64@1.2.19': optional: true - '@rolldown/binding-freebsd-x64@1.2.16': + '@rolldown/binding-freebsd-x64@1.2.19': optional: true - '@rolldown/binding-linux-arm-gnueabihf@1.2.16': + '@rolldown/binding-linux-arm-gnueabihf@1.2.19': optional: true - '@rolldown/binding-linux-arm64-gnu@1.2.16': + '@rolldown/binding-linux-arm64-gnu@1.2.19': optional: true - '@rolldown/binding-linux-arm64-musl@1.2.16': + '@rolldown/binding-linux-arm64-musl@1.2.19': optional: true - '@rolldown/binding-linux-ppc64-gnu@1.2.16': + '@rolldown/binding-linux-ppc64-gnu@1.2.19': optional: true - '@rolldown/binding-linux-s390x-gnu@1.2.16': + '@rolldown/binding-linux-s390x-gnu@1.2.19': optional: true - '@rolldown/binding-linux-x64-gnu@1.2.16': + '@rolldown/binding-linux-x64-gnu@1.2.19': optional: true - '@rolldown/binding-linux-x64-musl@1.2.16': + '@rolldown/binding-linux-x64-musl@1.2.19': optional: true - '@rolldown/binding-openharmony-arm64@1.2.16': + '@rolldown/binding-openharmony-arm64@1.2.19': optional: true - '@rolldown/binding-win32-arm64-msvc@1.2.16': + '@rolldown/binding-wasm32-wasi@1.2.19': + dependencies: + '@emnapi/core': 2.0.0-beta.2 + '@emnapi/runtime': 2.0.0-beta.2 + '@napi-rs/wasm-runtime': 1.2.6(@emnapi/core@2.0.0-beta.2)(@emnapi/runtime@2.0.0-beta.2) optional: true - '@rolldown/binding-win32-x64-msvc@1.2.16': + '@rolldown/binding-win32-arm64-msvc@1.2.19': optional: true - '@rolldown/pluginutils@1.0.1': {} + '@rolldown/binding-win32-x64-msvc@1.2.19': + optional: true + + '@rolldown/pluginutils@1.1.1': {} '@sindresorhus/is@4.6.0': {} @@ -2056,7 +2131,7 @@ snapshots: react: 19.3.1 react-dom: 19.3.1(react@19.3.1) - '@tanstack/react-start-client@1.168.44(react-dom@19.3.1(react@19.3.1))(react@19.3.1)': + '@tanstack/react-start-client@1.168.45(react-dom@19.3.1(react@19.3.1))(react@19.3.1)': dependencies: '@tanstack/react-router': 1.170.46(react-dom@19.3.1(react@19.3.1))(react@19.3.1) '@tanstack/router-core': 1.171.39 @@ -2064,14 +2139,14 @@ snapshots: react: 19.3.1 react-dom: 19.3.1(react@19.3.1) - '@tanstack/react-start-rsc@0.1.65(react-dom@19.3.1(react@19.3.1))(react@19.3.1)(rolldown@1.2.16)(vite@8.3.5(@types/node@26.6.6)(jiti@2.7.0))': + '@tanstack/react-start-rsc@0.1.68(react-dom@19.3.1(react@19.3.1))(react@19.3.1)(rolldown@1.2.19)(vite@8.3.8(@types/node@26.6.6)(jiti@2.7.0))': dependencies: '@tanstack/react-router': 1.170.46(react-dom@19.3.1(react@19.3.1))(react@19.3.1) '@tanstack/router-core': 1.171.39 - '@tanstack/router-utils': 1.162.4 + '@tanstack/router-utils': 1.163.0 '@tanstack/start-client-core': 1.170.39 '@tanstack/start-fn-stubs': 1.162.0 - '@tanstack/start-plugin-core': 1.171.55(@tanstack/react-router@1.170.46(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(rolldown@1.2.16)(vite@8.3.5(@types/node@26.6.6)(jiti@2.7.0)) + '@tanstack/start-plugin-core': 1.172.0(@tanstack/react-router@1.170.46(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(rolldown@1.2.19)(vite@8.3.8(@types/node@26.6.6)(jiti@2.7.0)) '@tanstack/start-storage-context': 1.167.41 pathe: 2.0.3 react: 19.3.1 @@ -2097,21 +2172,21 @@ snapshots: react: 19.3.1 react-dom: 19.3.1(react@19.3.1) - '@tanstack/react-start@1.169.4(react-dom@19.3.1(react@19.3.1))(react@19.3.1)(rolldown@1.2.16)(vite@8.3.5(@types/node@26.6.6)(jiti@2.7.0))': + '@tanstack/react-start@1.169.7(react-dom@19.3.1(react@19.3.1))(react@19.3.1)(rolldown@1.2.19)(vite@8.3.8(@types/node@26.6.6)(jiti@2.7.0))': dependencies: '@tanstack/react-router': 1.170.46(react-dom@19.3.1(react@19.3.1))(react@19.3.1) - '@tanstack/react-start-client': 1.168.44(react-dom@19.3.1(react@19.3.1))(react@19.3.1) - '@tanstack/react-start-rsc': 0.1.65(react-dom@19.3.1(react@19.3.1))(react@19.3.1)(rolldown@1.2.16)(vite@8.3.5(@types/node@26.6.6)(jiti@2.7.0)) + '@tanstack/react-start-client': 1.168.45(react-dom@19.3.1(react@19.3.1))(react@19.3.1) + '@tanstack/react-start-rsc': 0.1.68(react-dom@19.3.1(react@19.3.1))(react@19.3.1)(rolldown@1.2.19)(vite@8.3.8(@types/node@26.6.6)(jiti@2.7.0)) '@tanstack/react-start-server': 1.167.52(react-dom@19.3.1(react@19.3.1))(react@19.3.1) - '@tanstack/router-utils': 1.162.4 + '@tanstack/router-utils': 1.163.0 '@tanstack/start-client-core': 1.170.39 - '@tanstack/start-plugin-core': 1.171.55(@tanstack/react-router@1.170.46(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(rolldown@1.2.16)(vite@8.3.5(@types/node@26.6.6)(jiti@2.7.0)) + '@tanstack/start-plugin-core': 1.172.0(@tanstack/react-router@1.170.46(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(rolldown@1.2.19)(vite@8.3.8(@types/node@26.6.6)(jiti@2.7.0)) '@tanstack/start-server-core': 1.169.45 pathe: 2.0.3 react: 19.3.1 react-dom: 19.3.1(react@19.3.1) optionalDependencies: - vite: 8.3.5(@types/node@26.6.6)(jiti@2.7.0) + vite: 8.3.8(@types/node@26.6.6)(jiti@2.7.0) transitivePeerDependencies: - '@farmfe/core' - '@rspack/core' @@ -2139,33 +2214,33 @@ snapshots: seroval: 1.7.6 seroval-plugins: 1.7.6(seroval@1.7.6) - '@tanstack/router-generator@1.167.46': + '@tanstack/router-generator@1.168.0': dependencies: - '@babel/types': 7.29.11 + '@babel/types': 7.29.15 '@tanstack/router-core': 1.171.39 - '@tanstack/router-utils': 1.162.4 + '@tanstack/router-utils': 1.163.0 '@tanstack/virtual-file-routes': 1.162.0 jiti: 2.7.0 magic-string: 0.30.21 - prettier: 3.9.10 + prettier: 3.10.1 zod: 4.6.7 transitivePeerDependencies: - supports-color - '@tanstack/router-plugin@1.168.48(@tanstack/react-router@1.170.46(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(rolldown@1.2.16)(vite@8.3.5(@types/node@26.6.6)(jiti@2.7.0))': + '@tanstack/router-plugin@1.169.0(@tanstack/react-router@1.170.46(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(rolldown@1.2.19)(vite@8.3.8(@types/node@26.6.6)(jiti@2.7.0))': dependencies: - '@babel/core': 7.29.7 + '@babel/core': 7.29.13 '@babel/template': 7.29.7 - '@babel/types': 7.29.11 + '@babel/types': 7.29.15 '@tanstack/router-core': 1.171.39 - '@tanstack/router-generator': 1.167.46 - '@tanstack/router-utils': 1.162.4 + '@tanstack/router-generator': 1.168.0 + '@tanstack/router-utils': 1.163.0 chokidar: 5.0.0 - unplugin: 3.7.0(rolldown@1.2.16)(vite@8.3.5(@types/node@26.6.6)(jiti@2.7.0)) + unplugin: 3.7.0(rolldown@1.2.19)(vite@8.3.8(@types/node@26.6.6)(jiti@2.7.0)) zod: 4.6.7 optionalDependencies: '@tanstack/react-router': 1.170.46(react-dom@19.3.1(react@19.3.1))(react@19.3.1) - vite: 8.3.5(@types/node@26.6.6)(jiti@2.7.0) + vite: 8.3.8(@types/node@26.6.6)(jiti@2.7.0) transitivePeerDependencies: - '@farmfe/core' - '@rspack/core' @@ -2176,12 +2251,12 @@ snapshots: - supports-color - unloader - '@tanstack/router-utils@1.162.4': + '@tanstack/router-utils@1.163.0': dependencies: - '@babel/generator': 7.29.12 - '@babel/parser': 7.29.12 - '@babel/types': 7.29.11 - ansis: 4.4.0 + '@babel/generator': 7.29.15 + '@babel/parser': 7.29.15 + '@babel/types': 7.29.15 + ansis: 4.5.0 babel-dead-code-elimination: 1.0.12 diff: 9.0.0 pathe: 2.0.3 @@ -2194,35 +2269,35 @@ snapshots: '@tanstack/router-core': 1.171.39 '@tanstack/start-fn-stubs': 1.162.0 '@tanstack/start-storage-context': 1.167.41 - seroval: 1.7.6 + seroval: 1.8.2 '@tanstack/start-fn-stubs@1.162.0': {} - '@tanstack/start-plugin-core@1.171.55(@tanstack/react-router@1.170.46(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(rolldown@1.2.16)(vite@8.3.5(@types/node@26.6.6)(jiti@2.7.0))': + '@tanstack/start-plugin-core@1.172.0(@tanstack/react-router@1.170.46(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(rolldown@1.2.19)(vite@8.3.8(@types/node@26.6.6)(jiti@2.7.0))': dependencies: '@babel/code-frame': 7.29.7 - '@babel/core': 7.29.7 - '@babel/types': 7.29.11 + '@babel/core': 7.29.13 + '@babel/types': 7.29.15 '@jridgewell/remapping': 2.3.5 '@tanstack/router-core': 1.171.39 - '@tanstack/router-generator': 1.167.46 - '@tanstack/router-plugin': 1.168.48(@tanstack/react-router@1.170.46(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(rolldown@1.2.16)(vite@8.3.5(@types/node@26.6.6)(jiti@2.7.0)) - '@tanstack/router-utils': 1.162.4 + '@tanstack/router-generator': 1.168.0 + '@tanstack/router-plugin': 1.169.0(@tanstack/react-router@1.170.46(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(rolldown@1.2.19)(vite@8.3.8(@types/node@26.6.6)(jiti@2.7.0)) + '@tanstack/router-utils': 1.163.0 '@tanstack/start-server-core': 1.169.45 exsolve: 1.2.0 lightningcss: 1.33.0 pathe: 2.0.3 picomatch: 4.0.7 - seroval: 1.7.6 + seroval: 1.8.2 source-map: 0.7.6 srvx: 1.0.8 tinyglobby: 0.2.17 ufo: 1.6.4 - vitefu: 1.1.3(vite@8.3.5(@types/node@26.6.6)(jiti@2.7.0)) + vitefu: 1.1.4(vite@8.3.8(@types/node@26.6.6)(jiti@2.7.0)) xmlbuilder2: 4.0.3 zod: 4.6.7 optionalDependencies: - vite: 8.3.5(@types/node@26.6.6)(jiti@2.7.0) + vite: 8.3.8(@types/node@26.6.6)(jiti@2.7.0) transitivePeerDependencies: - '@farmfe/core' - '@rspack/core' @@ -2244,7 +2319,7 @@ snapshots: '@tanstack/start-storage-context': 1.167.41 cookie-es: 3.1.1 fetchdts: 0.2.0 - seroval: 1.7.6 + seroval: 1.8.2 '@tanstack/start-storage-context@1.167.41': dependencies: @@ -2275,6 +2350,11 @@ snapshots: '@types/react': 19.3.0 '@types/react-dom': 19.3.0(@types/react@19.3.0) + '@tybys/wasm-util@0.10.5': + dependencies: + tslib: 2.9.1 + optional: true + '@types/aria-query@5.0.4': {} '@types/chai@5.2.3': @@ -2304,21 +2384,21 @@ snapshots: dependencies: '@types/node': 26.6.6 - '@vitejs/plugin-react@6.1.2(vite@8.3.5(@types/node@26.6.6)(jiti@2.7.0))': + '@vitejs/plugin-react@6.3.0(vite@8.3.8(@types/node@26.6.6)(jiti@2.7.0))': dependencies: - '@rolldown/pluginutils': 1.0.1 - vite: 8.3.5(@types/node@26.6.6)(jiti@2.7.0) + '@rolldown/pluginutils': 1.1.1 + vite: 8.3.8(@types/node@26.6.6)(jiti@2.7.0) - '@vitest/mocker@5.0.5(vite@8.3.5(@types/node@26.6.6)(jiti@2.7.0))': + '@vitest/mocker@5.1.1(vite@8.3.8(@types/node@26.6.6)(jiti@2.7.0))': dependencies: '@jridgewell/trace-mapping': 0.3.31 - '@vitest/spy': 5.0.5 + '@vitest/spy': 5.1.1 estree-walker: 3.0.3 magic-string: 1.4.5 optionalDependencies: - vite: 8.3.5(@types/node@26.6.6)(jiti@2.7.0) + vite: 8.3.8(@types/node@26.6.6)(jiti@2.7.0) - '@vitest/spy@5.0.5': {} + '@vitest/spy@5.1.1': {} ansi-escapes@7.3.0: dependencies: @@ -2334,7 +2414,7 @@ snapshots: ansi-styles@5.2.0: {} - ansis@4.4.0: {} + ansis@4.5.0: {} any-promise@1.3.0: {} @@ -2348,28 +2428,28 @@ snapshots: babel-dead-code-elimination@1.0.12: dependencies: - '@babel/core': 7.29.7 - '@babel/parser': 7.29.12 - '@babel/traverse': 7.29.12 - '@babel/types': 7.29.11 + '@babel/core': 7.29.13 + '@babel/parser': 7.29.15 + '@babel/traverse': 7.29.15 + '@babel/types': 7.29.15 transitivePeerDependencies: - supports-color - baseline-browser-mapping@2.11.34: {} + baseline-browser-mapping@2.11.39: {} - browserslist@4.29.5: + browserslist@4.29.6: dependencies: - baseline-browser-mapping: 2.11.34 - caniuse-lite: 1.0.30001820 - electron-to-chromium: 1.5.472 - node-releases: 2.0.63 - update-browserslist-db: 1.3.4(browserslist@4.29.5) + baseline-browser-mapping: 2.11.39 + caniuse-lite: 1.0.30001826 + electron-to-chromium: 1.5.492 + node-releases: 2.0.65 + update-browserslist-db: 1.4.0(browserslist@4.29.6) buffer-image-size@0.6.4: dependencies: '@types/node': 26.6.6 - caniuse-lite@1.0.30001820: {} + caniuse-lite@1.0.30001826: {} chai@6.3.0: {} @@ -2439,9 +2519,9 @@ snapshots: dom-accessibility-api@0.5.16: {} - effect@4.1.1: {} + effect@4.1.5: {} - electron-to-chromium@1.5.472: {} + electron-to-chromium@1.5.492: {} emoji-regex@8.0.0: {} @@ -2503,6 +2583,8 @@ snapshots: isbot@5.2.2: {} + isbot@5.2.3: {} + jiti@2.7.0: {} js-tokens@4.0.0: {} @@ -2614,57 +2696,57 @@ snapshots: emojilib: 2.4.0 skin-tone: 2.0.0 - node-releases@2.0.63: {} + node-releases@2.0.65: {} object-assign@4.1.1: {} obug@3.0.0: {} - oxfmt@0.75.0: + oxfmt@0.79.0: dependencies: tinypool: 2.2.0 optionalDependencies: - '@oxfmt/binding-android-arm-eabi': 0.75.0 - '@oxfmt/binding-android-arm64': 0.75.0 - '@oxfmt/binding-darwin-arm64': 0.75.0 - '@oxfmt/binding-darwin-x64': 0.75.0 - '@oxfmt/binding-freebsd-x64': 0.75.0 - '@oxfmt/binding-linux-arm-gnueabihf': 0.75.0 - '@oxfmt/binding-linux-arm-musleabihf': 0.75.0 - '@oxfmt/binding-linux-arm64-gnu': 0.75.0 - '@oxfmt/binding-linux-arm64-musl': 0.75.0 - '@oxfmt/binding-linux-ppc64-gnu': 0.75.0 - '@oxfmt/binding-linux-riscv64-gnu': 0.75.0 - '@oxfmt/binding-linux-riscv64-musl': 0.75.0 - '@oxfmt/binding-linux-s390x-gnu': 0.75.0 - '@oxfmt/binding-linux-x64-gnu': 0.75.0 - '@oxfmt/binding-linux-x64-musl': 0.75.0 - '@oxfmt/binding-openharmony-arm64': 0.75.0 - '@oxfmt/binding-win32-arm64-msvc': 0.75.0 - '@oxfmt/binding-win32-ia32-msvc': 0.75.0 - '@oxfmt/binding-win32-x64-msvc': 0.75.0 - - oxlint@1.90.0: + '@oxfmt/binding-android-arm-eabi': 0.79.0 + '@oxfmt/binding-android-arm64': 0.79.0 + '@oxfmt/binding-darwin-arm64': 0.79.0 + '@oxfmt/binding-darwin-x64': 0.79.0 + '@oxfmt/binding-freebsd-x64': 0.79.0 + '@oxfmt/binding-linux-arm-gnueabihf': 0.79.0 + '@oxfmt/binding-linux-arm-musleabihf': 0.79.0 + '@oxfmt/binding-linux-arm64-gnu': 0.79.0 + '@oxfmt/binding-linux-arm64-musl': 0.79.0 + '@oxfmt/binding-linux-ppc64-gnu': 0.79.0 + '@oxfmt/binding-linux-riscv64-gnu': 0.79.0 + '@oxfmt/binding-linux-riscv64-musl': 0.79.0 + '@oxfmt/binding-linux-s390x-gnu': 0.79.0 + '@oxfmt/binding-linux-x64-gnu': 0.79.0 + '@oxfmt/binding-linux-x64-musl': 0.79.0 + '@oxfmt/binding-openharmony-arm64': 0.79.0 + '@oxfmt/binding-win32-arm64-msvc': 0.79.0 + '@oxfmt/binding-win32-ia32-msvc': 0.79.0 + '@oxfmt/binding-win32-x64-msvc': 0.79.0 + + oxlint@1.94.0: optionalDependencies: - '@oxlint/binding-android-arm-eabi': 1.90.0 - '@oxlint/binding-android-arm64': 1.90.0 - '@oxlint/binding-darwin-arm64': 1.90.0 - '@oxlint/binding-darwin-x64': 1.90.0 - '@oxlint/binding-freebsd-x64': 1.90.0 - '@oxlint/binding-linux-arm-gnueabihf': 1.90.0 - '@oxlint/binding-linux-arm-musleabihf': 1.90.0 - '@oxlint/binding-linux-arm64-gnu': 1.90.0 - '@oxlint/binding-linux-arm64-musl': 1.90.0 - '@oxlint/binding-linux-ppc64-gnu': 1.90.0 - '@oxlint/binding-linux-riscv64-gnu': 1.90.0 - '@oxlint/binding-linux-riscv64-musl': 1.90.0 - '@oxlint/binding-linux-s390x-gnu': 1.90.0 - '@oxlint/binding-linux-x64-gnu': 1.90.0 - '@oxlint/binding-linux-x64-musl': 1.90.0 - '@oxlint/binding-openharmony-arm64': 1.90.0 - '@oxlint/binding-win32-arm64-msvc': 1.90.0 - '@oxlint/binding-win32-ia32-msvc': 1.90.0 - '@oxlint/binding-win32-x64-msvc': 1.90.0 + '@oxlint/binding-android-arm-eabi': 1.94.0 + '@oxlint/binding-android-arm64': 1.94.0 + '@oxlint/binding-darwin-arm64': 1.94.0 + '@oxlint/binding-darwin-x64': 1.94.0 + '@oxlint/binding-freebsd-x64': 1.94.0 + '@oxlint/binding-linux-arm-gnueabihf': 1.94.0 + '@oxlint/binding-linux-arm-musleabihf': 1.94.0 + '@oxlint/binding-linux-arm64-gnu': 1.94.0 + '@oxlint/binding-linux-arm64-musl': 1.94.0 + '@oxlint/binding-linux-ppc64-gnu': 1.94.0 + '@oxlint/binding-linux-riscv64-gnu': 1.94.0 + '@oxlint/binding-linux-riscv64-musl': 1.94.0 + '@oxlint/binding-linux-s390x-gnu': 1.94.0 + '@oxlint/binding-linux-x64-gnu': 1.94.0 + '@oxlint/binding-linux-x64-musl': 1.94.0 + '@oxlint/binding-openharmony-arm64': 1.94.0 + '@oxlint/binding-win32-arm64-msvc': 1.94.0 + '@oxlint/binding-win32-ia32-msvc': 1.94.0 + '@oxlint/binding-win32-x64-msvc': 1.94.0 p-map@7.1.1: {} @@ -2690,13 +2772,13 @@ snapshots: exsolve: 1.2.0 pathe: 2.0.3 - postcss@8.5.32: + postcss@8.5.33: dependencies: nanoid: 3.3.20 picocolors: 1.1.1 - source-map-js: 1.2.2 + source-map-js: 1.2.4 - prettier@3.9.10: {} + prettier@3.10.1: {} pretty-format@27.5.1: dependencies: @@ -2720,7 +2802,7 @@ snapshots: react-refresh@0.18.0: {} - react-router@8.5.1(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.1(react@19.3.1))(react@19.3.1): + react-router@8.5.2(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.1(react@19.3.1))(react@19.3.1): dependencies: '@remix-run/route-pattern': 0.22.1 cookie-es: 3.1.1 @@ -2736,26 +2818,27 @@ snapshots: require-directory@2.1.1: {} - rolldown@1.2.16: + rolldown@1.2.19: dependencies: '@oxc-project/types': 0.156.0 - '@rolldown/pluginutils': 1.0.1 + '@rolldown/pluginutils': 1.1.1 optionalDependencies: - '@rolldown/binding-android-arm-eabi': 1.2.16 - '@rolldown/binding-android-arm64': 1.2.16 - '@rolldown/binding-darwin-arm64': 1.2.16 - '@rolldown/binding-darwin-x64': 1.2.16 - '@rolldown/binding-freebsd-x64': 1.2.16 - '@rolldown/binding-linux-arm-gnueabihf': 1.2.16 - '@rolldown/binding-linux-arm64-gnu': 1.2.16 - '@rolldown/binding-linux-arm64-musl': 1.2.16 - '@rolldown/binding-linux-ppc64-gnu': 1.2.16 - '@rolldown/binding-linux-s390x-gnu': 1.2.16 - '@rolldown/binding-linux-x64-gnu': 1.2.16 - '@rolldown/binding-linux-x64-musl': 1.2.16 - '@rolldown/binding-openharmony-arm64': 1.2.16 - '@rolldown/binding-win32-arm64-msvc': 1.2.16 - '@rolldown/binding-win32-x64-msvc': 1.2.16 + '@rolldown/binding-android-arm-eabi': 1.2.19 + '@rolldown/binding-android-arm64': 1.2.19 + '@rolldown/binding-darwin-arm64': 1.2.19 + '@rolldown/binding-darwin-x64': 1.2.19 + '@rolldown/binding-freebsd-x64': 1.2.19 + '@rolldown/binding-linux-arm-gnueabihf': 1.2.19 + '@rolldown/binding-linux-arm64-gnu': 1.2.19 + '@rolldown/binding-linux-arm64-musl': 1.2.19 + '@rolldown/binding-linux-ppc64-gnu': 1.2.19 + '@rolldown/binding-linux-s390x-gnu': 1.2.19 + '@rolldown/binding-linux-x64-gnu': 1.2.19 + '@rolldown/binding-linux-x64-musl': 1.2.19 + '@rolldown/binding-openharmony-arm64': 1.2.19 + '@rolldown/binding-wasm32-wasi': 1.2.19 + '@rolldown/binding-win32-arm64-msvc': 1.2.19 + '@rolldown/binding-win32-x64-msvc': 1.2.19 sade@1.8.1: dependencies: @@ -2763,21 +2846,27 @@ snapshots: scheduler@0.28.0: {} - semver@6.3.1: {} + semver@6.3.2: {} semver@7.8.5: {} + semver@7.8.6: {} + seroval-plugins@1.7.6(seroval@1.7.6): dependencies: seroval: 1.7.6 seroval@1.7.6: {} + seroval@1.8.2: {} + + signal-exit@4.1.0: {} + skin-tone@2.0.0: dependencies: unicode-emoji-modifier-base: 1.0.0 - source-map-js@1.2.2: {} + source-map-js@1.2.4: {} source-map@0.7.6: {} @@ -2812,7 +2901,7 @@ snapshots: dependencies: any-promise: 1.3.0 - tinybench@6.2.2: {} + tinybench@6.2.4: {} tinyexec@1.3.1: {} @@ -2823,6 +2912,9 @@ snapshots: tinypool@2.2.0: {} + tslib@2.9.1: + optional: true + typescript@5.6.1-rc: {} typescript@6.0.3: {} @@ -2833,19 +2925,19 @@ snapshots: unicode-emoji-modifier-base@1.0.0: {} - unplugin@3.7.0(rolldown@1.2.16)(vite@8.3.5(@types/node@26.6.6)(jiti@2.7.0)): + unplugin@3.7.0(rolldown@1.2.19)(vite@8.3.8(@types/node@26.6.6)(jiti@2.7.0)): dependencies: '@jridgewell/remapping': 2.3.5 - '@rolldown/pluginutils': 1.0.1 + '@rolldown/pluginutils': 1.1.1 picomatch: 4.0.7 webpack-virtual-modules: 0.6.2 optionalDependencies: - rolldown: 1.2.16 - vite: 8.3.5(@types/node@26.6.6)(jiti@2.7.0) + rolldown: 1.2.19 + vite: 8.3.8(@types/node@26.6.6)(jiti@2.7.0) - update-browserslist-db@1.3.4(browserslist@4.29.5): + update-browserslist-db@1.4.0(browserslist@4.29.6): dependencies: - browserslist: 4.29.5 + browserslist: 4.29.6 escalade: 3.2.0 picocolors: 1.1.1 @@ -2859,26 +2951,26 @@ snapshots: validate-npm-package-name@5.0.1: {} - vite@8.3.5(@types/node@26.6.6)(jiti@2.7.0): + vite@8.3.8(@types/node@26.6.6)(jiti@2.7.0): dependencies: lightningcss: 1.33.0 picomatch: 4.0.7 - postcss: 8.5.32 - rolldown: 1.2.16 + postcss: 8.5.33 + rolldown: 1.2.19 tinyglobby: 0.2.17 optionalDependencies: '@types/node': 26.6.6 fsevents: 2.3.3 jiti: 2.7.0 - vitefu@1.1.3(vite@8.3.5(@types/node@26.6.6)(jiti@2.7.0)): + vitefu@1.1.4(vite@8.3.8(@types/node@26.6.6)(jiti@2.7.0)): optionalDependencies: - vite: 8.3.5(@types/node@26.6.6)(jiti@2.7.0) + vite: 8.3.8(@types/node@26.6.6)(jiti@2.7.0) - vitest@5.0.5(@types/node@26.6.6)(happy-dom@21.0.4)(vite@8.3.5(@types/node@26.6.6)(jiti@2.7.0)): + vitest@5.1.1(@types/node@26.6.6)(happy-dom@21.0.4)(vite@8.3.8(@types/node@26.6.6)(jiti@2.7.0)): dependencies: '@types/chai': 5.2.3 - '@vitest/mocker': 5.0.5(vite@8.3.5(@types/node@26.6.6)(jiti@2.7.0)) + '@vitest/mocker': 5.1.1(vite@8.3.8(@types/node@26.6.6)(jiti@2.7.0)) chai: 6.3.0 es-module-lexer: 2.3.2 expect-type: 1.4.0 @@ -2886,10 +2978,10 @@ snapshots: obug: 3.0.0 picomatch: 4.0.7 std-env: 4.3.0 - tinybench: 6.2.2 + tinybench: 6.2.4 tinyexec: 1.3.1 tinyglobby: 0.2.17 - vite: 8.3.5(@types/node@26.6.6)(jiti@2.7.0) + vite: 8.3.8(@types/node@26.6.6)(jiti@2.7.0) why-is-node-running: 3.2.1 optionalDependencies: '@types/node': 26.6.6 diff --git a/scripts/build.mjs b/scripts/build.mjs index 3bc2a33..a013ad6 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -5,6 +5,8 @@ import { execFileSync } from "node:child_process"; import { readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"; import path from "node:path"; +import ts from "typescript"; + const root = path.resolve(import.meta.dirname, ".."); const outDir = path.join(root, "dist"); const bin = (name) => path.join(root, "node_modules", ".bin", name); @@ -15,6 +17,55 @@ execFileSync(bin("tsc"), ["-p", "tsconfig.build.json"], { stdio: "inherit", }); +// TypeScript doesn't show the JSDoc of `export * as Query` in a hover: an +// editor shows the module's path instead. A `declare namespace` carries its +// JSDoc, so the entry's .d.ts declares each namespace with its members, as +// Effetch's does. The JavaScript keeps `export * as`; each member stays +// declared in its own module, where Go to Definition lands. +const declareNamespaces = (file) => { + const program = ts.createProgram([file], { + module: ts.ModuleKind.NodeNext, + moduleResolution: ts.ModuleResolutionKind.NodeNext, + noEmit: true, + skipLibCheck: true, + }); + const checker = program.getTypeChecker(); + const source = program.getSourceFile(file); + let imports = ""; + let body = ""; + let last = 0; + for (const statement of source.statements) { + if ( + !ts.isExportDeclaration(statement) || + statement.exportClause === undefined || + !ts.isNamespaceExport(statement.exportClause) + ) { + continue; + } + const name = statement.exportClause.name.text; + // `export type * as` has no runtime namespace to declare. + if (statement.isTypeOnly) { + throw new Error(`Can't declare the type-only namespace ${name}`); + } + const module = checker.getSymbolAtLocation(statement.moduleSpecifier); + if (module === undefined) { + throw new Error(`Can't resolve the module of namespace ${name}`); + } + const members = checker + .getExportsOfModule(module) + .map((member) => member.name) + .sort(); + // Imported under the namespace's name, so `make` from two modules + // don't collide. + imports += `import { ${members.map((member) => `${member} as ${name}_${member}`).join(", ")} } from ${statement.moduleSpecifier.getText(source)};\n`; + body += `${source.text.slice(last, statement.getStart(source))}declare namespace ${name} {\n\texport { ${members.map((member) => `${name}_${member} as ${member}`).join(", ")} };\n}\nexport { ${name} };`; + last = statement.end; + } + writeFileSync(file, imports + body + source.text.slice(last)); +}; + +declareNamespaces(path.join(outDir, "index.d.ts")); + const files = readdirSync(outDir, { recursive: true, encoding: "utf8" }); for (const file of files.filter((name) => /\.(d\.ts|js)$/.test(name))) { const target = path.join(outDir, file); diff --git a/scripts/editor-check.mjs b/scripts/editor-check.mjs index 2c7bd6c..9f267d0 100644 --- a/scripts/editor-check.mjs +++ b/scripts/editor-check.mjs @@ -9,7 +9,7 @@ const source = `import * as Effect from "effect/Effect"; import * as Schema from "effect/Schema"; import * as Stream from "effect/Stream"; -import { /*Entity*/Entity, /*Query*/Query, /*QueryClient*/QueryClient } from "@monarcode/effetch-query"; +import { /*Entity*/Entity, /*InfiniteQuery*/InfiniteQuery, /*Mutation*/Mutation, /*Query*/Query, /*QueryClient*/QueryClient, /*Signals*/Signals } from "@monarcode/effetch-query"; import { /*endpoints*/endpoints, /*fromClient*/fromClient } from "@monarcode/effetch-query/effetch"; import { /*useIsFetching*/useIsFetching, /*useMutationState*/useMutationState, /*useQueries*/useQueries, /*useQuery*/useQuery, /*useQueryState*/useQueryState } from "@monarcode/effetch-query/react"; import { /*reactNativeSignals*/reactNativeSignals } from "@monarcode/effetch-query/react-native"; @@ -29,7 +29,7 @@ export const update = Entity./*entityUpdate*/update; export const rename = (id: number) => update(Todos, id, (todo) => ({ ...todo, title: "renamed" })); export const stream = Query./*queryStream*/stream; export const /*price*/price = stream({ key: ["price"], run: Stream.fromIterable([1, 2]) }); -export { connectQueryClient, endpoints, fromClient, reactNativeSignals, useIsFetching, useMutationState, useQueries }; +export { InfiniteQuery, Mutation, Signals, connectQueryClient, endpoints, fromClient, reactNativeSignals, useIsFetching, useMutationState, useQueries }; `; const config = ts.getParsedCommandLineOfConfigFile( @@ -86,20 +86,39 @@ const dist = path.join( "dist", ); -// TypeScript doesn't show the JSDoc of `export * as Query` in hovers, so a -// namespace is only checked for where go-to-definition lands. -for (const [marker, file] of [ - ["Entity", "Entity.d.ts"], - ["Query", "Query.d.ts"], - ["QueryClient", "QueryClient.d.ts"], +// The entry's .d.ts declares each namespace (scripts/build.mjs), so its +// hover shows the namespace's docs, and Go to Definition lands on that +// declaration. [marker, the start of its docs] +for (const [marker, docs] of [ + ["Entity", "Entities: one record held by many queries"], + ["InfiniteQuery", "Infinite queries: pages loaded one at a time"], + ["Mutation", "Mutations: changes to server state"], + ["Query", "Queries: keyed, cached server state"], + ["QueryClient", "The query cache: create one per app"], + ["Signals", "Focus and reconnect signals"], ]) { const definitions = service.getDefinitionAtPosition(probe, at(marker)) ?? []; const targets = definitions.map((definition) => path.relative(dist, definition.fileName), ); expect( - targets.includes(file), - `Go to definition on ${marker} lands on ${targets.join(", ") || "nothing"}, not dist/${file}`, + targets.includes("index.d.ts"), + `Go to definition on ${marker} lands on ${targets.join(", ") || "nothing"}, not dist/index.d.ts`, + ); + const info = service.getQuickInfoAtPosition(probe, at(marker)); + const display = ts.displayPartsToString(info?.displayParts); + const documentation = ts.displayPartsToString(info?.documentation); + expect( + display.startsWith(`(alias) namespace ${marker}\n`), + `Hover on ${marker} shows ${JSON.stringify(display)}, not the namespace`, + ); + expect( + documentation.startsWith(docs), + `Hover on ${marker} doesn't show its docs: ${JSON.stringify(documentation.slice(0, 80))}`, + ); + expect( + (info?.tags ?? []).some((tag) => tag.name === "since"), + `Hover on ${marker} lacks @since`, ); } @@ -109,25 +128,25 @@ for (const [marker, file, signature, docs] of [ [ "Key", "Query.d.ts", - "type Key = readonly unknown[]", + "(alias) type Query.Key = readonly unknown[]", "Identifies a query in the cache", ], [ "make", "QueryClient.d.ts", - "const make: (options?: QueryClient.CommonOptions | QueryClient.Options | undefined) => QueryClient.QueryClient", + "(alias) const QueryClient.make: (options?: QueryClient.CommonOptions | QueryClient.Options | undefined) => QueryClient.QueryClient", "Nothing is built until", ], [ "entityUpdate", "Entity.d.ts", - "const update: (entity: Entity.Entity, id: NoInfer, f: (value: A) => A)", + "(alias) const Entity.update: (entity: Entity.Entity, id: NoInfer, f: (value: A) => A)", "Writes a value computed from the entity", ], [ "queryStream", "Query.d.ts", - "const stream: (options: Query.MakeStreamOptions) => Query.Query", + "(alias) const Query.stream: (options: Query.MakeStreamOptions) => Query.Query", "Defines a query whose value is the latest element", ], [ diff --git a/src/KeyHoldsTargetError.ts b/src/KeyHoldsTargetError.ts new file mode 100644 index 0000000..68f4e25 --- /dev/null +++ b/src/KeyHoldsTargetError.ts @@ -0,0 +1,50 @@ +import * as Data from "effect/Data"; + +import type * as Query from "./Query.js"; + +/** + * Thrown when a key holds a query, a family or a group, such as + * `Query.invalidate([wallet, transactions])`. Its segments are compared + * with the query keys, so as a key it would match nothing: the targets were + * meant to be one target. Combine them with {@link Query.group}. + * + * Everything that takes a {@link Query.Target} checks it, and reports it + * in its own way: + * + * - the `Query` functions, such as `Query.invalidate`, die with it, and so + * does `Mutation.run` for a key in `invalidates`; + * - the client's methods, such as `client.refetch`, reject with it; + * - `useRefetch`, `useIsFetching`, `QueryClient.dehydrate`'s `queries` and + * `connectQueryClient`'s `queries` throw it when called. + * + * @example + * ```ts + * import * as Cause from "effect/Cause"; + * import * as Effect from "effect/Effect"; + * + * import { Query } from "@monarcode/effetch-query"; + * + * declare const refresh: Effect.Effect; + * + * // Turns the defect into a message, for a log or a test. + * export const explained = refresh.pipe( + * Effect.catchCause((cause) => + * Effect.succeed( + * Cause.squash(cause) instanceof Query.KeyHoldsTargetError + * ? "Pass a Query.group, not an array of queries" + * : Cause.pretty(cause), + * ), + * ), + * ); + * ``` + * + * @since 0.1.0 + */ +export class KeyHoldsTargetError extends Data.TaggedError( + "KeyHoldsTargetError", +)<{ + /** The key that holds a target. */ + readonly key: Query.Key; + /** What went wrong and how to fix it, for logs. */ + readonly message: string; +}> {} diff --git a/src/Mutation.ts b/src/Mutation.ts index 93fedbc..61da973 100644 --- a/src/Mutation.ts +++ b/src/Mutation.ts @@ -184,7 +184,7 @@ export interface MakeOptions< * that returns one. Default: none. A failed run invalidates nothing. * * A key that holds a query, a family or a group matches nothing: in a - * list, the run dies with a `KeyHoldsTargetError` before it starts; from + * list, the run dies with a {@link Query.KeyHoldsTargetError} before it starts; from * the function, the change is already saved, so the target is logged and * skipped. Combine targets with {@link Query.group}. */ diff --git a/src/Query.ts b/src/Query.ts index c76610b..400b5db 100644 --- a/src/Query.ts +++ b/src/Query.ts @@ -15,8 +15,11 @@ import { type GroupTypeId, makeGroup } from "./internal/keyIndex.js"; import * as optimistic from "./internal/optimistic.js"; import * as internal from "./internal/queryAtom.js"; import * as targets from "./internal/targets.js"; +import { KeyHoldsTargetError } from "./KeyHoldsTargetError.js"; import * as QueryClient from "./QueryClient.js"; +export { KeyHoldsTargetError }; + /** * Identifies a query in the cache. Keys are hierarchical arrays: each segment * is compared with `Equal.equals`, so plain objects and arrays match by @@ -174,7 +177,7 @@ export interface Family { * these (every query one of them matches). * * An array of queries is a key, not a group, and as a key it would match - * nothing: `[wallet, transactions]` fails with a `KeyHoldsTargetError` + * nothing: `[wallet, transactions]` fails with a {@link KeyHoldsTargetError} * defect instead. Combine targets with {@link group}. * * @example @@ -329,6 +332,47 @@ export interface Options extends QueryClient.QueryDefaults { * none. */ readonly reactivityKeys?: Reactivity.KeysInput | undefined; + /** + * How this query takes part in the client's entity sync + * ({@link QueryClient.EntitiesOptions.sync}). Default: it does, if it + * has a `schema`. + */ + readonly entities?: EntitiesOptions | undefined; +} + +/** + * A query's `entities` option ({@link Options}): whether the client's entity + * sync ({@link QueryClient.EntitiesOptions.sync}) reads this query's copies + * and writes over them. + * + * @example + * ```ts + * import * as Effect from "effect/Effect"; + * import * as Schema from "effect/Schema"; + * + * import { Query } from "@monarcode/effetch-query"; + * + * const Summary = Schema.Struct({ id: Schema.String, status: Schema.String }); + * + * // A partial view: its copies neither update nor overwrite the full ones. + * export const summaries = Query.make({ + * key: ["transactions", "summaries"], + * run: Effect.succeed([{ id: "t1", status: "Pending" }]), + * schema: { success: Schema.Array(Summary) }, + * entities: { sync: false }, + * }); + * ``` + * + * @since 0.1.0 + */ +export interface EntitiesOptions { + /** + * If false, entity sync leaves this query out both ways: a fetch of it + * updates no other query, and no other query's fetch updates it. For a + * deliberately partial view whose copies shouldn't overwrite fuller + * ones. `Entity` writes reach it as before. Default: `true`. + */ + readonly sync?: boolean | undefined; } /** diff --git a/src/QueryClient.ts b/src/QueryClient.ts index 302157c..44c6558 100644 --- a/src/QueryClient.ts +++ b/src/QueryClient.ts @@ -15,9 +15,12 @@ import * as Reactivity from "effect/reactivity/Reactivity"; import type * as Schedule from "effect/Schedule"; import * as Scope from "effect/Scope"; +import type * as Entity from "./Entity.js"; import { fetchValue, observeNodes } from "./internal/cache.js"; import * as hydration from "./internal/dehydrate.js"; import * as disposal from "./internal/disposeAfter.js"; +import { definition } from "./internal/entity.js"; +import { stampWritten, syncFetched } from "./internal/entitySync.js"; import { peek } from "./internal/queryAtom.js"; import { initialValues, makeClientState, track } from "./internal/runtime.js"; import * as targets from "./internal/targets.js"; @@ -213,7 +216,7 @@ export interface QueryClient { * those in use refetch at once, the rest the next time they're used. * Without a target, every query. Resolves at once, without waiting for * the refetches, and does nothing on a disposed client. Rejects with a - * `KeyHoldsTargetError` for a key that holds queries ({@link Query.Target}). + * {@link Query.KeyHoldsTargetError} for a key that holds queries ({@link Query.Target}). * * @see {@link QueryClient.refetch} to wait for them */ @@ -223,7 +226,7 @@ export interface QueryClient { * does, and resolves when they've all settled. Without a target, every * query in use. A query that fails doesn't reject it: each shows its own * failure. It rejects only with a defect, such as a - * `KeyHoldsTargetError` for a key that holds queries + * {@link Query.KeyHoldsTargetError} for a key that holds queries * ({@link Query.Target}). On a disposed client, it resolves at once. */ readonly refetch: (target?: Query.Target | undefined) => Promise; @@ -448,6 +451,96 @@ export interface CommonOptions { readonly queries?: QueriesOptions | undefined; /** Defaults and app-wide hooks for every mutation. */ readonly mutations?: MutationsOptions | undefined; + /** Entities whose cached copies are kept in sync ({@link EntitiesOptions}). */ + readonly entities?: EntitiesOptions | undefined; +} + +/** + * The `entities` group of {@link Options}: entities whose copies a fetch + * keeps in sync across the cache. + * + * @example + * ```ts + * import * as Effect from "effect/Effect"; + * import * as Schema from "effect/Schema"; + * + * import { Entity, Query, QueryClient } from "@monarcode/effetch-query"; + * + * const Transaction = Schema.Struct({ + * id: Schema.String, + * status: Schema.String, + * }); + * const Transactions = Entity.make(Transaction, { id: (t) => t.id }); + * + * export const transactions = Query.make({ + * key: ["transactions"], + * run: Effect.succeed([{ id: "t1", status: "Pending" }]), + * schema: { success: Schema.Array(Transaction) }, + * }); + * + * export const transaction = Query.family({ + * key: ["transactions"], + * run: (id: string) => Effect.succeed({ id, status: "Successful" }), + * schema: { success: Transaction }, + * }); + * + * // Fetching transaction("t1") shows "Successful" in the list at once, + * // and a list fetch with a newer copy updates the cached details. + * export const client = QueryClient.make({ + * entities: { sync: [Transactions] }, + * }); + * ``` + * + * @since 0.1.0 + */ +export interface EntitiesOptions { + /** + * Entities kept in sync: when a query's fetch succeeds, each copy of + * these entities in its value goes over the other cached copies with + * the same id, in every query whose `schema` holds the entity. A copy + * another query holds that is newer comes into the fetched value + * instead. So a details refetch updates every list row of that record, + * and a list fetch updates the cached details, with no other fetch. + * + * - **Newer wins.** A copy is as new as the fetch attempt it came from, + * by when that attempt started: a slow response that lands after a + * newer one doesn't overwrite it, and the query that fetched it shows + * the newer copy instead. A refetch of an infinite query dates each + * page by its own attempt. Its next page is new, and only that page + * spreads: the pages it already had keep their age. A copy a query read from + * another (`ctx.result`) keeps that query's age, and a value from the + * server (`hydrate`) is older than any fetch. + * - **Only fetched copies spread.** A copy a write changed + * (`Query.set`, `Query.update`, {@link Entity.set}, + * {@link Entity.update}, a `live` push) counts as newer than every + * fetch already in flight, so none syncs over it. But a sync doesn't + * copy it to other queries: an entity write already reached every + * query that held it, and an optimistic one may be rolled back. + * - **Only fetches sync.** Writes, `live` pushes and stream queries' + * elements don't, so a sync never starts another sync. A sync doesn't + * write the queries the fetch read through `ctx.result`, so a fetch + * doesn't start itself again. A query that reads a written query + * through `ctx.result` refetches, as after any write to it. + * - **Ages kept.** A query written by a sync keeps its own age and + * staleness, as with {@link Entity.update}. Queries that are + * invalidated, failed, not cached or that opted out + * (`entities: { sync: false }`) are neither read nor written, and a + * query that doesn't hold an id doesn't gain it. A copy equal to the + * newer one (`Equal.equals`) isn't written. + * - **Optimistic writes.** A sync replaces a copy a mutation's + * `optimistic` changed when its fetch started later. If the mutation + * then fails, its rollback puts the old value back and the synced + * copy over it again, unless the query has fetched since. + * - **Cost.** Each fetch of a query that holds a synced entity reads + * every cached query that holds it, once per entity. For an entity in + * many large lists, opt out the queries that don't need it. + * - **Errors.** An `id` that throws is logged with `Effect.logError`; + * the fetch keeps its value and nothing is written. A listener that + * throws as a query is written is logged too. + * + * The other copies are written as the fetch settles. Default: none. + */ + readonly sync?: ReadonlyArray> | undefined; } /** @@ -872,6 +965,11 @@ export const make = (...[given]: OptionalOptions): QueryClient => { memoMap, state, options, + entities: (options.entities?.sync ?? []).map((entity) => + definition(entity), + ), + syncFetched, + stampWritten, }), }); observeNodes(registry, state); diff --git a/src/effetch/index.ts b/src/effetch/index.ts index 069363d..f9365bc 100644 --- a/src/effetch/index.ts +++ b/src/effetch/index.ts @@ -483,6 +483,109 @@ export type ErrorSchema< Default extends Fetch.AnySchema, > = Own extends Fetch.AnySchema ? Own : Default; +/** + * The value of a query {@link Endpoints.query} makes from an endpoint, from + * its `output` schema `O` and its stream format `St`: the decoded `output` + * (the raw `HttpClientResponse` without one), or for a stream endpoint + * (`stream: "sse"` or `"ndjson"`) its latest element, a `Fetch.SseEvent` of + * the `output` for SSE. + * + * @example + * ```ts + * import * as Schema from "effect/Schema"; + * + * import type { EndpointQueryValue } from "@monarcode/effetch-query/effetch"; + * + * const Todo = Schema.Struct({ id: Schema.Finite, title: Schema.String }); + * + * // { readonly id: number; readonly title: string } + * export type TodoValue = EndpointQueryValue; + * ``` + * + * @since 0.1.0 + */ +export type EndpointQueryValue< + O extends Fetch.AnySchema | undefined, + St extends Fetch.StreamFormat | undefined, +> = [St] extends [Fetch.StreamFormat] + ? Fetch.StreamElement + : Fetch.Success; + +/** + * The error of a query {@link Endpoints.query} makes from an endpoint: the + * `Fetch.CallError` of its call, from its `output` schema `O`, its error + * body schema `EB` ({@link ErrorSchema}), the client's plugins `Ps`, its + * status errors `SE` and its stream format `St`. A stream endpoint's + * elements are decoded as they come, so its `DecodeError` isn't for the + * whole `output`. + * + * @example + * ```ts + * import * as Schema from "effect/Schema"; + * + * import type { EndpointQueryCallError } from "@monarcode/effetch-query/effetch"; + * + * const Todo = Schema.Struct({ id: Schema.Finite }); + * + * export type TodoError = EndpointQueryCallError< + * typeof Todo, + * Schema.Unknown, + * [], + * undefined, + * undefined + * >; + * ``` + * + * @since 0.1.0 + */ +export type EndpointQueryCallError< + O extends Fetch.AnySchema | undefined, + EB extends Fetch.AnySchema, + Ps extends ReadonlyArray, + SE extends Fetch.StatusErrorMap | undefined, + St extends Fetch.StreamFormat | undefined, +> = Fetch.CallError< + [St] extends [Fetch.StreamFormat] ? Fetch.AnySchema : O, + EB, + Ps, + SE +>; + +/** + * The options {@link Endpoints.query} takes for an endpoint: those of a + * stream query ({@link EndpointStreamOptions}) for a stream endpoint, + * whose stream format `St` is `"sse"` or `"ndjson"`, else those of a + * fetched one ({@link EndpointQueryOptions}). `E` is the query's error + * ({@link EndpointQueryCallError}), `A` its value + * ({@link EndpointQueryValue}), `R` the endpoint's route and `QS` its + * `query` schema, which type `placeholder` and `live`. + * + * @example + * ```ts + * import type { EndpointQueryOptionsFor } from "@monarcode/effetch-query/effetch"; + * + * export const options: EndpointQueryOptionsFor< + * "GET /todos", + * undefined, + * never, + * [], + * string + * > = { staleTime: "1 minute" }; + * ``` + * + * @since 0.1.0 + */ +export type EndpointQueryOptionsFor< + R extends string, + St extends Fetch.StreamFormat | undefined, + E, + Ps extends ReadonlyArray, + A, + QS extends KeyQuerySchema | undefined = undefined, +> = [St] extends [Fetch.StreamFormat] + ? EndpointStreamOptions> + : EndpointQueryOptions>; + /** * A family of queries, one per call of an Effetch endpoint, made by * {@link Endpoints.query}. Call it with the endpoint's `params` and `query` @@ -510,7 +613,7 @@ export type ErrorSchema< * each field by its sent name. Equal requests share a query, and keys stay * JSON for server rendering. The query a member was first called with is * the one it sends, and the `args` {@link Query.update} gives. A call - * throws an `EndpointQueryError` (its `_tag`) when its query doesn't match + * throws an {@link EndpointQueryError} when its query doesn't match * the schema, a field encodes to an object, or a field is `Redacted`: a key * would hold the secret and send it to the browser, so send it in a header. * @@ -674,6 +777,38 @@ export interface Endpoints< * has them: read from a `Fetch.Service` class, or given for a * `Context.Service` key ({@link EndpointsOptions.statusErrors}). A query * that failed with a plugin's error isn't sent. + * + * @example + * ```ts + * import { Fetch } from "@monarcode/effetch"; + * import * as Schema from "effect/Schema"; + * + * import { Query } from "@monarcode/effetch-query"; + * import { fromClient } from "@monarcode/effetch-query/effetch"; + * + * class Api extends Fetch.Service()("Api", { + * baseUrl: "https://api.example.com", + * }) {} + * + * declare module "@monarcode/effetch-query" { + * interface Register { + * readonly services: Api; + * } + * } + * + * const api = fromClient(Api); + * const Todo = Schema.Struct({ id: Schema.Finite, title: Schema.String }); + * + * // todo({ params: { id: 1 } }) is the query keyed ["todos", 1] + * export const todo = api.query( + * Fetch.endpoint("GET /todos/:id", { output: Todo }), + * { staleTime: "1 minute" }, + * ); + * + * export const loadTodo = Query.fetch(todo({ params: { id: 1 } })); + * ``` + * + * @since 0.1.0 */ readonly query: < const R extends `${HttpMethod.HttpMethod.NoBody} ${string}`, @@ -685,35 +820,18 @@ export interface Endpoints< St extends Fetch.StreamFormat | undefined = undefined, >( endpoint: Fetch.UnboundEndpoint, - options?: [St] extends [Fetch.StreamFormat] - ? EndpointStreamOptions< - Fetch.CallError< - Fetch.AnySchema, - ErrorSchema, - Ps, - OwnSE | SE - >, - Ps, - Fetch.StreamElement, - EndpointQueryArgs - > - : EndpointQueryOptions< - Fetch.CallError, Ps, OwnSE | SE>, - Ps, - Fetch.Success, - EndpointQueryArgs - >, - ) => EndpointQuery< - R, - [St] extends [Fetch.StreamFormat] - ? Fetch.StreamElement - : Fetch.Success, - Fetch.CallError< - [St] extends [Fetch.StreamFormat] ? Fetch.AnySchema : O, - ErrorSchema, + options?: EndpointQueryOptionsFor< + R, + St, + EndpointQueryCallError, Ps, OwnSE | SE, St>, Ps, - OwnSE | SE + EndpointQueryValue, + QS >, + ) => EndpointQuery< + R, + EndpointQueryValue, + EndpointQueryCallError, Ps, OwnSE | SE, St>, QS >; /** @@ -726,6 +844,45 @@ export interface Endpoints< * names one of its optional fields ({@link EndpointPageField}). Only * endpoints without a body. Its queries cross from server to browser as * {@link Endpoints.query}'s do, the page params as JSON. + * + * @example + * ```ts + * import { Fetch } from "@monarcode/effetch"; + * import * as Schema from "effect/Schema"; + * + * import { InfiniteQuery } from "@monarcode/effetch-query"; + * import { fromClient } from "@monarcode/effetch-query/effetch"; + * + * class Api extends Fetch.Service()("Api", { + * baseUrl: "https://api.example.com", + * }) {} + * + * declare module "@monarcode/effetch-query" { + * interface Register { + * readonly services: Api; + * } + * } + * + * const api = fromClient(Api); + * const ActivityPage = Schema.Struct({ + * items: Schema.Array(Schema.String), + * nextCursor: Schema.NullOr(Schema.String), + * }); + * + * // activity({}) loads GET /activity, then GET /activity?cursor=… + * export const activity = api.infiniteQuery( + * Fetch.endpoint("GET /activity", { output: ActivityPage }), + * { + * pageParam: "cursor", + * initialPageParam: null as string | null, + * nextPageParam: (lastPage) => lastPage.nextCursor, + * }, + * ); + * + * export const loadMore = InfiniteQuery.fetchNextPage(activity({})); + * ``` + * + * @since 0.1.0 */ readonly infiniteQuery: < const R extends `${HttpMethod.HttpMethod.NoBody} ${string}`, @@ -764,6 +921,41 @@ export interface Endpoints< * whose `input` is a `Fetch.multipart` schema sends `body` as * `multipart/form-data`, typed by the schema: an upload, with * `Fetch.UploadFile` for each file. + * + * @example + * ```ts + * import { Fetch } from "@monarcode/effetch"; + * import * as Schema from "effect/Schema"; + * + * import { Mutation } from "@monarcode/effetch-query"; + * import { fromClient } from "@monarcode/effetch-query/effetch"; + * + * class Api extends Fetch.Service()("Api", { + * baseUrl: "https://api.example.com", + * }) {} + * + * declare module "@monarcode/effetch-query" { + * interface Register { + * readonly services: Api; + * } + * } + * + * const api = fromClient(Api); + * const Todo = Schema.Struct({ id: Schema.Finite, title: Schema.String }); + * + * // run with { body: { title } }; on success, invalidates every todos query + * export const addTodo = api.mutation( + * Fetch.endpoint("POST /todos", { + * input: Schema.Struct({ title: Schema.String }), + * output: Todo, + * }), + * { invalidates: [["todos"]] }, + * ); + * + * export const addMilk = Mutation.run(addTodo, { body: { title: "Milk" } }); + * ``` + * + * @since 0.1.0 */ readonly mutation: < const R extends string, @@ -801,11 +993,32 @@ interface AnyEndpoint { /** * Thrown when a call's `query` can't be part of its key: it doesn't match * the endpoint's `query` schema, a field encodes to an object, or a field is - * `Redacted`, whose secret the key would hold and send to the browser. + * `Redacted`, whose secret the key would hold and send to the browser. Send + * a secret in a header instead. It's thrown when the query is made, such as + * `todos({ query })` in a component, before anything is fetched. + * + * @example + * ```ts + * import { EndpointQueryError } from "@monarcode/effetch-query/effetch"; + * + * // The message names the route: "Invalid query for GET /todos: …". + * export const explain = (error: unknown): string => + * error instanceof EndpointQueryError ? error.message : String(error); + * ``` + * + * @see {@link Endpoints.query} for how a query becomes part of a key + * + * @since 0.1.0 */ -class EndpointQueryError extends Data.TaggedError("EndpointQueryError")<{ +export class EndpointQueryError extends Data.TaggedError("EndpointQueryError")<{ + /** The endpoint's route, such as `"GET /todos"`. */ readonly route: string; + /** What can't be part of the key, for logs. */ readonly message: string; + /** + * What encoding the query threw, when it doesn't match the schema: a + * `Schema.SchemaError`, whose `issue` says which field is wrong. + */ readonly cause?: unknown; }> {} diff --git a/src/internal/ages.ts b/src/internal/ages.ts new file mode 100644 index 0000000..1764e37 --- /dev/null +++ b/src/internal/ages.ts @@ -0,0 +1,102 @@ +import * as MutableHashMap from "effect/MutableHashMap"; +import * as Option from "effect/Option"; + +import type * as Query from "../Query.js"; +import type { ClientState } from "./runtime.js"; + +/** + * How new each copy of a synced entity in a query is, for entity sync + * (DESIGN.md §4.15), on the client's `clock`. A fetch attempt takes a whole + * number when it starts; a write takes the half after the latest attempt + * (`now`). `base` dates the query's value, and `copies` the copies that + * came from elsewhere, per entity and id: synced in, written, or carried + * over from an older value. + */ +export interface Ages { + readonly base: number; + readonly copies: Map>; +} + +/** No record, or a value from the server: older than any fetch. */ +export const oldest = -1; + +/** Dates a fetch attempt as it starts. */ +export const tick = (state: ClientState): number => ++state.clock; + +/** + * A write's age: after every fetch attempt started so far and before the + * next one, so a fetch already in flight doesn't sync over it. + */ +export const now = (state: ClientState): number => state.clock + 0.5; + +/** Whether an age is a fetch's: only fetched copies are synced to other queries. */ +export const isFetched = (age: number): boolean => Number.isInteger(age); + +export const ageOf = ( + state: ClientState, + query: Query.Query, + entity: object, + id: unknown, +): number => { + const ages = state.ages.get(query); + if (ages === undefined) { + return oldest; + } + const copies = ages.copies.get(entity); + return copies === undefined + ? ages.base + : Option.getOrElse(MutableHashMap.get(copies, id), () => ages.base); +}; + +/** Dates a query's whole value, forgetting its copies' own ages. */ +export const stampQuery = ( + state: ClientState, + query: Query.Query, + age: number, +): void => { + state.ages.set(query, { base: age, copies: new Map() }); +}; + +/** + * Dates copies of a query's value. Returns how to put their ages back, for + * a write's undo: only while the query keeps these ages, and for each copy + * nothing has dated since. + */ +export const stampCopies = ( + state: ClientState, + query: Query.Query, + copies: ReadonlyArray, + age: number, +): (() => void) => { + let ages = state.ages.get(query); + if (ages === undefined) { + ages = { base: oldest, copies: new Map() }; + state.ages.set(query, ages); + } + const stamped = ages; + const previous = copies.map(([entity, id]) => { + let byId = stamped.copies.get(entity); + if (byId === undefined) { + byId = MutableHashMap.empty(); + stamped.copies.set(entity, byId); + } + const before = MutableHashMap.get(byId, id); + MutableHashMap.set(byId, id, age); + return { byId, id, before }; + }); + return () => { + if (state.ages.get(query) !== stamped) { + return; + } + for (const { byId, id, before } of previous) { + if (Option.getOrUndefined(MutableHashMap.get(byId, id)) !== age) { + continue; + } + if (Option.isSome(before)) { + MutableHashMap.set(byId, id, before.value); + } else { + MutableHashMap.remove(byId, id); + } + } + }; +}; diff --git a/src/internal/cache.ts b/src/internal/cache.ts index 8712fcb..71595c4 100644 --- a/src/internal/cache.ts +++ b/src/internal/cache.ts @@ -5,6 +5,7 @@ import type * as Atom from "effect/reactivity/Atom"; import type * as AtomRegistry from "effect/reactivity/AtomRegistry"; import type * as Query from "../Query.js"; +import { oldest, stampQuery } from "./ages.js"; import type { QuerySettings } from "./defaults.js"; import { emit } from "./events.js"; import { isFresh } from "./freshness.js"; @@ -90,7 +91,21 @@ export const setValue = ( value: A, ): Undo => { const mark = pushMark(registry, query); - return guardUndo(registry, query, mark, writeValue(registry, query, value)); + const { stampWritten } = registry.get(ConfigAtom); + const before = Option.flatMap(peek(registry, query), AsyncResult.value); + const undo = writeValue(registry, query, value); + const restoreAges = stampWritten?.(registry, query, before, value); + return guardUndo( + registry, + query, + mark, + restoreAges === undefined + ? undo + : () => { + undo(); + restoreAges(); + }, + ); }; /** @@ -202,6 +217,10 @@ export const hydrateValue = ( seed(registry, fetchAtom(target), result); registry.set(local, { generation: target, written: Option.none() }); registry.get(cache); + // The server's copies are older than any fetch here. + if (registry.get(ConfigAtom).entities.length > 0) { + stampQuery(registry.get(StateAtom), query, oldest); + } }; /** Writes a value computed from the cached one, as `setValue` does, if there is one. */ diff --git a/src/internal/entity.ts b/src/internal/entity.ts index 2c34531..2864c3b 100644 --- a/src/internal/entity.ts +++ b/src/internal/entity.ts @@ -7,10 +7,11 @@ import * as Schema from "effect/Schema"; import * as SchemaAST from "effect/SchemaAST"; import type * as Query from "../Query.js"; +import { now, stampCopies } from "./ages.js"; import { lastSuccess, patchValue, undoAll } from "./cache.js"; import type { Undo } from "./optimistic.js"; import { internals, peek } from "./queryAtom.js"; -import { StateAtom } from "./runtime.js"; +import { ConfigAtom, StateAtom } from "./runtime.js"; /** * Where an entity sits in a query's value (DESIGN.md §4.13), found once per @@ -502,7 +503,7 @@ export interface EntityDefinition { readonly plans: WeakMap; } -const planIn = ( +export const planIn = ( entity: EntityDefinition, query: Query.Query, ): Plan | undefined => { @@ -522,7 +523,7 @@ const planIn = ( * Each cached query that holds the entity, with its last success, when that * was fetched or written, and whether the query shows a failure over it. */ -const holding = ( +export const holding = ( registry: AtomRegistry.AtomRegistry, entity: EntityDefinition, ): ReadonlyArray<{ @@ -577,10 +578,33 @@ export const writeEntity = ( : [{ query, next, timestamp }]; }, ); + const syncing = registry.get(ConfigAtom).entities.length > 0; + const state = registry.get(StateAtom); return undoAll( writes.flatMap(({ query, next, timestamp }) => { const undo = patchValue(registry, query, next, timestamp); - return undo === undefined ? [] : [undo]; + if (undo === undefined) { + return []; + } + if (!syncing) { + return [undo]; + } + // So a fetch already in flight doesn't sync an older copy over it. + const restoreAges = stampCopies( + state, + query, + [[entity, id]], + now(state), + ); + return [ + Object.assign( + () => { + undo(); + restoreAges(); + }, + { release: undo.release }, + ), + ]; }), ); }; diff --git a/src/internal/entitySync.ts b/src/internal/entitySync.ts new file mode 100644 index 0000000..261c571 --- /dev/null +++ b/src/internal/entitySync.ts @@ -0,0 +1,470 @@ +import * as Effect from "effect/Effect"; +import * as Equal from "effect/Equal"; +import * as MutableHashMap from "effect/MutableHashMap"; +import * as Option from "effect/Option"; +import * as Predicate from "effect/Predicate"; +import type * as Atom from "effect/reactivity/Atom"; +import type * as AtomRegistry from "effect/reactivity/AtomRegistry"; + +import type * as Query from "../Query.js"; +import { + ageOf, + isFetched, + now, + oldest, + stampCopies, + stampQuery, +} from "./ages.js"; +import { + applyPlan, + type EntityDefinition, + holding, + type Plan, + planIn, +} from "./entity.js"; +import { dropSyncs, recordPush } from "./live.js"; +import { + cachedQuery, + internals, + isCurrent, + lastSuccess, + localValue, + peek, + syncsEntities, + writeKeepingAge, +} from "./queryAtom.js"; +import { + type ClientState, + ConfigAtom, + type StampWritten, + StateAtom, + type SyncFetched, +} from "./runtime.js"; + +interface Copy { + readonly copy: object; + readonly age: number; + /** Read by this fetch: only those go to other queries. */ + readonly fresh: boolean; +} + +type Holding = ReturnType[number]; + +/** One synced entity in the fetched query, with the other queries that hold it. */ +interface Pass { + readonly entity: EntityDefinition; + readonly plan: Plan; + readonly others: ReadonlyArray; + /** Each id's copy and age in the fetched value, once newer copies are pulled in. */ + readonly mine: MutableHashMap.MutableHashMap; + readonly pulled: MutableHashMap.MutableHashMap; +} + +/** A sync's write over another query, made once every write is computed. */ +interface Write { + readonly entity: EntityDefinition; + readonly query: Query.Query; + /** + * Puts the newer copies into a value: the query's when it's written, so + * two entities' writes to one query both stay, and the one an undo puts + * back (`live.ts`). `undefined` when every copy was already equal. + */ + readonly apply: ((value: unknown) => unknown) | undefined; + /** The ages of the copies it dates, written or equal. */ + readonly ages: ReadonlyArray; +} + +/** Calls `f` with each copy a plan reaches in a value, without changing it. */ +const eachCopy = ( + plan: Plan, + value: unknown, + f: (copy: object) => void, +): void => { + applyPlan(plan, value, (copy) => { + f(copy); + return copy; + }); +}; + +/** Keeps the newer of two copies of an id. */ +const keepNewer = ( + copies: MutableHashMap.MutableHashMap, + id: unknown, + copy: Copy, +): void => { + const known = MutableHashMap.get(copies, id); + if (Option.isNone(known) || known.value.age < copy.age) { + MutableHashMap.set(copies, id, copy); + } +}; + +/** + * The queries the fetch read through `ctx.result`, and theirs: a sync + * doesn't write them, or the fetch would start again. + */ +const dependencies = ( + registry: AtomRegistry.AtomRegistry, + atom: Atom.Atom, +): ReadonlySet> => { + const found = new Set>(); + const seen = new Set(); + const pending = [...(registry.getNodes().get(atom)?.parents ?? [])]; + for (let node = pending.pop(); node !== undefined; node = pending.pop()) { + if (seen.has(node)) { + continue; + } + seen.add(node); + const query = cachedQuery(node.atom); + if (query !== undefined) { + found.add(query); + } + pending.push(...node.parents); + } + return found; +}; + +/** + * When each object in what a fetch's attempts read was read: an infinite + * query's refetch reads its pages one after the other, and a retried page + * later still. `undefined` for an object no attempt read. + */ +const readDates = ( + reads: ReadonlyArray<{ readonly result: unknown; readonly start: number }>, +): ((copy: object) => number | undefined) => { + let dates: WeakMap | undefined; + return (copy) => { + if (dates === undefined) { + dates = new WeakMap(); + for (const { result, start } of reads) { + const pending: Array = [result]; + while (pending.length > 0) { + const next = pending.pop(); + if (Predicate.isObjectOrArray(next) && !dates.has(next)) { + dates.set(next, start); + // One by one: a spread of a large array exceeds the + // engine's argument limit. A typed array holds no copies. + if (!ArrayBuffer.isView(next)) { + for (const field of Object.values(next)) { + pending.push(field); + } + } + } + } + } + } + return dates.get(copy); + }; +}; + +/** + * Dates each copy of the entity in the fetched value and pulls newer + * copies into it. A copy is dated by `dateOf`, unless it isn't new: one + * the query already showed (an infinite query's older pages) keeps its + * age, and one another query holds (read through `ctx.result`) takes that + * query's. Only fetched copies are pulled: from other queries, and the + * query's own, synced in while it fetched. + */ +const pull = ( + registry: AtomRegistry.AtomRegistry, + state: ClientState, + query: Query.Query, + entity: EntityDefinition, + plan: Plan, + value: A, + dateOf: (copy: object) => Omit, +): { readonly value: A; readonly pass: Pass } => { + const shown = Option.flatMap(peek(registry, query), lastSuccess); + const carried = new Set(); + const newest = MutableHashMap.empty(); + Option.map(shown, (success) => + eachCopy(plan, success.value, (copy) => { + carried.add(copy); + const id = entity.id(copy); + const age = ageOf(state, query, entity, id); + if (isFetched(age)) { + keepNewer(newest, id, { copy, age, fresh: false }); + } + }), + ); + const mine = MutableHashMap.empty(); + eachCopy(plan, value, (copy) => { + const id = entity.id(copy); + keepNewer( + mine, + id, + carried.has(copy) + ? { copy, age: ageOf(state, query, entity, id), fresh: false } + : { copy, ...dateOf(copy) }, + ); + }); + const others = holding(registry, entity).filter( + (other) => + other.query !== query && + !other.failed && + syncsEntities(registry, other.query) && + isCurrent(registry, other.query), + ); + const borrowed = MutableHashMap.empty(); + for (const other of others) { + eachCopy(other.plan, other.value, (copy) => { + const id = entity.id(copy); + const own = MutableHashMap.get(mine, id); + if (Option.isNone(own)) { + return; + } + const age = ageOf(state, other.query, entity, id); + if (own.value.copy === copy && !carried.has(copy)) { + MutableHashMap.set(borrowed, id, age); + } + if (isFetched(age)) { + keepNewer(newest, id, { copy, age, fresh: false }); + } + }); + } + for (const [id, age] of borrowed) { + const own = Option.getOrThrow(MutableHashMap.get(mine, id)); + MutableHashMap.set(mine, id, { copy: own.copy, age, fresh: false }); + } + const pulled = MutableHashMap.empty(); + for (const [id, other] of newest) { + const own = MutableHashMap.get(mine, id); + if (Option.isSome(own) && other.age > own.value.age) { + MutableHashMap.set(pulled, id, other); + MutableHashMap.set(mine, id, other); + } + } + const next = + MutableHashMap.size(pulled) === 0 + ? value + : (applyPlan(plan, value, (copy) => + Option.match(MutableHashMap.get(pulled, entity.id(copy)), { + onNone: () => copy, + onSome: ({ copy: newer }) => + Equal.equals(copy, newer) ? copy : newer, + }), + ) as A); + return { value: next, pass: { entity, plan, others, mine, pulled } }; +}; + +/** + * The writes of the fetched copies over older copies in other queries, + * from the value with every entity's newer copies pulled in. Only the + * copies this fetch read go, not carried, borrowed or pulled ones, and a + * query the fetch depends on isn't written. + */ +const push = ( + state: ClientState, + pass: Pass, + value: unknown, + skip: ReadonlySet>, +): ReadonlyArray => { + const { entity, plan, others, mine, pulled } = pass; + // A copy another entity's pull rebuilt (an outer copy with a newer + // inner one) is written as rebuilt. + const kept = new Set(); + const latest = MutableHashMap.empty(); + eachCopy(plan, value, (copy) => { + kept.add(copy); + MutableHashMap.set(latest, entity.id(copy), copy); + }); + return others.flatMap((other): ReadonlyArray => { + if (skip.has(other.query)) { + return []; + } + const ages: Array = []; + const changed = MutableHashMap.empty(); + eachCopy(other.plan, other.value, (copy) => { + const id = entity.id(copy); + const own = MutableHashMap.get(mine, id); + if ( + Option.isNone(own) || + !own.value.fresh || + MutableHashMap.has(pulled, id) || + own.value.age <= ageOf(state, other.query, entity, id) + ) { + return; + } + const newer = kept.has(own.value.copy) + ? own.value.copy + : Option.getOrElse( + MutableHashMap.get(latest, id), + () => own.value.copy, + ); + ages.push([id, own.value.age]); + if (!Equal.equals(copy, newer)) { + MutableHashMap.set(changed, id, newer); + } + }); + if (ages.length === 0) { + return []; + } + return [ + { + entity, + query: other.query, + apply: + MutableHashMap.size(changed) === 0 + ? undefined + : (current) => + applyPlan(other.plan, current, (copy) => + Option.getOrElse( + MutableHashMap.get(changed, entity.id(copy)), + () => copy, + ), + ), + ages, + }, + ]; + }); +}; + +/** + * Entity sync after a successful fetch (DESIGN.md §4.15), for the client's + * `entities.sync`. Every write is computed before any is made, so an `id` + * that throws writes nothing. A throw is logged, and the fetch keeps its + * value. A fetch of a generation the query has left (a `reset` or `clear` + * since) syncs nothing: its value isn't shown. + */ +export const syncFetched: SyncFetched = (registry, query, value, fetch) => + Effect.suspend(() => { + if ( + !syncsEntities(registry, query) || + localValue(registry, query).generation !== fetch.generation + ) { + return Effect.succeed(value); + } + const state = registry.get(StateAtom); + // A value the server sent, read by no attempt, is older than any fetch. + const base = + fetch.reads.length === 0 + ? oldest + : Math.min(...fetch.reads.map(({ start }) => start)); + const readAt = readDates(fetch.reads); + // A copy no attempt read was changed while the fetch ran, by a `live` + // push `withPushes` replayed: a write, dated as one. + const dateOf = (copy: object): Omit => { + const read = fetch.reads.length === 0 ? undefined : readAt(copy); + return read !== undefined + ? { age: read, fresh: true } + : { + age: fetch.reads.length === 0 ? oldest : now(state), + fresh: false, + }; + }; + let synced = value; + const passes: Array = []; + const writes: Array = []; + try { + for (const entity of registry.get(ConfigAtom).entities) { + const plan = planIn(entity, query); + if (plan !== undefined) { + const pulled = pull( + registry, + state, + query, + entity, + plan, + synced, + dateOf, + ); + synced = pulled.value; + passes.push(pulled.pass); + } + } + const skip = dependencies( + registry, + internals(query).fetchAtom(fetch.generation), + ); + for (const pass of passes) { + writes.push(...push(state, pass, synced, skip)); + } + } catch (cause) { + // A fetch that read nothing (an infinite query with no page to + // add) returns what the query showed, which keeps its ages. + if (fetch.reads.length > 0) { + stampQuery(state, query, base); + } + return Effect.as(Effect.logError("Entity sync failed", cause), value); + } + stampQuery(state, query, base); + for (const { entity, mine } of passes) { + for (const [id, { age }] of mine) { + if (age !== base) { + stampCopies(state, query, [[entity, id]], age); + } + } + } + // The fetched value is dated after them, so an undo mustn't apply them. + dropSyncs(state, query); + // Each write is made whatever another throws: a listener, or an `id` + // over a value a listener changed. + const failures: Array = []; + for (const { entity, query: other, apply, ages } of writes) { + try { + for (const [id, age] of ages) { + stampCopies(state, other, [[entity, id]], age); + } + const current = Option.flatMap(peek(registry, other), lastSuccess); + if (apply === undefined || Option.isNone(current)) { + continue; + } + const next = apply(current.value.value); + if (next === current.value.value) { + continue; + } + // Recorded first: the registry stores the value before a + // listener can throw. + recordPush(state, other, apply, true); + writeKeepingAge(registry, other, next, current.value.timestamp); + } catch (cause) { + failures.push(cause); + } + } + return failures.length === 0 + ? Effect.succeed(synced) + : Effect.as( + Effect.logError("Entity sync failed", ...failures), + synced, + ); + }); + +/** + * Dates as new the synced entities' copies a write put in a query: those + * that aren't the same objects it showed before (DESIGN.md §4.15). A copy + * whose `id` throws isn't dated: the write stands, as without sync, and the + * next fetch that syncs the query logs the throw. + */ +export const stampWritten: StampWritten = (registry, query, before, after) => { + if (!syncsEntities(registry, query)) { + return () => {}; + } + const state = registry.get(StateAtom); + const written: Array = []; + try { + for (const entity of registry.get(ConfigAtom).entities) { + const plan = planIn(entity, query); + if (plan === undefined) { + continue; + } + const old = new Set(); + Option.map(before, (value) => + eachCopy(plan, value, (copy) => old.add(copy)), + ); + eachCopy(plan, after, (copy) => { + if (old.has(copy)) { + return; + } + try { + written.push([entity, entity.id(copy)]); + } catch { + // Left undated. + } + }); + } + } catch { + // The write has been made: date what was found. + } + return written.length === 0 + ? () => {} + : stampCopies(state, query, written, now(state)); +}; diff --git a/src/internal/keyIndex.ts b/src/internal/keyIndex.ts index 76c5fd0..31f97bd 100644 --- a/src/internal/keyIndex.ts +++ b/src/internal/keyIndex.ts @@ -1,8 +1,8 @@ -import * as Data from "effect/Data"; import * as Equal from "effect/Equal"; import * as Predicate from "effect/Predicate"; import type * as AtomRegistry from "effect/reactivity/AtomRegistry"; +import { KeyHoldsTargetError } from "../KeyHoldsTargetError.js"; import type { Group, Query, @@ -37,17 +37,6 @@ export const makeGroup = (targets: ReadonlyArray): Group => { return { [GroupTypeId]: GroupTypeId, targets: Array.from(flat) }; }; -/** - * Thrown when a key holds a query, a family or a group: targets passed as an - * array, which as a key would match nothing. - */ -export class KeyHoldsTargetError extends Data.TaggedError( - "KeyHoldsTargetError", -)<{ - readonly key: QueryKey; - readonly message: string; -}> {} - const isTargetValue = (segment: unknown): boolean => isQuery(segment) || // A family: a function with a key. diff --git a/src/internal/live.ts b/src/internal/live.ts index 7cafbca..36f3423 100644 --- a/src/internal/live.ts +++ b/src/internal/live.ts @@ -11,7 +11,12 @@ type Update = (value: any) => any; */ export interface PushLog { seq: number; - entries: Array<{ readonly seq: number; readonly f: Update }>; + /** `sync` marks an entity sync's write (DESIGN.md §4.15), which only an undo applies again. */ + entries: Array<{ + readonly seq: number; + readonly f: Update; + readonly sync: boolean; + }>; readonly marks: Set; } @@ -35,14 +40,22 @@ const logOf = (state: ClientState, query: Query.Query): PushLog => { return log; }; -/** Opens a {@link Mark} at the query's latest push. */ +/** + * Opens a {@link Mark} at the query's latest push. A fetch's mark leaves out + * entity syncs: they're dated, and a fetch that settles over one is newer + * or gets it back from where it came from. + */ export const openMark = ( state: ClientState, query: Query.Query, + purpose: "fetch" | "undo", ): Mark => { const log = logOf(state, query); const since = log.seq; - const after = () => log.entries.filter((entry) => entry.seq > since); + const after = () => + log.entries.filter( + (entry) => entry.seq > since && (purpose === "undo" || !entry.sync), + ); const mark: Mark = { since, replay: (value) => @@ -74,10 +87,25 @@ export const recordPush = ( state: ClientState, query: Query.Query, f: Update, + sync = false, ): void => { const log = logOf(state, query); log.seq++; if (log.marks.size > 0) { - log.entries.push({ seq: log.seq, f }); + log.entries.push({ seq: log.seq, f, sync }); + } +}; + +/** + * Forgets a query's entity syncs once its own fetch settles: the fetched + * value is dated after them, so an undo mustn't apply them over it. + */ +export const dropSyncs = ( + state: ClientState, + query: Query.Query, +): void => { + const log = state.pushes.get(query); + if (log !== undefined) { + log.entries = log.entries.filter((entry) => !entry.sync); } }; diff --git a/src/internal/queryAtom.ts b/src/internal/queryAtom.ts index 32ba993..0ede446 100644 --- a/src/internal/queryAtom.ts +++ b/src/internal/queryAtom.ts @@ -13,6 +13,7 @@ import * as Stream from "effect/Stream"; import type * as Query from "../Query.js"; import type * as QueryClient from "../QueryClient.js"; +import { oldest, stampQuery, tick } from "./ages.js"; import { type QuerySettings, resolveGcTime, @@ -386,6 +387,7 @@ const preloadedResult = ( */ const seedPreloaded = ( registry: AtomRegistry.AtomRegistry, + query: Query.Query, atom: Atom.Atom>, hydration: QueryHydration, ): void => { @@ -394,9 +396,13 @@ const seedPreloaded = ( return; } if (Option.isNone(nodeValue(registry, atom))) { - Option.map(preloadedResult(registry, hydration), (result) => - seed(registry, atom, result), - ); + Option.map(preloadedResult(registry, hydration), (result) => { + seed(registry, atom, result); + // The server's copies are older than any fetch here. + if (registry.get(ConfigAtom).entities.length > 0) { + stampQuery(registry.get(StateAtom), query, oldest); + } + }); } registry.preloadedSerializable.delete(hash.value); }; @@ -657,6 +663,15 @@ export const makeQuery = (definition: { get(refreshSignal); subscribeReactivity(get); const { retry } = get(watcher).settings; + const run = fetchRun(get); + const { state } = run; + const streamed = takeStreamed(state, hydration); + // What each attempt read, and when it started, for entity sync: + // a refetch of an infinite query reads its pages one by one. + const reads: Array<{ + readonly result: unknown; + readonly start: number; + }> = []; const context: FetchContext = { get, previous: () => { @@ -674,18 +689,24 @@ export const makeQuery = (definition: { }, // Each attempt gets its own scope, closed in its fiber, and the // client tracks the fiber: `dispose()` waits for both. - attempt: (run) => { - const once = Effect.scoped( - run(runContext(get, generation)), - ); + attempt: (runAttempt) => { + const once = Effect.suspend(() => { + const start = tick(state); + return Effect.map( + Effect.scoped( + runAttempt(runContext(get, generation)), + ), + (result) => { + reads.push({ result, start }); + return result; + }, + ); + }); return retry === undefined ? once : Effect.retry(once, retry); }, }; - const run = fetchRun(get); - const { state } = run; - const streamed = takeStreamed(state, hydration); const fetched = (): Effect.Effect< A, E, @@ -695,12 +716,22 @@ export const makeQuery = (definition: { streamed === undefined || hydration === undefined ? fetched() : fromServer(streamed, hydration.codec, fetched); + const { syncFetched } = get.once(ConfigAtom); return Effect.withFiber((fiber) => { started(state, fiber); - return Effect.onExit( + const withLive = live === undefined ? fetch - : withPushes(state, query, fetch), + : withPushes(state, query, fetch); + return Effect.onExit( + syncFetched === undefined + ? withLive + : Effect.flatMap(withLive, (value) => + syncFetched(run.registry, query, value, { + reads, + generation, + }), + ), (exit) => settled(run, fiber, generation, exit), ); }); @@ -857,7 +888,7 @@ export const makeQuery = (definition: { return AsyncResult.initial(); } if (generation === 0 && hydration !== undefined) { - seedPreloaded(get.registry, fetchAtom(0), hydration); + seedPreloaded(get.registry, query, fetchAtom(0), hydration); } const result = combine(get(fetchAtom(generation)), written); get(watcher).resume(); @@ -906,7 +937,12 @@ export const makeQuery = (definition: { } // Before the stream writes its fetch atom. if (generation === 0 && hydration !== undefined) { - seedPreloaded(get.registry, fetchAtom(0), hydration); + seedPreloaded( + get.registry, + query, + fetchAtom(0), + hydration, + ); } const running = get(streamAtom!(generation)); const result = get(cache); @@ -984,7 +1020,7 @@ const withPushes = ( fetch: Effect.Effect, ): Effect.Effect => Effect.suspend(() => { - const mark = openMark(state, query); + const mark = openMark(state, query, "fetch"); return Effect.ensuring( Effect.map(fetch, (value) => mark.replay(value)), Effect.sync(mark.close), @@ -1006,12 +1042,17 @@ const push = ( recordPush(state, query, f); const current = peek(registry, query); if (Option.isSome(current) && AsyncResult.isSuccess(current.value)) { - writeKeepingAge( - registry, - query, - f(current.value.value), - current.value.timestamp, - ); + const next = f(current.value.value); + writeKeepingAge(registry, query, next, current.value.timestamp); + // A pushed copy is newer than any fetch in flight (DESIGN.md §4.15). + registry + .get(ConfigAtom) + .stampWritten?.( + registry, + query, + Option.some(current.value.value), + next, + ); } }; @@ -1027,15 +1068,11 @@ export const writeKeepingAge = ( value: A, timestamp: number, ): Local | undefined => { - const { local, fetchAtom } = internals(query); const previous = localValue(registry, query); - const state = registry - .getNodes() - .get(fetchAtom(previous.generation)) - ?.currentState(); - if (previous.idle === true || state !== "valid") { + if (!isCurrent(registry, query)) { return undefined; } + const { local } = internals(query); registry.set(local, { generation: previous.generation, written: Option.some(written(value, timestamp)), @@ -1085,10 +1122,43 @@ export const pushMark = ( registry: AtomRegistry.AtomRegistry, query: Query.Query, ): Mark | undefined => - internals(query).live === "Updates" - ? openMark(registry.get(StateAtom), query) + internals(query).live === "Updates" || syncsEntities(registry, query) + ? openMark(registry.get(StateAtom), query, "undo") : undefined; +/** + * Whether entity sync (DESIGN.md §4.15) reads and writes the query: the + * client syncs entities, and the query has a schema to find them in and + * didn't opt out. A stream query's elements aren't synced. + */ +export const syncsEntities = ( + registry: AtomRegistry.AtomRegistry, + query: Query.Query, +): boolean => { + const { options, hydration, live } = internals(query); + return ( + registry.get(ConfigAtom).entities.length > 0 && + hydration !== undefined && + live !== "Stream" && + options.entities?.sync !== false + ); +}; + +/** Whether the query shows a value a write can go over (`writeKeepingAge`). */ +export const isCurrent = ( + registry: AtomRegistry.AtomRegistry, + query: Query.Query, +): boolean => { + const { idle, generation } = localValue(registry, query); + return ( + idle !== true && + registry + .getNodes() + .get(internals(query).fetchAtom(generation)) + ?.currentState() === "valid" + ); +}; + /** The query whose value a node holds: its cache's, for a live query. */ export const cachedQuery = ( atom: Atom.Atom, diff --git a/src/internal/runtime.ts b/src/internal/runtime.ts index fb24145..7d94f14 100644 --- a/src/internal/runtime.ts +++ b/src/internal/runtime.ts @@ -12,20 +12,64 @@ import * as Reactivity from "effect/reactivity/Reactivity"; import type { Query } from "../Query.js"; import type * as QueryClient from "../QueryClient.js"; import type { Signals } from "../Signals.js"; +import type { Ages } from "./ages.js"; +import type { EntityDefinition } from "./entity.js"; import { type Activity, type CacheEvent, makeActivity } from "./events.js"; import type { PushLog } from "./live.js"; +/** + * Entity sync after a fetch (DESIGN.md §4.15): writes the fetched copies + * over older ones in other queries, and gives back the value with any newer + * copy those hold. `reads` are what the fetch's attempts returned, each with + * when it started (`ClientState.clock`): none for a value the server sent. + * `generation` is the fetch atom's. `QueryClient.make` passes it in, so the + * query atom doesn't import the entity code. + */ +export type SyncFetched = ( + registry: AtomRegistry.AtomRegistry, + query: Query, + value: A, + fetch: { + readonly reads: ReadonlyArray<{ + readonly result: unknown; + readonly start: number; + }>; + readonly generation: number; + }, +) => Effect.Effect; + +/** + * Dates as new the synced entities' copies a write put in a query, those + * not in `before`, for entity sync (DESIGN.md §4.15). Returns how to put + * their ages back, for the write's undo. + */ +export type StampWritten = ( + registry: AtomRegistry.AtomRegistry, + query: Query, + before: Option.Option, + after: unknown, +) => () => void; + /** What `QueryClient.make` stores for queries and mutations to read at run time. */ export interface Config { readonly signals: Signals | undefined; readonly queries: QueryClient.QueriesOptions; readonly mutations: QueryClient.MutationsOptions; + /** The entities kept in sync, from `entities.sync`. */ + readonly entities: ReadonlyArray>; + /** Set when `entities` isn't empty. */ + readonly syncFetched: SyncFetched | undefined; + /** Set when `entities` isn't empty. */ + readonly stampWritten: StampWritten | undefined; } const defaultConfig: Config = { signals: undefined, queries: {}, mutations: {}, + entities: [], + syncFetched: undefined, + stampWritten: undefined, }; /** A client's own mutable state. It lives in the client's registry. */ @@ -86,6 +130,10 @@ export interface ClientState { readonly placeholders: WeakSet>; /** Each live query's pushes, while a fetch or an undo may need them (see `live.ts`). */ readonly pushes: WeakMap, PushLog>; + /** How new each query's copies of synced entities are (see `ages.ts`). */ + readonly ages: WeakMap, Ages>; + /** Orders fetch attempts and writes, for those ages. */ + clock: number; } export const makeClientState = (): ClientState => ({ @@ -105,6 +153,8 @@ export const makeClientState = (): ClientState => ({ runCount: 0, placeholders: new WeakSet(), pushes: new WeakMap(), + ages: new WeakMap(), + clock: 0, }); /** Adds a fiber to the ones `dispose()` interrupts, until it ends. */ @@ -169,6 +219,9 @@ export const initialValues = (input: { readonly memoMap: Layer.MemoMap; readonly state: ClientState; readonly options: QueryClient.CommonOptions; + readonly entities: ReadonlyArray>; + readonly syncFetched: SyncFetched; + readonly stampWritten: StampWritten; }): ReadonlyArray, unknown]> => [ initialValue(ContextAtom, input.context), initialValue(MemoMapAtom, input.memoMap), @@ -176,6 +229,10 @@ export const initialValues = (input: { signals: input.options.signals, queries: input.options.queries ?? {}, mutations: input.options.mutations ?? {}, + entities: input.entities, + syncFetched: input.entities.length === 0 ? undefined : input.syncFetched, + stampWritten: + input.entities.length === 0 ? undefined : input.stampWritten, }), initialValue(StateAtom, input.state), ]; diff --git a/src/react/hooks.ts b/src/react/hooks.ts index 41bbceb..4ece8e6 100644 --- a/src/react/hooks.ts +++ b/src/react/hooks.ts @@ -16,6 +16,7 @@ import { pageState, pagingAtom, } from "../internal/infiniteQuery.js"; +import { matcher } from "../internal/keyIndex.js"; import { makeHandle } from "../internal/mutationHandle.js"; import { makeQueriesUse } from "../internal/queriesUse.js"; import { queryState } from "../internal/queryState.js"; @@ -1297,7 +1298,9 @@ export interface UseRefetchResult { * {@link Query.Target}'s queries in use, as {@link Query.refetch} does. For a * screen made of queries with different keys, pass a {@link Query.group} of * them: it's refetching until every one has settled. Throws a - * `MissingQueryProviderError` outside a `QueryProvider`. + * `MissingQueryProviderError` outside a `QueryProvider`, and a + * {@link Query.KeyHoldsTargetError} for a key that holds a query, a family + * or a group, such as `[todos, profile]`: pass a {@link Query.group}. * * @example * ```ts @@ -1312,6 +1315,9 @@ export interface UseRefetchResult { * @since 0.1.0 */ export const useRefetch = (target: Query.Target): UseRefetchResult => { + // Checked as it renders, as `useIsFetching` checks its target: inside + // the refetch's own fiber, the defect would be lost. + matcher(target); const registry = useRegistry(); const handle = useHandle(() => makeRefetchHandle(registry), [registry]); const isRefetching = useAtomValue(handle.refetching); diff --git a/test/effetch-service.test.ts b/test/effetch-service.test.ts index 4fe460f..8f809c8 100644 --- a/test/effetch-service.test.ts +++ b/test/effetch-service.test.ts @@ -11,7 +11,7 @@ import { Fetch } from "@monarcode/effetch"; import { FetchTest } from "@monarcode/effetch/test"; import { afterEach, describe, expect, it, vi } from "vitest"; -import { fromClient } from "../src/effetch/index.js"; +import { EndpointQueryError, fromClient } from "../src/effetch/index.js"; import { InfiniteQuery, Mutation, Query, QueryClient } from "../src/index.js"; import { disposeClients, gate, makeClient, record } from "./helpers.js"; import { @@ -395,9 +395,13 @@ describe("query schemas: the review's regressions", () => { expect(() => dated({ query: { due: new Date("x") } })).toThrow( expect.objectContaining({ _tag: "EndpointQueryError", + route: "GET /todos/dated", message: expect.stringContaining("GET /todos/dated"), }), ); + expect(() => dated({ query: { due: new Date("x") } })).toThrow( + EndpointQueryError, + ); }); it("leaves a renamed page field out of the key", () => { diff --git a/test/entity-sync.test.ts b/test/entity-sync.test.ts new file mode 100644 index 0000000..667ea63 --- /dev/null +++ b/test/entity-sync.test.ts @@ -0,0 +1,1229 @@ +import * as Cause from "effect/Cause"; +import * as Effect from "effect/Effect"; +import * as Layer from "effect/Layer"; +import * as Logger from "effect/Logger"; +import * as Option from "effect/Option"; +import * as Queue from "effect/Queue"; +import * as AsyncResult from "effect/reactivity/AsyncResult"; +import * as Schedule from "effect/Schedule"; +import * as Schema from "effect/Schema"; +import * as Stream from "effect/Stream"; + +import { Fetch } from "@monarcode/effetch"; +import { afterEach, describe, expect, it } from "vitest"; + +import { fromClient } from "../src/effetch/index.js"; +import { + Entity, + InfiniteQuery, + Mutation, + Query, + QueryClient, +} from "../src/index.js"; +import { setValue } from "../src/internal/cache.js"; +import { peek } from "../src/internal/queryAtom.js"; +import { disposeClients, gate, makeClient, use } from "./helpers.js"; +import { servicesLayer, TestApi } from "./services.js"; + +afterEach(disposeClients); + +const Transaction = Schema.Struct({ id: Schema.String, status: Schema.String }); +type Transaction = typeof Transaction.Type; +const Transactions = Entity.make(Transaction, { id: (t) => t.id }); + +/** The server's records, which every fetch reads. */ +const backend = () => { + const records = new Map([ + ["t1", { id: "t1", status: "Pending" }], + ["t2", { id: "t2", status: "Pending" }], + ]); + const fetches = { list: 0, detail: 0 }; + const set = (id: string, status: string) => { + records.set(id, { id, status }); + }; + const list = Query.family({ + key: ["transactions", "list"], + run: (limit: number) => + Effect.sync(() => { + fetches.list++; + return [...records.values()].slice(0, limit); + }), + schema: { success: Schema.Array(Transaction) }, + }); + const detail = Query.family({ + key: ["transactions"], + run: (id: string) => + Effect.sync(() => { + fetches.detail++; + return records.get(id)!; + }), + schema: { success: Transaction }, + }); + return { records, fetches, set, list, detail }; +}; + +const syncing = () => makeClient({ entities: { sync: [Transactions] } }); + +const cached = async ( + client: QueryClient.QueryClient, + query: Query.Query, +): Promise => Option.getOrThrow(await client.runPromise(Query.get(query))); + +const timestamp = ( + client: QueryClient.QueryClient, + query: Query.Query, +): number => { + const result = Option.getOrThrow(peek(client.registry, query)); + if (!AsyncResult.isSuccess(result)) { + throw new Error(`Not a success: ${result._tag}`); + } + return result.timestamp; +}; + +const statuses = (list: ReadonlyArray) => + list.map((t) => `${t.id} ${t.status}`); + +describe("entity sync", () => { + it("writes a details fetch into every list that holds the record, keeping their ages", async () => { + const client = await syncing(); + const server = backend(); + await client.fetch(server.list(10)); + await client.fetch(server.list(20)); + const unmount = use(client.registry, server.list(10)); + const listFetches = server.fetches.list; + const ages = [ + timestamp(client, server.list(10)), + timestamp(client, server.list(20)), + ]; + + server.set("t1", "Successful"); + expect(await client.fetch(server.detail("t1"))).toEqual({ + id: "t1", + status: "Successful", + }); + + for (const limit of [10, 20]) { + expect(statuses(await cached(client, server.list(limit)))).toEqual([ + "t1 Successful", + "t2 Pending", + ]); + } + expect([ + timestamp(client, server.list(10)), + timestamp(client, server.list(20)), + ]).toEqual(ages); + expect(server.fetches.list).toBe(listFetches); + unmount(); + }); + + it("writes a list fetch into the cached details", async () => { + const client = await syncing(); + const server = backend(); + await client.fetch(server.detail("t1")); + await client.fetch(server.detail("t2")); + const untouched = await cached(client, server.detail("t2")); + + server.set("t1", "Successful"); + await client.fetch(server.list(10)); + + expect(await cached(client, server.detail("t1"))).toEqual({ + id: "t1", + status: "Successful", + }); + // An equal copy isn't written. + expect(await cached(client, server.detail("t2"))).toBe(untouched); + expect(server.fetches.detail).toBe(2); + }); + + it("does nothing without entities.sync, and for entities not in it", async () => { + const server = backend(); + const plain = await makeClient(); + await plain.fetch(server.list(10)); + server.set("t1", "Successful"); + await plain.fetch(server.detail("t1")); + expect(statuses(await cached(plain, server.list(10)))).toEqual([ + "t1 Pending", + "t2 Pending", + ]); + + const Other = Entity.make(Schema.Struct({ id: Schema.String }), { + id: (record) => record.id, + }); + const other = await makeClient({ entities: { sync: [Other] } }); + server.set("t1", "Pending"); + await other.fetch(server.list(10)); + server.set("t1", "Successful"); + await other.fetch(server.detail("t1")); + expect(statuses(await cached(other, server.list(10)))).toEqual([ + "t1 Pending", + "t2 Pending", + ]); + }); + + it("doesn't let an older response that settles last overwrite a newer copy", async () => { + const client = await syncing(); + const server = backend(); + const slow = gate(); + const detail = Query.family({ + key: ["transactions", "slow"], + run: (id: string) => + Effect.flatMap( + Effect.sync(() => server.records.get(id)!), + (read) => Effect.as(slow.wait, read), + ), + schema: { success: Transaction }, + }); + await client.fetch(server.list(10)); + + // The details read "Pending", then the list reads "Successful" and + // settles first. + const pending = client.fetch(detail("t1")); + await Effect.runPromise(Effect.yieldNow); + server.set("t1", "Successful"); + await client.fetch(server.list(10)); + slow.open(); + + expect(await pending).toEqual({ id: "t1", status: "Successful" }); + expect(statuses(await cached(client, server.list(10)))).toEqual([ + "t1 Successful", + "t2 Pending", + ]); + }); + + it("never fetches again to sync, and a sync starts no other", async () => { + const client = await syncing(); + const server = backend(); + await client.fetch(server.list(10)); + await client.fetch(server.list(20)); + await client.fetch(server.detail("t1")); + const before = { ...server.fetches }; + + server.set("t1", "Successful"); + await client.fetch(server.detail("t1")); + await client.fetch(server.list(10)); + + expect(server.fetches).toEqual({ + list: before.list + 1, + detail: before.detail + 1, + }); + expect(statuses(await cached(client, server.list(20)))).toEqual([ + "t1 Successful", + "t2 Pending", + ]); + }); + + it("skips an invalidated query and a failed one, both ways", async () => { + const client = await syncing(); + const server = backend(); + let fail = false; + const flaky = Query.make({ + key: ["transactions", "flaky"], + run: Effect.suspend(() => + fail + ? Effect.fail("offline" as const) + : Effect.succeed([...server.records.values()]), + ), + schema: { success: Schema.Array(Transaction) }, + }); + await client.fetch(server.list(10)); + await client.fetch(flaky); + fail = true; + await client.runPromiseExit(Query.fetch(flaky)); + await client.invalidate(server.list(10)); + + server.set("t1", "Successful"); + await client.fetch(server.detail("t1")); + + expect(statuses(await cached(client, server.list(10)))).toEqual([ + "t1 Pending", + "t2 Pending", + ]); + expect(statuses(await cached(client, flaky))).toEqual([ + "t1 Pending", + "t2 Pending", + ]); + }); + + it("leaves out a query that opted out, both ways", async () => { + const client = await syncing(); + const server = backend(); + const summaries = Query.make({ + key: ["transactions", "summaries"], + run: Effect.sync(() => [...server.records.values()]), + schema: { success: Schema.Array(Transaction) }, + entities: { sync: false }, + }); + await client.fetch(summaries); + await client.fetch(server.detail("t1")); + + server.set("t1", "Successful"); + await client.fetch(server.detail("t1")); + expect(statuses(await cached(client, summaries))).toEqual([ + "t1 Pending", + "t2 Pending", + ]); + + server.set("t1", "Failed"); + await client.fetch(summaries); + expect(await cached(client, server.detail("t1"))).toEqual({ + id: "t1", + status: "Successful", + }); + }); + + it("doesn't sync a fetch already in flight over a newer Entity write, or spread the write", async () => { + const client = await syncing(); + const server = backend(); + const started = gate(); + const slow = gate(); + const detail = Query.make({ + key: ["transactions", "slow", "t1"], + run: Effect.flatMap( + Effect.sync(() => { + started.open(); + return server.records.get("t1")!; + }), + (read) => Effect.as(slow.wait, read), + ), + schema: { success: Transaction }, + }); + await client.fetch(server.list(10)); + + const pending = client.fetch(detail); + await Effect.runPromise(started.wait); + await client.runPromise( + Entity.set(Transactions, { id: "t1", status: "Cancelled" }), + ); + slow.open(); + + // The write is newer than the fetch, so the list keeps it. A sync + // spreads only fetched copies: the details show what they fetched. + expect(await pending).toEqual({ id: "t1", status: "Pending" }); + expect(statuses(await cached(client, server.list(10)))).toEqual([ + "t1 Cancelled", + "t2 Pending", + ]); + }); + + it("puts a sync back over a failed mutation's rolled-back optimistic write", async () => { + const client = await syncing(); + const server = backend(); + await client.fetch(server.list(10)); + await client.fetch(server.detail("t1")); + let during: ReadonlyArray = []; + const cancel = Mutation.make({ + run: () => + Effect.promise(async () => { + server.set("t1", "Successful"); + await client.fetch(server.detail("t1")); + during = statuses(await cached(client, server.list(10))); + }).pipe(Effect.andThen(Effect.fail("rejected" as const))), + optimistic: () => + Entity.update(Transactions, "t1", (t) => ({ + ...t, + status: "Cancelling", + })), + }); + + await client.runPromiseExit(Mutation.run(cancel)); + + expect(during).toEqual(["t1 Successful", "t2 Pending"]); + expect(statuses(await cached(client, server.list(10)))).toEqual([ + "t1 Successful", + "t2 Pending", + ]); + }); + + it("writes an infinite query's pages, and dates only a new page by its fetch", async () => { + const client = await syncing(); + const server = backend(); + let failNext = false; + const Page = Schema.Struct({ + items: Schema.Array(Transaction), + next: Schema.NullOr(Schema.Finite), + }); + const pages = InfiniteQuery.make({ + key: ["transactions", "pages"], + run: (cursor: number) => + cursor === 1 && failNext + ? Effect.fail("offline" as const) + : Effect.sync(() => ({ + items: [server.records.get(cursor === 0 ? "t1" : "t2")!], + next: cursor === 0 ? 1 : null, + })), + initialPageParam: 0, + nextPageParam: (last: typeof Page.Type) => last.next, + schema: { page: Page }, + staleTime: "1 hour", + }); + const items = async () => + statuses( + (await cached(client, pages)).pages.flatMap((page) => page.items), + ); + await client.runPromise(InfiniteQuery.fetchNextPage(pages)); + await client.fetch(server.detail("t2")); + + // A details fetch reaches a loaded page. + server.set("t1", "Successful"); + await client.fetch(server.detail("t1")); + expect(await items()).toEqual(["t1 Successful"]); + + // While the pages show a failure, a details fetch skips them, so + // their first page is older than the details. + failNext = true; + await client.runPromiseExit(InfiniteQuery.fetchNextPage(pages)); + server.set("t1", "Refunded"); + await client.fetch(server.detail("t1")); + + // Loading the next page doesn't date the first by its fetch: the + // details keep theirs and the page takes it. The new page goes to + // the details. + failNext = false; + server.set("t2", "Successful"); + await client.runPromise(InfiniteQuery.fetchNextPage(pages)); + expect(await items()).toEqual(["t1 Refunded", "t2 Successful"]); + expect(await cached(client, server.detail("t1"))).toEqual({ + id: "t1", + status: "Refunded", + }); + expect(await cached(client, server.detail("t2"))).toEqual({ + id: "t2", + status: "Successful", + }); + }); + + it("logs an id that throws, and the fetch keeps its value", async () => { + const errors: Array = []; + const logger = Logger.layer([ + Logger.make(({ logLevel, message }) => { + if (logLevel === "Error") { + errors.push(message); + } + }), + ]); + const Throwing = Entity.make(Transaction, { + id: (t) => { + if (t.status === "Broken") { + throw new Error("no id"); + } + return t.id; + }, + }); + const client = await makeClient({ + layer: Layer.merge(servicesLayer("hello"), logger), + entities: { sync: [Throwing] }, + }); + const server = backend(); + await client.fetch(server.list(10)); + + server.set("t1", "Broken"); + expect(await client.fetch(server.detail("t1"))).toEqual({ + id: "t1", + status: "Broken", + }); + expect(statuses(await cached(client, server.list(10)))).toEqual([ + "t1 Pending", + "t2 Pending", + ]); + expect(errors.flat()).toContain("Entity sync failed"); + }); + + it("syncs Effetch endpoint queries", async () => { + const records = new Map([ + ["t1", { id: "t1", status: "Pending" }], + ]); + const client = await makeClient({ + layer: servicesLayer("hello", (request) => + Response.json( + request.url.pathname === "/transactions" + ? [...records.values()] + : records.get("t1"), + ), + ), + entities: { sync: [Transactions] }, + }); + const api = fromClient(TestApi); + const list = api.query( + Fetch.endpoint("GET /transactions", { + output: Schema.Array(Transaction), + }), + ); + const detail = api.query( + Fetch.endpoint("GET /transactions/:id", { output: Transaction }), + ); + await client.fetch(list()); + + records.set("t1", { id: "t1", status: "Successful" }); + await client.fetch(detail({ params: { id: "t1" } })); + + expect(statuses(await cached(client, list()))).toEqual(["t1 Successful"]); + }); +}); + +/** Lets the registry's tasks and a stream's fibers run. */ +const settle = async () => { + for (let i = 0; i < 3; i++) { + await new Promise((resolve) => setImmediate(resolve)); + } +}; + +/** A details query whose fetch reads the record, then waits for `slow`. */ +const slowDetail = (server: ReturnType, id: string) => { + const started = gate(); + const slow = gate(); + const query = Query.make({ + key: ["transactions", "slow", id], + run: Effect.flatMap( + Effect.sync(() => { + started.open(); + return server.records.get(id)!; + }), + (read) => Effect.as(slow.wait, read), + ), + schema: { success: Transaction }, + }); + return { query, started: Effect.runPromise(started.wait), open: slow.open }; +}; + +describe("entity sync, from the review", () => { + it("dates only the copies a write changed", async () => { + const client = await syncing(); + const server = backend(); + await client.fetch(server.list(10)); + server.set("t2", "Successful"); + const detail = slowDetail(server, "t2"); + + const pending = client.fetch(detail.query); + await detail.started; + // A row added to the list doesn't make its other rows newer. + await client.runPromise( + Query.update(server.list(10), (rows) => [ + ...rows, + { id: "t3", status: "Pending" }, + ]), + ); + detail.open(); + + expect(await pending).toEqual({ id: "t2", status: "Successful" }); + expect(statuses(await cached(client, server.list(10)))).toEqual([ + "t1 Pending", + "t2 Successful", + "t3 Pending", + ]); + }); + + it("doesn't spread an optimistic write, and a rollback dates the copy back", async () => { + const client = await syncing(); + const server = backend(); + await client.fetch(server.list(10)); + server.set("t1", "Successful"); + const detail = slowDetail(server, "t1"); + const pending = client.fetch(detail.query); + await detail.started; + const cancel = Mutation.make({ + run: () => Effect.fail("rejected" as const), + optimistic: () => + Entity.update(Transactions, "t1", (t) => ({ + ...t, + status: "Cancelling", + })), + }); + + await client.runPromiseExit(Mutation.run(cancel)); + detail.open(); + + // The detail fetched "Successful" and never showed "Cancelling"; the + // list, rolled back, is older than that fetch again. + expect(await pending).toEqual({ id: "t1", status: "Successful" }); + expect(statuses(await cached(client, server.list(10)))).toEqual([ + "t1 Successful", + "t2 Pending", + ]); + }); + + it("keeps a newer copy synced into a query while it fetched", async () => { + const client = await syncing(); + const server = backend(); + const listStarted = gate(); + const listGate = gate(); + const list = Query.make({ + key: ["transactions", "slow list"], + run: Effect.flatMap( + Effect.sync(() => { + listStarted.open(); + return [...server.records.values()]; + }), + (read) => Effect.as(listGate.wait, read), + ), + schema: { success: Schema.Array(Transaction) }, + }); + await client.runPromise(Query.set(list, [...server.records.values()])); + + const pending = client.fetch(list); + await Effect.runPromise(listStarted.wait); + server.set("t1", "Successful"); + await client.fetch(server.detail("t1")); + // The source of the newer copy is gone before the list lands. + await client.runPromise(Query.clear(server.detail("t1"))); + listGate.open(); + + expect(statuses(await pending)).toEqual(["t1 Successful", "t2 Pending"]); + }); + + it("doesn't write a query the fetch read, so it doesn't fetch again", async () => { + const client = await syncing(); + const server = backend(); + let reads = 0; + const Detailed = Schema.Struct({ + transaction: Transaction, + seenAt: Schema.Finite, + }); + const detailed = Query.make({ + key: ["transactions", "detailed"], + run: (ctx: Query.RunContext) => + Effect.map(ctx.result(server.detail("t1")), (transaction) => { + reads++; + // Its own copy, which differs from the one it read. + return { + transaction: { ...transaction, status: "Seen" }, + seenAt: reads, + }; + }), + schema: { success: Detailed }, + }); + // The details are older than the fetch that reads them. + await client.fetch(server.detail("t1")); + const unmount = use(client.registry, detailed); + await settle(); + await settle(); + + expect(reads).toBe(1); + expect(await cached(client, server.detail("t1"))).toEqual({ + id: "t1", + status: "Pending", + }); + unmount(); + }); + + it("doesn't let an older fetch overwrite a live push", async () => { + const client = await syncing(); + const server = backend(); + let queue: + | Queue.Queue< + (rows: ReadonlyArray) => ReadonlyArray, + Cause.Done + > + | undefined; + const live = Query.make({ + key: ["transactions", "live"], + run: Effect.sync(() => [...server.records.values()]), + schema: { success: Schema.Array(Transaction) }, + live: Stream.callback< + (rows: ReadonlyArray) => ReadonlyArray + >((q) => + Effect.sync(() => { + queue = q; + }), + ), + staleTime: "1 hour", + }); + const unmount = client.registry.mount(live); + await settle(); + const detail = slowDetail(server, "t1"); + + const pending = client.fetch(detail.query); + await detail.started; + Queue.offerUnsafe(queue!, (rows) => + rows.map((t) => (t.id === "t1" ? { ...t, status: "Successful" } : t)), + ); + await settle(); + detail.open(); + await pending; + + expect(statuses(await cached(client, live))).toEqual([ + "t1 Successful", + "t2 Pending", + ]); + unmount(); + }); + + it("dates a retry by when it started", async () => { + const client = await syncing(); + const server = backend(); + const firstAttempt = gate(); + const failing = gate(); + let attempts = 0; + const detail = Query.make({ + key: ["transactions", "retried"], + run: Effect.suspend(() => { + attempts++; + if (attempts === 1) { + firstAttempt.open(); + return Effect.andThen( + failing.wait, + Effect.fail("timeout" as const), + ); + } + return Effect.sync(() => server.records.get("t1")!); + }), + schema: { success: Transaction }, + retry: Schedule.recurs(1), + }); + const pending = client.fetch(detail); + await Effect.runPromise(firstAttempt.wait); + await client.fetch(server.list(10)); + server.set("t1", "Successful"); + failing.open(); + + expect(await pending).toEqual({ id: "t1", status: "Successful" }); + expect(statuses(await cached(client, server.list(10)))).toEqual([ + "t1 Successful", + "t2 Pending", + ]); + }); + + it("doesn't put a sync back over a newer fetch when a mutation rolls back", async () => { + const client = await syncing(); + const server = backend(); + await client.fetch(server.list(10)); + const rename = Mutation.make({ + run: () => + Effect.promise(async () => { + server.set("t1", "Successful"); + await client.fetch(server.detail("t1")); + server.set("t1", "Refunded"); + await client.fetch(server.list(10)); + }).pipe(Effect.andThen(Effect.fail("rejected" as const))), + optimistic: () => + Entity.update(Transactions, "t2", (t) => ({ + ...t, + status: "Cancelling", + })), + }); + + await client.runPromiseExit(Mutation.run(rename)); + + expect(statuses(await cached(client, server.list(10)))).toEqual([ + "t1 Refunded", + "t2 Pending", + ]); + }); + + it("writes an outer entity with the inner copies it pulled", async () => { + const Customer = Schema.Struct({ + id: Schema.String, + name: Schema.String, + }); + const Order = Schema.Struct({ id: Schema.String, customer: Customer }); + const Customers = Entity.make(Customer, { id: (c) => c.id }); + const Orders = Entity.make(Order, { id: (o) => o.id }); + // Orders first: their writes are computed after every pull. + const client = await makeClient({ + entities: { sync: [Orders, Customers] }, + }); + let name = "Ada"; + const customer = () => ({ id: "c1", name }); + const recent = Query.make({ + key: ["orders", "recent"], + run: Effect.sync(() => [{ id: "o1", customer: customer() }]), + schema: { success: Schema.Array(Order) }, + }); + const profile = Query.make({ + key: ["customers", "c1"], + run: Effect.sync(customer), + schema: { success: Customer }, + }); + await client.fetch(recent); + const started = gate(); + const slow = gate(); + const orders = Query.make({ + key: ["orders"], + run: Effect.flatMap( + Effect.sync(() => { + started.open(); + return [{ id: "o1", customer: customer() }]; + }), + (read) => Effect.as(slow.wait, read), + ), + schema: { success: Schema.Array(Order) }, + }); + + // The orders read "Ada"; then the customer, fetched later, is "Grace". + const pending = client.fetch(orders); + await Effect.runPromise(started.wait); + name = "Grace"; + await client.fetch(profile); + slow.open(); + await pending; + + for (const query of [orders, recent]) { + expect((await cached(client, query))[0]!.customer.name).toBe("Grace"); + } + }); + + it("refetches a query that reads a written one, once", async () => { + const client = await syncing(); + const server = backend(); + let reads = 0; + const done = Query.make({ + key: ["transactions", "done"], + run: (ctx: Query.RunContext) => + Effect.map(ctx.result(server.list(10)), (rows) => { + reads++; + return rows.filter((t) => t.status === "Successful").length; + }), + }); + const unmount = use(client.registry, done); + await settle(); + expect(reads).toBe(1); + + server.set("t1", "Successful"); + await client.fetch(server.detail("t1")); + await settle(); + await settle(); + + expect(reads).toBe(2); + expect(await cached(client, done)).toBe(1); + unmount(); + }); + + it("leaves out Effetch queries and infinite queries that opted out", async () => { + const records = new Map([ + ["t1", { id: "t1", status: "Pending" }], + ]); + const client = await makeClient({ + layer: servicesLayer("hello", (request) => + Response.json( + request.url.pathname === "/transactions" + ? [...records.values()] + : request.url.pathname === "/pages" + ? { items: [...records.values()], next: null } + : records.get("t1"), + ), + ), + entities: { sync: [Transactions] }, + }); + const api = fromClient(TestApi); + const list = api.query( + Fetch.endpoint("GET /transactions", { + output: Schema.Array(Transaction), + }), + { entities: { sync: false } }, + ); + const pages = api.infiniteQuery( + Fetch.endpoint("GET /pages", { + output: Schema.Struct({ + items: Schema.Array(Transaction), + next: Schema.NullOr(Schema.String), + }), + }), + { + pageParam: "cursor", + initialPageParam: null as string | null, + nextPageParam: (page) => page.next, + entities: { sync: false }, + }, + ); + const detail = api.query( + Fetch.endpoint("GET /transactions/:id", { output: Transaction }), + ); + await client.fetch(list()); + await client.runPromise(InfiniteQuery.fetchNextPage(pages())); + + records.set("t1", { id: "t1", status: "Successful" }); + await client.fetch(detail({ params: { id: "t1" } })); + + expect(statuses(await cached(client, list()))).toEqual(["t1 Pending"]); + expect(statuses((await cached(client, pages())).pages[0]!.items)).toEqual( + ["t1 Pending"], + ); + }); + + it("logs a listener that throws, and the fetch keeps its value", async () => { + const errors: Array = []; + const logger = Logger.layer([ + Logger.make(({ logLevel, message }) => { + if (logLevel === "Error") { + errors.push(message); + } + }), + ]); + const client = await makeClient({ + layer: Layer.merge(servicesLayer("hello"), logger), + entities: { sync: [Transactions] }, + }); + const server = backend(); + await client.fetch(server.list(10)); + let calls = 0; + client.registry.subscribe(server.list(10), () => { + calls++; + throw new Error("listener"); + }); + + server.set("t1", "Successful"); + expect(await client.fetch(server.detail("t1"))).toEqual({ + id: "t1", + status: "Successful", + }); + expect(calls).toBeGreaterThan(0); + expect(errors.flat()).toContain("Entity sync failed"); + }); +}); + +describe("entity sync, paged and guarded", () => { + const Page = Schema.Struct({ + items: Schema.Array(Transaction), + next: Schema.NullOr(Schema.Finite), + }); + + /** Two pages, t1 then t2, that wait for `hold` when it's set. */ + const paged = ( + server: ReturnType, + hold: { page?: number; first?: boolean; until?: Effect.Effect }, + options: { retry?: Schedule.Schedule } = {}, + ) => + InfiniteQuery.make({ + key: ["transactions", "pages"], + run: (cursor: number) => + Effect.suspend(() => { + const read = Effect.sync(() => ({ + items: [server.records.get(cursor === 0 ? "t1" : "t2")!], + next: cursor === 0 ? 1 : null, + })); + if (hold.page !== cursor || hold.until === undefined) { + return read; + } + const until = hold.until; + if (hold.first === true) { + hold.first = false; + return Effect.andThen(until, Effect.fail("timeout" as const)); + } + return Effect.andThen(until, read); + }), + initialPageParam: 0, + nextPageParam: (last: typeof Page.Type) => last.next, + schema: { page: Page }, + ...options, + }); + + const items = async ( + client: QueryClient.QueryClient, + pages: ReturnType, + ) => + statuses( + (await cached(client, pages)).pages.flatMap((page) => page.items), + ); + + it("dates each page of a refetch by when its fetch started", async () => { + const client = await syncing(); + const server = backend(); + const hold: Parameters[1] = {}; + const pages = paged(server, hold); + await client.runPromise(InfiniteQuery.fetchNextPage(pages)); + await client.runPromise(InfiniteQuery.fetchNextPage(pages)); + + // The first page waits, so the second starts after the details fetch. + const firstPage = gate(); + const started = gate(); + Object.assign(hold, { + page: 0, + until: Effect.andThen(Effect.sync(started.open), firstPage.wait), + }); + const refetching = client.fetch(pages); + await Effect.runPromise(started.wait); + server.set("t2", "Successful"); + await client.fetch(server.detail("t2")); + server.set("t2", "Refunded"); + firstPage.open(); + await refetching; + + expect(await items(client, pages)).toEqual(["t1 Pending", "t2 Refunded"]); + expect(await cached(client, server.detail("t2"))).toEqual({ + id: "t2", + status: "Refunded", + }); + }); + + it("dates a page read before a retried page by when it was read", async () => { + const client = await syncing(); + const server = backend(); + const hold: Parameters[1] = {}; + const pages = paged(server, hold, { retry: Schedule.recurs(1) }); + await client.runPromise(InfiniteQuery.fetchNextPage(pages)); + await client.runPromise(InfiniteQuery.fetchNextPage(pages)); + + // The second page fails once, and its retry starts after the details + // fetch: the first page, read before both, is older than the details. + const failing = gate(); + const started = gate(); + Object.assign(hold, { + page: 1, + first: true, + until: Effect.andThen(Effect.sync(started.open), failing.wait), + }); + const refetching = client.fetch(pages); + await Effect.runPromise(started.wait); + server.set("t1", "Successful"); + await client.fetch(server.detail("t1")); + hold.until = Effect.void; + failing.open(); + await refetching; + + expect(await items(client, pages)).toEqual([ + "t1 Successful", + "t2 Pending", + ]); + expect(await cached(client, server.detail("t1"))).toEqual({ + id: "t1", + status: "Successful", + }); + }); + + it("sends only the new page when loading more, not the pages already shown", async () => { + const server = backend(); + const detail = Query.family({ + key: ["transactions"], + run: (id: string) => Effect.sync(() => server.records.get(id)!), + schema: { success: Transaction }, + staleTime: "1 hour", + }); + const rendered = await makeClient(); + server.set("t1", "Successful"); + await rendered.fetch(detail("t1")); + const sent = QueryClient.dehydrate(rendered); + server.set("t1", "Pending"); + + const client = await syncing(); + const pages = paged(server, {}); + await client.runPromise(InfiniteQuery.fetchNextPage(pages)); + // A server render sent the details after the first page loaded. + QueryClient.hydrate(client, sent); + const unmount = use(client.registry, detail("t1")); + await client.runPromise(InfiniteQuery.fetchNextPage(pages)); + + expect(await cached(client, detail("t1"))).toEqual({ + id: "t1", + status: "Successful", + }); + unmount(); + }); + + it("keeps a write whose id throws", async () => { + const Throwing = Entity.make(Transaction, { + id: (t) => { + if (t.status === "Broken") { + throw new Error("no id"); + } + return t.id; + }, + }); + const client = await makeClient({ entities: { sync: [Throwing] } }); + const server = backend(); + await client.fetch(server.list(10)); + + await client.runPromise( + Query.set(server.list(10), [{ id: "t1", status: "Broken" }]), + ); + + expect(statuses(await cached(client, server.list(10)))).toEqual([ + "t1 Broken", + ]); + const mutation = Mutation.make({ + run: () => Effect.fail("rejected" as const), + optimistic: () => + Query.update(server.list(10), (list) => [ + ...list, + { id: "t3", status: "Broken" }, + ]), + }); + await client.runPromiseExit(Mutation.run(mutation)); + expect(statuses(await cached(client, server.list(10)))).toEqual([ + "t1 Broken", + ]); + }); + + it("dates a live push made during the query's own fetch as a write", async () => { + const client = await syncing(); + const server = backend(); + let queue: + | Queue.Queue< + (rows: ReadonlyArray) => ReadonlyArray, + Cause.Done + > + | undefined; + const listStarted = gate(); + const slowList = gate(); + const live = Query.make({ + key: ["transactions", "live"], + run: Effect.flatMap( + Effect.sync(() => { + listStarted.open(); + return [...server.records.values()]; + }), + (read) => Effect.as(slowList.wait, read), + ), + schema: { success: Schema.Array(Transaction) }, + live: Stream.callback< + (rows: ReadonlyArray) => ReadonlyArray + >((q) => + Effect.sync(() => { + queue = q; + }), + ), + staleTime: "1 hour", + }); + const unmount = client.registry.mount(live); + await Effect.runPromise(listStarted.wait); + // The details fetch starts after the list's, and before the push. + const detail = slowDetail(server, "t1"); + const pending = client.fetch(detail.query); + await detail.started; + await settle(); + Queue.offerUnsafe(queue!, (rows) => + rows.map((t) => (t.id === "t1" ? { ...t, status: "Successful" } : t)), + ); + await settle(); + slowList.open(); + await settle(); + detail.open(); + await pending; + + expect(statuses(await cached(client, live))).toEqual([ + "t1 Successful", + "t2 Pending", + ]); + unmount(); + }); + + it("dates the copies a write changed when another's id throws", async () => { + let breaking = false; + const Flaky = Entity.make(Transaction, { + id: (t) => { + if (breaking && t.status === "Broken") { + throw new Error("no id"); + } + return t.id; + }, + }); + const client = await makeClient({ entities: { sync: [Flaky] } }); + const server = backend(); + await client.fetch(server.list(10)); + server.set("t1", "Successful"); + const detail = slowDetail(server, "t1"); + const pending = client.fetch(detail.query); + await detail.started; + + breaking = true; + await client.runPromise( + Query.update(server.list(10), (list) => [ + { id: "t1", status: "Cancelled" }, + ...list.slice(1), + { id: "t3", status: "Broken" }, + ]), + ); + breaking = false; + detail.open(); + await pending; + + // The write is newer than the detail's fetch, which was in flight. + expect(statuses(await cached(client, server.list(10)))).toEqual([ + "t1 Cancelled", + "t2 Pending", + "t3 Broken", + ]); + }); + + it("keeps the fetched value when a listener leaves a copy whose id throws", async () => { + const Throwing = Entity.make(Transaction, { + id: (t) => { + if (t.status === "Broken") { + throw new Error("no id"); + } + return t.id; + }, + }); + const client = await makeClient({ + layer: Layer.merge( + servicesLayer("hello"), + Logger.layer([Logger.make(() => {})]), + ), + entities: { sync: [Throwing] }, + }); + const server = backend(); + await client.fetch(server.list(10)); + await client.fetch(server.list(20)); + // Each list's first write breaks the other, before its own write. + for (const [limit, other] of [ + [10, 20], + [20, 10], + ] as const) { + client.registry.subscribe(server.list(limit), () => { + setValue(client.registry, server.list(other), [ + { id: "t1", status: "Broken" }, + ]); + }); + } + + server.set("t1", "Successful"); + expect(await client.fetch(server.detail("t1"))).toEqual({ + id: "t1", + status: "Successful", + }); + }); + + it("dates a refetch whose page holds a large array", async () => { + const client = await syncing(); + const server = backend(); + const pages = InfiniteQuery.make({ + key: ["transactions", "large"], + run: (cursor: number) => + Effect.sync(() => ({ + items: [server.records.get(cursor === 0 ? "t1" : "t2")!], + next: cursor === 0 ? 1 : null, + scores: Array.from({ length: 200_000 }, () => 0), + })), + initialPageParam: 0, + nextPageParam: (last: { readonly next: number | null }) => last.next, + schema: { page: Page }, + }); + await client.runPromise(InfiniteQuery.fetchNextPage(pages)); + await client.runPromise(InfiniteQuery.fetchNextPage(pages)); + await client.fetch(server.detail("t2")); + + server.set("t2", "Successful"); + await client.fetch(pages); + + expect(await cached(client, server.detail("t2"))).toEqual({ + id: "t2", + status: "Successful", + }); + }); + + it("writes every query when a listener of one throws", async () => { + const client = await makeClient({ + layer: Layer.merge( + servicesLayer("hello"), + Logger.layer([Logger.make(() => {})]), + ), + entities: { sync: [Transactions] }, + }); + const server = backend(); + await client.fetch(server.list(10)); + await client.fetch(server.list(20)); + for (const limit of [10, 20]) { + client.registry.subscribe(server.list(limit), () => { + throw new Error("listener"); + }); + } + + server.set("t1", "Successful"); + await client.fetch(server.detail("t1")); + + for (const limit of [10, 20]) { + expect(statuses(await cached(client, server.list(limit)))).toEqual([ + "t1 Successful", + "t2 Pending", + ]); + } + }); +}); diff --git a/test/exports.test.ts b/test/exports.test.ts index d77d158..8aab6fb 100644 --- a/test/exports.test.ts +++ b/test/exports.test.ts @@ -41,6 +41,7 @@ describe("public entry points", () => { "run", ]); expect(Object.keys(Core.Query).sort()).toEqual([ + "KeyHoldsTargetError", "TypeId", "clear", "family", @@ -101,7 +102,11 @@ describe("public entry points", () => { }); it("@monarcode/effetch-query/effetch exports exactly these values", () => { - expect(Object.keys(Effetch).sort()).toEqual(["endpoints", "fromClient"]); + expect(Object.keys(Effetch).sort()).toEqual([ + "EndpointQueryError", + "endpoints", + "fromClient", + ]); }); it("keeps endpoints as the deprecated name of fromClient", () => { diff --git a/test/query.test.ts b/test/query.test.ts index 456aa20..e8ade28 100644 --- a/test/query.test.ts +++ b/test/query.test.ts @@ -644,8 +644,10 @@ describe("Query.group", () => { Query.invalidate([wallet.query, transactions.family]), ); - expect(Exit.isFailure(exit) && Cause.squash(exit.cause)).toMatchObject({ - _tag: "KeyHoldsTargetError", + const defect = Exit.isFailure(exit) && Cause.squash(exit.cause); + expect(defect).toBeInstanceOf(Query.KeyHoldsTargetError); + expect(defect).toMatchObject({ + key: [wallet.query, transactions.family], }); expect(fetches()).toEqual([1, 1, 1, 1, 1]); }); diff --git a/test/react.test.tsx b/test/react.test.tsx index f5bbae6..094e633 100644 --- a/test/react.test.tsx +++ b/test/react.test.tsx @@ -872,6 +872,19 @@ describe("useRefetch", () => { expect(refetches.size).toBe(1); }); + it("throws a KeyHoldsTargetError as it renders for a key that holds queries", async () => { + const client = await makeClient(); + const wallet = tracked(["wallet"], (fetch) => Effect.succeed(fetch)); + const Home = () => { + useRefetch([wallet.query]); + return null; + }; + + expect(() => render(withClient(client, ))).toThrow( + Query.KeyHoldsTargetError, + ); + }); + it("resolves at once, and isn't refetching, once its client is disposed", async () => { const client = await makeClient(); let controls: ReturnType | undefined; diff --git a/test/types/effetch.test-d.ts b/test/types/effetch.test-d.ts index 2f0dff0..e8392e2 100644 --- a/test/types/effetch.test-d.ts +++ b/test/types/effetch.test-d.ts @@ -12,7 +12,12 @@ import { describe, expectTypeOf, it } from "vitest"; import { type EndpointQuery, + type EndpointQueryArgs, + type EndpointQueryCallError, type EndpointQueryOptions, + type EndpointQueryOptionsFor, + type EndpointQueryValue, + type EndpointStreamOptions, fromClient, } from "../../src/effetch/index.js"; import { type InfiniteQuery, Mutation, Query } from "../../src/index.js"; @@ -620,6 +625,91 @@ describe("status errors", () => { }); }); +describe("Endpoints.query's named types", () => { + const Progress = Schema.Struct({ percent: Schema.Finite }); + + it("resolve to a fetched endpoint's value, error and options", () => { + type E = EndpointQueryCallError< + typeof Todo, + typeof ApiError, + [], + undefined, + undefined + >; + expectTypeOf< + EndpointQueryValue + >().toEqualTypeOf(); + expectTypeOf().toEqualTypeOf< + Fetch.CallError + >(); + expectTypeOf< + EndpointQueryOptionsFor<"GET /todos/:id", undefined, E, [], Todo> + >().toEqualTypeOf< + EndpointQueryOptions> + >(); + }); + + it("resolve to a stream endpoint's element, error and options", () => { + type E = EndpointQueryCallError< + typeof Progress, + typeof ApiError, + [], + undefined, + "sse" + >; + expectTypeOf>().toEqualTypeOf< + Fetch.SseEvent + >(); + expectTypeOf().toEqualTypeOf< + Fetch.CallError + >(); + expectTypeOf< + EndpointQueryOptionsFor< + "GET /jobs", + "sse", + E, + [], + Fetch.SseEvent + > + >().toEqualTypeOf< + EndpointStreamOptions< + E, + [], + Fetch.SseEvent, + EndpointQueryArgs<"GET /jobs"> + > + >(); + }); + + it("type the args by the endpoint's query schema", () => { + const Page = Schema.Struct({ page: Schema.FiniteFromString }); + type E = EndpointQueryCallError< + typeof Todo, + typeof ApiError, + [], + undefined, + undefined + >; + expectTypeOf< + EndpointQueryOptionsFor< + "GET /todos", + undefined, + E, + [], + Todo, + typeof Page + > + >().toEqualTypeOf< + EndpointQueryOptions< + E, + [], + Todo, + EndpointQueryArgs<"GET /todos", Fetch.QueryInput, typeof Page> + > + >(); + }); +}); + describe("Endpoints.query with a stream endpoint", () => { const Progress = Schema.Struct({ percent: Schema.Finite }); type Progress = typeof Progress.Type; diff --git a/test/types/entity.test-d.ts b/test/types/entity.test-d.ts index 122c50d..cc66ca1 100644 --- a/test/types/entity.test-d.ts +++ b/test/types/entity.test-d.ts @@ -1,13 +1,14 @@ -import type * as Effect from "effect/Effect"; +import * as Effect from "effect/Effect"; import type * as Option from "effect/Option"; import * as Schema from "effect/Schema"; +import * as Stream from "effect/Stream"; import { Fetch } from "@monarcode/effetch"; import { describe, expectTypeOf, it } from "vitest"; import { fromClient } from "../../src/effetch/index.js"; -import { Entity, type QueryClient } from "../../src/index.js"; -import { TestApi } from "../services.js"; +import { Entity, InfiniteQuery, Query, QueryClient } from "../../src/index.js"; +import { servicesLayer, TestApi } from "../services.js"; const Todo = Schema.Struct({ id: Schema.Finite, title: Schema.String }); type Todo = typeof Todo.Type; @@ -84,3 +85,53 @@ describe("writes and reads", () => { }); }); }); + +describe("entity sync", () => { + const Todos = Entity.make(Todo, { id: (todo) => todo.id }); + const Ids = Entity.make(TodoClass, { id: (todo) => todo.id }); + + it("takes the client's entities, of any types", () => { + QueryClient.make({ + layer: servicesLayer("hello"), + entities: { sync: [Todos, Ids] }, + }); + expectTypeOf().toEqualTypeOf< + ReadonlyArray> | undefined + >(); + QueryClient.make({ + layer: servicesLayer("hello"), + // @ts-expect-error: an entity, not its schema + entities: { sync: [Todo] }, + }); + }); + + it("is opted out of on queries that fetch, not on stream queries", () => { + const run = Effect.succeed({ id: 1, title: "x" }); + Query.make({ key: ["a"], run, entities: { sync: false } }); + Query.family({ + key: ["b"], + run: (id: number) => Effect.succeed({ id, title: "x" }), + entities: { sync: false }, + }); + InfiniteQuery.make({ + key: ["c"], + run: (page: number) => Effect.succeed({ id: page, title: "x" }), + initialPageParam: 0, + nextPageParam: () => null, + entities: { sync: false }, + }); + fromClient(TestApi).query( + Fetch.endpoint("GET /todos/:id", { output: Todo }), + { entities: { sync: false } }, + ); + expectTypeOf["entities"]>().toEqualTypeOf< + Query.EntitiesOptions | undefined + >(); + Query.stream({ + key: ["d"], + run: Stream.make(1), + // @ts-expect-error: a stream query's elements aren't synced + entities: { sync: false }, + }); + }); +});