@shivaedev/admin 0.25.0 → 0.26.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.
Files changed (61) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +16 -0
  3. package/dist/client/adapters/JobDetail.d.ts +5 -2
  4. package/dist/client/adapters/JobDetail.d.ts.map +1 -1
  5. package/dist/client/adapters/JobDetail.js +13 -9
  6. package/dist/client/adapters/JobDetail.js.map +1 -1
  7. package/dist/client/adapters/JobList.d.ts +3 -1
  8. package/dist/client/adapters/JobList.d.ts.map +1 -1
  9. package/dist/client/adapters/JobList.js +3 -3
  10. package/dist/client/adapters/JobList.js.map +1 -1
  11. package/dist/client/adapters/JobsQueueView.d.ts +3 -1
  12. package/dist/client/adapters/JobsQueueView.d.ts.map +1 -1
  13. package/dist/client/adapters/JobsQueueView.js +2 -2
  14. package/dist/client/adapters/JobsQueueView.js.map +1 -1
  15. package/dist/client/adapters/JobsView.d.ts +3 -2
  16. package/dist/client/adapters/JobsView.d.ts.map +1 -1
  17. package/dist/client/adapters/JobsView.js +10 -2
  18. package/dist/client/adapters/JobsView.js.map +1 -1
  19. package/dist/client/adapters/SessionListView.d.ts +2 -0
  20. package/dist/client/adapters/SessionListView.d.ts.map +1 -1
  21. package/dist/client/adapters/SessionListView.js +5 -5
  22. package/dist/client/adapters/SessionListView.js.map +1 -1
  23. package/dist/client/adapters/SessionsView.d.ts +3 -2
  24. package/dist/client/adapters/SessionsView.d.ts.map +1 -1
  25. package/dist/client/adapters/SessionsView.js +10 -2
  26. package/dist/client/adapters/SessionsView.js.map +1 -1
  27. package/dist/client/adapters/Timestamp.d.ts +8 -0
  28. package/dist/client/adapters/Timestamp.d.ts.map +1 -0
  29. package/dist/client/adapters/Timestamp.js +7 -0
  30. package/dist/client/adapters/Timestamp.js.map +1 -0
  31. package/dist/client/adapters/UsersTable.d.ts +2 -0
  32. package/dist/client/adapters/UsersTable.d.ts.map +1 -1
  33. package/dist/client/adapters/UsersTable.js +3 -3
  34. package/dist/client/adapters/UsersTable.js.map +1 -1
  35. package/dist/client/adapters/UsersView.d.ts +3 -2
  36. package/dist/client/adapters/UsersView.d.ts.map +1 -1
  37. package/dist/client/adapters/UsersView.js +4 -2
  38. package/dist/client/adapters/UsersView.js.map +1 -1
  39. package/dist/client/adapters/timestampText.d.ts +7 -0
  40. package/dist/client/adapters/timestampText.d.ts.map +1 -0
  41. package/dist/client/adapters/timestampText.js +9 -0
  42. package/dist/client/adapters/timestampText.js.map +1 -0
  43. package/dist/jobs/Page.d.ts +6 -1
  44. package/dist/jobs/Page.d.ts.map +1 -1
  45. package/dist/jobs/PageWithRetry.d.ts +6 -1
  46. package/dist/jobs/PageWithRetry.d.ts.map +1 -1
  47. package/dist/sessions/Page.d.ts +6 -1
  48. package/dist/sessions/Page.d.ts.map +1 -1
  49. package/dist/users/Page.d.ts +6 -1
  50. package/dist/users/Page.d.ts.map +1 -1
  51. package/package.json +15 -15
  52. package/src/client/adapters/JobDetail.tsx +23 -8
  53. package/src/client/adapters/JobList.tsx +5 -2
  54. package/src/client/adapters/JobsQueueView.tsx +4 -1
  55. package/src/client/adapters/JobsView.ts +12 -3
  56. package/src/client/adapters/SessionListView.tsx +7 -5
  57. package/src/client/adapters/SessionsView.ts +12 -3
  58. package/src/client/adapters/Timestamp.tsx +18 -0
  59. package/src/client/adapters/UsersTable.tsx +6 -5
  60. package/src/client/adapters/UsersView.ts +6 -3
  61. package/src/client/adapters/timestampText.ts +17 -0
