@shivaedev/identity 0.31.1 → 0.32.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 (76) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +20 -5
  3. package/dist/AccountPreferences.d.ts +52 -0
  4. package/dist/AccountPreferences.d.ts.map +1 -0
  5. package/dist/AccountPreferences.js +37 -0
  6. package/dist/AccountPreferences.js.map +1 -0
  7. package/dist/Sessions.d.ts +40 -0
  8. package/dist/Sessions.d.ts.map +1 -0
  9. package/dist/Sessions.js +30 -0
  10. package/dist/Sessions.js.map +1 -0
  11. package/dist/accountPreferenceValues.d.ts +9 -0
  12. package/dist/accountPreferenceValues.d.ts.map +1 -0
  13. package/dist/accountPreferenceValues.js +10 -0
  14. package/dist/accountPreferenceValues.js.map +1 -0
  15. package/dist/generated/AccountPreferences.d.ts +58 -0
  16. package/dist/generated/AccountPreferences.d.ts.map +1 -0
  17. package/dist/generated/AccountPreferences.js +28 -0
  18. package/dist/generated/AccountPreferences.js.map +1 -0
  19. package/dist/generated/Sessions.d.ts +76 -0
  20. package/dist/generated/Sessions.d.ts.map +1 -0
  21. package/dist/generated/Sessions.js +26 -0
  22. package/dist/generated/Sessions.js.map +1 -0
  23. package/dist/server/account-preferences/Rows.js +1 -1
  24. package/dist/server/account-preferences/Rows.js.map +1 -1
  25. package/dist/server/account-preferences/get.d.ts +3 -7
  26. package/dist/server/account-preferences/get.d.ts.map +1 -1
  27. package/dist/server/account-preferences/get.js +2 -1
  28. package/dist/server/account-preferences/get.js.map +1 -1
  29. package/dist/server/account-preferences/service.d.ts +3 -7
  30. package/dist/server/account-preferences/service.d.ts.map +1 -1
  31. package/dist/server/better-auth/adapters/accountPreferenceOptions.js +1 -1
  32. package/dist/server/better-auth/adapters/accountPreferenceOptions.js.map +1 -1
  33. package/dist/server/better-auth/sessionAdministration.d.ts +3 -18
  34. package/dist/server/better-auth/sessionAdministration.d.ts.map +1 -1
  35. package/dist/server/better-auth/sessionAdministration.js +3 -2
  36. package/dist/server/better-auth/sessionAdministration.js.map +1 -1
  37. package/dist/signedInSessions.d.ts +29 -0
  38. package/dist/signedInSessions.d.ts.map +1 -0
  39. package/dist/signedInSessions.js +16 -0
  40. package/dist/signedInSessions.js.map +1 -0
  41. package/dist/users.d.ts +2 -2
  42. package/dist/users.d.ts.map +1 -1
  43. package/package.json +27 -25
  44. package/src/AccountPreferences.ts +40 -0
  45. package/src/Sessions.ts +32 -0
  46. package/src/accountPreferenceValues.ts +14 -0
  47. package/src/generated/AccountPreferences.ts +33 -0
  48. package/src/generated/README.md +1 -0
  49. package/src/generated/Sessions.ts +31 -0
  50. package/src/server/account-preferences/Rows.ts +1 -1
  51. package/src/server/account-preferences/capture.ts +1 -1
  52. package/src/server/account-preferences/get.ts +5 -2
  53. package/src/server/account-preferences/set.ts +1 -1
  54. package/src/server/better-auth/adapters/accountPreferenceOptions.ts +1 -1
  55. package/src/server/better-auth/sessionAdministration.ts +3 -2
  56. package/src/signedInSessions.ts +23 -0
  57. package/dist/accountPreferences.d.ts +0 -106
  58. package/dist/accountPreferences.d.ts.map +0 -1
  59. package/dist/accountPreferences.js +0 -37
  60. package/dist/accountPreferences.js.map +0 -1
  61. package/dist/server/accountPreferencesHandlers.d.ts +0 -2
  62. package/dist/server/accountPreferencesHandlers.d.ts.map +0 -1
  63. package/dist/server/accountPreferencesHandlers.js +0 -19
  64. package/dist/server/accountPreferencesHandlers.js.map +0 -1
  65. package/dist/server/better-auth/sessionsHandlers.d.ts +0 -2
  66. package/dist/server/better-auth/sessionsHandlers.d.ts.map +0 -1
  67. package/dist/server/better-auth/sessionsHandlers.js +0 -7
  68. package/dist/server/better-auth/sessionsHandlers.js.map +0 -1
  69. package/dist/sessions.d.ts +0 -150
  70. package/dist/sessions.d.ts.map +0 -1
  71. package/dist/sessions.js +0 -39
  72. package/dist/sessions.js.map +0 -1
  73. package/src/accountPreferences.ts +0 -42
  74. package/src/server/accountPreferencesHandlers.ts +0 -22
  75. package/src/server/better-auth/sessionsHandlers.ts +0 -7
  76. package/src/sessions.ts +0 -42
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.32.0 - 2026-11-11
4
+
5
+ ### Breaking
6
+
7
+ - `AccountPreferences` moved from `@shivaedev/identity/accountPreferences.ts` to `@shivaedev/identity/AccountPreferences.ts`, and `Sessions` from `@shivaedev/identity/sessions.ts` to `@shivaedev/identity/Sessions.ts`. Both are now modules built with `defineModule`, and both files are server code. Register them with `module: AccountPreferences` or `module: Sessions` in an `AppModule`, or serve them with `moduleHandlers(Sessions)` from `@shivaedev/contract/moduleHandlers.ts`, for example as admin's `sessions` handlers. `accountPreferencesHandlers` (`@shivaedev/identity/server/accountPreferencesHandlers.ts`) and `sessionsHandlers` (`@shivaedev/identity/server/better-auth/sessionsHandlers.ts`) are removed.
8
+ - Browser code imports the client contracts `AccountPreferences` from `@shivaedev/identity/generated/AccountPreferences.ts` and `Sessions` from `@shivaedev/identity/generated/Sessions.ts`.
9
+ - `AccountPreferenceValues`, `AccountTimezone` and `accountPreferenceKeys` moved from `@shivaedev/identity/accountPreferences.ts` to `@shivaedev/identity/accountPreferenceValues.ts`. `SignedInSession`, `SessionCursor` and `SessionListInput` moved from `@shivaedev/identity/sessions.ts` to `@shivaedev/identity/signedInSessions.ts`, which also exports the sessions collection as `sessionKeys`. The `SessionList` schema is now the `SessionList` type there: replace `typeof SessionList.Type` with `SessionList`.
10
+ - `identity.sessions.list` takes its success from what the operation returns, so `next` travels as an encoded `Option` instead of a nullable cursor; deploy the browser and the server together.
11
+
12
+ ## 0.31.2 - 2026-11-11
13
+
14
+ ### Changed
15
+
16
+ - Update `@shivaedev/access` from 0.6.2 to 0.6.3.
17
+ - Update `@shivaedev/changes` from 0.11.1 to 0.12.0.
18
+ - Update `@shivaedev/contract` from 0.43.5 to 0.44.0.
19
+ - Update `@shivaedev/errors` from 0.11.0 to 0.12.0.
20
+ - Update `@shivaedev/rate-limit` from 0.6.9 to 0.6.10.
21
+ - Update `@shivaedev/service` from 0.9.0 to 0.9.1.
22
+ - Update `@shivaedev/sql` from 0.46.4 to 0.47.0.
23
+
3
24
  ## 0.31.1 - 2026-11-10
