@shivaedev/react 0.32.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/README.md +129 -69
- package/dist/AtomServices.d.ts +5 -0
- package/dist/AtomServices.d.ts.map +1 -0
- package/dist/AtomServices.js +2 -0
- package/dist/AtomServices.js.map +1 -0
- package/dist/adapters/Forbidden.d.ts.map +1 -0
- package/dist/adapters/Forbidden.js.map +1 -0
- package/dist/adapters/loadQuery.js +1 -1
- package/dist/adapters/loadQuery.js.map +1 -1
- package/dist/adapters/permissionBoundary.d.ts.map +1 -0
- package/dist/adapters/permissionBoundary.js.map +1 -0
- package/dist/{permissionGuard.d.ts → adapters/permissionGuard.d.ts} +2 -2
- package/dist/adapters/permissionGuard.d.ts.map +1 -0
- package/dist/{permissionGuard.js → adapters/permissionGuard.js} +2 -2
- package/dist/adapters/permissionGuard.js.map +1 -0
- package/dist/{internal → adapters}/queryHandoff.d.ts.map +1 -1
- package/dist/{internal → adapters}/queryHandoff.js.map +1 -1
- package/dist/{queryRoute.d.ts → adapters/queryRoute.d.ts} +13 -7
- package/dist/adapters/queryRoute.d.ts.map +1 -0
- package/dist/adapters/queryRoute.js +21 -0
- package/dist/adapters/queryRoute.js.map +1 -0
- package/dist/adapters/queryRouteFailure.d.ts +10 -0
- package/dist/adapters/queryRouteFailure.d.ts.map +1 -0
- package/dist/adapters/queryRouteFailure.js +13 -0
- package/dist/adapters/queryRouteFailure.js.map +1 -0
- package/dist/adapters/screenPending.d.ts.map +1 -0
- package/dist/adapters/screenPending.js.map +1 -0
- package/dist/{internal → adapters}/useLoaderHandoff.d.ts.map +1 -1
- package/dist/{internal → adapters}/useLoaderHandoff.js.map +1 -1
- package/dist/adapters/useQueryRetry.d.ts +3 -0
- package/dist/adapters/useQueryRetry.d.ts.map +1 -0
- package/dist/adapters/useQueryRetry.js +10 -0
- package/dist/adapters/useQueryRetry.js.map +1 -0
- package/dist/client/actionCompletion.d.ts +1 -1
- package/dist/client/actionCompletion.d.ts.map +1 -1
- package/dist/client/adapters/SessionGeneration.d.ts +1 -1
- package/dist/client/adapters/SessionGeneration.d.ts.map +1 -1
- package/dist/client/adapters/SessionGeneration.js +2 -1
- package/dist/client/adapters/SessionGeneration.js.map +1 -1
- package/dist/client/adapters/useLiveWindow.d.ts +4 -0
- package/dist/client/adapters/useLiveWindow.d.ts.map +1 -0
- package/dist/client/adapters/useLiveWindow.js +16 -0
- package/dist/client/adapters/useLiveWindow.js.map +1 -0
- package/dist/client/adapters/useSignOut.d.ts.map +1 -0
- package/dist/client/{useSignOut.js → adapters/useSignOut.js} +1 -1
- package/dist/client/adapters/useSignOut.js.map +1 -0
- package/dist/client/create.d.ts +4 -3
- package/dist/client/create.d.ts.map +1 -1
- package/dist/client/create.js +8 -5
- package/dist/client/create.js.map +1 -1
- package/dist/client/editor.d.ts +4 -3
- package/dist/client/editor.d.ts.map +1 -1
- package/dist/client/editor.js +4 -4
- package/dist/client/editor.js.map +1 -1
- package/dist/client/mountLive.d.ts +3 -3
- package/dist/client/mountLive.d.ts.map +1 -1
- package/dist/client/mountLive.js +7 -4
- package/dist/client/mountLive.js.map +1 -1
- package/dist/client/resultState.d.ts +1 -1
- package/dist/client/resultState.d.ts.map +1 -1
- package/dist/client/resultState.js +3 -10
- package/dist/client/resultState.js.map +1 -1
- package/dist/client/saveState.d.ts +1 -1
- package/dist/client/saveState.d.ts.map +1 -1
- package/dist/client/saveState.js +1 -1
- package/dist/client/saveState.js.map +1 -1
- package/dist/client/sessionBoundary.js +1 -1
- package/dist/client/sessionBoundary.js.map +1 -1
- package/dist/client/useLoaderQuery.js +1 -1
- package/dist/client/useLoaderQuery.js.map +1 -1
- package/dist/internal/registerLiveWindow.d.ts +5 -0
- package/dist/internal/registerLiveWindow.d.ts.map +1 -0
- package/dist/internal/registerLiveWindow.js +31 -0
- package/dist/internal/registerLiveWindow.js.map +1 -0
- package/dist/internal/useSubmissionCallbacks.d.ts +3 -2
- package/dist/internal/useSubmissionCallbacks.d.ts.map +1 -1
- package/dist/internal/useSubmissionCallbacks.js +1 -1
- package/dist/internal/useSubmissionCallbacks.js.map +1 -1
- package/dist/notices.d.ts +1 -1
- package/dist/notices.d.ts.map +1 -1
- package/dist/submission.d.ts +3 -1
- package/dist/submission.d.ts.map +1 -1
- package/dist/submission.js +2 -1
- package/dist/submission.js.map +1 -1
- package/package.json +14 -14
- package/src/AtomServices.ts +5 -0
- package/src/adapters/loadQuery.ts +1 -1
- package/src/{permissionGuard.ts → adapters/permissionGuard.ts} +2 -2
- package/src/adapters/queryRoute.ts +46 -0
- package/src/adapters/queryRouteFailure.ts +21 -0
- package/src/adapters/useQueryRetry.ts +10 -0
- package/src/client/actionCompletion.ts +1 -1
- package/src/client/adapters/SessionGeneration.ts +4 -2
- package/src/client/adapters/useLiveWindow.ts +17 -0
- package/src/client/{useSignOut.ts → adapters/useSignOut.ts} +1 -1
- package/src/client/create.ts +15 -7
- package/src/client/editor.ts +8 -6
- package/src/client/mountLive.ts +8 -6
- package/src/client/resultState.ts +4 -11
- package/src/client/saveState.ts +2 -2
- package/src/client/sessionBoundary.ts +1 -1
- package/src/client/useLoaderQuery.ts +1 -1
- package/src/internal/registerLiveWindow.ts +41 -0
- package/src/internal/useSubmissionCallbacks.ts +2 -1
- package/src/notices.ts +1 -1
- package/src/submission.ts +4 -1
- package/dist/client/Forbidden.d.ts.map +0 -1
- package/dist/client/Forbidden.js.map +0 -1
- package/dist/client/permissionBoundary.d.ts.map +0 -1
- package/dist/client/permissionBoundary.js.map +0 -1
- package/dist/client/screenPending.d.ts.map +0 -1
- package/dist/client/screenPending.js.map +0 -1
- package/dist/client/useSignOut.d.ts.map +0 -1
- package/dist/client/useSignOut.js.map +0 -1
- package/dist/fieldRejection.d.ts +0 -25
- package/dist/fieldRejection.d.ts.map +0 -1
- package/dist/fieldRejection.js +0 -21
- package/dist/fieldRejection.js.map +0 -1
- package/dist/permissionGuard.d.ts.map +0 -1
- package/dist/permissionGuard.js.map +0 -1
- package/dist/queryRoute.d.ts.map +0 -1
- package/dist/queryRoute.js +0 -21
- package/dist/queryRoute.js.map +0 -1
- package/src/fieldRejection.ts +0 -51
- package/src/queryRoute.ts +0 -35
- /package/dist/{client → adapters}/Forbidden.d.ts +0 -0
- /package/dist/{client → adapters}/Forbidden.js +0 -0
- /package/dist/{client → adapters}/permissionBoundary.d.ts +0 -0
- /package/dist/{client → adapters}/permissionBoundary.js +0 -0
- /package/dist/{internal → adapters}/queryHandoff.d.ts +0 -0
- /package/dist/{internal → adapters}/queryHandoff.js +0 -0
- /package/dist/{client → adapters}/screenPending.d.ts +0 -0
- /package/dist/{client → adapters}/screenPending.js +0 -0
- /package/dist/{internal → adapters}/useLoaderHandoff.d.ts +0 -0
- /package/dist/{internal → adapters}/useLoaderHandoff.js +0 -0
- /package/dist/client/{useSignOut.d.ts → adapters/useSignOut.d.ts} +0 -0
- /package/src/{client → adapters}/Forbidden.ts +0 -0
- /package/src/{client → adapters}/permissionBoundary.ts +0 -0
- /package/src/{internal → adapters}/queryHandoff.ts +0 -0
- /package/src/{client → adapters}/screenPending.ts +0 -0
- /package/src/{internal → adapters}/useLoaderHandoff.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.34.0 - 2026-11-02
|
|
4
|
+
|
|
5
|
+
### Breaking
|
|
6
|
+
|
|
7
|
+
- Import `AtomServices` from `@shivaedev/react/AtomServices.ts` instead of the removed `@shivaedev/react/fieldRejection.ts` module.
|
|
8
|
+
- Import `queryRoute` from `@shivaedev/react/adapters/queryRoute.ts` instead of `@shivaedev/react/queryRoute.ts`.
|
|
9
|
+
- Import `permissionGuard`, `PermissionGuardOptions` and `PermissionGuardContext` from `@shivaedev/react/adapters/permissionGuard.ts` instead of `@shivaedev/react/permissionGuard.ts`.
|
|
10
|
+
- Import `PermissionBoundary`, `PermissionBoundaryError`, `PermissionBoundaryProps` and `useCan` from `@shivaedev/react/adapters/permissionBoundary.ts` instead of `@shivaedev/react/client/permissionBoundary.ts`.
|
|
11
|
+
- Import `screenPending` and `ScreenPendingOptions` from `@shivaedev/react/adapters/screenPending.ts` instead of `@shivaedev/react/client/screenPending.ts`.
|
|
12
|
+
- Import `useSignOut` from `@shivaedev/react/client/adapters/useSignOut.ts` instead of `@shivaedev/react/client/useSignOut.ts`.
|
|
13
|
+
- Direct imports of `useLoaderHandoff` move from `@shivaedev/react/internal/useLoaderHandoff.ts` to `@shivaedev/react/adapters/useLoaderHandoff.ts`. Direct imports of `keepLoaderQuery`, `acceptLoaderQuery` and `pendingLoaderQuery` move from `@shivaedev/react/internal/queryHandoff.ts` to `@shivaedev/react/adapters/queryHandoff.ts`.
|
|
14
|
+
- Import `Forbidden` and `ForbiddenProps` from `@shivaedev/react/adapters/Forbidden.ts` instead of `@shivaedev/react/client/Forbidden.ts`.
|
|
15
|
+
|
|
16
|
+
## 0.33.0 - 2026-11-02
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- Form and React submission configurations accept a `savedValues` mapping to normalize a successful submission against its captured baseline while retaining later field edits.
|
|
21
|
+
- Return a `useRetry` hook from `queryRoute` so a route's error component can refresh its query and render a successful result without rebuilding the query or replacing the surrounding shell.
|
|
22
|
+
- Accept optional `redirects.signedOut` and `redirects.refused` callbacks for native typed TanStack redirects. Signed-out redirects can preserve the full return location with `signInSearch`; refused reads handle both `Forbidden` and `QueryReadDenied`.
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
|
|
26
|
+
- Editors preserve newer received baselines when an earlier save completes, and merge normalized saved fields without erasing later edits.
|
|
27
|
+
- Create forms retain optional keys removed while a submission is in flight when resetting their inputs.
|
|
28
|
+
- Keep live coalescing overrides owned by each query reader, so removing a reader restores the remaining reader's override. Clearing a session's live coalescing override restores the binding's original window.
|
|
29
|
+
|
|
30
|
+
### Breaking
|
|
31
|
+
|
|
32
|
+
- Direct callers of `@shivaedev/react/client/mountLive.ts` now run `mountLive(client, window)` as an Effect requiring `AtomRegistry.AtomRegistry`, instead of passing the registry as its first argument. Provide the registry with `Effect.provideService(AtomRegistry.AtomRegistry, registry)` and call the returned cleanup when the reader unmounts.
|
|
33
|
+
- Direct calls to the loader returned by `queryRoute` now require `location` alongside `abortController`, context, deps and params. Pass the native TanStack loader context, or add the requested location to a custom loader invocation.
|
|
34
|
+
|
|
3
35
|
## 0.32.0 - 2026-11-01
|
|
4
36
|
|
|
5
37
|
### Added
|
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ An **editor** joins a query atom, a form field schema and a save Effect. The que
|
|
|
30
30
|
|
|
31
31
|
A **session generation** is the string returned by `identify(session)`. `SessionBoundary` owns its client, registry and React subtree. Your auth owner supplies the session and decides when to replace or end it. The boundary automatically mounts live connections on bound contract APIs returned by `connect`, directly or as client properties such as `api`. Use a Platform database host and the default shared WebSocket client; the application needs no subscribe handler or `live()` call. Live changed hints coalesce over 20 ms by default. Set `liveCoalesceWindow` on `SessionBoundary` to a native Duration to choose the window for that session, or `0` for immediate per-hint refreshes. A bound query can override that default with `useQuery(atom, { coalesceWindow: "2 seconds" })`. Changing this option applies to subsequent windows without reconnecting or refetching any query; a window already started keeps its deadline. A refetch in flight runs once more after settling when further hints arrive. Cache policy, RPC declarations and transport stay with native Effect and the application; this package supplies their React state and lifecycle boundary.
|
|
32
32
|
|
|
33
|
-
`useEditor` and `useCreate` opt into persisted input with `persistedDraft: { key,
|
|
33
|
+
`useEditor` and `useCreate` opt into persisted input with `persistedDraft: { key, ...persistence }`. Choose a stable key for the record or create request, independent of its server revision. Acquire `persistence` with `draftPersistence` from `@shivaedev/form/adapters/draftPersistence.ts`, provided with `browserDraftStorage` from `@shivaedev/form/adapters/browserDraftStorage.ts`. The setup reads the storage provider and Clock from the Effect environment; timestamps and expiry use that captured clock. The hooks inherit ownership from `SessionBoundary`: reload and query refresh preserve edits, successful submission clears accepted input, and a committed session replacement drops tracked drafts. A suspended replacement that is canceled keeps the visible session's draft and future writes. Later edits made during a save remain persisted. Supply `DraftStorageProvider` for custom storage; optional `maxBytes` and `maxAgeMs` customize the bounds, which default to 256 KiB of UTF-8 JSON and seven days. See [form's persisted input API](https://github.com/ShivaeDev/platform/tree/main/packages/form#persist-input-across-reloads) for direct form hooks and limits.
|
|
34
34
|
|
|
35
35
|
### 1. Once per application
|
|
36
36
|
|
|
@@ -255,7 +255,7 @@ The next module assumes `./invoice-lines-client.ts` exports a contract-bound `ap
|
|
|
255
255
|
import { useCreate } from "@shivaedev/react/client/create.ts";
|
|
256
256
|
import { useEditor } from "@shivaedev/react/client/editor.ts";
|
|
257
257
|
import { QueryView } from "@shivaedev/react/client/QueryView.ts";
|
|
258
|
-
import { useField } from "@shivaedev/form/
|
|
258
|
+
import { useField } from "@shivaedev/form/adapters/react.ts";
|
|
259
259
|
import type { Form } from "@shivaedev/form/shape.ts";
|
|
260
260
|
import { Option, Schema } from "effect";
|
|
261
261
|
import { api, InvoiceLinesClient } from "./invoice-lines-client.ts";
|
|
@@ -571,7 +571,7 @@ With native `RpcClient.layerProtocolHttp` and `FetchHttpClient.layer` as the bro
|
|
|
571
571
|
|
|
572
572
|
#### Route loaders with TanStack Router
|
|
573
573
|
|
|
574
|
-
TanStack Router owns routes, navigation, search validation, loader data and screen components. Spread `queryRoute(buildQuery)` from `@shivaedev/react/queryRoute.ts` into `createRoute` to derive loader dependencies from validated search and load a contract query atom in the router context’s registry. A `NotFound` instance from `@shivaedev/errors/taxonomy.ts` or a `QueryReadDenied` refusal enters TanStack's not-found handling with the original rejection in the not-found component's `data` prop, preserving its message. One root `notFoundComponent` can show that message for all query routes; a route's own `notFoundComponent` takes precedence. Other typed failures reach `errorComponent` unchanged. The atom runs through its native RPC runtime and shares its execution with React. The factory receives `{ context, params, search }`: `context` is the loader’s router context, including parent `beforeLoad` contributions. Annotate it with `typeof root.types.allContext` (or the parent route’s `types.allContext`) to keep client and viewer access checked against the route’s declaration.
|
|
574
|
+
TanStack Router owns routes, navigation, search validation, loader data and screen components. Spread `queryRoute(buildQuery)` from `@shivaedev/react/adapters/queryRoute.ts` into `createRoute` to derive loader dependencies from validated search and load a contract query atom in the router context’s registry. A `NotFound` instance from `@shivaedev/errors/taxonomy.ts` or a `QueryReadDenied` refusal enters TanStack's not-found handling with the original rejection in the not-found component's `data` prop, preserving its message. One root `notFoundComponent` can show that message for all query routes; a route's own `notFoundComponent` takes precedence. Other typed failures reach `errorComponent` unchanged. The atom runs through its native RPC runtime and shares its execution with React. The factory receives `{ context, params, search }`: `context` is the loader’s router context, including parent `beforeLoad` contributions. Annotate it with `typeof root.types.allContext` (or the parent route’s `types.allContext`) to keep client and viewer access checked against the route’s declaration.
|
|
575
575
|
|
|
576
576
|
This example assumes an application-owned `api.get.query({ id, page })` returning `{ id, title }`, with declared `NotFound` and `NoteMissing` rejections:
|
|
577
577
|
|
|
@@ -583,7 +583,7 @@ import { Effect, Option, Predicate, Schema } from "effect";
|
|
|
583
583
|
import type { ReactNode } from "react";
|
|
584
584
|
import * as AtomRegistry from "effect/reactivity/AtomRegistry";
|
|
585
585
|
import { NotFound } from "@shivaedev/errors/taxonomy.ts";
|
|
586
|
-
import { queryRoute } from "@shivaedev/react/queryRoute.ts";
|
|
586
|
+
import { queryRoute } from "@shivaedev/react/adapters/queryRoute.ts";
|
|
587
587
|
import { useLoaderQuery } from "@shivaedev/react/client/useLoaderQuery.ts";
|
|
588
588
|
import { api } from "./notes-client.ts";
|
|
589
589
|
|
|
@@ -597,13 +597,15 @@ const Search = Schema.Struct({
|
|
|
597
597
|
Schema.withDecodingDefaultKey(Effect.succeed(1)),
|
|
598
598
|
),
|
|
599
599
|
});
|
|
600
|
+
const noteQuery = queryRoute(
|
|
601
|
+
({ context, params, search }: { context: typeof root.types.allContext; params: { id: string }; search: typeof Search.Type }) =>
|
|
602
|
+
context.api.get.query({ id: params.id, page: search.page }),
|
|
603
|
+
);
|
|
600
604
|
const note = createRoute({
|
|
601
605
|
getParentRoute: () => root,
|
|
602
606
|
path: "/notes/$id",
|
|
603
607
|
validateSearch: Schema.toStandardSchemaV1(Search),
|
|
604
|
-
...
|
|
605
|
-
context.api.get.query({ id: params.id, page: search.page }),
|
|
606
|
-
),
|
|
608
|
+
...noteQuery,
|
|
607
609
|
component: Note,
|
|
608
610
|
errorComponent: Failure,
|
|
609
611
|
});
|
|
@@ -634,7 +636,15 @@ function Note() {
|
|
|
634
636
|
return <h1>{query.data.title}</h1>;
|
|
635
637
|
}
|
|
636
638
|
function Failure({ error }: ErrorComponentProps) {
|
|
637
|
-
|
|
639
|
+
const retry = noteQuery.useRetry();
|
|
640
|
+
return (
|
|
641
|
+
<>
|
|
642
|
+
<p role="alert">{Predicate.isTagged(error, "NoteMissing") ? "Note missing" : "Could not load"}</p>
|
|
643
|
+
<button type="button" onClick={() => void retry()}>
|
|
644
|
+
Retry
|
|
645
|
+
</button>
|
|
646
|
+
</>
|
|
647
|
+
);
|
|
638
648
|
}
|
|
639
649
|
function SharedNotFound({ data }: NotFoundRouteProps) {
|
|
640
650
|
return <h1>{Schema.is(NotFound)(data) ? data.message : "Page not found"}</h1>;
|
|
@@ -652,6 +662,25 @@ export function App() {
|
|
|
652
662
|
|
|
653
663
|
`validateSearch` stays native: `Schema.toStandardSchemaV1(Search)` supplies TanStack’s search input and output types. The schema defaults a missing or invalid page to `1`. The query callback names its params and schema output type because TypeScript cannot infer them backward through an object spread. Changing search changes the loader dependencies and queries the new payload. Keep `params`, `validateSearch`, `component` and `errorComponent` on the route, with an optional `notFoundComponent` to override the shared screen; options after the spread can override its `loaderDeps` or `loader`.
|
|
654
664
|
|
|
665
|
+
Keep the result of `queryRoute` to call its `useRetry()` hook inside that route's error component. The returned callback refreshes the query using the current match's params, decoded search dependencies and context, then invalidates that match. A successful retry renders the route again without replacing the surrounding shell or its draft inputs.
|
|
666
|
+
|
|
667
|
+
For redirects, supply `redirects.signedOut` and `redirects.refused` in the optional second argument. The signed-out callback handles the shared `Unauthorized` rejection; the refusal callback handles `Forbidden` and `QueryReadDenied`. Use TanStack's typed `redirect` with a registered router (or an explicit router type), and `signInSearch` to carry the requested path, search and fragment into sign-in's `returnTo`. Destinations and UI remain application choices:
|
|
668
|
+
|
|
669
|
+
```ts
|
|
670
|
+
import { redirect } from "@tanstack/react-router";
|
|
671
|
+
import { queryRoute } from "@shivaedev/react/adapters/queryRoute.ts";
|
|
672
|
+
import { signInSearch } from "@shivaedev/react/signInSearch.ts";
|
|
673
|
+
|
|
674
|
+
const noteQuery = queryRoute(buildQuery, {
|
|
675
|
+
redirects: {
|
|
676
|
+
signedOut: (location) => redirect({ to: "/sign-in", search: signInSearch(location) }),
|
|
677
|
+
refused: () => redirect({ to: "/no-access" }),
|
|
678
|
+
},
|
|
679
|
+
});
|
|
680
|
+
```
|
|
681
|
+
|
|
682
|
+
Without the corresponding callback, failures retain their normal error or not-found handling. `NotFound` continues to use the not-found screen even when refusal redirects are configured.
|
|
683
|
+
|
|
655
684
|
For a loader that coordinates more work, use `loadQuery(registry, atom, loaderContext)` from `@shivaedev/react/adapters/loadQuery.ts` directly. It reads the atom in the supplied registry and throws typed failures unchanged, including `NotFound`; the loader decides how to handle them.
|
|
656
685
|
|
|
657
686
|
`defaultPendingMs: Infinity` keeps the current route's data visible during navigation; the shell reads TanStack's `isLoading` to display pending state. The new route commits when its loader settles. This is TanStack's pending policy, separate from `useQuery`'s retained display. The loader and the component share one query execution even when the route delays mounting for 650 ms, beyond the registry’s idle window: the first render has the loaded value and the RPC handler runs once.
|
|
@@ -676,12 +705,12 @@ import { createRootRouteWithContext, createRoute, createRouter, Link, RouterProv
|
|
|
676
705
|
import type { ReactNode } from "react";
|
|
677
706
|
import type * as AtomRegistry from "effect/reactivity/AtomRegistry";
|
|
678
707
|
import { permission } from "@shivaedev/access/permission.ts";
|
|
679
|
-
import { Forbidden } from "@shivaedev/react/
|
|
680
|
-
import { PermissionBoundary, PermissionBoundaryError, useCan } from "@shivaedev/react/
|
|
708
|
+
import { Forbidden } from "@shivaedev/react/adapters/Forbidden.ts";
|
|
709
|
+
import { PermissionBoundary, PermissionBoundaryError, useCan } from "@shivaedev/react/adapters/permissionBoundary.ts";
|
|
681
710
|
import { useLoaderQuery } from "@shivaedev/react/client/useLoaderQuery.ts";
|
|
682
|
-
import { permissionGuard } from "@shivaedev/react/permissionGuard.ts";
|
|
711
|
+
import { permissionGuard } from "@shivaedev/react/adapters/permissionGuard.ts";
|
|
683
712
|
import { can, type PermissionSession } from "@shivaedev/react/permissions.ts";
|
|
684
|
-
import { queryRoute } from "@shivaedev/react/queryRoute.ts";
|
|
713
|
+
import { queryRoute } from "@shivaedev/react/adapters/queryRoute.ts";
|
|
685
714
|
import { api, registry } from "./notes-client.ts";
|
|
686
715
|
import { auth, SignIn } from "./auth.tsx";
|
|
687
716
|
|
|
@@ -765,7 +794,7 @@ const showNotes = can(auth.session, ReadNotes);
|
|
|
765
794
|
|
|
766
795
|
`InnerWrap` puts `PermissionBoundary` inside the router. Its fallback can render `Link` and read route context. Set `defaultErrorComponent: PermissionBoundaryError` so route and loader failures reach the boundary's fallback while TanStack keeps its navigation controller mounted. This lets a refused viewer follow the fallback link without reloading the page. Keep `disableGlobalCatchBoundary: true`; other errors propagate to an enclosing application boundary. A route-specific `errorComponent` owns any failures it consumes.
|
|
767
796
|
|
|
768
|
-
`Forbidden` from `@shivaedev/react/
|
|
797
|
+
`Forbidden` from `@shivaedev/react/adapters/Forbidden.ts` supplies the no-access heading, explanation and a router link. Set `to` to a route the viewer may open. Optional `title`, `children`, `backLabel` and `className` let the application choose wording and layout. The default heading is “Permission denied” and the link says “Go back”.
|
|
769
798
|
|
|
770
799
|
`PermissionBoundary` also catches component query failures containing the shared `Forbidden` class. Without a boundary, query failures keep their normal typed state. TanStack resets route failures when the viewer navigates away; remount a boundary to clear a failure it catches outside the route error path.
|
|
771
800
|
|
|
@@ -834,7 +863,7 @@ The example uses `Option` from `effect` and the application's Better Auth client
|
|
|
834
863
|
|
|
835
864
|
For other Better Auth reads, `authQuery` from `@shivaedev/react/client/authQuery.ts` creates an input-keyed query atom family. Call `authQuery((input, signal) => authClient.getSession({ query: input, fetchOptions: { signal } }))` with an explicitly typed input, then render its atom with `useQuery`. Releasing a pending read interrupts its Effect and aborts the supplied signal.
|
|
836
865
|
|
|
837
|
-
For an explicit sign-out in a TanStack route, use `useSignOut(signOut, { signIn: "/sign-in" })` from `@shivaedev/react/client/useSignOut.ts` in place of `useAction`. It exposes the same state and a `dispatch()` handler. The hook records sign-out intent before the request and navigates to sign-in after success. Repeated clicks while pending share one request and follow-up. Unmounting the component or disposing its registry stops the follow-up navigation. If a session refresh replaces the component before the response, the replacement session’s route policy owns navigation to sign-in. `permissionGuard` and `signInSearch(location)` omit `returnTo` for that intent, including when the auth owner's session refresh reruns guards first. Use `signInSearch` for module sign-in links too; ordinary visits retain the full requested location. Applications do not need history markers or Better Auth completion timing hooks.
|
|
866
|
+
For an explicit sign-out in a TanStack route, use `useSignOut(signOut, { signIn: "/sign-in" })` from `@shivaedev/react/client/adapters/useSignOut.ts` in place of `useAction`. It exposes the same state and a `dispatch()` handler. The hook records sign-out intent before the request and navigates to sign-in after success. Repeated clicks while pending share one request and follow-up. Unmounting the component or disposing its registry stops the follow-up navigation. If a session refresh replaces the component before the response, the replacement session’s route policy owns navigation to sign-in. `permissionGuard` and `signInSearch(location)` omit `returnTo` for that intent, including when the auth owner's session refresh reruns guards first. Use `signInSearch` for module sign-in links too; ordinary visits retain the full requested location. Applications do not need history markers or Better Auth completion timing hooks.
|
|
838
867
|
|
|
839
868
|
### 3. Every day
|
|
840
869
|
|
|
@@ -897,80 +926,111 @@ pnpm add @shivaedev/changes @shivaedev/contract
|
|
|
897
926
|
pnpm add -D @shivaedev/test-story @effect/platform-node @effect/vitest vitest happy-dom react-dom @types/react-dom
|
|
898
927
|
```
|
|
899
928
|
|
|
900
|
-
Configure Vitest with `test: { environment: "happy-dom" }`, or select that environment for your DOM test project.
|
|
929
|
+
Configure Vitest with `test: { environment: "happy-dom" }`, or select that environment for your DOM test project. Keep the engine, rendering and verbs in a story kit under `src/test-support/notesScreen.tsx`. This kit runs the declared query and command against native RPC test handlers and gives the screen driver the registry's pending signal:
|
|
901
930
|
|
|
902
931
|
```tsx
|
|
903
932
|
import { Effect, Layer, Option, Ref, Schema, Stream } from "effect";
|
|
904
933
|
import { act, createElement } from "react";
|
|
905
|
-
import {
|
|
934
|
+
import { collection } from "@shivaedev/changes/keys.ts";
|
|
906
935
|
import { makeClient } from "@shivaedev/contract/bind.ts";
|
|
907
936
|
import { contract } from "@shivaedev/contract/contract.ts";
|
|
908
|
-
import { collection } from "@shivaedev/changes/keys.ts";
|
|
909
937
|
import { command, query } from "@shivaedev/contract/operation.ts";
|
|
910
938
|
import { layerMemoryProtocol } from "@shivaedev/contract/testing.ts";
|
|
939
|
+
import { screenPending } from "@shivaedev/react/adapters/screenPending.ts";
|
|
911
940
|
import { useAction, useQuery } from "@shivaedev/react/client/resultState.ts";
|
|
912
|
-
import {
|
|
913
|
-
import {
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
expectNoReactWarnings();
|
|
941
|
+
import { render } from "@shivaedev/test-story/client/react.ts";
|
|
942
|
+
import { screenDriver } from "@shivaedev/test-story/server/screenDriver.ts";
|
|
943
|
+
import { storyKit } from "@shivaedev/test-story/server/storyKit.ts";
|
|
944
|
+
import * as AtomRegistry from "effect/reactivity/AtomRegistry";
|
|
917
945
|
|
|
918
946
|
const notes = collection("notes", Schema.Number);
|
|
919
947
|
const List = query("list", { readPolicy: () => Effect.succeed(true), reads: () => [notes.list], success: Schema.Array(Schema.String) });
|
|
920
948
|
const Add = command("add", { invalidates: () => [notes.list], payload: { title: Schema.String } });
|
|
921
949
|
const Notes = contract("notes", { commands: [Add], queries: [List] });
|
|
922
950
|
|
|
923
|
-
const
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
951
|
+
export const notesScreen = storyKit({
|
|
952
|
+
clock: "live",
|
|
953
|
+
*create() {
|
|
954
|
+
const handlers = Notes.toLayer(
|
|
955
|
+
Effect.gen(function* () {
|
|
956
|
+
const stored = yield* Ref.make<readonly string[]>([]);
|
|
957
|
+
return Notes.of({
|
|
958
|
+
"notes.$changes": () => Stream.never,
|
|
959
|
+
"notes.add": ({ title }) => Ref.update(stored, (all) => [...all, title]),
|
|
960
|
+
"notes.list": () => Ref.get(stored),
|
|
961
|
+
});
|
|
962
|
+
}),
|
|
963
|
+
);
|
|
964
|
+
const { api, Client } = makeClient(Notes, {
|
|
965
|
+
live: false,
|
|
966
|
+
protocol: layerMemoryProtocol(Notes).pipe(Layer.provide(handlers)),
|
|
967
|
+
url: "memory://notes",
|
|
930
968
|
});
|
|
931
|
-
|
|
932
|
-
)
|
|
933
|
-
const
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
969
|
+
const add = Client.runtime.fn(api.add.run);
|
|
970
|
+
function NotesView() {
|
|
971
|
+
const list = useQuery(api.list.query());
|
|
972
|
+
const action = useAction(add);
|
|
973
|
+
return createElement(
|
|
974
|
+
"section",
|
|
975
|
+
null,
|
|
976
|
+
createElement("output", null, Option.getOrElse(list.data, () => []).join(", ")),
|
|
977
|
+
createElement(
|
|
978
|
+
"button",
|
|
979
|
+
{
|
|
980
|
+
disabled: list.pending || action.pending,
|
|
981
|
+
onClick: () => action.dispatch({ title: "Morning walk" }),
|
|
982
|
+
type: "button",
|
|
983
|
+
},
|
|
984
|
+
"Add",
|
|
985
|
+
),
|
|
986
|
+
);
|
|
987
|
+
}
|
|
988
|
+
const view = yield* Effect.acquireRelease(
|
|
989
|
+
Effect.promise(() => render(createElement(NotesView))),
|
|
990
|
+
(mounted) => Effect.promise(mounted.unmount),
|
|
991
|
+
);
|
|
992
|
+
const pending = yield* screenPending().pipe(Effect.provideService(AtomRegistry.AtomRegistry, view.registry));
|
|
993
|
+
return { pending, view };
|
|
994
|
+
},
|
|
995
|
+
inspect: ({ view }) => ({ screen: view.container.textContent }),
|
|
996
|
+
name: "notes screen",
|
|
997
|
+
stages: ["screen"],
|
|
998
|
+
verbs: ({ pending, view }, story) =>
|
|
999
|
+
screenDriver({
|
|
1000
|
+
act: async (action) => {
|
|
1001
|
+
await act(action);
|
|
952
1002
|
},
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
}
|
|
1003
|
+
pending,
|
|
1004
|
+
root: view.container,
|
|
1005
|
+
tell: story.tell,
|
|
1006
|
+
}),
|
|
1007
|
+
});
|
|
1008
|
+
```
|
|
957
1009
|
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
1010
|
+
The spec drives one action and states what the screen shows. With `#test/*` mapped to `src/test-support/*` in your package's imports, `notesScreen.dom.spec.tsx` is:
|
|
1011
|
+
|
|
1012
|
+
```tsx
|
|
1013
|
+
import { expect } from "vitest";
|
|
1014
|
+
import { expectNoReactWarnings } from "@shivaedev/test-story/client/react.ts";
|
|
1015
|
+
import { notesScreen } from "#test/notesScreen.tsx";
|
|
1016
|
+
|
|
1017
|
+
Object.assign(globalThis, { "IS_REACT_ACT_ENVIRONMENT": true });
|
|
1018
|
+
expectNoReactWarnings();
|
|
1019
|
+
|
|
1020
|
+
notesScreen.it("a command refetches the rendered notes through native RPC", [], function* ({ click, settle, text }) {
|
|
1021
|
+
yield* settle();
|
|
1022
|
+
expect(text("output")).toBe("");
|
|
1023
|
+
|
|
1024
|
+
yield* click({ name: "Add", role: "button" });
|
|
1025
|
+
yield* settle();
|
|
1026
|
+
|
|
1027
|
+
expect(text("output")).toBe("Morning walk");
|
|
970
1028
|
});
|
|
971
1029
|
```
|
|
972
1030
|
|
|
973
|
-
`
|
|
1031
|
+
`settle()` waits for the engine's pending work and flushes the resulting React render. Release held server responses with a Deferred or another engine completion signal, then settle the screen before reading it. Keep each verb to one action and let a missing target fail; the driver's `click` and `enter` require a rendered control. Keep expectations in the spec.
|
|
1032
|
+
|
|
1033
|
+
`render(node, options?)` returns the attached `container`, its fresh native `registry`, `render(nextNode)` to update the same root and registry, and `unmount()` to release the root, registry and container. The options are React's own `RootOptions`, passed to `createRoot`, including `onCaughtError`, `onUncaughtError` and `onRecoverableError`. Acquire the view with `Effect.acquireRelease` so its scope releases it on success, failure or interruption. The screen driver's `act` adapter keeps component interactions and settling inside React's `act`. `expectNoReactWarnings()` registers a Vitest hook that fails a test if it logged to `console.error`.
|
|
974
1034
|
|
|
975
1035
|
The RPC layer stays application-owned: replace these in-memory handlers with the service Layer your component needs.
|
|
976
1036
|
|
|
@@ -992,7 +1052,7 @@ screenStories.it("shows the route failure", [], async () => {
|
|
|
992
1052
|
|
|
993
1053
|
Story kits can acquire `captureReactWarnings` from `@shivaedev/test-story/client/react.ts` in their `create` effect with `const warnings = yield* captureReactWarnings`. The scope owns the capture and restores `console.error` when it closes, including after a failed story. Pass `warnings.onCaughtError` to `render` to capture boundary errors, or `warnings.expectCaughtError(predicate)` to exclude a declared error. Both handlers silence caught errors; the capture also silences and records `console.error` calls. `warnings.read()` returns `{ consoleErrors, caughtErrors }`, with each console call's arguments and the unexpected caught errors. It asserts nothing, leaving the story spec to state its expectation. The Vitest guard uses the same capture mechanism and additionally checks that every declared error occurred.
|
|
994
1054
|
|
|
995
|
-
A screen kit tells its screen driver when the screen has finished its work with `screenPending({ router })` from `@shivaedev/react/
|
|
1055
|
+
A screen kit tells its screen driver when the screen has finished its work with `screenPending({ router })` from `@shivaedev/react/adapters/screenPending.ts`. The Effect reads the `AtomRegistry` from its environment and returns a function that reports `true` while a native `AsyncResult` that something still reads is waiting, or while the optional TanStack router loads a route, and `false` otherwise. A result left waiting by a component that has unmounted does not count, even while the registry's idle window keeps its atom. Each call reads the registry and router at that moment, so pass it as the driver's `pending` option instead of listing the screen's queries by hand:
|
|
996
1056
|
|
|
997
1057
|
```ts
|
|
998
1058
|
const pending = yield* screenPending({ router }).pipe(Effect.provideService(AtomRegistry.AtomRegistry, view.registry));
|
|
@@ -1015,7 +1075,7 @@ const screen = screenDriver({ act, pending, root: view.container, tell: story.te
|
|
|
1015
1075
|
|
|
1016
1076
|
Import the defining `.ts` module, such as `@shivaedev/react/client/editor.ts`. There is no root import. `useSessionRecheck()` from `client/sessionBoundary.ts` reads the boundary's `recheck` callback.
|
|
1017
1077
|
|
|
1018
|
-
Prefer `useEditor` and `useCreate` when binding a form to a command. The lower-level modules expose the same composition pieces: `submission` from `submission.ts` makes a form and its submission snapshot reader, `rejecting` from
|
|
1078
|
+
Prefer `useEditor` and `useCreate` when binding a form to a command. The lower-level modules expose the same composition pieces: `submission` from `submission.ts` makes a form and its submission snapshot reader, `rejecting` from `@shivaedev/form/fieldRejection.ts` maps save failures through a submitter, and `useSaveState` from `client/saveState.ts` observes submission and invokes a success callback. Field-rejection mapping types and `fieldRejectionOf` also belong to `@shivaedev/form/fieldRejection.ts`; `AtomServices` belongs to `AtomServices.ts`.
|
|
1019
1079
|
|
|
1020
1080
|
### Install, setup and limits
|
|
1021
1081
|
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Scope } from "effect";
|
|
2
|
+
import type { AtomRegistry } from "effect/reactivity/AtomRegistry";
|
|
3
|
+
import type { Reactivity } from "effect/reactivity/Reactivity";
|
|
4
|
+
export type AtomServices<TRequirements> = TRequirements | Scope.Scope | AtomRegistry | Reactivity;
|
|
5
|
+
//# sourceMappingURL=AtomServices.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AtomServices.d.ts","sourceRoot":"","sources":["../src/AtomServices.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAE/D,MAAM,MAAM,YAAY,CAAC,aAAa,IAAI,aAAa,GAAG,KAAK,CAAC,KAAK,GAAG,YAAY,GAAG,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AtomServices.js","sourceRoot":"","sources":["../src/AtomServices.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Forbidden.d.ts","sourceRoot":"","sources":["../../src/adapters/Forbidden.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtD,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,SAAS,CAAC,EACzB,EAAE,EACF,KAA2B,EAC3B,QAAiD,EACjD,SAAqB,EACrB,SAAS,GACT,EAAE,cAAc,GAAG,SAAS,CAQ5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Forbidden.js","sourceRoot":"","sources":["../../src/adapters/Forbidden.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAkB,MAAM,OAAO,CAAC;AAUtD,MAAM,UAAU,SAAS,CAAC,EACzB,EAAE,EACF,KAAK,GAAG,mBAAmB,EAC3B,QAAQ,GAAG,sCAAsC,EACjD,SAAS,GAAG,SAAS,EACrB,SAAS,GACO;IAChB,OAAO,aAAa,CACnB,MAAM,EACN,EAAE,SAAS,EAAE,EACb,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,EAChC,aAAa,CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,CAAC,EAClC,aAAa,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE,SAAS,CAAC,CACtC,CAAC;AACH,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import * as AtomRegistry from "effect/reactivity/AtomRegistry";
|
|
3
|
-
import { keepLoaderQuery } from "#internal/queryHandoff.ts";
|
|
4
3
|
import { recheckUnauthorized } from "#internal/sessionRecheck.ts";
|
|
4
|
+
import { keepLoaderQuery } from "./queryHandoff.js";
|
|
5
5
|
export async function loadQuery(registry, atom, { abortController }) {
|
|
6
6
|
const { signal } = abortController;
|
|
7
7
|
const handoff = keepLoaderQuery(registry, atom, signal);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadQuery.js","sourceRoot":"","sources":["../../src/adapters/loadQuery.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAO,KAAK,YAAY,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"loadQuery.js","sourceRoot":"","sources":["../../src/adapters/loadQuery.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAO,KAAK,YAAY,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,CAAC,KAAK,UAAU,SAAS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CAAC,iBAAiB,CAAC,CAAC;IAC9C,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,KAAK,CAAC;IACb,CAAC;IACD,OAAO,OAAO,EAAE,QAAQ,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAA2B;IAC1F,OAAO,aAAa,CACnB,iBAAiB,CAAC,QAAQ,EAC1B,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAChC,aAAa,CAAC,aAAa,EAAE,EAAE,QAAQ,EAAE,cAAc,EAAE,uBAAuB,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,YAAY,EAAE,CAAC,CACpH,CAAC;AACH,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Permission } from "@shivaedev/access/permission.ts";
|
|
2
|
-
import { type PermissionSession } from "
|
|
3
|
-
import { type SignInLocation } from "
|
|
2
|
+
import { type PermissionSession } from "#permissions.ts";
|
|
3
|
+
import { type SignInLocation } from "#signInSearch.ts";
|
|
4
4
|
declare module "@tanstack/react-router" {
|
|
5
5
|
interface StaticDataRouteOption {
|
|
6
6
|
readonly permission?: Permission;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissionGuard.d.ts","sourceRoot":"","sources":["../../src/adapters/permissionGuard.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAElE,OAAO,EAAO,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAE,KAAK,cAAc,EAAgB,MAAM,kBAAkB,CAAC;AAErE,OAAO,QAAQ,wBAAwB,CAAC;IACvC,UAAU,qBAAqB;QAC9B,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC;QACjC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;KAC5B;CACD;AAED,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,iBAAiB,GAAG,IAAI,GAAG,SAAS,CAAC;IAC7D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,SAAS;QAAE,QAAQ,CAAC,UAAU,EAAE;YAAE,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC;YAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;SAAE,CAAA;KAAE,EAAE,CAAC;CACxH;AAED,wBAAgB,eAAe,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,MAAc,EAAE,EAAE,sBAAsB,GAAG,CAAC,OAAO,EAAE,sBAAsB,KAAK,IAAI,CAgBtI"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { notFound, redirect } from "@tanstack/react-router";
|
|
2
2
|
import { forbidden } from "@shivaedev/access/refusal.ts";
|
|
3
|
-
import { can } from "
|
|
4
|
-
import { signInSearch } from "
|
|
3
|
+
import { can } from "#permissions.ts";
|
|
4
|
+
import { signInSearch } from "#signInSearch.ts";
|
|
5
5
|
export function permissionGuard({ session, signIn, hidden = false }) {
|
|
6
6
|
return ({ matches, location }) => {
|
|
7
7
|
const required = matches.flatMap((match) => (match.staticData.permission === undefined ? [] : [match.staticData.permission]));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissionGuard.js","sourceRoot":"","sources":["../../src/adapters/permissionGuard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAE5D,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,GAA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":["../../src/
|
|
1
|
+
{"version":3,"file":"queryHandoff.d.ts","sourceRoot":"","sources":["../../src/adapters/queryHandoff.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAC/C,OAAO,KAAK,KAAK,YAAY,MAAM,gCAAgC,CAAC;AAUpE,wBAAgB,eAAe,CAAC,QAAQ,EAAE,YAAY,CAAC,YAAY,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,WAAW;;;EAiCjH;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,YAAY,CAAC,YAAY,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAIrG;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,YAAY,CAAC,YAAY,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,CAO3H"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryHandoff.js","sourceRoot":"","sources":["../../src/
|
|
1
|
+
{"version":3,"file":"queryHandoff.js","sourceRoot":"","sources":["../../src/adapters/queryHandoff.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAS/C,MAAM,QAAQ,GAAG,IAAI,OAAO,EAAwE,CAAC;AAErG,MAAM,UAAU,eAAe,CAAC,QAAmC,EAAE,IAAwB,EAAE,MAAmB;IACjH,IAAI,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACnC,IAAI,CAAC,KAAK,EAAE,CAAC;QACZ,KAAK,GAAG,IAAI,OAAO,EAAE,CAAC;QACtB,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC/B,CAAC;IACD,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAA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D,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,QAAmC,EAAE,IAAwB;IAC9F,KAAK,MAAM,OAAO,IAAI,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;QAC/D,OAAO,CAAC,OAAO,EAAE,CAAC;IACnB,CAAC;AACF,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,QAAmC,EAAE,IAAwB;IAC/F,KAAK,MAAM,OAAO,IAAI,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;QAC/D,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACrB,OAAO,OAAO,CAAC,KAAK,CAAC;QACtB,CAAC;IACF,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC"}
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { LoaderFnContext } from "@tanstack/react-router";
|
|
2
2
|
import type * as AsyncResult from "effect/reactivity/AsyncResult";
|
|
3
3
|
import type * as Atom from "effect/reactivity/Atom";
|
|
4
4
|
import type * as AtomRegistry from "effect/reactivity/AtomRegistry";
|
|
5
|
+
import { type QueryRouteRedirects } from "./queryRouteFailure.ts";
|
|
6
|
+
interface QueryRouteInput<TParams, TSearch, TContext> {
|
|
7
|
+
readonly context: TContext;
|
|
8
|
+
readonly params: TParams;
|
|
9
|
+
readonly search: TSearch;
|
|
10
|
+
}
|
|
5
11
|
export declare function queryRoute<TParams extends object, TSearch extends object, A, E, TContext extends {
|
|
6
12
|
readonly registry: AtomRegistry.AtomRegistry;
|
|
7
13
|
} = {
|
|
8
14
|
readonly registry: AtomRegistry.AtomRegistry;
|
|
9
|
-
}>(query: (route: {
|
|
10
|
-
readonly
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}) => Atom.Atom<AsyncResult.AsyncResult<A, E>>): {
|
|
14
|
-
loader: (context: Pick<LoaderFnContext, "abortController"> & {
|
|
15
|
+
}>(query: (route: QueryRouteInput<TParams, TSearch, TContext>) => Atom.Atom<AsyncResult.AsyncResult<A, E>>, options?: {
|
|
16
|
+
readonly redirects?: QueryRouteRedirects;
|
|
17
|
+
}): {
|
|
18
|
+
loader: (context: Pick<LoaderFnContext, "abortController" | "location"> & {
|
|
15
19
|
readonly context: TContext;
|
|
16
20
|
readonly deps: TSearch;
|
|
17
21
|
readonly params: TParams;
|
|
@@ -19,5 +23,7 @@ export declare function queryRoute<TParams extends object, TSearch extends objec
|
|
|
19
23
|
loaderDeps: ({ search }: {
|
|
20
24
|
readonly search: TSearch;
|
|
21
25
|
}) => TSearch;
|
|
26
|
+
useRetry: () => () => Promise<void>;
|
|
22
27
|
};
|
|
28
|
+
export {};
|
|
23
29
|
//# sourceMappingURL=queryRoute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryRoute.d.ts","sourceRoot":"","sources":["../../src/adapters/queryRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,KAAK,WAAW,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,KAAK,IAAI,MAAM,wBAAwB,CAAC;AACpD,OAAO,KAAK,KAAK,YAAY,MAAM,gCAAgC,CAAC;AAEpE,OAAO,EAAE,KAAK,mBAAmB,EAAqB,MAAM,wBAAwB,CAAC;AAGrF,UAAU,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ;IACnD,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CACzB;AAED,wBAAgB,UAAU,CACzB,OAAO,SAAS,MAAM,EACtB,OAAO,SAAS,MAAM,EACtB,CAAC,EACD,CAAC,EACD,QAAQ,SAAS;IAAE,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC,YAAY,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC,YAAY,CAAA;CAAE,EAEpH,KAAK,EAAE,CAAC,KAAK,EAAE,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EACvG,OAAO,GAAE;IAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,mBAAmB,CAAA;CAAO;IAGzD,MAAM,YACI,IAAI,CAAC,eAAe,EAAE,iBAAiB,GAAG,UAAU,CAAC,GAAG;QAChE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;QAC3B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;QACvB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;KACzB,KACC,OAAO,CAAC,CAAC,CAAC;IAOb,UAAU,eAAe;QAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;KAAE;IACrD,QAAQ;EAMT"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { loadQuery } from "./loadQuery.js";
|
|
2
|
+
import { queryRouteFailure } from "./queryRouteFailure.js";
|
|
3
|
+
import { useQueryRetry } from "./useQueryRetry.js";
|
|
4
|
+
export function queryRoute(query, options = {}) {
|
|
5
|
+
return {
|
|
6
|
+
loader: async (context) => {
|
|
7
|
+
try {
|
|
8
|
+
return await loadQuery(context.context.registry, query({ context: context.context, params: context.params, search: context.deps }), context);
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
throw queryRouteFailure(error, context.location, options.redirects);
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
loaderDeps: ({ search }) => search,
|
|
15
|
+
useRetry: () => useQueryRetry((match) => {
|
|
16
|
+
const { context, params, loaderDeps } = match;
|
|
17
|
+
context.registry.refresh(query({ context, params, search: loaderDeps }));
|
|
18
|
+
}),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=queryRoute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryRoute.js","sourceRoot":"","sources":["../../src/adapters/queryRoute.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAA4B,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAQnD,MAAM,UAAU,UAAU,CAOzB,KAAuG,EACvG,OAAO,GAAiD,EAAE;IAE1D,OAAO;QACN,MAAM,EAAE,KAAK,EACZ,OAIC,EACY,EAAE;YACf,IAAI,CAAC;gBACJ,OAAO,MAAM,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;YAC9I,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,MAAM,iBAAiB,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;YACrE,CAAC;QACF,CAAC;QACD,UAAU,EAAE,CAAC,EAAE,MAAM,EAAgC,EAAE,EAAE,CAAC,MAAM;QAChE,QAAQ,EAAE,GAAG,EAAE,CACd,aAAa,CAAC,CAAC,KAAK,EAAE,EAAE;YACvB,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,GAAgE,KAAK,CAAC;YAC3G,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;QAC1E,CAAC,CAAC;KACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SignInLocation } from "#signInSearch.ts";
|
|
2
|
+
export type QueryRouteRedirect = Response & {
|
|
3
|
+
readonly options: object;
|
|
4
|
+
};
|
|
5
|
+
export interface QueryRouteRedirects {
|
|
6
|
+
readonly refused?: () => QueryRouteRedirect;
|
|
7
|
+
readonly signedOut?: (location: SignInLocation) => QueryRouteRedirect;
|
|
8
|
+
}
|
|
9
|
+
export declare function queryRouteFailure(error: unknown, location: SignInLocation, redirects: QueryRouteRedirects | undefined): unknown;
|
|
10
|
+
//# sourceMappingURL=queryRouteFailure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryRouteFailure.d.ts","sourceRoot":"","sources":["../../src/adapters/queryRouteFailure.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzE,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,kBAAkB,CAAC;IAC5C,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,kBAAkB,CAAC;CACtE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,SAAS,EAAE,mBAAmB,GAAG,SAAS,GAAG,OAAO,CAQ/H"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { notFound } from "@tanstack/react-router";
|
|
2
|
+
import { Predicate } from "effect";
|
|
3
|
+
import { isForbidden, isNotFound, isUnauthorized } from "@shivaedev/errors/taxonomy.ts";
|
|
4
|
+
export function queryRouteFailure(error, location, redirects) {
|
|
5
|
+
if (isUnauthorized(error) && redirects?.signedOut) {
|
|
6
|
+
return redirects.signedOut(location);
|
|
7
|
+
}
|
|
8
|
+
if ((isForbidden(error) || Predicate.isTagged(error, "QueryReadDenied")) && redirects?.refused) {
|
|
9
|
+
return redirects.refused();
|
|
10
|
+
}
|
|
11
|
+
return isNotFound(error) || Predicate.isTagged(error, "QueryReadDenied") ? notFound({ data: error }) : error;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=queryRouteFailure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryRouteFailure.js","sourceRoot":"","sources":["../../src/adapters/queryRouteFailure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAUxF,MAAM,UAAU,iBAAiB,CAAC,KAAc,EAAE,QAAwB,EAAE,SAA0C;IACrH,IAAI,cAAc,CAAC,KAAK,CAAC,IAAI,SAAS,EAAE,SAAS,EAAE,CAAC;QACnD,OAAO,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACtC,CAAC;IACD,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC,IAAI,SAAS,EAAE,OAAO,EAAE,CAAC;QAChG,OAAO,SAAS,CAAC,OAAO,EAAE,CAAC;IAC5B,CAAC;IACD,OAAO,UAAU,CAAC,KAAK,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC9G,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screenPending.d.ts","sourceRoot":"","sources":["../../src/adapters/screenPending.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AAExC,OAAO,KAAK,YAAY,MAAM,gCAAgC,CAAC;AAE/D,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CACxC;AAED,wBAAgB,aAAa,CAAC,EAAE,MAAM,EAAE,GAAE,oBAAyB,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,OAAO,EAAE,KAAK,EAAE,YAAY,CAAC,YAAY,CAAC,CAKnI"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screenPending.js","sourceRoot":"","sources":["../../src/adapters/screenPending.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,WAAW,MAAM,+BAA+B,CAAC;AAC7D,OAAO,KAAK,YAAY,MAAM,gCAAgC,CAAC;AAM/D,MAAM,UAAU,aAAa,CAAC,EAAE,MAAM,EAAE,GAAyB,EAAE;IAClE,OAAO,MAAM,CAAC,GAAG,CAChB,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,YAAY,CAAC,EACzC,CAAC,QAAQ,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC,CACnI,CAAC;AACH,CAAC;AAED,S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