@@ -1 +1 @@
1
- {"version":3,"file":"UsersView.js","sourceRoot":"","sources":["../../../src/client/adapters/UsersView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAGlD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEhD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAA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,IAAI,EACvG,IAAI,KAAK,SAAS;QACjB,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,aAAa,CAAC,UAAiB,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC,EACrI,IAAI,KAAK,SAAS;QACjB,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,aAAa,CACb,KAAK,EACL,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,EACvD,aAAa,CACZ,QAAQ,EACR;YACC,SAAS,EAAE,iDAAiD;YAC5D,QAAQ,EAAE,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,OAAO;YAC/C,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YAC/C,IAAI,EAAE,QAAQ;SACd,EACD,gBAAgB,CAChB,EACD,aAAa,CACZ,QAAQ,EACR;YACC,SAAS,EAAE,iDAAiD;YAC5D,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,OAAO;YACnD,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;YAC9E,IAAI,EAAE,QAAQ;SACd,EACD,YAAY,CACZ,CACD,CACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { DateTime } from "effect";
2
+ export interface DateDisplay {
3
+ readonly locale?: string | undefined;
4
+ readonly timeZone?: string | undefined;
5
+ }
6
+ export declare function timestampText(time: DateTime.DateTime, { locale, timeZone }: DateDisplay): string;
7
+ //# sourceMappingURL=timestampText.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timestampText.d.ts","sourceRoot":"","sources":["../../../src/client/adapters/timestampText.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAU,MAAM,QAAQ,CAAC;AAE1C,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACvC;AAID,wBAAgB,aAAa,CAAC,IAAI,EAAE,QAAQ,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,WAAW,GAAG,MAAM,CAOhG"}
@@ -0,0 +1,9 @@
1
+ import { DateTime, Option } from "effect";
2
+ const STYLE = { dateStyle: "medium", timeStyle: "long" };
3
+ export function timestampText(time, { locale, timeZone }) {
4
+ const options = locale === undefined ? STYLE : { ...STYLE, locale };
5
+ // Intl throws on a locale or time zone it cannot read, and a saved preference must not take the page down with it.
6
+ const preferred = Option.liftThrowable(() => timeZone === undefined ? DateTime.formatLocal(time, options) : DateTime.format(time, { ...options, timeZone }))();
7
+ return Option.getOrElse(preferred, () => DateTime.formatLocal(time, STYLE));
8
+ }
9
+ //# sourceMappingURL=timestampText.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timestampText.js","sourceRoot":"","sources":["../../../src/client/adapters/timestampText.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAO1C,MAAM,KAAK,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAW,CAAC;AAElE,MAAM,UAAU,aAAa,CAAC,IAAuB,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAe;IACvF,MAAM,OAAO,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,CAAC;IACpE,mHAAmH;IACnH,MAAM,SAAS,GAAG,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE,CAC3C,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,GAAG,OAAO,EAAE,QAAQ,EAAE,CAAC,CAC9G,EAAE,CAAC;IACJ,OAAO,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;AAC7E,CAAC"}
@@ -128,7 +128,12 @@ export declare const JobsPage: import("#page.ts").AdminPage & {
128
128
  readonly queue: import("effect/Schema").String;
129
129
  }>;
130
130
  }>)[]>>;