4
25
 
5
26
  ### Changed
package/README.md CHANGED
@@ -77,9 +77,24 @@ Pass `subject: delegated` to the contract. A delegated request selects the accou
77
77
 
78
78
  ### Account preferences and logical days
79
79
 
80
- `AccountPreferences` from `@shivaedev/identity/accountPreferences.ts` exposes authenticated `get`, `set` and `capture` operations for the caller's timezone, locale and units (`metric` or `imperial`). `set` replaces all three values. `capture` only creates a missing record, preserving saved preferences on subsequent sign-ins. An account without a record reads `UTC`, `en` and `metric`. The contract uses `selfSubject`, so a caller cannot select another account with a transport header.
80
+ `AccountPreferences` exposes authenticated `get`, `set` and `capture` operations for the caller's timezone, locale and units (`metric` or `imperial`). `set` replaces all three values. `capture` only creates a missing record, preserving saved preferences on subsequent sign-ins. An account without a record reads `UTC`, `en` and `metric`. The module uses `selfSubject`, so a caller cannot select another account with a transport header. `AccountPreferenceValues`, `AccountTimezone` and the `accountPreferenceKeys` collection come from `@shivaedev/identity/accountPreferenceValues.ts`.
81
81
 
82
- Apply `accountPreferencesMigration` from `@shivaedev/identity/server/adapters/accountPreferencesMigration.ts` as a numbered migration through `migratePostgres`. Provide `accountPreferencesStore` from `@shivaedev/identity/server/account-preferences/store.ts` with the application's `SqlClient`, merge `AccountPreferences` into the RPC group, and install `accountPreferencesHandlers` from `@shivaedev/identity/server/accountPreferencesHandlers.ts`. The host supplies subject middleware as for other subject contracts. The composed `accountPreferencesStore` Layer supplies the repository service internally, so callers provide only the application SQL Layer. Store operations yield `AccountPreferenceRows` and accept a target account id; handlers obtain that authorized target from `Subject`.
82
+ `AccountPreferences` from `@shivaedev/identity/AccountPreferences.ts` is a defined module, which is server code: register it as `module: AccountPreferences` in an `AppModule` with `accountPreferencesStore` from `@shivaedev/identity/server/account-preferences/store.ts` as its services, and apply `accountPreferencesMigration` from `@shivaedev/identity/server/adapters/accountPreferencesMigration.ts` as one of its numbered migrations. The store needs only the application's `SqlClient`. The host supplies subject middleware as for other subject contracts, and each operation reads the authorized account from `Subject`. Browser code imports the client contract under the same name from `@shivaedev/identity/generated/AccountPreferences.ts`, which holds no server code:
83
+
84
+ ```ts
85
+ import { Migrator } from "effect/sql";
86
+ import { AccountPreferences } from "@shivaedev/identity/AccountPreferences.ts";
87
+ import { accountPreferencesStore } from "@shivaedev/identity/server/account-preferences/store.ts";
88
+ import { accountPreferencesMigration } from "@shivaedev/identity/server/adapters/accountPreferencesMigration.ts";
89
+ import type { AppModule } from "@shivaedev/server/AppModule.ts";
90
+
91
+ export const preferencesModule = {
92
+ migrations: { loader: Migrator.fromRecord({ "0005_account_preferences": accountPreferencesMigration }) },
93
+ module: AccountPreferences,
94
+ name: "accountPreferences",
95
+ services: accountPreferencesStore,
96
+ } satisfies AppModule;
97
+ ```
83
98
 
84
99
  To capture browser defaults, enable `{ accountPreferences: true }` in `betterAuthMount` and install the optional Better Auth client plugin:
85
100
 
@@ -399,7 +414,7 @@ The seed only grants: removing an account from config does not restore its previ
399
414
 
400
415
  ### Administer signed-in sessions
401
416
 
402
- Merge `Sessions` from `@shivaedev/identity/sessions.ts` into the application's RPC group and provide `sessionsHandlers` from `@shivaedev/identity/server/better-auth/sessionsHandlers.ts`. Install `permissionLayer(SessionsPermission)` using `SessionsPermission` from `@shivaedev/identity/sessionPermissions.ts` and the mounted session policy. Supply the application's Effect `SqlClient`; the handlers use the default Better Auth PostgreSQL user and session tables.
417
+ `Sessions` from `@shivaedev/identity/Sessions.ts` is a defined module, which is server code: register it as `module: Sessions`, or serve it through admin's sessions page with `moduleHandlers(Sessions)` from `@shivaedev/contract/moduleHandlers.ts`. Install `permissionLayer(SessionsPermission)` using `SessionsPermission` from `@shivaedev/identity/sessionPermissions.ts` and the mounted session policy. Supply the application's Effect `SqlClient`; the operations use the default Better Auth PostgreSQL user and session tables. Browser code imports the client contract under the same name from `@shivaedev/identity/generated/Sessions.ts`, and the `SignedInSession`, `SessionCursor` and `SessionListInput` schemas and the `SessionList` type from `@shivaedev/identity/signedInSessions.ts`.
403
418
 
404
419
  Grant `ManageSessions` (`sessions.manage`) from `sessionPermissions.ts` to the roles that manage sessions. The starter grants it to admin and owner. Both operations use the same permission middleware and `Forbidden` refusal as the admin Users page. They require no Better Auth admin plugin.
405
420
 
@@ -798,7 +813,7 @@ The host's generated `$changes` handler accepts `{ queries: [{ query: "get", pay
798
813
 
