@shivaedev/admin 0.15.0 → 0.16.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 (54) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +65 -9
  3. package/dist/adapters/matchAdminRoute.d.ts +3 -0
  4. package/dist/adapters/matchAdminRoute.d.ts.map +1 -0
  5. package/dist/adapters/matchAdminRoute.js +14 -0
  6. package/dist/adapters/matchAdminRoute.js.map +1 -0
  7. package/dist/client/adapters/adminPermissionGuard.d.ts +20 -0
  8. package/dist/client/adapters/adminPermissionGuard.d.ts.map +1 -0
  9. package/dist/client/adapters/adminPermissionGuard.js +9 -0
  10. package/dist/client/adapters/adminPermissionGuard.js.map +1 -0
  11. package/dist/jobs/page.d.ts +7 -0
  12. package/dist/jobs/page.d.ts.map +1 -1
  13. package/dist/jobs/retryPage.d.ts +7 -0
  14. package/dist/jobs/retryPage.d.ts.map +1 -1
  15. package/dist/page.d.ts +14 -5
  16. package/dist/page.d.ts.map +1 -1
  17. package/dist/page.js +3 -1
  18. package/dist/page.js.map +1 -1
  19. package/dist/registry.d.ts.map +1 -1
  20. package/dist/registry.js +3 -1
  21. package/dist/registry.js.map +1 -1
  22. package/dist/server/AdminSessions.d.ts +7 -0
  23. package/dist/server/AdminSessions.d.ts.map +1 -0
  24. package/dist/server/AdminSessions.js +4 -0
  25. package/dist/server/AdminSessions.js.map +1 -0
  26. package/dist/server/adminDocuments.d.ts +7 -0
  27. package/dist/server/adminDocuments.d.ts.map +1 -0
  28. package/dist/server/adminDocuments.js +20 -0
  29. package/dist/server/adminDocuments.js.map +1 -0
  30. package/dist/server/pagePermissions.d.ts +5 -0
  31. package/dist/server/pagePermissions.d.ts.map +1 -0
  32. package/dist/server/pagePermissions.js +18 -0
  33. package/dist/server/pagePermissions.js.map +1 -0
  34. package/dist/server/registerAdmin.d.ts +4 -1
  35. package/dist/server/registerAdmin.d.ts.map +1 -1
  36. package/dist/server/registerAdmin.js +2 -1
  37. package/dist/server/registerAdmin.js.map +1 -1
  38. package/dist/server/users.d.ts +1 -1
  39. package/dist/server/users.d.ts.map +1 -1
  40. package/dist/server/usersHandlers.d.ts +1 -1
  41. package/dist/server/usersHandlers.d.ts.map +1 -1
  42. package/dist/sessions/Page.d.ts +7 -0
  43. package/dist/sessions/Page.d.ts.map +1 -1
  44. package/dist/users/page.d.ts +7 -0
  45. package/dist/users/page.d.ts.map +1 -1
  46. package/package.json +11 -11
  47. package/src/adapters/matchAdminRoute.ts +19 -0
  48. package/src/client/adapters/adminPermissionGuard.ts +16 -0
  49. package/src/page.ts +18 -6
  50. package/src/registry.ts +3 -1
  51. package/src/server/AdminSessions.ts +4 -0
  52. package/src/server/adminDocuments.ts +27 -0
  53. package/src/server/pagePermissions.ts +31 -0
  54. package/src/server/registerAdmin.ts +7 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.16.1 - 2026-10-31
4
+
5
+ ### Changed
6
+
7
+ - Update `@shivaedev/identity` from 0.13.0 to 0.14.0.
8
+ - Update `@shivaedev/jobs` from 0.28.1 to 0.28.2.
9
+
10
+ ## 0.16.0 - 2026-10-31
11
+
12
+ ### Added
13
+
14
+ - Admin pages can declare a detail path under `route.detail`. `adminDocuments` and `adminPermissionGuard` use the registered page's permission for its list and detail paths.
15
+ - Identity permission layers accept native context keys for permission middleware.
16
+
17
+ ### Fixed
18
+
19
+ - Generated apps use admin registration for permission layers and guard each admin document by its registered page.
20
+
21
+ ### Breaking
22
+
23
+ - Admin registrations install their pages' permission middleware and require `AdminSessions` when their handler layer builds. Provide `Layer.succeed(AdminSessions, sessions)` once at the host instead of installing each page's `permissionLayer` by hand. Missing policy fails startup with the page id and permission name.
24
+ - Declare page middleware with identity’s `permissionMiddleware` so it provides `Identity` and `SessionUser` with the shared identity failures.
25
+ - Generated apps import `ReadStatistics` from `#ReadStatistics.ts` and `StatisticsPermission` from `#modules/notes/StatisticsPermission.ts`; migrate custom imports of `#appPermissions.ts` when applying the template update.
26
+
3
27
  ## 0.15.0 - 2026-10-31
4
28
 
5
29
  ### Added
package/README.md CHANGED
@@ -28,6 +28,8 @@ An admin page is a native `@shivaedev/contract` contract plus a stable id, route
28
28
 
29
29
  Declare each page's queries, commands and streams with `@shivaedev/contract`, then pass its native contract to `adminPage`. The stable id identifies the page at server registration; route metadata belongs to the application's view. Author RPC namespaces in the contract name, such as `admin.jobs`.
30
30
 
31
+ For a wholly admin-only jobs feature, put this browser-safe declaration in `src/modules/admin/jobs/pages.ts`:
32
+
31
33
  ```ts
32
34
  import { Schema } from "effect";
33
35
  import { JobsPermission } from "@shivaedev/admin/permissions.ts";
@@ -40,37 +42,44 @@ const Failed = query("failed", {
40
42
  reads: () => [],
41
43
  success: Schema.Array(Schema.String),
42
44
  });
43
- const Jobs = adminPage({
45
+ export const Jobs = adminPage({
44
46
  id: "jobs",
45
47
  permission: JobsPermission,
46
48
  route: { path: "/admin/jobs", title: "Jobs" },
47
49
  contract: contract("admin.jobs", { queries: [Failed] }),
48
50
  });
49
- const Admin = adminRegistry(Jobs);
51
+ export const Admin = adminRegistry(Jobs);
50
52
  ```
51
53
 
52
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.
53
55
 
54
- Register server handler Layers by page id:
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`:
55
57
 
56
58
  ```ts
57
59
  import { Effect, Layer } from "effect";
58
60
  import { registerAdmin } from "@shivaedev/admin/server/registerAdmin.ts";
59
- import { JobsPermission, ReadJobs } from "@shivaedev/admin/permissions.ts";
60
- import { permissionLayer } from "@shivaedev/identity/server/permissions.ts";
61
+ import { AdminSessions } from "@shivaedev/admin/server/AdminSessions.ts";
61
62
 
62
63
  const registration = registerAdmin(Admin, {
63
64
  jobs: Jobs.contract.application.toLayer({
64
65
  "admin.jobs.failed": () => Effect.succeed(["mail-42"]),
65
66
  }),
66
67
  });
