@shivaedev/react 0.33.0 → 0.35.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.
Files changed (99) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +121 -77
  3. package/dist/AtomServices.d.ts +5 -0
  4. package/dist/AtomServices.d.ts.map +1 -0
  5. package/dist/AtomServices.js +2 -0
  6. package/dist/AtomServices.js.map +1 -0
  7. package/dist/adapters/loadQuery.d.ts.map +1 -1
  8. package/dist/adapters/loadQuery.js +0 -1
  9. package/dist/adapters/loadQuery.js.map +1 -1
  10. package/dist/adapters/permissionBoundary.d.ts +1 -1
  11. package/dist/adapters/permissionBoundary.d.ts.map +1 -1
  12. package/dist/adapters/permissionBoundary.js +1 -1
  13. package/dist/adapters/permissionBoundary.js.map +1 -1
  14. package/dist/adapters/permissionGuard.d.ts +1 -1
  15. package/dist/adapters/permissionGuard.d.ts.map +1 -1
  16. package/dist/adapters/permissionGuard.js +1 -1
  17. package/dist/adapters/permissionGuard.js.map +1 -1
  18. package/dist/can.d.ts +4 -0
  19. package/dist/can.d.ts.map +1 -0
  20. package/dist/can.js +5 -0
  21. package/dist/can.js.map +1 -0
  22. package/dist/client/actionCompletion.d.ts +1 -1
  23. package/dist/client/actionCompletion.d.ts.map +1 -1
  24. package/dist/client/adapters/SessionGeneration.js +1 -1
  25. package/dist/client/adapters/SessionGeneration.js.map +1 -1
  26. package/dist/client/authAction.d.ts +2 -16
  27. package/dist/client/authAction.d.ts.map +1 -1
  28. package/dist/client/authAction.js +1 -77
  29. package/dist/client/authAction.js.map +1 -1
  30. package/dist/client/authQuery.d.ts +2 -3
  31. package/dist/client/authQuery.d.ts.map +1 -1
  32. package/dist/client/authQuery.js +2 -7
  33. package/dist/client/authQuery.js.map +1 -1
  34. package/dist/client/authSession.d.ts +3 -9
  35. package/dist/client/authSession.d.ts.map +1 -1
  36. package/dist/client/authSession.js +2 -19
  37. package/dist/client/authSession.js.map +1 -1
  38. package/dist/client/create.d.ts +6 -4
  39. package/dist/client/create.d.ts.map +1 -1
  40. package/dist/client/create.js +2 -2
  41. package/dist/client/create.js.map +1 -1
  42. package/dist/client/editor.d.ts +6 -4
  43. package/dist/client/editor.d.ts.map +1 -1
  44. package/dist/client/editor.js +2 -1
  45. package/dist/client/editor.js.map +1 -1
  46. package/dist/client/mountLive.js +1 -1
  47. package/dist/client/mountLive.js.map +1 -1
  48. package/dist/client/resultState.d.ts +1 -1
  49. package/dist/client/resultState.d.ts.map +1 -1
  50. package/dist/client/resultState.js.map +1 -1
  51. package/dist/client/sessionBoundary.js +1 -1
  52. package/dist/client/sessionBoundary.js.map +1 -1
  53. package/dist/internal/PermissionContext.d.ts +1 -1
  54. package/dist/internal/PermissionContext.d.ts.map +1 -1
  55. package/dist/internal/useSubmissionCallbacks.d.ts +3 -2
  56. package/dist/internal/useSubmissionCallbacks.d.ts.map +1 -1
  57. package/dist/internal/useSubmissionCallbacks.js +1 -1
  58. package/dist/internal/useSubmissionCallbacks.js.map +1 -1
  59. package/dist/notices.d.ts +1 -1
  60. package/dist/notices.d.ts.map +1 -1
  61. package/dist/submission.d.ts +4 -3
  62. package/dist/submission.d.ts.map +1 -1
  63. package/dist/submission.js +5 -1
  64. package/dist/submission.js.map +1 -1
  65. package/package.json +13 -13
  66. package/src/AtomServices.ts +5 -0
  67. package/src/adapters/loadQuery.ts +0 -1
  68. package/src/adapters/permissionBoundary.ts +2 -1
  69. package/src/adapters/permissionGuard.ts +2 -1
  70. package/src/can.ts +6 -0
  71. package/src/client/actionCompletion.ts +1 -1
  72. package/src/client/adapters/SessionGeneration.ts +1 -1
  73. package/src/client/authAction.ts +3 -94
  74. package/src/client/authQuery.ts +3 -14
  75. package/src/client/authSession.ts +5 -34
  76. package/src/client/create.ts +9 -6
  77. package/src/client/editor.ts +9 -5
  78. package/src/client/mountLive.ts +1 -1
  79. package/src/client/resultState.ts +1 -1
  80. package/src/client/sessionBoundary.ts +1 -1
  81. package/src/internal/PermissionContext.ts +1 -1
  82. package/src/internal/useSubmissionCallbacks.ts +2 -1
  83. package/src/notices.ts +1 -1
  84. package/src/submission.ts +9 -3
  85. package/dist/fieldRejection.d.ts +0 -25
  86. package/dist/fieldRejection.d.ts.map +0 -1
  87. package/dist/fieldRejection.js +0 -21
  88. package/dist/fieldRejection.js.map +0 -1
  89. package/dist/internal/liveBindings.d.ts +0 -3
  90. package/dist/internal/liveBindings.d.ts.map +0 -1
  91. package/dist/internal/liveBindings.js +0 -10
  92. package/dist/internal/liveBindings.js.map +0 -1
  93. package/dist/permissions.d.ts +0 -13
  94. package/dist/permissions.d.ts.map +0 -1
  95. package/dist/permissions.js +0 -9
  96. package/dist/permissions.js.map +0 -1
  97. package/src/fieldRejection.ts +0 -51
  98. package/src/internal/liveBindings.ts +0 -11
  99. package/src/permissions.ts +0 -11
