@shivaedev/admin 0.7.0 → 0.8.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.
- package/README.md +44 -30
- package/dist/client/UsersTable.js +3 -3
- package/dist/jobs/entry.d.ts +12 -0
- package/dist/jobs/entry.d.ts.map +1 -0
- package/dist/jobs/entry.js +5 -0
- package/dist/jobs/entry.js.map +1 -0
- package/dist/jobs/keys.d.ts +5 -5
- package/dist/jobs/keys.js +1 -1
- package/dist/jobs/keys.js.map +1 -1
- package/dist/jobs/page.d.ts +20 -14
- package/dist/jobs/page.d.ts.map +1 -1
- package/dist/jobs/page.js +17 -4
- package/dist/jobs/page.js.map +1 -1
- package/dist/jobs/retryPage.d.ts +23 -17
- package/dist/jobs/retryPage.d.ts.map +1 -1
- package/dist/jobs/retryPage.js.map +1 -1
- package/dist/jobs/schemas.d.ts +2 -2
- package/dist/jobs/schemas.d.ts.map +1 -1
- package/dist/jobs/schemas.js.map +1 -1
- package/dist/permissions.d.ts +2 -2
- package/dist/server/jobsHandlers.d.ts +8 -7
- package/dist/server/jobsHandlers.d.ts.map +1 -1
- package/dist/server/jobsHandlers.js +2 -1
- package/dist/server/jobsHandlers.js.map +1 -1
- package/dist/server/jobsHandlersWithRetry.d.ts +2 -2
- package/dist/server/jobsHandlersWithRetry.d.ts.map +1 -1
- package/dist/server/jobsHandlersWithRetry.js +5 -2
- package/dist/server/jobsHandlersWithRetry.js.map +1 -1
- package/dist/users/page.d.ts +8 -2
- package/dist/users/page.d.ts.map +1 -1
- package/dist/users/page.js +5 -2
- package/dist/users/page.js.map +1 -1
- package/package.json +12 -11
- package/src/client/UsersTable.tsx +3 -3
- package/src/jobs/entry.ts +15 -0
- package/src/jobs/keys.ts +1 -1
- package/src/jobs/page.ts +19 -6
- package/src/jobs/retryPage.ts +3 -2
- package/src/jobs/schemas.ts +2 -2
- package/src/server/jobsHandlers.ts +8 -7
- package/src/server/jobsHandlersWithRetry.ts +8 -5
- package/src/users/page.ts +5 -2
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,17 +92,19 @@ 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
|
|
|
95
99
|
The queries are `admin.jobs.health`, `admin.jobs.counts`, `admin.jobs.failed`, `admin.jobs.deadLettered` and `admin.jobs.job`. Counts take `{ queue }`; listings take `{ queue, limit, cursor? }` and return `{ jobs, next }`, where `next` is an `Option<string>`. Job lookup takes `{ queue, id }` and returns `Option<Job>`. Each job carries its queue, decoded payload, state, attempt and retry counts, output and timestamps. Dead-letter listings also carry `sourceId` and `sourceOutput`. Timestamps use UTC `DateTime` values; the RPC encodes timestamps as strings and Options as nullable values. The queue's original codec encodes and decodes its payload across RPC, preserving its service requirements.
|
|
96
100
|
|
|
101
|
+
Schedule definitions from `defineSchedule` can be passed beside queues. A browser declaration can share just `{ _tag: "ScheduleDefinition", name }`; scheduled runs use a null payload schema for failed and dead-letter listings and job lookup. Calling `jobsPage()` with no arguments registers the same read-only page and serves health with no jobs and zero totals.
|
|
102
|
+
|
|
97
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.
|
|
98
104
|
|
|
99
|
-
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.
|
|
100
106
|
|
|
101
|
-
|
|
107
|
+
#### Declare retry explicitly
|
|
102
108
|
|
|
103
109
|
Use `jobsPageWithRetry` and `jobsHandlersWithRetry` when administrators should be able to retry failed original jobs:
|
|
104
110
|
|
|
@@ -109,15 +115,15 @@ import { jobsHandlersWithRetry } from "@shivaedev/admin/server/jobsHandlersWithR
|
|
|
109
115
|
const JobsPage = jobsPageWithRetry({ name: "mail", schema: MailPayload });
|
|
110
116
|
const Admin = adminRegistry(JobsPage);
|
|
111
117
|
const registration = registerAdmin(Admin, {
|
|
112
|
-
|
|
118
|
+
jobs: jobsHandlersWithRetry(JobsPage, JobsService),
|
|
113
119
|
});
|
|
114
120
|
```
|
|
115
121
|
|
|
116
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.
|
|
117
123
|
|
|
118
|
-
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.
|
|
119
125
|
|
|
120
|
-
|
|
126
|
+
### Built-in Users page
|
|
121
127
|
|
|
122
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.
|
|
123
129
|
|
|
@@ -140,8 +146,16 @@ const changeRole = Client.runtime.fn(users.changeRole.run);
|
|
|
140
146
|
|
|
141
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`.
|
|
142
148
|
|
|
143
|
-
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.
|
|
144
158
|
|
|
145
|
-
|
|
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.
|
|
146
160
|
|
|
147
|
-
|
|
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
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import type { JobsQueue } from "./schemas.ts";
|
|
3
|
+
export type JobsEntry = JobsQueue | {
|
|
4
|
+
readonly _tag: "ScheduleDefinition";
|
|
5
|
+
readonly name: string;
|
|
6
|
+
};
|
|
7
|
+
export type JobsPayload<TEntry extends JobsEntry> = [TEntry] extends [never] ? typeof Schema.Never : TEntry extends JobsQueue ? TEntry["schema"] : typeof Schema.Null;
|
|
8
|
+
export declare function jobsQueue<TEntry extends JobsEntry>(entry: TEntry): {
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly schema: JobsPayload<TEntry>;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=entry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../../src/jobs/entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnG,MAAM,MAAM,WAAW,CAAC,MAAM,SAAS,SAAS,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,GACzE,OAAO,MAAM,CAAC,KAAK,GACnB,MAAM,SAAS,SAAS,GACvB,MAAM,CAAC,QAAQ,CAAC,GAChB,OAAO,MAAM,CAAC,IAAI,CAAC;AAEvB,wBAAgB,SAAS,CAAC,MAAM,SAAS,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry.js","sourceRoot":"","sources":["../../src/jobs/entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAYhC,MAAM,UAAU,SAAS,CAAC,KAAgB;IACzC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;AACrF,CAAC"}
|
package/dist/jobs/keys.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export declare const jobsKeys: {
|
|
2
|
-
counts: import("@shivaedev/
|
|
3
|
-
deadLettered: import("@shivaedev/
|
|
4
|
-
failed: import("@shivaedev/
|
|
5
|
-
health: import("@shivaedev/
|
|
6
|
-
job: (queue: string) => import("@shivaedev/
|
|
2
|
+
counts: import("@shivaedev/changes/keys.ts").Collection<"admin.jobs.counts", string, Record<never, never>>;
|
|
3
|
+
deadLettered: import("@shivaedev/changes/keys.ts").Collection<"admin.jobs.deadLettered", string, Record<never, never>>;
|
|
4
|
+
failed: import("@shivaedev/changes/keys.ts").Collection<"admin.jobs.failed", string, Record<never, never>>;
|
|
5
|
+
health: import("@shivaedev/changes/keys.ts").Collection<"admin.jobs.health", string, Record<never, never>>;
|
|
6
|
+
job: (queue: string) => import("@shivaedev/changes/keys.ts").Collection<`admin.jobs.job.${string}`, string, Record<never, never>>;
|
|
7
7
|
};
|
|
8
8
|
//# sourceMappingURL=keys.d.ts.map
|
package/dist/jobs/keys.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
-
import { collection } from "@shivaedev/
|
|
2
|
+
import { collection } from "@shivaedev/changes/keys.ts";
|
|
3
3
|
export const jobsKeys = {
|
|
4
4
|
counts: collection("admin.jobs.counts", Schema.String),
|
|
5
5
|
deadLettered: collection("admin.jobs.deadLettered", Schema.String),
|
package/dist/jobs/keys.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../src/jobs/keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../src/jobs/keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAExD,MAAM,CAAC,MAAM,QAAQ,GAAG;IACvB,MAAM,EAAE,UAAU,CAAC,mBAAmB,EAAE,MAAM,CAAC,MAAM,CAAC;IACtD,YAAY,EAAE,UAAU,CAAC,yBAAyB,EAAE,MAAM,CAAC,MAAM,CAAC;IAClE,MAAM,EAAE,UAAU,CAAC,mBAAmB,EAAE,MAAM,CAAC,MAAM,CAAC;IACtD,MAAM,EAAE,UAAU,CAAC,mBAAmB,EAAE,MAAM,CAAC,MAAM,CAAC;IACtD,GAAG,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,UAAU,CAAC,kBAAkB,KAAK,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC;CAC5E,CAAC"}
|
package/dist/jobs/page.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
import { JobsPermission } from "#permissions.ts";
|
|
3
|
-
import { type
|
|
4
|
-
export declare function jobsPage<const TQueues extends readonly
|
|
3
|
+
import { type JobsEntry, type JobsPayload } from "./entry.ts";
|
|
4
|
+
export declare function jobsPage<const TQueues extends readonly JobsEntry[]>(...queues: TQueues): import("#page.ts").AdminPage & {
|
|
5
5
|
readonly id: "jobs";
|
|
6
6
|
readonly contract: import("@shivaedev/contract/contract.ts").Contract<"admin.jobs", readonly [NoInfer<import("@shivaedev/contract/operation.ts").Query<"health", Schema.Void, Schema.Struct<{
|
|
7
7
|
readonly activeTotal: Schema.Number;
|
|
@@ -47,7 +47,7 @@ export declare function jobsPage<const TQueues extends readonly JobsQueue[]>(...
|
|
|
47
47
|
readonly retryLimit: Schema.Number;
|
|
48
48
|
readonly startedOn: Schema.OptionFromNullOr<Schema.DateTimeUtcFromString>;
|
|
49
49
|
readonly state: Schema.Literals<readonly ["created", "retry", "active", "completed", "cancelled", "failed"]>;
|
|
50
|
-
readonly data: TQueues[number]
|
|
50
|
+
readonly data: JobsPayload<TQueues[number]>;
|
|
51
51
|
readonly queue: Schema.Literal<string>;
|
|
52
52
|
}>[]>>;
|
|
53
53
|
readonly next: Schema.OptionFromNullOr<Schema.String>;
|
|
@@ -70,7 +70,7 @@ export declare function jobsPage<const TQueues extends readonly JobsQueue[]>(...
|
|
|
70
70
|
readonly retryLimit: Schema.Number;
|
|
71
71
|
readonly startedOn: Schema.OptionFromNullOr<Schema.DateTimeUtcFromString>;
|
|
72
72
|
readonly state: Schema.Literals<readonly ["created", "retry", "active", "completed", "cancelled", "failed"]>;
|
|
73
|
-
readonly data: TQueues[number]
|
|
73
|
+
readonly data: JobsPayload<TQueues[number]>;
|
|
74
74
|
readonly queue: Schema.Literal<string>;
|
|
75
75
|
readonly sourceId: Schema.OptionFromNullOr<Schema.String>;
|
|
76
76
|
readonly sourceOutput: Schema.Unknown;
|
|
@@ -93,7 +93,7 @@ export declare function jobsPage<const TQueues extends readonly JobsQueue[]>(...
|
|
|
93
93
|
readonly retryLimit: Schema.Number;
|
|
94
94
|
readonly startedOn: Schema.OptionFromNullOr<Schema.DateTimeUtcFromString>;
|
|
95
95
|
readonly state: Schema.Literals<readonly ["created", "retry", "active", "completed", "cancelled", "failed"]>;
|
|
96
|
-
readonly data: TQueues[number]
|
|
96
|
+
readonly data: JobsPayload<TQueues[number]>;
|
|
97
97
|
readonly queue: Schema.Literal<string>;
|
|
98
98
|
}>[]>>, {
|
|
99
99
|
JobsPayloadInvalid: typeof import("./schemas.ts").JobsPayloadInvalid;
|
|
@@ -112,9 +112,9 @@ export declare function jobsPage<const TQueues extends readonly JobsQueue[]>(...
|
|
|
112
112
|
readonly retryLimit: Schema.Number;
|
|
113
113
|
readonly startedOn: Schema.OptionFromNullOr<Schema.DateTimeUtcFromString>;
|
|
114
114
|
readonly state: Schema.Literals<readonly ["created", "retry", "active", "completed", "cancelled", "failed"]>;
|
|
115
|
-
readonly data: TQueues[number]
|
|
115
|
+
readonly data: JobsPayload<TQueues[number]>;
|
|
116
116
|
readonly queue: Schema.Literal<string>;
|
|
117
|
-
}>[]>>, Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.$changes", Schema.Struct<{
|
|
117
|
+
}>[]>>, 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.$changes", Schema.Struct<{
|
|
118
118
|
queries: Schema.$Array<Schema.Union<readonly (Schema.Struct<{
|
|
119
119
|
query: Schema.Literal<"counts">;
|
|
120
120
|
payload: Schema.Struct<{
|
|
@@ -147,6 +147,11 @@ export declare function jobsPage<const TQueues extends readonly JobsQueue[]>(...
|
|
|
147
147
|
}>, import("effect/rpc/RpcSchema").Stream<Schema.Union<readonly [Schema.Struct<{
|
|
148
148
|
readonly _tag: Schema.Literal<"Changed">;
|
|
149
149
|
readonly keys: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
150
|
+
readonly _tag: Schema.Literal<"Bucket">;
|
|
151
|
+
readonly collection: Schema.String;
|
|
152
|
+
readonly field: Schema.String;
|
|
153
|
+
readonly value: Schema.Union<readonly [Schema.String, Schema.Number]>;
|
|
154
|
+
}>, Schema.Struct<{
|
|
150
155
|
readonly _tag: Schema.Literal<"List">;
|
|
151
156
|
readonly collection: Schema.String;
|
|
152
157
|
}>, Schema.Struct<{
|
|
@@ -154,16 +159,17 @@ export declare function jobsPage<const TQueues extends readonly JobsQueue[]>(...
|
|
|
154
159
|
readonly collection: Schema.String;
|
|
155
160
|
readonly id: Schema.Union<readonly [Schema.String, Schema.Number]>;
|
|
156
161
|
}>]>>;
|
|
162
|
+
readonly queryIndexes: Schema.optional<Schema.$Array<Schema.Number>>;
|
|
157
163
|
}>, Schema.Struct<{
|
|
158
164
|
readonly _tag: Schema.Literal<"Resync">;
|
|
159
|
-
}>]>, Schema.
|
|
165
|
+
}>]>, Schema.Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>>, Schema.Never, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.counts", Schema.Struct<{
|
|
160
166
|
queue: Schema.String;
|
|
161
167
|
}>, Schema.Struct<{
|
|
162
168
|
readonly activeCount: Schema.Number;
|
|
163
169
|
readonly failedCount: Schema.Number;
|
|
164
170
|
readonly queuedCount: Schema.Number;
|
|
165
171
|
readonly totalCount: Schema.Number;
|
|
166
|
-
}>, Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.health", Schema.Void, Schema.Struct<{
|
|
172
|
+
}>, 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<{
|
|
167
173
|
readonly activeTotal: Schema.Number;
|
|
168
174
|
readonly deadLetteredTotal: Schema.Number;
|
|
169
175
|
readonly failedTotal: Schema.Number;
|
|
@@ -177,7 +183,7 @@ export declare function jobsPage<const TQueues extends readonly JobsQueue[]>(...
|
|
|
177
183
|
}>>;
|
|
178
184
|
readonly queuedTotal: Schema.Number;
|
|
179
185
|
readonly readyTotal: Schema.Number;
|
|
180
|
-
}>, Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.failed", Schema.Struct<{
|
|
186
|
+
}>, 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<{
|
|
181
187
|
cursor: Schema.optionalKey<Schema.String>;
|
|
182
188
|
limit: Schema.Number;
|
|
183
189
|
queue: Schema.String;
|
|
@@ -192,11 +198,11 @@ export declare function jobsPage<const TQueues extends readonly JobsQueue[]>(...
|
|
|
192
198
|
readonly retryLimit: Schema.Number;
|
|
193
199
|
readonly startedOn: Schema.OptionFromNullOr<Schema.DateTimeUtcFromString>;
|
|
194
200
|
readonly state: Schema.Literals<readonly ["created", "retry", "active", "completed", "cancelled", "failed"]>;
|
|
195
|
-
readonly data: TQueues[number]
|
|
201
|
+
readonly data: JobsPayload<TQueues[number]>;
|
|
196
202
|
readonly queue: Schema.Literal<string>;
|
|
197
203
|
}>[]>>;
|
|
198
204
|
readonly next: Schema.OptionFromNullOr<Schema.String>;
|
|
199
|
-
}>, Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.deadLettered", Schema.Struct<{
|
|
205
|
+
}>, 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<{
|
|
200
206
|
cursor: Schema.optionalKey<Schema.String>;
|
|
201
207
|
limit: Schema.Number;
|
|
202
208
|
queue: Schema.String;
|
|
@@ -211,13 +217,13 @@ export declare function jobsPage<const TQueues extends readonly JobsQueue[]>(...
|
|
|
211
217
|
readonly retryLimit: Schema.Number;
|
|
212
218
|
readonly startedOn: Schema.OptionFromNullOr<Schema.DateTimeUtcFromString>;
|
|
213
219
|
readonly state: Schema.Literals<readonly ["created", "retry", "active", "completed", "cancelled", "failed"]>;
|
|
214
|
-
readonly data: TQueues[number]
|
|
220
|
+
readonly data: JobsPayload<TQueues[number]>;
|
|
215
221
|
readonly queue: Schema.Literal<string>;
|
|
216
222
|
readonly sourceId: Schema.OptionFromNullOr<Schema.String>;
|
|
217
223
|
readonly sourceOutput: Schema.Unknown;
|
|
218
224
|
}>[]>>;
|
|
219
225
|
readonly next: Schema.OptionFromNullOr<Schema.String>;
|
|
220
|
-
}>, Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, 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>;
|
|
221
227
|
} & {
|
|
222
228
|
queues: TQueues;
|
|
223
229
|
};
|
package/dist/jobs/page.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../src/jobs/page.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../src/jobs/page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AAMxC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,WAAW,EAAa,MAAM,YAAY,CAAC;AAIzE,wBAAgB,QAAQ,CAAC,KAAK,CAAC,OAAO,SAAS,SAAS,SAAS,EAAE,EAAE,GAAG,MAAM,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgDtF"}
|
package/dist/jobs/page.js
CHANGED
|
@@ -1,37 +1,50 @@
|
|
|
1
|
-
import { Schema } from "effect";
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
2
|
import { contract } from "@shivaedev/contract/contract.ts";
|
|
3
3
|
import { query } from "@shivaedev/contract/operation.ts";
|
|
4
|
+
import { SessionUser } from "@shivaedev/identity/identity.ts";
|
|
5
|
+
import { hasPermission } from "@shivaedev/identity/permission.ts";
|
|
4
6
|
import { adminPage } from "#page.ts";
|
|
5
7
|
import { JobsPermission } from "#permissions.ts";
|
|
8
|
+
import { jobsQueue } from "./entry.js";
|
|
6
9
|
import { jobsKeys } from "./keys.js";
|
|
7
10
|
import { deadLetteredSchema, JobsFailures, JobsHealth, jobPage, jobSchema, PageFields, QueueCounts } from "./schemas.js";
|
|
8
11
|
export function jobsPage(...queues) {
|
|
9
|
-
const
|
|
10
|
-
const
|
|
12
|
+
const definitions = queues.map((queue) => jobsQueue(queue));
|
|
13
|
+
const Job = Schema.Union(definitions.map((queue) => jobSchema(queue)));
|
|
14
|
+
const DeadLettered = Schema.Union(definitions.map((queue) => deadLetteredSchema(queue)));
|
|
11
15
|
const page = adminPage({
|
|
12
16
|
contract: contract("admin.jobs", {
|
|
13
17
|
queries: [
|
|
14
|
-
query("health", {
|
|
18
|
+
query("health", {
|
|
19
|
+
readPolicy: () => Effect.map(SessionUser, (user) => hasPermission(user, JobsPermission.permission)),
|
|
20
|
+
reads: () => [jobsKeys.health.list],
|
|
21
|
+
rejections: JobsFailures,
|
|
22
|
+
success: JobsHealth,
|
|
23
|
+
}),
|
|
15
24
|
query("counts", {
|
|
16
25
|
payload: { queue: Schema.String },
|
|
26
|
+
readPolicy: () => Effect.map(SessionUser, (user) => hasPermission(user, JobsPermission.permission)),
|
|
17
27
|
reads: ({ queue }) => [jobsKeys.counts.item(queue)],
|
|
18
28
|
rejections: JobsFailures,
|
|
19
29
|
success: QueueCounts,
|
|
20
30
|
}),
|
|
21
31
|
query("failed", {
|
|
22
32
|
payload: { ...PageFields, queue: Schema.String },
|
|
33
|
+
readPolicy: () => Effect.map(SessionUser, (user) => hasPermission(user, JobsPermission.permission)),
|
|
23
34
|
reads: ({ queue }) => [jobsKeys.failed.item(queue)],
|
|
24
35
|
rejections: JobsFailures,
|
|
25
36
|
success: jobPage(Job),
|
|
26
37
|
}),
|
|
27
38
|
query("deadLettered", {
|
|
28
39
|
payload: { ...PageFields, queue: Schema.String },
|
|
40
|
+
readPolicy: () => Effect.map(SessionUser, (user) => hasPermission(user, JobsPermission.permission)),
|
|
29
41
|
reads: ({ queue }) => [jobsKeys.deadLettered.item(queue)],
|
|
30
42
|
rejections: JobsFailures,
|
|
31
43
|
success: jobPage(DeadLettered),
|
|
32
44
|
}),
|
|
33
45
|
query("job", {
|
|
34
46
|
payload: { id: Schema.String, queue: Schema.String },
|
|
47
|
+
readPolicy: () => Effect.map(SessionUser, (user) => hasPermission(user, JobsPermission.permission)),
|
|
35
48
|
reads: ({ queue, id }) => [jobsKeys.job(queue).item(id)],
|
|
36
49
|
rejections: JobsFailures,
|
|
37
50
|
success: Schema.OptionFromNullOr(Job),
|
package/dist/jobs/page.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page.js","sourceRoot":"","sources":["../../src/jobs/page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"page.js","sourceRoot":"","sources":["../../src/jobs/page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,QAAQ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import type { JobsEntry } from "./entry.ts";
|
|
4
4
|
declare const JobsNotFailed_base: Schema.Class<JobsNotFailed, Schema.TaggedStruct<"JobsNotFailed", {
|
|
5
5
|
readonly id: Schema.String;
|
|
6
6
|
readonly queue: Schema.String;
|
|
7
7
|
}>, import("effect/Cause").YieldableError>;
|
|
8
8
|
export declare class JobsNotFailed extends JobsNotFailed_base {
|
|
9
9
|
}
|
|
10
|
-
export declare function jobsPageWithRetry<const TQueues extends readonly
|
|
10
|
+
export declare function jobsPageWithRetry<const TQueues extends readonly JobsEntry[]>(...queues: TQueues): import("#page.ts").AdminPage & {
|
|
11
11
|
readonly id: "jobs";
|
|
12
12
|
readonly contract: import("@shivaedev/contract/contract.ts").Contract<"admin.jobs", readonly [NoInfer<import("@shivaedev/contract/operation.ts").Query<"health", Schema.Void, Schema.Struct<{
|
|
13
13
|
readonly activeTotal: Schema.Number;
|
|
@@ -53,7 +53,7 @@ export declare function jobsPageWithRetry<const TQueues extends readonly JobsQue
|
|
|
53
53
|
readonly retryLimit: Schema.Number;
|
|
54
54
|
readonly startedOn: Schema.OptionFromNullOr<Schema.DateTimeUtcFromString>;
|
|
55
55
|
readonly state: Schema.Literals<readonly ["created", "retry", "active", "completed", "cancelled", "failed"]>;
|
|
56
|
-
readonly data: [...TQueues][number]
|
|
56
|
+
readonly data: import("./entry.ts").JobsPayload<[...TQueues][number]>;
|
|
57
57
|
readonly queue: Schema.Literal<string>;
|
|
58
58
|
}>[]>>;
|
|
59
59
|
readonly next: Schema.OptionFromNullOr<Schema.String>;
|
|
@@ -76,7 +76,7 @@ export declare function jobsPageWithRetry<const TQueues extends readonly JobsQue
|
|
|
76
76
|
readonly retryLimit: Schema.Number;
|
|
77
77
|
readonly startedOn: Schema.OptionFromNullOr<Schema.DateTimeUtcFromString>;
|
|
78
78
|
readonly state: Schema.Literals<readonly ["created", "retry", "active", "completed", "cancelled", "failed"]>;
|
|
79
|
-
readonly data: [...TQueues][number]
|
|
79
|
+
readonly data: import("./entry.ts").JobsPayload<[...TQueues][number]>;
|
|
80
80
|
readonly queue: Schema.Literal<string>;
|
|
81
81
|
readonly sourceId: Schema.OptionFromNullOr<Schema.String>;
|
|
82
82
|
readonly sourceOutput: Schema.Unknown;
|
|
@@ -99,7 +99,7 @@ export declare function jobsPageWithRetry<const TQueues extends readonly JobsQue
|
|
|
99
99
|
readonly retryLimit: Schema.Number;
|
|
100
100
|
readonly startedOn: Schema.OptionFromNullOr<Schema.DateTimeUtcFromString>;
|
|
101
101
|
readonly state: Schema.Literals<readonly ["created", "retry", "active", "completed", "cancelled", "failed"]>;
|
|
102
|
-
readonly data: [...TQueues][number]
|
|
102
|
+
readonly data: import("./entry.ts").JobsPayload<[...TQueues][number]>;
|
|
103
103
|
readonly queue: Schema.Literal<string>;
|
|
104
104
|
}>[]>>, {
|
|
105
105
|
JobsPayloadInvalid: typeof import("./schemas.ts").JobsPayloadInvalid;
|
|
@@ -146,6 +146,11 @@ export declare function jobsPageWithRetry<const TQueues extends readonly JobsQue
|
|
|
146
146
|
}>, import("effect/rpc/RpcSchema").Stream<Schema.Union<readonly [Schema.Struct<{
|
|
147
147
|
readonly _tag: Schema.Literal<"Changed">;
|
|
148
148
|
readonly keys: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
149
|
+
readonly _tag: Schema.Literal<"Bucket">;
|
|
150
|
+
readonly collection: Schema.String;
|
|
151
|
+
readonly field: Schema.String;
|
|
152
|
+
readonly value: Schema.Union<readonly [Schema.String, Schema.Number]>;
|
|
153
|
+
}>, Schema.Struct<{
|
|
149
154
|
readonly _tag: Schema.Literal<"List">;
|
|
150
155
|
readonly collection: Schema.String;
|
|
151
156
|
}>, Schema.Struct<{
|
|
@@ -153,16 +158,20 @@ export declare function jobsPageWithRetry<const TQueues extends readonly JobsQue
|
|
|
153
158
|
readonly collection: Schema.String;
|
|
154
159
|
readonly id: Schema.Union<readonly [Schema.String, Schema.Number]>;
|
|
155
160
|
}>]>>;
|
|
161
|
+
readonly queryIndexes: Schema.optional<Schema.$Array<Schema.Number>>;
|
|
156
162
|
}>, Schema.Struct<{
|
|
157
163
|
readonly _tag: Schema.Literal<"Resync">;
|
|
158
|
-
}>]>, Schema.
|
|
164
|
+
}>]>, Schema.Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>>, Schema.Never, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.retry", Schema.Struct<{
|
|
165
|
+
id: Schema.String;
|
|
166
|
+
queue: Schema.String;
|
|
167
|
+
}>, 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.counts", Schema.Struct<{
|
|
159
168
|
queue: Schema.String;
|
|
160
169
|
}>, Schema.Struct<{
|
|
161
170
|
readonly activeCount: Schema.Number;
|
|
162
171
|
readonly failedCount: Schema.Number;
|
|
163
172
|
readonly queuedCount: Schema.Number;
|
|
164
173
|
readonly totalCount: Schema.Number;
|
|
165
|
-
}>, Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.deadLettered", Schema.Struct<{
|
|
174
|
+
}>, 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<{
|
|
166
175
|
cursor: Schema.optionalKey<Schema.String>;
|
|
167
176
|
limit: Schema.Number;
|
|
168
177
|
queue: Schema.String;
|
|
@@ -177,13 +186,13 @@ export declare function jobsPageWithRetry<const TQueues extends readonly JobsQue
|
|
|
177
186
|
readonly retryLimit: Schema.Number;
|
|
178
187
|
readonly startedOn: Schema.OptionFromNullOr<Schema.DateTimeUtcFromString>;
|
|
179
188
|
readonly state: Schema.Literals<readonly ["created", "retry", "active", "completed", "cancelled", "failed"]>;
|
|
180
|
-
readonly data: [...TQueues][number]
|
|
189
|
+
readonly data: import("./entry.ts").JobsPayload<[...TQueues][number]>;
|
|
181
190
|
readonly queue: Schema.Literal<string>;
|
|
182
191
|
readonly sourceId: Schema.OptionFromNullOr<Schema.String>;
|
|
183
192
|
readonly sourceOutput: Schema.Unknown;
|
|
184
193
|
}>[]>>;
|
|
185
194
|
readonly next: Schema.OptionFromNullOr<Schema.String>;
|
|
186
|
-
}>, Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.failed", Schema.Struct<{
|
|
195
|
+
}>, 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<{
|
|
187
196
|
cursor: Schema.optionalKey<Schema.String>;
|
|
188
197
|
limit: Schema.Number;
|
|
189
198
|
queue: Schema.String;
|
|
@@ -198,11 +207,11 @@ export declare function jobsPageWithRetry<const TQueues extends readonly JobsQue
|
|
|
198
207
|
readonly retryLimit: Schema.Number;
|
|
199
208
|
readonly startedOn: Schema.OptionFromNullOr<Schema.DateTimeUtcFromString>;
|
|
200
209
|
readonly state: Schema.Literals<readonly ["created", "retry", "active", "completed", "cancelled", "failed"]>;
|
|
201
|
-
readonly data: [...TQueues][number]
|
|
210
|
+
readonly data: import("./entry.ts").JobsPayload<[...TQueues][number]>;
|
|
202
211
|
readonly queue: Schema.Literal<string>;
|
|
203
212
|
}>[]>>;
|
|
204
213
|
readonly next: Schema.OptionFromNullOr<Schema.String>;
|
|
205
|
-
}>, Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.health", Schema.Void, Schema.Struct<{
|
|
214
|
+
}>, 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<{
|
|
206
215
|
readonly activeTotal: Schema.Number;
|
|
207
216
|
readonly deadLetteredTotal: Schema.Number;
|
|
208
217
|
readonly failedTotal: Schema.Number;
|
|
@@ -216,7 +225,7 @@ export declare function jobsPageWithRetry<const TQueues extends readonly JobsQue
|
|
|
216
225
|
}>>;
|
|
217
226
|
readonly queuedTotal: Schema.Number;
|
|
218
227
|
readonly readyTotal: Schema.Number;
|
|
219
|
-
}>, Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.job", Schema.Struct<{
|
|
228
|
+
}>, 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<{
|
|
220
229
|
id: Schema.String;
|
|
221
230
|
queue: Schema.String;
|
|
222
231
|
}>, Schema.OptionFromNullOr<Schema.Union<Schema.Struct<{
|
|
@@ -229,12 +238,9 @@ export declare function jobsPageWithRetry<const TQueues extends readonly JobsQue
|
|
|
229
238
|
readonly retryLimit: Schema.Number;
|
|
230
239
|
readonly startedOn: Schema.OptionFromNullOr<Schema.DateTimeUtcFromString>;
|
|
231
240
|
readonly state: Schema.Literals<readonly ["created", "retry", "active", "completed", "cancelled", "failed"]>;
|
|
232
|
-
readonly data: [...TQueues][number]
|
|
241
|
+
readonly data: import("./entry.ts").JobsPayload<[...TQueues][number]>;
|
|
233
242
|
readonly queue: Schema.Literal<string>;
|
|
234
|
-
}>[]>>, Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof
|
|
235
|
-
id: Schema.String;
|
|
236
|
-
queue: Schema.String;
|
|
237
|
-
}>, 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>, readonly [], undefined>;
|
|
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>;
|
|
238
244
|
} & {
|
|
239
245
|
queues: TQueues;
|
|
240
246
|
};
|
|
@@ -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;AAIhC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"retryPage.d.ts","sourceRoot":"","sources":["../../src/jobs/retryPage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retryPage.js","sourceRoot":"","sources":["../../src/jobs/retryPage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"retryPage.js","sourceRoot":"","sources":["../../src/jobs/retry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