67
- const handlers = registration.handlers.pipe(Layer.provideMerge(permissionLayer(JobsPermission, sessions)));
68
+ const handlers = registration.handlers.pipe(Layer.provide(Layer.succeed(AdminSessions, sessions)));
68
69
  ```
69
70
 
70
71
  Declare application roles with `@shivaedev/access`, grant the relevant domain permissions explicitly, and supply that role set through the session or auth configuration of `@shivaedev/identity`.
71
72
 
72
73
  Pass `registration.group` and `handlers` to the existing application's RPC host on `/rpc`, merging them with its other groups and Layers as needed. The Platform host supplies generated change handlers; registration requires the page's application handlers. Handler Layer errors and service requirements remain inferred. Missing or extra page ids defect when the handler Layer is built; TypeScript also checks each Layer provides the handlers for its page.
73
74
 
75
+ ### Protect documents and detail routes
76
+
77
+ Provide the application's session policy through `AdminSessions` once. Registration builds each page's permission layer with that policy. Omitting the policy fails when the handlers start, with a message naming the page and permission.
78
+
79
+ 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 `AdminSessions` 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
+
81
+ 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
+
74
83
  ### Pages owned by modules
75
84
 
76
85
  Each module declares its own registry and calls `registerAdmin` with its own page handlers. The application host combines those registrations:
@@ -81,10 +90,57 @@ import { mergeAdminRegistrations } from "@shivaedev/admin/server/mergeAdminRegis
81
90
  const admin = mergeAdminRegistrations(foundation.admin, catalog.admin);
82
91
  ```
83
92
 
84
- Pass `admin.group` and `admin.handlers` to the application's RPC host. The combined registration exposes `pages` for navigation and preserves the handler Layers' errors and service requirements. Duplicate page ids across modules fail at the type level; duplicate paths and RPC tags fail at composition. A module cannot register a page without its handlers.
93
+ Provide `AdminSessions` once to `admin.handlers` and pass it with `admin.group` to the application's RPC host. The combined registration exposes `pages` for navigation and preserves the handler Layers' errors and service requirements. Duplicate page ids across modules fail at the type level; duplicate paths and RPC tags fail at composition. A module cannot register a page without its handlers.
85
94
 
86
95
  Browser composition uses `mergeAdminRegistries` from `@shivaedev/admin/registry.ts` with the modules' browser-safe registries. A client module can also contribute its registry's `pages` directly to the application's navigation. A feature module adds pages to its own registry and handlers to its own registration; the foundation does not import feature pages.
87
96
 