package/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.35.0 - 2026-11-03
4
+
5
+ ### Added
6
+
7
+ - Session boundaries mount every API declared with contract's `composeBindings`, including APIs nested inside feature modules, and apply the session's live coalescing window to each binding.
8
+ - Accept and forward form's `requiredMessages`, `checks`, `debounce` and `arrayKeys` in editor, create and submission configurations, preserving encoded field types and runtime service requirements.
9
+
10
+ ### Fixed
11
+
12
+ - Keep a failed route's query in its registry until its own retry refreshes it or the route leaves, so refreshing another query cannot recover the failed route.
13
+ - Mounted session queries refresh after worker writes, and a denied recheck reaches the query as `QueryReadDenied`.
14
+
15
+ ### Breaking
16
+
17
+ - The `internal/liveBindings.ts` module is removed. Consumers that imported it must import `liveBindings` from `@shivaedev/contract/composeBindings.ts` instead.
18
+ - `useEditor` and `useCreate` require explicit draft storage alongside time. Acquire `persistence` with form's `draftPersistence` Effect from `@shivaedev/form/adapters/draftPersistence.ts`, provide `browserDraftStorage` from `@shivaedev/form/adapters/browserDraftStorage.ts`, and pass `persistedDraft: { key, ...persistence }`.
19
+ - Import `authCall` and `AuthActionResult` from `@shivaedev/identity/client/adapters/authCall.ts` instead of `@shivaedev/react/client/authAction.ts`. Import `AuthFailure` from `@shivaedev/identity/client/AuthFailure.ts` and the `AuthFailureCode` schema and type from `@shivaedev/identity/client/AuthFailureCode.ts`.
20
+ - React's `authAction` now accepts an input-to-Effect function: replace `authAction(runPromise)` with `authAction(authCall(runPromise))` using identity's bridge. React's `authQuery` also accepts an input-to-Effect function: wrap the Promise reader with `authQuery` from `@shivaedev/identity/client/adapters/authQuery.ts` before passing it to React's atom family.
21
+ - React's `authSession` now accepts a session Effect: wrap the Promise reader with `authSession` from `@shivaedev/identity/client/adapters/authSession.ts` before passing it to React's session atom. Import `SessionWithPermissions` from that identity adapter instead of React's session module. `AuthSession<A, E>` now exposes exactly `E`; include `AuthUnavailable` in `E` when explicitly annotating an identity-backed session.
22
+ - Import the `PermissionSession` schema and type from `@shivaedev/identity/PermissionSession.ts` instead of `@shivaedev/react/permissions.ts`. Import `can` from `@shivaedev/react/can.ts` instead of `@shivaedev/react/permissions.ts`. The removed exports have no compatibility aliases.
23
+
24
+ ## 0.34.0 - 2026-11-02
25
+
26
+ ### Breaking
27
+
28
+ - Import `AtomServices` from `@shivaedev/react/AtomServices.ts` instead of the removed `@shivaedev/react/fieldRejection.ts` module.
29
+ - Import `queryRoute` from `@shivaedev/react/adapters/queryRoute.ts` instead of `@shivaedev/react/queryRoute.ts`.
30
+ - Import `permissionGuard`, `PermissionGuardOptions` and `PermissionGuardContext` from `@shivaedev/react/adapters/permissionGuard.ts` instead of `@shivaedev/react/permissionGuard.ts`.
31
+ - Import `PermissionBoundary`, `PermissionBoundaryError`, `PermissionBoundaryProps` and `useCan` from `@shivaedev/react/adapters/permissionBoundary.ts` instead of `@shivaedev/react/client/permissionBoundary.ts`.
32
+ - Import `screenPending` and `ScreenPendingOptions` from `@shivaedev/react/adapters/screenPending.ts` instead of `@shivaedev/react/client/screenPending.ts`.
33
+ - Import `useSignOut` from `@shivaedev/react/client/adapters/useSignOut.ts` instead of `@shivaedev/react/client/useSignOut.ts`.
34
+ - 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`.
35
+ - Import `Forbidden` and `ForbiddenProps` from `@shivaedev/react/adapters/Forbidden.ts` instead of `@shivaedev/react/client/Forbidden.ts`.
36
+
3
37
  ## 0.33.0 - 2026-11-02
4
38
 
5
39
  ### 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, now }`. Choose a stable key for the record or create request, independent of its server revision. Supply `now: () => clock.currentTimeMillisUnsafe()` using `Clock.Clock` captured in the application’s Effect setup; draft timestamps and expiry use that clock. The adapters use form's browser storage and 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. Optional `storage`, `maxBytes` and `maxAgeMs` customize the provider and bounds; defaults are `localStorage`, 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.
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
 
@@ -105,6 +105,24 @@ import { SessionBoundary } from "@shivaedev/react/client/sessionBoundary.ts";
105
105
 
106
106
  `Preferences` is the application's session-scoped contract, and `makePreferencesClient()` creates its native AtomRpc service using the current session cookie. A one-argument `connect` callback also works. The boundary allocates the registry before calling `connect`; an unchanged generation keeps its binding and state. Account replacement, sign-out and same-account re-entry dispose the old registry, private query tracking, live registrations and pending refreshes. Use the user id for cookie-based clients so session rotation keeps state. A sign-out followed by sign-in creates a new registry even for the same user.
107
107
 
108
+ #### Connections with several modules
109
+
110
+ Declare all the connection's bound APIs with contract's `composeBindings`. The session boundary mounts each declared binding and applies its `liveCoalesceWindow` to all of them. The client can keep its application modules nested:
111
+
112
+ ```ts
113
+ import { composeBindings } from "@shivaedev/contract/composeBindings.ts";
114
+
115
+ function connect(session: Session, registry: AtomRegistry.AtomRegistry) {
116
+ const modules = [notesModule(registry), tasksModule(registry)];
117
+ return composeBindings(
118
+ { modules },
119
+ modules.map((module) => module.api),
120
+ );
121
+ }
122
+ ```
123
+
124
+ `Session`, `notesModule` and `tasksModule` belong to the application; each module binds its contract with the supplied registry. Import `AtomRegistry` from `effect/reactivity/AtomRegistry`. Return the resulting connection from `SessionBoundary`'s `connect` callback and render `client.modules` in its child.
125
+
108
126
  #### Resume from a native shell
109
127
 
110
128
  For a native shell, pass its resume source when binding the API returned by `connect`:
