@tgoliveira/outpost 1.1.0 → 1.2.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 (167) hide show
  1. package/AGENTS.md +22 -0
  2. package/dist/adapters/drizzle/index.cjs +57 -0
  3. package/dist/adapters/drizzle/index.cjs.map +1 -1
  4. package/dist/adapters/drizzle/index.d.cts +165 -3
  5. package/dist/adapters/drizzle/index.d.ts +165 -3
  6. package/dist/adapters/drizzle/index.js +57 -2
  7. package/dist/adapters/drizzle/index.js.map +1 -1
  8. package/dist/admin/index.cjs +641 -0
  9. package/dist/admin/index.cjs.map +1 -0
  10. package/dist/admin/index.d.cts +119 -0
  11. package/dist/admin/index.d.ts +119 -0
  12. package/dist/admin/index.js +638 -0
  13. package/dist/admin/index.js.map +1 -0
  14. package/dist/config-override-repository-BHIGX3DJ.d.cts +14 -0
  15. package/dist/config-override-repository-BHIGX3DJ.d.ts +14 -0
  16. package/dist/http/index.d.cts +3 -3
  17. package/dist/http/index.d.ts +3 -3
  18. package/dist/{index-Dmt-aLH2.d.cts → index-BO0GiZmP.d.cts} +1 -1
  19. package/dist/{index-CVUvaJms.d.ts → index-c6caPsUG.d.ts} +1 -1
  20. package/dist/index.d.cts +5 -5
  21. package/dist/index.d.ts +5 -5
  22. package/dist/modules/ui/index.cjs +942 -0
  23. package/dist/modules/ui/index.cjs.map +1 -0
  24. package/dist/modules/ui/index.d.cts +17 -0
  25. package/dist/modules/ui/index.d.ts +17 -0
  26. package/dist/modules/ui/index.js +885 -0
  27. package/dist/modules/ui/index.js.map +1 -0
  28. package/dist/modules/ui/layouts/page-shell.cjs +58 -0
  29. package/dist/modules/ui/layouts/page-shell.cjs.map +1 -0
  30. package/dist/modules/ui/layouts/page-shell.d.cts +13 -0
  31. package/dist/modules/ui/layouts/page-shell.d.ts +13 -0
  32. package/dist/modules/ui/layouts/page-shell.js +32 -0
  33. package/dist/modules/ui/layouts/page-shell.js.map +1 -0
  34. package/dist/modules/ui/lib/cn.cjs +33 -0
  35. package/dist/modules/ui/lib/cn.cjs.map +1 -0
  36. package/dist/modules/ui/lib/cn.d.cts +3 -0
  37. package/dist/modules/ui/lib/cn.d.ts +3 -0
  38. package/dist/modules/ui/lib/cn.js +8 -0
  39. package/dist/modules/ui/lib/cn.js.map +1 -0
  40. package/dist/modules/ui/lib/main-content.cjs +31 -0
  41. package/dist/modules/ui/lib/main-content.cjs.map +1 -0
  42. package/dist/modules/ui/lib/main-content.d.cts +3 -0
  43. package/dist/modules/ui/lib/main-content.d.ts +3 -0
  44. package/dist/modules/ui/lib/main-content.js +6 -0
  45. package/dist/modules/ui/lib/main-content.js.map +1 -0
  46. package/dist/modules/ui/outpost-ui-provider.cjs +52 -0
  47. package/dist/modules/ui/outpost-ui-provider.cjs.map +1 -0
  48. package/dist/modules/ui/outpost-ui-provider.d.cts +15 -0
  49. package/dist/modules/ui/outpost-ui-provider.d.ts +15 -0
  50. package/dist/modules/ui/outpost-ui-provider.js +27 -0
  51. package/dist/modules/ui/outpost-ui-provider.js.map +1 -0
  52. package/dist/modules/ui/pages/admin/admin-config-page.cjs +429 -0
  53. package/dist/modules/ui/pages/admin/admin-config-page.cjs.map +1 -0
  54. package/dist/modules/ui/pages/admin/admin-config-page.d.cts +8 -0
  55. package/dist/modules/ui/pages/admin/admin-config-page.d.ts +8 -0
  56. package/dist/modules/ui/pages/admin/admin-config-page.js +395 -0
  57. package/dist/modules/ui/pages/admin/admin-config-page.js.map +1 -0
  58. package/dist/modules/ui/pages/admin/admin-observability-page.cjs +344 -0
  59. package/dist/modules/ui/pages/admin/admin-observability-page.cjs.map +1 -0
  60. package/dist/modules/ui/pages/admin/admin-observability-page.d.cts +8 -0
  61. package/dist/modules/ui/pages/admin/admin-observability-page.d.ts +8 -0
  62. package/dist/modules/ui/pages/admin/admin-observability-page.js +310 -0
  63. package/dist/modules/ui/pages/admin/admin-observability-page.js.map +1 -0
  64. package/dist/modules/ui/pages/admin/admin-panel-page.cjs +160 -0
  65. package/dist/modules/ui/pages/admin/admin-panel-page.cjs.map +1 -0
  66. package/dist/modules/ui/pages/admin/admin-panel-page.d.cts +9 -0
  67. package/dist/modules/ui/pages/admin/admin-panel-page.d.ts +9 -0
  68. package/dist/modules/ui/pages/admin/admin-panel-page.js +126 -0
  69. package/dist/modules/ui/pages/admin/admin-panel-page.js.map +1 -0
  70. package/dist/modules/ui/pages/admin/admin-queue-page.cjs +565 -0
  71. package/dist/modules/ui/pages/admin/admin-queue-page.cjs.map +1 -0
  72. package/dist/modules/ui/pages/admin/admin-queue-page.d.cts +8 -0
  73. package/dist/modules/ui/pages/admin/admin-queue-page.d.ts +8 -0
  74. package/dist/modules/ui/pages/admin/admin-queue-page.js +531 -0
  75. package/dist/modules/ui/pages/admin/admin-queue-page.js.map +1 -0
  76. package/dist/modules/ui/pages/index.cjs +909 -0
  77. package/dist/modules/ui/pages/index.cjs.map +1 -0
  78. package/dist/modules/ui/pages/index.d.cts +6 -0
  79. package/dist/modules/ui/pages/index.d.ts +6 -0
  80. package/dist/modules/ui/pages/index.js +869 -0
  81. package/dist/modules/ui/pages/index.js.map +1 -0
  82. package/dist/modules/ui/pages/types.cjs +38 -0
  83. package/dist/modules/ui/pages/types.cjs.map +1 -0
  84. package/dist/modules/ui/pages/types.d.cts +9 -0
  85. package/dist/modules/ui/pages/types.d.ts +9 -0
  86. package/dist/modules/ui/pages/types.js +12 -0
  87. package/dist/modules/ui/pages/types.js.map +1 -0
  88. package/dist/modules/ui/pages/use-page-ui.cjs +55 -0
  89. package/dist/modules/ui/pages/use-page-ui.cjs.map +1 -0
  90. package/dist/modules/ui/pages/use-page-ui.d.cts +6 -0
  91. package/dist/modules/ui/pages/use-page-ui.d.ts +6 -0
  92. package/dist/modules/ui/pages/use-page-ui.js +29 -0
  93. package/dist/modules/ui/pages/use-page-ui.js.map +1 -0
  94. package/dist/modules/ui/primitives/alert.cjs +63 -0
  95. package/dist/modules/ui/primitives/alert.cjs.map +1 -0
  96. package/dist/modules/ui/primitives/alert.d.cts +10 -0
  97. package/dist/modules/ui/primitives/alert.d.ts +10 -0
  98. package/dist/modules/ui/primitives/alert.js +36 -0
  99. package/dist/modules/ui/primitives/alert.js.map +1 -0
  100. package/dist/modules/ui/primitives/badge.cjs +60 -0
  101. package/dist/modules/ui/primitives/badge.cjs.map +1 -0
  102. package/dist/modules/ui/primitives/badge.d.cts +9 -0
  103. package/dist/modules/ui/primitives/badge.d.ts +9 -0
  104. package/dist/modules/ui/primitives/badge.js +33 -0
  105. package/dist/modules/ui/primitives/badge.js.map +1 -0
  106. package/dist/modules/ui/primitives/button.cjs +61 -0
  107. package/dist/modules/ui/primitives/button.cjs.map +1 -0
  108. package/dist/modules/ui/primitives/button.d.cts +9 -0
  109. package/dist/modules/ui/primitives/button.d.ts +9 -0
  110. package/dist/modules/ui/primitives/button.js +37 -0
  111. package/dist/modules/ui/primitives/button.js.map +1 -0
  112. package/dist/modules/ui/primitives/card.cjs +71 -0
  113. package/dist/modules/ui/primitives/card.cjs.map +1 -0
  114. package/dist/modules/ui/primitives/card.d.cts +11 -0
  115. package/dist/modules/ui/primitives/card.d.ts +11 -0
  116. package/dist/modules/ui/primitives/card.js +41 -0
  117. package/dist/modules/ui/primitives/card.js.map +1 -0
  118. package/dist/modules/ui/primitives/empty-state.cjs +37 -0
  119. package/dist/modules/ui/primitives/empty-state.cjs.map +1 -0
  120. package/dist/modules/ui/primitives/empty-state.d.cts +9 -0
  121. package/dist/modules/ui/primitives/empty-state.d.ts +9 -0
  122. package/dist/modules/ui/primitives/empty-state.js +12 -0
  123. package/dist/modules/ui/primitives/empty-state.js.map +1 -0
  124. package/dist/modules/ui/primitives/input.cjs +55 -0
  125. package/dist/modules/ui/primitives/input.cjs.map +1 -0
  126. package/dist/modules/ui/primitives/input.d.cts +6 -0
  127. package/dist/modules/ui/primitives/input.d.ts +6 -0
  128. package/dist/modules/ui/primitives/input.js +30 -0
  129. package/dist/modules/ui/primitives/input.js.map +1 -0
  130. package/dist/modules/ui/primitives/loading-state.cjs +55 -0
  131. package/dist/modules/ui/primitives/loading-state.cjs.map +1 -0
  132. package/dist/modules/ui/primitives/loading-state.d.cts +8 -0
  133. package/dist/modules/ui/primitives/loading-state.d.ts +8 -0
  134. package/dist/modules/ui/primitives/loading-state.js +30 -0
  135. package/dist/modules/ui/primitives/loading-state.js.map +1 -0
  136. package/dist/modules/ui/primitives/page-header.cjs +40 -0
  137. package/dist/modules/ui/primitives/page-header.cjs.map +1 -0
  138. package/dist/modules/ui/primitives/page-header.d.cts +10 -0
  139. package/dist/modules/ui/primitives/page-header.d.ts +10 -0
  140. package/dist/modules/ui/primitives/page-header.js +15 -0
  141. package/dist/modules/ui/primitives/page-header.js.map +1 -0
  142. package/dist/{outpost-client-ymTJISpu.d.ts → outpost-client-BItbgqIo.d.ts} +2 -2
  143. package/dist/{outpost-client-yUijE00q.d.cts → outpost-client-BlVf4gjo.d.cts} +2 -2
  144. package/dist/react/client.cjs +14 -0
  145. package/dist/react/client.cjs.map +1 -0
  146. package/dist/react/client.d.cts +5 -0
  147. package/dist/react/client.d.ts +5 -0
  148. package/dist/react/client.js +11 -0
  149. package/dist/react/client.js.map +1 -0
  150. package/dist/react/index.cjs +943 -0
  151. package/dist/react/index.cjs.map +1 -0
  152. package/dist/react/index.d.cts +17 -0
  153. package/dist/react/index.d.ts +17 -0
  154. package/dist/react/index.js +887 -0
  155. package/dist/react/index.js.map +1 -0
  156. package/dist/{repositories-DhUe8f2R.d.cts → repositories-CHIOFGn3.d.cts} +2 -0
  157. package/dist/{repositories-Bck6wJNS.d.ts → repositories-WyhvxzyY.d.ts} +2 -0
  158. package/dist/testing/index.cjs +41 -0
  159. package/dist/testing/index.cjs.map +1 -1
  160. package/dist/testing/index.d.cts +13 -3
  161. package/dist/testing/index.d.ts +13 -3
  162. package/dist/testing/index.js +41 -1
  163. package/dist/testing/index.js.map +1 -1
  164. package/dist/workers/index.d.cts +2 -2
  165. package/dist/workers/index.d.ts +2 -2
  166. package/package.json +45 -3
  167. package/styles.css +4 -0
