@shivaedev/react 0.34.0 → 0.36.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 (109) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +37 -24
  3. package/dist/adapters/loadQuery.d.ts.map +1 -1
  4. package/dist/adapters/loadQuery.js +0 -1
  5. package/dist/adapters/loadQuery.js.map +1 -1
  6. package/dist/adapters/permissionBoundary.d.ts +1 -1
  7. package/dist/adapters/permissionBoundary.d.ts.map +1 -1
  8. package/dist/adapters/permissionBoundary.js +1 -1
  9. package/dist/adapters/permissionBoundary.js.map +1 -1
  10. package/dist/adapters/permissionGuard.d.ts +1 -1
  11. package/dist/adapters/permissionGuard.d.ts.map +1 -1
  12. package/dist/adapters/permissionGuard.js +1 -1
  13. package/dist/adapters/permissionGuard.js.map +1 -1
  14. package/dist/can.d.ts +4 -0
  15. package/dist/can.d.ts.map +1 -0
  16. package/dist/can.js +5 -0
  17. package/dist/can.js.map +1 -0
  18. package/dist/client/adapters/SessionGeneration.js +2 -2
  19. package/dist/client/adapters/SessionGeneration.js.map +1 -1
  20. package/dist/client/authAction.d.ts +2 -16
  21. package/dist/client/authAction.d.ts.map +1 -1
  22. package/dist/client/authAction.js +1 -77
  23. package/dist/client/authAction.js.map +1 -1
  24. package/dist/client/authQuery.d.ts +2 -3
  25. package/dist/client/authQuery.d.ts.map +1 -1
  26. package/dist/client/authQuery.js +2 -7
  27. package/dist/client/authQuery.js.map +1 -1
  28. package/dist/client/authSession.d.ts +3 -9
  29. package/dist/client/authSession.d.ts.map +1 -1
  30. package/dist/client/authSession.js +2 -19
  31. package/dist/client/authSession.js.map +1 -1
  32. package/dist/client/create.d.ts +2 -1
  33. package/dist/client/create.d.ts.map +1 -1
  34. package/dist/client/create.js +2 -2
  35. package/dist/client/create.js.map +1 -1
  36. package/dist/client/editor.d.ts +2 -1
  37. package/dist/client/editor.d.ts.map +1 -1
  38. package/dist/client/editor.js +2 -1
  39. package/dist/client/editor.js.map +1 -1
  40. package/dist/client/mountLive.js +1 -1
  41. package/dist/client/mountLive.js.map +1 -1
  42. package/dist/client/resultState.js +2 -2
  43. package/dist/client/resultState.js.map +1 -1
  44. package/dist/internal/PermissionContext.d.ts +1 -1
  45. package/dist/internal/PermissionContext.d.ts.map +1 -1
  46. package/dist/internal/adapters/useLatestCallback.d.ts.map +1 -0
  47. package/dist/internal/adapters/useLatestCallback.js.map +1 -0
  48. package/dist/internal/adapters/useNoticePublisher.d.ts.map +1 -0
  49. package/dist/internal/{useNoticePublisher.js → adapters/useNoticePublisher.js} +2 -2
  50. package/dist/internal/adapters/useNoticePublisher.js.map +1 -0
  51. package/dist/internal/adapters/usePermissionFailure.d.ts.map +1 -0
  52. package/dist/internal/{usePermissionFailure.js → adapters/usePermissionFailure.js} +1 -1
  53. package/dist/internal/adapters/usePermissionFailure.js.map +1 -0
  54. package/dist/internal/adapters/useQueryNotice.d.ts.map +1 -0
  55. package/dist/internal/{useQueryNotice.js → adapters/useQueryNotice.js} +2 -2
  56. package/dist/internal/adapters/useQueryNotice.js.map +1 -0
  57. package/dist/internal/adapters/useSubmissionCallbacks.d.ts.map +1 -0
  58. package/dist/internal/adapters/useSubmissionCallbacks.js.map +1 -0
  59. package/dist/submission.d.ts +2 -2
  60. package/dist/submission.d.ts.map +1 -1
  61. package/dist/submission.js +4 -0
  62. package/dist/submission.js.map +1 -1
  63. package/package.json +14 -13
  64. package/src/adapters/loadQuery.ts +0 -1
  65. package/src/adapters/permissionBoundary.ts +2 -1
  66. package/src/adapters/permissionGuard.ts +2 -1
  67. package/src/can.ts +6 -0
  68. package/src/client/adapters/SessionGeneration.ts +2 -2
  69. package/src/client/authAction.ts +3 -94
  70. package/src/client/authQuery.ts +3 -14
  71. package/src/client/authSession.ts +5 -34
  72. package/src/client/create.ts +5 -4
  73. package/src/client/editor.ts +5 -3
  74. package/src/client/mountLive.ts +1 -1
  75. package/src/client/resultState.ts +2 -2
  76. package/src/internal/PermissionContext.ts +1 -1
  77. package/src/internal/{useNoticePublisher.ts → adapters/useNoticePublisher.ts} +2 -2
  78. package/src/internal/{usePermissionFailure.ts → adapters/usePermissionFailure.ts} +1 -1
  79. package/src/internal/{useQueryNotice.ts → adapters/useQueryNotice.ts} +2 -2
  80. package/src/submission.ts +7 -2
  81. package/dist/internal/liveBindings.d.ts +0 -3
  82. package/dist/internal/liveBindings.d.ts.map +0 -1
  83. package/dist/internal/liveBindings.js +0 -10
  84. package/dist/internal/liveBindings.js.map +0 -1
  85. package/dist/internal/useLatestCallback.d.ts.map +0 -1
  86. package/dist/internal/useLatestCallback.js.map +0 -1
  87. package/dist/internal/useNoticePublisher.d.ts.map +0 -1
  88. package/dist/internal/useNoticePublisher.js.map +0 -1
  89. package/dist/internal/usePermissionFailure.d.ts.map +0 -1
  90. package/dist/internal/usePermissionFailure.js.map +0 -1
  91. package/dist/internal/useQueryNotice.d.ts.map +0 -1
  92. package/dist/internal/useQueryNotice.js.map +0 -1
  93. package/dist/internal/useSubmissionCallbacks.d.ts.map +0 -1
  94. package/dist/internal/useSubmissionCallbacks.js.map +0 -1
  95. package/dist/permissions.d.ts +0 -13
  96. package/dist/permissions.d.ts.map +0 -1
  97. package/dist/permissions.js +0 -9
  98. package/dist/permissions.js.map +0 -1
  99. package/src/internal/liveBindings.ts +0 -11
  100. package/src/permissions.ts +0 -11
  101. /package/dist/internal/{useLatestCallback.d.ts → adapters/useLatestCallback.d.ts} +0 -0
  102. /package/dist/internal/{useLatestCallback.js → adapters/useLatestCallback.js} +0 -0
  103. /package/dist/internal/{useNoticePublisher.d.ts → adapters/useNoticePublisher.d.ts} +0 -0
  104. /package/dist/internal/{usePermissionFailure.d.ts → adapters/usePermissionFailure.d.ts} +0 -0
  105. /package/dist/internal/{useQueryNotice.d.ts → adapters/useQueryNotice.d.ts} +0 -0
  106. /package/dist/internal/{useSubmissionCallbacks.d.ts → adapters/useSubmissionCallbacks.d.ts} +0 -0
  107. /package/dist/internal/{useSubmissionCallbacks.js → adapters/useSubmissionCallbacks.js} +0 -0
  108. /package/src/internal/{useLatestCallback.ts → adapters/useLatestCallback.ts} +0 -0
  109. /package/src/internal/{useSubmissionCallbacks.ts → adapters/useSubmissionCallbacks.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.36.0 - 2026-11-03
4
+
5
+ ### Breaking
6
+
7
+ - React hooks under `@shivaedev/react/internal/` now live under `@shivaedev/react/internal/adapters/`. Change imports of `useLatestCallback.ts`, `useNoticePublisher.ts`, `usePermissionFailure.ts`, `useQueryNotice.ts` and `useSubmissionCallbacks.ts` to that directory; their exports and behavior are unchanged.
8
+
9
+ ## 0.35.0 - 2026-11-03
10
+
11
+ ### Added
12
+
13
+ - 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.
14
+ - Accept and forward form's `requiredMessages`, `checks`, `debounce` and `arrayKeys` in editor, create and submission configurations, preserving encoded field types and runtime service requirements.
15
+
16
+ ### Fixed
17
+
18
+ - 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.
19
+ - Mounted session queries refresh after worker writes, and a denied recheck reaches the query as `QueryReadDenied`.
20
+
21
+ ### Breaking
22
+
23
+ - The `internal/liveBindings.ts` module is removed. Consumers that imported it must import `liveBindings` from `@shivaedev/contract/composeBindings.ts` instead.
24
+ - `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 }`.
25
+ - 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`.
26
+ - 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.
27
+ - 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.
28
+ - 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.
29
+
3
30
  ## 0.34.0 - 2026-11-02
4
31
 
5
32
  ### Breaking
package/README.md CHANGED
@@ -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`:
@@ -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:
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.
825
842
 
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`.
832
-
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,7 +932,7 @@ 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
@@ -935,10 +948,10 @@ 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
950
  import { command, query } from "@shivaedev/contract/operation.ts";
938
- import { layerMemoryProtocol } from "@shivaedev/contract/testing.ts";
951
+ import { layerMemoryProtocol } from "@shivaedev/test-kits/contract/testing.ts";
939
952
  import { screenPending } from "@shivaedev/react/adapters/screenPending.ts";
940
953
  import { useAction, useQuery } from "@shivaedev/react/client/resultState.ts";
941
- import { render } from "@shivaedev/test-story/client/react.ts";
954
+ import { render } from "@shivaedev/test-story/client/adapters/react.ts";
942
955
  import { screenDriver } from "@shivaedev/test-story/server/screenDriver.ts";
943
956
  import { storyKit } from "@shivaedev/test-story/server/storyKit.ts";
944
957
  import * as AtomRegistry from "effect/reactivity/AtomRegistry";
@@ -1011,7 +1024,7 @@ The spec drives one action and states what the screen shows. With `#test/*` mapp
1011
1024
 
1012
1025
  ```tsx
1013
1026
  import { expect } from "vitest";
1014
- import { expectNoReactWarnings } from "@shivaedev/test-story/client/react.ts";
1027
+ import { expectNoReactWarnings } from "@shivaedev/test-story/client/adapters/react.ts";
1015
1028
  import { notesScreen } from "#test/notesScreen.tsx";
1016
1029
 
1017
1030
  Object.assign(globalThis, { "IS_REACT_ACT_ENVIRONMENT": true });
@@ -1050,7 +1063,7 @@ screenStories.it("shows the route failure", [], async () => {
1050
1063
  });
1051
1064
  ```
1052
1065
 
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.
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.
1054
1067
 
1055
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:
1056
1069
 
@@ -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;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,CAAC,KAAK,UAAU,SAAS,CAC9B,QAAmC,EACnC,IAA8C,EAC9C,EAAE,eAAe,EAA4C;IAE7D,MAAM,EAAE,MAAM,EAAE,GAAG,eAAe,CAAC;IACnC,MAAM,OAAO,GAAG,eAAe,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IACxD,IAAI,CAAC;QACJ,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;QACtI,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC/B,MAAM,mBAAmB,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;YACpD,MAAM,MAAM,CAAC,OAAO,CAAC;QACtB,CAAC;QACD,OAAO,MAAM,CAAC,OAAO,CAAC;IACvB,CAAC;IAAC,OAAO,KAAK,EAAE,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MAAM,CAAC,OAAO,CAAC;QACtB,CAAC;QACD,OAAO,MAAM,CAAC,OAAO,CAAC;IACvB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,MAAM,QAAQ,GAAG,IAAI,KAAK,CAAC,wBAAwB,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;YACvE,QAAQ,CAAC,IAAI,GAAG,YAAY,CAAC;YAC7B,MAAM,QAAQ,CAAC;QAChB,CAAC;QACD,MAAM,KAAK,CAAC;IACb,CAAC;YAAS,CAAC;QACV,OAAO,CAAC,QAAQ,EAAE,CAAC;IACpB,CAAC;AACF,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { type ReactNode } from "react";
2
2
  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,OAAO,EAAE,UAAU,CAAC,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,EAAE,KAAK,EAA+B;IAC7E,MAAM,OAAO,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
+ {"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;AAE5D,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAQnE,MAAM,UAAU,MAAM;IACrB,MAAM,OAAO,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAC9C,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,EAAE,KAAK,EAA+B;IAC7E,MAAM,OAAO,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,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
+ {"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,KAAK,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAElF,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,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,E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,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"}
@@ -3,11 +3,11 @@ 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
+ import { useLatestCallback } from "#internal/adapters/useLatestCallback.ts";
8
9
  import { RecheckContext } from "#internal/RecheckContext.ts";
9
10
  import { registerSessionRecheck } from "#internal/sessionRecheck.ts";
10
- import { useLatestCallback } from "#internal/useLatestCallback.ts";
11
11
  function owning(connect, identity) {
12
12
  const registry = AtomRegistry.make({ "defaultIdleTTL": 400 });
13
13
  let client;
@@ -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,O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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
@@ -1 +1 @@
1
- {"version":3,"file":"authAction.d.ts","sourceRoot":"","sources":["../../src/client/authAction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAExC,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAE/C,MAAM,WAAW,gBAAgB,CAAC,CAAC,EAAE,CAAC;IACrC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IACjB,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;CACzB;AAED,eAAO,MAAM,eAAe,+xCAoD1B,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC,IAAI,CAAC;;;;;AAE1D,qBAAa,WAAY,SAAQ,gBAG/B;CAAG;AAIL,wBAAgB,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,KAAK,EAC3D,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAC1E,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,WAAW,CAAC,CAiBlD;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,KAAK,EAC7D,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAC1E,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE,WAAW,CAAC,CAE3C"}
1
+ {"version":3,"file":"authAction.d.ts","sourceRoot":"","sources":["../../src/client/authAction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAE/C,wBAAgB,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,CAErH"}
@@ -1,81 +1,5 @@
1
- import { Effect, Schema } from "effect";
2
- import * as HttpStatus from "effect/http/HttpStatus";
3
1
  import * as Atom from "effect/reactivity/Atom";
4
- export const AuthFailureCode = Schema.Literals([
5
- "USER_NOT_FOUND",
6
- "FAILED_TO_CREATE_USER",
7
- "FAILED_TO_CREATE_SESSION",
8
- "FAILED_TO_UPDATE_USER",
9
- "FAILED_TO_GET_SESSION",
10
- "INVALID_PASSWORD",
11
- "INVALID_EMAIL",
12
- "INVALID_EMAIL_OR_PASSWORD",
13
- "INVALID_USER",
14
- "SOCIAL_ACCOUNT_ALREADY_LINKED",
15
- "PROVIDER_NOT_FOUND",
16
- "INVALID_TOKEN",
17
- "TOKEN_EXPIRED",
18
- "ID_TOKEN_NOT_SUPPORTED",
19
- "FAILED_TO_GET_USER_INFO",
20
- "USER_EMAIL_NOT_FOUND",
21
- "EMAIL_NOT_VERIFIED",
22
- "PASSWORD_TOO_SHORT",
23
- "PASSWORD_TOO_LONG",
24
- "USER_ALREADY_EXISTS",
25
- "USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL",
26
- "EMAIL_CAN_NOT_BE_UPDATED",
27
- "CHANGE_EMAIL_DISABLED",
28
- "CREDENTIAL_ACCOUNT_NOT_FOUND",
29
- "SESSION_EXPIRED",
30
- "FAILED_TO_UNLINK_LAST_ACCOUNT",
31
- "ACCOUNT_NOT_FOUND",
32
- "USER_ALREADY_HAS_PASSWORD",
33
- "CROSS_SITE_NAVIGATION_LOGIN_BLOCKED",
34
- "VERIFICATION_EMAIL_NOT_ENABLED",
35
- "EMAIL_ALREADY_VERIFIED",
36
- "EMAIL_MISMATCH",
37
- "SESSION_NOT_FRESH",
38
- "LINKED_ACCOUNT_ALREADY_EXISTS",
39
- "INVALID_ORIGIN",
40
- "INVALID_CALLBACK_URL",
41
- "INVALID_REDIRECT_URL",
42
- "INVALID_ERROR_CALLBACK_URL",
43
- "INVALID_NEW_USER_CALLBACK_URL",
44
- "MISSING_OR_NULL_ORIGIN",
45
- "CALLBACK_URL_REQUIRED",
46
- "FAILED_TO_CREATE_VERIFICATION",
47
- "FIELD_NOT_ALLOWED",
48
- "ASYNC_VALIDATION_NOT_SUPPORTED",
49
- "VALIDATION_ERROR",
50
- "MISSING_FIELD",
51
- "METHOD_NOT_ALLOWED_DEFER_SESSION_REQUIRED",
52
- "BODY_MUST_BE_AN_OBJECT",
53
- "PASSWORD_ALREADY_SET",
54
- "RATE_LIMITED",
55
- "UNKNOWN",
56
- ]);
57
- export class AuthFailure extends Schema.TaggedError()("AuthFailure", {
58
- cause: Schema.Unknown,
59
- code: AuthFailureCode,
60
- }) {
61
- }
62
- const supportedCode = Schema.is(AuthFailureCode);
63
- export function authCall(run) {
64
- return (input) => Effect.tryPromise({
65
- catch: (cause) => new AuthFailure({ cause, code: "UNKNOWN" }),
66
- try: (signal) => run(input, signal),
67
- }).pipe(Effect.flatMap(({ data, error }) => {
68
- if (error === null) {
69
- return Effect.succeed(data);
70
- }
71
- if ("code" in error && supportedCode(error.code)) {
72
- return Effect.fail(new AuthFailure({ cause: error, code: error.code }));
73
- }
74
- const code = "status" in error && error.status === HttpStatus.fromLiteral("TooManyRequests") ? "RATE_LIMITED" : "UNKNOWN";
75
- return Effect.fail(new AuthFailure({ cause: error, code }));
76
- }));
77
- }
78
2
  export function authAction(run) {
79
- return Atom.fn()(authCall(run));
3
+ return Atom.fn()(run);
80
4
  }
81
5
  //# sourceMappingURL=authAction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"authAction.js","sourceRoot":"","sources":["../../src/client/authAction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAC;AACrD,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAO/C,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,QAAQ,CAAC;IAC9C,gBAAgB;IAChB,uBAAuB;IACvB,0BAA0B;IAC1B,uBAAuB;IACvB,uBAAuB;IACvB,kBAAkB;IAClB,eAAe;IACf,2BAA2B;IAC3B,cAAc;IACd,+BAA+B;IAC/B,oBAAoB;IACpB,eAAe;IACf,eAAe;IACf,wBAAwB;IACxB,yBAAyB;IACzB,sBAAsB;IACtB,oBAAoB;IACpB,oBAAoB;IACpB,mBAAmB;IACnB,qBAAqB;IACrB,uCAAuC;IACvC,0BAA0B;IAC1B,uBAAuB;IACvB,8BAA8B;IAC9B,iBAAiB;IACjB,+BAA+B;IAC/B,mBAAmB;IACnB,2BAA2B;IAC3B,qCAAqC;IACrC,gCAAgC;IAChC,wBAAwB;IACxB,gBAAgB;I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AAC,CAAC;QACzE,CAAC;QACD,MAAM,IAAI,GAAG,QAAQ,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,UAAU,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC;QAC1H,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,WAAW,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC7D,CAAC,CAAC,CACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,UAAU,CACzB,GAA4E;IAE5E,OAAO,IAAI,CAAC,EAAE,EAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;AACzC,CAAC"}
1
+ {"version":3,"file":"authAction.js","sourceRoot":"","sources":["../../src/client/authAction.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAE/C,MAAM,UAAU,UAAU,CAAe,GAA2C;IACnF,OAAO,IAAI,CAAC,EAAE,EAAU,CAAC,GAAG,CAAC,CAAC;AAC/B,CAAC"}
@@ -1,6 +1,5 @@
1
+ import type { Effect } from "effect";
1
2
  import type * as AsyncResult from "effect/reactivity/AsyncResult";
2
3
  import * as Atom from "effect/reactivity/Atom";
3
- import { AuthUnavailable } from "@shivaedev/errors/taxonomy.ts";
4
- import type { AuthActionResult } from "./authAction.ts";
5
- export declare function authQuery<TInput, A, E extends object = never>(run: (input: TInput, signal: AbortSignal) => Promise<AuthActionResult<A, E>>): (input: TInput) => Atom.Atom<AsyncResult.AsyncResult<A, E | AuthUnavailable>>;
4
+ export declare function authQuery<TInput, A, E>(read: (input: TInput) => Effect.Effect<A, E>): (input: TInput) => Atom.Atom<AsyncResult.AsyncResult<A, E>>;
6
5
  //# sourceMappingURL=authQuery.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"authQuery.d.ts","sourceRoot":"","sources":["../../src/client/authQuery.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,WAAW,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,wBAAgB,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,KAAK,EAC5D,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAC1E,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,GAAG,eAAe,CAAC,CAAC,CAS/E"}
1
+ {"version":3,"file":"authQuery.d.ts","sourceRoot":"","sources":["../../src/client/authQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,KAAK,WAAW,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAE/C,wBAAgB,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAEjJ"}
@@ -1,10 +1,5 @@
1
- import { Effect } from "effect";
2
1
  import * as Atom from "effect/reactivity/Atom";
3
- import { AuthUnavailable } from "@shivaedev/errors/taxonomy.ts";
4
- export function authQuery(run) {
5
- return Atom.family((input) => Atom.make(Effect.tryPromise({
6
- catch: (cause) => new AuthUnavailable({ message: String(cause) }),
7
- try: (signal) => run(input, signal),
8
- }).pipe(Effect.flatMap((result) => (result.error === null ? Effect.succeed(result.data) : Effect.fail(result.error))))));
2
+ export function authQuery(read) {
3
+ return Atom.family((input) => Atom.make(read(input)));
9
4
  }
10
5
  //# sourceMappingURL=authQuery.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"authQuery.js","sourceRoot":"","sources":["../../src/client/authQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAGhE,MAAM,UAAU,SAAS,CACxB,GAA4E;IAE5E,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,KAAa,EAAE,EAAE,CACpC,IAAI,CAAC,IAAI,CACR,MAAM,CAAC,UAAU,CAAC;QACjB,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,eAAe,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QACjE,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC;KACnC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CACtH,CACD,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"authQuery.js","sourceRoot":"","sources":["../../src/client/authQuery.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAE/C,MAAM,UAAU,SAAS,CAAe,IAA4C;IACnF,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,KAAa,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC/D,CAAC"}
@@ -2,15 +2,9 @@ import { Effect } from "effect";
2
2
  import type * as AsyncResult from "effect/reactivity/AsyncResult";
3
3
  import * as Atom from "effect/reactivity/Atom";
4
4
  import * as AtomRegistry from "effect/reactivity/AtomRegistry";
5
- import { AuthUnavailable } from "@shivaedev/errors/taxonomy.ts";
6
- import { PermissionSession } from "#permissions.ts";
7
- import type { AuthActionResult } from "./authAction.ts";
8
5
  export interface AuthSession<A, E> {
9
- readonly atom: Atom.Atom<AsyncResult.AsyncResult<A, E | AuthUnavailable>>;
10
- readonly refresh: Effect.Effect<A, E | AuthUnavailable, AtomRegistry.AtomRegistry>;
6
+ readonly atom: Atom.Atom<AsyncResult.AsyncResult<A, E>>;
7
+ readonly refresh: Effect.Effect<A, E, AtomRegistry.AtomRegistry>;
11
8
  }
12
- export type SessionWithPermissions<A> = A extends null ? null : A & PermissionSession;
13
- export declare function authSession<A extends {
14
- readonly user: object;
15
- } | null, E extends object = never>(read: (signal: AbortSignal) => Promise<AuthActionResult<A, E>>): AuthSession<SessionWithPermissions<A>, E>;
9
+ export declare function authSession<A, E>(read: Effect.Effect<A, E>): AuthSession<A, E>;
16
10
  //# sourceMappingURL=authSession.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"authSession.d.ts","sourceRoot":"","sources":["../../src/client/authSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,KAAK,WAAW,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAC/C,OAAO,KAAK,YAAY,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA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W,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACxD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,YAAY,CAAC,YAAY,CAAC,CAAC;CACjE;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAQ9E"}
@@ -1,25 +1,8 @@
1
- import { Effect, Schema } from "effect";
1
+ import { Effect } from "effect";
2
2
  import * as Atom from "effect/reactivity/Atom";
3
3
  import * as AtomRegistry from "effect/reactivity/AtomRegistry";
4
- import { AuthUnavailable } from "@shivaedev/errors/taxonomy.ts";
5
- import { PermissionSession } from "#permissions.ts";
6
- function decodeSession(data) {
7
- if (data === null) {
8
- return Effect.succeed(null);
9
- }
10
- return Schema.decodeUnknownEffect(PermissionSession)(data).pipe(Effect.map((access) => ({ ...data, user: { ...data.user, ...access.user } })), Effect.mapError(() => new AuthUnavailable({ message: "Could not read session permissions" })));
11
- }
12
4
  export function authSession(read) {
13
- const atom = Atom.make(Effect.gen(function* () {
14
- const result = yield* Effect.tryPromise({
15
- catch: (cause) => new AuthUnavailable({ message: String(cause) }),
16
- try: read,
17
- });
18
- if (result.error !== null) {
19
- return yield* Effect.fail(result.error);
20
- }
21
- return yield* decodeSession(result.data);
22
- }));
5
+ const atom = Atom.make(read);
23
6
  const refresh = Effect.gen(function* () {
24
7
  const registry = yield* AtomRegistry.AtomRegistry;
25
8
  registry.refresh(atom);
@@ -1 +1 @@
1
- {"version":3,"file":"authSession.js","sourceRoot":"","sources":["../../src/client/authSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAExC,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAC/C,OAAO,KAAK,YAAY,MAAM,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AC,CAAC;IAC1C,CAAC,CAAC,CACF,CAAC;IACF,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QACnC,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,YAAY,CAAC,YAAY,CAAC;QAClD,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACvB,OAAO,KAAK,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAC;IAClF,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAC1B,CAAC"}
1
+ {"version":3,"file":"authSession.js","sourceRoot":"","sources":["../../src/client/authSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAC/C,OAAO,KAAK,YAAY,MAAM,gCAAgC,CAAC;AAO/D,MAAM,UAAU,WAAW,CAAO,IAAyB;IAC1D,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7B,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QACnC,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,YAAY,CAAC,YAAY,CAAC;QAClD,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACvB,OAAO,KAAK,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAC;IAClF,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAC1B,CAAC"}
@@ -5,6 +5,7 @@ import type { PersistedDraftConfig } from "@shivaedev/form/persistence.ts";
5
5
  import type { Decoded, Encoded, FieldFailure, Fields, Form, Services } from "@shivaedev/form/shape.ts";
6
6
  import type { AtomServices } from "#AtomServices.ts";
7
7
  import type { NoticeFeedback } from "#notices.ts";
8
+ import { type SubmissionConfig } from "#submission.ts";
8
9
  import { type SaveState } from "./saveState.ts";
9
10
  export type CreateConfig<TFields extends Fields, TCreated, TSaveError, R, TRuntimeError> = {
10
11
  readonly persistedDraft?: PersistedDraftConfig | undefined;
@@ -13,7 +14,7 @@ export type CreateConfig<TFields extends Fields, TCreated, TSaveError, R, TRunti
13
14
  readonly create: (values: Decoded<TFields>) => Effect.Effect<TCreated, TSaveError, AtomServices<R>>;
14
15
  readonly runtime: Atom.AtomRuntime<Services<TFields, R>, TRuntimeError>;
15
16
  readonly notices?: NoticeFeedback<Decoded<TFields>, TCreated, TSaveError, Services<TFields, R>>;
16
- } & FieldRejectionMapping<TFields, TSaveError>;
17
+ } & FieldRejectionMapping<TFields, TSaveError> & Pick<SubmissionConfig<TFields, TCreated, TSaveError, R, TRuntimeError>, "requiredMessages" | "checks" | "debounce" | "arrayKeys">;
17
18
  export interface Create<TFields extends Fields, TCreated, TSaveError, TRuntimeError> extends SaveState<TSaveError | TRuntimeError> {
18
19
  readonly created: Option.Option<TCreated>;
19
20
  readonly form: Form<TFields, TCreated, TSaveError | FieldFailure, TRuntimeError>;