@@ -255,7 +273,7 @@ The next module assumes `./invoice-lines-client.ts` exports a contract-bound `ap
255
273
  import { useCreate } from "@shivaedev/react/client/create.ts";
256
274
  import { useEditor } from "@shivaedev/react/client/editor.ts";
257
275
  import { QueryView } from "@shivaedev/react/client/QueryView.ts";
258
- import { useField } from "@shivaedev/form/client/react.ts";
276
+ import { useField } from "@shivaedev/form/adapters/react.ts";
259
277
  import type { Form } from "@shivaedev/form/shape.ts";
260
278
  import { Option, Schema } from "effect";
261
279
  import { api, InvoiceLinesClient } from "./invoice-lines-client.ts";
@@ -709,7 +727,8 @@ import { Forbidden } from "@shivaedev/react/adapters/Forbidden.ts";
709
727
  import { PermissionBoundary, PermissionBoundaryError, useCan } from "@shivaedev/react/adapters/permissionBoundary.ts";
710
728
  import { useLoaderQuery } from "@shivaedev/react/client/useLoaderQuery.ts";
711
729
  import { permissionGuard } from "@shivaedev/react/adapters/permissionGuard.ts";
712
- import { can, type PermissionSession } from "@shivaedev/react/permissions.ts";
730
+ import type { PermissionSession } from "@shivaedev/identity/PermissionSession.ts";
731
+ import { can } from "@shivaedev/react/can.ts";
713
732
  import { queryRoute } from "@shivaedev/react/adapters/queryRoute.ts";
714
733
  import { api, registry } from "./notes-client.ts";
715
734
  import { auth, SignIn } from "./auth.tsx";
@@ -800,10 +819,10 @@ const showNotes = can(auth.session, ReadNotes);
800
819
 
801
820
  #### Better Auth actions
802
821
 
803
- `authAction` from `@shivaedev/react/client/authAction.ts` turns a Better Auth client call into a native action atom. Create it with the client, then pass it to `useAction` for the same `pending`, `data`, `cause`, `result` and `dispatch` shape as commands:
822
+ `authAction` from `@shivaedev/react/client/authAction.ts` turns an input-to-Effect function into a native action atom. Bridge Better Auth with `authCall` from `@shivaedev/identity/client/adapters/authCall.ts`, then pass the atom to `useAction` for the same `pending`, `data`, `cause`, `result` and `dispatch` shape as commands:
804
823
 
805
824
  ```tsx
806
- const signIn = authAction((credentials: { email: string; password: string }, signal) => authClient.signIn.email(credentials, { signal }));
825
+ const signIn = authAction(authCall((credentials: { email: string; password: string }, signal) => authClient.signIn.email(credentials, { signal })));
807
826
 
808
827
  function SignInButton({ email, password }: { email: string; password: string }) {
809
828
  const action = useAction(signIn);
@@ -819,27 +838,19 @@ function SignInButton({ email, password }: { email: string; password: string })
819
838
  }
820
839
  ```
821
840
 
822
- The example uses `authAction`, `useAction`, `effect/reactivity/AsyncResult` and `effect/Option`, with an application-owned `authClient`. Actions fail with `AuthFailure` from the same module. Its `code` uses the closed `AuthFailureCode` union: supported Better Auth core codes, `RATE_LIMITED` for a code-less 429, and `UNKNOWN` for unsupported or missing codes and rejected promises. The original error is available in `cause`. Applications own the sentences, and can make their mapping exhaustive with `Record<AuthFailureCode, string>`.
823
-
824
- For a form's Effect-based `onSubmit`, use `authCall` from the same module:
825
-
826
- ```ts
827
- const signIn = authCall((credentials: { email: string; password: string }, signal) => authClient.signIn.email(credentials, { signal }));
828
- const onSubmit = (credentials: { email: string; password: string }) => signIn(credentials);
829
- ```
830
-
831
- `authCall` returns a function from input to `Effect<A, AuthFailure>`. It uses the same failure codes and successful data as `authAction`.
841
+ The example uses `authAction`, identity's `authCall`, `useAction`, `effect/reactivity/AsyncResult` and `effect/Option`, with an application-owned `authClient`. Identity owns the Promise bridge and its typed failures; see [Better Auth client adapters](https://github.com/ShivaeDev/platform/blob/main/packages/identity/README.md#better-auth-client-adapters). For a form's Effect-based `onSubmit`, pass the function returned by `authCall` directly.
832
842
 
833
- Use `authSession` from `@shivaedev/react/client/authSession.ts` for the application's Better Auth session. It returns a native `atom` for `useQuery` and a `refresh` Effect that refreshes that same atom and waits through its loading state. Both expose typed `user.permissions` alongside the provider's existing session and user fields, using the `PermissionSession` schema from `@shivaedev/react/permissions.ts`. Applications do not decode `get-session` themselves. Missing grants stay optional; malformed grants fail with `AuthUnavailable`. The reader must return a nullable session with a `user` object; use `authQuery` for other payload shapes. Supply Better Auth's public `getSession` call with `disableCookieCache: true` so a mutation reads current user data:
843
+ Use `authSession` from `@shivaedev/react/client/authSession.ts` to wrap identity's session Effect. It returns a native `atom` for `useQuery` and a `refresh` Effect that refreshes that same atom and waits through its loading state. Both expose typed `user.permissions` alongside the provider's existing session and user fields, using the `PermissionSession` schema from `@shivaedev/identity/PermissionSession.ts`. Applications do not decode `get-session` themselves. Missing grants stay optional; malformed grants fail with `AuthUnavailable`. The reader must return a nullable session with a `user` object; use `authQuery` for other payload shapes. Supply Better Auth's public `getSession` call with `disableCookieCache: true` so a mutation reads current user data:
834
844
 
835
845
  ```tsx
836
846
  import { Effect } from "effect";
837
847
  import * as Atom from "effect/reactivity/Atom";
838
- import { authCall } from "@shivaedev/react/client/authAction.ts";
848
+ import { authCall } from "@shivaedev/identity/client/adapters/authCall.ts";
849
+ import { authSession as readSession } from "@shivaedev/identity/client/adapters/authSession.ts";
839
850
  import { authSession } from "@shivaedev/react/client/authSession.ts";