97
+ ### Keep admin code in admin paths
98
+
99
+ An `admin/` path segment means admin-only code. A wholly admin-only feature lives under `src/modules/admin/<name>`, with its shared declarations, `server/` and `client/` there. Admin tools for a member feature stay inside that feature: `admin/` for browser-safe page declarations, `server/admin/` for reads and handlers, and `client/admin/` for bindings and views. Each module reads only its own tables; compose another module's exposed operations for data it owns. Permissions enforce access regardless of the path.
100
+
101
+ The starter declares `StatisticsPage` with `adminPage` in [`src/modules/notes/admin/pages.ts`](https://github.com/ShivaeDev/platform/blob/main/examples/starter/src/modules/notes/admin/pages.ts). Its all-user read lives in [`src/modules/notes/server/admin/readStatistics.ts`](https://github.com/ShivaeDev/platform/blob/main/examples/starter/src/modules/notes/server/admin/readStatistics.ts):
102
+
103
+ ```ts
104
+ import { Effect, Schema } from "effect";
105
+ import { SqlClient, SqlSchema } from "effect/sql";
106
+ import { NoteStatistics } from "#modules/notes/admin/pages.ts";
107
+ import { notesSqlFailure } from "#modules/notes/server/sqlFailure.ts";
108
+
109
+ export const readStatistics = Effect.fn("Notes.readStatistics")(function* () {
110
+ const sql = yield* SqlClient.SqlClient;
111
+ const read = SqlSchema.findOne({
112
+ execute: () => sql`select count(*)::int as notes, count(*) filter (where word_count is null)::int as pending,
113
+ coalesce(sum(word_count), 0)::int as words from notes`,
114
+ Request: Schema.Void,
115
+ Result: NoteStatistics,
116
+ });
117
+ return yield* read(undefined).pipe(Effect.catchTag("SqlError", (cause) => Effect.fail(notesSqlFailure(cause))));
118
+ });
119
+ ```
120
+
121
+ [`src/modules/notes/server/admin/registration.ts`](https://github.com/ShivaeDev/platform/blob/main/examples/starter/src/modules/notes/server/admin/registration.ts) pairs that read with the page:
122
+
123
+ ```ts
124
+ import { registerAdmin } from "@shivaedev/admin/server/registerAdmin.ts";
125
+ import { rpcBoundary } from "@shivaedev/errors/boundary.ts";
126
+ import { InternalServerError } from "@shivaedev/errors/taxonomy.ts";
127
+ import { Admin, StatisticsPage } from "#modules/notes/admin/pages.ts";
128
+ import { readStatistics } from "./readStatistics.ts";
129
+
130
+ const statistics = StatisticsPage.contract.application.toLayer({
131
+ "admin.notes.statistics": () =>
132
+ readStatistics().pipe(
133
+ rpcBoundary(StatisticsPage.contract.declaration.queries[0].error, { unexpected: (message) => new InternalServerError({ message }) }),
134
+ ),
135
+ });
136
+
137
+ export const adminRegistration = registerAdmin(Admin, {
138
+ "note-statistics": statistics,
139
+ });
140
+ ```
141
+
142
+ The read stays in notes because notes owns the table. The [client registration](https://github.com/ShivaeDev/platform/blob/main/examples/starter/src/modules/notes/client/admin/registration.tsx) and view stay in `src/modules/notes/client/admin/`. Application composition may import these registrations from its member and admin module lists without moving their implementation out of the owning module.
143
+
88
144
  ### Built-in Jobs page
89
145
 
90
146
  Share each queue's name and payload Schema with the browser declaration. The page exposes only the queues passed to `jobsPage`; a queue registered with the jobs runtime is not automatically available to operators.
@@ -168,7 +224,7 @@ const changeRole = Client.runtime.fn(users.changeRole.run);
168
224
  <UsersView roles={AppAccess.Role.literals} list={users.list.query} changeRole={changeRole} />;
169
225
  ```
170
226
 
171
- `admin.users.list` takes `{ limit, cursor? }` (1–100 users) and returns `{ users, next, canChangeRoles }` ordered by user id. Each user has id, name, email, role and a UTC sign-up time. The page's operations and generated subscription require `ReadUsers` (`users.read`), enforced by `UsersPermission`. Supply `permissionLayer(UsersPermission, sessions)` alongside the application's other handler Layers.
227
+ `admin.users.list` takes `{ limit, cursor? }` (1–100 users) and returns `{ users, next, canChangeRoles }` ordered by user id. Each user has id, name, email, role and a UTC sign-up time. The page's operations and generated subscription require `ReadUsers` (`users.read`), enforced by `UsersPermission`. Registration installs this middleware using `AdminSessions`.
172
228
 
173
229
  `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.
174
230
 
@@ -178,7 +234,7 @@ Keep Better Auth cookie caching disabled so requests see current permissions. Ro
178
234
 
179
235
  ### Built-in Sessions page
180
236
 
181
- Add `SessionsPage` from `@shivaedev/admin/sessions/Page.ts` to the admin registry and register `sessions: sessionsHandlers` from `@shivaedev/identity/server/better-auth/sessionsHandlers.ts`. Supply `permissionLayer(SessionsPermission, sessions)` from identity alongside the other permission Layers. The page uses identity's `identity.sessions` contract and `sessions.manage` permission.
237
+ Add `SessionsPage` from `@shivaedev/admin/sessions/Page.ts` to the admin registry and register `sessions: sessionsHandlers` from `@shivaedev/identity/server/better-auth/sessionsHandlers.ts`. Registration installs this middleware using `AdminSessions`. The page uses identity's `identity.sessions` contract and `sessions.manage` permission.
182
238
 
183
239
  ```tsx
184
240
  import { SessionsView } from "@shivaedev/admin/client/SessionsView.ts";
@@ -0,0 +1,3 @@
1
+ import type { AdminRoute } from "#page.ts";
2
+ export declare function matchAdminRoute(routes: readonly AdminRoute[], pathname: string): AdminRoute | undefined;
3
+ //# sourceMappingURL=matchAdminRoute.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,14 @@
1
+ export function matchAdminRoute(routes, pathname) {
2
+ const path = pathname.replace(/\/$/u, "");
3
+ return (routes.find((route) => route.path.replace(/\/$/u, "") === path)
4
+ ?? routes.find((route) => {
5
+ if (route.detail === undefined) {
6
+ return false;
7
+ }
8
+ const expected = route.detail.split("/");
9
+ const actual = path.split("/");
10
+ return (expected.length === actual.length
11
+ && expected.every((segment, index) => (segment.startsWith("$") ? actual[index] !== "" : segment === actual[index])));
12
+ }));
13
+ }
14
+ //# sourceMappingURL=matchAdminRoute.js.map
@@ -0,0 +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;IAC1C,OAAO,CACN,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,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,KAAK,CAAC,GAAG,CAAC,CAAC;YACzC,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,20 @@
1
+ import type { Permission } from "@shivaedev/access/permission.ts";
2
+ import type { AdminRoute } from "#page.ts";
3
+ interface GuardContext {
4
+ readonly location: {
5
+ readonly href: string;
6
+ readonly pathname: string;
7
+ readonly state?: object | undefined;
8
+ };
9
+ readonly matches: readonly {
10
+ readonly staticData: {
11
+ readonly permission?: Permission;
12
+ readonly signedIn?: boolean;
13
+ };
14
+ }[];
15
+ }
16
+ export declare function adminPermissionGuard(pages: readonly {
17
+ readonly route: AdminRoute;
18
+ }[], guard: (context: GuardContext) => void): (context: GuardContext) => void;
19
+ export {};
20
+ //# sourceMappingURL=adminPermissionGuard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adminPermissionGuard.d.ts","sourceRoot":"","sources":["../../../src/client/adapters/adminPermissionGuard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAElE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,UAAU,YAAY;IACrB,QAAQ,CAAC,QAAQ,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,CAAC;IAC7G,QAAQ,CAAC,OAAO,EAAE,SAAS;QAAE,QAAQ,CAAC,UAAU,EAAE;YAAE,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC;YAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;SAAE,CAAA;KAAE,EAAE,CAAC;CACxH;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,SAAS;IAAE,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAA;CAAE,EAAE,EAAE,KAAK,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,aAE3G,YAAY,KAAG,IAAI,CAIpC"}
@@ -0,0 +1,9 @@
1
+ import { matchAdminRoute } from "#adapters/matchAdminRoute.ts";
2
+ export function adminPermissionGuard(pages, guard) {
3
+ const routes = pages.map((page) => page.route);
4
+ return (context) => {
5
+ const matched = matchAdminRoute(routes, context.location.pathname);
6
+ guard({ ...context, matches: [...context.matches, { staticData: matched === undefined ? {} : { permission: matched.permission } }] });
7
+ };
8
+ }
9
+ //# sourceMappingURL=adminPermissionGuard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adminPermissionGuard.js","sourceRoot":"","sources":["../../../src/client/adapters/adminPermissionGuard.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAQ/D,MAAM,UAAU,oBAAoB,CAAC,KAAgD,EAAE,KAAsC;IAC5H,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/C,OAAO,CAAC,OAAqB,EAAQ,EAAE;QACtC,MAAM,OAAO,GAAG,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACnE,KAAK,CAAC,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;IACvI,CAAC,CAAC;AACH,CAAC"}
@@ -2,7 +2,14 @@ import { Schema } from "effect";
2
2
  import { type JobsEntry } from "#jobs/entry.ts";
3
3
  import { JobsPermission } from "#permissions.ts";
4
4
  export declare function jobsPage<const TQueues extends readonly JobsEntry[]>(...queues: TQueues): import("#page.ts").AdminPage & {
5
+ readonly route: {
6
+ readonly path: "/admin/jobs";
7
+ readonly title: "Jobs";
8
+ } & {
9
+ readonly permission: import("@shivaedev/access/permission.ts").Permission;
10
+ };
5
11
  readonly id: "jobs";
12
+ readonly permissionKey: string;
6
13
  readonly contract: import("@shivaedev/contract/contract.ts").Contract<"admin.jobs", readonly [Omit<NoInfer<import("@shivaedev/contract/operation.ts").Query<"health", Schema.Void, Schema.Struct<{
7
14
  readonly activeTotal: Schema.Number;
8
15
  readonly deadLetteredTotal: Schema.Number;
@@ -1 +1 @@
1
- {"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../src/jobs/page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGxC,OAAO,EAAE,KAAK,SAAS,EAA+B,MAAM,gBAAgB,CAAC;AAI7E,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,wBAAgB,QAAQ,CAAC,KAAK,CAAC,OAAO,SAAS,SAAS,SAAS,EAAE,EAAE,GAAG,MAAM,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgDtF"}
1
+ {"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../src/jobs/page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGxC,OAAO,EAAE,KAAK,SAAS,EAA+B,MAAM,gBAAgB,CAAC;AAI7E,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,wBAAgB,QAAQ,CAAC,KAAK,CAAC,OAAO,SAAS,SAAS,SAAS,EAAE,EAAE,GAAG,MAAM,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgDtF"}
@@ -9,7 +9,14 @@ declare const JobsNotFailed_base: Schema.Class<JobsNotFailed, Schema.TaggedStruc
9
9
  export declare class JobsNotFailed extends JobsNotFailed_base {
10
10
  }
11
11
  export declare function jobsPageWithRetry<const TQueues extends readonly JobsEntry[]>(...queues: TQueues): import("#page.ts").AdminPage & {
12
+ readonly route: import("#page.ts").AdminRoute & {
13
+ readonly path: "/admin/jobs";
14
+ readonly title: "Jobs";
15
+ } & {
16
+ readonly permission: import("@shivaedev/access/permission.ts").Permission;
17
+ };
12
18
  readonly id: "jobs";
19
+ readonly permissionKey: string;
13
20
  readonly contract: import("@shivaedev/contract/contract.ts").Contract<"admin.jobs", readonly [Omit<Omit<NoInfer<import("@shivaedev/contract/operation.ts").Query<"health", Schema.Void, Schema.Struct<{
14
21
  readonly activeTotal: Schema.Number;
15
22
  readonly deadLetteredTotal: Schema.Number;
@@ -1 +1 @@
1
- {"version":3,"file":"retryPage.d.ts","sourceRoot":"","sources":["../../src/jobs/retryPage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;;;;;AAK5C,qBAAa,aAAc,SAAQ,kBAGjC;CAAG;AAEL,wBAAgB,iBAAiB,CAAC,KAAK,CAAC,OAAO,SAAS,SAAS,SAAS,EAAE,EAAE,GAAG,MAAM,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0B/F"}
1
+ {"version":3,"file":"retryPage.d.ts","sourceRoot":"","sources":["../../src/jobs/retryPage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;;;;;AAK5C,qBAAa,aAAc,SAAQ,kBAGjC;CAAG;AAEL,wBAAgB,iBAAiB,CAAC,KAAK,CAAC,OAAO,SAAS,SAAS,SAAS,EAAE,EAAE,GAAG,MAAM,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0B/F"}
package/dist/page.d.ts CHANGED
@@ -1,21 +1,28 @@
1
+ import { type Context } from "effect";
1
2
  import type { Rpc, RpcGroup, RpcMiddleware } from "effect/rpc";
2
3
  import type { Permission } from "@shivaedev/access/permission.ts";
3
4
  import { type Contract, type QueryServices } from "@shivaedev/contract/contract.ts";
4
5
  import type { CommandShape, QueryShape, StreamShape } from "@shivaedev/contract/operation.ts";
5
6
  import type { QueryReadPolicy } from "@shivaedev/contract/readPolicy.ts";
6
- import { SessionUser } from "@shivaedev/identity/identity.ts";
7
+ import { type Identity, SessionUser } from "@shivaedev/identity/identity.ts";
8
+ import type { IdentityFailures } from "@shivaedev/identity/middleware.ts";
7
9
  export interface AdminRoute {
10
+ readonly detail?: string;
8
11
  readonly path: string;
9
12
  readonly permission: Permission;
10
13
  readonly title: string;
11
14
  }
12
15
  declare const AdminPageTypeId: unique symbol;
16
+ type PagePermission = Context.Key<unknown, RpcMiddleware.RpcMiddleware<Identity | SessionUser, IdentityFailures, never>> & {
17
+ readonly permission: Permission;
18
+ };
13
19
  export interface AdminPage {
14
20
  readonly contract: RpcGroup.Any & {
15
21
  readonly application: RpcGroup.Any;
16
22
  readonly requests: ReadonlyMap<string, Rpc.Any>;
17
23
  };
18
24
  readonly id: string;
25
+ readonly permissionKey: string;
19
26
  readonly route: AdminRoute;
20
27
  readonly [AdminPageTypeId]: true;
21
28
  }
@@ -25,15 +32,17 @@ type PageQueries<TQueries extends readonly QueryShape[]> = {
25
32
  };
26
33
  };
27
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;
28
- export declare function adminPage<const TId extends string, 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 & {
29
- readonly permission: Permission;
30
- }>(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>(page: {
31
36
  readonly id: TId;
32
- readonly route: Omit<AdminRoute, "permission">;
37
+ readonly route: TRoute;
33
38
  readonly permission: TMiddleware;
34
39
  readonly contract: Contract<TName, TQueries, TCommands, TRpcs, TStreams>;
35
40
  }): AdminPage & {
41
+ readonly route: TRoute & {
42
+ readonly permission: Permission;
43
+ };
36
44
  readonly id: TId;
45
+ readonly permissionKey: TMiddleware["key"];
37
46
  readonly contract: Contract<TName, PageQueries<TQueries>, TCommands, Rpc.AddMiddleware<PageRpcs<TRpcs>, TMiddleware>, TStreams>;
38
47
  };
39
48
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../src/page.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,YAA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,CAAC,MAAM,SAAS,IAAI,CAAC,UAAU,EAAE,YAAY,CAAC,EACnD,KAAK,CAAC,KAAK,SAAS,MAAM,EAC1B,KAAK,CAAC,QAAQ,SAAS,SAAS,UAAU,EAAE,EAC5C,KAAK,CAAC,SAAS,SAAS,SAAS,YAAY,EAAE,EAC/C,KAAK,SAAS,GAAG,CAAC,YAAY,EAC9B,KAAK,CAAC,QAAQ,SAAS,SAAS,WAAW,EAAE,EAC7C,WAAW,SAAS,aAAa,CAAC,UAAU,GAAG,cAAc,EAC5D,IAAI,EAAE;IACP,QAAQ,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,CAAC,CAAC;CACzE,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,CAAC,CAAC;CAChI,CAAC"}
package/dist/page.js CHANGED
@@ -16,8 +16,10 @@ export function adminPage(page) {
16
16
  protectedContract = protectedContract.middleware(middleware);
17
17
  }
18
18
  }
19
+ const { permission, ...definition } = page;
19
20
  return {
20
- ...page,
21
+ ...definition,
22
+ permissionKey: permission.key,
21
23
  route: { ...page.route, permission: page.permission.permission },
22
24
  [AdminPageTypeId]: true,
23
25
  contract: protectedContract.middleware(page.permission),
package/dist/page.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"page.js","sourceRoot":"","sources":["../src/page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAe,MAAM,QAAQ,CAAC;AAG7C,OAAO,EAAiB,QAAQ,EAAqC,MAAM,iCAAiC,CAAC;AAG7G,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAQlE,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;AAkD5D,MAAM,UAAU,SAAS,CAAC,IAQzB;IACA,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC;IACtC,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACnD,GAAG,KAAK;QACR,UAAU,EAAE,CAAC,OAAgB,EAAE,MAA6B,EAAE,EAAE,CAC/D,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,EAAE,CACpC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CACvI;KACF,CAAC,CAAC,CAAC;IACJ,IAAI,iBAAiB,GAAc,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,EAAE,GAAG,WAAW,EAAE,OAAO,EAAE,CAAC,CAAC;IAC3F,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,IAA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AAI,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,CAoBxI"}
package/dist/registry.js CHANGED
@@ -14,7 +14,9 @@ export function adminRegistry(...pages) {
14
14
  }
15
15
  for (const page of pages) {
16
16
  unique(ids, page.id, "page id");
17
- unique(paths, page.route.path, "path");
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
+ }
18
20
  for (const tag of page.contract.requests.keys()) {
19
21
  unique(tags, tag, "RPC tag");
20
22
  }
@@ -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,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,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC;YACjD,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;QAC9B,CAAC;IACF,CAAC;IACD,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"}
@@ -0,0 +1,7 @@
1
+ import { Context } from "effect";
2
+ import type { SessionPolicy, UserSessionShape } from "@shivaedev/identity/server/session.ts";
3
+ declare const AdminSessions_base: Context.ServiceClass<AdminSessions, "@shivaedev/admin/AdminSessions", SessionPolicy<UserSessionShape>>;
4
+ export declare class AdminSessions extends AdminSessions_base {
5
+ }
6
+ export {};
7
+ //# sourceMappingURL=AdminSessions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdminSessions.d.ts","sourceRoot":"","sources":["../../src/server/AdminSessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;;AAE7F,qBAAa,aAAc,SAAQ,kBAAmG;CAAG"}
@@ -0,0 +1,4 @@
1
+ import { Context } from "effect";
2
+ export class AdminSessions extends Context.Service()("@shivaedev/admin/AdminSessions") {
3
+ }
4
+ //# sourceMappingURL=AdminSessions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdminSessions.js","sourceRoot":"","sources":["../../src/server/AdminSessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAGjC,MAAM,OAAO,aAAc,SAAQ,OAAO,CAAC,OAAO,EAAkD,CAAC,gCAAgC,CAAC;CAAG"}
@@ -0,0 +1,7 @@
1
+ import { Effect } from "effect";
2
+ import type { HttpServerRequest } from "effect/http";
3
+ import { HttpRouter, HttpServerResponse } from "effect/http";
4
+ import type { AnyAdminRegistry } from "#registry.ts";
5
+ import { AdminSessions } from "./AdminSessions.ts";
6
+ export declare function adminDocuments<E, R>(registry: AnyAdminRegistry, handler: (request: HttpServerRequest.HttpServerRequest) => Effect.Effect<HttpServerResponse.HttpServerResponse, E, R>): import("effect/Layer").Layer<never, never, AdminSessions | HttpRouter.HttpRouter | Exclude<HttpRouter.Request.From<"Error", E>, import("effect/Scope").Scope> | Exclude<HttpRouter.Request.From<"Requires", Exclude<Exclude<R, import("@shivaedev/identity/identity.ts").Identity | import("@shivaedev/identity/identity.ts").SessionUser>, HttpRouter.Provided>>, import("effect/Scope").Scope>>;
7
+ //# sourceMappingURL=adminDocuments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adminDocuments.d.ts","sourceRoot":"","sources":["../../src/server/adminDocuments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAI7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,wBAAgB,cAAc,CAAC,CAAC,EAAE,CAAC,EAClC,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,EAAE,CAAC,OAAO,EAAE,iBAAiB,CAAC,iBAAiB,KAAK,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,kBAAkB,EAAE,CAAC,EAAE,CAAC,CAAC,qYAerH"}
@@ -0,0 +1,20 @@
1
+ import { Effect } from "effect";
2
+ import { HttpRouter, HttpServerResponse } from "effect/http";
3
+ import * as HttpStatus from "effect/http/HttpStatus";
4
+ import { permissionRoute } from "@shivaedev/identity/server/permissions.ts";
5
+ import { matchAdminRoute } from "#adapters/matchAdminRoute.ts";
6
+ import { AdminSessions } from "./AdminSessions.js";
7
+ export function adminDocuments(registry, handler) {
8
+ const routes = registry.pages.map((page) => page.route);
9
+ return HttpRouter.use((router) => Effect.gen(function* () {
10
+ const sessions = yield* AdminSessions;
11
+ yield* router.add("GET", "/admin/*", (request) => {
12
+ const path = new URL(request.url, "http://localhost").pathname;
13
+ const route = path.replace(/\/$/u, "") === "/admin" ? routes[0] : matchAdminRoute(routes, path);
14
+ return route === undefined
15
+ ? Effect.succeed(HttpServerResponse.empty({ status: HttpStatus.fromLiteral("NotFound") }))
16
+ : permissionRoute(sessions, route.permission)(handler)(request);
17
+ });
18
+ }));
19
+ }
20
+ //# sourceMappingURL=adminDocuments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adminDocuments.js","sourceRoot":"","sources":["../../src/server/adminDocuments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,UAAU,cAAc,CAC7B,QAA0B,EAC1B,OAAqH;IAErH,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACxD,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAChC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QACnB,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,aAAa,CAAC;QACtC,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,UAAU,EAAE,CAAC,OAAO,EAAE,EAAE;YAChD,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC,QAAQ,CAAC;YAC/D,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAChG,OAAO,KAAK,KAAK,SAAS;gBACzB,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;gBAC1F,CAAC,CAAC,eAAe,CAAC,QAAQ,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC;QAClE,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CACF,CAAC;AACH,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { Layer } from "effect";
2
+ import type { AnyAdminRegistry } from "#registry.ts";
3
+ import { AdminSessions } from "./AdminSessions.ts";
4
+ export declare function pagePermissions(registry: AnyAdminRegistry): Layer.Layer<unknown, never, AdminSessions>;
5
+ //# sourceMappingURL=pagePermissions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagePermissions.d.ts","sourceRoot":"","sources":["../../src/server/pagePermissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,EAAU,MAAM,QAAQ,CAAC;AAKxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,wBAAgB,eAAe,CAAC,QAAQ,EAAE,gBAAgB,8CAsBzD"}
@@ -0,0 +1,18 @@
1
+ import { Context, Effect, Layer, Option } from "effect";
2
+ import { permissionLayer } from "@shivaedev/identity/server/permissions.ts";
3
+ import { AdminSessions } from "./AdminSessions.js";
4
+ export function pagePermissions(registry) {
5
+ return Layer.unwrap(Effect.gen(function* () {
6
+ const context = yield* Effect.context();
7
+ const sessions = Context.getOption(context, AdminSessions);
8
+ if (Option.isNone(sessions)) {
9
+ const page = registry.pages[0];
10
+ return yield* Effect.die(new Error(`Missing admin permission policy: page ${page?.id}, permission ${page?.route.permission.name}; provide AdminSessions`));
11
+ }
12
+ return Layer.mergeAll(Layer.empty, ...registry.pages.map((page) => {
13
+ const middleware = Context.Service(page.permissionKey);
14
+ return permissionLayer(Object.assign(middleware, { permission: page.route.permission }), sessions.value);
15
+ }));
16
+ }));
17
+ }
18
+ //# sourceMappingURL=pagePermissions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagePermissions.js","sourceRoot":"","sources":["../../src/server/pagePermissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIxD,OAAO,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAE5E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,UAAU,eAAe,CAAC,QAA0B;IACzD,OAAO,KAAK,CAAC,MAAM,CAClB,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QACnB,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,EAAiB,CAAC;QACvD,MAAM,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QAC3D,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAC/B,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CACvB,IAAI,KAAK,CAAC,yCAAyC,IAAI,EAAE,EAAE,gBAAgB,IAAI,EAAE,KAAK,CAAC,UAAU,CAAC,IAAI,yBAAyB,CAAC,CAChI,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC,QAAQ,CACpB,KAAK,CAAC,KAAK,EACX,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;YAC9B,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CACjC,IAAI,CAAC,aAAa,CAClB,CAAC;YACF,OAAO,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC1G,CAAC,CAAC,CACF,CAAC;IACH,CAAC,CAAC,CACF,CAAC;AACH,CAAC"}
@@ -2,6 +2,7 @@ import { Layer } from "effect";
2
2
  import type { Rpc, RpcGroup } from "effect/rpc";
3
3
  import type { AdminPage } from "#page.ts";
4
4
  import type { AdminRegistry } from "#registry.ts";
5
+ import type { AdminSessions } from "./AdminSessions.ts";
5
6
  type HandlerLayers<TPages extends readonly AdminPage[]> = {
6
7
  readonly [TPage in TPages[number] as TPage["id"]]: Layer.Layer<Rpc.ToHandler<RpcGroup.Rpcs<TPage["contract"]["application"]>>, unknown, unknown>;
7
8
  };
@@ -9,7 +10,9 @@ type RegisteredLayers<THandlers> = Extract<THandlers[keyof THandlers], Layer.Any
9
10
  export declare function registerAdmin<const TPages extends readonly AdminPage[], THandlers extends HandlerLayers<TPages>>(registry: AdminRegistry<TPages>, handlers: THandlers & Record<Exclude<keyof THandlers, TPages[number]["id"]>, never>): {
10
11
  readonly group: AdminRegistry<TPages>["group"];
11
12
  readonly pages: TPages;
12
- readonly handlers: Layer.Layer<Layer.Success<RegisteredLayers<THandlers>>, Layer.Error<RegisteredLayers<THandlers>>, Layer.Services<RegisteredLayers<THandlers>>>;
13
+ readonly handlers: Layer.Layer<Layer.Success<RegisteredLayers<THandlers>> | Extract<Rpc.Middleware<RpcGroup.Rpcs<TPages[number]["contract"]>>, {
14
+ readonly key: TPages[number]["permissionKey"];
15
+ }>, Layer.Error<RegisteredLayers<THandlers>>, Layer.Services<RegisteredLayers<THandlers>> | AdminSessions>;
13
16
  };
14
17
  export {};
15
18
  //# sourceMappingURL=registerAdmin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"registerAdmin.d.ts","sourceRoot":"","sources":["../../src/server/registerAdmin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,KAAK,aAAa,CAAC,MAAM,SAAS,SAAS,SAAS,EAAE,IAAI;IACzD,QAAQ,EAAE,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC;CAChJ,CAAC;AAEF,KAAK,gBAAgB,CAAC,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC,MAAM,SAAS,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;AAElF,wBAAgB,aAAa,CAAC,KAAK,CAAC,MAAM,SAAS,SAAS,SAAS,EAAE,EAAE,SAAS,SAAS,aAAa,CAAC,MAAM,CAAC,EAC/G,QAAQ,EAAE,aAA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CAChJ,CAAC;AAEF,KAAK,gBAAgB,CAAC,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC,MAAM,SAAS,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;AAElF,wBAAgB,aAAa,CAAC,KAAK,CAAC,MAAM,SAAS,SAAS,SAAS,EAAE,EAAE,SAAS,SAAS,aAAa,CAAC,MAAM,CAAC,EAC/G,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,EAC/B,QAAQ,EAAE,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,CAAC,GACjF;IACF,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC;IAC/C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,KAAK,CAC3B,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,GAC1C,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE;QAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,eAAe,CAAC,CAAA;KAAE,CAAC,EACvH,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,EACxC,KAAK,CAAC,QAAQ,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,GAAG,aAAa,CAC3D,CAAC;CACF,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { Effect, Layer } from "effect";
2
+ import { pagePermissions } from "./pagePermissions.js";
2
3
  export function registerAdmin(registry, handlers) {
3
4
  const registered = Layer.suspend(() => {
4
5
  const ids = new Set(registry.pages.map((page) => page.id));
@@ -12,7 +13,7 @@ export function registerAdmin(registry, handlers) {
12
13
  return Layer.effectDiscard(Effect.die(new Error(`Unregistered admin handlers: ${id}`)));
13
14
  }
14
15
  }
15
- return Layer.mergeAll(Layer.empty, ...Object.values(handlers));
16
+ return Layer.mergeAll(Layer.empty, ...Object.values(handlers)).pipe(Layer.provideMerge(pagePermissions(registry)));
16
17
  });
17
18
  return { group: registry.group, handlers: registered, pages: registry.pages };
18
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"registerAdmin.js","sourceRoot":"","sources":["../../src/server/registerAdmin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAuBvC,MAAM,UAAU,aAAa,CAC5B,QAA6C,EAC7C,QAAwE;IAExE,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACrC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QAC3D,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;YACtB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC,EAAE,CAAC;gBAClC,OAAO,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,2BAA2B,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;YACpF,CAAC;QACF,CAAC;QACD,KAAK,MAAM,EAAE,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YACxC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;gBAClB,OAAO,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,gCAAgC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;YACzF,CAA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AK,CAAC,gCAAgC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;YACzF,CAAC;QACF,CAAC;QACD,OAAO,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IACpH,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC;AAC/E,CAAC"}
@@ -17,5 +17,5 @@ export declare const listUsers: <TRole extends string>(access: Pick<AccessPolicy
17
17
  readonly role: TRole;
18
18
  }[];
19
19
  }, 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, import("effect/reactivity/Reactivity").Reactivity | 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
21
  //# 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,2XAW7F,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;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,4 +1,4 @@
1
1
  import type { AccessPolicy } from "@shivaedev/access/roleSet.ts";
2
2
  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/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>;
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
4
  //# 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,wPAU3D"}
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,6 +1,13 @@
1
1
  import { SessionsPermission } from "@shivaedev/identity/sessionPermissions.ts";
2
2
  export declare const SessionsPage: import("#page.ts").AdminPage & {
3
+ readonly route: {
4
+ readonly path: "/admin/sessions";
5
+ readonly title: "Sessions";
6
+ } & {
7
+ readonly permission: import("@shivaedev/access/permission.ts").Permission;
8
+ };
3
9
  readonly id: "sessions";
10
+ readonly permissionKey: string;
4
11
  readonly contract: import("@shivaedev/contract/contract.ts").Contract<"identity.sessions", readonly [Omit<NoInfer<import("@shivaedev/contract/operation.ts").Query<"list", import("effect/Schema").Struct<{
5
12
  readonly cursor: import("effect/Schema").optionalKey<import("effect/Schema").Struct<{
6
13
  readonly id: import("effect/Schema").String;
@@ -1 +1 @@
1
- {"version":3,"file":"Page.d.ts","sourceRoot":"","sources":["../../src/sessions/Page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAI/E,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAKvB,CAAC"}
1
+ {"version":3,"file":"Page.d.ts","sourceRoot":"","sources":["../../src/sessions/Page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAI/E,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAKvB,CAAC"}
@@ -15,7 +15,14 @@ export declare const UsersList: Schema.Struct<{
15
15
  readonly canChangeRoles: Schema.Boolean;
16
16
  }>;
17
17
  export declare function usersPage<const TRole extends string>(access: Pick<AccessPolicy<TRole>, "Role">): import("#page.ts").AdminPage & {
18
+ readonly route: {
19
+ readonly path: "/admin/users";
20
+ readonly title: "Users";
21
+ } & {
22
+ readonly permission: import("@shivaedev/access/permission.ts").Permission;
23
+ };
18
24
  readonly id: "users";
25
+ readonly permissionKey: string;
19
26
  readonly contract: import("@shivaedev/contract/contract.ts").Contract<"admin.users", readonly [Omit<NoInfer<import("@shivaedev/contract/operation.ts").Query<"list", Schema.Struct<{
20
27
  readonly cursor: Schema.optionalKey<Schema.String>;
21
28
  readonly limit: Schema.Number;
@@ -1 +1 @@
1
- {"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../src/users/page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAI9D,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAErF,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAKlD,eAAO,MAAM,SAAS;;;;;;;;;;EAAwE,CAAC;AAC/F,wBAAgB,SAAS,CAAC,KAAK,CAAC,KAAK,SAAS,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwB9F"}
1
+ {"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../src/users/page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAI9D,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAErF,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAKlD,eAAO,MAAM,SAAS;;;;;;;;;;EAAwE,CAAC;AAC/F,wBAAgB,SAAS,CAAC,KAAK,CAAC,KAAK,SAAS,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwB9F"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shivaedev/admin",
3
- "version": "0.15.0",
3
+ "version": "0.16.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,20 @@
42
42
  "README.md"
43
43
  ],
44
44
  "dependencies": {
45
- "@shivaedev/access": "0.3.3",
45
+ "@shivaedev/access": "0.3.4",
46
46
  "@shivaedev/changes": "0.6.0",
47
- "@shivaedev/contract": "0.29.0",
48
- "@shivaedev/errors": "0.3.0",
49
- "@shivaedev/identity": "0.12.0",
50
- "@shivaedev/jobs": "0.28.0",
51
- "@shivaedev/react": "0.30.0"
47
+ "@shivaedev/contract": "0.30.0",
48
+ "@shivaedev/errors": "0.4.0",
49
+ "@shivaedev/identity": "0.14.0",
50
+ "@shivaedev/jobs": "0.28.2",
51
+ "@shivaedev/react": "0.30.1"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@effect/atom-react": "4.0.6",
55
- "@shivaedev/quality": "0.51.0",
56
- "@shivaedev/server": "0.13.0",
57
- "@shivaedev/test-sql": "0.15.1",
58
- "@shivaedev/test-story": "0.31.0",
55
+ "@shivaedev/quality": "0.52.0",
56
+ "@shivaedev/server": "0.15.0",
57
+ "@shivaedev/test-sql": "0.15.2",
58
+ "@shivaedev/test-story": "0.31.2",
59
59
  "@types/node": "24.19.2",
60
60
  "@types/react": "19.3.0",
61
61
  "@types/react-dom": "19.3.0",
@@ -0,0 +1,19 @@
1
+ import type { AdminRoute } from "#page.ts";
2
+
3
+ export function matchAdminRoute(routes: readonly AdminRoute[], pathname: string): AdminRoute | undefined {
4
+ const path = pathname.replace(/\/$/u, "");
5
+ return (
6
+ routes.find((route) => route.path.replace(/\/$/u, "") === path)
7
+ ?? routes.find((route) => {
8
+ if (route.detail === undefined) {
9
+ return false;
10
+ }
11
+ const expected = route.detail.split("/");
12
+ const actual = path.split("/");
13
+ return (
14
+ expected.length === actual.length
15
+ && expected.every((segment, index) => (segment.startsWith("$") ? actual[index] !== "" : segment === actual[index]))
16
+ );
17
+ })
18
+ );
19
+ }
@@ -0,0 +1,16 @@
1
+ import type { Permission } from "@shivaedev/access/permission.ts";
2
+ import { matchAdminRoute } from "#adapters/matchAdminRoute.ts";
3
+ import type { AdminRoute } from "#page.ts";
4
+
5
+ interface GuardContext {
6
+ readonly location: { readonly href: string; readonly pathname: string; readonly state?: object | undefined };
7
+ readonly matches: readonly { readonly staticData: { readonly permission?: Permission; readonly signedIn?: boolean } }[];
8
+ }
9
+
10
+ export function adminPermissionGuard(pages: readonly { readonly route: AdminRoute }[], guard: (context: GuardContext) => void) {
11
+ const routes = pages.map((page) => page.route);
12
+ return (context: GuardContext): void => {
13
+ const matched = matchAdminRoute(routes, context.location.pathname);
14
+ guard({ ...context, matches: [...context.matches, { staticData: matched === undefined ? {} : { permission: matched.permission } }] });
15
+ };
16
+ }
package/src/page.ts CHANGED
@@ -1,13 +1,15 @@
1
- import { Effect, type Option } from "effect";
1
+ import { type Context, Effect, type Option } from "effect";
2
2
  import type { Rpc, RpcGroup, RpcMiddleware } from "effect/rpc";
3
3
  import type { Permission } from "@shivaedev/access/permission.ts";
4
4
  import { type Contract, contract, type Declared, type QueryServices } from "@shivaedev/contract/contract.ts";
5
5
  import type { CommandShape, QueryShape, StreamShape } from "@shivaedev/contract/operation.ts";
6
6
  import type { QueryReadPolicy, Viewer } from "@shivaedev/contract/readPolicy.ts";
7
- import { SessionUser } from "@shivaedev/identity/identity.ts";
7
+ import { type Identity, SessionUser } from "@shivaedev/identity/identity.ts";
8
+ import type { IdentityFailures } from "@shivaedev/identity/middleware.ts";
8
9
  import { hasPermission } from "@shivaedev/identity/permission.ts";
9
10
 
10
11
  export interface AdminRoute {
12
+ readonly detail?: string;
11
13
  readonly path: string;
12
14
  readonly permission: Permission;
13
15
  readonly title: string;
@@ -15,12 +17,17 @@ export interface AdminRoute {
15
17
 
16
18
  const AdminPageTypeId = Symbol.for("@shivaedev/admin/Page");
17
19
 
20
+ type PagePermission = Context.Key<unknown, RpcMiddleware.RpcMiddleware<Identity | SessionUser, IdentityFailures, never>> & {
21
+ readonly permission: Permission;
22
+ };
23
+
18
24
  export interface AdminPage {
19
25
  readonly contract: RpcGroup.Any & {
20
26
  readonly application: RpcGroup.Any;
21
27
  readonly requests: ReadonlyMap<string, Rpc.Any>;
22
28
  };
23
29
  readonly id: string;
30
+ readonly permissionKey: string;
24
31
  readonly route: AdminRoute;
25
32
  readonly [AdminPageTypeId]: true;
26
33
  }
@@ -48,25 +55,28 @@ type PageRpcs<TRpc> =
48
55
 
49
56
  export function adminPage<
50
57
  const TId extends string,
58
+ const TRoute extends Omit<AdminRoute, "permission">,
51
59
  const TName extends string,
52
60
  const TQueries extends readonly QueryShape[],
53
61
  const TCommands extends readonly CommandShape[],
54
62
  TRpcs extends Rpc.AnyWithProps,
55
63
  const TStreams extends readonly StreamShape[],
56
- TMiddleware extends RpcMiddleware.AnyService & { readonly permission: Permission },
64
+ TMiddleware extends RpcMiddleware.AnyService & PagePermission,
57
65
  >(page: {
58
66
  readonly id: TId;
59
- readonly route: Omit<AdminRoute, "permission">;
67
+ readonly route: TRoute;
60
68
  readonly permission: TMiddleware;
61
69
  readonly contract: Contract<TName, TQueries, TCommands, TRpcs, TStreams>;
62
70
  }): AdminPage & {
71
+ readonly route: TRoute & { readonly permission: Permission };
63
72
  readonly id: TId;
73
+ readonly permissionKey: TMiddleware["key"];
64
74
  readonly contract: Contract<TName, PageQueries<TQueries>, TCommands, Rpc.AddMiddleware<PageRpcs<TRpcs>, TMiddleware>, TStreams>;
65
75
  };
66
76
  export function adminPage(page: {
67
77
  readonly id: string;
68
78
  readonly route: Omit<AdminRoute, "permission">;
69
- readonly permission: RpcMiddleware.AnyService & { readonly permission: Permission };
79
+ readonly permission: PagePermission & RpcMiddleware.AnyService;
70
80
  readonly contract: {
71
81
  readonly declaration: Declared<string, readonly QueryShape[], readonly CommandShape[], readonly StreamShape[]>;
72
82
  readonly requests: ReadonlyMap<string, Rpc.AnyWithProps>;
@@ -87,8 +97,10 @@ export function adminPage(page: {
87
97
  protectedContract = protectedContract.middleware(middleware);
88
98
  }
89
99
  }
100
+ const { permission, ...definition } = page;
90
101
  return {
91
- ...page,
102
+ ...definition,
103
+ permissionKey: permission.key,
92
104
  route: { ...page.route, permission: page.permission.permission },
93
105
  [AdminPageTypeId]: true as const,
94
106
  contract: protectedContract.middleware(page.permission),
package/src/registry.ts CHANGED
@@ -48,7 +48,9 @@ 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
- unique(paths, page.route.path, "path");
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
+ }
52
54
  for (const tag of page.contract.requests.keys()) {
53
55
  unique(tags, tag, "RPC tag");
54
56
  }
@@ -0,0 +1,4 @@
1
+ import { Context } from "effect";
2
+ import type { SessionPolicy, UserSessionShape } from "@shivaedev/identity/server/session.ts";
3
+
4
+ export class AdminSessions extends Context.Service<AdminSessions, SessionPolicy<UserSessionShape>>()("@shivaedev/admin/AdminSessions") {}
@@ -0,0 +1,27 @@
1
+ import { Effect } from "effect";
2
+ import type { HttpServerRequest } from "effect/http";
3
+ import { HttpRouter, HttpServerResponse } from "effect/http";
4
+ import * as HttpStatus from "effect/http/HttpStatus";
5
+ import { permissionRoute } from "@shivaedev/identity/server/permissions.ts";
6
+ import { matchAdminRoute } from "#adapters/matchAdminRoute.ts";
7
+ import type { AnyAdminRegistry } from "#registry.ts";
8
+ import { AdminSessions } from "./AdminSessions.ts";
9
+
10
+ export function adminDocuments<E, R>(
11
+ registry: AnyAdminRegistry,
12
+ handler: (request: HttpServerRequest.HttpServerRequest) => Effect.Effect<HttpServerResponse.HttpServerResponse, E, R>,
13
+ ) {
14
+ const routes = registry.pages.map((page) => page.route);
15
+ return HttpRouter.use((router) =>
16
+ Effect.gen(function* () {
17
+ const sessions = yield* AdminSessions;
18
+ yield* router.add("GET", "/admin/*", (request) => {
19
+ const path = new URL(request.url, "http://localhost").pathname;
20
+ const route = path.replace(/\/$/u, "") === "/admin" ? routes[0] : matchAdminRoute(routes, path);
21
+ return route === undefined
22
+ ? Effect.succeed(HttpServerResponse.empty({ status: HttpStatus.fromLiteral("NotFound") }))
23
+ : permissionRoute(sessions, route.permission)(handler)(request);
24
+ });
25
+ }),
26
+ );
27
+ }
@@ -0,0 +1,31 @@
1
+ import { Context, Effect, Layer, Option } from "effect";
2
+ import type { RpcMiddleware } from "effect/rpc";
3
+ import type { Identity, SessionUser } from "@shivaedev/identity/identity.ts";
4
+ import type { IdentityFailures } from "@shivaedev/identity/middleware.ts";
5
+ import { permissionLayer } from "@shivaedev/identity/server/permissions.ts";
6
+ import type { AnyAdminRegistry } from "#registry.ts";
7
+ import { AdminSessions } from "./AdminSessions.ts";
8
+
9
+ export function pagePermissions(registry: AnyAdminRegistry) {
10
+ return Layer.unwrap(
11
+ Effect.gen(function* () {
12
+ const context = yield* Effect.context<AdminSessions>();
13
+ const sessions = Context.getOption(context, AdminSessions);
14
+ if (Option.isNone(sessions)) {
15
+ const page = registry.pages[0];
16
+ return yield* Effect.die(
17
+ new Error(`Missing admin permission policy: page ${page?.id}, permission ${page?.route.permission.name}; provide AdminSessions`),
18
+ );
19
+ }
20
+ return Layer.mergeAll(
21
+ Layer.empty,
22
+ ...registry.pages.map((page) => {
23
+ const middleware = Context.Service<unknown, RpcMiddleware.RpcMiddleware<Identity | SessionUser, IdentityFailures, never>>(
24
+ page.permissionKey,
25
+ );
26
+ return permissionLayer(Object.assign(middleware, { permission: page.route.permission }), sessions.value);
27
+ }),
28
+ );
29
+ }),
30
+ );
31
+ }
@@ -2,6 +2,8 @@ import { Effect, Layer } from "effect";
2
2
  import type { Rpc, RpcGroup } from "effect/rpc";
3
3
  import type { AdminPage } from "#page.ts";
4
4
  import type { AdminRegistry } from "#registry.ts";
5
+ import type { AdminSessions } from "./AdminSessions.ts";
6
+ import { pagePermissions } from "./pagePermissions.ts";
5
7
 
6
8
  type HandlerLayers<TPages extends readonly AdminPage[]> = {
7
9
  readonly [TPage in TPages[number] as TPage["id"]]: Layer.Layer<Rpc.ToHandler<RpcGroup.Rpcs<TPage["contract"]["application"]>>, unknown, unknown>;
@@ -16,15 +18,16 @@ export function registerAdmin<const TPages extends readonly AdminPage[], THandle
16
18
  readonly group: AdminRegistry<TPages>["group"];
17
19
  readonly pages: TPages;
18
20
  readonly handlers: Layer.Layer<
19
- Layer.Success<RegisteredLayers<THandlers>>,
21
+ | Layer.Success<RegisteredLayers<THandlers>>
22
+ | Extract<Rpc.Middleware<RpcGroup.Rpcs<TPages[number]["contract"]>>, { readonly key: TPages[number]["permissionKey"] }>,
20
23
  Layer.Error<RegisteredLayers<THandlers>>,
21
- Layer.Services<RegisteredLayers<THandlers>>
24
+ Layer.Services<RegisteredLayers<THandlers>> | AdminSessions
22
25
  >;
23
26
  };
24
27
  export function registerAdmin(
25
28
  registry: AdminRegistry<readonly AdminPage[]>,
26
29
  handlers: Readonly<Record<string, Layer.Layer<never, unknown, unknown>>>,
27
- ) {
30
+ ): { readonly group: RpcGroup.Any; readonly handlers: Layer.Layer<never, unknown, unknown>; readonly pages: readonly AdminPage[] } {
28
31
  const registered = Layer.suspend(() => {
29
32
  const ids = new Set(registry.pages.map((page) => page.id));
30
33
  for (const id of ids) {
@@ -37,7 +40,7 @@ export function registerAdmin(
37
40
  return Layer.effectDiscard(Effect.die(new Error(`Unregistered admin handlers: ${id}`)));
38
41
  }
39
42
  }
40
- return Layer.mergeAll(Layer.empty, ...Object.values(handlers));
43
+ return Layer.mergeAll(Layer.empty, ...Object.values(handlers)).pipe(Layer.provideMerge(pagePermissions(registry)));
41
44
  });
42
45
  return { group: registry.group, handlers: registered, pages: registry.pages };
43
46
  }