@shivaedev/admin 0.11.0 → 0.11.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/dist/client/UsersTable.d.ts.map +1 -1
- package/dist/client/UsersTable.js +13 -5
- package/dist/client/UsersTable.js.map +1 -1
- package/dist/jobs/page.d.ts +7 -7
- package/dist/jobs/retryPage.d.ts +11 -11
- package/dist/users/page.d.ts +3 -3
- package/package.json +7 -7
- package/src/client/UsersTable.tsx +33 -18
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UsersTable.d.ts","sourceRoot":"","sources":["../../src/client/UsersTable.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"UsersTable.d.ts","sourceRoot":"","sources":["../../src/client/UsersTable.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAW,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEhE,UAAU,YAAY,CAAC,KAAK,SAAS,MAAM;IAC1C,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,eAAe,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC;IAC3D,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,SAAS,KAAK,EAAE,CAAC;CACjC;AAmFD,wBAAgB,UAAU,CAAC,KAAK,SAAS,MAAM,EAAE,EAAE,IAAI,EAAE,GAAG,QAAQ,EAAE,EAAE,YAAY,CAAC,KAAK,CAAC,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,SAAS,CAAC,IAAI,CAAA;CAAE,+BASrI"}
|
|
@@ -2,21 +2,29 @@ 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
|
-
|
|
5
|
+
if (!canChangeRoles) {
|
|
6
|
+
return user.role;
|
|
7
|
+
}
|
|
8
|
+
return (_jsx("select", { "aria-label": `Role for ${user.email}`, className: "bg-background max-w-full min-w-0 rounded-md border p-2 sm:max-w-none", disabled: pending, onChange: (event) => {
|
|
6
9
|
const role = roles.find((candidate) => candidate === event.target.value);
|
|
7
10
|
if (role !== undefined) {
|
|
8
11
|
dispatch({ role, userId: user.id });
|
|
9
12
|
}
|
|
10
|
-
}, value: user.role, children: roles.map((role) => (_jsx("option", { value: role, children: role }, role))) }))
|
|
13
|
+
}, value: user.role, children: roles.map((role) => (_jsx("option", { value: role, children: role }, role))) }));
|
|
11
14
|
}
|
|
12
15
|
function UserRow({ user, canChangeRoles, ...controls }) {
|
|
13
|
-
return (_jsxs("tr", { className: "border-b", children: [_jsx(
|
|
16
|
+
return (_jsxs("tr", { className: "block min-w-0 rounded-md border sm:table-row sm:rounded-none sm:border-0 sm:border-b", children: [_jsx(UserCell, { label: "Name", children: user.name }), _jsx(UserCell, { label: "Email", children: user.email }), _jsx(UserCell, { label: "Role", children: _jsx(UserRole, { ...controls, canChangeRoles: canChangeRoles, user: user }) }), _jsx(UserCell, { label: "Signed up", children: _jsx("time", { className: "sm:whitespace-nowrap", dateTime: DateTime.formatIso(user.createdAt), children: DateTime.formatIso(user.createdAt) }) })] }));
|
|
17
|
+
}
|
|
18
|
+
function UserCell({ label, children }) {
|
|
19
|
+
return (_jsxs("td", { className: "block min-w-0 p-3 wrap-anywhere sm:table-cell sm:wrap-normal", children: [_jsx("span", { className: "block font-medium sm:hidden", children: label }), _jsx("div", { children: children })] }));
|
|
14
20
|
}
|
|
15
21
|
function UserRows({ data, ...controls }) {
|
|
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 }))) })] }) }));
|
|
22
|
+
return (_jsx("div", { className: "sm:overflow-x-auto sm:rounded-md sm:border", children: _jsxs("table", { className: "block w-full text-left text-sm sm:table", children: [_jsx("caption", { className: "sr-only", children: "App users and roles" }), _jsx("thead", { className: "bg-muted hidden sm:table-header-group", children: _jsx(UserHeaders, {}) }), _jsx("tbody", { className: "grid gap-4 sm:table-row-group", children: data.users.map((user) => (_createElement(UserRow, { ...controls, canChangeRoles: data.canChangeRoles, key: user.id, user: user }))) })] }) }));
|
|
17
23
|
}
|
|
18
24
|
export function UsersTable({ data, ...controls }) {
|
|
19
|
-
|
|
25
|
+
const permission = !data.canChangeRoles && _jsx("p", { children: "Permission to assign roles is required to change roles." });
|
|
26
|
+
const users = data.users.length === 0 ? _jsx("p", { children: "No users." }) : _jsx(UserRows, { ...controls, data: data });
|
|
27
|
+
return (_jsxs("div", { className: "space-y-4", children: [permission, users] }));
|
|
20
28
|
}
|
|
21
29
|
function UserHeaders() {
|
|
22
30
|
return (_jsx("tr", { children: ["Name", "Email", "Role", "Signed up"].map((label) => (_jsx("th", { className: "p-3 whitespace-nowrap", scope: "col", children: label }, label))) }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UsersTable.js","sourceRoot":"","sources":["../../src/client/UsersTable.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"UsersTable.js","sourceRoot":"","sources":["../../src/client/UsersTable.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAWlC,SAAS,QAAQ,CAAuB,EACvC,IAAI,EACJ,cAAc,EACd,KAAK,EACL,OAAO,EACP,QAAQ,GAIR;IACA,IAAI,CAAC,cAAc,EAAE,CAAC;QACrB,OAAO,IAAI,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AAO,CACN,uBACE,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CACtD,aAAI,SAAS,EAAC,uBAAuB,EAAa,KAAK,EAAC,KAAK,YAC3D,KAAK,IADoC,KAAK,CAE3C,CACL,CAAC,GACE,CACL,CAAC;AACH,CAAC"}
|
package/dist/jobs/page.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export declare function jobsPage<const TQueues extends readonly JobsEntry[]>(...
|
|
|
22
22
|
JobsPayloadInvalid: typeof import("#jobs/schemas.ts").JobsPayloadInvalid;
|
|
23
23
|
JobsQueueUnregistered: typeof import("#jobs/schemas.ts").JobsQueueUnregistered;
|
|
24
24
|
JobsUnavailable: typeof import("#jobs/schemas.ts").JobsUnavailable;
|
|
25
|
-
}, never>>, "readPolicy"> & {
|
|
25
|
+
}, never, undefined>>, "readPolicy"> & {
|
|
26
26
|
readonly readPolicy: import("@shivaedev/contract/readPolicy.ts").QueryReadPolicy<void, import("@shivaedev/errors/taxonomy.ts").BadRequest | import("#jobs/schemas.ts").JobsPayloadInvalid | import("#jobs/schemas.ts").JobsQueueUnregistered | import("#jobs/schemas.ts").JobsUnavailable, import("@shivaedev/identity/identity.ts").SessionUser>;
|
|
27
27
|
}, Omit<NoInfer<import("@shivaedev/contract/operation.ts").Query<"counts", Schema.Struct<{
|
|
28
28
|
queue: Schema.String;
|
|
@@ -36,7 +36,7 @@ export declare function jobsPage<const TQueues extends readonly JobsEntry[]>(...
|
|
|
36
36
|
JobsPayloadInvalid: typeof import("#jobs/schemas.ts").JobsPayloadInvalid;
|
|
37
37
|
JobsQueueUnregistered: typeof import("#jobs/schemas.ts").JobsQueueUnregistered;
|
|
38
38
|
JobsUnavailable: typeof import("#jobs/schemas.ts").JobsUnavailable;
|
|
39
|
-
}, never>>, "readPolicy"> & {
|
|
39
|
+
}, never, undefined>>, "readPolicy"> & {
|
|
40
40
|
readonly readPolicy: import("@shivaedev/contract/readPolicy.ts").QueryReadPolicy<{
|
|
41
41
|
readonly queue: string;
|
|
42
42
|
}, import("@shivaedev/errors/taxonomy.ts").BadRequest | import("#jobs/schemas.ts").JobsPayloadInvalid | import("#jobs/schemas.ts").JobsQueueUnregistered | import("#jobs/schemas.ts").JobsUnavailable, import("@shivaedev/identity/identity.ts").SessionUser>;
|
|
@@ -67,7 +67,7 @@ export declare function jobsPage<const TQueues extends readonly JobsEntry[]>(...
|
|
|
67
67
|
JobsPayloadInvalid: typeof import("#jobs/schemas.ts").JobsPayloadInvalid;
|
|
68
68
|
JobsQueueUnregistered: typeof import("#jobs/schemas.ts").JobsQueueUnregistered;
|
|
69
69
|
JobsUnavailable: typeof import("#jobs/schemas.ts").JobsUnavailable;
|
|
70
|
-
}, never>>, "readPolicy"> & {
|
|
70
|
+
}, never, undefined>>, "readPolicy"> & {
|
|
71
71
|
readonly readPolicy: import("@shivaedev/contract/readPolicy.ts").QueryReadPolicy<{
|
|
72
72
|
readonly cursor?: string;
|
|
73
73
|
readonly limit: number;
|
|
@@ -105,7 +105,7 @@ export declare function jobsPage<const TQueues extends readonly JobsEntry[]>(...
|
|
|
105
105
|
JobsPayloadInvalid: typeof import("#jobs/schemas.ts").JobsPayloadInvalid;
|
|
106
106
|
JobsQueueUnregistered: typeof import("#jobs/schemas.ts").JobsQueueUnregistered;
|
|
107
107
|
JobsUnavailable: typeof import("#jobs/schemas.ts").JobsUnavailable;
|
|
108
|
-
}, never>>, "readPolicy"> & {
|
|
108
|
+
}, never, undefined>>, "readPolicy"> & {
|
|
109
109
|
readonly readPolicy: import("@shivaedev/contract/readPolicy.ts").QueryReadPolicy<{
|
|
110
110
|
readonly cursor?: string;
|
|
111
111
|
readonly limit: number;
|
|
@@ -134,7 +134,7 @@ export declare function jobsPage<const TQueues extends readonly JobsEntry[]>(...
|
|
|
134
134
|
JobsPayloadInvalid: typeof import("#jobs/schemas.ts").JobsPayloadInvalid;
|
|
135
135
|
JobsQueueUnregistered: typeof import("#jobs/schemas.ts").JobsQueueUnregistered;
|
|
136
136
|
JobsUnavailable: typeof import("#jobs/schemas.ts").JobsUnavailable;
|
|
137
|
-
}, never>>, "readPolicy"> & {
|
|
137
|
+
}, never, undefined>>, "readPolicy"> & {
|
|
138
138
|
readonly readPolicy: import("@shivaedev/contract/readPolicy.ts").QueryReadPolicy<{
|
|
139
139
|
readonly id: string;
|
|
140
140
|
readonly queue: string;
|
|
@@ -169,7 +169,7 @@ export declare function jobsPage<const TQueues extends readonly JobsEntry[]>(...
|
|
|
169
169
|
queue: Schema.String;
|
|
170
170
|
}>;
|
|
171
171
|
}>)[]>>;
|
|
172
|
-
}>, import("effect/rpc/RpcSchema").Stream<Schema.Union<readonly [Schema.Struct<{
|
|
172
|
+
}>, import("effect/rpc/RpcSchema").Stream<Schema.Union<readonly [Schema.Union<readonly [Schema.Struct<{
|
|
173
173
|
readonly _tag: Schema.Literal<"Changed">;
|
|
174
174
|
readonly keys: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
175
175
|
readonly _tag: Schema.Literal<"Bucket">;
|
|
@@ -187,7 +187,7 @@ export declare function jobsPage<const TQueues extends readonly JobsEntry[]>(...
|
|
|
187
187
|
readonly queryIndexes: Schema.optional<Schema.$Array<Schema.Number>>;
|
|
188
188
|
}>, Schema.Struct<{
|
|
189
189
|
readonly _tag: Schema.Literal<"Resync">;
|
|
190
|
-
}>]>, Schema.Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, ...Schema.Union<readonly (typeof import("@shivaedev/errors/taxonomy.ts").BadRequest | typeof import("#jobs/schemas.ts").JobsUnavailable | typeof import("#jobs/schemas.ts").JobsPayloadInvalid | typeof import("#jobs/schemas.ts").JobsQueueUnregistered)[]>[]]>>, Schema.Never, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.counts", Schema.Struct<{
|
|
190
|
+
}>]>, ...never[]]>, Schema.Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, ...Schema.Union<readonly (typeof import("@shivaedev/errors/taxonomy.ts").BadRequest | typeof import("#jobs/schemas.ts").JobsUnavailable | typeof import("#jobs/schemas.ts").JobsPayloadInvalid | typeof import("#jobs/schemas.ts").JobsQueueUnregistered)[]>[]]>>, Schema.Never, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.counts", Schema.Struct<{
|
|
191
191
|
queue: Schema.String;
|
|
192
192
|
}>, Schema.Struct<{
|
|
193
193
|
readonly activeCount: Schema.Number;
|
package/dist/jobs/retryPage.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export declare function jobsPageWithRetry<const TQueues extends readonly JobsEnt
|
|
|
29
29
|
JobsPayloadInvalid: typeof import("./schemas.ts").JobsPayloadInvalid;
|
|
30
30
|
JobsQueueUnregistered: typeof import("./schemas.ts").JobsQueueUnregistered;
|
|
31
31
|
JobsUnavailable: typeof import("./schemas.ts").JobsUnavailable;
|
|
32
|
-
}, never>>, "readPolicy"> & {
|
|
32
|
+
}, never, undefined>>, "readPolicy"> & {
|
|
33
33
|
readonly readPolicy: import("@shivaedev/contract/readPolicy.ts").QueryReadPolicy<void, import("@shivaedev/errors/taxonomy.ts").BadRequest | import("./schemas.ts").JobsPayloadInvalid | import("./schemas.ts").JobsQueueUnregistered | import("./schemas.ts").JobsUnavailable, import("@shivaedev/identity/identity.ts").SessionUser>;
|
|
34
34
|
}, "readPolicy"> & {
|
|
35
35
|
readonly readPolicy: import("@shivaedev/contract/readPolicy.ts").QueryReadPolicy<void, import("@shivaedev/errors/taxonomy.ts").BadRequest | import("./schemas.ts").JobsPayloadInvalid | import("./schemas.ts").JobsQueueUnregistered | import("./schemas.ts").JobsUnavailable, import("@shivaedev/identity/identity.ts").SessionUser>;
|
|
@@ -45,7 +45,7 @@ export declare function jobsPageWithRetry<const TQueues extends readonly JobsEnt
|
|
|
45
45
|
JobsPayloadInvalid: typeof import("./schemas.ts").JobsPayloadInvalid;
|
|
46
46
|
JobsQueueUnregistered: typeof import("./schemas.ts").JobsQueueUnregistered;
|
|
47
47
|
JobsUnavailable: typeof import("./schemas.ts").JobsUnavailable;
|
|
48
|
-
}, never>>, "readPolicy"> & {
|
|
48
|
+
}, never, undefined>>, "readPolicy"> & {
|
|
49
49
|
readonly readPolicy: import("@shivaedev/contract/readPolicy.ts").QueryReadPolicy<{
|
|
50
50
|
readonly queue: string;
|
|
51
51
|
}, import("@shivaedev/errors/taxonomy.ts").BadRequest | import("./schemas.ts").JobsPayloadInvalid | import("./schemas.ts").JobsQueueUnregistered | import("./schemas.ts").JobsUnavailable, import("@shivaedev/identity/identity.ts").SessionUser>;
|
|
@@ -80,7 +80,7 @@ export declare function jobsPageWithRetry<const TQueues extends readonly JobsEnt
|
|
|
80
80
|
JobsPayloadInvalid: typeof import("./schemas.ts").JobsPayloadInvalid;
|
|
81
81
|
JobsQueueUnregistered: typeof import("./schemas.ts").JobsQueueUnregistered;
|
|
82
82
|
JobsUnavailable: typeof import("./schemas.ts").JobsUnavailable;
|
|
83
|
-
}, never>>, "readPolicy"> & {
|
|
83
|
+
}, never, undefined>>, "readPolicy"> & {
|
|
84
84
|
readonly readPolicy: import("@shivaedev/contract/readPolicy.ts").QueryReadPolicy<{
|
|
85
85
|
readonly cursor?: string;
|
|
86
86
|
readonly limit: number;
|
|
@@ -124,7 +124,7 @@ export declare function jobsPageWithRetry<const TQueues extends readonly JobsEnt
|
|
|
124
124
|
JobsPayloadInvalid: typeof import("./schemas.ts").JobsPayloadInvalid;
|
|
125
125
|
JobsQueueUnregistered: typeof import("./schemas.ts").JobsQueueUnregistered;
|
|
126
126
|
JobsUnavailable: typeof import("./schemas.ts").JobsUnavailable;
|
|
127
|
-
}, never>>, "readPolicy"> & {
|
|
127
|
+
}, never, undefined>>, "readPolicy"> & {
|
|
128
128
|
readonly readPolicy: import("@shivaedev/contract/readPolicy.ts").QueryReadPolicy<{
|
|
129
129
|
readonly cursor?: string;
|
|
130
130
|
readonly limit: number;
|
|
@@ -159,7 +159,7 @@ export declare function jobsPageWithRetry<const TQueues extends readonly JobsEnt
|
|
|
159
159
|
JobsPayloadInvalid: typeof import("./schemas.ts").JobsPayloadInvalid;
|
|
160
160
|
JobsQueueUnregistered: typeof import("./schemas.ts").JobsQueueUnregistered;
|
|
161
161
|
JobsUnavailable: typeof import("./schemas.ts").JobsUnavailable;
|
|
162
|
-
}, never>>, "readPolicy"> & {
|
|
162
|
+
}, never, undefined>>, "readPolicy"> & {
|
|
163
163
|
readonly readPolicy: import("@shivaedev/contract/readPolicy.ts").QueryReadPolicy<{
|
|
164
164
|
readonly id: string;
|
|
165
165
|
readonly queue: string;
|
|
@@ -209,7 +209,7 @@ export declare function jobsPageWithRetry<const TQueues extends readonly JobsEnt
|
|
|
209
209
|
queue: Schema.String;
|
|
210
210
|
}>;
|
|
211
211
|
}>)[]>>;
|
|
212
|
-
}>, import("effect/rpc/RpcSchema").Stream<Schema.Union<readonly [Schema.Struct<{
|
|
212
|
+
}>, import("effect/rpc/RpcSchema").Stream<Schema.Union<readonly [Schema.Union<readonly [Schema.Struct<{
|
|
213
213
|
readonly _tag: Schema.Literal<"Changed">;
|
|
214
214
|
readonly keys: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
215
215
|
readonly _tag: Schema.Literal<"Bucket">;
|
|
@@ -227,7 +227,10 @@ export declare function jobsPageWithRetry<const TQueues extends readonly JobsEnt
|
|
|
227
227
|
readonly queryIndexes: Schema.optional<Schema.$Array<Schema.Number>>;
|
|
228
228
|
}>, Schema.Struct<{
|
|
229
229
|
readonly _tag: Schema.Literal<"Resync">;
|
|
230
|
-
}>]>, Schema.Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, ...Schema.Union<readonly (typeof import("@shivaedev/errors/taxonomy.ts").BadRequest | typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>[]]>>, Schema.Never, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.
|
|
230
|
+
}>]>, ...never[]]>, Schema.Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, ...Schema.Union<readonly (typeof import("@shivaedev/errors/taxonomy.ts").BadRequest | typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>[]]>>, Schema.Never, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.retry", Schema.Struct<{
|
|
231
|
+
id: Schema.String;
|
|
232
|
+
queue: Schema.String;
|
|
233
|
+
}>, Schema.Void, Schema.Union<readonly (typeof Forbidden | typeof import("@shivaedev/errors/taxonomy.ts").BadRequest | typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered | typeof JobsNotFailed)[]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.counts", Schema.Struct<{
|
|
231
234
|
queue: Schema.String;
|
|
232
235
|
}>, Schema.Struct<{
|
|
233
236
|
readonly activeCount: Schema.Number;
|
|
@@ -315,10 +318,7 @@ export declare function jobsPageWithRetry<const TQueues extends readonly JobsEnt
|
|
|
315
318
|
readonly state: Schema.Literals<readonly ["created", "retry", "active", "completed", "cancelled", "failed"]>;
|
|
316
319
|
readonly data: import("./entry.ts").JobsPayload<[...TQueues][number]>;
|
|
317
320
|
readonly queue: Schema.Literal<string>;
|
|
318
|
-
}>[]>>, Schema.Union<readonly [Schema.Union<readonly (typeof import("@shivaedev/errors/taxonomy.ts").BadRequest | typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never
|
|
319
|
-
id: Schema.String;
|
|
320
|
-
queue: Schema.String;
|
|
321
|
-
}>, Schema.Void, Schema.Union<readonly (typeof Forbidden | typeof import("@shivaedev/errors/taxonomy.ts").BadRequest | typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered | typeof JobsNotFailed)[]>, typeof JobsPermission, never>, readonly [], undefined>;
|
|
321
|
+
}>[]>>, Schema.Union<readonly [Schema.Union<readonly (typeof import("@shivaedev/errors/taxonomy.ts").BadRequest | typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never>, readonly [], undefined>;
|
|
322
322
|
} & {
|
|
323
323
|
queues: TQueues;
|
|
324
324
|
};
|
package/dist/users/page.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export declare function usersPage<const TRole extends string>(access: Pick<Acces
|
|
|
32
32
|
}>, {
|
|
33
33
|
readonly AuthUnavailable: typeof AuthUnavailable;
|
|
34
34
|
readonly Forbidden: typeof Forbidden;
|
|
35
|
-
}, never>>, "readPolicy"> & {
|
|
35
|
+
}, never, undefined>>, "readPolicy"> & {
|
|
36
36
|
readonly readPolicy: import("@shivaedev/contract/readPolicy.ts").QueryReadPolicy<{
|
|
37
37
|
readonly cursor?: string;
|
|
38
38
|
readonly limit: number;
|
|
@@ -53,7 +53,7 @@ export declare function usersPage<const TRole extends string>(access: Pick<Acces
|
|
|
53
53
|
readonly limit: Schema.Number;
|
|
54
54
|
}>;
|
|
55
55
|
}>[]>>;
|
|
56
|
-
}>, import("effect/rpc/RpcSchema").Stream<Schema.Union<readonly [Schema.Struct<{
|
|
56
|
+
}>, import("effect/rpc/RpcSchema").Stream<Schema.Union<readonly [Schema.Union<readonly [Schema.Struct<{
|
|
57
57
|
readonly _tag: Schema.Literal<"Changed">;
|
|
58
58
|
readonly keys: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
59
59
|
readonly _tag: Schema.Literal<"Bucket">;
|
|
@@ -71,7 +71,7 @@ export declare function usersPage<const TRole extends string>(access: Pick<Acces
|
|
|
71
71
|
readonly queryIndexes: Schema.optional<Schema.$Array<Schema.Number>>;
|
|
72
72
|
}>, Schema.Struct<{
|
|
73
73
|
readonly _tag: Schema.Literal<"Resync">;
|
|
74
|
-
}>]>, Schema.Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, ...Schema.Union<readonly (typeof Forbidden | typeof AuthUnavailable)[]>[]]>>, Schema.Never, typeof UsersPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.users.changeRole", Schema.Struct<{
|
|
74
|
+
}>]>, ...never[]]>, Schema.Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, ...Schema.Union<readonly (typeof Forbidden | typeof AuthUnavailable)[]>[]]>>, Schema.Never, typeof UsersPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.users.changeRole", Schema.Struct<{
|
|
75
75
|
role: Schema.Literals<TRole[]>;
|
|
76
76
|
userId: Schema.String;
|
|
77
77
|
}>, 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<{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shivaedev/admin",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.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.2.0",
|
|
45
45
|
"@shivaedev/changes": "0.5.1",
|
|
46
|
-
"@shivaedev/contract": "0.
|
|
46
|
+
"@shivaedev/contract": "0.24.0",
|
|
47
47
|
"@shivaedev/errors": "0.1.2",
|
|
48
|
-
"@shivaedev/identity": "0.
|
|
48
|
+
"@shivaedev/identity": "0.8.0",
|
|
49
49
|
"@shivaedev/jobs": "0.23.1",
|
|
50
|
-
"@shivaedev/react": "0.23.
|
|
50
|
+
"@shivaedev/react": "0.23.2",
|
|
51
51
|
"@shivaedev/sql": "0.26.1"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@effect/atom-react": "4.0.6",
|
|
55
55
|
"@shivaedev/quality": "0.47.0",
|
|
56
|
-
"@shivaedev/server": "0.
|
|
57
|
-
"@shivaedev/test-sql": "0.
|
|
58
|
-
"@shivaedev/test-story": "0.
|
|
56
|
+
"@shivaedev/server": "0.9.0",
|
|
57
|
+
"@shivaedev/test-sql": "0.14.0",
|
|
58
|
+
"@shivaedev/test-story": "0.26.1",
|
|
59
59
|
"@types/node": "24.19.2",
|
|
60
60
|
"@types/react": "19.3.0",
|
|
61
61
|
"@types/react-dom": "19.3.0",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DateTime } from "effect";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
2
3
|
import type { UsersList } from "#users/page.ts";
|
|
3
4
|
import type { AppUser, ChangeRoleInput } from "#users/roles.ts";
|
|
4
5
|
|
|
@@ -18,10 +19,13 @@ function UserRole<TRole extends string>({
|
|
|
18
19
|
readonly user: typeof AppUser.Type;
|
|
19
20
|
readonly canChangeRoles: boolean;
|
|
20
21
|
}) {
|
|
21
|
-
|
|
22
|
+
if (!canChangeRoles) {
|
|
23
|
+
return user.role;
|
|
24
|
+
}
|
|
25
|
+
return (
|
|
22
26
|
<select
|
|
23
27
|
aria-label={`Role for ${user.email}`}
|
|
24
|
-
className="bg-background rounded-md border p-2"
|
|
28
|
+
className="bg-background max-w-full min-w-0 rounded-md border p-2 sm:max-w-none"
|
|
25
29
|
disabled={pending}
|
|
26
30
|
onChange={(event) => {
|
|
27
31
|
const role = roles.find((candidate) => candidate === event.target.value);
|
|
@@ -37,8 +41,6 @@ function UserRole<TRole extends string>({
|
|
|
37
41
|
</option>
|
|
38
42
|
))}
|
|
39
43
|
</select>
|
|
40
|
-
) : (
|
|
41
|
-
user.role
|
|
42
44
|
);
|
|
43
45
|
}
|
|
44
46
|
|
|
@@ -48,27 +50,38 @@ function UserRow<TRole extends string>({
|
|
|
48
50
|
...controls
|
|
49
51
|
}: RoleControls<TRole> & { readonly user: typeof AppUser.Type; readonly canChangeRoles: boolean }) {
|
|
50
52
|
return (
|
|
51
|
-
<tr className="border-b">
|
|
52
|
-
<
|
|
53
|
-
<
|
|
54
|
-
<
|
|
53
|
+
<tr className="block min-w-0 rounded-md border sm:table-row sm:rounded-none sm:border-0 sm:border-b">
|
|
54
|
+
<UserCell label="Name">{user.name}</UserCell>
|
|
55
|
+
<UserCell label="Email">{user.email}</UserCell>
|
|
56
|
+
<UserCell label="Role">
|
|
55
57
|
<UserRole {...controls} canChangeRoles={canChangeRoles} user={user} />
|
|
56
|
-
</
|
|
57
|
-
<
|
|
58
|
-
<time dateTime={DateTime.formatIso(user.createdAt)}>
|
|
59
|
-
|
|
58
|
+
</UserCell>
|
|
59
|
+
<UserCell label="Signed up">
|
|
60
|
+
<time className="sm:whitespace-nowrap" dateTime={DateTime.formatIso(user.createdAt)}>
|
|
61
|
+
{DateTime.formatIso(user.createdAt)}
|
|
62
|
+
</time>
|
|
63
|
+
</UserCell>
|
|
60
64
|
</tr>
|
|
61
65
|
);
|
|
62
66
|
}
|
|
67
|
+
function UserCell({ label, children }: { readonly label: string; readonly children: ReactNode }) {
|
|
68
|
+
return (
|
|
69
|
+
<td className="block min-w-0 p-3 wrap-anywhere sm:table-cell sm:wrap-normal">
|
|
70
|
+
<span className="block font-medium sm:hidden">{label}</span>
|
|
71
|
+
<div>{children}</div>
|
|
72
|
+
</td>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
63
76
|
function UserRows<TRole extends string>({ data, ...controls }: RoleControls<TRole> & { readonly data: typeof UsersList.Type }) {
|
|
64
77
|
return (
|
|
65
|
-
<div className="overflow-x-auto rounded-md border">
|
|
66
|
-
<table className="w-full text-left text-sm">
|
|
78
|
+
<div className="sm:overflow-x-auto sm:rounded-md sm:border">
|
|
79
|
+
<table className="block w-full text-left text-sm sm:table">
|
|
67
80
|
<caption className="sr-only">App users and roles</caption>
|
|
68
|
-
<thead className="bg-muted">
|
|
81
|
+
<thead className="bg-muted hidden sm:table-header-group">
|
|
69
82
|
<UserHeaders />
|
|
70
83
|
</thead>
|
|
71
|
-
<tbody>
|
|
84
|
+
<tbody className="grid gap-4 sm:table-row-group">
|
|
72
85
|
{data.users.map((user) => (
|
|
73
86
|
<UserRow {...controls} canChangeRoles={data.canChangeRoles} key={user.id} user={user} />
|
|
74
87
|
))}
|
|
@@ -78,10 +91,12 @@ function UserRows<TRole extends string>({ data, ...controls }: RoleControls<TRol
|
|
|
78
91
|
);
|
|
79
92
|
}
|
|
80
93
|
export function UsersTable<TRole extends string>({ data, ...controls }: RoleControls<TRole> & { readonly data: typeof UsersList.Type }) {
|
|
94
|
+
const permission = !data.canChangeRoles && <p>Permission to assign roles is required to change roles.</p>;
|
|
95
|
+
const users = data.users.length === 0 ? <p>No users.</p> : <UserRows {...controls} data={data} />;
|
|
81
96
|
return (
|
|
82
97
|
<div className="space-y-4">
|
|
83
|
-
{
|
|
84
|
-
{
|
|
98
|
+
{permission}
|
|
99
|
+
{users}
|
|
85
100
|
</div>
|
|
86
101
|
);
|
|
87
102
|
}
|