840
851
  import { useAction, useQuery } from "@shivaedev/react/client/resultState.ts";
841
852
 
842
- const session = authSession((signal) => authClient.getSession({ query: { disableCookieCache: true }, fetchOptions: { signal } }));
853
+ const session = authSession(readSession((signal) => authClient.getSession({ query: { disableCookieCache: true }, fetchOptions: { signal } })));
843
854
  const updateUser = authCall((name: string, signal) => authClient.updateUser({ name }, { signal }));
844
855
  const rename = Atom.fn<string>()((name) => updateUser(name).pipe(Effect.andThen(session.refresh)));
845
856
 
@@ -859,9 +870,9 @@ function Account() {
859
870
 
860
871
  The example uses `Option` from `effect` and the application's Better Auth client. The mutation stays pending until the refreshed session settles; the query retains its previous data while refreshing and exposes `pending` for `aria-busy`. Compose email verification with `session.refresh` the same way. Reads preserve returned auth errors and use `AuthUnavailable` from `@shivaedev/errors/taxonomy.ts` for rejected promises; a failed refresh fails the composed mutation. A successful `null` session represents sign-out.
861
872
 
862
- `session.refresh` uses the native `AtomRegistry` service supplied by action atoms and atom runtimes. For an Effect run outside an atom, provide the registry that renders the session with `Effect.provideService(AtomRegistry.AtomRegistry, registry)`. Keep the session atom in the auth owner's registry, above any session boundary whose subtree it replaces. The application owns when to refresh; this adapter does not subscribe to Better Auth's hook or store.
873
+ `session.refresh` uses the native `AtomRegistry` service supplied by action atoms and atom runtimes. For an Effect run outside an atom, provide the registry that renders the session with `Effect.provideService(AtomRegistry.AtomRegistry, registry)`. Keep the session atom in the auth owner's registry, above any session boundary whose subtree it replaces. The application owns when to refresh; the session atom does not subscribe to Better Auth's hook or store.
863
874
 
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.
875
+ For other Better Auth reads, `authQuery` from `@shivaedev/react/client/authQuery.ts` creates an input-keyed query atom family. Pass an input-to-Effect function, such as the result of `authQuery` from `@shivaedev/identity/client/adapters/authQuery.ts`, then render its atom with `useQuery`. Releasing a pending read interrupts its Effect and aborts the supplied signal.
865
876
 
866
877
  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.
867
878
 
@@ -875,7 +886,9 @@ These rules apply to each component and test you write.
875
886
 
876
887
  Changing the `fields` schema or `runtime` by reference replaces either hook's form and discards its in-memory draft and submission state. A changed editor `query` also starts a new form. Keep schemas, runtimes and query atoms outside components or memoize them; constructing a schema on every render continually replaces the form.
877
888
 
878
- `initialValues` (create), `values` (editor) and `persistedDraft` are setup options, captured when the hook first creates a form and again when `fields`, `runtime` or editor `query` changes. Successful creates reuse the captured initial values and persistence options for the next entry. Changing setup options alone does not replace an existing form; remount the component with a different React `key` to apply them. An editor's `loaded` value remains a fallback for query data, as with `useLoaderQuery`.
889
+ `useEditor`, `useCreate` and the lower-level `submission` accept form’s `requiredMessages`, `checks`, `debounce` and `arrayKeys`. Required wording and checks use encoded field names and values; check services come from the supplied runtime, and array key selectors receive encoded elements. Form owns check scheduling, stale feedback and keyed rejection tracking.
890
+
891
+ `initialValues` (create), `values` (editor), `persistedDraft`, `requiredMessages`, `checks`, `debounce` and `arrayKeys` are setup options, captured when the hook first creates a form and again when `fields`, `runtime` or editor `query` changes. Successful creates reuse the captured setup options for the next entry. Changing setup options alone does not replace an existing form; remount the component with a different React `key` to apply them. An editor's `loaded` value remains a fallback for query data, as with `useLoaderQuery`.
879
892
 
880
893
  #### Resume and refresh policy
881
894
 
@@ -919,87 +932,118 @@ Without a runtime it uses a native empty atom runtime. Stories supply a runtime
919
932
 
920
933
  #### Render tests in happy-dom
921
934
 
922
- Use `@shivaedev/test-story/client/react.ts` with Vitest's `happy-dom` environment. Install contract and changes for the example's query, command and key declarations, and the testing peers and environment in your app's dev dependencies:
935
+ Use `@shivaedev/test-story/client/adapters/react.ts` with Vitest's `happy-dom` environment. Install contract and changes for the example's query, command and key declarations, and the testing peers and environment in your app's dev dependencies:
923
936
 
924
937
  ```sh
925
938
  pnpm add @shivaedev/changes @shivaedev/contract
926
939
  pnpm add -D @shivaedev/test-story @effect/platform-node @effect/vitest vitest happy-dom react-dom @types/react-dom
927
940
  ```
928
941
 
929
- Configure Vitest with `test: { environment: "happy-dom" }`, or select that environment for your DOM test project. This complete `notes.dom.test.tsx` renders a component that runs a declared query and command against native RPC test handlers:
942
+ 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:
930
943
 
931
944
  ```tsx
932
945
  import { Effect, Layer, Option, Ref, Schema, Stream } from "effect";
933
946
  import { act, createElement } from "react";
934
- import { expect } from "vitest";
947
+ import { collection } from "@shivaedev/changes/keys.ts";
935
948
  import { makeClient } from "@shivaedev/contract/bind.ts";
936
949
  import { contract } from "@shivaedev/contract/contract.ts";
937
- import { collection } from "@shivaedev/changes/keys.ts";
938
950
  import { command, query } from "@shivaedev/contract/operation.ts";
939
951
  import { layerMemoryProtocol } from "@shivaedev/contract/testing.ts";
952
+ import { screenPending } from "@shivaedev/react/adapters/screenPending.ts";
940
953
  import { useAction, useQuery } from "@shivaedev/react/client/resultState.ts";
941
- import { eventually, expectNoReactWarnings, render } from "@shivaedev/test-story/client/react.ts";
942
- import { it } from "@shivaedev/test/it.ts";
943
-
944
- Object.assign(globalThis, { "IS_REACT_ACT_ENVIRONMENT": true });
945
- expectNoReactWarnings();
954
+ import { render } from "@shivaedev/test-story/client/adapters/react.ts";
955
+ import { screenDriver } from "@shivaedev/test-story/server/screenDriver.ts";
956
+ import { storyKit } from "@shivaedev/test-story/server/storyKit.ts";
957
+ import * as AtomRegistry from "effect/reactivity/AtomRegistry";
946
958
 
947
959
  const notes = collection("notes", Schema.Number);
948
960
  const List = query("list", { readPolicy: () => Effect.succeed(true), reads: () => [notes.list], success: Schema.Array(Schema.String) });
949
961
  const Add = command("add", { invalidates: () => [notes.list], payload: { title: Schema.String } });
950
962
  const Notes = contract("notes", { commands: [Add], queries: [List] });
951
963
 
952
- const handlers = Notes.toLayer(
953
- Effect.gen(function* () {
954
- const stored = yield* Ref.make<readonly string[]>([]);
955
- return Notes.of({
956
- "notes.$changes": () => Stream.never,
957
- "notes.add": ({ title }) => Ref.update(stored, (all) => [...all, title]),
958
- "notes.list": () => Ref.get(stored).pipe(Effect.delay("20 millis")),
964
+ export const notesScreen = storyKit({
965
+ clock: "live",
966
+ *create() {
967
+ const handlers = Notes.toLayer(
968
+ Effect.gen(function* () {
969
+ const stored = yield* Ref.make<readonly string[]>([]);
970
+ return Notes.of({
971
+ "notes.$changes": () => Stream.never,
972
+ "notes.add": ({ title }) => Ref.update(stored, (all) => [...all, title]),
973
+ "notes.list": () => Ref.get(stored),
974
+ });
975
+ }),
976
+ );
977
+ const { api, Client } = makeClient(Notes, {
978
+ live: false,
979
+ protocol: layerMemoryProtocol(Notes).pipe(Layer.provide(handlers)),
980
+ url: "memory://notes",
959
981
  });
960
- }),
961
- );
962
- const { api, Client } = makeClient(Notes, {
963
- live: false,
964
- protocol: layerMemoryProtocol(Notes).pipe(Layer.provide(handlers)),
965
- url: "memory://notes",
966
- });
967
- const add = Client.runtime.fn(api.add.run);
968
- function NotesView() {
969
- const list = useQuery(api.list.query());
970
- const action = useAction(add);
971
- return createElement(
972
- "section",
973
- null,
974
- createElement("output", null, Option.getOrElse(list.data, () => []).join(", ")),
975
- createElement(
976
- "button",
977
- {
978
- disabled: list.pending || action.pending,
979
- onClick: () => action.dispatch({ title: "Morning walk" }),
980
- type: "button",
982
+ const add = Client.runtime.fn(api.add.run);
983
+ function NotesView() {
984
+ const list = useQuery(api.list.query());
985
+ const action = useAction(add);
986
+ return createElement(
987
+ "section",
988
+ null,
989
+ createElement("output", null, Option.getOrElse(list.data, () => []).join(", ")),
990
+ createElement(
991
+ "button",
992
+ {
993
+ disabled: list.pending || action.pending,
994
+ onClick: () => action.dispatch({ title: "Morning walk" }),
995
+ type: "button",
996
+ },
997
+ "Add",
998
+ ),
999
+ );
1000
+ }
1001
+ const view = yield* Effect.acquireRelease(
1002
+ Effect.promise(() => render(createElement(NotesView))),
1003
+ (mounted) => Effect.promise(mounted.unmount),
1004
+ );
1005
+ const pending = yield* screenPending().pipe(Effect.provideService(AtomRegistry.AtomRegistry, view.registry));
1006
+ return { pending, view };
1007
+ },
1008
+ inspect: ({ view }) => ({ screen: view.container.textContent }),
1009
+ name: "notes screen",
1010
+ stages: ["screen"],
1011
+ verbs: ({ pending, view }, story) =>
1012
+ screenDriver({
1013
+ act: async (action) => {
1014
+ await act(action);
981
1015
  },
982
- "Add",
983
- ),
984
- );
985
- }
1016
+ pending,
1017
+ root: view.container,
1018
+ tell: story.tell,
1019
+ }),
1020
+ });
1021
+ ```
986
1022
 
987
- it.live("renders a query and refetches it after a command through a test RPC layer", function* () {
988
- const view = yield* Effect.acquireRelease(
989
- Effect.promise(() => render(createElement(NotesView))),
990
- (view) => Effect.promise(view.unmount),
991
- );
992
- yield* eventually(() => expect(view.container.querySelector("button")?.disabled).toBe(false));
993
- expect(view.container.querySelector("output")?.textContent).toBe("");
994
- yield* Effect.promise(() => act(async () => view.container.querySelector("button")?.click()));
995
- yield* eventually(() => {
996
- expect(view.container.querySelector("output")?.textContent).toBe("Morning walk");
997
- expect(view.container.querySelector("button")?.disabled).toBe(false);
998
- });
1023
+ 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:
1024
+
1025
+ ```tsx
1026
+ import { expect } from "vitest";
1027
+ import { expectNoReactWarnings } from "@shivaedev/test-story/client/adapters/react.ts";
1028
+ import { notesScreen } from "#test/notesScreen.tsx";
1029
+
1030
+ Object.assign(globalThis, { "IS_REACT_ACT_ENVIRONMENT": true });
1031
+ expectNoReactWarnings();
1032
+
1033
+ notesScreen.it("a command refetches the rendered notes through native RPC", [], function* ({ click, settle, text }) {
1034
+ yield* settle();
1035
+ expect(text("output")).toBe("");
1036
+
1037
+ yield* click({ name: "Add", role: "button" });
1038
+ yield* settle();
1039
+
1040
+ expect(text("output")).toBe("Morning walk");
999
1041
  });
1000
1042
  ```
1001
1043
 
1002
- `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`. In Effect tests, acquire the view with `Effect.acquireRelease` so its scope releases it on success, failure or interruption. In async tests, unmount in `finally`. Keep component interactions inside React's `act`. `eventually(assert)` returns an Effect: yield it directly in a story or Effect test, keeping the expectation in the spec. It retries for up to three seconds in live time, allowing pending responses to settle inside `act` between attempts without advancing the story’s TestClock. A timeout fails with an Error whose message includes the elapsed milliseconds and last assertion message, and whose `cause` is that assertion error. In an async test, use `await Effect.runPromise(eventually(assert))`. `expectNoReactWarnings()` registers a Vitest hook that fails a test if it logged to `console.error`.
1044
+ `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.
1045
+
1046
+ `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`.
1003
1047
 
1004
1048
  The RPC layer stays application-owned: replace these in-memory handlers with the service Layer your component needs.
1005
1049
 
@@ -1019,7 +1063,7 @@ screenStories.it("shows the route failure", [], async () => {
1019
1063
  });
1020
1064
  ```
1021
1065
 
1022
- 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.
1066
+ Story kits can acquire `captureReactWarnings` from `@shivaedev/test-story/client/adapters/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.
1023
1067
 
1024
1068
  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:
1025
1069
 
@@ -1044,7 +1088,7 @@ const screen = screenDriver({ act, pending, root: view.container, tell: story.te
1044
1088
 
1045
1089
  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.
1046
1090
 
1047
- 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 `fieldRejection.ts` maps save failures through a submitter, and `useSaveState` from `client/saveState.ts` observes submission and invokes a success callback.
1091
+ 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`.
1048
1092
 
1049
1093
  ### Install, setup and limits
1050
1094
 
@@ -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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=AtomServices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AtomServices.js","sourceRoot":"","sources":["../src/AtomServices.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"loadQuery.d.ts","sourceRoot":"","sources":["../../src/adapters/loadQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,KAAK,KAAK,WAAW,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,KAAK,IAAI,MAAM,wBAAwB,CAAC;AACpD,OAAO,KAAK,YAAY,MAAM,gCAAgC,CAAC;AAI/D,wBAAsB,SAAS,CAAC,CAAC,EAAE,CAAC,EACnC,QAAQ,EAAE,YAAY,CAAC,YAAY,EACnC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAC9C,EAAE,eAAe,EAAE,EAAE,IAAI,CAAC,eAAe,EAAE,iBAAiB,CAAC,GAC3D,OAAO,CAAC,CAAC,CAAC,CAqBZ"}
1
+ {"version":3,"file":"loadQuery.d.ts","sourceRoot":"","sources":["../../src/adapters/loadQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,KAAK,KAAK,WAAW,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,KAAK,IAAI,MAAM,wBAAwB,CAAC;AACpD,OAAO,KAAK,YAAY,MAAM,gCAAgC,CAAC;AAI/D,wBAAsB,SAAS,CAAC,CAAC,EAAE,CAAC,EACnC,QAAQ,EAAE,YAAY,CAAC,YAAY,EACnC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAC9C,EAAE,eAAe,EAAE,EAAE,IAAI,CAAC,eAAe,EAAE,iBAAiB,CAAC,GAC3D,OAAO,CAAC,CAAC,CAAC,CAoBZ"}
@@ -14,7 +14,6 @@ export async function loadQuery(registry, atom, { abortController }) {
14
14
  return result.success;
15
15
  }
16
16
  catch (error) {
17
- handoff.release();
18
17
  if (signal.aborted) {
19
18
  const canceled = new Error("Query loading canceled", { cause: error });
20
19
  canceled.name = "AbortError";
@@ -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,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;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  import type { Permission } from "@shivaedev/access/permission.ts";
3
- import { type PermissionSession } from "#permissions.ts";
3
+ import type { PermissionSession } from "@shivaedev/identity/PermissionSession.ts";
4
4
  export interface PermissionBoundaryProps {
5
5
  readonly children: ReactNode;
6
6
  readonly fallback: ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"permissionBoundary.d.ts","sourceRoot":"","sources":["../../src/adapters/permissionBoundary.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,KAAK,SAAS,EAAc,MAAM,OAAO,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAGlE,OAAO,EAAO,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAE9D,MAAM,WAAW,uBAAuB;IACvC,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,GAAG,SAAS,CAAC;CACvD;AAED,wBAAgB,MAAM,IAAI,CAAC,UAAU,EAAE,UAAU,KAAK,OAAO,CAG5D;AAED,wBAAgB,uBAAuB,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,CAMzF;AAED,wBAAgB,kBAAkB,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,uBAAuB,GAAG,SAAS,CAMtG"}
1
+ {"version":3,"file":"permissionBoundary.d.ts","sourceRoot":"","sources":["../../src/adapters/permissionBoundary.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,KAAK,SAAS,EAAc,MAAM,OAAO,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAElE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAIlF,MAAM,WAAW,uBAAuB;IACvC,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,GAAG,SAAS,CAAC;CACvD;AAED,wBAAgB,MAAM,IAAI,CAAC,UAAU,EAAE,UAAU,KAAK,OAAO,CAG5D;AAED,wBAAgB,uBAAuB,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,CAMzF;AAED,wBAAgB,kBAAkB,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,uBAAuB,GAAG,SAAS,CAMtG"}
@@ -1,8 +1,8 @@
1
1
  import { CatchBoundary } from "@tanstack/react-router";
2
2
  import { createElement, useContext } from "react";
3
3
  import { isForbidden } from "@shivaedev/errors/taxonomy.ts";
4
+ import { can } from "#can.ts";
4
5
  import { PermissionContext } from "#internal/PermissionContext.ts";
5
- import { can } from "#permissions.ts";
6
6
  export function useCan() {
7
7
  const context = useContext(PermissionContext);
8
8
  return (permission) => can(context?.session, permission);
@@ -1 +1 @@
1
- {"version":3,"file":"permissionBoundary.js","sourceRoot":"","sources":["../../src/adapters/permissionBoundary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAkB,UAAU,EAAE,MAAM,OAAO,CAAC;AAElE,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,GAAG,EAA0B,MAAM,iBAAiB,CAAC;AAQ9D,MAAM,UAAU,MAAM;IACrB,MAAM,OAAO,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAC9C,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,OAA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,GAAG,UAAU,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,5 +1,5 @@
1
1
  import type { Permission } from "@shivaedev/access/permission.ts";
2
- import { type PermissionSession } from "#permissions.ts";
2
+ import type { PermissionSession } from "@shivaedev/identity/PermissionSession.ts";
3
3
  import { type SignInLocation } from "#signInSearch.ts";
4
4
  declare module "@tanstack/react-router" {
5
5
  interface StaticDataRouteOption {
@@ -1 +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,C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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,6 +1,6 @@
1
1
  import { notFound, redirect } from "@tanstack/react-router";
2
2
  import { forbidden } from "@shivaedev/access/refusal.ts";
3
- import { can } from "#permissions.ts";
3
+ import { can } from "#can.ts";
4
4
  import { signInSearch } from "#signInSearch.ts";
5
5
  export function permissionGuard({ session, signIn, hidden = false }) {
6
6
  return ({ matches, location }) => {
@@ -1 +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,GAAG,EAA0B,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAuB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAoBrE,MAAM,UAAU,eAAe,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,KAAK,EAA0B;IAC1F,OAAO,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;QAChC,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC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AAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAC9H,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,KAAK,IAAI,CAAC,EAAE,CAAC;YAC3F,OAAO;QACR,CAAC;QACD,MAAM,OAAO,GAAG,OAAO,EAAE,CAAC;QAC1B,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC/C,MAAM,QAAQ,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;QAChE,CAAC;QACD,KAAK,MAAM,UAAU,IAAI,QAAQ,EAAE,CAAC;YACnC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,CAAC;gBAC/B,MAAM,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;YACnD,CAAC;QACF,CAAC;IACF,CAAC,CAAC;AACH,CAAC"}
package/dist/can.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import { type Permission } from "@shivaedev/access/permission.ts";
2
+ import type { PermissionSession } from "@shivaedev/identity/PermissionSession.ts";
3
+ export declare function can(session: PermissionSession | null | undefined, permission: Permission): boolean;
4
+ //# sourceMappingURL=can.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"can.d.ts","sourceRoot":"","sources":["../src/can.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,iCAAiC,CAAC;AACjF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAElF,wBAAgB,GAAG,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,GAAG,SAAS,EAAE,UAAU,EAAE,UAAU,GAAG,OAAO,CAElG"}
package/dist/can.js ADDED
@@ -0,0 +1,5 @@
1
+ import { hasPermission } from "@shivaedev/access/permission.ts";
2
+ export function can(session, permission) {
3
+ return hasPermission(session?.user.permissions, permission);
4
+ }
5
+ //# sourceMappingURL=can.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"can.js","sourceRoot":"","sources":["../src/can.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAmB,MAAM,iCAAiC,CAAC;AAGjF,MAAM,UAAU,GAAG,CAAC,OAA6C,EAAE,UAAsB;IACxF,OAAO,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;AAC7D,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { Effect } from "effect";
2
2
  import type * as Atom from "effect/reactivity/Atom";
3
- import type { AtomServices } from "#fieldRejection.ts";
3
+ import type { AtomServices } from "#AtomServices.ts";
4
4
  import type { NoticeFeedback } from "#notices.ts";
5
5
  export interface ActionOptions<TInput, A, E, R = never> {
6
6
  readonly concurrent?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"actionCompletion.d.ts","sourceRoot":"","sources":["../../src/client/actionCompletion.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAEpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD,MAAM,WAAW,aAAa,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,KAAK;IACrD,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC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rD,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvD,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACvD;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,aAAa,EAC7D,MAAM,EAAE,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,EAAE,aAAa,CAAC,EAC5E,GAAG,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,EAC1E,OAAO,EAAE,aAAa,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GACrC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,CA4DjD"}
@@ -3,8 +3,8 @@ import { Effect } from "effect";
3
3
  import * as AtomRegistry from "effect/reactivity/AtomRegistry";
4
4
  import { createElement, useEffect, useState } from "react";
5
5
  import { LiveConnection } from "@shivaedev/contract/automaticLive.ts";
6
+ import { liveBindings } from "@shivaedev/contract/composeBindings.ts";
6
7
  import { mountLive } from "#client/mountLive.ts";
7
- import { liveBindings } from "#internal/liveBindings.ts";
8
8
  import { RecheckContext } from "#internal/RecheckContext.ts";
9
9
  import { registerSessionRecheck } from "#internal/sessionRecheck.ts";
10
10
  import { useLatestCallback } from "#internal/useLatestCallback.ts";
@@ -1 +1 @@
1
- {"version":3,"file":"SessionGeneration.js","sourceRoot":"","sources":["../../../src/client/adapters/SessionGeneration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAiB,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,KAAK,YAAY,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAkB,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAOnE,SAAS,MAAM,CAAU,OAAyD,EAAE,QAA4B;IAC/G,MAAM,QAAQ,GAAG,YAAY,CAAC,IAAI,CAAC,EAAE,gBAAgB,EAAE,GAAG,EAAE,CAAC,CAAC;IAC9D,IAAI,MAA+C,CAAC;IACpD,OAAO;QACN,IAAI,MAAM;YACT,MAAM,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YACxC,KAAK,MAAM,OAAO,IAAI,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;gBAClD,MAAM,OAAO,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC;gBACjD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;oBAC3B,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;gBACjC,CAAC;YACF,CAAC;YACD,OAAO,MAAM,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,MAAM,EAAE,kBAAkB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,YAAY,CAAC,YAAY,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAClH,CAAC;QACF,OAAO,GAAG,EAAE;YACX,QAAQ,EAAE,CAAC;YACX,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;YACnB,cAAc,CAAC,GAAG,EAAE;gBACnB,IAAI,KAAK,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC;oBACvB,OAAO;gBACR,CAAC;gBACD,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;gBACzB,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;YAC1E,CAAC,CAAC,CAAC;QACJ,CAAC,CAAC;IACH,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,kBAAkB,EAAE,IAAI,CAAC,CAAC,CAAC;IAChD,OAAO,aAAa,CACnB,cAAc,CAAC,QAAQ,EACvB,EAAE,KAAK,EAAE,aAAa,EAAE,EACxB,aAAa,CAAC,eAAe,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAC1F,CAAC;AACH,CAAC"}
@@ -1,18 +1,4 @@
1
- import { Effect, Schema } from "effect";
1
+ import type { Effect } from "effect";
2
2
  import * as Atom from "effect/reactivity/Atom";
3
- export interface AuthActionResult<A, E> {
4
- readonly data: A;
5
- readonly error: E | null;
6
- }
7
- export declare const AuthFailureCode: Schema.Literals<readonly ["USER_NOT_FOUND", "FAILED_TO_CREATE_USER", "FAILED_TO_CREATE_SESSION", "FAILED_TO_UPDATE_USER", "FAILED_TO_GET_SESSION", "INVALID_PASSWORD", "INVALID_EMAIL", "INVALID_EMAIL_OR_PASSWORD", "INVALID_USER", "SOCIAL_ACCOUNT_ALREADY_LINKED", "PROVIDER_NOT_FOUND", "INVALID_TOKEN", "TOKEN_EXPIRED", "ID_TOKEN_NOT_SUPPORTED", "FAILED_TO_GET_USER_INFO", "USER_EMAIL_NOT_FOUND", "EMAIL_NOT_VERIFIED", "PASSWORD_TOO_SHORT", "PASSWORD_TOO_LONG", "USER_ALREADY_EXISTS", "USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL", "EMAIL_CAN_NOT_BE_UPDATED", "CHANGE_EMAIL_DISABLED", "CREDENTIAL_ACCOUNT_NOT_FOUND", "SESSION_EXPIRED", "FAILED_TO_UNLINK_LAST_ACCOUNT", "ACCOUNT_NOT_FOUND", "USER_ALREADY_HAS_PASSWORD", "CROSS_SITE_NAVIGATION_LOGIN_BLOCKED", "VERIFICATION_EMAIL_NOT_ENABLED", "EMAIL_ALREADY_VERIFIED", "EMAIL_MISMATCH", "SESSION_NOT_FRESH", "LINKED_ACCOUNT_ALREADY_EXISTS", "INVALID_ORIGIN", "INVALID_CALLBACK_URL", "INVALID_REDIRECT_URL", "INVALID_ERROR_CALLBACK_URL", "INVALID_NEW_USER_CALLBACK_URL", "MISSING_OR_NULL_ORIGIN", "CALLBACK_URL_REQUIRED", "FAILED_TO_CREATE_VERIFICATION", "FIELD_NOT_ALLOWED", "ASYNC_VALIDATION_NOT_SUPPORTED", "VALIDATION_ERROR", "MISSING_FIELD", "METHOD_NOT_ALLOWED_DEFER_SESSION_REQUIRED", "BODY_MUST_BE_AN_OBJECT", "PASSWORD_ALREADY_SET", "RATE_LIMITED", "UNKNOWN"]>;
8
- export type AuthFailureCode = typeof AuthFailureCode.Type;
9
- declare const AuthFailure_base: Schema.Class<AuthFailure, Schema.TaggedStruct<"AuthFailure", {
10
- readonly cause: Schema.Unknown;
11
- readonly code: Schema.Literals<readonly ["USER_NOT_FOUND", "FAILED_TO_CREATE_USER", "FAILED_TO_CREATE_SESSION", "FAILED_TO_UPDATE_USER", "FAILED_TO_GET_SESSION", "INVALID_PASSWORD", "INVALID_EMAIL", "INVALID_EMAIL_OR_PASSWORD", "INVALID_USER", "SOCIAL_ACCOUNT_ALREADY_LINKED", "PROVIDER_NOT_FOUND", "INVALID_TOKEN", "TOKEN_EXPIRED", "ID_TOKEN_NOT_SUPPORTED", "FAILED_TO_GET_USER_INFO", "USER_EMAIL_NOT_FOUND", "EMAIL_NOT_VERIFIED", "PASSWORD_TOO_SHORT", "PASSWORD_TOO_LONG", "USER_ALREADY_EXISTS", "USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL", "EMAIL_CAN_NOT_BE_UPDATED", "CHANGE_EMAIL_DISABLED", "CREDENTIAL_ACCOUNT_NOT_FOUND", "SESSION_EXPIRED", "FAILED_TO_UNLINK_LAST_ACCOUNT", "ACCOUNT_NOT_FOUND", "USER_ALREADY_HAS_PASSWORD", "CROSS_SITE_NAVIGATION_LOGIN_BLOCKED", "VERIFICATION_EMAIL_NOT_ENABLED", "EMAIL_ALREADY_VERIFIED", "EMAIL_MISMATCH", "SESSION_NOT_FRESH", "LINKED_ACCOUNT_ALREADY_EXISTS", "INVALID_ORIGIN", "INVALID_CALLBACK_URL", "INVALID_REDIRECT_URL", "INVALID_ERROR_CALLBACK_URL", "INVALID_NEW_USER_CALLBACK_URL", "MISSING_OR_NULL_ORIGIN", "CALLBACK_URL_REQUIRED", "FAILED_TO_CREATE_VERIFICATION", "FIELD_NOT_ALLOWED", "ASYNC_VALIDATION_NOT_SUPPORTED", "VALIDATION_ERROR", "MISSING_FIELD", "METHOD_NOT_ALLOWED_DEFER_SESSION_REQUIRED", "BODY_MUST_BE_AN_OBJECT", "PASSWORD_ALREADY_SET", "RATE_LIMITED", "UNKNOWN"]>;
12
- }>, import("effect/Cause").YieldableError>;
13
- export declare class AuthFailure extends AuthFailure_base {
14
- }
15
- export declare function authCall<TInput, A, E extends object = never>(run: (input: TInput, signal: AbortSignal) => Promise<AuthActionResult<A, E>>): (input: TInput) => Effect.Effect<A, AuthFailure>;
16
- export declare function authAction<TInput, A, E extends object = never>(run: (input: TInput, signal: AbortSignal) => Promise<AuthActionResult<A, E>>): Atom.AtomResultFn<TInput, A, AuthFailure>;
17
- export {};
3
+ export declare function authAction<TInput, A, E>(run: (input: TInput) => Effect.Effect<A, E>): Atom.AtomResultFn<TInput, A, E>;
18
4
  //# sourceMappingURL=authAction.d.ts.map