131
- }>, import("effect/rpc/RpcSchema").Stream<import("effect/Schema").Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, ...(import("effect/Schema").Struct<{
131
+ }>, import("effect/rpc/RpcSchema").Stream<import("effect/Schema").Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, import("effect/Schema").Struct<{
132
+ readonly _tag: import("effect/Schema").Literal<"Syncing">;
133
+ }>, import("effect/Schema").Struct<{
134
+ readonly _tag: import("effect/Schema").Literal<"Synced">;
135
+ readonly ids: import("effect/Schema").$Array<import("effect/Schema").Number>;
136
+ }>, ...(import("effect/Schema").Struct<{
132
137
  readonly _tag: import("effect/Schema").Literal<"Unchanged">;
133
138
  readonly queryIndex: import("effect/Schema").Number;
134
139
  }> | import("effect/Schema").Struct<{
@@ -1 +1 @@
1
- {"version":3,"file":"Page.d.ts","sourceRoot":"","sources":["../../src/jobs/Page.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAKnB,CAAC"}
1
+ {"version":3,"file":"Page.d.ts","sourceRoot":"","sources":["../../src/jobs/Page.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAKnB,CAAC"}
@@ -147,7 +147,12 @@ export declare const JobsPageWithRetry: import("#page.ts").AdminPage & {
147
147
  readonly queue: import("effect/Schema").String;
148
148
  }>;
149
149
  }>)[]>>;
150
- }>, import("effect/rpc/RpcSchema").Stream<import("effect/Schema").Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, ...(import("effect/Schema").Struct<{
150
+ }>, import("effect/rpc/RpcSchema").Stream<import("effect/Schema").Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, import("effect/Schema").Struct<{
151
+ readonly _tag: import("effect/Schema").Literal<"Syncing">;
152
+ }>, import("effect/Schema").Struct<{
153
+ readonly _tag: import("effect/Schema").Literal<"Synced">;
154
+ readonly ids: import("effect/Schema").$Array<import("effect/Schema").Number>;
155
+ }>, ...(import("effect/Schema").Struct<{
151
156
  readonly _tag: import("effect/Schema").Literal<"Unchanged">;
152
157
  readonly queryIndex: import("effect/Schema").Number;
153
158
  }> | import("effect/Schema").Struct<{
@@ -1 +1 @@
1
- {"version":3,"file":"PageWithRetry.d.ts","sourceRoot":"","sources":["../../src/jobs/PageWithRetry.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAK5B,CAAC"}
1
+ {"version":3,"file":"PageWithRetry.d.ts","sourceRoot":"","sources":["../../src/jobs/PageWithRetry.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAK5B,CAAC"}
@@ -62,7 +62,12 @@ export declare const SessionsPage: import("#page.ts").AdminPage & {
62
62
  readonly limit: import("effect/Schema").Number;
63
63
  }>;
64
64
  }>[]>>;
65
- }>, import("effect/rpc/RpcSchema").Stream<import("effect/Schema").Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, ...(import("effect/Schema").Struct<{
65
+ }>, import("effect/rpc/RpcSchema").Stream<import("effect/Schema").Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, import("effect/Schema").Struct<{
66
+ readonly _tag: import("effect/Schema").Literal<"Syncing">;
67
+ }>, import("effect/Schema").Struct<{
68
+ readonly _tag: import("effect/Schema").Literal<"Synced">;
69
+ readonly ids: import("effect/Schema").$Array<import("effect/Schema").Number>;
70
+ }>, ...(import("effect/Schema").Struct<{
66
71
  readonly _tag: import("effect/Schema").Literal<"Unchanged">;
67
72
  readonly queryIndex: import("effect/Schema").Number;
68
73
  }> | import("effect/Schema").Struct<{
@@ -1 +1 @@
1
- {"version":3,"file":"Page.d.ts","sourceRoot":"","sources":["../../src/sessions/Page.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAG/E,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAKvB,CAAC"}
1
+ {"version":3,"file":"Page.d.ts","sourceRoot":"","sources":["../../src/sessions/Page.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAG/E,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAKvB,CAAC"}
@@ -49,7 +49,12 @@ export declare const UsersPage: import("#page.ts").AdminPage & {
49
49
  readonly limit: import("effect/Schema").Number;
50
50
  }>;
51
51
  }>[]>>;
52
- }>, import("effect/rpc/RpcSchema").Stream<import("effect/Schema").Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, ...(import("effect/Schema").Struct<{
52
+ }>, import("effect/rpc/RpcSchema").Stream<import("effect/Schema").Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, import("effect/Schema").Struct<{
53
+ readonly _tag: import("effect/Schema").Literal<"Syncing">;
54
+ }>, import("effect/Schema").Struct<{
55
+ readonly _tag: import("effect/Schema").Literal<"Synced">;
56
+ readonly ids: import("effect/Schema").$Array<import("effect/Schema").Number>;
57
+ }>, ...(import("effect/Schema").Struct<{
53
58
  readonly _tag: import("effect/Schema").Literal<"Unchanged">;
54
59
  readonly queryIndex: import("effect/Schema").Number;
55
60
  }> | import("effect/Schema").Struct<{
@@ -1 +1 @@
1
- {"version":3,"file":"Page.d.ts","sourceRoot":"","sources":["../../src/users/Page.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAKpB,CAAC"}
1
+ {"version":3,"file":"Page.d.ts","sourceRoot":"","sources":["../../src/users/Page.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAKpB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shivaedev/admin",
3
- "version": "0.25.0",
3
+ "version": "0.26.1",
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": {
@@ -48,23 +48,23 @@
48
48
  ],
49
49
  "dependencies": {
50
50
  "@shivaedev/access": "0.6.3",
51
- "@shivaedev/changes": "0.12.0",
52
- "@shivaedev/contract": "0.44.0",
51
+ "@shivaedev/changes": "0.13.0",
52
+ "@shivaedev/contract": "0.46.0",
53
53
  "@shivaedev/errors": "0.12.0",
54
- "@shivaedev/identity": "0.32.0",
55
- "@shivaedev/jobs": "0.42.2"
54
+ "@shivaedev/identity": "0.32.2",
55
+ "@shivaedev/jobs": "0.42.4"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@effect/atom-react": "4.1.2",
59
- "@shivaedev/build": "0.1.1",
60
- "@shivaedev/quality": "0.78.0",
61
- "@shivaedev/rate-limit": "0.6.10",
62
- "@shivaedev/react": "0.47.3",
63
- "@shivaedev/server": "0.34.1",
64
- "@shivaedev/sql": "0.47.0",
65
- "@shivaedev/test-kits": "0.12.1",
66
- "@shivaedev/test-sql": "0.25.0",
67
- "@shivaedev/test-story": "0.47.1",
59
+ "@shivaedev/build": "0.2.1",
60
+ "@shivaedev/quality": "0.78.2",
61
+ "@shivaedev/rate-limit": "0.6.12",
62
+ "@shivaedev/react": "0.48.1",
63
+ "@shivaedev/server": "0.35.0",
64
+ "@shivaedev/sql": "0.49.0",
65
+ "@shivaedev/test-kits": "0.13.1",
66
+ "@shivaedev/test-sql": "0.25.2",
67
+ "@shivaedev/test-story": "0.47.3",
68
68
  "@types/node": "24.19.2",
69
69
  "@types/react": "19.3.0",
70
70
  "@types/react-dom": "19.3.0",
@@ -77,7 +77,7 @@
77
77
  },
78
78
  "peerDependencies": {
79
79
  "@effect/atom-react": "4.1.2",
80
- "@shivaedev/react": "0.47.3",
80
+ "@shivaedev/react": "0.48.1",
81
81
  "effect": "4.1.2",
82
82
  "react": "19.3.1"
83
83
  },
@@ -1,16 +1,20 @@
1
- import { DateTime, Option } from "effect";
1
+ import { type DateTime, Option } from "effect";
2
2
  import { useAction, useQuery } from "@shivaedev/react/client/resultState.ts";
3
3
  import { JobButton } from "#client/adapters/JobButton.tsx";
4
4
  import { JobsQueryPanel } from "#client/adapters/JobsQueryPanel.tsx";
5
5
  import type { AdminJob, JobsViewClient, RetryJob } from "#client/adapters/jobsTypes.ts";
6
+ import { Timestamp } from "#client/adapters/Timestamp.tsx";
7
+ import type { DateDisplay } from "#client/adapters/timestampText.ts";
6
8
 
7
9
  export function JobDetail({
8
10
  api,
11
+ dates,
9
12
  queue,
10
13
  id,
11
14
  retry,
12
15
  }: {
13
16
  readonly api: JobsViewClient;
17
+ readonly dates: DateDisplay;
14
18
  readonly queue: string;
15
19
  readonly id: string;
16
20
  readonly retry: RetryJob | undefined;
@@ -19,19 +23,30 @@ export function JobDetail({
19
23
  return (
20
24
  <section aria-label="Job detail">
21
25
  <h2 className="mb-4 text-xl font-semibold">Job detail</h2>
22
- <JobsQueryPanel state={state}>{(job) => <JobResult job={job} retry={retry} />}</JobsQueryPanel>
26
+ <JobsQueryPanel state={state}>{(job) => <JobResult dates={dates} job={job} retry={retry} />}</JobsQueryPanel>
23
27
  </section>
24
28
  );
25
29
  }
26
30
 
27
- function JobResult({ job, retry }: { readonly job: Option.Option<AdminJob>; readonly retry: RetryJob | undefined }) {
31
+ function JobResult({
32
+ dates,
33
+ job,
34
+ retry,
35
+ }: {
36
+ readonly dates: DateDisplay;
37
+ readonly job: Option.Option<AdminJob>;
38
+ readonly retry: RetryJob | undefined;
39
+ }) {
28
40
  if (Option.isNone(job)) {
29
41
  return <p>Job not found.</p>;
30
42
  }
31
- return <JobRecord job={job.value} retry={retry} />;
43
+ return <JobRecord dates={dates} job={job.value} retry={retry} />;
32
44
  }
33
45
 
34
- export function JobRecord({ job, retry }: { readonly job: AdminJob; readonly retry?: RetryJob | undefined }) {
46
+ export function JobRecord({ dates, job, retry }: { readonly dates: DateDisplay; readonly job: AdminJob; readonly retry?: RetryJob | undefined }) {
47
+ function shown(time: DateTime.DateTime) {
48
+ return <Timestamp dates={dates} time={time} />;
49
+ }
35
50
  const failure = ("sourceOutput" in job ? job.sourceOutput : job.output)?.message ?? "No failure recorded.";
36
51
  const deadLetterDetails =
37
52
  "sourceId" in job ? (
@@ -48,12 +63,12 @@ export function JobRecord({ job, retry }: { readonly job: AdminJob; readonly ret
48
63
  <dl className="grid min-w-0 gap-3 text-sm wrap-anywhere sm:grid-cols-2">
49
64
  {Object.entries({
50
65
  Attempt: job.attempt,
51
- Completed: Option.match(job.completedOn, { onNone: () => "—", onSome: DateTime.formatIso }),
52
- Created: DateTime.formatIso(job.createdOn),
66
+ Completed: Option.match(job.completedOn, { onNone: () => "—", onSome: shown }),
67
+ Created: shown(job.createdOn),
53
68
  "ID": job.id,
54
69
  Queue: job.queue,
55
70
  "Retry count / limit": `${job.retryCount} / ${job.retryLimit}`,
56
- Started: Option.match(job.startedOn, { onNone: () => "—", onSome: DateTime.formatIso }),
71
+ Started: Option.match(job.startedOn, { onNone: () => "—", onSome: shown }),
57
72
  State: job.state,
58
73
  }).map(([label, value]) => (
59
74
  <div key={label}>
@@ -7,15 +7,18 @@ import { JobPagination } from "#client/adapters/JobPagination.tsx";
7
7
  import { JobsQueryPanel } from "#client/adapters/JobsQueryPanel.tsx";
8
8
  import { JobTable } from "#client/adapters/JobTable.tsx";
9
9
  import type { AdminJob, JobsViewClient, RetryJob } from "#client/adapters/jobsTypes.ts";
10
+ import type { DateDisplay } from "#client/adapters/timestampText.ts";
10
11
 
11
12
  export function JobList({
12
13
  api,
14
+ dates,
13
15
  queue,
14
16
  kind,
15
17
  retry,
16
18
  subject,
17
19
  }: {
18
20
  readonly api: JobsViewClient;
21
+ readonly dates: DateDisplay;
19
22
  readonly queue: string;
20
23
  readonly kind: "failed" | "deadLettered";
21
24
  readonly retry: RetryJob | undefined;
@@ -29,12 +32,12 @@ export function JobList({
29
32
  let selectedDetail: ReactNode = null;
30
33
  if (selectedId !== undefined) {
31
34
  if (kind === "failed") {
32
- selectedDetail = <JobDetail api={api} id={selectedId} key={selectedId} queue={queue} retry={retry} />;
35
+ selectedDetail = <JobDetail api={api} dates={dates} id={selectedId} key={selectedId} queue={queue} retry={retry} />;
33
36
  } else if (Option.isSome(selected)) {
34
37
  selectedDetail = (
35
38
  <section aria-label="Dead-letter detail">
36
39
  <h2 className="mb-4 text-xl font-semibold">Dead-letter detail</h2>
37
- <JobRecord job={selected.value} />
40
+ <JobRecord dates={dates} job={selected.value} />
38
41
  </section>
39
42
  );
40
43
  }
@@ -5,15 +5,18 @@ import { JobList } from "#client/adapters/JobList.tsx";
5
5
  import { JobsMetrics } from "#client/adapters/JobsMetrics.tsx";
6
6
  import { JobsQueryPanel } from "#client/adapters/JobsQueryPanel.tsx";
7
7
  import type { JobsViewClient, RetryJob } from "#client/adapters/jobsTypes.ts";
8
+ import type { DateDisplay } from "#client/adapters/timestampText.ts";
8
9
 
9
10
  export function JobsQueueView({
10
11
  api,
12
+ dates,
11
13
  label,
12
14
  queue,
13
15
  retry,
14
16
  subject,
15
17
  }: {
16
18
  readonly api: JobsViewClient;
19
+ readonly dates: DateDisplay;
17
20
  readonly label?: string | undefined;
18
21
  readonly queue: string;
19
22
  readonly retry: RetryJob | undefined;
@@ -53,7 +56,7 @@ export function JobsQueueView({
53
56
  ))}
54
57
  </div>
55
58
  <div aria-labelledby={`jobs-${kind}-tab`} id={`jobs-${kind}-panel`} role="tabpanel">
56
- <JobList api={api} key={kind} kind={kind} queue={queue} retry={retry} subject={subject} />
59
+ <JobList api={api} dates={dates} key={kind} kind={kind} queue={queue} retry={retry} subject={subject} />
57
60
  </div>
58
61
  </>
59
62
  );
@@ -6,8 +6,9 @@ import { JobsHealthMetrics } from "#client/adapters/JobsMetrics.tsx";
6
6
  import { JobsQueuePicker, JobsQueueView } from "#client/adapters/JobsQueueView.tsx";
7
7
  import type { JobsViewClient, RetryJob, RunScheduleNow } from "#client/adapters/jobsTypes.ts";
8
8
  import { RunScheduleControl } from "#client/adapters/RunScheduleControl.tsx";
9
+ import type { DateDisplay } from "#client/adapters/timestampText.ts";
9
10
 
10
- export interface JobsViewProps {
11
+ export interface JobsViewProps extends DateDisplay {
11
12
  readonly api: JobsViewClient;
12
13
  readonly queues: readonly (string | QueueDisplay)[];
13
14
  readonly retry?: RetryJob | undefined;
@@ -15,7 +16,7 @@ export interface JobsViewProps {
15
16
  readonly schedules?: readonly { readonly name: string }[];
16
17
  }
17
18
 
18
- export function JobsView({ api, queues, retry, schedules, runScheduleNow }: JobsViewProps) {
19
+ export function JobsView({ api, queues, retry, schedules, runScheduleNow, locale, timeZone }: JobsViewProps) {
19
20
  const definitions = queues.map((definition) => (typeof definition === "string" ? { name: definition } : definition));
20
21
  const [name, selectQueue] = useState(definitions[0]?.name ?? "");
21
22
  const queue = definitions.find((candidate) => candidate.name === name);
@@ -37,7 +38,15 @@ export function JobsView({ api, queues, retry, schedules, runScheduleNow }: Jobs
37
38
  runScheduleNow !== undefined && schedules?.some((schedule) => schedule.name === name)
38
39
  ? createElement(RunScheduleControl, { key: `run-${name}`, queue: name, run: runScheduleNow })
39
40
  : null,
40
- createElement(JobsQueueView, { api, key: name, label: queue.label, queue: name, retry, subject: queue.subject }),
41
+ createElement(JobsQueueView, {
42
+ api,
43
+ dates: { locale, timeZone },
44
+ key: name,
45
+ label: queue.label,
46
+ queue: name,
47
+ retry,
48
+ subject: queue.subject,
49
+ }),
41
50
  ),
42
51
  );
43
52
  }
@@ -1,8 +1,10 @@
1
- import { DateTime } from "effect";
2
1
  import type { SignedInSession } from "@shivaedev/identity/signedInSessions.ts";
2
+ import { Timestamp } from "#client/adapters/Timestamp.tsx";
3
+ import type { DateDisplay } from "#client/adapters/timestampText.ts";
3
4
 
4
5
  interface SessionControls {
5
6
  readonly currentSessionId: string | undefined;
7
+ readonly dates: DateDisplay;
6
8
  readonly pending: boolean;
7
9
  readonly select: (session: typeof SignedInSession.Type) => void;
8
10
  }
@@ -20,7 +22,7 @@ export function SessionListView({ sessions, ...controls }: SessionControls & { r
20
22
  );
21
23
  }
22
24
 
23
- function SessionRow({ session, currentSessionId, pending, select }: SessionControls & { readonly session: typeof SignedInSession.Type }) {
25
+ function SessionRow({ session, currentSessionId, dates, pending, select }: SessionControls & { readonly session: typeof SignedInSession.Type }) {
24
26
  const current = session.id === currentSessionId && <p className="font-medium">Your current session</p>;
25
27
  return (
26
28
  <li className="min-w-0 space-y-3 rounded-md border p-4 wrap-anywhere">
@@ -40,12 +42,12 @@ function SessionRow({ session, currentSessionId, pending, select }: SessionContr
40
42
  Revoke session
41
43
  </button>
42
44
  </div>
43
- <SessionTimes session={session} />
45
+ <SessionTimes dates={dates} session={session} />
44
46
  </li>
45
47
  );
46
48
  }
47
49
 
48
- function SessionTimes({ session }: { readonly session: typeof SignedInSession.Type }) {
50
+ function SessionTimes({ dates, session }: { readonly dates: DateDisplay; readonly session: typeof SignedInSession.Type }) {
49
51
  const times = [
50
52
  ["Started", session.startedAt],
51
53
  ["Last activity", session.lastActivityAt],
@@ -57,7 +59,7 @@ function SessionTimes({ session }: { readonly session: typeof SignedInSession.Ty
57
59
  <div key={label}>
58
60
  <dt className="text-muted-foreground">{label}</dt>
59
61
  <dd>
60
- <time dateTime={DateTime.formatIso(time)}>{DateTime.formatIso(time)}</time>
62
+ <Timestamp dates={dates} time={time} />
61
63
  </dd>
62
64
  </div>
63
65
  ))}
@@ -8,8 +8,9 @@ import { useAction, useQuery } from "@shivaedev/react/client/resultState.ts";
8
8
  import { SessionConfirmation } from "#client/adapters/SessionConfirmation.tsx";
9
9
  import { SessionListView } from "#client/adapters/SessionListView.tsx";
10
10
  import { SessionPagination } from "#client/adapters/SessionPagination.tsx";
11
+ import type { DateDisplay } from "#client/adapters/timestampText.ts";
11
12
 
12
- export interface SessionsViewProps<R, E> {
13
+ export interface SessionsViewProps<R, E> extends DateDisplay {
13
14
  readonly currentSessionId: string | undefined;
14
15
  readonly list: (input: typeof SessionListInput.Type) => Atom.Atom<AsyncResult.AsyncResult<SessionList, unknown>>;
15
16
  readonly onCurrentSessionRevoked: () => void;
@@ -21,7 +22,7 @@ function forbidden(cause: Option.Option<Cause.Cause<unknown>>) {
21
22
  return Option.exists(Option.flatMap(cause, Cause.findErrorOption), (error) => Predicate.isTagged(error, "Forbidden"));
22
23
  }
23
24
 
24
- export function SessionsView<R, E>({ currentSessionId, list, onCurrentSessionRevoked, revoke, runtime }: SessionsViewProps<R, E>) {
25
+ export function SessionsView<R, E>({ currentSessionId, list, locale, onCurrentSessionRevoked, revoke, runtime, timeZone }: SessionsViewProps<R, E>) {
25
26
  const [cursors, setCursors] = useState<readonly NonNullable<typeof SessionListInput.Type.cursor>[]>([]);
26
27
  const [selected, select] = useState<typeof SignedInSession.Type>();
27
28
  const cursor = cursors.at(-1);
@@ -61,7 +62,15 @@ export function SessionsView<R, E>({ currentSessionId, list, onCurrentSessionRev
61
62
  pending: action.pending,
62
63
  selected,
63
64
  }),
64
- data === undefined ? null : createElement(SessionListView, { currentSessionId, pending: action.pending, select, sessions: data.sessions }),
65
+ data === undefined
66
+ ? null
67
+ : createElement(SessionListView, {
68
+ currentSessionId,
69
+ dates: { locale, timeZone },
70
+ pending: action.pending,
71
+ select,
72
+ sessions: data.sessions,
73
+ }),
65
74
  createElement(SessionPagination, {
66
75
  cursors,
67
76
  data,
@@ -0,0 +1,18 @@
1
+ import { DateTime } from "effect";
2
+ import { type DateDisplay, timestampText } from "#client/adapters/timestampText.ts";
3
+
4
+ export function Timestamp({
5
+ className,
6
+ dates,
7
+ time,
8
+ }: {
9
+ readonly className?: string;
10
+ readonly dates: DateDisplay;
11
+ readonly time: DateTime.DateTime;
12
+ }) {
13
+ return (
14
+ <time className={className} dateTime={DateTime.formatIso(time)}>
15
+ {timestampText(time, dates)}
16
+ </time>
17
+ );
18
+ }
@@ -1,10 +1,12 @@
1
- import { DateTime } from "effect";
2
1
  import type { ReactNode } from "react";
3
2
  import type { DirectoryUser } from "@shivaedev/identity/users.ts";
3
+ import { Timestamp } from "#client/adapters/Timestamp.tsx";
4
+ import type { DateDisplay } from "#client/adapters/timestampText.ts";
4
5
  import type { ChangeRoleInput } from "#users/ChangeRoleInput.ts";
5
6
  import type { UsersList } from "#users/List.ts";
6
7
 
7
8
  interface RoleControls<TRole extends string> {
9
+ readonly dates: DateDisplay;
8
10
  readonly dispatch: (input: ChangeRoleInput<TRole>) => void;
9
11
  readonly pending: boolean;
10
12
  readonly roles: readonly TRole[];
@@ -16,7 +18,7 @@ function UserRole<TRole extends string>({
16
18
  roles,
17
19
  pending,
18
20
  dispatch,
19
- }: RoleControls<TRole> & {
21
+ }: Omit<RoleControls<TRole>, "dates"> & {
20
22
  readonly user: typeof DirectoryUser.Type;
21
23
  readonly canChangeRoles: boolean;
22
24
  }) {
@@ -48,6 +50,7 @@ function UserRole<TRole extends string>({
48
50
  function UserRow<TRole extends string>({
49
51
  user,
50
52
  canChangeRoles,
53
+ dates,
51
54
  ...controls
52
55
  }: RoleControls<TRole> & { readonly user: typeof DirectoryUser.Type; readonly canChangeRoles: boolean }) {
53
56
  return (
@@ -58,9 +61,7 @@ function UserRow<TRole extends string>({
58
61
  <UserRole {...controls} canChangeRoles={canChangeRoles} user={user} />
59
62
  </UserCell>
60
63
  <UserCell label="Signed up">
61
- <time className="sm:whitespace-nowrap" dateTime={DateTime.formatIso(user.createdAt)}>
62
- {DateTime.formatIso(user.createdAt)}
63
- </time>
64
+ <Timestamp className="sm:whitespace-nowrap" dates={dates} time={user.createdAt} />
64
65
  </UserCell>
65
66
  </tr>
66
67
  );
@@ -4,11 +4,12 @@ import type * as Atom from "effect/reactivity/Atom";
4
4
  import { createElement, useState } from "react";
5
5
  import type { UserListInput } from "@shivaedev/identity/users.ts";
6
6
  import { useAction, useQuery } from "@shivaedev/react/client/resultState.ts";
7
+ import type { DateDisplay } from "#client/adapters/timestampText.ts";
7
8
  import { UsersTable } from "#client/adapters/UsersTable.tsx";
8
9
  import type { ChangeRoleInput } from "#users/ChangeRoleInput.ts";
9
10
  import type { UsersList } from "#users/List.ts";
10
11
 
11
- export interface UsersViewProps<TRole extends string> {
12
+ export interface UsersViewProps<TRole extends string> extends DateDisplay {
12
13
  readonly changeRole: Atom.AtomResultFn<ChangeRoleInput<TRole>, void, unknown>;
13
14
  readonly list: (input: typeof UserListInput.Type) => Atom.Atom<AsyncResult.AsyncResult<UsersList, unknown>>;
14
15
  readonly roles: readonly TRole[];
@@ -25,7 +26,7 @@ function failure(cause: Cause.Cause<unknown>): string {
25
26
  return "Could not change the role. Try again.";
26
27
  }
27
28
 
28
- export function UsersView<TRole extends string>({ list, changeRole, roles }: UsersViewProps<TRole>) {
29
+ export function UsersView<TRole extends string>({ list, changeRole, roles, locale, timeZone }: UsersViewProps<TRole>) {
29
30
  const [cursors, setCursors] = useState<readonly string[]>([]);
30
31
  const cursor = cursors.at(-1);
31
32
  const state = useQuery(list({ ...(cursor === undefined ? {} : { cursor }), limit: 20 }));
@@ -42,7 +43,9 @@ export function UsersView<TRole extends string>({ list, changeRole, roles }: Use
42
43
  state.pending ? createElement("p", { role: "status" }, "Loading users…") : null,
43
44
  Option.isSome(state.cause) ? createElement("p", { role: "alert" }, "Could not load users. Try refreshing.") : null,
44
45
  Option.isSome(action.cause) ? createElement("p", { role: "alert" }, failure(action.cause.value)) : null,
45
- data === undefined ? null : createElement(UsersTable<TRole>, { data, dispatch: action.dispatch, pending: action.pending, roles }),
46
+ data === undefined
47
+ ? null
48
+ : createElement(UsersTable<TRole>, { data, dates: { locale, timeZone }, dispatch: action.dispatch, pending: action.pending, roles }),
46
49
  data === undefined
47
50
  ? null
48
51
  : createElement(
@@ -0,0 +1,17 @@
1
+ import { DateTime, Option } from "effect";
2
+
3
+ export interface DateDisplay {
4
+ readonly locale?: string | undefined;
5
+ readonly timeZone?: string | undefined;
6
+ }
7
+
8
+ const STYLE = { dateStyle: "medium", timeStyle: "long" } as const;
9
+
10
+ export function timestampText(time: DateTime.DateTime, { locale, timeZone }: DateDisplay): string {
11
+ const options = locale === undefined ? STYLE : { ...STYLE, locale };
12
+ // Intl throws on a locale or time zone it cannot read, and a saved preference must not take the page down with it.
13
+ const preferred = Option.liftThrowable(() =>
14
+ timeZone === undefined ? DateTime.formatLocal(time, options) : DateTime.format(time, { ...options, timeZone }),
15
+ )();
16
+ return Option.getOrElse(preferred, () => DateTime.formatLocal(time, STYLE));
17
+ }