@shivaedev/react 0.34.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.
- package/CHANGELOG.md +21 -0
- package/README.md +36 -23
- package/dist/adapters/loadQuery.d.ts.map +1 -1
- package/dist/adapters/loadQuery.js +0 -1
- package/dist/adapters/loadQuery.js.map +1 -1
- package/dist/adapters/permissionBoundary.d.ts +1 -1
- package/dist/adapters/permissionBoundary.d.ts.map +1 -1
- package/dist/adapters/permissionBoundary.js +1 -1
- package/dist/adapters/permissionBoundary.js.map +1 -1
- package/dist/adapters/permissionGuard.d.ts +1 -1
- package/dist/adapters/permissionGuard.d.ts.map +1 -1
- package/dist/adapters/permissionGuard.js +1 -1
- package/dist/adapters/permissionGuard.js.map +1 -1
- package/dist/can.d.ts +4 -0
- package/dist/can.d.ts.map +1 -0
- package/dist/can.js +5 -0
- package/dist/can.js.map +1 -0
- package/dist/client/adapters/SessionGeneration.js +1 -1
- package/dist/client/adapters/SessionGeneration.js.map +1 -1
- package/dist/client/authAction.d.ts +2 -16
- package/dist/client/authAction.d.ts.map +1 -1
- package/dist/client/authAction.js +1 -77
- package/dist/client/authAction.js.map +1 -1
- package/dist/client/authQuery.d.ts +2 -3
- package/dist/client/authQuery.d.ts.map +1 -1
- package/dist/client/authQuery.js +2 -7
- package/dist/client/authQuery.js.map +1 -1
- package/dist/client/authSession.d.ts +3 -9
- package/dist/client/authSession.d.ts.map +1 -1
- package/dist/client/authSession.js +2 -19
- package/dist/client/authSession.js.map +1 -1
- package/dist/client/create.d.ts +2 -1
- package/dist/client/create.d.ts.map +1 -1
- package/dist/client/create.js +1 -1
- package/dist/client/create.js.map +1 -1
- package/dist/client/editor.d.ts +2 -1
- package/dist/client/editor.d.ts.map +1 -1
- package/dist/client/editor.js +1 -0
- package/dist/client/editor.js.map +1 -1
- package/dist/client/mountLive.js +1 -1
- package/dist/client/mountLive.js.map +1 -1
- package/dist/internal/PermissionContext.d.ts +1 -1
- package/dist/internal/PermissionContext.d.ts.map +1 -1
- package/dist/submission.d.ts +2 -2
- package/dist/submission.d.ts.map +1 -1
- package/dist/submission.js +4 -0
- package/dist/submission.js.map +1 -1
- package/package.json +13 -13
- package/src/adapters/loadQuery.ts +0 -1
- package/src/adapters/permissionBoundary.ts +2 -1
- package/src/adapters/permissionGuard.ts +2 -1
- package/src/can.ts +6 -0
- package/src/client/adapters/SessionGeneration.ts +1 -1
- package/src/client/authAction.ts +3 -94
- package/src/client/authQuery.ts +3 -14
- package/src/client/authSession.ts +5 -34
- package/src/client/create.ts +4 -3
- package/src/client/editor.ts +4 -2
- package/src/client/mountLive.ts +1 -1
- package/src/internal/PermissionContext.ts +1 -1
- package/src/submission.ts +7 -2
- package/dist/internal/liveBindings.d.ts +0 -3
- package/dist/internal/liveBindings.d.ts.map +0 -1
- package/dist/internal/liveBindings.js +0 -10
- package/dist/internal/liveBindings.js.map +0 -1
- package/dist/permissions.d.ts +0 -13
- package/dist/permissions.d.ts.map +0 -1
- package/dist/permissions.js +0 -9
- package/dist/permissions.js.map +0 -1
- package/src/internal/liveBindings.ts +0 -11
- package/src/permissions.ts +0 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
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
|
+
|
|
3
24
|
## 0.34.0 - 2026-11-02
|
|
4
25
|
|
|
5
26
|
### 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 {
|
|
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
|
|
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`.
|
|
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
|
-
|
|
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/
|
|
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;
|
|
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.
|
|
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
|
-
`
|
|
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
|
|
@@ -938,7 +951,7 @@ import { command, query } from "@shivaedev/contract/operation.ts";
|
|
|
938
951
|
import { layerMemoryProtocol } from "@shivaedev/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,
|
|
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,eAA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AC;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,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 {
|
|
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;
|
|
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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B,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 {
|
|
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,
|
|
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 "#
|
|
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;
|
|
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;AAEzD,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAC9B,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,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
package/dist/can.js.map
ADDED
|
@@ -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,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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AAM,CAAC,CAAC,CAC1F,CAAC;AACH,CAAC"}
|
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
import { Effect
|
|
1
|
+
import type { Effect } from "effect";
|
|
2
2
|
import * as Atom from "effect/reactivity/Atom";
|
|
3
|
-
export
|
|
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,
|
|
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()(
|
|
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":"
|
|
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
|
-
|
|
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":"
|
|
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"}
|
package/dist/client/authQuery.js
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import { Effect } from "effect";
|
|
2
1
|
import * as Atom from "effect/reactivity/Atom";
|
|
3
|
-
|
|
4
|
-
|
|
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":"
|
|
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
|
|
10
|
-
readonly refresh: Effect.Effect<A, E
|
|
6
|
+
readonly atom: Atom.Atom<AsyncResult.AsyncResult<A, E>>;
|
|
7
|
+
readonly refresh: Effect.Effect<A, E, AtomRegistry.AtomRegistry>;
|
|
11
8
|
}
|
|
12
|
-
export
|
|
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,
|
|
1
|
+
{"version":3,"file":"authSession.d.ts","sourceRoot":"","sources":["../../src/client/authSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,KAAK,WAAW,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAC/C,OAAO,KAAK,YAAY,MAAM,gCAAgC,CAAC;AAE/D,MAAM,WAAW,WAAW,CAAC,CAAC,EAAE,CAAC;IAChC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,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
|
|
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(
|
|
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,
|
|
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"}
|
package/dist/client/create.d.ts
CHANGED
|
@@ -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>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/client/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAS,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AACjE,OAAO,KAAK,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAGpD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,K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