@shivaedev/admin 0.16.2 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/README.md +8 -7
- package/dist/jobs/page.d.ts +23 -23
- package/dist/server/adminDocuments.d.ts +1 -2
- package/dist/server/adminDocuments.d.ts.map +1 -1
- package/dist/server/adminDocuments.js +1 -3
- package/dist/server/adminDocuments.js.map +1 -1
- package/dist/server/pagePermissions.d.ts +1 -2
- package/dist/server/pagePermissions.d.ts.map +1 -1
- package/dist/server/pagePermissions.js +4 -13
- package/dist/server/pagePermissions.js.map +1 -1
- package/dist/server/registerAdmin.d.ts +2 -2
- package/dist/server/registerAdmin.d.ts.map +1 -1
- package/dist/users/page.d.ts +5 -5
- package/package.json +11 -11
- package/src/server/adminDocuments.ts +1 -3
- package/src/server/pagePermissions.ts +6 -21
- package/src/server/registerAdmin.ts +2 -2
- package/dist/server/AdminSessions.d.ts +0 -7
- package/dist/server/AdminSessions.d.ts.map +0 -1
- package/dist/server/AdminSessions.js +0 -4
- package/dist/server/AdminSessions.js.map +0 -1
- package/src/server/AdminSessions.ts +0 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.17.0 - 2026-11-01
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- Identity operation spans use the `Identity` prefix, including `Identity.resolveSession` and `Identity.betterAuthSession`. Adjust trace queries that used `Platform` or `PlatformRpc` names.
|
|
8
|
+
|
|
9
|
+
### Breaking
|
|
10
|
+
|
|
11
|
+
- Identity reads `SessionPolicy` from the Effect environment. Import the service from `@shivaedev/identity/server/SessionPolicy.ts` and construct one `Layer.succeed(SessionPolicy, { origin, provider, roles, streamRevalidationInterval })`, omitting optional fields as needed. Replace `SessionPolicy<TSession>` annotations with `SessionPolicy["Service"]`; provider-specific types remain on `SessionProvider<TSession>`. Remove policy arguments from session middleware constructors, `resolveSession`, `withSessionUser`, `permissionLayer`, `permissionRoute`, session lookup, rechecks and stream revalidation; provide the policy Layer to the composed readers. Profiles and provider accounts are decoded at their middleware boundaries from the shared provider.
|
|
12
|
+
- Server's `appHost` `sessions` option accepts that Layer and supplies it to middleware, application routes, sockets and change subscriptions. Wrap the previous policy object in `Layer.succeed(SessionPolicy, policy)`. Remove the session-shape generic from host option and factory types, and remove the policy argument from `hostChanges` and `bearerSocketRpc`.
|
|
13
|
+
- Admin uses identity's `SessionPolicy` directly. Replace `AdminSessions` imports and Layers with the identity service, and provide the policy once through the host instead of separately to admin handlers and documents.
|
|
14
|
+
- MCP's `mcpRoutes` reads `SessionPolicy` from the environment. Remove its `sessions` option and the session-shape generic from `McpOptions`; `betterAuthMcp` now returns `sessions` as a policy Layer, which can be passed to the host or supplied to MCP routes with `HttpRouter.provideRequest(oauth.sessions)` when the host also serves cookie-authenticated RPC.
|
|
15
|
+
|
|
16
|
+
## 0.16.3 - 2026-11-01
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- Update `@shivaedev/access` from 0.3.4 to 0.3.5.
|
|
21
|
+
- Update `@shivaedev/contract` from 0.30.0 to 0.30.1.
|
|
22
|
+
- Update `@shivaedev/errors` from 0.4.0 to 0.4.1.
|
|
23
|
+
- Update `@shivaedev/identity` from 0.15.0 to 0.16.0.
|
|
24
|
+
- Update `@shivaedev/jobs` from 0.28.3 to 0.29.0.
|
|
25
|
+
- Update `@shivaedev/react` from 0.31.0 to 0.31.1.
|
|
26
|
+
|
|
3
27
|
## 0.16.2 - 2026-11-01
|
|
4
28
|
|
|
5
29
|
### Changed
|
package/README.md
CHANGED
|
@@ -58,14 +58,15 @@ Register server handler Layers by page id in `src/modules/admin/jobs/server/regi
|
|
|
58
58
|
```ts
|
|
59
59
|
import { Effect, Layer } from "effect";
|
|
60
60
|
import { registerAdmin } from "@shivaedev/admin/server/registerAdmin.ts";
|
|
61
|
-
import {
|
|
61
|
+
import { SessionPolicy } from "@shivaedev/identity/server/SessionPolicy.ts";
|
|
62
62
|
|
|
63
63
|
const registration = registerAdmin(Admin, {
|
|
64
64
|
jobs: Jobs.contract.application.toLayer({
|
|
65
65
|
"admin.jobs.failed": () => Effect.succeed(["mail-42"]),
|
|
66
66
|
}),
|
|
67
67
|
});
|
|
68
|
-
const
|
|
68
|
+
const sessions = Layer.succeed(SessionPolicy, { origin, provider, roles: Access });
|
|
69
|
+
const handlers = registration.handlers;
|
|
69
70
|
```
|
|
70
71
|
|
|
71
72
|
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`.
|
|
@@ -74,9 +75,9 @@ Pass `registration.group` and `handlers` to the existing application's RPC host
|
|
|
74
75
|
|
|
75
76
|
### Protect documents and detail routes
|
|
76
77
|
|
|
77
|
-
Provide the application's session policy through `
|
|
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.
|
|
78
79
|
|
|
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 `
|
|
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
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
83
|
|
|
@@ -90,7 +91,7 @@ import { mergeAdminRegistrations } from "@shivaedev/admin/server/mergeAdminRegis
|
|
|
90
91
|
const admin = mergeAdminRegistrations(foundation.admin, catalog.admin);
|
|
91
92
|
```
|
|
92
93
|
|
|
93
|
-
|
|
94
|
+
Pass the policy Layer once as `appHost({ sessions, handlers: admin.handlers, group: admin.group })`. Custom hosts provide it to their composed middleware and routes with `Layer.provide(sessions)`. 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.
|
|
94
95
|
|
|
95
96
|
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.
|
|
96
97
|
|
|
@@ -224,7 +225,7 @@ const changeRole = Client.runtime.fn(users.changeRole.run);
|
|
|
224
225
|
<UsersView roles={AppAccess.Role.literals} list={users.list.query} changeRole={changeRole} />;
|
|
225
226
|
```
|
|
226
227
|
|
|
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 `
|
|
228
|
+
`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 `SessionPolicy`.
|
|
228
229
|
|
|
229
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.
|
|
230
231
|
|
|
@@ -234,7 +235,7 @@ Keep Better Auth cookie caching disabled so requests see current permissions. Ro
|
|
|
234
235
|
|
|
235
236
|
### Built-in Sessions page
|
|
236
237
|
|
|
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 `
|
|
238
|
+
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 `SessionPolicy`. The page uses identity's `identity.sessions` contract and `sessions.manage` permission.
|
|
238
239
|
|
|
239
240
|
```tsx
|
|
240
241
|
import { SessionsView } from "@shivaedev/admin/client/SessionsView.ts";
|
package/dist/jobs/page.d.ts
CHANGED
|
@@ -202,7 +202,7 @@ export declare function jobsPage<const TQueues extends readonly JobsEntry[]>(...
|
|
|
202
202
|
readonly failedCount: Schema.Number;
|
|
203
203
|
readonly queuedCount: Schema.Number;
|
|
204
204
|
readonly totalCount: Schema.Number;
|
|
205
|
-
}>, Schema.Union<readonly [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)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.
|
|
205
|
+
}>, Schema.Union<readonly [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)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.deadLettered", Schema.Struct<{
|
|
206
206
|
cursor: Schema.optionalKey<Schema.String>;
|
|
207
207
|
limit: Schema.Number;
|
|
208
208
|
queue: Schema.String;
|
|
@@ -222,9 +222,15 @@ export declare function jobsPage<const TQueues extends readonly JobsEntry[]>(...
|
|
|
222
222
|
readonly state: Schema.Literals<readonly ["created", "retry", "active", "completed", "cancelled", "failed"]>;
|
|
223
223
|
readonly data: Schema.Unknown;
|
|
224
224
|
readonly queue: Schema.Literal<string>;
|
|
225
|
+
readonly sourceId: Schema.OptionFromNullOr<Schema.String>;
|
|
226
|
+
readonly sourceOutput: Schema.NullOr<Schema.Struct<{
|
|
227
|
+
readonly _tag: Schema.withDecodingDefaultKey<Schema.String, never>;
|
|
228
|
+
readonly message: Schema.decodeTo<Schema.String, Schema.String, never, never>;
|
|
229
|
+
}>>;
|
|
230
|
+
readonly sourceQueue: Schema.Literal<string>;
|
|
225
231
|
}>[]>>;
|
|
226
232
|
readonly next: Schema.OptionFromNullOr<Schema.String>;
|
|
227
|
-
}>, Schema.Union<readonly [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)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.
|
|
233
|
+
}>, Schema.Union<readonly [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)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.failed", Schema.Struct<{
|
|
228
234
|
cursor: Schema.optionalKey<Schema.String>;
|
|
229
235
|
limit: Schema.Number;
|
|
230
236
|
queue: Schema.String;
|
|
@@ -244,14 +250,22 @@ export declare function jobsPage<const TQueues extends readonly JobsEntry[]>(...
|
|
|
244
250
|
readonly state: Schema.Literals<readonly ["created", "retry", "active", "completed", "cancelled", "failed"]>;
|
|
245
251
|
readonly data: Schema.Unknown;
|
|
246
252
|
readonly queue: Schema.Literal<string>;
|
|
247
|
-
readonly sourceId: Schema.OptionFromNullOr<Schema.String>;
|
|
248
|
-
readonly sourceOutput: Schema.NullOr<Schema.Struct<{
|
|
249
|
-
readonly _tag: Schema.withDecodingDefaultKey<Schema.String, never>;
|
|
250
|
-
readonly message: Schema.decodeTo<Schema.String, Schema.String, never, never>;
|
|
251
|
-
}>>;
|
|
252
|
-
readonly sourceQueue: Schema.Literal<string>;
|
|
253
253
|
}>[]>>;
|
|
254
254
|
readonly next: Schema.OptionFromNullOr<Schema.String>;
|
|
255
|
+
}>, Schema.Union<readonly [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)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.health", Schema.Void, Schema.Struct<{
|
|
256
|
+
readonly activeTotal: Schema.Number;
|
|
257
|
+
readonly deadLetteredTotal: Schema.Number;
|
|
258
|
+
readonly failedTotal: Schema.Number;
|
|
259
|
+
readonly jobs: Schema.$Array<Schema.Struct<{
|
|
260
|
+
readonly activeCount: Schema.Number;
|
|
261
|
+
readonly deadLetteredCount: Schema.Number;
|
|
262
|
+
readonly failedCount: Schema.Number;
|
|
263
|
+
readonly name: Schema.String;
|
|
264
|
+
readonly queuedCount: Schema.Number;
|
|
265
|
+
readonly readyCount: Schema.Number;
|
|
266
|
+
}>>;
|
|
267
|
+
readonly queuedTotal: Schema.Number;
|
|
268
|
+
readonly readyTotal: Schema.Number;
|
|
255
269
|
}>, Schema.Union<readonly [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)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.job", Schema.Struct<{
|
|
256
270
|
id: Schema.String;
|
|
257
271
|
queue: Schema.String;
|
|
@@ -270,21 +284,7 @@ export declare function jobsPage<const TQueues extends readonly JobsEntry[]>(...
|
|
|
270
284
|
readonly state: Schema.Literals<readonly ["created", "retry", "active", "completed", "cancelled", "failed"]>;
|
|
271
285
|
readonly data: Schema.Unknown;
|
|
272
286
|
readonly queue: Schema.Literal<string>;
|
|
273
|
-
}>[]>>, Schema.Union<readonly [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)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never
|
|
274
|
-
readonly activeTotal: Schema.Number;
|
|
275
|
-
readonly deadLetteredTotal: Schema.Number;
|
|
276
|
-
readonly failedTotal: Schema.Number;
|
|
277
|
-
readonly jobs: Schema.$Array<Schema.Struct<{
|
|
278
|
-
readonly activeCount: Schema.Number;
|
|
279
|
-
readonly deadLetteredCount: Schema.Number;
|
|
280
|
-
readonly failedCount: Schema.Number;
|
|
281
|
-
readonly name: Schema.String;
|
|
282
|
-
readonly queuedCount: Schema.Number;
|
|
283
|
-
readonly readyCount: Schema.Number;
|
|
284
|
-
}>>;
|
|
285
|
-
readonly queuedTotal: Schema.Number;
|
|
286
|
-
readonly readyTotal: Schema.Number;
|
|
287
|
-
}>, Schema.Union<readonly [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)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never>, readonly [], undefined>;
|
|
287
|
+
}>[]>>, Schema.Union<readonly [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)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never>, readonly [], undefined>;
|
|
288
288
|
} & {
|
|
289
289
|
queues: TQueues;
|
|
290
290
|
};
|
|
@@ -2,6 +2,5 @@ import { Effect } from "effect";
|
|
|
2
2
|
import type { HttpServerRequest } from "effect/http";
|
|
3
3
|
import { HttpRouter, HttpServerResponse } from "effect/http";
|
|
4
4
|
import type { AnyAdminRegistry } from "#registry.ts";
|
|
5
|
-
import
|
|
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>>;
|
|
5
|
+
export declare function adminDocuments<E, R>(registry: AnyAdminRegistry, handler: (request: HttpServerRequest.HttpServerRequest) => Effect.Effect<HttpServerResponse.HttpServerResponse, E, R>): import("effect/Layer").Layer<never, never, HttpRouter.HttpRouter | HttpRouter.Request<"Requires", import("@shivaedev/identity/server/SessionPolicy.ts").SessionPolicy> | 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
6
|
//# sourceMappingURL=adminDocuments.d.ts.map
|
|
@@ -1 +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;
|
|
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;AAErD,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,2dAcrH"}
|
|
@@ -3,17 +3,15 @@ import { HttpRouter, HttpServerResponse } from "effect/http";
|
|
|
3
3
|
import * as HttpStatus from "effect/http/HttpStatus";
|
|
4
4
|
import { permissionRoute } from "@shivaedev/identity/server/permissions.ts";
|
|
5
5
|
import { matchAdminRoute } from "#adapters/matchAdminRoute.ts";
|
|
6
|
-
import { AdminSessions } from "./AdminSessions.js";
|
|
7
6
|
export function adminDocuments(registry, handler) {
|
|
8
7
|
const routes = registry.pages.map((page) => page.route);
|
|
9
8
|
return HttpRouter.use((router) => Effect.gen(function* () {
|
|
10
|
-
const sessions = yield* AdminSessions;
|
|
11
9
|
yield* router.add("GET", "/admin/*", (request) => {
|
|
12
10
|
const path = new URL(request.url, "http://localhost").pathname;
|
|
13
11
|
const route = path.replace(/\/$/u, "") === "/admin" ? routes[0] : matchAdminRoute(routes, path);
|
|
14
12
|
return route === undefined
|
|
15
13
|
? Effect.succeed(HttpServerResponse.empty({ status: HttpStatus.fromLiteral("NotFound") }))
|
|
16
|
-
: permissionRoute(
|
|
14
|
+
: permissionRoute(route.permission)(handler)(request);
|
|
17
15
|
});
|
|
18
16
|
}));
|
|
19
17
|
}
|
|
@@ -1 +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;
|
|
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;AAG/D,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,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,KAAK,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CACF,CAAC;AACH,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Layer } from "effect";
|
|
2
2
|
import type { AnyAdminRegistry } from "#registry.ts";
|
|
3
|
-
|
|
4
|
-
export declare function pagePermissions(registry: AnyAdminRegistry): Layer.Layer<unknown, never, AdminSessions>;
|
|
3
|
+
export declare function pagePermissions(registry: AnyAdminRegistry): Layer.Layer<unknown, never, import("@shivaedev/identity/server/SessionPolicy.ts").SessionPolicy>;
|
|
5
4
|
//# sourceMappingURL=pagePermissions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagePermissions.d.ts","sourceRoot":"","sources":["../../src/server/pagePermissions.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"pagePermissions.d.ts","sourceRoot":"","sources":["../../src/server/pagePermissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,EAAE,MAAM,QAAQ,CAAC;AAKxC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,wBAAgB,eAAe,CAAC,QAAQ,EAAE,gBAAgB,oGAQzD"}
|
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
import { Context,
|
|
1
|
+
import { Context, Layer } from "effect";
|
|
2
2
|
import { permissionLayer } from "@shivaedev/identity/server/permissions.ts";
|
|
3
|
-
import { AdminSessions } from "./AdminSessions.js";
|
|
4
3
|
export function pagePermissions(registry) {
|
|
5
|
-
return Layer.
|
|
6
|
-
const
|
|
7
|
-
|
|
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
|
-
}));
|
|
4
|
+
return Layer.mergeAll(Layer.empty, ...registry.pages.map((page) => {
|
|
5
|
+
const middleware = Context.Service(page.permissionKey);
|
|
6
|
+
return permissionLayer(Object.assign(middleware, { permission: page.route.permission }));
|
|
16
7
|
}));
|
|
17
8
|
}
|
|
18
9
|
//# sourceMappingURL=pagePermissions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagePermissions.js","sourceRoot":"","sources":["../../src/server/pagePermissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"pagePermissions.js","sourceRoot":"","sources":["../../src/server/pagePermissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAIxC,OAAO,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAG5E,MAAM,UAAU,eAAe,CAAC,QAA0B;IACzD,OAAO,KAAK,CAAC,QAAQ,CACpB,KAAK,CAAC,KAAK,EACX,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAC9B,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAwF,IAAI,CAAC,aAAa,CAAC,CAAC;QAC9I,OAAO,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IAC1F,CAAC,CAAC,CACF,CAAC;AACH,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Layer } from "effect";
|
|
2
2
|
import type { Rpc, RpcGroup } from "effect/rpc";
|
|
3
|
+
import type { SessionPolicy } from "@shivaedev/identity/server/SessionPolicy.ts";
|
|
3
4
|
import type { AdminPage } from "#page.ts";
|
|
4
5
|
import type { AdminRegistry } from "#registry.ts";
|
|
5
|
-
import type { AdminSessions } from "./AdminSessions.ts";
|
|
6
6
|
type HandlerLayers<TPages extends readonly AdminPage[]> = {
|
|
7
7
|
readonly [TPage in TPages[number] as TPage["id"]]: Layer.Layer<Rpc.ToHandler<RpcGroup.Rpcs<TPage["contract"]["application"]>>, unknown, unknown>;
|
|
8
8
|
};
|
|
@@ -12,7 +12,7 @@ export declare function registerAdmin<const TPages extends readonly AdminPage[],
|
|
|
12
12
|
readonly pages: TPages;
|
|
13
13
|
readonly handlers: Layer.Layer<Layer.Success<RegisteredLayers<THandlers>> | Extract<Rpc.Middleware<RpcGroup.Rpcs<TPages[number]["contract"]>>, {
|
|
14
14
|
readonly key: TPages[number]["permissionKey"];
|
|
15
|
-
}>, Layer.Error<RegisteredLayers<THandlers>>, Layer.Services<RegisteredLayers<THandlers>> |
|
|
15
|
+
}>, Layer.Error<RegisteredLayers<THandlers>>, Layer.Services<RegisteredLayers<THandlers>> | SessionPolicy>;
|
|
16
16
|
};
|
|
17
17
|
export {};
|
|
18
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,
|
|
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,aAAa,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGlD,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,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"}
|
package/dist/users/page.d.ts
CHANGED
|
@@ -78,10 +78,7 @@ 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.
|
|
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<{
|
|
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<{
|
|
85
82
|
readonly cursor: Schema.optionalKey<Schema.String>;
|
|
86
83
|
readonly limit: Schema.Number;
|
|
87
84
|
}>, Schema.Struct<{
|
|
@@ -94,6 +91,9 @@ export declare function usersPage<const TRole extends string>(access: Pick<Acces
|
|
|
94
91
|
readonly role: Schema.String;
|
|
95
92
|
}>>;
|
|
96
93
|
readonly canChangeRoles: Schema.Boolean;
|
|
97
|
-
}>, Schema.Union<readonly [Schema.Union<readonly (typeof Forbidden | typeof AuthUnavailable)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof UsersPermission, never
|
|
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>;
|
|
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.
|
|
3
|
+
"version": "0.17.0",
|
|
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.
|
|
45
|
+
"@shivaedev/access": "0.3.5",
|
|
46
46
|
"@shivaedev/changes": "0.6.0",
|
|
47
|
-
"@shivaedev/contract": "0.30.
|
|
48
|
-
"@shivaedev/errors": "0.4.
|
|
49
|
-
"@shivaedev/identity": "0.
|
|
50
|
-
"@shivaedev/jobs": "0.
|
|
51
|
-
"@shivaedev/react": "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"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@effect/atom-react": "4.0.6",
|
|
55
|
-
"@shivaedev/quality": "0.
|
|
56
|
-
"@shivaedev/server": "0.
|
|
57
|
-
"@shivaedev/test-sql": "0.
|
|
58
|
-
"@shivaedev/test-story": "0.
|
|
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",
|
|
59
59
|
"@types/node": "24.19.2",
|
|
60
60
|
"@types/react": "19.3.0",
|
|
61
61
|
"@types/react-dom": "19.3.0",
|
|
@@ -5,7 +5,6 @@ import * as HttpStatus from "effect/http/HttpStatus";
|
|
|
5
5
|
import { permissionRoute } from "@shivaedev/identity/server/permissions.ts";
|
|
6
6
|
import { matchAdminRoute } from "#adapters/matchAdminRoute.ts";
|
|
7
7
|
import type { AnyAdminRegistry } from "#registry.ts";
|
|
8
|
-
import { AdminSessions } from "./AdminSessions.ts";
|
|
9
8
|
|
|
10
9
|
export function adminDocuments<E, R>(
|
|
11
10
|
registry: AnyAdminRegistry,
|
|
@@ -14,13 +13,12 @@ export function adminDocuments<E, R>(
|
|
|
14
13
|
const routes = registry.pages.map((page) => page.route);
|
|
15
14
|
return HttpRouter.use((router) =>
|
|
16
15
|
Effect.gen(function* () {
|
|
17
|
-
const sessions = yield* AdminSessions;
|
|
18
16
|
yield* router.add("GET", "/admin/*", (request) => {
|
|
19
17
|
const path = new URL(request.url, "http://localhost").pathname;
|
|
20
18
|
const route = path.replace(/\/$/u, "") === "/admin" ? routes[0] : matchAdminRoute(routes, path);
|
|
21
19
|
return route === undefined
|
|
22
20
|
? Effect.succeed(HttpServerResponse.empty({ status: HttpStatus.fromLiteral("NotFound") }))
|
|
23
|
-
: permissionRoute(
|
|
21
|
+
: permissionRoute(route.permission)(handler)(request);
|
|
24
22
|
});
|
|
25
23
|
}),
|
|
26
24
|
);
|
|
@@ -1,31 +1,16 @@
|
|
|
1
|
-
import { Context,
|
|
1
|
+
import { Context, Layer } from "effect";
|
|
2
2
|
import type { RpcMiddleware } from "effect/rpc";
|
|
3
3
|
import type { Identity, SessionUser } from "@shivaedev/identity/identity.ts";
|
|
4
4
|
import type { IdentityFailures } from "@shivaedev/identity/middleware.ts";
|
|
5
5
|
import { permissionLayer } from "@shivaedev/identity/server/permissions.ts";
|
|
6
6
|
import type { AnyAdminRegistry } from "#registry.ts";
|
|
7
|
-
import { AdminSessions } from "./AdminSessions.ts";
|
|
8
7
|
|
|
9
8
|
export function pagePermissions(registry: AnyAdminRegistry) {
|
|
10
|
-
return Layer.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
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
|
-
);
|
|
9
|
+
return Layer.mergeAll(
|
|
10
|
+
Layer.empty,
|
|
11
|
+
...registry.pages.map((page) => {
|
|
12
|
+
const middleware = Context.Service<unknown, RpcMiddleware.RpcMiddleware<Identity | SessionUser, IdentityFailures, never>>(page.permissionKey);
|
|
13
|
+
return permissionLayer(Object.assign(middleware, { permission: page.route.permission }));
|
|
29
14
|
}),
|
|
30
15
|
);
|
|
31
16
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Effect, Layer } from "effect";
|
|
2
2
|
import type { Rpc, RpcGroup } from "effect/rpc";
|
|
3
|
+
import type { SessionPolicy } from "@shivaedev/identity/server/SessionPolicy.ts";
|
|
3
4
|
import type { AdminPage } from "#page.ts";
|
|
4
5
|
import type { AdminRegistry } from "#registry.ts";
|
|
5
|
-
import type { AdminSessions } from "./AdminSessions.ts";
|
|
6
6
|
import { pagePermissions } from "./pagePermissions.ts";
|
|
7
7
|
|
|
8
8
|
type HandlerLayers<TPages extends readonly AdminPage[]> = {
|
|
@@ -21,7 +21,7 @@ export function registerAdmin<const TPages extends readonly AdminPage[], THandle
|
|
|
21
21
|
| Layer.Success<RegisteredLayers<THandlers>>
|
|
22
22
|
| Extract<Rpc.Middleware<RpcGroup.Rpcs<TPages[number]["contract"]>>, { readonly key: TPages[number]["permissionKey"] }>,
|
|
23
23
|
Layer.Error<RegisteredLayers<THandlers>>,
|
|
24
|
-
Layer.Services<RegisteredLayers<THandlers>> |
|
|
24
|
+
Layer.Services<RegisteredLayers<THandlers>> | SessionPolicy
|
|
25
25
|
>;
|
|
26
26
|
};
|
|
27
27
|
export function registerAdmin(
|
|
@@ -1,7 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|