799
814
  `authenticatedLayer`, `authenticatedUserLayer`, `authenticatedUserWithProviderAccountsLayer` and `permissionLayer` run command invalidation inside the authenticated invocation. Successful commands publish plain keys after the handler returns and omit keys the handler's transactions already published. Keys that must commit atomically with a write come from the stored model's `bucket()` fields and the repository, rather than command `invalidates`. A rejected transaction publishes no keys.
800
815
 
801
- Declared-key publication retries twice, after 50 ms and 100 ms, without rerunning the handler. Exhausted retries preserve the committed result. On a database-backed host, they mark local live streams for Resync and attempt a broadcast Resync on the PostgreSQL change channel. If that broadcast also fails, the server logs that other hosts may remain stale. There is no durable replay: a remote host whose listener remains healthy cannot discover a notification that never reached PostgreSQL. Reconnect or listener recovery reconciles its streams.
816
+ Declared-key publication retries twice, after 50 ms and 100 ms, without rerunning the handler. Exhausted retries preserve the committed result. On a database-backed host, they mark local live streams for Resync and attempt a broadcast Resync on the PostgreSQL change channel. If that broadcast also fails, the server logs that other hosts may remain stale. There is no durable replay: a remote host whose listener remains healthy cannot discover a notification that never reached PostgreSQL. A client reconnect reconciles its streams.
802
817
 
803
818
  Hosted applications use `Api.application.toLayer(...)` and let `appHost` own `$changes`. A custom change handler accepts query references and resolves them inside `Stream.unwrap`, after authentication has provided `Identity`:
804
819
 
@@ -1054,7 +1069,7 @@ Import the module that defines the name; there is no package-root entry. Paths b
1054
1069
 
1055
1070
  ### Install, setup and limits
1056
1071
 
1057
- Install `@shivaedev/identity` with `effect` as its peer. Everything outside `server/better-auth/` works with only `effect` installed, including the Promise-based `betterAuthSessions` adapter. Better Auth mounts and test fixtures need the optional peer `better-auth` and the application’s PostgreSQL `SqlClient`; `sweepExpiredSessions` needs only the application's Effect SQL client. Browser code imports `identity.ts`, `middleware.ts` and `permission.ts`.
1072
+ Install `@shivaedev/identity` with `effect` as its peer. Everything outside `server/better-auth/` works with only `effect` installed, including the Promise-based `betterAuthSessions` adapter. Better Auth mounts and test fixtures need the optional peer `better-auth` and the application’s PostgreSQL `SqlClient`; `sweepExpiredSessions` needs only the application's Effect SQL client. Browser code imports `identity.ts`, `middleware.ts`, `permission.ts` and the client contracts in `generated/`. The package's build writes `src/generated` and `dist/generated` before compiling, so the published archive holds them although the repository does not commit them.
1058
1073
  - The package needs Node 24 or newer.
1059
1074
  - Keep the auth provider's configuration, cookie settings and resource authorization in the application. The session adapter takes a session lookup and an optional provider-account lookup and returns a session result; it does not write provider refresh cookies into RPC responses.
1060
1075
  - Without an `HttpServerRequest`, `transportHeaders` falls back to the supplied RPC headers. An application using another transport must decide what headers it can trust.
