@shivaedev/admin 0.8.0 → 0.8.2
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/README.md +42 -30
- package/dist/client/UsersTable.js +3 -3
- package/dist/jobs/page.d.ts +19 -19
- package/dist/jobs/retryPage.d.ts +19 -19
- package/dist/users/page.d.ts +5 -5
- package/package.json +7 -7
- package/src/client/UsersTable.tsx +3 -3
package/README.md
CHANGED
|
@@ -4,21 +4,29 @@ Admin tooling starts with an explicit list of pages and the operations each page
|
|
|
4
4
|
|
|
5
5
|
## Declare the tools operators can use
|
|
6
6
|
|
|
7
|
+
Operators need one place to find the tools an application exposes, and an admin operation that forgot its permission check is a public operation. Here each admin page names its permission once, and every operation on the page, including its generated change subscription, requires it.
|
|
8
|
+
|
|
7
9
|
```ts
|
|
8
10
|
const Jobs = adminPage({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
id: "jobs",
|
|
12
|
+
permission: JobsPermission,
|
|
13
|
+
route: { path: "/admin/jobs", title: "Jobs" },
|
|
14
|
+
contract: contract("admin.jobs", { queries: [Failed] }),
|
|
13
15
|
});
|
|
14
16
|
const Admin = adminRegistry(Jobs);
|
|
15
17
|
```
|
|
16
18
|
|
|
17
19
|
The page exposes `admin.jobs.failed` and the generated `admin.jobs.$changes` subscription. Both require `JobsPermission`, which checks `ReadJobs` (`jobs.read`). A query-only contract has no command. The application grants this permission to its chosen roles.
|
|
18
20
|
|
|
19
|
-
##
|
|
21
|
+
## Using it
|
|
22
|
+
|
|
23
|
+
### How to think about it
|
|
24
|
+
|
|
25
|
+
An admin page is a native `@shivaedev/contract` contract plus a stable id, route metadata and one permission middleware. The page applies that middleware to every operation in its contract, so no admin operation exists without a permission check. The registry merges the pages into one native RPC group, and server registration pairs each page id with the handler Layer the application writes. Everything else, from the admin shell and its views to session policy and the RPC host, stays with the application.
|
|
20
26
|
|
|
21
|
-
|
|
27
|
+
### Declare pages and the registry
|
|
28
|
+
|
|
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`.
|
|
22
30
|
|
|
23
31
|
```ts
|
|
24
32
|
import { Schema } from "effect";
|
|
@@ -29,14 +37,14 @@ import { contract } from "@shivaedev/contract/contract.ts";
|
|
|
29
37
|
import { query } from "@shivaedev/contract/operation.ts";
|
|
30
38
|
|
|
31
39
|
const Failed = query("failed", {
|
|
32
|
-
|
|
33
|
-
|
|
40
|
+
reads: () => [],
|
|
41
|
+
success: Schema.Array(Schema.String),
|
|
34
42
|
});
|
|
35
43
|
const Jobs = adminPage({
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
id: "jobs",
|
|
45
|
+
permission: JobsPermission,
|
|
46
|
+
route: { path: "/admin/jobs", title: "Jobs" },
|
|
47
|
+
contract: contract("admin.jobs", { queries: [Failed] }),
|
|
40
48
|
});
|
|
41
49
|
const Admin = adminRegistry(Jobs);
|
|
42
50
|
```
|
|
@@ -52,22 +60,18 @@ import { JobsPermission, ReadJobs } from "@shivaedev/admin/permissions.ts";
|
|
|
52
60
|
import { permissionLayer } from "@shivaedev/identity/server/permissions.ts";
|
|
53
61
|
|
|
54
62
|
const registration = registerAdmin(Admin, {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
63
|
+
jobs: Jobs.contract.application.toLayer({
|
|
64
|
+
"admin.jobs.failed": () => Effect.succeed(["mail-42"]),
|
|
65
|
+
}),
|
|
58
66
|
});
|
|
59
|
-
const handlers = registration.handlers.pipe(
|
|
60
|
-
Layer.provideMerge(permissionLayer(JobsPermission, sessions)),
|
|
61
|
-
);
|
|
67
|
+
const handlers = registration.handlers.pipe(Layer.provideMerge(permissionLayer(JobsPermission, sessions)));
|
|
62
68
|
```
|
|
63
69
|
|
|
64
70
|
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`.
|
|
65
71
|
|
|
66
72
|
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 fail at registration; TypeScript also checks each Layer provides the handlers for its page.
|
|
67
73
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
## Built-in Jobs page
|
|
74
|
+
### Built-in Jobs page
|
|
71
75
|
|
|
72
76
|
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.
|
|
73
77
|
|
|
@@ -88,7 +92,7 @@ import { jobsHandlers } from "@shivaedev/admin/server/jobsHandlers.ts";
|
|
|
88
92
|
import { registerAdmin } from "@shivaedev/admin/server/registerAdmin.ts";
|
|
89
93
|
|
|
90
94
|
const registration = registerAdmin(Admin, {
|
|
91
|
-
|
|
95
|
+
jobs: jobsHandlers(JobsPage, JobsService),
|
|
92
96
|
});
|
|
93
97
|
```
|
|
94
98
|
|
|
@@ -98,9 +102,9 @@ Schedule definitions from `defineSchedule` can be passed beside queues. A browse
|
|
|
98
102
|
|
|
99
103
|
Health filters the runtime's monitor snapshot to the page's queues and recomputes totals from those queues. It has the same refresh timing as jobs health. Unregistered names, including dead-letter queue names passed directly, fail with `JobsQueueUnregistered`. Stored payload decoding failures become `JobsPayloadInvalid`; jobs operation failures become `JobsUnavailable`, carrying the operation name. These declared failures do not expose the original database error.
|
|
100
104
|
|
|
101
|
-
The default `jobsPage` declares no commands, and its bound client has no retry operation. Handler registration performs no jobs read, and a failed jobs request leaves other pages available.
|
|
105
|
+
The default `jobsPage` declares no commands, and its bound client has no retry operation. Handler registration performs no jobs read, and a failed jobs request leaves other pages available. The application supplies the Jobs view and mounts the registration on its existing RPC host.
|
|
102
106
|
|
|
103
|
-
|
|
107
|
+
#### Declare retry explicitly
|
|
104
108
|
|
|
105
109
|
Use `jobsPageWithRetry` and `jobsHandlersWithRetry` when administrators should be able to retry failed original jobs:
|
|
106
110
|
|
|
@@ -111,15 +115,15 @@ import { jobsHandlersWithRetry } from "@shivaedev/admin/server/jobsHandlersWithR
|
|
|
111
115
|
const JobsPage = jobsPageWithRetry({ name: "mail", schema: MailPayload });
|
|
112
116
|
const Admin = adminRegistry(JobsPage);
|
|
113
117
|
const registration = registerAdmin(Admin, {
|
|
114
|
-
|
|
118
|
+
jobs: jobsHandlersWithRetry(JobsPage, JobsService),
|
|
115
119
|
});
|
|
116
120
|
```
|
|
117
121
|
|
|
118
122
|
This variant adds only `admin.jobs.retry`, taking `{ queue, id }` and returning void. It requires `ReadJobs`, through the same page middleware. The handler uses the jobs package's existing retry for a failed job in a declared queue. Missing jobs and jobs in other states fail with `JobsNotFailed`; unregistered queue names, including dead-letter queues, fail with `JobsQueueUnregistered`. A dead-letter copy's id cannot retry its original.
|
|
119
123
|
|
|
120
|
-
A successful bound retry invalidates health, the affected queue's counts and both listings, and the original job's detail.
|
|
124
|
+
A successful bound retry invalidates health, the affected queue's counts and both listings, and the original job's detail. Health retains the runtime monitor's refresh timing.
|
|
121
125
|
|
|
122
|
-
|
|
126
|
+
### Built-in Users page
|
|
123
127
|
|
|
124
128
|
Call `usersPage(AppAccess)` from `@shivaedev/admin/users/page.ts` with the application's code-defined role set. Add the returned page to the same registry as Jobs and register `users: usersHandlers(UsersPage, AppAccess)` from `@shivaedev/admin/server/usersHandlers.ts`. The handlers use the application's existing Effect SQL client against Better Auth's default PostgreSQL `user` table and its `role` column. Custom table or column names are not supported.
|
|
125
129
|
|
|
@@ -142,8 +146,16 @@ const changeRole = Client.runtime.fn(users.changeRole.run);
|
|
|
142
146
|
|
|
143
147
|
Applications can call `listUsers(AppAccess, input)` and `changeUserRole(AppAccess, input)` from `@shivaedev/admin/server/users.ts` on the server. These enforce their respective domain permissions using `SessionUser`.
|
|
144
148
|
|
|
145
|
-
Keep Better Auth cookie caching disabled so requests see current permissions. Route role writes through this operation to retain the final-assigner policy.
|
|
149
|
+
Keep Better Auth cookie caching disabled so requests see current permissions. Route role writes through this operation to retain the final-assigner policy: the policy covers only `admin.users.changeRole`, so disable Better Auth's `/admin/set-role`, `/admin/update-user` and `/admin/create-user` browser endpoints, which write roles outside it. Better Auth's server-side APIs stay available for trusted code such as a bootstrap command.
|
|
150
|
+
|
|
151
|
+
### Client permission routes
|
|
152
|
+
|
|
153
|
+
`adminPage` requires a permission middleware, including for custom pages. It applies that middleware to the whole contract and exposes its permission as `page.route.permission`. Set the React route's `staticData.permission` to that value. Use `permissionGuard` from `@shivaedev/react/permissionGuard.ts` in protected routes' `beforeLoad` and wrap the router in `PermissionBoundary` from `@shivaedev/react/client/permissionBoundary.ts` with the session and one application fallback.
|
|
154
|
+
|
|
155
|
+
### Install and limits
|
|
156
|
+
|
|
157
|
+
Install `@shivaedev/admin` with `effect`, `react` and `@effect/atom-react` as peers. The package has no root entry; import the module that defines the name.
|
|
146
158
|
|
|
147
|
-
|
|
159
|
+
Page declarations and the registry are browser-safe and add no transport. Server registration lives under `/server`, and the built-in Users view under `/client` uses React. Applications own route composition and styling.
|
|
148
160
|
|
|
149
|
-
|
|
161
|
+
This package declares the permission middleware and does not resolve sessions. `permissionLayer` from `@shivaedev/identity/server/permissions.ts` resolves each request's session through the session policy the application supplies, then checks the page's permission.
|
|
@@ -2,7 +2,7 @@ import { createElement as _createElement } from "react";
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { DateTime } from "effect";
|
|
4
4
|
function UserRole({ user, canChangeRoles, roles, pending, dispatch, }) {
|
|
5
|
-
return canChangeRoles ? (_jsx("select", { "aria-label": `Role for ${user.email}`, className: "rounded-md border
|
|
5
|
+
return canChangeRoles ? (_jsx("select", { "aria-label": `Role for ${user.email}`, className: "bg-background rounded-md border p-2", disabled: pending, onChange: (event) => {
|
|
6
6
|
const role = roles.find((candidate) => candidate === event.target.value);
|
|
7
7
|
if (role !== undefined) {
|
|
8
8
|
dispatch({ role, userId: user.id });
|
|
@@ -10,7 +10,7 @@ function UserRole({ user, canChangeRoles, roles, pending, dispatch, }) {
|
|
|
10
10
|
}, value: user.role, children: roles.map((role) => (_jsx("option", { value: role, children: role }, role))) })) : (user.role);
|
|
11
11
|
}
|
|
12
12
|
function UserRow({ user, canChangeRoles, ...controls }) {
|
|
13
|
-
return (_jsxs("tr", { className: "border-b", children: [_jsx("td", { className: "p-3", children: user.name }), _jsx("td", { className: "p-3", children: user.email }), _jsx("td", { className: "p-3", children: _jsx(UserRole, { ...controls, canChangeRoles: canChangeRoles, user: user }) }), _jsx("td", { className: "whitespace-nowrap
|
|
13
|
+
return (_jsxs("tr", { className: "border-b", children: [_jsx("td", { className: "p-3", children: user.name }), _jsx("td", { className: "p-3", children: user.email }), _jsx("td", { className: "p-3", children: _jsx(UserRole, { ...controls, canChangeRoles: canChangeRoles, user: user }) }), _jsx("td", { className: "p-3 whitespace-nowrap", children: _jsx("time", { dateTime: DateTime.formatIso(user.createdAt), children: DateTime.formatIso(user.createdAt) }) })] }));
|
|
14
14
|
}
|
|
15
15
|
function UserRows({ data, ...controls }) {
|
|
16
16
|
return (_jsx("div", { className: "overflow-x-auto rounded-md border", children: _jsxs("table", { className: "w-full text-left text-sm", children: [_jsx("caption", { className: "sr-only", children: "App users and roles" }), _jsx("thead", { className: "bg-muted", children: _jsx(UserHeaders, {}) }), _jsx("tbody", { children: data.users.map((user) => (_createElement(UserRow, { ...controls, canChangeRoles: data.canChangeRoles, key: user.id, user: user }))) })] }) }));
|
|
@@ -19,6 +19,6 @@ export function UsersTable({ data, ...controls }) {
|
|
|
19
19
|
return (_jsxs("div", { className: "space-y-4", children: [data.canChangeRoles ? null : _jsx("p", { children: "Permission to assign roles is required to change roles." }), data.users.length === 0 ? _jsx("p", { children: "No users." }) : _jsx(UserRows, { ...controls, data: data })] }));
|
|
20
20
|
}
|
|
21
21
|
function UserHeaders() {
|
|
22
|
-
return (_jsx("tr", { children: ["Name", "Email", "Role", "Signed up"].map((label) => (_jsx("th", { className: "whitespace-nowrap
|
|
22
|
+
return (_jsx("tr", { children: ["Name", "Email", "Role", "Signed up"].map((label) => (_jsx("th", { className: "p-3 whitespace-nowrap", scope: "col", children: label }, label))) }));
|
|
23
23
|
}
|
|
24
24
|
//# sourceMappingURL=UsersTable.js.map
|
package/dist/jobs/page.d.ts
CHANGED
|
@@ -154,7 +154,7 @@ export declare function jobsPage<const TQueues extends readonly JobsEntry[]>(...
|
|
|
154
154
|
readonly failedCount: Schema.Number;
|
|
155
155
|
readonly queuedCount: Schema.Number;
|
|
156
156
|
readonly totalCount: Schema.Number;
|
|
157
|
-
}>, Schema.Union<readonly [Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.
|
|
157
|
+
}>, Schema.Union<readonly [Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.deadLettered", Schema.Struct<{
|
|
158
158
|
cursor: Schema.optionalKey<Schema.String>;
|
|
159
159
|
limit: Schema.Number;
|
|
160
160
|
queue: Schema.String;
|
|
@@ -171,9 +171,11 @@ export declare function jobsPage<const TQueues extends readonly JobsEntry[]>(...
|
|
|
171
171
|
readonly state: Schema.Literals<readonly ["created", "retry", "active", "completed", "cancelled", "failed"]>;
|
|
172
172
|
readonly data: JobsPayload<TQueues[number]>;
|
|
173
173
|
readonly queue: Schema.Literal<string>;
|
|
174
|
+
readonly sourceId: Schema.OptionFromNullOr<Schema.String>;
|
|
175
|
+
readonly sourceOutput: Schema.Unknown;
|
|
174
176
|
}>[]>>;
|
|
175
177
|
readonly next: Schema.OptionFromNullOr<Schema.String>;
|
|
176
|
-
}>, Schema.Union<readonly [Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.
|
|
178
|
+
}>, Schema.Union<readonly [Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.failed", Schema.Struct<{
|
|
177
179
|
cursor: Schema.optionalKey<Schema.String>;
|
|
178
180
|
limit: Schema.Number;
|
|
179
181
|
queue: Schema.String;
|
|
@@ -190,10 +192,22 @@ export declare function jobsPage<const TQueues extends readonly JobsEntry[]>(...
|
|
|
190
192
|
readonly state: Schema.Literals<readonly ["created", "retry", "active", "completed", "cancelled", "failed"]>;
|
|
191
193
|
readonly data: JobsPayload<TQueues[number]>;
|
|
192
194
|
readonly queue: Schema.Literal<string>;
|
|
193
|
-
readonly sourceId: Schema.OptionFromNullOr<Schema.String>;
|
|
194
|
-
readonly sourceOutput: Schema.Unknown;
|
|
195
195
|
}>[]>>;
|
|
196
196
|
readonly next: Schema.OptionFromNullOr<Schema.String>;
|
|
197
|
+
}>, Schema.Union<readonly [Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.health", Schema.Void, Schema.Struct<{
|
|
198
|
+
readonly activeTotal: Schema.Number;
|
|
199
|
+
readonly deadLetteredTotal: Schema.Number;
|
|
200
|
+
readonly failedTotal: Schema.Number;
|
|
201
|
+
readonly jobs: Schema.$Array<Schema.Struct<{
|
|
202
|
+
readonly activeCount: Schema.Number;
|
|
203
|
+
readonly deadLetteredCount: Schema.Number;
|
|
204
|
+
readonly failedCount: Schema.Number;
|
|
205
|
+
readonly name: Schema.String;
|
|
206
|
+
readonly queuedCount: Schema.Number;
|
|
207
|
+
readonly readyCount: Schema.Number;
|
|
208
|
+
}>>;
|
|
209
|
+
readonly queuedTotal: Schema.Number;
|
|
210
|
+
readonly readyTotal: Schema.Number;
|
|
197
211
|
}>, Schema.Union<readonly [Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.job", Schema.Struct<{
|
|
198
212
|
id: Schema.String;
|
|
199
213
|
queue: Schema.String;
|
|
@@ -209,21 +223,7 @@ export declare function jobsPage<const TQueues extends readonly JobsEntry[]>(...
|
|
|
209
223
|
readonly state: Schema.Literals<readonly ["created", "retry", "active", "completed", "cancelled", "failed"]>;
|
|
210
224
|
readonly data: JobsPayload<TQueues[number]>;
|
|
211
225
|
readonly queue: Schema.Literal<string>;
|
|
212
|
-
}>[]>>, Schema.Union<readonly [Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never
|
|
213
|
-
readonly activeTotal: Schema.Number;
|
|
214
|
-
readonly deadLetteredTotal: Schema.Number;
|
|
215
|
-
readonly failedTotal: Schema.Number;
|
|
216
|
-
readonly jobs: Schema.$Array<Schema.Struct<{
|
|
217
|
-
readonly activeCount: Schema.Number;
|
|
218
|
-
readonly deadLetteredCount: Schema.Number;
|
|
219
|
-
readonly failedCount: Schema.Number;
|
|
220
|
-
readonly name: Schema.String;
|
|
221
|
-
readonly queuedCount: Schema.Number;
|
|
222
|
-
readonly readyCount: Schema.Number;
|
|
223
|
-
}>>;
|
|
224
|
-
readonly queuedTotal: Schema.Number;
|
|
225
|
-
readonly readyTotal: Schema.Number;
|
|
226
|
-
}>, Schema.Union<readonly [Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never>, readonly [], undefined>;
|
|
226
|
+
}>[]>>, Schema.Union<readonly [Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never>, readonly [], undefined>;
|
|
227
227
|
} & {
|
|
228
228
|
queues: TQueues;
|
|
229
229
|
};
|
package/dist/jobs/retryPage.d.ts
CHANGED
|
@@ -168,7 +168,7 @@ export declare function jobsPageWithRetry<const TQueues extends readonly JobsEnt
|
|
|
168
168
|
readonly failedCount: Schema.Number;
|
|
169
169
|
readonly queuedCount: Schema.Number;
|
|
170
170
|
readonly totalCount: Schema.Number;
|
|
171
|
-
}>, Schema.Union<readonly [Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.
|
|
171
|
+
}>, Schema.Union<readonly [Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.failed", Schema.Struct<{
|
|
172
172
|
cursor: Schema.optionalKey<Schema.String>;
|
|
173
173
|
limit: Schema.Number;
|
|
174
174
|
queue: Schema.String;
|
|
@@ -185,11 +185,9 @@ export declare function jobsPageWithRetry<const TQueues extends readonly JobsEnt
|
|
|
185
185
|
readonly state: Schema.Literals<readonly ["created", "retry", "active", "completed", "cancelled", "failed"]>;
|
|
186
186
|
readonly data: import("./entry.ts").JobsPayload<[...TQueues][number]>;
|
|
187
187
|
readonly queue: Schema.Literal<string>;
|
|
188
|
-
readonly sourceId: Schema.OptionFromNullOr<Schema.String>;
|
|
189
|
-
readonly sourceOutput: Schema.Unknown;
|
|
190
188
|
}>[]>>;
|
|
191
189
|
readonly next: Schema.OptionFromNullOr<Schema.String>;
|
|
192
|
-
}>, Schema.Union<readonly [Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.
|
|
190
|
+
}>, Schema.Union<readonly [Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.deadLettered", Schema.Struct<{
|
|
193
191
|
cursor: Schema.optionalKey<Schema.String>;
|
|
194
192
|
limit: Schema.Number;
|
|
195
193
|
queue: Schema.String;
|
|
@@ -206,22 +204,10 @@ export declare function jobsPageWithRetry<const TQueues extends readonly JobsEnt
|
|
|
206
204
|
readonly state: Schema.Literals<readonly ["created", "retry", "active", "completed", "cancelled", "failed"]>;
|
|
207
205
|
readonly data: import("./entry.ts").JobsPayload<[...TQueues][number]>;
|
|
208
206
|
readonly queue: Schema.Literal<string>;
|
|
207
|
+
readonly sourceId: Schema.OptionFromNullOr<Schema.String>;
|
|
208
|
+
readonly sourceOutput: Schema.Unknown;
|
|
209
209
|
}>[]>>;
|
|
210
210
|
readonly next: Schema.OptionFromNullOr<Schema.String>;
|
|
211
|
-
}>, Schema.Union<readonly [Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.health", Schema.Void, Schema.Struct<{
|
|
212
|
-
readonly activeTotal: Schema.Number;
|
|
213
|
-
readonly deadLetteredTotal: Schema.Number;
|
|
214
|
-
readonly failedTotal: Schema.Number;
|
|
215
|
-
readonly jobs: Schema.$Array<Schema.Struct<{
|
|
216
|
-
readonly activeCount: Schema.Number;
|
|
217
|
-
readonly deadLetteredCount: Schema.Number;
|
|
218
|
-
readonly failedCount: Schema.Number;
|
|
219
|
-
readonly name: Schema.String;
|
|
220
|
-
readonly queuedCount: Schema.Number;
|
|
221
|
-
readonly readyCount: Schema.Number;
|
|
222
|
-
}>>;
|
|
223
|
-
readonly queuedTotal: Schema.Number;
|
|
224
|
-
readonly readyTotal: Schema.Number;
|
|
225
211
|
}>, Schema.Union<readonly [Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.job", Schema.Struct<{
|
|
226
212
|
id: Schema.String;
|
|
227
213
|
queue: Schema.String;
|
|
@@ -240,7 +226,21 @@ export declare function jobsPageWithRetry<const TQueues extends readonly JobsEnt
|
|
|
240
226
|
}>[]>>, Schema.Union<readonly [Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.retry", Schema.Struct<{
|
|
241
227
|
id: Schema.String;
|
|
242
228
|
queue: Schema.String;
|
|
243
|
-
}>, Schema.Void, Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered | typeof JobsNotFailed)[]>, typeof JobsPermission, never
|
|
229
|
+
}>, Schema.Void, Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered | typeof JobsNotFailed)[]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.health", Schema.Void, Schema.Struct<{
|
|
230
|
+
readonly activeTotal: Schema.Number;
|
|
231
|
+
readonly deadLetteredTotal: Schema.Number;
|
|
232
|
+
readonly failedTotal: Schema.Number;
|
|
233
|
+
readonly jobs: Schema.$Array<Schema.Struct<{
|
|
234
|
+
readonly activeCount: Schema.Number;
|
|
235
|
+
readonly deadLetteredCount: Schema.Number;
|
|
236
|
+
readonly failedCount: Schema.Number;
|
|
237
|
+
readonly name: Schema.String;
|
|
238
|
+
readonly queuedCount: Schema.Number;
|
|
239
|
+
readonly readyCount: Schema.Number;
|
|
240
|
+
}>>;
|
|
241
|
+
readonly queuedTotal: Schema.Number;
|
|
242
|
+
readonly readyTotal: Schema.Number;
|
|
243
|
+
}>, Schema.Union<readonly [Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never>, readonly [], undefined>;
|
|
244
244
|
} & {
|
|
245
245
|
queues: TQueues;
|
|
246
246
|
};
|
package/dist/users/page.d.ts
CHANGED
|
@@ -66,10 +66,7 @@ export declare function usersPage<const TRole extends string>(access: Pick<Retur
|
|
|
66
66
|
readonly queryIndexes: Schema.optional<Schema.$Array<Schema.Number>>;
|
|
67
67
|
}>, Schema.Struct<{
|
|
68
68
|
readonly _tag: Schema.Literal<"Resync">;
|
|
69
|
-
}>]>, Schema.Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>>, Schema.Never, typeof UsersPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.users.
|
|
70
|
-
role: Schema.Literals<TRole[]>;
|
|
71
|
-
userId: Schema.String;
|
|
72
|
-
}>, 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<{
|
|
69
|
+
}>]>, Schema.Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>>, Schema.Never, typeof UsersPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.users.list", Schema.Struct<{
|
|
73
70
|
readonly cursor: Schema.optionalKey<Schema.String>;
|
|
74
71
|
readonly limit: Schema.Number;
|
|
75
72
|
}>, Schema.Struct<{
|
|
@@ -82,6 +79,9 @@ export declare function usersPage<const TRole extends string>(access: Pick<Retur
|
|
|
82
79
|
readonly role: Schema.String;
|
|
83
80
|
}>>;
|
|
84
81
|
readonly canChangeRoles: Schema.Boolean;
|
|
85
|
-
}>, Schema.Union<readonly [Schema.Union<readonly (typeof Forbidden | typeof AuthUnavailable)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof UsersPermission, never
|
|
82
|
+
}>, 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<{
|
|
83
|
+
role: Schema.Literals<TRole[]>;
|
|
84
|
+
userId: Schema.String;
|
|
85
|
+
}>, Schema.Void, Schema.Union<readonly (typeof NotFound | typeof Forbidden | typeof AuthUnavailable | typeof LastRoleAssigner)[]>, typeof UsersPermission, never>, readonly [], undefined>;
|
|
86
86
|
};
|
|
87
87
|
//# sourceMappingURL=page.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shivaedev/admin",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
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": {
|
|
@@ -43,19 +43,19 @@
|
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@shivaedev/access": "0.1.1",
|
|
45
45
|
"@shivaedev/changes": "0.5.0",
|
|
46
|
-
"@shivaedev/contract": "0.
|
|
46
|
+
"@shivaedev/contract": "0.20.0",
|
|
47
47
|
"@shivaedev/errors": "0.1.0",
|
|
48
|
-
"@shivaedev/identity": "0.3.
|
|
48
|
+
"@shivaedev/identity": "0.3.2",
|
|
49
49
|
"@shivaedev/jobs": "0.22.0",
|
|
50
|
-
"@shivaedev/react": "0.
|
|
50
|
+
"@shivaedev/react": "0.22.0",
|
|
51
51
|
"@shivaedev/sql": "0.24.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@effect/atom-react": "4.0.5",
|
|
55
|
-
"@shivaedev/quality": "0.
|
|
56
|
-
"@shivaedev/server": "0.
|
|
55
|
+
"@shivaedev/quality": "0.44.1",
|
|
56
|
+
"@shivaedev/server": "0.4.0",
|
|
57
57
|
"@shivaedev/test-sql": "0.10.2",
|
|
58
|
-
"@shivaedev/test-story": "0.
|
|
58
|
+
"@shivaedev/test-story": "0.23.0",
|
|
59
59
|
"@types/node": "24.19.2",
|
|
60
60
|
"@types/react": "19.3.0",
|
|
61
61
|
"@types/react-dom": "19.3.0",
|
|
@@ -21,7 +21,7 @@ function UserRole<TRole extends string>({
|
|
|
21
21
|
return canChangeRoles ? (
|
|
22
22
|
<select
|
|
23
23
|
aria-label={`Role for ${user.email}`}
|
|
24
|
-
className="rounded-md border
|
|
24
|
+
className="bg-background rounded-md border p-2"
|
|
25
25
|
disabled={pending}
|
|
26
26
|
onChange={(event) => {
|
|
27
27
|
const role = roles.find((candidate) => candidate === event.target.value);
|
|
@@ -54,7 +54,7 @@ function UserRow<TRole extends string>({
|
|
|
54
54
|
<td className="p-3">
|
|
55
55
|
<UserRole {...controls} canChangeRoles={canChangeRoles} user={user} />
|
|
56
56
|
</td>
|
|
57
|
-
<td className="whitespace-nowrap
|
|
57
|
+
<td className="p-3 whitespace-nowrap">
|
|
58
58
|
<time dateTime={DateTime.formatIso(user.createdAt)}>{DateTime.formatIso(user.createdAt)}</time>
|
|
59
59
|
</td>
|
|
60
60
|
</tr>
|
|
@@ -90,7 +90,7 @@ function UserHeaders() {
|
|
|
90
90
|
return (
|
|
91
91
|
<tr>
|
|
92
92
|
{["Name", "Email", "Role", "Signed up"].map((label) => (
|
|
93
|
-
<th className="whitespace-nowrap
|
|
93
|
+
<th className="p-3 whitespace-nowrap" key={label} scope="col">
|
|
94
94
|
{label}
|
|
95
95
|
</th>
|
|
96
96
|
))}
|