@@ -0,0 +1,885 @@
1
+ // src/modules/ui/outpost-ui-provider.tsx
2
+ import { createContext, useContext } from "react";
3
+
4
+ // src/modules/ui/pages/types.ts
5
+ var DEFAULT_OUTPOST_PATHS = {
6
+ adminPanel: "/admin"
7
+ };
8
+ function resolveOutpostPaths(overrides) {
9
+ return { ...DEFAULT_OUTPOST_PATHS, ...overrides };
10
+ }
11
+
12
+ // src/modules/ui/outpost-ui-provider.tsx
13
+ import { jsx } from "react/jsx-runtime";
14
+ var OutpostUiContext = createContext(null);
15
+ function OutpostUIProvider({ children, paths }) {
16
+ return /* @__PURE__ */ jsx(OutpostUiContext.Provider, { value: { paths: resolveOutpostPaths(paths) }, children });
17
+ }
18
+ function useOutpostUi() {
19
+ return useContext(OutpostUiContext);
20
+ }
21
+
22
+ // src/modules/ui/lib/cn.ts
23
+ function cn(...classes) {
24
+ return classes.filter(Boolean).join(" ");
25
+ }
26
+
27
+ // src/modules/ui/lib/main-content.ts
28
+ var MAIN_CONTENT_ID = "outpost-main-content";
29
+
30
+ // src/modules/ui/layouts/page-shell.tsx
31
+ import { jsx as jsx2 } from "react/jsx-runtime";
32
+ var widthClass = {
33
+ narrow: "max-w-md",
34
+ medium: "max-w-xl",
35
+ wide: "max-w-6xl"
36
+ };
37
+ function PageShell({ children, width = "wide", className }) {
38
+ return /* @__PURE__ */ jsx2(
39
+ "main",
40
+ {
41
+ id: MAIN_CONTENT_ID,
42
+ tabIndex: -1,
43
+ className: cn("mx-auto px-4 py-8 md:py-10", widthClass[width], className),
44
+ children
45
+ }
46
+ );
47
+ }
48
+
49
+ // src/modules/ui/primitives/button.tsx
50
+ import { forwardRef } from "react";
51
+ import { jsx as jsx3 } from "react/jsx-runtime";
52
+ var Button = forwardRef(function Button2({ variant = "primary", className, children, ...props }, ref) {
53
+ const variants = {
54
+ primary: "bg-[var(--primary)] text-white hover:bg-[var(--primary-hover)]",
55
+ secondary: "border border-[var(--border)] bg-[var(--card)] text-[var(--foreground)] hover:bg-[var(--card-muted)]",
56
+ danger: "bg-[var(--danger)] text-white hover:bg-red-800"
57
+ };
58
+ return /* @__PURE__ */ jsx3(
59
+ "button",
60
+ {
61
+ ref,
62
+ className: cn(
63
+ "min-h-11 rounded-[var(--radius)] px-4 py-2.5 text-sm font-medium transition-colors",
64
+ "disabled:cursor-not-allowed disabled:opacity-50",
65
+ variants[variant],
66
+ className
67
+ ),
68
+ ...props,
69
+ children
70
+ }
71
+ );
72
+ });
73
+
74
+ // src/modules/ui/primitives/alert.tsx
75
+ import { jsx as jsx4, jsxs } from "react/jsx-runtime";
76
+ var variantStyles = {
77
+ info: "border-[var(--info-muted)] bg-[var(--info-muted)] text-[var(--info)]",
78
+ success: "border-[var(--success-muted)] bg-[var(--success-muted)] text-[var(--success)]",
79
+ warning: "border-[var(--warning-muted)] bg-[var(--warning-muted)] text-[var(--warning)]",
80
+ danger: "border-[var(--danger-muted)] bg-[var(--danger-muted)] text-[var(--danger)]",
81
+ muted: "border-[var(--border)] bg-[var(--card-muted)] text-[var(--muted)]"
82
+ };
83
+ function Alert({ variant = "muted", title, className, children, ...props }) {
84
+ return /* @__PURE__ */ jsxs(
85
+ "div",
86
+ {
87
+ role: "status",
88
+ className: cn(
89
+ "rounded-[var(--radius)] border px-4 py-3 text-sm leading-relaxed",
90
+ variantStyles[variant],
91
+ className
92
+ ),
93
+ ...props,
94
+ children: [
95
+ title && /* @__PURE__ */ jsx4("p", { className: "mb-1 font-medium", children: title }),
96
+ children
97
+ ]
98
+ }
99
+ );
100
+ }
101
+
102
+ // src/modules/ui/primitives/badge.tsx
103
+ import { jsx as jsx5 } from "react/jsx-runtime";
104
+ var styles = {
105
+ default: "bg-[var(--accent-muted)] text-[var(--foreground)]",
106
+ success: "bg-[var(--success-muted)] text-[var(--success)]",
107
+ info: "bg-[var(--info-muted)] text-[var(--info)]",
108
+ danger: "bg-[var(--danger-muted)] text-[var(--danger)]",
109
+ muted: "bg-[var(--card-muted)] text-[var(--muted)]",
110
+ warning: "bg-[var(--warning-muted)] text-[var(--warning)]"
111
+ };
112
+ function Badge({ variant = "default", className, children, ...props }) {
113
+ return /* @__PURE__ */ jsx5(
114
+ "span",
115
+ {
116
+ className: cn(
117
+ "inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",
118
+ styles[variant],
119
+ className
120
+ ),
121
+ ...props,
122
+ children
123
+ }
124
+ );
125
+ }
126
+
127
+ // src/modules/ui/primitives/card.tsx
128
+ import { jsx as jsx6 } from "react/jsx-runtime";
129
+ function Card({ className, muted, children, ...props }) {
130
+ return /* @__PURE__ */ jsx6(
131
+ "div",
132
+ {
133
+ className: cn(
134
+ "rounded-[var(--radius)] border border-[var(--border)] p-5 shadow-[var(--shadow-sm)]",
135
+ muted ? "bg-[var(--card-muted)]" : "bg-[var(--card)]",
136
+ className
137
+ ),
138
+ ...props,
139
+ children
140
+ }
141
+ );
142
+ }
143
+ function CardHeader({ className, children, ...props }) {
144
+ return /* @__PURE__ */ jsx6("div", { className: cn("mb-4 space-y-1", className), ...props, children });
145
+ }
146
+ function CardTitle({ className, children, ...props }) {
147
+ return /* @__PURE__ */ jsx6("h2", { className: cn("text-lg font-medium text-[var(--foreground)]", className), ...props, children });
148
+ }
149
+ function CardDescription({
150
+ className,
151
+ children,
152
+ ...props
153
+ }) {
154
+ return /* @__PURE__ */ jsx6("p", { className: cn("text-sm leading-relaxed text-[var(--muted)]", className), ...props, children });
155
+ }
156
+
157
+ // src/modules/ui/primitives/page-header.tsx
158
+ import { jsx as jsx7, jsxs as jsxs2 } from "react/jsx-runtime";
159
+ function PageHeader({ title, description, action }) {
160
+ return /* @__PURE__ */ jsxs2("div", { className: "mb-8 flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between", children: [
161
+ /* @__PURE__ */ jsxs2("div", { className: "space-y-2", children: [
162
+ /* @__PURE__ */ jsx7("h1", { className: "text-2xl font-semibold tracking-tight text-[var(--foreground)]", children: title }),
163
+ description && /* @__PURE__ */ jsx7("p", { className: "max-w-prose text-sm leading-relaxed text-[var(--muted)]", children: description })
164
+ ] }),
165
+ action && /* @__PURE__ */ jsx7("div", { className: "shrink-0", children: action })
166
+ ] });
167
+ }
168
+
169
+ // src/modules/ui/primitives/loading-state.tsx
170
+ import { jsx as jsx8, jsxs as jsxs3 } from "react/jsx-runtime";
171
+ function LoadingState({ label = "Loading" }) {
172
+ return /* @__PURE__ */ jsxs3(
173
+ "div",
174
+ {
175
+ className: "flex flex-col items-center justify-center gap-3 py-16 text-center",
176
+ role: "status",
177
+ "aria-live": "polite",
178
+ "aria-busy": "true",
179
+ children: [
180
+ /* @__PURE__ */ jsx8(
181
+ "div",
182
+ {
183
+ className: "h-8 w-8 animate-pulse rounded-full border-2 border-[var(--border)] border-t-[var(--primary)]",
184
+ "aria-hidden": "true"
185
+ }
186
+ ),
187
+ /* @__PURE__ */ jsxs3("p", { className: "text-sm text-[var(--muted)]", children: [
188
+ label,
189
+ "\u2026"
190
+ ] })
191
+ ]
192
+ }
193
+ );
194
+ }
195
+
196
+ // src/modules/ui/primitives/empty-state.tsx
197
+ import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
198
+ function EmptyState({ title, description }) {
199
+ return /* @__PURE__ */ jsxs4("div", { className: "py-8 text-center", children: [
200
+ /* @__PURE__ */ jsx9("p", { className: "text-sm font-medium text-[var(--foreground)]", children: title }),
201
+ description && /* @__PURE__ */ jsx9("p", { className: "mt-1 text-sm text-[var(--muted)]", children: description })
202
+ ] });
203
+ }
204
+
205
+ // src/modules/ui/primitives/input.tsx
206
+ import { forwardRef as forwardRef2 } from "react";
207
+ import { jsx as jsx10 } from "react/jsx-runtime";
208
+ var Input = forwardRef2(
209
+ function Input2({ className, ...props }, ref) {
210
+ return /* @__PURE__ */ jsx10(
211
+ "input",
212
+ {
213
+ ref,
214
+ className: cn(
215
+ "w-full rounded-[var(--radius)] border border-[var(--border)] bg-[var(--card)] px-3 py-2 text-sm text-[var(--foreground)]",
216
+ "placeholder:text-[var(--muted)] focus:outline-none focus:ring-2 focus:ring-[var(--primary)]",
217
+ className
218
+ ),
219
+ ...props
220
+ }
221
+ );
222
+ }
223
+ );
224
+
225
+ // src/modules/ui/pages/admin/admin-panel-page.tsx
226
+ import Link from "next/link";
227
+
228
+ // src/modules/ui/pages/use-page-ui.ts
229
+ function useUiPaths(overrides) {
230
+ const ui = useOutpostUi();
231
+ return resolveOutpostPaths({ ...ui?.paths, ...overrides });
232
+ }
233
+
234
+ // src/modules/ui/pages/admin/admin-panel-page.tsx
235
+ import { jsx as jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
236
+ var SECTIONS = [
237
+ {
238
+ key: "adminQueue",
239
+ label: "Email Queue",
240
+ description: "Inspect queued messages and run the send worker manually.",
241
+ suffix: "/queue"
242
+ },
243
+ {
244
+ key: "adminConfig",
245
+ label: "Configuration",
246
+ description: "View and override vault/env settings. Admin overrides win over env.local.",
247
+ suffix: "/config"
248
+ },
249
+ {
250
+ key: "adminObservability",
251
+ label: "Observability",
252
+ description: "Queue depth, worker activity, and OpenTelemetry metric catalog.",
253
+ suffix: "/observability"
254
+ }
255
+ ];
256
+ function AdminPanelPage({ paths }) {
257
+ const resolved = useUiPaths(paths);
258
+ const base = resolved.adminPanel;
259
+ return /* @__PURE__ */ jsxs5(PageShell, { width: "wide", children: [
260
+ /* @__PURE__ */ jsxs5("div", { className: "mb-8", children: [
261
+ /* @__PURE__ */ jsx11("h1", { className: "text-2xl font-semibold text-[var(--foreground)]", children: "Outpost Admin" }),
262
+ /* @__PURE__ */ jsx11("p", { className: "mt-1 text-sm text-[var(--muted)]", children: "Operate the transactional email outbox \u2014 queue, configuration, and observability." })
263
+ ] }),
264
+ /* @__PURE__ */ jsx11("div", { className: "grid gap-4 sm:grid-cols-2 lg:grid-cols-3", children: SECTIONS.map((section) => /* @__PURE__ */ jsx11(Link, { href: `${base}${section.suffix}`, className: "block", children: /* @__PURE__ */ jsx11(Card, { className: "h-full cursor-pointer transition-shadow hover:shadow-md", children: /* @__PURE__ */ jsxs5(CardHeader, { children: [
265
+ /* @__PURE__ */ jsx11(CardTitle, { className: "text-base", children: section.label }),
266
+ /* @__PURE__ */ jsx11(CardDescription, { className: "text-sm", children: section.description })
267
+ ] }) }) }, section.key)) })
268
+ ] });
269
+ }
270
+
271
+ // src/modules/ui/pages/admin/admin-queue-page.tsx
272
+ import { useState, useEffect, useCallback } from "react";
273
+ import Link2 from "next/link";
274
+ import { jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
275
+ var PIPELINE_CONFIG_KEYS = [
276
+ "domainValidation.syntax",
277
+ "domainValidation.mx",
278
+ "sanitize.maxSubjectBytes",
279
+ "sanitize.maxBodyBytes",
280
+ "sanitize.maxRecipientBytes",
281
+ "sanitize.maxHeaderValueBytes"
282
+ ];
283
+ function stateBadge(state) {
284
+ if (state === "queued") return /* @__PURE__ */ jsx12(Badge, { variant: "info", children: "queued" });
285
+ if (state === "sending") return /* @__PURE__ */ jsx12(Badge, { variant: "warning", children: "sending" });
286
+ if (state === "failed") return /* @__PURE__ */ jsx12(Badge, { variant: "danger", children: "failed" });
287
+ return /* @__PURE__ */ jsx12(Badge, { variant: "muted", children: state });
288
+ }
289
+ function formatDate(d) {
290
+ if (!d) return "\u2014";
291
+ return new Date(d).toLocaleString();
292
+ }
293
+ function formatBytes(n) {
294
+ if (typeof n !== "number" || Number.isNaN(n)) return String(n ?? "\u2014");
295
+ if (n >= 1e6) return `${(n / 1e6).toFixed(1)} MB`;
296
+ if (n >= 1e3) return `${(n / 1e3).toFixed(1)} KB`;
297
+ return `${n} B`;
298
+ }
299
+ function configLabel(key) {
300
+ const labels = {
301
+ "domainValidation.syntax": "Email syntax check",
302
+ "domainValidation.mx": "MX record check (dispatch)",
303
+ "sanitize.maxSubjectBytes": "Max subject size",
304
+ "sanitize.maxBodyBytes": "Max body size",
305
+ "sanitize.maxRecipientBytes": "Max recipient size",
306
+ "sanitize.maxHeaderValueBytes": "Max header value size"
307
+ };
308
+ return labels[key] ?? key;
309
+ }
310
+ function PipelineConfigCard({
311
+ apiBase,
312
+ configPath
313
+ }) {
314
+ const [keys, setKeys] = useState([]);
315
+ const [isLoading, setIsLoading] = useState(true);
316
+ const [error, setError] = useState("");
317
+ useEffect(() => {
318
+ let cancelled = false;
319
+ (async () => {
320
+ setIsLoading(true);
321
+ setError("");
322
+ try {
323
+ const res = await fetch(`${apiBase}/admin/config`);
324
+ if (!res.ok) throw new Error("Failed to load");
325
+ const data = await res.json();
326
+ if (!cancelled) setKeys(data.keys ?? []);
327
+ } catch {
328
+ if (!cancelled) setError("Could not load pipeline settings.");
329
+ } finally {
330
+ if (!cancelled) setIsLoading(false);
331
+ }
332
+ })();
333
+ return () => {
334
+ cancelled = true;
335
+ };
336
+ }, [apiBase]);
337
+ const pipeline = PIPELINE_CONFIG_KEYS.map((key) => {
338
+ const row = keys.find((k) => k.key === key);
339
+ return { key, source: row?.source ?? "default", value: row?.value };
340
+ });
341
+ return /* @__PURE__ */ jsxs6(Card, { children: [
342
+ /* @__PURE__ */ jsxs6(CardHeader, { children: [
343
+ /* @__PURE__ */ jsx12(CardTitle, { children: "Outbound pipeline (effective config)" }),
344
+ /* @__PURE__ */ jsxs6(CardDescription, { children: [
345
+ "Sanitization runs at enqueue and again before dispatch. Domain syntax is checked at enqueue; MX (when enabled) runs in the send worker.",
346
+ " ",
347
+ /* @__PURE__ */ jsx12(Link2, { href: configPath, className: "underline hover:text-[var(--foreground)]", children: "Edit in Config" })
348
+ ] })
349
+ ] }),
350
+ error ? /* @__PURE__ */ jsx12("div", { className: "px-6 pb-6", children: /* @__PURE__ */ jsx12(Alert, { variant: "danger", children: error }) }) : isLoading ? /* @__PURE__ */ jsx12("div", { className: "px-6 pb-6", children: /* @__PURE__ */ jsx12(LoadingState, { label: "Loading pipeline settings" }) }) : /* @__PURE__ */ jsx12("div", { className: "overflow-x-auto px-6 pb-6", children: /* @__PURE__ */ jsxs6("table", { className: "w-full text-sm", children: [
351
+ /* @__PURE__ */ jsx12("thead", { className: "border-b border-[var(--border)] text-left text-[var(--muted)]", children: /* @__PURE__ */ jsxs6("tr", { children: [
352
+ /* @__PURE__ */ jsx12("th", { className: "pb-2 font-medium", children: "Check / limit" }),
353
+ /* @__PURE__ */ jsx12("th", { className: "pb-2 font-medium", children: "Effective value" }),
354
+ /* @__PURE__ */ jsx12("th", { className: "pb-2 font-medium", children: "Source" })
355
+ ] }) }),
356
+ /* @__PURE__ */ jsx12("tbody", { className: "divide-y divide-[var(--border)]", children: pipeline.map((row) => /* @__PURE__ */ jsxs6("tr", { children: [
357
+ /* @__PURE__ */ jsx12("td", { className: "py-2 pr-4", children: configLabel(row.key) }),
358
+ /* @__PURE__ */ jsx12("td", { className: "py-2 pr-4 font-mono text-xs", children: row.key.startsWith("domainValidation.") ? row.value === true ? "enabled" : row.value === false ? "disabled" : String(row.value ?? "\u2014") : row.key.startsWith("sanitize.") ? formatBytes(row.value) : String(row.value ?? "\u2014") }),
359
+ /* @__PURE__ */ jsx12("td", { className: "py-2", children: row.source === "admin" ? /* @__PURE__ */ jsx12(Badge, { variant: "info", children: "admin" }) : row.source === "env" ? /* @__PURE__ */ jsx12(Badge, { variant: "default", children: "env" }) : /* @__PURE__ */ jsx12(Badge, { variant: "muted", children: "default" }) })
360
+ ] }, row.key)) })
361
+ ] }) })
362
+ ] });
363
+ }
364
+ function AuditTrailPanel({
365
+ apiBase,
366
+ messageId,
367
+ subject,
368
+ onClose
369
+ }) {
370
+ const [events, setEvents] = useState([]);
371
+ const [isLoading, setIsLoading] = useState(true);
372
+ const [error, setError] = useState("");
373
+ useEffect(() => {
374
+ let cancelled = false;
375
+ (async () => {
376
+ setIsLoading(true);
377
+ setError("");
378
+ try {
379
+ const res = await fetch(
380
+ `${apiBase}/admin/audit?messageId=${encodeURIComponent(messageId)}`
381
+ );
382
+ if (!res.ok) throw new Error("Failed to load");
383
+ const data = await res.json();
384
+ if (!cancelled) setEvents(data.events ?? []);
385
+ } catch {
386
+ if (!cancelled) setError("Failed to load audit trail.");
387
+ } finally {
388
+ if (!cancelled) setIsLoading(false);
389
+ }
390
+ })();
391
+ return () => {
392
+ cancelled = true;
393
+ };
394
+ }, [apiBase, messageId]);
395
+ return /* @__PURE__ */ jsx12(
396
+ "div",
397
+ {
398
+ className: "fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",
399
+ role: "dialog",
400
+ "aria-modal": "true",
401
+ "aria-labelledby": "audit-trail-title",
402
+ children: /* @__PURE__ */ jsxs6(Card, { className: "max-h-[85vh] w-full max-w-lg overflow-hidden shadow-lg", children: [
403
+ /* @__PURE__ */ jsxs6(CardHeader, { children: [
404
+ /* @__PURE__ */ jsx12(CardTitle, { id: "audit-trail-title", children: "Audit trail" }),
405
+ /* @__PURE__ */ jsxs6(CardDescription, { children: [
406
+ /* @__PURE__ */ jsx12("span", { className: "font-medium text-[var(--foreground)]", children: subject }),
407
+ /* @__PURE__ */ jsx12("span", { className: "mt-1 block font-mono text-xs", children: messageId })
408
+ ] })
409
+ ] }),
410
+ /* @__PURE__ */ jsx12("div", { className: "max-h-[50vh] overflow-y-auto px-6 pb-4", children: isLoading ? /* @__PURE__ */ jsx12(LoadingState, { label: "Loading audit events" }) : error ? /* @__PURE__ */ jsx12(Alert, { variant: "danger", children: error }) : events.length === 0 ? /* @__PURE__ */ jsx12(EmptyState, { title: "No events", description: "No audit entries for this message yet." }) : /* @__PURE__ */ jsx12("ol", { className: "space-y-3 border-l border-[var(--border)] pl-4", children: events.map((ev) => /* @__PURE__ */ jsxs6("li", { className: "relative text-sm", children: [
411
+ /* @__PURE__ */ jsx12("span", { className: "absolute -left-[calc(0.5rem+5px)] top-1.5 h-2 w-2 rounded-full bg-[var(--border)]" }),
412
+ /* @__PURE__ */ jsxs6("div", { className: "flex flex-wrap items-center gap-2", children: [
413
+ /* @__PURE__ */ jsx12(Badge, { variant: "default", children: ev.eventType }),
414
+ /* @__PURE__ */ jsx12("span", { className: "text-xs text-[var(--muted)]", children: formatDate(ev.at) })
415
+ ] }),
416
+ /* @__PURE__ */ jsxs6("p", { className: "mt-1 text-xs text-[var(--muted)]", children: [
417
+ "actor: ",
418
+ ev.actor
419
+ ] }),
420
+ ev.detail && Object.keys(ev.detail).length > 0 && /* @__PURE__ */ jsx12("pre", { className: "mt-1 overflow-x-auto rounded bg-[var(--card-muted)] p-2 font-mono text-xs", children: JSON.stringify(ev.detail, null, 2) })
421
+ ] }, ev.id)) }) }),
422
+ /* @__PURE__ */ jsx12("div", { className: "flex justify-end border-t border-[var(--border)] px-6 py-4", children: /* @__PURE__ */ jsx12(Button, { variant: "secondary", onClick: onClose, children: "Close" }) })
423
+ ] })
424
+ }
425
+ );
426
+ }
427
+ function MessageTable({
428
+ title,
429
+ description,
430
+ rows,
431
+ onViewAudit
432
+ }) {
433
+ return /* @__PURE__ */ jsxs6(Card, { className: "overflow-hidden", children: [
434
+ /* @__PURE__ */ jsxs6(CardHeader, { children: [
435
+ /* @__PURE__ */ jsx12(CardTitle, { children: title }),
436
+ /* @__PURE__ */ jsx12(CardDescription, { children: description })
437
+ ] }),
438
+ rows.length === 0 ? /* @__PURE__ */ jsx12("div", { className: "px-6 pb-6", children: /* @__PURE__ */ jsx12(EmptyState, { title: "No messages", description: "Nothing in this bucket right now." }) }) : /* @__PURE__ */ jsx12("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsxs6("table", { className: "w-full text-sm", children: [
439
+ /* @__PURE__ */ jsx12("thead", { className: "border-b border-[var(--border)] bg-[var(--card-muted)]", children: /* @__PURE__ */ jsxs6("tr", { children: [
440
+ /* @__PURE__ */ jsx12("th", { className: "px-4 py-2 text-left font-medium text-[var(--muted)]", children: "State" }),
441
+ /* @__PURE__ */ jsx12("th", { className: "px-4 py-2 text-left font-medium text-[var(--muted)]", children: "Subject" }),
442
+ /* @__PURE__ */ jsx12("th", { className: "px-4 py-2 text-left font-medium text-[var(--muted)]", children: "Provider" }),
443
+ /* @__PURE__ */ jsx12("th", { className: "px-4 py-2 text-left font-medium text-[var(--muted)]", children: "Attempts" }),
444
+ /* @__PURE__ */ jsx12("th", { className: "px-4 py-2 text-left font-medium text-[var(--muted)]", children: "Last error" }),
445
+ /* @__PURE__ */ jsx12("th", { className: "px-4 py-2 text-left font-medium text-[var(--muted)]", children: "Next attempt" }),
446
+ /* @__PURE__ */ jsx12("th", { className: "px-4 py-2 text-left font-medium text-[var(--muted)]", children: "Created" }),
447
+ /* @__PURE__ */ jsx12("th", { className: "px-4 py-2 text-left font-medium text-[var(--muted)]", children: "Audit" })
448
+ ] }) }),
449
+ /* @__PURE__ */ jsx12("tbody", { className: "divide-y divide-[var(--border)]", children: rows.map((row) => /* @__PURE__ */ jsxs6("tr", { className: "hover:bg-[var(--card-muted)]", children: [
450
+ /* @__PURE__ */ jsx12("td", { className: "px-4 py-3", children: stateBadge(row.state) }),
451
+ /* @__PURE__ */ jsxs6("td", { className: "px-4 py-3", children: [
452
+ /* @__PURE__ */ jsx12("div", { className: "font-medium", children: row.subject }),
453
+ /* @__PURE__ */ jsx12("div", { className: "font-mono text-xs text-[var(--muted)]", children: row.id })
454
+ ] }),
455
+ /* @__PURE__ */ jsx12("td", { className: "px-4 py-3", children: row.provider }),
456
+ /* @__PURE__ */ jsx12("td", { className: "px-4 py-3", children: row.attempts }),
457
+ /* @__PURE__ */ jsx12("td", { className: "max-w-[200px] px-4 py-3", children: row.lastError ? /* @__PURE__ */ jsx12(
458
+ "span",
459
+ {
460
+ className: "line-clamp-2 text-xs text-[var(--danger)]",
461
+ title: row.lastError,
462
+ children: row.lastError
463
+ }
464
+ ) : /* @__PURE__ */ jsx12("span", { className: "text-[var(--muted)]", children: "\u2014" }) }),
465
+ /* @__PURE__ */ jsx12("td", { className: "px-4 py-3 text-[var(--muted)]", children: formatDate(row.nextAttemptAt) }),
466
+ /* @__PURE__ */ jsx12("td", { className: "px-4 py-3 text-[var(--muted)]", children: formatDate(row.createdAt) }),
467
+ /* @__PURE__ */ jsx12("td", { className: "px-4 py-3", children: /* @__PURE__ */ jsx12(Button, { variant: "secondary", onClick: () => onViewAudit(row), children: "View" }) })
468
+ ] }, row.id)) })
469
+ ] }) })
470
+ ] });
471
+ }
472
+ function AdminQueuePage({ apiBase = "/api/outpost" }) {
473
+ const resolved = useUiPaths();
474
+ const configPath = `${resolved.adminPanel}/config`;
475
+ const [data, setData] = useState(null);
476
+ const [isLoading, setIsLoading] = useState(true);
477
+ const [isRunningWorker, setIsRunningWorker] = useState(false);
478
+ const [error, setError] = useState("");
479
+ const [workerResult, setWorkerResult] = useState("");
480
+ const [auditMessage, setAuditMessage] = useState(null);
481
+ const load = useCallback(async () => {
482
+ setIsLoading(true);
483
+ setError("");
484
+ try {
485
+ const res = await fetch(`${apiBase}/admin/queue`);
486
+ if (!res.ok) throw new Error("Failed to load");
487
+ setData(await res.json());
488
+ } catch {
489
+ setError("Failed to load the email queue. Please try again.");
490
+ } finally {
491
+ setIsLoading(false);
492
+ }
493
+ }, [apiBase]);
494
+ useEffect(() => {
495
+ void load();
496
+ }, [load]);
497
+ async function runWorker() {
498
+ setIsRunningWorker(true);
499
+ setError("");
500
+ setWorkerResult("");
501
+ try {
502
+ const res = await fetch(`${apiBase}/admin/worker/send`, { method: "POST" });
503
+ if (!res.ok) throw new Error("Worker run failed");
504
+ const report = await res.json();
505
+ setWorkerResult(`Worker finished: claimed ${report.claimed ?? 0} message(s).`);
506
+ await load();
507
+ } catch {
508
+ setError("Failed to run the send worker. Please try again.");
509
+ } finally {
510
+ setIsRunningWorker(false);
511
+ }
512
+ }
513
+ return /* @__PURE__ */ jsxs6(PageShell, { width: "wide", children: [
514
+ /* @__PURE__ */ jsxs6("div", { className: "mb-4 text-sm text-[var(--muted)]", children: [
515
+ /* @__PURE__ */ jsx12(Link2, { href: resolved.adminPanel, className: "hover:underline", children: "Admin" }),
516
+ /* @__PURE__ */ jsx12("span", { className: "mx-2", children: "/" }),
517
+ /* @__PURE__ */ jsx12("span", { className: "text-[var(--foreground)]", children: "Email Queue" })
518
+ ] }),
519
+ /* @__PURE__ */ jsx12(
520
+ PageHeader,
521
+ {
522
+ title: "Email Queue",
523
+ description: "Messages waiting to be sent. Run the send worker to process the next batch.",
524
+ action: /* @__PURE__ */ jsxs6("div", { className: "flex gap-2", children: [
525
+ /* @__PURE__ */ jsx12(Button, { variant: "secondary", onClick: load, disabled: isLoading, children: isLoading ? "Loading\u2026" : "Refresh" }),
526
+ /* @__PURE__ */ jsx12(Button, { variant: "primary", onClick: runWorker, disabled: isRunningWorker, children: isRunningWorker ? "Running\u2026" : "Run send worker" })
527
+ ] })
528
+ }
529
+ ),
530
+ error && /* @__PURE__ */ jsx12(Alert, { variant: "danger", className: "mb-4", children: error }),
531
+ workerResult && /* @__PURE__ */ jsx12(Alert, { variant: "success", className: "mb-4", children: workerResult }),
532
+ /* @__PURE__ */ jsx12("div", { className: "mb-6", children: /* @__PURE__ */ jsx12(PipelineConfigCard, { apiBase, configPath }) }),
533
+ isLoading ? /* @__PURE__ */ jsx12(LoadingState, { label: "Loading queue" }) : data ? /* @__PURE__ */ jsxs6("div", { className: "space-y-6", children: [
534
+ /* @__PURE__ */ jsxs6("div", { className: "grid gap-3 sm:grid-cols-3", children: [
535
+ /* @__PURE__ */ jsxs6(Card, { muted: true, children: [
536
+ /* @__PURE__ */ jsx12("p", { className: "text-xs uppercase tracking-wide text-[var(--muted)]", children: "Queued" }),
537
+ /* @__PURE__ */ jsx12("p", { className: "mt-1 text-2xl font-semibold", children: data.counts.queued ?? 0 })
538
+ ] }),
539
+ /* @__PURE__ */ jsxs6(Card, { muted: true, children: [
540
+ /* @__PURE__ */ jsx12("p", { className: "text-xs uppercase tracking-wide text-[var(--muted)]", children: "Sending" }),
541
+ /* @__PURE__ */ jsx12("p", { className: "mt-1 text-2xl font-semibold", children: data.counts.sending ?? 0 })
542
+ ] }),
543
+ /* @__PURE__ */ jsxs6(Card, { muted: true, children: [
544
+ /* @__PURE__ */ jsx12("p", { className: "text-xs uppercase tracking-wide text-[var(--muted)]", children: "Failed (DLQ)" }),
545
+ /* @__PURE__ */ jsx12("p", { className: "mt-1 text-2xl font-semibold", children: data.counts.failed ?? 0 })
546
+ ] })
547
+ ] }),
548
+ /* @__PURE__ */ jsx12(
549
+ MessageTable,
550
+ {
551
+ title: "Queued",
552
+ description: "Persisted and waiting for the send worker.",
553
+ rows: data.queued,
554
+ onViewAudit: setAuditMessage
555
+ }
556
+ ),
557
+ /* @__PURE__ */ jsx12(
558
+ MessageTable,
559
+ {
560
+ title: "Sending",
561
+ description: "Claimed by a worker; will be reclaimed if the lease expires.",
562
+ rows: data.sending,
563
+ onViewAudit: setAuditMessage
564
+ }
565
+ ),
566
+ /* @__PURE__ */ jsx12(
567
+ MessageTable,
568
+ {
569
+ title: "Failed",
570
+ description: "Dead-lettered after retries exhausted. Last error often reflects sanitization, domain, or provider failure.",
571
+ rows: data.failed,
572
+ onViewAudit: setAuditMessage
573
+ }
574
+ )
575
+ ] }) : null,
576
+ auditMessage && /* @__PURE__ */ jsx12(
577
+ AuditTrailPanel,
578
+ {
579
+ apiBase,
580
+ messageId: auditMessage.id,
581
+ subject: auditMessage.subject,
582
+ onClose: () => setAuditMessage(null)
583
+ }
584
+ )
585
+ ] });
586
+ }
587
+
588
+ // src/modules/ui/pages/admin/admin-config-page.tsx
589
+ import { useState as useState2, useEffect as useEffect2, useCallback as useCallback2 } from "react";
590
+ import Link3 from "next/link";
591
+ import { Fragment, jsx as jsx13, jsxs as jsxs7 } from "react/jsx-runtime";
592
+ function sourceBadge(source) {
593
+ if (source === "admin") return /* @__PURE__ */ jsx13(Badge, { variant: "info", children: "admin" });
594
+ if (source === "env") return /* @__PURE__ */ jsx13(Badge, { variant: "default", children: "env" });
595
+ return /* @__PURE__ */ jsx13(Badge, { variant: "muted", children: "default" });
596
+ }
597
+ function valueDisplay(value, secret) {
598
+ if (value === void 0 || value === null) return "\u2014";
599
+ if (secret && typeof value === "string") return value;
600
+ return String(value);
601
+ }
602
+ function AdminConfigPage({ apiBase = "/api/outpost" }) {
603
+ const resolved = useUiPaths();
604
+ const [configKeys, setConfigKeys] = useState2([]);
605
+ const [isLoading, setIsLoading] = useState2(true);
606
+ const [error, setError] = useState2("");
607
+ const [editingKey, setEditingKey] = useState2(null);
608
+ const [editValue, setEditValue] = useState2("");
609
+ const [saving, setSaving] = useState2(false);
610
+ const load = useCallback2(async () => {
611
+ setIsLoading(true);
612
+ setError("");
613
+ try {
614
+ const res = await fetch(`${apiBase}/admin/config`);
615
+ if (!res.ok) throw new Error("Failed to load");
616
+ const data = await res.json();
617
+ setConfigKeys(data.keys ?? []);
618
+ } catch {
619
+ setError("Failed to load configuration.");
620
+ } finally {
621
+ setIsLoading(false);
622
+ }
623
+ }, [apiBase]);
624
+ useEffect2(() => {
625
+ void load();
626
+ }, [load]);
627
+ function startEdit(ck) {
628
+ setEditingKey(ck.key);
629
+ setEditValue(ck.secret ? "" : valueDisplay(ck.value));
630
+ }
631
+ function parseEditValue(raw) {
632
+ if (raw === "true") return true;
633
+ if (raw === "false") return false;
634
+ const n = Number(raw);
635
+ if (!Number.isNaN(n) && raw.trim() !== "") return n;
636
+ return raw;
637
+ }
638
+ async function saveEdit(key) {
639
+ setSaving(true);
640
+ setError("");
641
+ try {
642
+ const res = await fetch(`${apiBase}/admin/config`, {
643
+ method: "POST",
644
+ headers: { "Content-Type": "application/json" },
645
+ body: JSON.stringify({ key, value: parseEditValue(editValue) })
646
+ });
647
+ if (!res.ok) {
648
+ const data = await res.json().catch(() => ({}));
649
+ throw new Error(data.error ?? "Save failed");
650
+ }
651
+ setEditingKey(null);
652
+ await load();
653
+ } catch (e) {
654
+ setError(e instanceof Error ? e.message : "Failed to save.");
655
+ } finally {
656
+ setSaving(false);
657
+ }
658
+ }
659
+ async function resetOverride(key) {
660
+ setSaving(true);
661
+ try {
662
+ await fetch(`${apiBase}/admin/config`, {
663
+ method: "DELETE",
664
+ headers: { "Content-Type": "application/json" },
665
+ body: JSON.stringify({ key })
666
+ });
667
+ await load();
668
+ } catch {
669
+ setError("Failed to reset override.");
670
+ } finally {
671
+ setSaving(false);
672
+ }
673
+ }
674
+ return /* @__PURE__ */ jsxs7(PageShell, { width: "wide", children: [
675
+ /* @__PURE__ */ jsxs7("div", { className: "mb-4 text-sm text-[var(--muted)]", children: [
676
+ /* @__PURE__ */ jsx13(Link3, { href: resolved.adminPanel, className: "hover:underline", children: "Admin" }),
677
+ /* @__PURE__ */ jsx13("span", { className: "mx-2", children: "/" }),
678
+ /* @__PURE__ */ jsx13("span", { className: "text-[var(--foreground)]", children: "Configuration" })
679
+ ] }),
680
+ /* @__PURE__ */ jsx13(
681
+ PageHeader,
682
+ {
683
+ title: "Configuration",
684
+ description: "Priority: admin override \u2192 env.local \u2192 package default. Secrets are masked in the UI.",
685
+ action: /* @__PURE__ */ jsx13(Button, { variant: "secondary", onClick: load, disabled: isLoading, children: "Refresh" })
686
+ }
687
+ ),
688
+ error && /* @__PURE__ */ jsx13(Alert, { variant: "danger", className: "mb-4", children: error }),
689
+ isLoading ? /* @__PURE__ */ jsx13(LoadingState, { label: "Loading config" }) : /* @__PURE__ */ jsxs7(Card, { className: "overflow-hidden", children: [
690
+ /* @__PURE__ */ jsxs7(CardHeader, { children: [
691
+ /* @__PURE__ */ jsx13(CardTitle, { children: "Vault & environment settings" }),
692
+ /* @__PURE__ */ jsx13(CardDescription, { children: "Keys mirror `.env.example` and `createOutpost` options. Admin overrides persist in the database." })
693
+ ] }),
694
+ /* @__PURE__ */ jsx13("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsxs7("table", { className: "w-full text-sm", children: [
695
+ /* @__PURE__ */ jsx13("thead", { className: "border-b border-[var(--border)] bg-[var(--card-muted)]", children: /* @__PURE__ */ jsxs7("tr", { children: [
696
+ /* @__PURE__ */ jsx13("th", { className: "px-4 py-2 text-left font-medium text-[var(--muted)]", children: "Key" }),
697
+ /* @__PURE__ */ jsx13("th", { className: "px-4 py-2 text-left font-medium text-[var(--muted)]", children: "Source" }),
698
+ /* @__PURE__ */ jsx13("th", { className: "px-4 py-2 text-left font-medium text-[var(--muted)]", children: "Value" }),
699
+ /* @__PURE__ */ jsx13("th", { className: "px-4 py-2" })
700
+ ] }) }),
701
+ /* @__PURE__ */ jsx13("tbody", { className: "divide-y divide-[var(--border)]", children: configKeys.map((ck) => /* @__PURE__ */ jsxs7("tr", { className: "hover:bg-[var(--card-muted)]", children: [
702
+ /* @__PURE__ */ jsx13("td", { className: "px-4 py-3 font-mono text-xs", children: ck.key }),
703
+ /* @__PURE__ */ jsx13("td", { className: "px-4 py-3", children: sourceBadge(ck.source) }),
704
+ /* @__PURE__ */ jsx13("td", { className: "px-4 py-3", children: editingKey === ck.key ? /* @__PURE__ */ jsx13(
705
+ Input,
706
+ {
707
+ className: "h-7 text-xs",
708
+ type: ck.secret ? "password" : "text",
709
+ placeholder: ck.secret ? "Enter new value" : void 0,
710
+ value: editValue,
711
+ onChange: (e) => setEditValue(e.target.value),
712
+ onKeyDown: (e) => {
713
+ if (e.key === "Enter") void saveEdit(ck.key);
714
+ if (e.key === "Escape") setEditingKey(null);
715
+ },
716
+ autoFocus: true
717
+ }
718
+ ) : /* @__PURE__ */ jsx13("span", { className: "font-mono text-xs", children: valueDisplay(ck.value, ck.secret) }) }),
719
+ /* @__PURE__ */ jsx13("td", { className: "px-4 py-3 text-right", children: /* @__PURE__ */ jsx13("div", { className: "flex items-center justify-end gap-2", children: editingKey === ck.key ? /* @__PURE__ */ jsxs7(Fragment, { children: [
720
+ /* @__PURE__ */ jsx13(
721
+ Button,
722
+ {
723
+ variant: "primary",
724
+ className: "text-xs",
725
+ disabled: saving,
726
+ onClick: () => saveEdit(ck.key),
727
+ children: saving ? "Saving\u2026" : "Save"
728
+ }
729
+ ),
730
+ /* @__PURE__ */ jsx13(
731
+ Button,
732
+ {
733
+ variant: "secondary",
734
+ className: "text-xs",
735
+ onClick: () => setEditingKey(null),
736
+ children: "Cancel"
737
+ }
738
+ )
739
+ ] }) : /* @__PURE__ */ jsxs7(Fragment, { children: [
740
+ /* @__PURE__ */ jsx13(Button, { variant: "secondary", className: "text-xs", onClick: () => startEdit(ck), children: "Edit" }),
741
+ ck.source === "admin" && /* @__PURE__ */ jsx13(
742
+ Button,
743
+ {
744
+ variant: "danger",
745
+ className: "text-xs",
746
+ disabled: saving,
747
+ onClick: () => resetOverride(ck.key),
748
+ children: "Reset"
749
+ }
750
+ )
751
+ ] }) }) })
752
+ ] }, ck.key)) })
753
+ ] }) })
754
+ ] })
755
+ ] });
756
+ }
757
+
758
+ // src/modules/ui/pages/admin/admin-observability-page.tsx
759
+ import { useState as useState3, useEffect as useEffect3, useCallback as useCallback3 } from "react";
760
+ import Link4 from "next/link";
761
+ import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
762
+ function AdminObservabilityPage({ apiBase = "/api/outpost" }) {
763
+ const resolved = useUiPaths();
764
+ const [data, setData] = useState3(null);
765
+ const [isLoading, setIsLoading] = useState3(true);
766
+ const [error, setError] = useState3("");
767
+ const load = useCallback3(async () => {
768
+ setIsLoading(true);
769
+ setError("");
770
+ try {
771
+ const res = await fetch(`${apiBase}/admin/observability`);
772
+ if (!res.ok) throw new Error("Failed to load");
773
+ setData(await res.json());
774
+ } catch {
775
+ setError("Failed to load observability data.");
776
+ } finally {
777
+ setIsLoading(false);
778
+ }
779
+ }, [apiBase]);
780
+ useEffect3(() => {
781
+ void load();
782
+ }, [load]);
783
+ return /* @__PURE__ */ jsxs8(PageShell, { width: "wide", children: [
784
+ /* @__PURE__ */ jsxs8("div", { className: "mb-4 text-sm text-[var(--muted)]", children: [
785
+ /* @__PURE__ */ jsx14(Link4, { href: resolved.adminPanel, className: "hover:underline", children: "Admin" }),
786
+ /* @__PURE__ */ jsx14("span", { className: "mx-2", children: "/" }),
787
+ /* @__PURE__ */ jsx14("span", { className: "text-[var(--foreground)]", children: "Observability" })
788
+ ] }),
789
+ /* @__PURE__ */ jsx14(
790
+ PageHeader,
791
+ {
792
+ title: "Observability",
793
+ description: "Operational snapshot from the outbox. Export OpenTelemetry metrics to your collector for dashboards.",
794
+ action: /* @__PURE__ */ jsx14(Button, { variant: "secondary", onClick: load, disabled: isLoading, children: isLoading ? "Loading\u2026" : "Refresh" })
795
+ }
796
+ ),
797
+ error && /* @__PURE__ */ jsx14(Alert, { variant: "danger", className: "mb-4", children: error }),
798
+ isLoading ? /* @__PURE__ */ jsx14(LoadingState, { label: "Loading observability" }) : data ? /* @__PURE__ */ jsxs8("div", { className: "space-y-6", children: [
799
+ /* @__PURE__ */ jsxs8("div", { className: "grid gap-3 sm:grid-cols-2 lg:grid-cols-4", children: [
800
+ Object.entries(data.countsByState).map(([state, count]) => /* @__PURE__ */ jsxs8(Card, { muted: true, children: [
801
+ /* @__PURE__ */ jsx14("p", { className: "text-xs uppercase tracking-wide text-[var(--muted)]", children: state }),
802
+ /* @__PURE__ */ jsx14("p", { className: "mt-1 text-2xl font-semibold", children: count })
803
+ ] }, state)),
804
+ /* @__PURE__ */ jsxs8(Card, { muted: true, children: [
805
+ /* @__PURE__ */ jsx14("p", { className: "text-xs uppercase tracking-wide text-[var(--muted)]", children: "suppressions" }),
806
+ /* @__PURE__ */ jsx14("p", { className: "mt-1 text-2xl font-semibold", children: data.suppressionCount })
807
+ ] })
808
+ ] }),
809
+ /* @__PURE__ */ jsxs8(Card, { children: [
810
+ /* @__PURE__ */ jsxs8(CardHeader, { children: [
811
+ /* @__PURE__ */ jsx14(CardTitle, { children: "Last send worker run" }),
812
+ /* @__PURE__ */ jsx14(CardDescription, { children: 'Updated when an operator clicks "Run send worker" on the queue page or a cron invokes the worker.' })
813
+ ] }),
814
+ data.lastWorkerRun ? /* @__PURE__ */ jsxs8("div", { className: "grid gap-4 sm:grid-cols-2 lg:grid-cols-3 text-sm", children: [
815
+ /* @__PURE__ */ jsxs8("div", { children: [
816
+ /* @__PURE__ */ jsx14("p", { className: "text-[var(--muted)]", children: "At" }),
817
+ /* @__PURE__ */ jsx14("p", { children: new Date(data.lastWorkerRun.at).toLocaleString() })
818
+ ] }),
819
+ /* @__PURE__ */ jsxs8("div", { children: [
820
+ /* @__PURE__ */ jsx14("p", { className: "text-[var(--muted)]", children: "Claimed" }),
821
+ /* @__PURE__ */ jsx14("p", { children: data.lastWorkerRun.claimed })
822
+ ] }),
823
+ /* @__PURE__ */ jsxs8("div", { children: [
824
+ /* @__PURE__ */ jsx14("p", { className: "text-[var(--muted)]", children: "Sent" }),
825
+ /* @__PURE__ */ jsx14("p", { children: data.lastWorkerRun.sent })
826
+ ] }),
827
+ /* @__PURE__ */ jsxs8("div", { children: [
828
+ /* @__PURE__ */ jsx14("p", { className: "text-[var(--muted)]", children: "Retried" }),
829
+ /* @__PURE__ */ jsx14("p", { children: data.lastWorkerRun.retried })
830
+ ] }),
831
+ /* @__PURE__ */ jsxs8("div", { children: [
832
+ /* @__PURE__ */ jsx14("p", { className: "text-[var(--muted)]", children: "Rate limited" }),
833
+ /* @__PURE__ */ jsx14("p", { children: data.lastWorkerRun.rateLimited })
834
+ ] }),
835
+ /* @__PURE__ */ jsxs8("div", { children: [
836
+ /* @__PURE__ */ jsx14("p", { className: "text-[var(--muted)]", children: "Failed (DLQ)" }),
837
+ /* @__PURE__ */ jsx14("p", { children: data.lastWorkerRun.failed })
838
+ ] })
839
+ ] }) : /* @__PURE__ */ jsx14("p", { className: "text-sm text-[var(--muted)]", children: "No worker run recorded yet." })
840
+ ] }),
841
+ /* @__PURE__ */ jsxs8(Card, { className: "overflow-hidden", children: [
842
+ /* @__PURE__ */ jsxs8(CardHeader, { children: [
843
+ /* @__PURE__ */ jsx14(CardTitle, { children: "OpenTelemetry metrics" }),
844
+ /* @__PURE__ */ jsx14(CardDescription, { children: "Emitted when `OtelTelemetry` is wired. Point your SDK exporter at these names." })
845
+ ] }),
846
+ /* @__PURE__ */ jsx14("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsxs8("table", { className: "w-full text-sm", children: [
847
+ /* @__PURE__ */ jsx14("thead", { className: "border-b border-[var(--border)] bg-[var(--card-muted)]", children: /* @__PURE__ */ jsxs8("tr", { children: [
848
+ /* @__PURE__ */ jsx14("th", { className: "px-4 py-2 text-left font-medium text-[var(--muted)]", children: "Name" }),
849
+ /* @__PURE__ */ jsx14("th", { className: "px-4 py-2 text-left font-medium text-[var(--muted)]", children: "Type" }),
850
+ /* @__PURE__ */ jsx14("th", { className: "px-4 py-2 text-left font-medium text-[var(--muted)]", children: "Description" })
851
+ ] }) }),
852
+ /* @__PURE__ */ jsx14("tbody", { className: "divide-y divide-[var(--border)]", children: data.metrics.map((m) => /* @__PURE__ */ jsxs8("tr", { className: "hover:bg-[var(--card-muted)]", children: [
853
+ /* @__PURE__ */ jsx14("td", { className: "px-4 py-3 font-mono text-xs", children: m.name }),
854
+ /* @__PURE__ */ jsx14("td", { className: "px-4 py-3", children: /* @__PURE__ */ jsx14(Badge, { variant: m.type === "gauge" ? "info" : "default", children: m.type }) }),
855
+ /* @__PURE__ */ jsx14("td", { className: "px-4 py-3 text-[var(--muted)]", children: m.description })
856
+ ] }, m.name)) })
857
+ ] }) })
858
+ ] })
859
+ ] }) : null
860
+ ] });
861
+ }
862
+ export {
863
+ AdminConfigPage,
864
+ AdminObservabilityPage,
865
+ AdminPanelPage,
866
+ AdminQueuePage,
867
+ Alert,
868
+ Badge,
869
+ Button,
870
+ Card,
871
+ CardDescription,
872
+ CardHeader,
873
+ CardTitle,
874
+ DEFAULT_OUTPOST_PATHS,
875
+ EmptyState,
876
+ Input,
877
+ LoadingState,
878
+ OutpostUIProvider,
879
+ PageHeader,
880
+ PageShell,
881
+ resolveOutpostPaths,
882
+ useOutpostUi,
883
+ useUiPaths
884
+ };
885
+ //# sourceMappingURL=index.js.map