@@ -0,0 +1,52 @@
1
+ import { Subject } from "#subject.ts";
2
+ export declare const AccountPreferences: import("@shivaedev/contract/defineModule.ts").Module<"identity.accountPreferences", readonly [import("@shivaedev/contract/servedOperation.ts").ServedQuery<"get", import("effect/Schema").Void, import("effect/Schema").Struct<{
3
+ readonly locale: import("effect/Schema").String;
4
+ readonly timezone: import("effect/Schema").String;
5
+ readonly units: import("effect/Schema").Literals<readonly ["imperial", "metric"]>;
6
+ }>, {
7
+ readonly InternalServerError: typeof import("@shivaedev/errors/taxonomy.ts").InternalServerError;
8
+ readonly ServiceUnavailable: typeof import("@shivaedev/errors/taxonomy.ts").ServiceUnavailable;
9
+ readonly AuthUnavailable: typeof import("@shivaedev/errors/taxonomy.ts").AuthUnavailable;
10
+ }, never, never, import("effect/Effect").Effect<{
11
+ readonly locale: string;
12
+ readonly timezone: string;
13
+ readonly units: "imperial" | "metric";
14
+ }, import("@shivaedev/errors/taxonomy.ts").AuthUnavailable, "@shivaedev/identity/AccountPreferencesStore" | Subject>>, import("@shivaedev/contract/servedOperation.ts").ServedCommand<"set", import("effect/Schema").Struct<{
15
+ readonly locale: import("effect/Schema").NonEmptyString;
16
+ readonly timezone: import("effect/Schema").String;
17
+ readonly units: import("effect/Schema").Literals<readonly ["metric", "imperial"]>;
18
+ }>, import("effect/Schema").Void, {
19
+ readonly InternalServerError: typeof import("@shivaedev/errors/taxonomy.ts").InternalServerError;
20
+ readonly ServiceUnavailable: typeof import("@shivaedev/errors/taxonomy.ts").ServiceUnavailable;
21
+ readonly AuthUnavailable: typeof import("@shivaedev/errors/taxonomy.ts").AuthUnavailable;
22
+ }, import("effect/Effect").Effect<void, import("@shivaedev/errors/taxonomy.ts").AuthUnavailable, "@shivaedev/identity/AccountPreferencesStore" | Subject>>, import("@shivaedev/contract/servedOperation.ts").ServedCommand<"capture", import("effect/Schema").Struct<{
23
+ readonly locale: import("effect/Schema").NonEmptyString;
24
+ readonly timezone: import("effect/Schema").String;
25
+ readonly units: import("effect/Schema").Literals<readonly ["metric", "imperial"]>;
26
+ }>, import("effect/Schema").Void, {
27
+ readonly InternalServerError: typeof import("@shivaedev/errors/taxonomy.ts").InternalServerError;
28
+ readonly ServiceUnavailable: typeof import("@shivaedev/errors/taxonomy.ts").ServiceUnavailable;
29
+ readonly AuthUnavailable: typeof import("@shivaedev/errors/taxonomy.ts").AuthUnavailable;
30
+ }, import("effect/Effect").Effect<void, import("@shivaedev/errors/taxonomy.ts").AuthUnavailable, "@shivaedev/identity/AccountPreferencesStore" | Subject>>] & readonly import("@shivaedev/contract/defineModule.ts").ModuleOperation[], readonly [import("effect/Context").Service<"@shivaedev/identity/AccountPreferencesStore", Readonly<{
31
+ readonly capture: (id: string, values: {
32
+ readonly locale: string;
33
+ readonly timezone: string;
34
+ readonly units: "imperial" | "metric";
35
+ }) => import("effect/Effect").Effect<void, import("@shivaedev/errors/taxonomy.ts").AuthUnavailable, never>;
36
+ readonly get: (id: string) => import("effect/Effect").Effect<{
37
+ readonly locale: string;
38
+ readonly timezone: string;
39
+ readonly units: "imperial" | "metric";
40
+ }, import("@shivaedev/errors/taxonomy.ts").AuthUnavailable, never>;
41
+ readonly set: (id: string, values: {
42
+ readonly locale: string;
43
+ readonly timezone: string;
44
+ readonly units: "imperial" | "metric";
45
+ }) => import("effect/Effect").Effect<void, import("@shivaedev/errors/taxonomy.ts").AuthUnavailable, never>;
46
+ }>> & {
47
+ readonly layer: import("effect/Layer").Layer<"@shivaedev/identity/AccountPreferencesStore", never, "@shivaedev/identity/AccountPreferenceRows">;
48
+ }], never, {
49
+ error: import("effect/Schema").Union<readonly [typeof import("@shivaedev/errors/taxonomy.ts").Unauthorized, typeof import("@shivaedev/errors/taxonomy.ts").AuthUnavailable, typeof import("@shivaedev/errors/taxonomy.ts").Forbidden, typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>;
50
+ middleware: import("effect/Effect").Effect<import("#subject.ts").SubjectMiddleware<never, never>, never, import("#subject.ts").SubjectResolver>;
51
+ }, undefined>;
52
+ //# sourceMappingURL=AccountPreferences.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccountPreferences.d.ts","sourceRoot":"","sources":["../src/AccountPreferences.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAe,MAAM,aAAa,CAAC;AA4BnD,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAM7B,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { defineModule } from "@shivaedev/contract/defineModule.ts";
2
+ import { command, query } from "@shivaedev/contract/operation.ts";
3
+ import { AccountPreferenceValues, accountPreferenceKeys } from "#accountPreferenceValues.ts";
4
+ import { identityAccountPreferencesWire } from "#generated/AccountPreferences.ts";
5
+ import { AccountPreferencesStore } from "#server/account-preferences/service.ts";
6
+ import { Subject, selfSubject } from "#subject.ts";
7
+ const GetPreferences = query("get", {
8
+ reads: () => [accountPreferenceKeys.list],
9
+ *run() {
10
+ const { id } = yield* Subject;
11
+ return yield* (yield* AccountPreferencesStore).get(id);
12
+ },
13
+ });
14
+ const SetPreferences = command("set", {
15
+ invalidates: () => [accountPreferenceKeys.list],
16
+ payload: AccountPreferenceValues.fields,
17
+ *run(values) {
18
+ const { id } = yield* Subject;
19
+ yield* (yield* AccountPreferencesStore).set(id, values);
20
+ },
21
+ });
22
+ const CapturePreferences = command("capture", {
23
+ invalidates: () => [accountPreferenceKeys.list],
24
+ payload: AccountPreferenceValues.fields,
25
+ *run(values) {
26
+ const { id } = yield* Subject;
27
+ yield* (yield* AccountPreferencesStore).capture(id, values);
28
+ },
29
+ });
30
+ export const AccountPreferences = defineModule({
31
+ name: "identity.accountPreferences",
32
+ operations: [GetPreferences, SetPreferences, CapturePreferences],
33
+ requires: [AccountPreferencesStore],
34
+ subject: selfSubject,
35
+ wire: identityAccountPreferencesWire,
36
+ });
37
+ //# sourceMappingURL=AccountPreferences.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccountPreferences.js","sourceRoot":"","sources":["../src/AccountPreferences.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAC7F,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEnD,MAAM,cAAc,GAAG,KAAK,CAAC,KAAK,EAAE;IACnC,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC;IACzC,CAAC,G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AAC,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { Schema } from "effect";
2
+ import { SqlClient } from "effect/sql";
3
+ import { SessionsPermission } from "#sessionPermissions.ts";
4
+ export declare const Sessions: import("@shivaedev/contract/defineModule.ts").Module<"identity.sessions", readonly [import("@shivaedev/contract/servedOperation.ts").ServedQuery<"list", Schema.Struct<{
5
+ readonly cursor: Schema.optionalKey<Schema.Struct<{
6
+ readonly id: Schema.String;
7
+ readonly lastActivityAt: Schema.DateTimeUtcFromString;
8
+ }>>;
9
+ readonly limit: Schema.Number;
10
+ }>, Schema.Struct<{
11
+ readonly next: Schema.Option<Schema.Struct<{
12
+ readonly id: Schema.String;
13
+ readonly lastActivityAt: Schema.DateTimeUtc;
14
+ }>>;
15
+ readonly sessions: Schema.$Array<Schema.Struct<{
16
+ readonly expiresAt: Schema.DateTimeUtc;
17
+ readonly id: Schema.String;
18
+ readonly lastActivityAt: Schema.DateTimeUtc;
19
+ readonly startedAt: Schema.DateTimeUtc;
20
+ readonly user: Schema.Struct<{
21
+ readonly email: Schema.String;
22
+ readonly id: Schema.String;
23
+ readonly name: Schema.String;
24
+ }>;
25
+ }>>;
26
+ }>, {
27
+ readonly InternalServerError: typeof import("@shivaedev/errors/taxonomy.ts").InternalServerError;
28
+ readonly ServiceUnavailable: typeof import("@shivaedev/errors/taxonomy.ts").ServiceUnavailable;
29
+ readonly AuthUnavailable: typeof import("@shivaedev/errors/taxonomy.ts").AuthUnavailable;
30
+ readonly Forbidden: typeof import("@shivaedev/errors/taxonomy.ts").Forbidden;
31
+ }, never, never, import("effect/Effect").Effect<import("#signedInSessions.ts").SessionList, import("@shivaedev/errors/taxonomy.ts").AuthUnavailable | import("@shivaedev/errors/taxonomy.ts").Forbidden, import("./identity.ts").SessionUser | SqlClient.SqlClient>>, import("@shivaedev/contract/servedOperation.ts").ServedCommand<"revoke", Schema.Struct<{
32
+ id: Schema.String;
33
+ }>, Schema.Void, {
34
+ readonly InternalServerError: typeof import("@shivaedev/errors/taxonomy.ts").InternalServerError;
35
+ readonly ServiceUnavailable: typeof import("@shivaedev/errors/taxonomy.ts").ServiceUnavailable;
36
+ readonly AuthUnavailable: typeof import("@shivaedev/errors/taxonomy.ts").AuthUnavailable;
37
+ readonly Forbidden: typeof import("@shivaedev/errors/taxonomy.ts").Forbidden;
38
+ readonly NotFound: typeof import("@shivaedev/errors/taxonomy.ts").NotFound;
39
+ }, import("effect/Effect").Effect<void, import("@shivaedev/errors/taxonomy.ts").AuthUnavailable | import("@shivaedev/errors/taxonomy.ts").Forbidden | import("@shivaedev/errors/taxonomy.ts").NotFound, import("./identity.ts").SessionUser | SqlClient.SqlClient>>] & readonly import("@shivaedev/contract/defineModule.ts").ModuleOperation[], readonly [import("effect/Context").Service<SqlClient.SqlClient, SqlClient.SqlClient>], typeof SessionsPermission, undefined, undefined>;
40
+ //# sourceMappingURL=Sessions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Sessions.d.ts","sourceRoot":"","sources":["../src/Sessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAKvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAmB5D,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wdAMnB,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { Schema } from "effect";
2
+ import { SqlClient } from "effect/sql";
3
+ import { defineModule } from "@shivaedev/contract/defineModule.ts";
4
+ import { command, query } from "@shivaedev/contract/operation.ts";
5
+ import { identitySessionsWire } from "#generated/Sessions.ts";
6
+ import { listSessions, revokeSession } from "#server/better-auth/sessionAdministration.ts";
7
+ import { SessionsPermission } from "#sessionPermissions.ts";
8
+ import { SessionListInput, sessionKeys } from "#signedInSessions.ts";
9
+ const ListSessions = query("list", {
10
+ payload: SessionListInput.fields,
11
+ reads: () => [sessionKeys.list],
12
+ *run(input) {
13
+ return yield* listSessions(input);
14
+ },
15
+ });
16
+ const RevokeSession = command("revoke", {
17
+ invalidates: () => [sessionKeys.list],
18
+ payload: { id: Schema.String },
19
+ *run({ id }) {
20
+ yield* revokeSession(id);
21
+ },
22
+ });
23
+ export const Sessions = defineModule({
24
+ middleware: SessionsPermission,
25
+ name: "identity.sessions",
26
+ operations: [ListSessions, RevokeSession],
27
+ requires: [SqlClient.SqlClient],
28
+ wire: identitySessionsWire,
29
+ });
30
+ //# sourceMappingURL=Sessions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Sessions.js","sourceRoot":"","sources":["../src/Sessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAC3F,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAErE,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,EAAE;IAClC,OAAO,EAAE,gBAAgB,CAAC,MAAM;IAChC,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC;IAC/B,CAAC,GAAG,CAAC,KAAK;QACT,OAAO,KAAK,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;CACD,CAAC,CAAC;AAEH,MAAM,aAAa,GAAG,OAAO,CAAC,QAAQ,EAAE;IACvC,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC;IACrC,OAAO,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE;IAC9B,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE;QACV,KAAK,CAAC,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;IAC1B,CAAC;CACD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,QAAQ,GAAG,YAAY,CAAC;IACpC,UAAU,EAAE,kBAAkB;IAC9B,IAAI,EAAE,mBAAmB;IACzB,UAAU,EAAE,CAAC,YAAY,EAAE,aAAa,CAAC;IACzC,QAAQ,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC;IAC/B,IAAI,EAAE,oBAAoB;CAC1B,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { Schema } from "effect";
2
+ export declare const AccountTimezone: Schema.String;
3
+ export declare const AccountPreferenceValues: Schema.Struct<{
4
+ readonly locale: Schema.NonEmptyString;
5
+ readonly timezone: Schema.String;
6
+ readonly units: Schema.Literals<readonly ["metric", "imperial"]>;
7
+ }>;
8
+ export declare const accountPreferenceKeys: import("@shivaedev/changes/keys.ts").Collection<"identity.accountPreferences", string, Record<never, never>, Record<never, never>>;
9
+ //# sourceMappingURL=accountPreferenceValues.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accountPreferenceValues.d.ts","sourceRoot":"","sources":["../src/accountPreferenceValues.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGlD,eAAO,MAAM,eAAe,eAE3B,CAAC;AAEF,eAAO,MAAM,uBAAuB;;;;EAIlC,CAAC;AAEH,eAAO,MAAM,qBAAqB,oIAA2D,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { DateTime, Option, Schema } from "effect";
2
+ import { collection } from "@shivaedev/changes/keys.ts";
3
+ export const AccountTimezone = Schema.String.check(Schema.makeFilter((value) => Option.isSome(DateTime.zoneMakeNamed(value)), { expected: "an IANA timezone" }));
4
+ export const AccountPreferenceValues = Schema.Struct({
5
+ locale: Schema.NonEmptyString,
6
+ timezone: AccountTimezone,
7
+ units: Schema.Literals(["metric", "imperial"]),
8
+ });
9
+ export const accountPreferenceKeys = collection("identity.accountPreferences", Schema.String);
10
+ //# sourceMappingURL=accountPreferenceValues.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accountPreferenceValues.js","sourceRoot":"","sources":["../src/accountPreferenceValues.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAExD,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CACjD,MAAM,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,QAAQ,EAAE,kBAAkB,EAAE,CAAC,CAC5G,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC,MAAM,CAAC;IACpD,MAAM,EAAE,MAAM,CAAC,cAAc;IAC7B,QAAQ,EAAE,eAAe;IACzB,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;CAC9C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG,UAAU,CAAC,6BAA6B,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC"}
@@ -0,0 +1,58 @@
1
+ import type { AccountPreferences as AccountPreferencesModule } from "#AccountPreferences.ts";
2
+ import type { ClientMatchesModule } from "@shivaedev/contract/clientMatchesModule.ts";
3
+ import { AuthUnavailable } from "@shivaedev/errors/taxonomy.ts";
4
+ import { Schema } from "effect";
5
+ export declare const identityAccountPreferencesWire: {
6
+ readonly capture: {
7
+ readonly rejections: {
8
+ readonly AuthUnavailable: typeof AuthUnavailable;
9
+ };
10
+ readonly success: Schema.Void;
11
+ };
12
+ readonly get: {
13
+ readonly rejections: {
14
+ readonly AuthUnavailable: typeof AuthUnavailable;
15
+ };
16
+ readonly success: Schema.Struct<{
17
+ readonly locale: Schema.String;
18
+ readonly timezone: Schema.String;
19
+ readonly units: Schema.Literals<readonly ["imperial", "metric"]>;
20
+ }>;
21
+ };
22
+ readonly set: {
23
+ readonly rejections: {
24
+ readonly AuthUnavailable: typeof AuthUnavailable;
25
+ };
26
+ readonly success: Schema.Void;
27
+ };
28
+ };
29
+ export declare const AccountPreferences: import("@shivaedev/contract/defineModule.ts").ModuleContract<"identity.accountPreferences", readonly (import("@shivaedev/contract/clientContract.ts").ClientQuery<"get", Schema.Void, Schema.Struct<{
30
+ readonly locale: Schema.String;
31
+ readonly timezone: Schema.String;
32
+ readonly units: Schema.Literals<readonly ["imperial", "metric"]>;
33
+ }>, {
34
+ readonly InternalServerError: typeof import("@shivaedev/errors/taxonomy.ts").InternalServerError;
35
+ readonly ServiceUnavailable: typeof import("@shivaedev/errors/taxonomy.ts").ServiceUnavailable;
36
+ readonly AuthUnavailable: typeof AuthUnavailable;
37
+ }> | (import("@shivaedev/contract/operation.ts").Command<"capture", Schema.Struct<{
38
+ readonly locale: Schema.NonEmptyString;
39
+ readonly timezone: Schema.String;
40
+ readonly units: Schema.Literals<readonly ["metric", "imperial"]>;
41
+ }>, Schema.Void, {
42
+ readonly InternalServerError: typeof import("@shivaedev/errors/taxonomy.ts").InternalServerError;
43
+ readonly ServiceUnavailable: typeof import("@shivaedev/errors/taxonomy.ts").ServiceUnavailable;
44
+ readonly AuthUnavailable: typeof AuthUnavailable;
45
+ }> | import("@shivaedev/contract/operation.ts").Command<"set", Schema.Struct<{
46
+ readonly locale: Schema.NonEmptyString;
47
+ readonly timezone: Schema.String;
48
+ readonly units: Schema.Literals<readonly ["metric", "imperial"]>;
49
+ }>, Schema.Void, {
50
+ readonly InternalServerError: typeof import("@shivaedev/errors/taxonomy.ts").InternalServerError;
51
+ readonly ServiceUnavailable: typeof import("@shivaedev/errors/taxonomy.ts").ServiceUnavailable;
52
+ readonly AuthUnavailable: typeof AuthUnavailable;
53
+ }>))[], never, {
54
+ error: Schema.Union<readonly [typeof import("@shivaedev/errors/taxonomy.ts").Unauthorized, typeof AuthUnavailable, typeof import("@shivaedev/errors/taxonomy.ts").Forbidden, typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>;
55
+ middleware: import("effect/Effect").Effect<import("#subject.ts").SubjectMiddleware<never, never>, never, import("#subject.ts").SubjectResolver>;
56
+ }, undefined>;
57
+ export declare const identityAccountPreferencesMatchModule: ClientMatchesModule<typeof AccountPreferences, typeof AccountPreferencesModule>;
58
+ //# sourceMappingURL=AccountPreferences.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccountPreferences.d.ts","sourceRoot":"","sources":["../../src/generated/AccountPreferences.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,IAAI,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAI7F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AACtF,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;CAIjC,CAAC;AAEX,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;aAe7B,CAAC;AAEH,eAAO,MAAM,qCAAqC,EAAE,mBAAmB,CAAC,OAAO,kBAAkB,EAAE,OAAO,wBAAwB,CAAQ,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { AccountPreferenceValues, accountPreferenceKeys } from "#accountPreferenceValues.ts";
2
+ import { selfSubject } from "#subject.ts";
3
+ import { clientContract } from "@shivaedev/contract/clientContract.ts";
4
+ import { AuthUnavailable } from "@shivaedev/errors/taxonomy.ts";
5
+ import { Schema } from "effect";
6
+ export const identityAccountPreferencesWire = {
7
+ capture: { rejections: { AuthUnavailable }, success: Schema.Void },
8
+ get: { rejections: { AuthUnavailable }, success: Schema.Struct({ locale: Schema.String, timezone: Schema.String, units: Schema.Literals(["imperial", "metric"]) }) },
9
+ set: { rejections: { AuthUnavailable }, success: Schema.Void },
10
+ };
11
+ export const AccountPreferences = clientContract({
12
+ commands: {
13
+ capture: { invalidates: () => [accountPreferenceKeys.list] },
14
+ set: { invalidates: () => [accountPreferenceKeys.list] },
15
+ },
16
+ name: "identity.accountPreferences",
17
+ payloads: {
18
+ capture: AccountPreferenceValues.fields,
19
+ set: AccountPreferenceValues.fields,
20
+ },
21
+ queries: {
22
+ get: { reads: () => [accountPreferenceKeys.list] },
23
+ },
24
+ subject: selfSubject,
25
+ wire: identityAccountPreferencesWire,
26
+ });
27
+ export const identityAccountPreferencesMatchModule = true;
28
+ //# sourceMappingURL=AccountPreferences.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccountPreferences.js","sourceRoot":"","sources":["../../src/generated/AccountPreferences.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAC7F,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAEvE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,CAAC,MAAM,8BAA8B,GAAG;IAC7C,OAAO,EAAE,EAAE,UAAU,EAAE,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE;IAClE,GAAG,EAAE,EAAE,UAAU,EAAE,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE;IACpK,GAAG,EAAE,EAAE,UAAU,EAAE,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE;CACrD,CAAC;AAEX,MAAM,CAAC,MAAM,kBAAkB,GAAG,cAAc,CAAC;IAChD,QAAQ,EAAE;QACT,OAAO,EAAE,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE;QAC5D,GAAG,EAAE,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE;KACxD;IACD,IAAI,EAAE,6BAA6B;IACnC,QAAQ,EAAE;QACT,OAAO,EAAE,uBAAuB,CAAC,MAAM;QACvC,GAAG,EAAE,uBAAuB,CAAC,MAAM;KACnC;IACD,OAAO,EAAE;QACR,GAAG,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE;KAClD;IACD,OAAO,EAAE,WAAW;IACpB,IAAI,EAAE,8BAA8B;CACpC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,qCAAqC,GAAoF,IAAI,CAAC"}
@@ -0,0 +1,76 @@
1
+ import type { Sessions as SessionsModule } from "#Sessions.ts";
2
+ import { SessionsPermission } from "#sessionPermissions.ts";
3
+ import type { ClientMatchesModule } from "@shivaedev/contract/clientMatchesModule.ts";
4
+ import { AuthUnavailable, Forbidden, NotFound } from "@shivaedev/errors/taxonomy.ts";
5
+ import { Schema } from "effect";
6
+ export declare const identitySessionsWire: {
7
+ readonly list: {
8
+ readonly rejections: {
9
+ readonly AuthUnavailable: typeof AuthUnavailable;
10
+ readonly Forbidden: typeof Forbidden;
11
+ };
12
+ readonly success: Schema.Struct<{
13
+ readonly next: Schema.Option<Schema.Struct<{
14
+ readonly id: Schema.String;
15
+ readonly lastActivityAt: Schema.DateTimeUtc;
16
+ }>>;
17
+ readonly sessions: Schema.$Array<Schema.Struct<{
18
+ readonly expiresAt: Schema.DateTimeUtc;
19
+ readonly id: Schema.String;
20
+ readonly lastActivityAt: Schema.DateTimeUtc;
21
+ readonly startedAt: Schema.DateTimeUtc;
22
+ readonly user: Schema.Struct<{
23
+ readonly email: Schema.String;
24
+ readonly id: Schema.String;
25
+ readonly name: Schema.String;
26
+ }>;
27
+ }>>;
28
+ }>;
29
+ };
30
+ readonly revoke: {
31
+ readonly rejections: {
32
+ readonly AuthUnavailable: typeof AuthUnavailable;
33
+ readonly Forbidden: typeof Forbidden;
34
+ readonly NotFound: typeof NotFound;
35
+ };
36
+ readonly success: Schema.Void;
37
+ };
38
+ };
39
+ export declare const Sessions: import("@shivaedev/contract/defineModule.ts").ModuleContract<"identity.sessions", readonly (import("@shivaedev/contract/clientContract.ts").ClientQuery<"list", Schema.Struct<{
40
+ readonly cursor: Schema.optionalKey<Schema.Struct<{
41
+ readonly id: Schema.String;
42
+ readonly lastActivityAt: Schema.DateTimeUtcFromString;
43
+ }>>;
44
+ readonly limit: Schema.Number;
45
+ }>, Schema.Struct<{
46
+ readonly next: Schema.Option<Schema.Struct<{
47
+ readonly id: Schema.String;
48
+ readonly lastActivityAt: Schema.DateTimeUtc;
49
+ }>>;
50
+ readonly sessions: Schema.$Array<Schema.Struct<{
51
+ readonly expiresAt: Schema.DateTimeUtc;
52
+ readonly id: Schema.String;
53
+ readonly lastActivityAt: Schema.DateTimeUtc;
54
+ readonly startedAt: Schema.DateTimeUtc;
55
+ readonly user: Schema.Struct<{
56
+ readonly email: Schema.String;
57
+ readonly id: Schema.String;
58
+ readonly name: Schema.String;
59
+ }>;
60
+ }>>;
61
+ }>, {
62
+ readonly InternalServerError: typeof import("@shivaedev/errors/taxonomy.ts").InternalServerError;
63
+ readonly ServiceUnavailable: typeof import("@shivaedev/errors/taxonomy.ts").ServiceUnavailable;
64
+ readonly AuthUnavailable: typeof AuthUnavailable;
65
+ readonly Forbidden: typeof Forbidden;
66
+ }> | import("@shivaedev/contract/operation.ts").Command<"revoke", Schema.Struct<{
67
+ readonly id: Schema.String;
68
+ }>, Schema.Void, {
69
+ readonly InternalServerError: typeof import("@shivaedev/errors/taxonomy.ts").InternalServerError;
70
+ readonly ServiceUnavailable: typeof import("@shivaedev/errors/taxonomy.ts").ServiceUnavailable;
71
+ readonly AuthUnavailable: typeof AuthUnavailable;
72
+ readonly Forbidden: typeof Forbidden;
73
+ readonly NotFound: typeof NotFound;
74
+ }>)[], typeof SessionsPermission, undefined, undefined>;
75
+ export declare const identitySessionsMatchModule: ClientMatchesModule<typeof Sessions, typeof SessionsModule>;
76
+ //# sourceMappingURL=Sessions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Sessions.d.ts","sourceRoot":"","sources":["../../src/generated/Sessions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,IAAI,cAAc,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAG5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AACtF,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACrF,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGvB,CAAC;AAEX,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uDAcnB,CAAC;AAEH,eAAO,MAAM,2BAA2B,EAAE,mBAAmB,CAAC,OAAO,QAAQ,EAAE,OAAO,cAAc,CAAQ,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { SessionsPermission } from "#sessionPermissions.ts";
2
+ import { SessionListInput, sessionKeys } from "#signedInSessions.ts";
3
+ import { clientContract } from "@shivaedev/contract/clientContract.ts";
4
+ import { AuthUnavailable, Forbidden, NotFound } from "@shivaedev/errors/taxonomy.ts";
5
+ import { Schema } from "effect";
6
+ export const identitySessionsWire = {
7
+ list: { rejections: { AuthUnavailable, Forbidden }, success: Schema.Struct({ next: Schema.Option(Schema.Struct({ id: Schema.String, lastActivityAt: Schema.DateTimeUtc })), sessions: Schema.Array(Schema.Struct({ expiresAt: Schema.DateTimeUtc, id: Schema.String, lastActivityAt: Schema.DateTimeUtc, startedAt: Schema.DateTimeUtc, user: Schema.Struct({ email: Schema.String, id: Schema.String, name: Schema.String }) })) }) },
8
+ revoke: { rejections: { AuthUnavailable, Forbidden, NotFound }, success: Schema.Void },
9
+ };
10
+ export const Sessions = clientContract({
11
+ commands: {
12
+ revoke: { invalidates: () => [sessionKeys.list] },
13
+ },
14
+ middleware: SessionsPermission,
15
+ name: "identity.sessions",
16
+ payloads: {
17
+ list: SessionListInput.fields,
18
+ revoke: { id: Schema.String },
19
+ },
20
+ queries: {
21
+ list: { reads: () => [sessionKeys.list] },
22
+ },
23
+ wire: identitySessionsWire,
24
+ });
25
+ export const identitySessionsMatchModule = true;
26
+ //# sourceMappingURL=Sessions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Sessions.js","sourceRoot":"","sources":["../../src/generated/Sessions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAEvE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACrF,OAAO,EAAE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,EAAE;QACR,IAAI,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE;KACzC;IACD,IAAI,EAAE,oBAAoB;CAC1B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,2BAA2B,GAAgE,IAAI,CAAC"}
@@ -2,7 +2,7 @@ import { Schema } from "effect";
2
2
  import { Model } from "effect/schema";
3
3
  import { defineRepository } from "@shivaedev/sql/defineRepository.ts";
4
4
  import { makeRepository } from "@shivaedev/sql/repository.ts";
5
- import { AccountPreferenceValues } from "#accountPreferences.ts";
5
+ import { AccountPreferenceValues } from "#accountPreferenceValues.ts";
6
6
  class StoredPreferences extends Model.Class("AccountPreferences")({
7
7
  id: Schema.String,
8
8
  ...AccountPreferenceValues.fields,
@@ -1 +1 @@
1
- {"version":3,"file":"Rows.js","sourceRoot":"","sources":["../../../src/server/account-preferences/Rows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,MAAM,iBAAkB,SAAQ,KAAK,CAAC,KAAK,CAAoB,oBAAoB,CAAC,CAAC;IACpF,EAAE,EAAE,MAAM,CAAC,MAAM;IACjB,GAAG,uBAAuB,CAAC,MAAM;CACjC,CAAC;CAAG;AAEL,MAAM,UAAU,GAAG,cAAc,CAAC,iBAAiB,EAAE;IACpD,eAAe,EAAE,CAAC,IAAI,CAAC;IACvB,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,oBAAoB;IAChC,SAAS,EAAE,8BAA8B;CACzC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG,gBAAgB,CAAC;IACrD,EAAE,EAAE,2CAA2C;IAC/C,UAAU;CACV,CAAC,CAAC"}
1
+ {"version":3,"file":"Rows.js","sourceRoot":"","sources":["../../../src/server/account-preferences/Rows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAEtE,MAAM,iBAAkB,SAAQ,KAAK,CAAC,KAAK,CAAoB,oBAAoB,CAAC,CAAC;IACpF,EAAE,EAAE,MAAM,CAAC,MAAM;IACjB,GAAG,uBAAuB,CAAC,MAAM;CACjC,CAAC;CAAG;AAEL,MAAM,UAAU,GAAG,cAAc,CAAC,iBAAiB,EAAE;IACpD,eAAe,EAAE,CAAC,IAAI,CAAC;IACvB,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,oBAAoB;IAChC,SAAS,EAAE,8BAA8B;CACzC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG,gBAAgB,CAAC;IACrD,EAAE,EAAE,2CAA2C;IAC/C,UAAU;CACV,CAAC,CAAC"}
@@ -1,11 +1,7 @@
1
1
  import { Effect } from "effect";
2
2
  export declare const get: (id: string) => Effect.Effect<{
3
- locale: string;
4
- timezone: string;
5
- units: "imperial" | "metric";
6
- } | {
7
- locale: string;
8
- timezone: string;
9
- units: "metric";
3
+ readonly locale: string;
4
+ readonly timezone: string;
5
+ readonly units: "imperial" | "metric";
10
6
  }, import("@shivaedev/errors/taxonomy.ts").AuthUnavailable, "@shivaedev/identity/AccountPreferenceRows">;
11
7
  //# sourceMappingURL=get.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../src/server/account-preferences/get.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,eAAO,MAAM,GAAG;;;;;;;WAIqF,QAAQ;wGAG3G,CAAC"}
1
+ {"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../src/server/account-preferences/get.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAOhC,eAAO,MAAM,GAAG;;;;wGAOd,CAAC"}
@@ -1,8 +1,9 @@
1
1
  import { Effect } from "effect";
2
2
  import { AccountPreferenceRows } from "#server/account-preferences/Rows.ts";
3
3
  import { providerFailure } from "#server/providerFailure.ts";
4
+ const DEFAULTS = { locale: "en", timezone: "UTC", units: "metric" };
4
5
  export const get = Effect.fn("AccountPreferencesStore.get")(function* (id) {
5
6
  const repository = yield* AccountPreferenceRows;
6
- return yield* repository.findById(id).pipe(Effect.map(({ locale, timezone, units }) => ({ locale, timezone, units })), Effect.catchTag("NoSuchElementError", () => Effect.succeed({ locale: "en", timezone: "UTC", units: "metric" })), Effect.catch(providerFailure));
7
+ return yield* repository.findById(id).pipe(Effect.map(({ locale, timezone, units }) => ({ locale, timezone, units })), Effect.catchTag("NoSuchElementError", () => Effect.succeed(DEFAULTS)), Effect.catch(providerFailure));
7
8
  });
8
9
  //# sourceMappingURL=get.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get.js","sourceRoot":"","sources":["../../../src/server/account-preferences/get.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,MAAM,CAAC,MAAM,GAAG,GAAG,MAAM,CAAC,EAAE,CAAC,6BAA6B,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAU;IAChF,MAAM,UAAU,GAAG,KAAK,CAAC,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AQ,EAAE,KAAK,EAAE,CAAC,CAAC,EAC/G,MAAM,CAAC,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,EACrE,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAC7B,CAAC;AACH,CAAC,CAAC,CAAC"}
@@ -6,13 +6,9 @@ export declare const AccountPreferencesStore: import("effect/Context").Service<"
6
6
  readonly units: "imperial" | "metric";
7
7
  }) => Effect.Effect<void, import("@shivaedev/errors/taxonomy.ts").AuthUnavailable, never>;
8
8
  readonly get: (id: string) => Effect.Effect<{
9
- locale: string;
10
- timezone: string;
11
- units: "imperial" | "metric";
12
- } | {
13
- locale: string;
14
- timezone: string;
15
- units: "metric";
9
+ readonly locale: string;
10
+ readonly timezone: string;
11
+ readonly units: "imperial" | "metric";
16
12
  }, import("@shivaedev/errors/taxonomy.ts").AuthUnavailable, never>;
17
13
  readonly set: (id: string, values: {
18
14
  readonly locale: string;
@@ -1 +1 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/server/account-preferences/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAOhC,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;CAKlC,CAAC"}
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/server/account-preferences/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAOhC,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;CAKlC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { createAuthMiddleware } from "better-auth/api";
2
2
  import { Effect, Option, Schema } from "effect";
3
- import { AccountPreferenceValues } from "#accountPreferences.ts";
3
+ import { AccountPreferenceValues } from "#accountPreferenceValues.ts";
4
4
  import { AccountPreferencesStore } from "#server/account-preferences/service.ts";
5
5
  export const accountPreferenceOptions = Effect.fnUntraced(function* (options) {
6
6
  const store = yield* AccountPreferencesStore;