@shivaedev/admin 0.17.0 → 0.18.1

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 (42) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +6 -6
  3. package/dist/adapters/matchAdminRoute.d.ts.map +1 -1
  4. package/dist/adapters/matchAdminRoute.js +4 -1
  5. package/dist/adapters/matchAdminRoute.js.map +1 -1
  6. package/dist/adapters/validateAdminRoutes.d.ts +3 -0
  7. package/dist/adapters/validateAdminRoutes.d.ts.map +1 -0
  8. package/dist/adapters/validateAdminRoutes.js +29 -0
  9. package/dist/adapters/validateAdminRoutes.js.map +1 -0
  10. package/dist/client/SessionsView.d.ts +1 -1
  11. package/dist/client/SessionsView.d.ts.map +1 -1
  12. package/dist/client/SessionsView.js.map +1 -1
  13. package/dist/jobs/page.d.ts +1 -1
  14. package/dist/jobs/retryPage.d.ts +43 -43
  15. package/dist/page.d.ts +3 -3
  16. package/dist/page.d.ts.map +1 -1
  17. package/dist/page.js +1 -1
  18. package/dist/page.js.map +1 -1
  19. package/dist/registry.d.ts.map +1 -1
  20. package/dist/registry.js +2 -4
  21. package/dist/registry.js.map +1 -1
  22. package/dist/server/adminDocuments.js +1 -1
  23. package/dist/server/adminDocuments.js.map +1 -1
  24. package/dist/server/users.d.ts +3 -2
  25. package/dist/server/users.d.ts.map +1 -1
  26. package/dist/server/users.js +8 -5
  27. package/dist/server/users.js.map +1 -1
  28. package/dist/server/usersHandlers.d.ts +2 -1
  29. package/dist/server/usersHandlers.d.ts.map +1 -1
  30. package/dist/server/usersHandlers.js +3 -3
  31. package/dist/server/usersHandlers.js.map +1 -1
  32. package/dist/sessions/Page.d.ts +1 -1
  33. package/dist/users/page.d.ts +5 -5
  34. package/package.json +14 -12
  35. package/src/adapters/matchAdminRoute.ts +4 -1
  36. package/src/adapters/validateAdminRoutes.ts +36 -0
  37. package/src/client/SessionsView.ts +1 -1
  38. package/src/page.ts +11 -7
  39. package/src/registry.ts +2 -4
  40. package/src/server/adminDocuments.ts +1 -1
  41. package/src/server/users.ts +8 -3
  42. package/src/server/usersHandlers.ts +4 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.18.1 - 2026-11-02
4
+
5
+ ### Changed
6
+
7
+ - Update `@shivaedev/changes` from 0.7.0 to 0.8.0.
8
+ - Update `@shivaedev/contract` from 0.30.2 to 0.31.0.
9
+ - Update `@shivaedev/identity` from 0.18.0 to 0.19.0.
10
+ - Update `@shivaedev/jobs` from 0.29.2 to 0.30.0.
11
+ - Update `@shivaedev/react` from 0.33.0 to 0.34.0.
12
+
13
+ ## 0.18.0 - 2026-11-02
14
+
15
+ ### Added
16
+
17
+ - Accept the application's Better Auth options in role assignment, provider-account role seeds and admin Users handlers to follow custom table and column mappings. Existing calls retain the default mapping.
18
+
19
+ ### Fixed
20
+
21
+ - Preserve permission read policies on admin page queries so live collection reads load and refresh after writes across tenants, while retaining the page grant and query restrictions.
22
+ - Apply the first registered page's permission to `/admin` and `/admin/` in both the client and server guards.
23
+ - Match detail routes with a declared trailing slash consistently with page routes.
24
+ - Accept session-scoped contracts in `adminPage` and preserve their scope through middleware and client binding, including queries using `readsCollections`.
25
+ - Redact scheduled worker logs using the same diagnostic policy as queue workers. Job details sanitize stored failure output and source failure output through the same schema as job listings, including native pg-boss timeout records.
26
+ - Preserve the configured role column when mounting stored roles, generating role-aware migrations and checking the auth schema.
27
+
28
+ ### Breaking
29
+
30
+ - Reject overlapping admin route patterns and detail paths outside their page at registry composition. Move colliding pages to distinct routes and place each detail under its page path.
31
+
3
32
  ## 0.17.0 - 2026-11-01
4
33
 
5
34
  ### Changed
