@shivaedev/admin 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/README.md +22 -15
- package/dist/client/adapters/JobButton.d.ts.map +1 -0
- package/dist/client/adapters/JobButton.js.map +1 -0
- package/dist/client/adapters/JobDetail.d.ts.map +1 -0
- package/dist/client/adapters/JobDetail.js.map +1 -0
- package/dist/client/{JobList.d.ts → adapters/JobList.d.ts} +3 -1
- package/dist/client/adapters/JobList.d.ts.map +1 -0
- package/dist/client/{JobList.js → adapters/JobList.js} +2 -2
- package/dist/client/adapters/JobList.js.map +1 -0
- package/dist/client/adapters/JobPagination.d.ts.map +1 -0
- package/dist/client/adapters/JobPagination.js.map +1 -0
- package/dist/client/adapters/JobTable.d.ts +10 -0
- package/dist/client/adapters/JobTable.d.ts.map +1 -0
- package/dist/client/adapters/JobTable.js +22 -0
- package/dist/client/adapters/JobTable.js.map +1 -0
- package/dist/client/adapters/JobsMetrics.d.ts.map +1 -0
- package/dist/client/adapters/JobsMetrics.js.map +1 -0
- package/dist/client/adapters/JobsQueryPanel.d.ts.map +1 -0
- package/dist/client/adapters/JobsQueryPanel.js.map +1 -0
- package/dist/client/{JobsQueueView.d.ts → adapters/JobsQueueView.d.ts} +5 -2
- package/dist/client/adapters/JobsQueueView.d.ts.map +1 -0
- package/dist/client/{JobsQueueView.js → adapters/JobsQueueView.js} +7 -4
- package/dist/client/adapters/JobsQueueView.js.map +1 -0
- package/dist/client/{JobsView.d.ts → adapters/JobsView.d.ts} +2 -1
- package/dist/client/adapters/JobsView.d.ts.map +1 -0
- package/dist/client/{JobsView.js → adapters/JobsView.js} +5 -3
- package/dist/client/adapters/JobsView.js.map +1 -0
- package/dist/client/adapters/SessionConfirmation.d.ts.map +1 -0
- package/dist/client/adapters/SessionConfirmation.js.map +1 -0
- package/dist/client/adapters/SessionListView.d.ts.map +1 -0
- package/dist/client/adapters/SessionListView.js.map +1 -0
- package/dist/client/adapters/SessionPagination.d.ts.map +1 -0
- package/dist/client/adapters/SessionPagination.js.map +1 -0
- package/dist/client/{SessionsView.d.ts → adapters/SessionsView.d.ts} +1 -1
- package/dist/client/adapters/SessionsView.d.ts.map +1 -0
- package/dist/client/adapters/SessionsView.js.map +1 -0
- package/dist/client/{UsersTable.d.ts → adapters/UsersTable.d.ts} +1 -1
- package/dist/client/adapters/UsersTable.d.ts.map +1 -0
- package/dist/client/adapters/UsersTable.js.map +1 -0
- package/dist/client/{UsersView.d.ts → adapters/UsersView.d.ts} +2 -1
- package/dist/client/adapters/UsersView.d.ts.map +1 -0
- package/dist/client/adapters/UsersView.js.map +1 -0
- package/dist/client/adapters/jobsTypes.d.ts.map +1 -0
- package/dist/client/adapters/jobsTypes.js.map +1 -0
- package/dist/jobs/entry.d.ts +3 -2
- package/dist/jobs/entry.d.ts.map +1 -1
- package/dist/jobs/entry.js.map +1 -1
- package/dist/jobs/page.d.ts +92 -44
- package/dist/jobs/page.d.ts.map +1 -1
- package/dist/jobs/retryPage.d.ts +57 -9
- package/dist/jobs/retryPage.d.ts.map +1 -1
- package/dist/server/jobsHandlers.d.ts +3 -3
- package/dist/server/jobsHandlers.d.ts.map +1 -1
- package/dist/server/jobsHandlers.js +3 -3
- package/dist/server/jobsHandlers.js.map +1 -1
- package/dist/server/users.d.ts +10 -13
- package/dist/server/users.d.ts.map +1 -1
- package/dist/server/users.js +7 -25
- package/dist/server/users.js.map +1 -1
- package/dist/server/usersHandlers.d.ts +1 -3
- package/dist/server/usersHandlers.d.ts.map +1 -1
- package/dist/server/usersHandlers.js +4 -4
- package/dist/server/usersHandlers.js.map +1 -1
- package/dist/sessions/Page.d.ts +18 -2
- package/dist/sessions/Page.d.ts.map +1 -1
- package/dist/users/ChangeRoleInput.d.ts +5 -0
- package/dist/users/ChangeRoleInput.d.ts.map +1 -0
- package/dist/users/ChangeRoleInput.js +2 -0
- package/dist/users/ChangeRoleInput.js.map +1 -0
- package/dist/users/page.d.ts +24 -8
- package/dist/users/page.d.ts.map +1 -1
- package/dist/users/page.js +4 -6
- package/dist/users/page.js.map +1 -1
- package/package.json +26 -13
- package/src/client/{JobList.tsx → adapters/JobList.tsx} +4 -1
- package/src/client/{JobTable.tsx → adapters/JobTable.tsx} +39 -3
- package/src/client/{JobsQueueView.tsx → adapters/JobsQueueView.tsx} +27 -11
- package/src/client/{JobsView.ts → adapters/JobsView.ts} +8 -5
- package/src/client/{SessionsView.ts → adapters/SessionsView.ts} +1 -1
- package/src/client/{UsersTable.tsx → adapters/UsersTable.tsx} +4 -3
- package/src/client/{UsersView.ts → adapters/UsersView.ts} +2 -1
- package/src/jobs/entry.ts +2 -1
- package/src/server/jobsHandlers.ts +3 -5
- package/src/server/users.ts +9 -35
- package/src/server/usersHandlers.ts +4 -10
- package/src/users/ChangeRoleInput.ts +4 -0
- package/src/users/page.ts +4 -7
- package/dist/client/JobButton.d.ts.map +0 -1
- package/dist/client/JobButton.js.map +0 -1
- package/dist/client/JobDetail.d.ts.map +0 -1
- package/dist/client/JobDetail.js.map +0 -1
- package/dist/client/JobList.d.ts.map +0 -1
- package/dist/client/JobList.js.map +0 -1
- package/dist/client/JobPagination.d.ts.map +0 -1
- package/dist/client/JobPagination.js.map +0 -1
- package/dist/client/JobTable.d.ts +0 -6
- package/dist/client/JobTable.d.ts.map +0 -1
- package/dist/client/JobTable.js +0 -13
- package/dist/client/JobTable.js.map +0 -1
- package/dist/client/JobsMetrics.d.ts.map +0 -1
- package/dist/client/JobsMetrics.js.map +0 -1
- package/dist/client/JobsQueryPanel.d.ts.map +0 -1
- package/dist/client/JobsQueryPanel.js.map +0 -1
- package/dist/client/JobsQueueView.d.ts.map +0 -1
- package/dist/client/JobsQueueView.js.map +0 -1
- package/dist/client/JobsView.d.ts.map +0 -1
- package/dist/client/JobsView.js.map +0 -1
- package/dist/client/SessionConfirmation.d.ts.map +0 -1
- package/dist/client/SessionConfirmation.js.map +0 -1
- package/dist/client/SessionListView.d.ts.map +0 -1
- package/dist/client/SessionListView.js.map +0 -1
- package/dist/client/SessionPagination.d.ts.map +0 -1
- package/dist/client/SessionPagination.js.map +0 -1
- package/dist/client/SessionsView.d.ts.map +0 -1
- package/dist/client/SessionsView.js.map +0 -1
- package/dist/client/UsersTable.d.ts.map +0 -1
- package/dist/client/UsersTable.js.map +0 -1
- package/dist/client/UsersView.d.ts.map +0 -1
- package/dist/client/UsersView.js.map +0 -1
- package/dist/client/jobsTypes.d.ts.map +0 -1
- package/dist/client/jobsTypes.js.map +0 -1
- package/dist/users/roles.d.ts +0 -27
- package/dist/users/roles.d.ts.map +0 -1
- package/dist/users/roles.js +0 -14
- package/dist/users/roles.js.map +0 -1
- package/src/users/roles.ts +0 -19
- /package/dist/client/{JobButton.d.ts → adapters/JobButton.d.ts} +0 -0
- /package/dist/client/{JobButton.js → adapters/JobButton.js} +0 -0
- /package/dist/client/{JobDetail.d.ts → adapters/JobDetail.d.ts} +0 -0
- /package/dist/client/{JobDetail.js → adapters/JobDetail.js} +0 -0
- /package/dist/client/{JobPagination.d.ts → adapters/JobPagination.d.ts} +0 -0
- /package/dist/client/{JobPagination.js → adapters/JobPagination.js} +0 -0
- /package/dist/client/{JobsMetrics.d.ts → adapters/JobsMetrics.d.ts} +0 -0
- /package/dist/client/{JobsMetrics.js → adapters/JobsMetrics.js} +0 -0
- /package/dist/client/{JobsQueryPanel.d.ts → adapters/JobsQueryPanel.d.ts} +0 -0
- /package/dist/client/{JobsQueryPanel.js → adapters/JobsQueryPanel.js} +0 -0
- /package/dist/client/{SessionConfirmation.d.ts → adapters/SessionConfirmation.d.ts} +0 -0
- /package/dist/client/{SessionConfirmation.js → adapters/SessionConfirmation.js} +0 -0
- /package/dist/client/{SessionListView.d.ts → adapters/SessionListView.d.ts} +0 -0
- /package/dist/client/{SessionListView.js → adapters/SessionListView.js} +0 -0
- /package/dist/client/{SessionPagination.d.ts → adapters/SessionPagination.d.ts} +0 -0
- /package/dist/client/{SessionPagination.js → adapters/SessionPagination.js} +0 -0
- /package/dist/client/{SessionsView.js → adapters/SessionsView.js} +0 -0
- /package/dist/client/{UsersTable.js → adapters/UsersTable.js} +0 -0
- /package/dist/client/{UsersView.js → adapters/UsersView.js} +0 -0
- /package/dist/client/{jobsTypes.d.ts → adapters/jobsTypes.d.ts} +0 -0
- /package/dist/client/{jobsTypes.js → adapters/jobsTypes.js} +0 -0
- /package/src/client/{JobButton.tsx → adapters/JobButton.tsx} +0 -0
- /package/src/client/{JobDetail.tsx → adapters/JobDetail.tsx} +0 -0
- /package/src/client/{JobPagination.tsx → adapters/JobPagination.tsx} +0 -0
- /package/src/client/{JobsMetrics.tsx → adapters/JobsMetrics.tsx} +0 -0
- /package/src/client/{JobsQueryPanel.tsx → adapters/JobsQueryPanel.tsx} +0 -0
- /package/src/client/{SessionConfirmation.tsx → adapters/SessionConfirmation.tsx} +0 -0
- /package/src/client/{SessionListView.tsx → adapters/SessionListView.tsx} +0 -0
- /package/src/client/{SessionPagination.tsx → adapters/SessionPagination.tsx} +0 -0
- /package/src/client/{jobsTypes.ts → adapters/jobsTypes.ts} +0 -0
package/dist/sessions/Page.d.ts
CHANGED
|
@@ -76,7 +76,15 @@ export declare const SessionsPage: import("#page.ts").AdminPage & {
|
|
|
76
76
|
readonly queryIndexes: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Number>>;
|
|
77
77
|
}>, import("effect/Schema").Struct<{
|
|
78
78
|
readonly _tag: import("effect/Schema").Literal<"Resync">;
|
|
79
|
-
}>]>, ...never[]]>, import("effect/Schema").Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, typeof import("@shivaedev/contract/WebSocketRequired.ts").WebSocketRequired, ...import("effect/Schema").Union<readonly (typeof import("@shivaedev/errors/taxonomy.ts").Forbidden | typeof import("@shivaedev/errors/taxonomy.ts").AuthUnavailable)[]>[]]>>, import("effect/Schema").Never, typeof SessionsPermission
|
|
79
|
+
}>]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, ...never[]]>, import("effect/Schema").Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, typeof import("@shivaedev/contract/WebSocketRequired.ts").WebSocketRequired, ...import("effect/Schema").Union<readonly (typeof import("@shivaedev/errors/taxonomy.ts").Forbidden | typeof import("@shivaedev/errors/taxonomy.ts").AuthUnavailable)[]>[]]>>, import("effect/Schema").Never, typeof SessionsPermission | (import("effect/Context").Reference<<A, E, R>(effect: import("effect/Effect").Effect<A, E, R>, request: {
|
|
80
|
+
readonly rpc: import("effect/rpc/Rpc").Any;
|
|
81
|
+
readonly payload: unknown;
|
|
82
|
+
}) => import("effect/Effect").Effect<A, E | import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy | import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied | import("@shivaedev/contract/WebSocketRequired.ts").WebSocketRequired | import("effect/Types").unhandled, R>> & {
|
|
83
|
+
"~effect/rpc/RpcMiddleware": "~effect/rpc/RpcMiddleware";
|
|
84
|
+
"~ClientError": never;
|
|
85
|
+
error: import("effect/Schema").Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, typeof import("@shivaedev/contract/WebSocketRequired.ts").WebSocketRequired]>;
|
|
86
|
+
requiredForClient: false;
|
|
87
|
+
}), never> | import("effect/rpc/Rpc").Rpc<"identity.sessions.list", import("effect/Schema").Struct<{
|
|
80
88
|
readonly cursor: import("effect/Schema").optionalKey<import("effect/Schema").Struct<{
|
|
81
89
|
readonly id: import("effect/Schema").String;
|
|
82
90
|
readonly lastActivityAt: import("effect/Schema").DateTimeUtcFromString;
|
|
@@ -98,7 +106,15 @@ export declare const SessionsPage: import("#page.ts").AdminPage & {
|
|
|
98
106
|
readonly name: import("effect/Schema").String;
|
|
99
107
|
}>;
|
|
100
108
|
}>>;
|
|
101
|
-
}>, import("effect/Schema").Union<readonly [import("effect/Schema").Union<readonly (typeof import("@shivaedev/errors/taxonomy.ts").Forbidden | typeof import("@shivaedev/errors/taxonomy.ts").AuthUnavailable)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof SessionsPermission
|
|
109
|
+
}>, import("effect/Schema").Union<readonly [import("effect/Schema").Union<readonly (typeof import("@shivaedev/errors/taxonomy.ts").Forbidden | typeof import("@shivaedev/errors/taxonomy.ts").AuthUnavailable)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof SessionsPermission | (import("effect/Context").Reference<<A, E, R>(effect: import("effect/Effect").Effect<A, E, R>, request: {
|
|
110
|
+
readonly rpc: import("effect/rpc/Rpc").Any;
|
|
111
|
+
readonly payload: unknown;
|
|
112
|
+
}) => import("effect/Effect").Effect<A, E | import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy | import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied | import("@shivaedev/contract/WebSocketRequired.ts").WebSocketRequired | import("effect/Types").unhandled, R>> & {
|
|
113
|
+
"~effect/rpc/RpcMiddleware": "~effect/rpc/RpcMiddleware";
|
|
114
|
+
"~ClientError": never;
|
|
115
|
+
error: import("effect/Schema").Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, typeof import("@shivaedev/contract/WebSocketRequired.ts").WebSocketRequired]>;
|
|
116
|
+
requiredForClient: false;
|
|
117
|
+
}), never> | import("effect/rpc/Rpc").Rpc<"identity.sessions.revoke", import("effect/Schema").Struct<{
|
|
102
118
|
id: import("effect/Schema").String;
|
|
103
119
|
}>, import("effect/Schema").Void, import("effect/Schema").Union<readonly (typeof import("@shivaedev/errors/taxonomy.ts").NotFound | typeof import("@shivaedev/errors/taxonomy.ts").Forbidden | typeof import("@shivaedev/errors/taxonomy.ts").AuthUnavailable)[]>, typeof SessionsPermission, never>, readonly [], undefined>;
|
|
104
120
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Page.d.ts","sourceRoot":"","sources":["../../src/sessions/Page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAI/E,eAAO,MAAM,YAAY
|
|
1
|
+
{"version":3,"file":"Page.d.ts","sourceRoot":"","sources":["../../src/sessions/Page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAI/E,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAKvB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChangeRoleInput.d.ts","sourceRoot":"","sources":["../../src/users/ChangeRoleInput.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM;IAC7D,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChangeRoleInput.js","sourceRoot":"","sources":["../../src/users/ChangeRoleInput.ts"],"names":[],"mappings":""}
|
package/dist/users/page.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Schema } from "effect";
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
2
|
import type { AccessPolicy } from "@shivaedev/access/roleSet.ts";
|
|
3
|
-
import { LastRoleAssigner } from "@shivaedev/access/roles.ts";
|
|
4
3
|
import { AuthUnavailable, Forbidden, NotFound } from "@shivaedev/errors/taxonomy.ts";
|
|
4
|
+
import { LastRoleAssigner } from "@shivaedev/identity/roles.ts";
|
|
5
5
|
import { UsersPermission } from "#permissions.ts";
|
|
6
6
|
export declare const UsersList: Schema.Struct<{
|
|
7
7
|
readonly next: Schema.OptionFromNullOr<Schema.String>;
|
|
@@ -52,7 +52,10 @@ export declare function usersPage<const TRole extends string>(access: Pick<Acces
|
|
|
52
52
|
readonly Forbidden: typeof Forbidden;
|
|
53
53
|
readonly LastRoleAssigner: typeof LastRoleAssigner;
|
|
54
54
|
readonly NotFound: typeof NotFound;
|
|
55
|
-
}>>], import("effect/rpc/Rpc").Rpc<"admin.users
|
|
55
|
+
}>>], import("effect/rpc/Rpc").Rpc<"admin.users.changeRole", Schema.Struct<{
|
|
56
|
+
role: Schema.Literals<TRole[]>;
|
|
57
|
+
userId: Schema.String;
|
|
58
|
+
}>, Schema.Void, Schema.Union<readonly (typeof NotFound | typeof Forbidden | typeof AuthUnavailable | typeof LastRoleAssigner)[]>, typeof UsersPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.users.$changes", Schema.Struct<{
|
|
56
59
|
queries: Schema.$Array<Schema.Union<readonly Schema.Struct<{
|
|
57
60
|
query: Schema.Literal<"list">;
|
|
58
61
|
payload: Schema.Struct<{
|
|
@@ -78,10 +81,15 @@ export declare function usersPage<const TRole extends string>(access: Pick<Acces
|
|
|
78
81
|
readonly queryIndexes: Schema.optional<Schema.$Array<Schema.Number>>;
|
|
79
82
|
}>, Schema.Struct<{
|
|
80
83
|
readonly _tag: Schema.Literal<"Resync">;
|
|
81
|
-
}>]>, ...never[]]>, Schema.Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, typeof import("@shivaedev/contract/WebSocketRequired.ts").WebSocketRequired, ...Schema.Union<readonly (typeof Forbidden | typeof AuthUnavailable)[]>[]]>>, Schema.Never, typeof UsersPermission
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
84
|
+
}>]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, ...never[]]>, Schema.Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, typeof import("@shivaedev/contract/WebSocketRequired.ts").WebSocketRequired, ...Schema.Union<readonly (typeof Forbidden | typeof AuthUnavailable)[]>[]]>>, Schema.Never, typeof UsersPermission | (import("effect/Context").Reference<<A, E, R>(effect: Effect.Effect<A, E, R>, request: {
|
|
85
|
+
readonly rpc: import("effect/rpc/Rpc").Any;
|
|
86
|
+
readonly payload: unknown;
|
|
87
|
+
}) => Effect.Effect<A, E | import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy | import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied | import("@shivaedev/contract/WebSocketRequired.ts").WebSocketRequired | import("effect/Types").unhandled, R>> & {
|
|
88
|
+
"~effect/rpc/RpcMiddleware": "~effect/rpc/RpcMiddleware";
|
|
89
|
+
"~ClientError": never;
|
|
90
|
+
error: Schema.Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, typeof import("@shivaedev/contract/WebSocketRequired.ts").WebSocketRequired]>;
|
|
91
|
+
requiredForClient: false;
|
|
92
|
+
}), never> | import("effect/rpc/Rpc").Rpc<"admin.users.list", Schema.Struct<{
|
|
85
93
|
readonly cursor: Schema.optionalKey<Schema.String>;
|
|
86
94
|
readonly limit: Schema.Number;
|
|
87
95
|
}>, Schema.Struct<{
|
|
@@ -94,6 +102,14 @@ export declare function usersPage<const TRole extends string>(access: Pick<Acces
|
|
|
94
102
|
readonly role: Schema.String;
|
|
95
103
|
}>>;
|
|
96
104
|
readonly canChangeRoles: Schema.Boolean;
|
|
97
|
-
}>, Schema.Union<readonly [Schema.Union<readonly (typeof Forbidden | typeof AuthUnavailable)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof UsersPermission,
|
|
105
|
+
}>, Schema.Union<readonly [Schema.Union<readonly (typeof Forbidden | typeof AuthUnavailable)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof UsersPermission | (import("effect/Context").Reference<<A, E, R>(effect: Effect.Effect<A, E, R>, request: {
|
|
106
|
+
readonly rpc: import("effect/rpc/Rpc").Any;
|
|
107
|
+
readonly payload: unknown;
|
|
108
|
+
}) => Effect.Effect<A, E | import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy | import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied | import("@shivaedev/contract/WebSocketRequired.ts").WebSocketRequired | import("effect/Types").unhandled, R>> & {
|
|
109
|
+
"~effect/rpc/RpcMiddleware": "~effect/rpc/RpcMiddleware";
|
|
110
|
+
"~ClientError": never;
|
|
111
|
+
error: Schema.Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, typeof import("@shivaedev/contract/WebSocketRequired.ts").WebSocketRequired]>;
|
|
112
|
+
requiredForClient: false;
|
|
113
|
+
}), never>, readonly [], undefined>;
|
|
98
114
|
};
|
|
99
115
|
//# sourceMappingURL=page.d.ts.map
|
package/dist/users/page.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../src/users/page.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../src/users/page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAGjE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACrF,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAGhE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,eAAO,MAAM,SAAS;;;;;;;;;;EAAwE,CAAC;AAC/F,wBAAgB,SAAS,CAAC,KAAK,CAAC,KAAK,SAAS,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwB9F"}
|
package/dist/users/page.js
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import { Effect, Schema } from "effect";
|
|
2
|
-
import { LastRoleAssigner } from "@shivaedev/access/roles.ts";
|
|
3
|
-
import { collection } from "@shivaedev/changes/keys.ts";
|
|
4
2
|
import { contract } from "@shivaedev/contract/contract.ts";
|
|
5
3
|
import { command, query } from "@shivaedev/contract/operation.ts";
|
|
6
4
|
import { AuthUnavailable, Forbidden, NotFound } from "@shivaedev/errors/taxonomy.ts";
|
|
5
|
+
import { LastRoleAssigner } from "@shivaedev/identity/roles.ts";
|
|
6
|
+
import { UserList, UserListInput, userKeys } from "@shivaedev/identity/users.ts";
|
|
7
7
|
import { adminPage } from "#page.ts";
|
|
8
8
|
import { UsersPermission } from "#permissions.ts";
|
|
9
|
-
import { UserList, UserListInput } from "#users/roles.ts";
|
|
10
|
-
const users = collection("admin.users", Schema.String);
|
|
11
9
|
export const UsersList = Schema.Struct({ ...UserList.fields, canChangeRoles: Schema.Boolean });
|
|
12
10
|
export function usersPage(access) {
|
|
13
11
|
return adminPage({
|
|
14
12
|
contract: contract("admin.users", {
|
|
15
13
|
commands: [
|
|
16
14
|
command("changeRole", {
|
|
17
|
-
invalidates: () => [
|
|
15
|
+
invalidates: () => [userKeys.list],
|
|
18
16
|
payload: { role: access.Role, userId: Schema.String },
|
|
19
17
|
rejections: { AuthUnavailable, Forbidden, LastRoleAssigner, NotFound },
|
|
20
18
|
}),
|
|
@@ -23,7 +21,7 @@ export function usersPage(access) {
|
|
|
23
21
|
query("list", {
|
|
24
22
|
payload: UserListInput.fields,
|
|
25
23
|
readPolicy: () => Effect.succeed(true),
|
|
26
|
-
reads: () => [
|
|
24
|
+
reads: () => [userKeys.list],
|
|
27
25
|
rejections: { AuthUnavailable, Forbidden },
|
|
28
26
|
success: UsersList,
|
|
29
27
|
}),
|
package/dist/users/page.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page.js","sourceRoot":"","sources":["../../src/users/page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAExC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"page.js","sourceRoot":"","sources":["../../src/users/page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAExC,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACrF,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,QAAQ,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;AAC/F,MAAM,UAAU,SAAS,CAA6B,MAAyC;IAC9F,OAAO,SAAS,CAAC;QAChB,QAAQ,EAAE,QAAQ,CAAC,aAAa,EAAE;YACjC,QAAQ,EAAE;gBACT,OAAO,CAAC,YAAY,EAAE;oBACrB,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;oBAClC,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;oBACrD,UAAU,EAAE,EAAE,eAAe,EAAE,SAAS,EAAE,gBAAgB,EAAE,QAAQ,EAAE;iBACtE,CAAC;aACF;YACD,OAAO,EAAE;gBACR,KAAK,CAAC,MAAM,EAAE;oBACb,OAAO,EAAE,aAAa,CAAC,MAAM;oBAC7B,UAAU,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;oBACtC,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;oBAC5B,UAAU,EAAE,EAAE,eAAe,EAAE,SAAS,EAAE;oBAC1C,OAAO,EAAE,SAAS;iBAClB,CAAC;aACF;SACD,CAAC;QACF,EAAE,EAAE,OAAO;QACX,UAAU,EAAE,eAAe;QAC3B,KAAK,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,OAAO,EAAE;KAC/C,CAAC,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shivaedev/admin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "Explicit admin page contracts and a protected native Effect RPC registry",
|
|
5
5
|
"homepage": "https://github.com/ShivaeDev/platform/tree/main/packages/admin#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -42,21 +42,22 @@
|
|
|
42
42
|
"README.md"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@shivaedev/access": "0.
|
|
46
|
-
"@shivaedev/changes": "0.
|
|
47
|
-
"@shivaedev/contract": "0.
|
|
48
|
-
"@shivaedev/errors": "0.
|
|
49
|
-
"@shivaedev/identity": "0.
|
|
50
|
-
"@shivaedev/jobs": "0.
|
|
51
|
-
"@shivaedev/react": "0.33.0"
|
|
45
|
+
"@shivaedev/access": "0.4.0",
|
|
46
|
+
"@shivaedev/changes": "0.9.0",
|
|
47
|
+
"@shivaedev/contract": "0.32.0",
|
|
48
|
+
"@shivaedev/errors": "0.6.0",
|
|
49
|
+
"@shivaedev/identity": "0.20.0",
|
|
50
|
+
"@shivaedev/jobs": "0.31.0"
|
|
52
51
|
},
|
|
53
52
|
"devDependencies": {
|
|
54
53
|
"@effect/atom-react": "4.0.6",
|
|
55
|
-
"@shivaedev/quality": "0.
|
|
56
|
-
"@shivaedev/
|
|
57
|
-
"@shivaedev/
|
|
58
|
-
"@shivaedev/
|
|
59
|
-
"@shivaedev/
|
|
54
|
+
"@shivaedev/quality": "0.57.0",
|
|
55
|
+
"@shivaedev/rate-limit": "0.3.0",
|
|
56
|
+
"@shivaedev/react": "0.35.0",
|
|
57
|
+
"@shivaedev/server": "0.20.0",
|
|
58
|
+
"@shivaedev/sql": "0.34.0",
|
|
59
|
+
"@shivaedev/test-sql": "0.17.0",
|
|
60
|
+
"@shivaedev/test-story": "0.35.0",
|
|
60
61
|
"@types/node": "24.19.2",
|
|
61
62
|
"@types/react": "19.3.0",
|
|
62
63
|
"@types/react-dom": "19.3.0",
|
|
@@ -69,9 +70,21 @@
|
|
|
69
70
|
},
|
|
70
71
|
"peerDependencies": {
|
|
71
72
|
"@effect/atom-react": "4.0.6",
|
|
73
|
+
"@shivaedev/react": "0.35.0",
|
|
72
74
|
"effect": "4.0.6",
|
|
73
75
|
"react": "19.3.1"
|
|
74
76
|
},
|
|
77
|
+
"peerDependenciesMeta": {
|
|
78
|
+
"@effect/atom-react": {
|
|
79
|
+
"optional": true
|
|
80
|
+
},
|
|
81
|
+
"@shivaedev/react": {
|
|
82
|
+
"optional": true
|
|
83
|
+
},
|
|
84
|
+
"react": {
|
|
85
|
+
"optional": true
|
|
86
|
+
}
|
|
87
|
+
},
|
|
75
88
|
"engines": {
|
|
76
89
|
"node": ">=24"
|
|
77
90
|
},
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Option } from "effect";
|
|
2
2
|
import { useState } from "react";
|
|
3
|
+
import type { QueueDisplay } from "@shivaedev/jobs/display.ts";
|
|
3
4
|
import { useQuery } from "@shivaedev/react/client/resultState.ts";
|
|
4
5
|
import { JobDetail, JobRecord } from "./JobDetail.tsx";
|
|
5
6
|
import { JobPagination } from "./JobPagination.tsx";
|
|
@@ -12,11 +13,13 @@ export function JobList({
|
|
|
12
13
|
queue,
|
|
13
14
|
kind,
|
|
14
15
|
retry,
|
|
16
|
+
subject,
|
|
15
17
|
}: {
|
|
16
18
|
readonly api: JobsViewClient;
|
|
17
19
|
readonly queue: string;
|
|
18
20
|
readonly kind: "failed" | "deadLettered";
|
|
19
21
|
readonly retry: RetryJob | undefined;
|
|
22
|
+
readonly subject?: QueueDisplay["subject"];
|
|
20
23
|
}) {
|
|
21
24
|
const [cursors, setCursors] = useState<readonly string[]>([]);
|
|
22
25
|
const [selectedId, select] = useState<string>();
|
|
@@ -38,7 +41,7 @@ export function JobList({
|
|
|
38
41
|
{page.jobs.length === 0 ? (
|
|
39
42
|
<p>No {kind === "failed" ? "failed" : "dead-lettered"} jobs.</p>
|
|
40
43
|
) : (
|
|
41
|
-
<JobTable jobs={page.jobs} select={selectJob} />
|
|
44
|
+
<JobTable jobs={page.jobs} select={selectJob} subject={subject} />
|
|
42
45
|
)}
|
|
43
46
|
<JobPagination change={changePage} cursors={cursors} next={page.next} pending={state.pending} />
|
|
44
47
|
</>
|
|
@@ -1,8 +1,18 @@
|
|
|
1
|
+
import { Predicate } from "effect";
|
|
1
2
|
import type { ReactNode } from "react";
|
|
3
|
+
import type { QueueDisplay } from "@shivaedev/jobs/display.ts";
|
|
2
4
|
import { JobButton } from "./JobButton.tsx";
|
|
3
5
|
import type { AdminJob } from "./jobsTypes.ts";
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
interface JobTableProps {
|
|
8
|
+
readonly jobs: readonly AdminJob[];
|
|
9
|
+
readonly select: (job: AdminJob) => void;
|
|
10
|
+
readonly subject?: QueueDisplay["subject"];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const noSubjectColumns: NonNullable<QueueDisplay["subject"]> = [];
|
|
14
|
+
|
|
15
|
+
export function JobTable({ jobs, select, subject = noSubjectColumns }: JobTableProps) {
|
|
6
16
|
return (
|
|
7
17
|
<table className="block w-full text-left text-sm sm:table">
|
|
8
18
|
<caption className="sr-only">Jobs and failures</caption>
|
|
@@ -13,18 +23,31 @@ export function JobTable({ jobs, select }: { readonly jobs: readonly AdminJob[];
|
|
|
13
23
|
{label}
|
|
14
24
|
</th>
|
|
15
25
|
))}
|
|
26
|
+
{subject.map(({ field, label }) => (
|
|
27
|
+
<th className="p-3" key={field} scope="col">
|
|
28
|
+
{label}
|
|
29
|
+
</th>
|
|
30
|
+
))}
|
|
16
31
|
</tr>
|
|
17
32
|
</thead>
|
|
18
33
|
<tbody className="grid gap-4 sm:table-row-group">
|
|
19
34
|
{jobs.map((job) => (
|
|
20
|
-
<JobRow job={job} key={job.id} select={select} />
|
|
35
|
+
<JobRow job={job} key={job.id} select={select} subject={subject} />
|
|
21
36
|
))}
|
|
22
37
|
</tbody>
|
|
23
38
|
</table>
|
|
24
39
|
);
|
|
25
40
|
}
|
|
26
41
|
|
|
27
|
-
function JobRow({
|
|
42
|
+
function JobRow({
|
|
43
|
+
job,
|
|
44
|
+
select,
|
|
45
|
+
subject,
|
|
46
|
+
}: {
|
|
47
|
+
readonly job: AdminJob;
|
|
48
|
+
readonly select: (job: AdminJob) => void;
|
|
49
|
+
readonly subject: NonNullable<QueueDisplay["subject"]>;
|
|
50
|
+
}) {
|
|
28
51
|
const failure = ("sourceOutput" in job ? job.sourceOutput : job.output)?.message ?? "No failure recorded.";
|
|
29
52
|
return (
|
|
30
53
|
<tr className="block min-w-0 rounded-md border sm:table-row">
|
|
@@ -34,10 +57,23 @@ function JobRow({ job, select }: { readonly job: AdminJob; readonly select: (job
|
|
|
34
57
|
<JobCell label="State">{job.state}</JobCell>
|
|
35
58
|
<JobCell label="Attempt">{job.attempt}</JobCell>
|
|
36
59
|
<JobCell label="Failure">{failure}</JobCell>
|
|
60
|
+
{subject.map(({ field, label }) => (
|
|
61
|
+
<JobCell key={field} label={label}>
|
|
62
|
+
{subjectValue(job.data, field)}
|
|
63
|
+
</JobCell>
|
|
64
|
+
))}
|
|
37
65
|
</tr>
|
|
38
66
|
);
|
|
39
67
|
}
|
|
40
68
|
|
|
69
|
+
function subjectValue(data: unknown, field: string): string {
|
|
70
|
+
const value = Predicate.isObject(data) ? data[field] : undefined;
|
|
71
|
+
if (value === undefined || value === null) {
|
|
72
|
+
return "—";
|
|
73
|
+
}
|
|
74
|
+
return typeof value === "string" ? value : JSON.stringify(value);
|
|
75
|
+
}
|
|
76
|
+
|
|
41
77
|
function JobCell({ label, children }: { readonly label: string; readonly children: ReactNode }) {
|
|
42
78
|
return (
|
|
43
79
|
<td className="block min-w-0 p-3 wrap-anywhere sm:table-cell">
|
|
@@ -1,17 +1,30 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
|
+
import type { QueueDisplay } from "@shivaedev/jobs/display.ts";
|
|
2
3
|
import { useQuery } from "@shivaedev/react/client/resultState.ts";
|
|
3
4
|
import { JobList } from "./JobList.tsx";
|
|
4
5
|
import { JobsMetrics } from "./JobsMetrics.tsx";
|
|
5
6
|
import { JobsQueryPanel } from "./JobsQueryPanel.tsx";
|
|
6
7
|
import type { JobsViewClient, RetryJob } from "./jobsTypes.ts";
|
|
7
8
|
|
|
8
|
-
export function JobsQueueView({
|
|
9
|
+
export function JobsQueueView({
|
|
10
|
+
api,
|
|
11
|
+
label,
|
|
12
|
+
queue,
|
|
13
|
+
retry,
|
|
14
|
+
subject,
|
|
15
|
+
}: {
|
|
16
|
+
readonly api: JobsViewClient;
|
|
17
|
+
readonly label?: string | undefined;
|
|
18
|
+
readonly queue: string;
|
|
19
|
+
readonly retry: RetryJob | undefined;
|
|
20
|
+
readonly subject?: QueueDisplay["subject"];
|
|
21
|
+
}) {
|
|
9
22
|
const [kind, setKind] = useState<"failed" | "deadLettered">("failed");
|
|
10
23
|
const counts = useQuery(api.counts.query({ queue }));
|
|
11
24
|
return (
|
|
12
25
|
<>
|
|
13
26
|
<section aria-label="Queue counts" className="space-y-4">
|
|
14
|
-
<h2 className="text-xl font-semibold">
|
|
27
|
+
<h2 className="text-xl font-semibold">{label ?? queue}</h2>
|
|
15
28
|
<JobsQueryPanel state={counts}>
|
|
16
29
|
{(value) => (
|
|
17
30
|
<JobsMetrics values={{ Active: value.activeCount, Failed: value.failedCount, Queued: value.queuedCount, Total: value.totalCount }} />
|
|
@@ -24,7 +37,7 @@ export function JobsQueueView({ api, queue, retry }: { readonly api: JobsViewCli
|
|
|
24
37
|
["failed", "Failed"],
|
|
25
38
|
["deadLettered", "Dead-lettered"],
|
|
26
39
|
] as const
|
|
27
|
-
).map(([value,
|
|
40
|
+
).map(([value, tabLabel]) => (
|
|
28
41
|
<button
|
|
29
42
|
aria-controls={`jobs-${value}-panel`}
|
|
30
43
|
aria-selected={kind === value}
|
|
@@ -35,12 +48,12 @@ export function JobsQueueView({ api, queue, retry }: { readonly api: JobsViewCli
|
|
|
35
48
|
role="tab"
|
|
36
49
|
type="button"
|
|
37
50
|
>
|
|
38
|
-
{
|
|
51
|
+
{tabLabel}
|
|
39
52
|
</button>
|
|
40
53
|
))}
|
|
41
54
|
</div>
|
|
42
55
|
<div aria-labelledby={`jobs-${kind}-tab`} id={`jobs-${kind}-panel`} role="tabpanel">
|
|
43
|
-
<JobList api={api} key={kind} kind={kind} queue={queue} retry={retry} />
|
|
56
|
+
<JobList api={api} key={kind} kind={kind} queue={queue} retry={retry} subject={subject} />
|
|
44
57
|
</div>
|
|
45
58
|
</>
|
|
46
59
|
);
|
|
@@ -51,7 +64,7 @@ export function JobsQueuePicker({
|
|
|
51
64
|
select,
|
|
52
65
|
value,
|
|
53
66
|
}: {
|
|
54
|
-
readonly queues: readonly string[];
|
|
67
|
+
readonly queues: readonly (string | QueueDisplay)[];
|
|
55
68
|
readonly select: (queue: string) => void;
|
|
56
69
|
readonly value: string;
|
|
57
70
|
}) {
|
|
@@ -63,11 +76,14 @@ export function JobsQueuePicker({
|
|
|
63
76
|
onChange={(event) => select(event.target.value)}
|
|
64
77
|
value={value}
|
|
65
78
|
>
|
|
66
|
-
{queues.map((
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
79
|
+
{queues.map((queue) => {
|
|
80
|
+
const { name, label } = typeof queue === "string" ? { name: queue } : queue;
|
|
81
|
+
return (
|
|
82
|
+
<option key={name} value={name}>
|
|
83
|
+
{label ?? name}
|
|
84
|
+
</option>
|
|
85
|
+
);
|
|
86
|
+
})}
|
|
71
87
|
</select>
|
|
72
88
|
</label>
|
|
73
89
|
);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Cause, Option, Predicate } from "effect";
|
|
2
2
|
import { createElement, useState } from "react";
|
|
3
|
+
import type { QueueDisplay } from "@shivaedev/jobs/display.ts";
|
|
3
4
|
import { useQuery } from "@shivaedev/react/client/resultState.ts";
|
|
4
5
|
import { JobsHealthMetrics } from "./JobsMetrics.tsx";
|
|
5
6
|
import { JobsQueuePicker, JobsQueueView } from "./JobsQueueView.tsx";
|
|
@@ -7,12 +8,14 @@ import type { JobsViewClient, RetryJob } from "./jobsTypes.ts";
|
|
|
7
8
|
|
|
8
9
|
export interface JobsViewProps {
|
|
9
10
|
readonly api: JobsViewClient;
|
|
10
|
-
readonly queues: readonly string[];
|
|
11
|
+
readonly queues: readonly (string | QueueDisplay)[];
|
|
11
12
|
readonly retry?: RetryJob | undefined;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
export function JobsView({ api, queues, retry }: JobsViewProps) {
|
|
15
|
-
const
|
|
16
|
+
const definitions = queues.map((definition) => (typeof definition === "string" ? { name: definition } : definition));
|
|
17
|
+
const [name, selectQueue] = useState(definitions[0]?.name ?? "");
|
|
18
|
+
const queue = definitions.find((candidate) => candidate.name === name);
|
|
16
19
|
const health = useQuery(api.health.query(undefined));
|
|
17
20
|
const denied = Option.exists(Option.flatMap(health.cause, Cause.findErrorOption), (error) => Predicate.isTagged(error, "Forbidden"));
|
|
18
21
|
if (denied) {
|
|
@@ -22,13 +25,13 @@ export function JobsView({ api, queues, retry }: JobsViewProps) {
|
|
|
22
25
|
"div",
|
|
23
26
|
{ className: "min-w-0 space-y-8" },
|
|
24
27
|
createElement(JobsHealthMetrics, { state: health }),
|
|
25
|
-
|
|
28
|
+
queue === undefined
|
|
26
29
|
? createElement("p", null, "No queues or schedules registered.")
|
|
27
30
|
: createElement(
|
|
28
31
|
"div",
|
|
29
32
|
{ className: "min-w-0 space-y-6" },
|
|
30
|
-
createElement(JobsQueuePicker, { queues, select: selectQueue, value:
|
|
31
|
-
createElement(JobsQueueView, { api, key: queue, queue, retry }),
|
|
33
|
+
createElement(JobsQueuePicker, { queues: definitions, select: selectQueue, value: name }),
|
|
34
|
+
createElement(JobsQueueView, { api, key: name, label: queue.label, queue: name, retry, subject: queue.subject }),
|
|
32
35
|
),
|
|
33
36
|
);
|
|
34
37
|
}
|
|
@@ -3,8 +3,8 @@ import type * as AsyncResult from "effect/reactivity/AsyncResult";
|
|
|
3
3
|
import type * as Atom from "effect/reactivity/Atom";
|
|
4
4
|
import { createElement, useState } from "react";
|
|
5
5
|
import type { SessionList, SessionListInput, SignedInSession } from "@shivaedev/identity/sessions.ts";
|
|
6
|
+
import type { AtomServices } from "@shivaedev/react/AtomServices.ts";
|
|
6
7
|
import { useAction, useQuery } from "@shivaedev/react/client/resultState.ts";
|
|
7
|
-
import type { AtomServices } from "@shivaedev/react/fieldRejection.ts";
|
|
8
8
|
import { SessionConfirmation } from "./SessionConfirmation.tsx";
|
|
9
9
|
import { SessionListView } from "./SessionListView.tsx";
|
|
10
10
|
import { SessionPagination } from "./SessionPagination.tsx";
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { DateTime } from "effect";
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
|
+
import type { DirectoryUser } from "@shivaedev/identity/users.ts";
|
|
4
|
+
import type { ChangeRoleInput } from "#users/ChangeRoleInput.ts";
|
|
3
5
|
import type { UsersList } from "#users/page.ts";
|
|
4
|
-
import type { AppUser, ChangeRoleInput } from "#users/roles.ts";
|
|
5
6
|
|
|
6
7
|
interface RoleControls<TRole extends string> {
|
|
7
8
|
readonly dispatch: (input: ChangeRoleInput<TRole>) => void;
|
|
@@ -16,7 +17,7 @@ function UserRole<TRole extends string>({
|
|
|
16
17
|
pending,
|
|
17
18
|
dispatch,
|
|
18
19
|
}: RoleControls<TRole> & {
|
|
19
|
-
readonly user: typeof
|
|
20
|
+
readonly user: typeof DirectoryUser.Type;
|
|
20
21
|
readonly canChangeRoles: boolean;
|
|
21
22
|
}) {
|
|
22
23
|
if (!canChangeRoles) {
|
|
@@ -48,7 +49,7 @@ function UserRow<TRole extends string>({
|
|
|
48
49
|
user,
|
|
49
50
|
canChangeRoles,
|
|
50
51
|
...controls
|
|
51
|
-
}: RoleControls<TRole> & { readonly user: typeof
|
|
52
|
+
}: RoleControls<TRole> & { readonly user: typeof DirectoryUser.Type; readonly canChangeRoles: boolean }) {
|
|
52
53
|
return (
|
|
53
54
|
<tr className="block min-w-0 rounded-md border sm:table-row sm:rounded-none sm:border-0 sm:border-b">
|
|
54
55
|
<UserCell label="Name">{user.name}</UserCell>
|
|
@@ -2,9 +2,10 @@ import { Cause, Option, Predicate } from "effect";
|
|
|
2
2
|
import type * as AsyncResult from "effect/reactivity/AsyncResult";
|
|
3
3
|
import type * as Atom from "effect/reactivity/Atom";
|
|
4
4
|
import { createElement, useState } from "react";
|
|
5
|
+
import type { UserListInput } from "@shivaedev/identity/users.ts";
|
|
5
6
|
import { useAction, useQuery } from "@shivaedev/react/client/resultState.ts";
|
|
7
|
+
import type { ChangeRoleInput } from "#users/ChangeRoleInput.ts";
|
|
6
8
|
import type { UsersList } from "#users/page.ts";
|
|
7
|
-
import type { ChangeRoleInput, UserListInput } from "#users/roles.ts";
|
|
8
9
|
import { UsersTable } from "./UsersTable.tsx";
|
|
9
10
|
|
|
10
11
|
export interface UsersViewProps<TRole extends string> {
|
package/src/jobs/entry.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
+
import type { QueueDisplay } from "@shivaedev/jobs/display.ts";
|
|
2
3
|
import type { JobsQueue } from "./schemas.ts";
|
|
3
4
|
|
|
4
|
-
export type JobsEntry = JobsQueue | { readonly name: string };
|
|
5
|
+
export type JobsEntry = (JobsQueue | { readonly name: string }) & QueueDisplay;
|
|
5
6
|
|
|
6
7
|
export type JobsPayload<TEntry extends JobsEntry> = [TEntry] extends [never]
|
|
7
8
|
? typeof Schema.Never
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type Context, DateTime, Effect, Option, Schema } from "effect";
|
|
1
|
+
import { type Context, DateTime, Effect, Option, type Schema } from "effect";
|
|
2
2
|
import { BadRequest } from "@shivaedev/errors/taxonomy.ts";
|
|
3
|
-
import { JobFailure } from "@shivaedev/jobs/JobFailure.ts";
|
|
4
3
|
import type { PgBossError, PgBossPayloadError } from "@shivaedev/jobs/server/error.ts";
|
|
4
|
+
import { readJobFailure } from "@shivaedev/jobs/server/readJobFailure.ts";
|
|
5
5
|
import type { PgBossService } from "@shivaedev/jobs/server/service.ts";
|
|
6
6
|
import { type JobsEntry, type JobsPayload, jobsQueue } from "#jobs/entry.ts";
|
|
7
7
|
import type { jobsPage } from "#jobs/page.ts";
|
|
@@ -64,9 +64,7 @@ export function jobsReadHandlers<const TQueues extends readonly JobsEntry[], TSe
|
|
|
64
64
|
return Option.none();
|
|
65
65
|
}
|
|
66
66
|
const job = result.value;
|
|
67
|
-
const output = yield*
|
|
68
|
-
Effect.mapError(() => new JobsPayloadInvalid({ queue })),
|
|
69
|
-
);
|
|
67
|
+
const output = yield* jobsFailures(readJobFailure(queue, job.output));
|
|
70
68
|
return Option.some({
|
|
71
69
|
attempt: job.startedOn === null ? 0 : job.retryCount + 1,
|
|
72
70
|
completedOn: Option.map(Option.fromNullishOr(job.completedOn), DateTime.makeUnsafe),
|
package/src/server/users.ts
CHANGED
|
@@ -1,47 +1,21 @@
|
|
|
1
|
-
import { DateTime, Effect
|
|
2
|
-
import { SqlClient, SqlSchema } from "effect/sql";
|
|
1
|
+
import { DateTime, Effect } from "effect";
|
|
3
2
|
import { requirePermission } from "@shivaedev/access/requirePermission.ts";
|
|
4
|
-
import type { AccessPolicy } from "@shivaedev/access/roleSet.ts";
|
|
5
|
-
import { AssignRoles } from "@shivaedev/access/roles.ts";
|
|
6
|
-
import { AuthUnavailable } from "@shivaedev/errors/taxonomy.ts";
|
|
7
3
|
import { SessionUser } from "@shivaedev/identity/identity.ts";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
4
|
+
import { AssignRoles } from "@shivaedev/identity/roles.ts";
|
|
5
|
+
import { UserDirectory } from "@shivaedev/identity/server/UserDirectory.ts";
|
|
6
|
+
import type { UserListInput } from "@shivaedev/identity/users.ts";
|
|
10
7
|
import { ReadUsers } from "#permissions.ts";
|
|
11
|
-
import {
|
|
8
|
+
import type { ChangeRoleInput } from "#users/ChangeRoleInput.ts";
|
|
12
9
|
|
|
13
|
-
function
|
|
14
|
-
return new AuthUnavailable({ message: "Could not access app users" });
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const listUsers = Effect.fn("Admin.listUsers")(function* <TRole extends string>(
|
|
18
|
-
access: Pick<AccessPolicy<TRole>, "Role">,
|
|
19
|
-
input: typeof UserListInput.Type,
|
|
20
|
-
options?: AuthTableOptions,
|
|
21
|
-
) {
|
|
10
|
+
export const listUsers = Effect.fn("Admin.listUsers")(function* (input: typeof UserListInput.Type) {
|
|
22
11
|
yield* requirePermission(yield* SessionUser, ReadUsers);
|
|
23
|
-
|
|
24
|
-
const { user } = tables(options);
|
|
25
|
-
const read = SqlSchema.findAll({
|
|
26
|
-
execute: () => sql`select id, ${sql(user.name)} as name, ${sql(user.email)} as email,
|
|
27
|
-
${sql(user.role)} as role, ${sql(user.createdAt)} as "createdAt" from ${sql(user.table)}
|
|
28
|
-
where id > ${input.cursor ?? ""} order by id limit ${input.limit + 1}`,
|
|
29
|
-
Request: Schema.Void,
|
|
30
|
-
Result: Schema.Struct({ ...AppUser.fields, role: access.Role }),
|
|
31
|
-
});
|
|
32
|
-
const rows = yield* read(undefined).pipe(Effect.mapError(unavailable));
|
|
33
|
-
const users = rows.slice(0, input.limit);
|
|
34
|
-
return { next: rows.length > input.limit ? Option.fromUndefinedOr(users.at(-1)?.id) : Option.none<string>(), users };
|
|
12
|
+
return yield* (yield* UserDirectory).list(input);
|
|
35
13
|
});
|
|
36
14
|
|
|
37
|
-
export const changeUserRole = Effect.fn("Admin.changeUserRole")(function*
|
|
38
|
-
access: Pick<AccessPolicy<TRole>, "Role" | "hasPermission">,
|
|
39
|
-
input: ChangeRoleInput<TRole>,
|
|
40
|
-
options?: AuthTableOptions,
|
|
41
|
-
) {
|
|
15
|
+
export const changeUserRole = Effect.fn("Admin.changeUserRole")(function* (input: ChangeRoleInput) {
|
|
42
16
|
const actor = yield* SessionUser;
|
|
43
17
|
yield* requirePermission(actor, AssignRoles);
|
|
44
|
-
const changed = yield* assignRole(
|
|
18
|
+
const changed = yield* (yield* UserDirectory).assignRole(input.userId, input.role);
|
|
45
19
|
if (changed) {
|
|
46
20
|
const changedAt = DateTime.formatIso(yield* DateTime.now);
|
|
47
21
|
yield* Effect.logInfo("User role changed").pipe(Effect.annotateLogs({ actorId: actor.id, changedAt, ...input }));
|