package/README.md CHANGED
@@ -51,7 +51,7 @@ export const Jobs = adminPage({
51
51
  export const Admin = adminRegistry(Jobs);
52
52
  ```
53
53
 
54
- `Jobs.contract` keeps the native `.declaration` and `.application.toLayer` APIs. `adminRegistry(...pages)` returns `pages` and a native `group`. Duplicate page ids, route paths and RPC tags, including generated subscriptions, fail when the registry is created.
54
+ `Jobs.contract` keeps the native `.declaration` and `.application.toLayer` APIs. `adminRegistry(...pages)` returns `pages` and a native `group`. Duplicate page ids and RPC tags, including generated subscriptions, fail when the registry is created. Route patterns that can match the same path also fail, including a static page that overlaps another page's `$` detail parameter. Choose distinct routes rather than relying on route order.
55
55
 
56
56
  Register server handler Layers by page id in `src/modules/admin/jobs/server/registration.ts`, importing `Admin` and `Jobs` from that module's `pages.ts`:
57
57
 
@@ -77,9 +77,9 @@ Pass `registration.group` and `handlers` to the existing application's RPC host
77
77
 
78
78
  Provide the application's session policy through `SessionPolicy` once. Registration builds each page's permission layer with that policy. The handler Layer requires identity's `SessionPolicy` service.
79
79
 
80
- A page can declare `route: { path: "/admin/workspaces", detail: "/admin/workspaces/$id", title: "Workspaces" }`. The detail must be under the page's path. Mount `adminDocuments(registration, handler)` from `@shivaedev/admin/server/adminDocuments.ts` beside the application's public document routes and provide the same `SessionPolicy` layer. The handler serves the application's document; the guard checks the matched page's permission first. Unregistered admin paths return 404. `/admin` and `/admin/` use the first registered page's permission.
80
+ A page can declare `route: { path: "/admin/workspaces", detail: "/admin/workspaces/$id", title: "Workspaces" }`. The detail must be a descendant of the page's path; composition rejects a detail elsewhere or equal to the page path. Mount `adminDocuments(registration, handler)` from `@shivaedev/admin/server/adminDocuments.ts` beside the application's public document routes and provide the same `SessionPolicy` layer. The handler serves the application's document; the guard checks the matched page's permission first. Unregistered admin paths return 404. `/admin` and `/admin/` use the first registered page's permission.
81
81
 
82
- Use `adminPermissionGuard(registration.pages, permissionGuard({ session, signIn: "/sign-in" }))` from `@shivaedev/admin/client/adapters/adminPermissionGuard.ts` as the client root route's `beforeLoad`, using the native `permissionGuard` from `@shivaedev/react/permissionGuard.ts`. It applies the matched list or detail page's permission together with other route permissions. The application still declares the detail component in its router.
82
+ Use `adminPermissionGuard(registration.pages, permissionGuard({ session, signIn: "/sign-in" }))` from `@shivaedev/admin/client/adapters/adminPermissionGuard.ts` as the client root route's `beforeLoad`, using the native `permissionGuard` from `@shivaedev/react/adapters/permissionGuard.ts`. It applies the matched list or detail page's permission together with other route permissions. Like the document guard, `/admin` and `/admin/` use the first registered page's permission. The application still declares the detail component in its router.
83
83
 
84
84
  ### Pages owned by modules
85
85
 
@@ -210,7 +210,7 @@ A successful bound retry invalidates health, the affected queue's counts and bot
210
210
 
211
211
  ### Built-in Users page
212
212
 
213
- Call `usersPage(AppAccess)` from `@shivaedev/admin/users/page.ts` with the application's code-defined role set. Add the returned page to the same registry as Jobs and register `users: usersHandlers(UsersPage, AppAccess)` from `@shivaedev/admin/server/usersHandlers.ts`. The handlers use the application's existing Effect SQL client against Better Auth's default PostgreSQL `user` table and its `role` column. Custom table or column names are not supported.
213
+ Call `usersPage(AppAccess)` from `@shivaedev/admin/users/page.ts` with the application's code-defined role set. Add the returned page to the same registry as Jobs and register `users: usersHandlers(UsersPage, AppAccess)` from `@shivaedev/admin/server/usersHandlers.ts`. The handlers use the application's existing Effect SQL client. For custom auth tables, pass the same Better Auth options used by `betterAuthMount` as the third argument: `usersHandlers(UsersPage, AppAccess, authOptions)`. The list follows `user.modelName`, `user.fields.name`, `email` and `createdAt`, and `user.additionalFields.role.fieldName`; role changes also follow `user.fields.updatedAt`. Omitting the options keeps the default PostgreSQL `user` table and column names.
214
214
 
215
215
  Each user stores one role string accepted by `AppAccess.Role`. Each role declares an explicit permission list in application code. The Users area assigns roles; it does not edit their grants.
216
216
 
@@ -229,7 +229,7 @@ const changeRole = Client.runtime.fn(users.changeRole.run);
229
229
 
230
230
  `admin.users.changeRole` takes `{ userId, role }`; its role Schema is the application's declared role union. The handler also requires `AssignRoles` (`roles.assign`) from `@shivaedev/access/roles.ts`. The view shows a role select only to callers with that permission. Role writes use identity’s `assignRole` verb, serialize in a transaction and return `LastRoleAssigner` (from `@shivaedev/access/roles.ts`) if replacing the final holder's role would remove `roles.assign`, regardless of the role's name. A missing user returns `NotFound`. Changes invalidate the list after commit and emit an Effect log with actor id, target id, role and timestamp.
231
231
 
232
- Applications can call `listUsers(AppAccess, input)` and `changeUserRole(AppAccess, input)` from `@shivaedev/admin/server/users.ts` on the server. These enforce their respective domain permissions using `SessionUser`. Decode untrusted role input with `AppAccess.Role` before calling `changeUserRole` directly; native RPC performs that decode at the contract boundary. Identity resolves the caller's stored role through the session policy.
232
+ Applications can call `listUsers(AppAccess, input)` and `changeUserRole(AppAccess, input)` from `@shivaedev/admin/server/users.ts` on the server. Both also accept `authOptions` as a third argument for custom mappings. These enforce their respective domain permissions using `SessionUser`. Decode untrusted role input with `AppAccess.Role` before calling `changeUserRole` directly; native RPC performs that decode at the contract boundary. Identity resolves the caller's stored role through the session policy.
233
233
 
234
234
  Keep Better Auth cookie caching disabled so requests see current permissions. Route role writes through this operation to retain the final-assigner policy: the policy covers only `admin.users.changeRole`, so disable Better Auth's `/admin/set-role`, `/admin/update-user` and `/admin/create-user` browser endpoints, which write roles outside it. Better Auth's server-side APIs stay available for trusted code such as a bootstrap command.
235
235
 
@@ -255,7 +255,7 @@ The view lists signed-in sessions with the user's name and email, started, last
255
255
 
256
256
  ### Client permission routes
257
257
 
258
- `adminPage` requires a permission middleware, including for custom pages. It applies that middleware to the whole contract, installs a read policy checking the page grant on every query, and exposes its permission as `page.route.permission`. Queries need no repeated page-grant policy. An additional query policy can restrict access further. Bound live queries use the same page grant as one-off reads. Set the React route's `staticData.permission` to that value. Use `permissionGuard` from `@shivaedev/react/permissionGuard.ts` in protected routes' `beforeLoad` and wrap the router in `PermissionBoundary` from `@shivaedev/react/client/permissionBoundary.ts` with the session and one application fallback.
258
+ `adminPage` requires a permission middleware, including for custom pages. It applies that middleware to the whole contract, installs a read policy checking the page grant on every query, and exposes its permission as `page.route.permission`. Queries need no repeated page-grant policy. An additional query policy can restrict access further. Bound live queries use the same page grant as one-off reads. Set the React route's `staticData.permission` to that value. Use `permissionGuard` from `@shivaedev/react/adapters/permissionGuard.ts` in protected routes' `beforeLoad` and wrap the router in `PermissionBoundary` from `@shivaedev/react/adapters/permissionBoundary.ts` with the session and one application fallback.
259
259
 
260
260
  ### Install and limits
261
261
 
@@ -1 +1 @@
1
- {"version":3,"file":"matchAdminRoute.d.ts","sourceRoot":"","sources":["../../src/adapters/matchAdminRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,UAAU,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAgBvG"}
1
+ {"version":3,"file":"matchAdminRoute.d.ts","sourceRoot":"","sources":["../../src/adapters/matchAdminRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,UAAU,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAmBvG"}
@@ -1,11 +1,14 @@
1
1
  export function matchAdminRoute(routes, pathname) {
2
2
  const path = pathname.replace(/\/$/u, "");
3
+ if (path === "/admin") {
4
+ return routes[0];
5
+ }
3
6
  return (routes.find((route) => route.path.replace(/\/$/u, "") === path)
4
7
  ?? routes.find((route) => {
5
8
  if (route.detail === undefined) {
6
9
  return false;
7
10
  }
8
- const expected = route.detail.split("/");
11
+ const expected = route.detail.replace(/\/$/u, "").split("/");
9
12
  const actual = path.split("/");
10
13
  return (expected.length === actual.length
11
14
  && expected.every((segment, index) => (segment.startsWith("$") ? actual[index] !== "" : segment === actual[index])));
@@ -1 +1 @@
1
- {"version":3,"file":"matchAdminRoute.js","sourceRoot":"","sources":["../../src/adapters/matchAdminRoute.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,eAAe,CAAC,MAA6B,EAAE,QAAgB;IAC9E,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC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CAAC,KAAK,IAAI,CAAC;WAC5D,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;YACxB,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;gBAChC,OAAO,KAAK,CAAC;YACd,CAAC;YACD,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC7D,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC/B,OAAO,CACN,QAAQ,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM;mBAC9B,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CACnH,CAAC;QACH,CAAC,CAAC,CACF,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { AdminRoute } from "#page.ts";
2
+ export declare function validateAdminRoutes(routes: readonly AdminRoute[]): void;
3
+ //# sourceMappingURL=validateAdminRoutes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateAdminRoutes.d.ts","sourceRoot":"","sources":["../../src/adapters/validateAdminRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAsB3C,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,UAAU,EAAE,GAAG,IAAI,CAavE"}
@@ -0,0 +1,29 @@
1
+ function overlaps(left, right) {
2
+ const expected = left.split("/");
3
+ const actual = right.split("/");
4
+ return (expected.length === actual.length
5
+ && expected.every((segment, index) => segment === actual[index] || (segment === "$" && actual[index] !== "") || (actual[index] === "$" && segment !== "")));
6
+ }
7
+ function pathsOf(route) {
8
+ const page = route.path.replace(/\/$/u, "");
9
+ const detail = route.detail?.replace(/\/$/u, "");
10
+ if (detail !== undefined && !detail.startsWith(`${page}/`)) {
11
+ throw new Error(`Admin detail path ${route.detail} must be under page path ${route.path}`);
12
+ }
13
+ return detail === undefined ? [page] : [page, detail];
14
+ }
15
+ export function validateAdminRoutes(routes) {
16
+ const paths = [];
17
+ for (const path of routes.flatMap(pathsOf)) {
18
+ const normalized = path.replace(/\$[^/]+/gu, "$");
19
+ if (paths.includes(normalized)) {
20
+ throw new Error(`Duplicate admin path: ${normalized}`);
21
+ }
22
+ const existing = paths.find((candidate) => overlaps(candidate, normalized));
23
+ if (existing !== undefined) {
24
+ throw new Error(`Overlapping admin paths: ${existing} and ${normalized}`);
25
+ }
26
+ paths.push(normalized);
27
+ }
28
+ }
29
+ //# sourceMappingURL=validateAdminRoutes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateAdminRoutes.js","sourceRoot":"","sources":["../../src/adapters/validateAdminRoutes.ts"],"names":[],"mappings":"AAEA,SAAS,QAAQ,CAAC,IAAY,EAAE,KAAa;IAC5C,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAChC,OAAO,CACN,QAAQ,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM;WAC9B,QAAQ,CAAC,KAAK,CAChB,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,KAAK,GAAG,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,OAAO,KAAK,EAAE,CAAC,CACvI,CACD,CAAC;AACH,CAAC;AAED,SAAS,OAAO,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AC;AACF,CAAC"}
@@ -2,7 +2,7 @@ import { type Effect } from "effect";
2
2
  import type * as AsyncResult from "effect/reactivity/AsyncResult";
3
3
  import type * as Atom from "effect/reactivity/Atom";
4
4
  import type { SessionList, SessionListInput } from "@shivaedev/identity/sessions.ts";
5
- import type { AtomServices } from "@shivaedev/react/fieldRejection.ts";
5
+ import type { AtomServices } from "@shivaedev/react/AtomServices.ts";
6
6
  export interface SessionsViewProps<R, E> {
7
7
  readonly currentSessionId: string | undefined;
8
8
  readonly list: (input: typeof SessionListInput.Type) => Atom.Atom<AsyncResult.AsyncResult<typeof SessionList.Type, unknown>>;
@@ -1 +1 @@
1
- {"version":3,"file":"SessionsView.d.ts","sourceRoot":"","sources":["../../src/client/SessionsView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,MAAM,EAAqB,MAAM,QAAQ,CAAC;AAC/D,OAAO,KAAK,KAAK,WAAW,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAEpD,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAmB,MAAM,iCAAiC,CAAC;AAEtG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAKvE,MAAM,WAAW,iBAAiB,CAAC,CAAC,EAAE,CAAC;IACtC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9C,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,gBAAgB,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,OAAO,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IAC7H,QAAQ,CAAC,uBAAuB,EAAE,MAAM,IAAI,CAAC;IAC7C,QAAQ,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;KAAE,KAAK,MAAM,CA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AM,CAAC,OAAO;QACvB,QAAQ;KACR,CAAC,EACF,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,eAAe,EAAE,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,EAC1I,aAAa,CAAC,iBAAiB,EAAE;QAChC,OAAO;QACP,IAAI;QACJ,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE;YACZ,MAAM,CAAC,SAAS,CAAC,CAAC;YAClB,UAAU,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC;QACD,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO;KACxC,CAAC,CACF,CAAC;AACH,CAAC"}
@@ -195,7 +195,7 @@ export declare function jobsPage<const TQueues extends readonly JobsEntry[]>(...
195
195
  readonly queryIndexes: Schema.optional<Schema.$Array<Schema.Number>>;
196
196
  }>, Schema.Struct<{
197
197
  readonly _tag: Schema.Literal<"Resync">;
198
- }>]>, ...never[]]>, Schema.Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, typeof import("@shivaedev/contract/WebSocketRequired.ts").WebSocketRequired, ...Schema.Union<readonly (typeof import("@shivaedev/errors/taxonomy.ts").BadRequest | typeof import("#jobs/schemas.ts").JobsUnavailable | typeof import("#jobs/schemas.ts").JobsPayloadInvalid | typeof import("#jobs/schemas.ts").JobsQueueUnregistered)[]>[]]>>, Schema.Never, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.counts", Schema.Struct<{
198
+ }>]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, ...never[]]>, Schema.Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, typeof import("@shivaedev/contract/WebSocketRequired.ts").WebSocketRequired, ...Schema.Union<readonly (typeof import("@shivaedev/errors/taxonomy.ts").BadRequest | typeof import("#jobs/schemas.ts").JobsUnavailable | typeof import("#jobs/schemas.ts").JobsPayloadInvalid | typeof import("#jobs/schemas.ts").JobsQueueUnregistered)[]>[]]>>, Schema.Never, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.counts", Schema.Struct<{
199
199
  queue: Schema.String;
200
200
  }>, Schema.Struct<{
201
201
  readonly activeCount: Schema.Number;
@@ -187,7 +187,25 @@ export declare function jobsPageWithRetry<const TQueues extends readonly JobsEnt
187
187
  readonly JobsUnavailable: typeof import("./schemas.ts").JobsUnavailable;
188
188
  readonly Forbidden: typeof Forbidden;
189
189
  readonly JobsNotFailed: typeof JobsNotFailed;
190
- }>>], import("effect/rpc/Rpc").Rpc<"admin.jobs.$changes", Schema.Struct<{
190
+ }>>], import("effect/rpc/Rpc").Rpc<"admin.jobs.job", Schema.Struct<{
191
+ id: Schema.String;
192
+ queue: Schema.String;
193
+ }>, Schema.OptionFromNullOr<Schema.Union<Schema.Struct<{
194
+ readonly attempt: Schema.Number;
195
+ readonly completedOn: Schema.OptionFromNullOr<Schema.DateTimeUtcFromString>;
196
+ readonly createdOn: Schema.DateTimeUtcFromString;
197
+ readonly id: Schema.String;
198
+ readonly output: Schema.NullOr<Schema.Struct<{
199
+ readonly _tag: Schema.withDecodingDefaultKey<Schema.String, never>;
200
+ readonly message: Schema.decodeTo<Schema.String, Schema.String, never, never>;
201
+ }>>;
202
+ readonly retryCount: Schema.Number;
203
+ readonly retryLimit: Schema.Number;
204
+ readonly startedOn: Schema.OptionFromNullOr<Schema.DateTimeUtcFromString>;
205
+ readonly state: Schema.Literals<readonly ["created", "retry", "active", "completed", "cancelled", "failed"]>;
206
+ readonly data: Schema.Unknown;
207
+ readonly queue: Schema.Literal<string>;
208
+ }>[]>>, Schema.Union<readonly [Schema.Union<readonly (typeof import("@shivaedev/errors/taxonomy.ts").BadRequest | typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.$changes", Schema.Struct<{
191
209
  queries: Schema.$Array<Schema.Union<readonly (Schema.Struct<{
192
210
  query: Schema.Literal<"counts">;
193
211
  payload: Schema.Struct<{
@@ -235,14 +253,28 @@ export declare function jobsPageWithRetry<const TQueues extends readonly JobsEnt
235
253
  readonly queryIndexes: Schema.optional<Schema.$Array<Schema.Number>>;
236
254
  }>, Schema.Struct<{
237
255
  readonly _tag: Schema.Literal<"Resync">;
238
- }>]>, ...never[]]>, Schema.Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, typeof import("@shivaedev/contract/WebSocketRequired.ts").WebSocketRequired, ...Schema.Union<readonly (typeof import("@shivaedev/errors/taxonomy.ts").BadRequest | typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>[]]>>, Schema.Never, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.counts", Schema.Struct<{
256
+ }>]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, ...never[]]>, Schema.Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, typeof import("@shivaedev/contract/WebSocketRequired.ts").WebSocketRequired, ...Schema.Union<readonly (typeof import("@shivaedev/errors/taxonomy.ts").BadRequest | typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>[]]>>, Schema.Never, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.counts", Schema.Struct<{
239
257
  queue: Schema.String;
240
258
  }>, Schema.Struct<{
241
259
  readonly activeCount: Schema.Number;
242
260
  readonly failedCount: Schema.Number;
243
261
  readonly queuedCount: Schema.Number;
244
262
  readonly totalCount: Schema.Number;
245
- }>, Schema.Union<readonly [Schema.Union<readonly (typeof import("@shivaedev/errors/taxonomy.ts").BadRequest | typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.deadLettered", Schema.Struct<{
263
+ }>, Schema.Union<readonly [Schema.Union<readonly (typeof import("@shivaedev/errors/taxonomy.ts").BadRequest | typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.health", Schema.Void, Schema.Struct<{
264
+ readonly activeTotal: Schema.Number;
265
+ readonly deadLetteredTotal: Schema.Number;
266
+ readonly failedTotal: Schema.Number;
267
+ readonly jobs: Schema.$Array<Schema.Struct<{
268
+ readonly activeCount: Schema.Number;
269
+ readonly deadLetteredCount: Schema.Number;
270
+ readonly failedCount: Schema.Number;
271
+ readonly name: Schema.String;
272
+ readonly queuedCount: Schema.Number;
273
+ readonly readyCount: Schema.Number;
274
+ }>>;
275
+ readonly queuedTotal: Schema.Number;
276
+ readonly readyTotal: Schema.Number;
277
+ }>, Schema.Union<readonly [Schema.Union<readonly (typeof import("@shivaedev/errors/taxonomy.ts").BadRequest | typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.failed", Schema.Struct<{
246
278
  cursor: Schema.optionalKey<Schema.String>;
247
279
  limit: Schema.Number;
248
280
  queue: Schema.String;
@@ -262,15 +294,9 @@ export declare function jobsPageWithRetry<const TQueues extends readonly JobsEnt
262
294
  readonly state: Schema.Literals<readonly ["created", "retry", "active", "completed", "cancelled", "failed"]>;
263
295
  readonly data: Schema.Unknown;
264
296
  readonly queue: Schema.Literal<string>;
265
- readonly sourceId: Schema.OptionFromNullOr<Schema.String>;
266
- readonly sourceOutput: Schema.NullOr<Schema.Struct<{
267
- readonly _tag: Schema.withDecodingDefaultKey<Schema.String, never>;
268
- readonly message: Schema.decodeTo<Schema.String, Schema.String, never, never>;
269
- }>>;
270
- readonly sourceQueue: Schema.Literal<string>;
271
297
  }>[]>>;
272
298
  readonly next: Schema.OptionFromNullOr<Schema.String>;
273
- }>, Schema.Union<readonly [Schema.Union<readonly (typeof import("@shivaedev/errors/taxonomy.ts").BadRequest | typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.failed", Schema.Struct<{
299
+ }>, Schema.Union<readonly [Schema.Union<readonly (typeof import("@shivaedev/errors/taxonomy.ts").BadRequest | typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.deadLettered", Schema.Struct<{
274
300
  cursor: Schema.optionalKey<Schema.String>;
275
301
  limit: Schema.Number;
276
302
  queue: Schema.String;
@@ -290,41 +316,15 @@ export declare function jobsPageWithRetry<const TQueues extends readonly JobsEnt
290
316
  readonly state: Schema.Literals<readonly ["created", "retry", "active", "completed", "cancelled", "failed"]>;
291
317
  readonly data: Schema.Unknown;
292
318
  readonly queue: Schema.Literal<string>;
319
+ readonly sourceId: Schema.OptionFromNullOr<Schema.String>;
320
+ readonly sourceOutput: Schema.NullOr<Schema.Struct<{
321
+ readonly _tag: Schema.withDecodingDefaultKey<Schema.String, never>;
322
+ readonly message: Schema.decodeTo<Schema.String, Schema.String, never, never>;
323
+ }>>;
324
+ readonly sourceQueue: Schema.Literal<string>;
293
325
  }>[]>>;
294
326
  readonly next: Schema.OptionFromNullOr<Schema.String>;
295
- }>, Schema.Union<readonly [Schema.Union<readonly (typeof import("@shivaedev/errors/taxonomy.ts").BadRequest | typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.health", Schema.Void, Schema.Struct<{
296
- readonly activeTotal: Schema.Number;
297
- readonly deadLetteredTotal: Schema.Number;
298
- readonly failedTotal: Schema.Number;
299
- readonly jobs: Schema.$Array<Schema.Struct<{
300
- readonly activeCount: Schema.Number;
301
- readonly deadLetteredCount: Schema.Number;
302
- readonly failedCount: Schema.Number;
303
- readonly name: Schema.String;
304
- readonly queuedCount: Schema.Number;
305
- readonly readyCount: Schema.Number;
306
- }>>;
307
- readonly queuedTotal: Schema.Number;
308
- readonly readyTotal: Schema.Number;
309
- }>, Schema.Union<readonly [Schema.Union<readonly (typeof import("@shivaedev/errors/taxonomy.ts").BadRequest | typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.job", Schema.Struct<{
310
- id: Schema.String;
311
- queue: Schema.String;
312
- }>, Schema.OptionFromNullOr<Schema.Union<Schema.Struct<{
313
- readonly attempt: Schema.Number;
314
- readonly completedOn: Schema.OptionFromNullOr<Schema.DateTimeUtcFromString>;
315
- readonly createdOn: Schema.DateTimeUtcFromString;
316
- readonly id: Schema.String;
317
- readonly output: Schema.NullOr<Schema.Struct<{
318
- readonly _tag: Schema.withDecodingDefaultKey<Schema.String, never>;
319
- readonly message: Schema.decodeTo<Schema.String, Schema.String, never, never>;
320
- }>>;
321
- readonly retryCount: Schema.Number;
322
- readonly retryLimit: Schema.Number;
323
- readonly startedOn: Schema.OptionFromNullOr<Schema.DateTimeUtcFromString>;
324
- readonly state: Schema.Literals<readonly ["created", "retry", "active", "completed", "cancelled", "failed"]>;
325
- readonly data: Schema.Unknown;
326
- readonly queue: Schema.Literal<string>;
327
- }>[]>>, Schema.Union<readonly [Schema.Union<readonly (typeof import("@shivaedev/errors/taxonomy.ts").BadRequest | typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.retry", Schema.Struct<{
327
+ }>, Schema.Union<readonly [Schema.Union<readonly (typeof import("@shivaedev/errors/taxonomy.ts").BadRequest | typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.retry", Schema.Struct<{
328
328
  id: Schema.String;
329
329
  queue: Schema.String;
330
330
  }>, Schema.Void, Schema.Union<readonly (typeof Forbidden | typeof import("@shivaedev/errors/taxonomy.ts").BadRequest | typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered | typeof JobsNotFailed)[]>, typeof JobsPermission, never>, readonly [], undefined>;
package/dist/page.d.ts CHANGED
@@ -32,18 +32,18 @@ type PageQueries<TQueries extends readonly QueryShape[]> = {
32
32
  };
33
33
  };
34
34
  type PageRpcs<TRpc> = TRpc extends Rpc.Rpc<infer TTag, infer TPayload, infer TSuccess, infer TError, infer TMiddleware, infer R> ? Rpc.Rpc<TTag, TPayload, TSuccess, TError, TMiddleware, R | SessionUser> : never;
35
- export declare function adminPage<const TId extends string, const TRoute extends Omit<AdminRoute, "permission">, const TName extends string, const TQueries extends readonly QueryShape[], const TCommands extends readonly CommandShape[], TRpcs extends Rpc.AnyWithProps, const TStreams extends readonly StreamShape[], TMiddleware extends RpcMiddleware.AnyService & PagePermission>(page: {
35
+ export declare function adminPage<const TId extends string, const TRoute extends Omit<AdminRoute, "permission">, const TName extends string, const TQueries extends readonly QueryShape[], const TCommands extends readonly CommandShape[], TRpcs extends Rpc.AnyWithProps, const TStreams extends readonly StreamShape[], TMiddleware extends RpcMiddleware.AnyService & PagePermission, const TScope extends "session" | undefined = undefined>(page: {
36
36
  readonly id: TId;
37
37
  readonly route: TRoute;
38
38
  readonly permission: TMiddleware;
39
- readonly contract: Contract<TName, TQueries, TCommands, TRpcs, TStreams>;
39
+ readonly contract: Contract<TName, TQueries, TCommands, TRpcs, TStreams, TScope>;
40
40
  }): AdminPage & {
41
41
  readonly route: TRoute & {
42
42
  readonly permission: Permission;
43
43
  };
44
44
  readonly id: TId;
45
45
  readonly permissionKey: TMiddleware["key"];
46
- readonly contract: Contract<TName, PageQueries<TQueries>, TCommands, Rpc.AddMiddleware<PageRpcs<TRpcs>, TMiddleware>, TStreams>;
46
+ readonly contract: Contract<TName, PageQueries<TQueries>, TCommands, Rpc.AddMiddleware<PageRpcs<TRpcs>,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CAAC,EAAE,EAAE,GAAG,CAAC;IACjB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;CACjF,GAAG,SAAS,GAAG;IACf,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG;QAAE,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAA;KAAE,CAAC;IAC7D,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC;IACjB,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;IAC3C,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,QAAQ,CAAC,EAAE,SAAS,EAAE,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;CACxI,CAAC"}
package/dist/page.js CHANGED
@@ -7,7 +7,7 @@ export function adminPage(page) {
7
7
  const { declaration } = page.contract;
8
8
  const queries = declaration.queries.map((query) => ({
9
9
  ...query,
10
- readPolicy: (payload, viewer) => Effect.flatMap(SessionUser, (user) => hasPermission(user, page.permission.permission) ? (query.readPolicy?.(payload, viewer) ?? Effect.succeed(true)) : Effect.succeed(false)),
10
+ readPolicy: Object.assign((payload, viewer) => Effect.flatMap(SessionUser, (user) => hasPermission(user, page.permission.permission) ? (query.readPolicy?.(payload, viewer) ?? Effect.succeed(true)) : Effect.succeed(false)), query.readPolicy),
11
11
  }));
12
12
  let protectedContract = contract(declaration.name, { ...declaration, queries });
13
13
  const original = page.contract.requests.values().next().value;
package/dist/page.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"page.js","sourceRoot":"","sources":["../src/page.ts"],"names":[],"mappings":"A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BAAgB,EAAE,IAAI,WAAW,SAAS,SAAS;IACzG,MAAM,MAAM,SAAS,gBAAgB;IACrC,GAAG,MAAM,KAAK,SAAS,SAAS,gBAAgB,EAAE;CAClD,GACE,SAAS,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,EAAE,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC,GACtD,MAAM,SAAS,WAAW,CAAC,QAAQ,CAAC,GACnC,SAAS,WAAW,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,EAAE,GAC/C,SAAS,EAAE,CAAC;AAEhB,wBAAgB,oBAAoB,CAAC,KAAK,CAAC,WAAW,SAAS,SAAS,gBAAgB,EAAE,EACzF,GAAG,UAAU,EAAE,WAAW,GAAG,aAAa,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,GACpE,aAAa,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC;AAK7C,wBAAgB,aAAa,CAAC,KAAK,CAAC,MAAM,SAAS,SAAS,SAAS,EAAE,EAAE,GAAG,KAAK,EAAE,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,CAiBxI"}
package/dist/registry.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { RpcGroup } from "effect/rpc";
2
+ import { validateAdminRoutes } from "#adapters/validateAdminRoutes.ts";
2
3
  export function mergeAdminRegistries(...registries) {
3
4
  return adminRegistry(...registries.flatMap((registry) => registry.pages));
4
5
  }
5
6
  export function adminRegistry(...pages) {
6
7
  const ids = new Set();
7
- const paths = new Set();
8
8
  const tags = new Set();
9
9
  function unique(seen, value, kind) {
10
10
  if (seen.has(value)) {
@@ -14,13 +14,11 @@ export function adminRegistry(...pages) {
14
14
  }
15
15
  for (const page of pages) {
16
16
  unique(ids, page.id, "page id");
17
- for (const path of [page.route.path, ...(page.route.detail === undefined ? [] : [page.route.detail])]) {
18
- unique(paths, path.replace(/\$[^/]+/gu, "$").replace(/\/$/u, ""), "path");
19
- }
20
17
  for (const tag of page.contract.requests.keys()) {
21
18
  unique(tags, tag, "RPC tag");
22
19
  }
23
20
  }
21
+ validateAdminRoutes(pages.map((page) => page.route));
24
22
  return { group: RpcGroup.make().merge(...pages.map((page) => page.contract)), pages };
25
23
  }
26
24
  //# sourceMappingURL=registry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAkCtC,MAAM,UAAU,oBAAoB,CAAC,GAAG,UAAuC;IAC9E,OAAO,aAAa,CAAC,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;AAC3E,CAAC;AAED,MAAM,UAAU,aAAa,CAA4C,GAAG,KAAqC;IAChH,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9B,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAChC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,SAAS,MAAM,CAAC,IAAiB,EAAE,KAAa,EAAE,IAAY;QAC7D,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,mBAAmB,IAAI,KAAK,KAAK,EAAE,CAAC,CAAC;QACtD,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC1B,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;QAChC,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC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AAC;YACrB,MAAM,IAAI,KAAK,CAAC,mBAAmB,IAAI,KAAK,KAAK,EAAE,CAAC,CAAC;QACtD,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC1B,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;QAChC,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC;YACjD,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;QAC9B,CAAC;IACF,CAAC;IACD,mBAAmB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACrD,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;AACvF,CAAC"}
@@ -8,7 +8,7 @@ export function adminDocuments(registry, handler) {
8
8
  return HttpRouter.use((router) => Effect.gen(function* () {
9
9
  yield* router.add("GET", "/admin/*", (request) => {
10
10
  const path = new URL(request.url, "http://localhost").pathname;
11
- const route = path.replace(/\/$/u, "") === "/admin" ? routes[0] : matchAdminRoute(routes, path);
11
+ const route = matchAdminRoute(routes, path);
12
12
  return route === undefined
13
13
  ? Effect.succeed(HttpServerResponse.empty({ status: HttpStatus.fromLiteral("NotFound") }))
14
14
  : permissionRoute(route.permission)(handler)(request);
@@ -1 +1 @@
1
- {"version":3,"file":"adminDocuments.js","sourceRoot":"","sources":["../../src/server/adminDocuments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,C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} from "effect/sql";
3
3
  import type { AccessPolicy } from "@shivaedev/access/roleSet.ts";
4
4
  import { AuthUnavailable } from "@shivaedev/errors/taxonomy.ts";
5
5
  import { SessionUser } from "@shivaedev/identity/identity.ts";
6
+ import { type AuthTableOptions } from "@shivaedev/identity/server/better-auth/adapters/tables.ts";
6
7
  import { type ChangeRoleInput } from "#users/roles.ts";
7
8
  export declare const listUsers: <TRole extends string>(access: Pick<AccessPolicy<TRole>, "Role">, input: {
8
9
  readonly cursor?: string;
9
10
  readonly limit: number;
10
- }) => Effect.Effect<{
11
+ }, options?: AuthTableOptions | undefined) => Effect.Effect<{
11
12
  next: Option.Option<string>;
12
13
  users: {
13
14
  readonly createdAt: DateTime.Utc;
@@ -17,5 +18,5 @@ export declare const listUsers: <TRole extends string>(access: Pick<AccessPolicy
17
18
  readonly role: TRole;
18
19
  }[];
19
20
  }, AuthUnavailable | import("@shivaedev/errors/taxonomy.ts").Forbidden, SessionUser | SqlClient.SqlClient>;
20
- export declare const changeUserRole: <TRole extends string>(access: Pick<AccessPolicy<TRole>, "Role" | "hasPermission">, input: ChangeRoleInput<TRole>) => Effect.Effect<void, AuthUnavailable | import("@shivaedev/errors/taxonomy.ts").Forbidden | import("@shivaedev/access/roles.ts").LastRoleAssigner | import("@shivaedev/errors/taxonomy.ts").NotFound, SessionUser | SqlClient.SqlClient>;
21
+ export declare const changeUserRole: <TRole extends string>(access: Pick<AccessPolicy<TRole>, "Role" | "hasPermission">, input: ChangeRoleInput<TRole>, options?: AuthTableOptions | undefined) => Effect.Effect<void, AuthUnavailable | import("@shivaedev/errors/taxonomy.ts").Forbidden | import("@shivaedev/access/roles.ts").LastRoleAssigner | import("@shivaedev/errors/taxonomy.ts").NotFound, SessionUser | SqlClient.SqlClient>;
21
22
  //# sourceMappingURL=users.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../src/server/users.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAa,MAAM,YAAY,CAAC;AAElD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAG9D,OAAO,EAAW,KAAK,eAAe,EAAsB,MAAM,iBAAiB,CAAC;AAMpF,eAAO,MAAM,SAAS,GAA2C,KAAK,SAAS,MAAM;;;;;;;;;;;;0GAenF,CAAC;AAEH,eAAO,MAAM,cAAc,GAAgD,KAAK,SAAS,MAAM,uUAW7F,CAAC"}
1
+ {"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../src/server/users.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAa,MAAM,YAAY,CAAC;AAElD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,KAAK,gBAAgB,EAAU,MAAM,2DAA2D,CAAC;AAG1G,OAAO,EAAW,KAAK,eAAe,EAAsB,MAAM,iBAAiB,CAAC;AAMpF,eAAO,MAAM,SAAS,GAA2C,KAAK,SAAS,MAAM;;;;;;;;;;;;0GAkBnF,CAAC;AAEH,eAAO,MAAM,cAAc,GAAgD,KAAK,SAAS,MAAM,+WAY7F,CAAC"}
@@ -4,17 +4,20 @@ import { requirePermission } from "@shivaedev/access/requirePermission.ts";
4
4
  import { AssignRoles } from "@shivaedev/access/roles.ts";
5
5
  import { AuthUnavailable } from "@shivaedev/errors/taxonomy.ts";
6
6
  import { SessionUser } from "@shivaedev/identity/identity.ts";
7
+ import { tables } from "@shivaedev/identity/server/better-auth/adapters/tables.ts";
7
8
  import { assignRole } from "@shivaedev/identity/server/better-auth/assignRole.ts";
8
9
  import { ReadUsers } from "#permissions.ts";
9
10
  import { AppUser } from "#users/roles.ts";
10
11
  function unavailable() {
11
12
  return new AuthUnavailable({ message: "Could not access app users" });
12
13
  }
13
- export const listUsers = Effect.fn("Admin.listUsers")(function* (access, input) {
14
+ export const listUsers = Effect.fn("Admin.listUsers")(function* (access, input, options) {
14
15
  yield* requirePermission(yield* SessionUser, ReadUsers);
15
- const sql = yield* SqlClient.SqlClient;
16
+ const sql = (yield* SqlClient.SqlClient).withoutTransforms();
17
+ const { user } = tables(options);
16
18
  const read = SqlSchema.findAll({
17
- execute: () => sql `select id, name, email, role, "createdAt" from "user"
19
+ execute: () => sql `select id, ${sql(user.name)} as name, ${sql(user.email)} as email,
20
+ ${sql(user.role)} as role, ${sql(user.createdAt)} as "createdAt" from ${sql(user.table)}
18
21
  where id > ${input.cursor ?? ""} order by id limit ${input.limit + 1}`,
19
22
  Request: Schema.Void,
20
23
  Result: Schema.Struct({ ...AppUser.fields, role: access.Role }),
@@ -23,10 +26,10 @@ export const listUsers = Effect.fn("Admin.listUsers")(function* (access, input)
23
26
  const users = rows.slice(0, input.limit);
24
27
  return { next: rows.length > input.limit ? Option.fromUndefinedOr(users.at(-1)?.id) : Option.none(), users };
25
28
  });
26
- export const changeUserRole = Effect.fn("Admin.changeUserRole")(function* (access, input) {
29
+ export const changeUserRole = Effect.fn("Admin.changeUserRole")(function* (access, input, options) {
27
30
  const actor = yield* SessionUser;
28
31
  yield* requirePermission(actor, AssignRoles);
29
- const changed = yield* assignRole(access, input.userId, input.role);
32
+ const changed = yield* assignRole(access, input.userId, input.role, options);
30
33
  if (changed) {
31
34
  const changedAt = DateTime.formatIso(yield* DateTime.now);
32
35
  yield* Effect.logInfo("User role changed").pipe(Effect.annotateLogs({ actorId: actor.id, changedAt, ...input }));
@@ -1 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B,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;IAC7C,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC7E,IAAI,OAAO,EAAE,CAAC;QACb,MAAM,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC1D,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC;IAClH,CAAC;AACF,CAAC,CAAC,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import type { AccessPolicy } from "@shivaedev/access/roleSet.ts";
2
+ import type { AuthTableOptions } from "@shivaedev/identity/server/better-auth/adapters/tables.ts";
2
3
  import type { usersPage } from "#users/page.ts";
3
- export declare function usersHandlers<const TRole extends string>(page: ReturnType<typeof usersPage<TRole>>, access: Pick<AccessPolicy<TRole>, "Role" | "hasPermission">): import("effect/Layer").Layer<import("effect/rpc/Rpc").Handler<"admin.users.changeRole"> | import("effect/rpc/Rpc").Handler<"admin.users.list">, never, import("effect/sql/SqlClient").SqlClient>;
4
+ export declare function usersHandlers<const TRole extends string>(page: ReturnType<typeof usersPage<TRole>>, access: Pick<AccessPolicy<TRole>, "Role" | "hasPermission">, options?: AuthTableOptions): import("effect/Layer").Layer<import("effect/rpc/Rpc").Handler<"admin.users.changeRole"> | import("effect/rpc/Rpc").Handler<"admin.users.list">, never, import("effect/sql/SqlClient").SqlClient>;
4
5
  //# sourceMappingURL=usersHandlers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"usersHandlers.d.ts","sourceRoot":"","sources":["../../src/server/usersHandlers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAKjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,wBAAgB,aAAa,CAAC,KAAK,CAAC,KAAK,SAAS,MAAM,EACvD,IAAI,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC,EACzC,MAAM,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,eAAe,CAAC,oMAU3D"}
1
+ {"version":3,"file":"usersHandlers.d.ts","sourceRoot":"","sources":["../../src/server/usersHandlers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAIjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2DAA2D,CAAC;AAElG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,wBAAgB,aAAa,CAAC,KAAK,CAAC,KAAK,SAAS,MAAM,EACvD,IAAI,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC,EACzC,MAAM,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,eAAe,CAAC,EAC3D,OAAO,CAAC,EAAE,gBAAgB,oMAU1B"}
@@ -3,12 +3,12 @@ import { AssignRoles } from "@shivaedev/access/roles.ts";
3
3
  import { SessionUser } from "@shivaedev/identity/identity.ts";
4
4
  import { hasPermission } from "@shivaedev/identity/permission.ts";
5
5
  import { changeUserRole, listUsers } from "#server/users.ts";
6
- export function usersHandlers(page, access) {
6
+ export function usersHandlers(page, access, options) {
7
7
  return page.contract.application.toLayer({
8
- "admin.users.changeRole": (input) => changeUserRole(access, input),
8
+ "admin.users.changeRole": (input) => changeUserRole(access, input, options),
9
9
  "admin.users.list": (input) => Effect.gen(function* () {
10
10
  const user = yield* SessionUser;
11
- return { ...(yield* listUsers(access, input)), canChangeRoles: hasPermission(user, AssignRoles) };
11
+ return { ...(yield* listUsers(access, input, options)), canChangeRoles: hasPermission(user, AssignRoles) };
12
12
  }),
13
13
  });
14
14
  }
@@ -1 +1 @@
1
- {"version":3,"file":"usersHandlers.js","sourceRoot":"","sources":["../../src/server/usersHandlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG7D,MAAM,UAAU,aAAa,CAC5B,IAAyC,EACzC,MAA2D;IAE3D,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC;QACxC,wBAAwB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,MAAM,EAAE,KAAK,CAAC;QAClE,kBAAkB,EAAE,CAAC,KAAK,EAAE,EAAE,CAC7B,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;YACnB,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,WAAW,CAAC;YAChC,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,EAAE,cAAc,EAAE,aAAa,CAAC,IAAI,EAAE,WAAW,CAAC,EAAE,CAAC;QACnG,CAAC,CAAC;KACH,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"usersHandlers.js","sourceRoot":"","sources":["../../src/server/usersHandlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAElE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG7D,MAAM,UAAU,aAAa,CAC5B,IAAyC,EACzC,MAA2D,EAC3D,OAA0B;IAE1B,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC;QACxC,wBAAwB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC;QAC3E,kBAAkB,EAAE,CAAC,KAAK,EAAE,EAAE,CAC7B,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;YACnB,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,WAAW,CAAC;YAChC,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,EAAE,cAAc,EAAE,aAAa,CAAC,IAAI,EAAE,WAAW,CAAC,EAAE,CAAC;QAC5G,CAAC,CAAC;KACH,CAAC,CAAC;AACJ,CAAC"}
@@ -76,7 +76,7 @@ export declare const SessionsPage: import("#page.ts").AdminPage & {
76
76
  readonly queryIndexes: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Number>>;
77
77
  }>, import("effect/Schema").Struct<{
78
78
  readonly _tag: import("effect/Schema").Literal<"Resync">;
79
- }>]>, ...never[]]>, import("effect/Schema").Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, typeof import("@shivaedev/contract/WebSocketRequired.ts").WebSocketRequired, ...import("effect/Schema").Union<readonly (typeof import("@shivaedev/errors/taxonomy.ts").Forbidden | typeof import("@shivaedev/errors/taxonomy.ts").AuthUnavailable)[]>[]]>>, import("effect/Schema").Never, typeof SessionsPermission, never> | import("effect/rpc/Rpc").Rpc<"identity.sessions.list", import("effect/Schema").Struct<{
79
+ }>]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, ...never[]]>, import("effect/Schema").Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, typeof import("@shivaedev/contract/WebSocketRequired.ts").WebSocketRequired, ...import("effect/Schema").Union<readonly (typeof import("@shivaedev/errors/taxonomy.ts").Forbidden | typeof import("@shivaedev/errors/taxonomy.ts").AuthUnavailable)[]>[]]>>, import("effect/Schema").Never, typeof SessionsPermission, never> | import("effect/rpc/Rpc").Rpc<"identity.sessions.list", import("effect/Schema").Struct<{
80
80
  readonly cursor: import("effect/Schema").optionalKey<import("effect/Schema").Struct<{
81
81
  readonly id: import("effect/Schema").String;
82
82
  readonly lastActivityAt: import("effect/Schema").DateTimeUtcFromString;
@@ -78,7 +78,10 @@ export declare function usersPage<const TRole extends string>(access: Pick<Acces
78
78
  readonly queryIndexes: Schema.optional<Schema.$Array<Schema.Number>>;
79
79
  }>, Schema.Struct<{
80
80
  readonly _tag: Schema.Literal<"Resync">;
81
- }>]>, ...never[]]>, Schema.Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, typeof import("@shivaedev/contract/WebSocketRequired.ts").WebSocketRequired, ...Schema.Union<readonly (typeof Forbidden | typeof AuthUnavailable)[]>[]]>>, Schema.Never, typeof UsersPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.users.list", Schema.Struct<{
81
+ }>]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, ...never[]]>, Schema.Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, typeof import("@shivaedev/contract/WebSocketRequired.ts").WebSocketRequired, ...Schema.Union<readonly (typeof Forbidden | typeof AuthUnavailable)[]>[]]>>, Schema.Never, typeof UsersPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.users.changeRole", Schema.Struct<{
82
+ role: Schema.Literals<TRole[]>;
83
+ userId: Schema.String;
84
+ }>, Schema.Void, Schema.Union<readonly (typeof NotFound | typeof Forbidden | typeof AuthUnavailable | typeof LastRoleAssigner)[]>, typeof UsersPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.users.list", Schema.Struct<{
82
85
  readonly cursor: Schema.optionalKey<Schema.String>;
83
86
  readonly limit: Schema.Number;
84
87
  }>, Schema.Struct<{
@@ -91,9 +94,6 @@ export declare function usersPage<const TRole extends string>(access: Pick<Acces
91
94
  readonly role: Schema.String;
92
95
  }>>;
93
96
  readonly canChangeRoles: Schema.Boolean;
94
- }>, Schema.Union<readonly [Schema.Union<readonly (typeof Forbidden | typeof AuthUnavailable)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof UsersPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.users.changeRole", Schema.Struct<{
95
- role: Schema.Literals<TRole[]>;
96
- userId: Schema.String;
97
- }>, Schema.Void, Schema.Union<readonly (typeof NotFound | typeof Forbidden | typeof AuthUnavailable | typeof LastRoleAssigner)[]>, typeof UsersPermission, never>, readonly [], undefined>;
97
+ }>, Schema.Union<readonly [Schema.Union<readonly (typeof Forbidden | typeof AuthUnavailable)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof UsersPermission, never>, readonly [], undefined>;
98
98
  };
99
99
  //# sourceMappingURL=page.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shivaedev/admin",
3
- "version": "0.17.0",
3
+ "version": "0.18.1",
4
4
  "description": "Explicit admin page contracts and a protected native Effect RPC registry",
5
5
  "homepage": "https://github.com/ShivaeDev/platform/tree/main/packages/admin#readme",
6
6
  "bugs": {
@@ -42,20 +42,22 @@
42
42
  "README.md"
43
43
  ],
44
44
  "dependencies": {
45
- "@shivaedev/access": "0.3.5",
46
- "@shivaedev/changes": "0.6.0",
47
- "@shivaedev/contract": "0.30.1",
48
- "@shivaedev/errors": "0.4.1",
49
- "@shivaedev/identity": "0.17.0",
50
- "@shivaedev/jobs": "0.29.1",
51
- "@shivaedev/react": "0.32.0"
45
+ "@shivaedev/access": "0.3.6",
46
+ "@shivaedev/changes": "0.8.0",
47
+ "@shivaedev/contract": "0.31.0",
48
+ "@shivaedev/errors": "0.5.0",
49
+ "@shivaedev/identity": "0.19.0",
50
+ "@shivaedev/jobs": "0.30.0",
51
+ "@shivaedev/react": "0.34.0"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@effect/atom-react": "4.0.6",
55
- "@shivaedev/quality": "0.54.0",
56
- "@shivaedev/server": "0.17.0",
57
- "@shivaedev/test-sql": "0.16.0",
58
- "@shivaedev/test-story": "0.32.0",
55
+ "@shivaedev/quality": "0.56.0",
56
+ "@shivaedev/rate-limit": "0.2.1",
57
+ "@shivaedev/server": "0.19.0",
58
+ "@shivaedev/sql": "0.33.0",
59
+ "@shivaedev/test-sql": "0.16.2",
60
+ "@shivaedev/test-story": "0.34.0",
59
61
  "@types/node": "24.19.2",
60
62
  "@types/react": "19.3.0",
61
63
  "@types/react-dom": "19.3.0",
@@ -2,13 +2,16 @@ import type { AdminRoute } from "#page.ts";
2
2
 
3
3
  export function matchAdminRoute(routes: readonly AdminRoute[], pathname: string): AdminRoute | undefined {
4
4
  const path = pathname.replace(/\/$/u, "");
5
+ if (path === "/admin") {
6
+ return routes[0];
7
+ }
5
8
  return (
6
9
  routes.find((route) => route.path.replace(/\/$/u, "") === path)
7
10
  ?? routes.find((route) => {
8
11
  if (route.detail === undefined) {
9
12
  return false;
10
13
  }
11
- const expected = route.detail.split("/");
14
+ const expected = route.detail.replace(/\/$/u, "").split("/");
12
15
  const actual = path.split("/");
13
16
  return (
14
17
  expected.length === actual.length
@@ -0,0 +1,36 @@
1
+ import type { AdminRoute } from "#page.ts";
2
+
3
+ function overlaps(left: string, right: string): boolean {
4
+ const expected = left.split("/");
5
+ const actual = right.split("/");
6
+ return (
7
+ expected.length === actual.length
8
+ && expected.every(
9
+ (segment, index) => segment === actual[index] || (segment === "$" && actual[index] !== "") || (actual[index] === "$" && segment !== ""),
10
+ )
11
+ );
12
+ }
13
+
14
+ function pathsOf(route: AdminRoute): readonly string[] {
15
+ const page = route.path.replace(/\/$/u, "");
16
+ const detail = route.detail?.replace(/\/$/u, "");
17
+ if (detail !== undefined && !detail.startsWith(`${page}/`)) {
18
+ throw new Error(`Admin detail path ${route.detail} must be under page path ${route.path}`);
19
+ }
20
+ return detail === undefined ? [page] : [page, detail];
21
+ }
22
+
23
+ export function validateAdminRoutes(routes: readonly AdminRoute[]): void {
24
+ const paths: string[] = [];
25
+ for (const path of routes.flatMap(pathsOf)) {
26
+ const normalized = path.replace(/\$[^/]+/gu, "$");
27
+ if (paths.includes(normalized)) {
28
+ throw new Error(`Duplicate admin path: ${normalized}`);
29
+ }
30
+ const existing = paths.find((candidate) => overlaps(candidate, normalized));
31
+ if (existing !== undefined) {
32
+ throw new Error(`Overlapping admin paths: ${existing} and ${normalized}`);
33
+ }
34
+ paths.push(normalized);
35
+ }
36
+ }
@@ -3,8 +3,8 @@ import type * as AsyncResult from "effect/reactivity/AsyncResult";
3
3
  import type * as Atom from "effect/reactivity/Atom";
4
4
  import { createElement, useState } from "react";
5
5
  import type { SessionList, SessionListInput, SignedInSession } from "@shivaedev/identity/sessions.ts";
6
+ import type { AtomServices } from "@shivaedev/react/AtomServices.ts";
6
7
  import { useAction, useQuery } from "@shivaedev/react/client/resultState.ts";
7
- import type { AtomServices } from "@shivaedev/react/fieldRejection.ts";
8
8
  import { SessionConfirmation } from "./SessionConfirmation.tsx";
9
9
  import { SessionListView } from "./SessionListView.tsx";
10
10
  import { SessionPagination } from "./SessionPagination.tsx";
package/src/page.ts CHANGED
@@ -62,33 +62,37 @@ export function adminPage<
62
62
  TRpcs extends Rpc.AnyWithProps,
63
63
  const TStreams extends readonly StreamShape[],
64
64
  TMiddleware extends RpcMiddleware.AnyService & PagePermission,
65
+ const TScope extends "session" | undefined = undefined,
65
66
  >(page: {
66
67
  readonly id: TId;
67
68
  readonly route: TRoute;
68
69
  readonly permission: TMiddleware;
69
- readonly contract: Contract<TName, TQueries, TCommands, TRpcs, TStreams>;
70
+ readonly contract: Contract<TName, TQueries, TCommands, TRpcs, TStreams, TScope>;
70
71
  }): AdminPage & {
71
72
  readonly route: TRoute & { readonly permission: Permission };
72
73
  readonly id: TId;
73
74
  readonly permissionKey: TMiddleware["key"];
74
- readonly contract: Contract<TName, PageQueries<TQueries>, TCommands, Rpc.AddMiddleware<PageRpcs<TRpcs>, TMiddleware>, TStreams>;
75
+ readonly contract: Contract<TName, PageQueries<TQueries>, TCommands, Rpc.AddMiddleware<PageRpcs<TRpcs>, TMiddleware>, TStreams, TScope>;
75
76
  };
76
77
  export function adminPage(page: {
77
78
  readonly id: string;
78
79
  readonly route: Omit<AdminRoute, "permission">;
79
80
  readonly permission: PagePermission & RpcMiddleware.AnyService;
80
81
  readonly contract: {
81
- readonly declaration: Declared<string, readonly QueryShape[], readonly CommandShape[], readonly StreamShape[]>;
82
+ readonly declaration: Declared<string, readonly QueryShape[], readonly CommandShape[], readonly StreamShape[], "session" | undefined>;
82
83
  readonly requests: ReadonlyMap<string, Rpc.AnyWithProps>;
83
84
  };
84
85
  }): AdminPage {
85
86
  const { declaration } = page.contract;
86
87
  const queries = declaration.queries.map((query) => ({
87
88
  ...query,
88
- readPolicy: (payload: unknown, viewer: Option.Option<Viewer>) =>
89
- Effect.flatMap(SessionUser, (user) =>
90
- hasPermission(user, page.permission.permission) ? (query.readPolicy?.(payload, viewer) ?? Effect.succeed(true)) : Effect.succeed(false),
91
- ),
89
+ readPolicy: Object.assign(
90
+ (payload: unknown, viewer: Option.Option<Viewer>) =>
91
+ Effect.flatMap(SessionUser, (user) =>
92
+ hasPermission(user, page.permission.permission) ? (query.readPolicy?.(payload, viewer) ?? Effect.succeed(true)) : Effect.succeed(false),
93
+ ),
94
+ query.readPolicy,
95
+ ),
92
96
  }));
93
97
  let protectedContract: PageGroup = contract(declaration.name, { ...declaration, queries });
94
98
  const original = page.contract.requests.values().next().value;
package/src/registry.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { RpcGroup } from "effect/rpc";
2
+ import { validateAdminRoutes } from "#adapters/validateAdminRoutes.ts";
2
3
  import type { AdminPage } from "./page.ts";
3
4
 
4
5
  export interface AdminRegistry<TPages extends readonly AdminPage[]> {
@@ -38,7 +39,6 @@ export function mergeAdminRegistries(...registries: readonly AnyAdminRegistry[])
38
39
 
39
40
  export function adminRegistry<const TPages extends readonly AdminPage[]>(...pages: TPages & UniquePageIds<TPages>): AdminRegistry<TPages> {
40
41
  const ids = new Set<string>();
41
- const paths = new Set<string>();
42
42
  const tags = new Set<string>();
43
43
  function unique(seen: Set<string>, value: string, kind: string) {
44
44
  if (seen.has(value)) {
@@ -48,12 +48,10 @@ export function adminRegistry<const TPages extends readonly AdminPage[]>(...page
48
48
  }
49
49
  for (const page of pages) {
50
50
  unique(ids, page.id, "page id");
51
- for (const path of [page.route.path, ...(page.route.detail === undefined ? [] : [page.route.detail])]) {
52
- unique(paths, path.replace(/\$[^/]+/gu, "$").replace(/\/$/u, ""), "path");
53
- }
54
51
  for (const tag of page.contract.requests.keys()) {
55
52
  unique(tags, tag, "RPC tag");
56
53
  }
57
54
  }
55
+ validateAdminRoutes(pages.map((page) => page.route));
58
56
  return { group: RpcGroup.make().merge(...pages.map((page) => page.contract)), pages };
59
57
  }
@@ -15,7 +15,7 @@ export function adminDocuments<E, R>(
15
15
  Effect.gen(function* () {
16
16
  yield* router.add("GET", "/admin/*", (request) => {
17
17
  const path = new URL(request.url, "http://localhost").pathname;
18
- const route = path.replace(/\/$/u, "") === "/admin" ? routes[0] : matchAdminRoute(routes, path);
18
+ const route = matchAdminRoute(routes, path);
19
19
  return route === undefined
20
20
  ? Effect.succeed(HttpServerResponse.empty({ status: HttpStatus.fromLiteral("NotFound") }))
21
21
  : permissionRoute(route.permission)(handler)(request);
@@ -5,6 +5,7 @@ import type { AccessPolicy } from "@shivaedev/access/roleSet.ts";
5
5
  import { AssignRoles } from "@shivaedev/access/roles.ts";
6
6
  import { AuthUnavailable } from "@shivaedev/errors/taxonomy.ts";
7
7
  import { SessionUser } from "@shivaedev/identity/identity.ts";
8
+ import { type AuthTableOptions, tables } from "@shivaedev/identity/server/better-auth/adapters/tables.ts";
8
9
  import { assignRole } from "@shivaedev/identity/server/better-auth/assignRole.ts";
9
10
  import { ReadUsers } from "#permissions.ts";
10
11
  import { AppUser, type ChangeRoleInput, type UserListInput } from "#users/roles.ts";
@@ -16,11 +17,14 @@ function unavailable() {
16
17
  export const listUsers = Effect.fn("Admin.listUsers")(function* <TRole extends string>(
17
18
  access: Pick<AccessPolicy<TRole>, "Role">,
18
19
  input: typeof UserListInput.Type,
20
+ options?: AuthTableOptions,
19
21
  ) {
20
22
  yield* requirePermission(yield* SessionUser, ReadUsers);
21
- const sql = yield* SqlClient.SqlClient;
23
+ const sql = (yield* SqlClient.SqlClient).withoutTransforms();
24
+ const { user } = tables(options);
22
25
  const read = SqlSchema.findAll({
23
- execute: () => sql`select id, name, email, role, "createdAt" from "user"
26
+ execute: () => sql`select id, ${sql(user.name)} as name, ${sql(user.email)} as email,
27
+ ${sql(user.role)} as role, ${sql(user.createdAt)} as "createdAt" from ${sql(user.table)}
24
28
  where id > ${input.cursor ?? ""} order by id limit ${input.limit + 1}`,
25
29
  Request: Schema.Void,
26
30
  Result: Schema.Struct({ ...AppUser.fields, role: access.Role }),
@@ -33,10 +37,11 @@ export const listUsers = Effect.fn("Admin.listUsers")(function* <TRole extends s
33
37
  export const changeUserRole = Effect.fn("Admin.changeUserRole")(function* <TRole extends string>(
34
38
  access: Pick<AccessPolicy<TRole>, "Role" | "hasPermission">,
35
39
  input: ChangeRoleInput<TRole>,
40
+ options?: AuthTableOptions,
36
41
  ) {
37
42
  const actor = yield* SessionUser;
38
43
  yield* requirePermission(actor, AssignRoles);
39
- const changed = yield* assignRole(access, input.userId, input.role);
44
+ const changed = yield* assignRole(access, input.userId, input.role, options);
40
45
  if (changed) {
41
46
  const changedAt = DateTime.formatIso(yield* DateTime.now);
42
47
  yield* Effect.logInfo("User role changed").pipe(Effect.annotateLogs({ actorId: actor.id, changedAt, ...input }));
@@ -3,19 +3,21 @@ import type { AccessPolicy } from "@shivaedev/access/roleSet.ts";
3
3
  import { AssignRoles } from "@shivaedev/access/roles.ts";
4
4
  import { SessionUser } from "@shivaedev/identity/identity.ts";
5
5
  import { hasPermission } from "@shivaedev/identity/permission.ts";
6
+ import type { AuthTableOptions } from "@shivaedev/identity/server/better-auth/adapters/tables.ts";
6
7
  import { changeUserRole, listUsers } from "#server/users.ts";
7
8
  import type { usersPage } from "#users/page.ts";
8
9
 
9
10
  export function usersHandlers<const TRole extends string>(
10
11
  page: ReturnType<typeof usersPage<TRole>>,
11
12
  access: Pick<AccessPolicy<TRole>, "Role" | "hasPermission">,
13
+ options?: AuthTableOptions,
12
14
  ) {
13
15
  return page.contract.application.toLayer({
14
- "admin.users.changeRole": (input) => changeUserRole(access, input),
16
+ "admin.users.changeRole": (input) => changeUserRole(access, input, options),
15
17
  "admin.users.list": (input) =>
16
18
  Effect.gen(function* () {
17
19
  const user = yield* SessionUser;
18
- return { ...(yield* listUsers(access, input)), canChangeRoles: hasPermission(user, AssignRoles) };
20
+ return { ...(yield* listUsers(access, input, options)), canChangeRoles: hasPermission(user, AssignRoles) };
19
21
  }),
20
22
  });
21
23
  }