appos 0.10.5-0 → 0.11.0-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.
Files changed (192) hide show
  1. package/dist/admin-rt00c3tJ.d.mts +411 -0
  2. package/dist/api/admin.d.mts +303 -0
  3. package/dist/api/admin.mjs +711 -0
  4. package/dist/api/auth.d.mts +3 -3
  5. package/dist/api/auth.mjs +52 -21
  6. package/dist/api/cache.d.mts +3 -3
  7. package/dist/api/cache.mjs +13 -4
  8. package/dist/api/cli.d.mts +5 -5
  9. package/dist/api/cli.mjs +49 -32
  10. package/dist/api/container.d.mts +6 -6
  11. package/dist/api/container.mjs +30 -3
  12. package/dist/api/database.d.mts +2 -2
  13. package/dist/api/database.mjs +2 -2
  14. package/dist/api/event.d.mts +8 -7
  15. package/dist/api/event.mjs +65 -39
  16. package/dist/api/flags.d.mts +134 -0
  17. package/dist/api/flags.mjs +206 -0
  18. package/dist/api/instrumentation.d.mts +1 -1
  19. package/dist/api/instrumentation.mjs +1 -1
  20. package/dist/api/mailer.d.mts +5 -5
  21. package/dist/api/mailer.mjs +5 -5
  22. package/dist/api/observability.d.mts +3 -3
  23. package/dist/api/observability.mjs +10 -19
  24. package/dist/api/openapi.d.mts +273 -5
  25. package/dist/api/openapi.mjs +63 -29
  26. package/dist/api/resource.d.mts +286 -0
  27. package/dist/api/resource.mjs +568 -0
  28. package/dist/api/server.d.mts +6 -5
  29. package/dist/api/server.mjs +7 -5
  30. package/dist/api/ssr.d.mts +7 -5
  31. package/dist/api/ssr.mjs +3 -3
  32. package/dist/api/storage.d.mts +5 -5
  33. package/dist/api/storage.mjs +14 -7
  34. package/dist/api/trpc.d.mts +8 -0
  35. package/dist/api/trpc.mjs +989 -0
  36. package/dist/api/workflow.d.mts +6 -6
  37. package/dist/api/workflow.mjs +4 -4
  38. package/dist/app-context-CpewsStA.mjs +3 -0
  39. package/dist/{app-context-B442LxCN.mjs → app-context-DPuAYWnM.mjs} +6 -1
  40. package/dist/{auth-Cn1L6HLs.d.mts → auth-6bcoHRzX.d.mts} +15 -5
  41. package/dist/{auth-ZWBLYkOZ.d.ts → auth-CM9UGyRn.d.ts} +3741 -1634
  42. package/dist/auth-DCkWiPo6.js +14 -0
  43. package/dist/{cache-CJqBlATk.d.mts → cache-CXBmRwD6.d.mts} +16 -4
  44. package/dist/colors-Cgn4NW4l.mjs +3 -0
  45. package/dist/{constants-D14iAtMu.mjs → constants-D5R9dkoU.mjs} +3 -3
  46. package/dist/{container-CIm1-Ogf.d.mts → container-DK4Ztu83.d.mts} +2390 -2671
  47. package/dist/{database-lzS5JWOl.mjs → database-BX0Pqc6E.mjs} +11 -4
  48. package/dist/{database-C4QyLQ0H.d.mts → database-CsDWKQ7i.d.mts} +1 -1
  49. package/dist/devtools/test.d.mts +9 -7
  50. package/dist/devtools/test.mjs +9 -7
  51. package/dist/devtools/vite.mjs +5 -5
  52. package/dist/index--rzwqsGa.d.mts +16 -0
  53. package/dist/{logger-BoaRYCuF.d.mts → logger-GuMZy8FH.d.mts} +3 -8
  54. package/dist/{observability-NQdrXEya.d.mts → observability-D6BWQ_bu.d.mts} +8 -10
  55. package/dist/{panel-Ci_q5lir.mjs → panel-CJ6zAL1n.mjs} +3 -2
  56. package/dist/panel-DYzMVRZl.mjs +5 -0
  57. package/dist/{redis-DwTSiGWI.mjs → redis-zu6SD_Wj.mjs} +27 -3
  58. package/dist/{routes-BCFBeb0b.mjs → routes-AvR9aKXG.mjs} +2 -2
  59. package/dist/routes-DIsmPq53.mjs +4 -0
  60. package/dist/{server-BwlYpYEN.mjs → server-DHzvcfxr.mjs} +56 -40
  61. package/dist/server-PKeb9zjC.d.mts +114 -0
  62. package/dist/trpc-C0E6-AHq.d.mts +781 -0
  63. package/dist/universal/auth.js +2 -1
  64. package/dist/universal/config.js +3 -3
  65. package/dist/use-mobile-BV_aQ_YE.js +39 -0
  66. package/dist/{utils-B638PyaT.d.ts → utils-B84tFWJA.d.ts} +2 -2
  67. package/dist/{utils-C7VSFtlY.js → utils-DZTzrwAc.js} +17 -1
  68. package/dist/web/admin.d.ts +65 -0
  69. package/dist/web/admin.js +125 -0
  70. package/dist/web/auth.d.ts +2 -2
  71. package/dist/web/auth.js +5 -14
  72. package/dist/web/hooks.d.ts +20 -0
  73. package/dist/web/hooks.js +1 -1
  74. package/dist/web/trpc.d.ts +2020 -0
  75. package/dist/web/trpc.js +786 -0
  76. package/dist/web/ui/accordion.js +1 -1
  77. package/dist/web/ui/alert-dialog.js +1 -1
  78. package/dist/web/ui/alert.js +1 -1
  79. package/dist/web/ui/animated-check.d.ts +1 -1
  80. package/dist/web/ui/animated-check.js +1 -1
  81. package/dist/web/ui/aspect-ratio.js +1 -1
  82. package/dist/web/ui/auth.d.ts +2 -2
  83. package/dist/web/ui/auth.js +3 -3
  84. package/dist/web/ui/avatar.js +1 -1
  85. package/dist/web/ui/badge.d.ts +1 -1
  86. package/dist/web/ui/badge.js +1 -1
  87. package/dist/web/ui/brand.d.ts +2 -2
  88. package/dist/web/ui/brand.js +1 -1
  89. package/dist/web/ui/breadcrumb.js +1 -1
  90. package/dist/web/ui/button-group.js +1 -1
  91. package/dist/web/ui/button.d.ts +2 -2
  92. package/dist/web/ui/button.js +1 -1
  93. package/dist/web/ui/calendar.js +1 -1
  94. package/dist/web/ui/card.js +1 -1
  95. package/dist/web/ui/carousel.js +1 -1
  96. package/dist/web/ui/chart.js +1 -1
  97. package/dist/web/ui/checkbox.js +1 -1
  98. package/dist/web/ui/command.js +1 -1
  99. package/dist/web/ui/context-menu.js +1 -1
  100. package/dist/web/ui/dialog.js +1 -1
  101. package/dist/web/ui/drawer.js +1 -1
  102. package/dist/web/ui/dropdown-menu.js +1 -1
  103. package/dist/web/ui/empty.js +1 -1
  104. package/dist/web/ui/error-page.js +1 -1
  105. package/dist/web/ui/field.js +1 -1
  106. package/dist/web/ui/hover-card.js +1 -1
  107. package/dist/web/ui/input-group.js +1 -1
  108. package/dist/web/ui/input-otp.js +1 -1
  109. package/dist/web/ui/input.js +1 -1
  110. package/dist/web/ui/item.d.ts +1 -1
  111. package/dist/web/ui/item.js +1 -1
  112. package/dist/web/ui/kbd.js +1 -1
  113. package/dist/web/ui/label.js +1 -1
  114. package/dist/web/ui/menubar.js +1 -1
  115. package/dist/web/ui/navigation-menu.js +1 -1
  116. package/dist/web/ui/pagination.js +1 -1
  117. package/dist/web/ui/popover.js +1 -1
  118. package/dist/web/ui/progress.js +1 -1
  119. package/dist/web/ui/radio-group.js +1 -1
  120. package/dist/web/ui/resizable.js +1 -1
  121. package/dist/web/ui/scroll-area.js +1 -1
  122. package/dist/web/ui/select.js +1 -1
  123. package/dist/web/ui/separator.js +1 -1
  124. package/dist/web/ui/sheet.js +1 -1
  125. package/dist/web/ui/sidebar.d.ts +2 -2
  126. package/dist/web/ui/sidebar.js +7 -7
  127. package/dist/web/ui/skeleton.js +1 -1
  128. package/dist/web/ui/slider.js +1 -1
  129. package/dist/web/ui/spinner.js +1 -1
  130. package/dist/web/ui/switch.js +1 -1
  131. package/dist/web/ui/table.js +1 -1
  132. package/dist/web/ui/tabs.js +1 -1
  133. package/dist/web/ui/textarea.js +1 -1
  134. package/dist/web/ui/theme.js +1 -1
  135. package/dist/web/ui/toggle-group.js +1 -1
  136. package/dist/web/ui/toggle.d.ts +1 -1
  137. package/dist/web/ui/toggle.js +1 -1
  138. package/dist/web/ui/tooltip.js +1 -1
  139. package/dist/{workflow-Cc101G1B.mjs → workflow-Cj0Ph4Qz.mjs} +5 -5
  140. package/dist/ws-DokuCyJg.mjs +70 -0
  141. package/package.json +70 -42
  142. package/src/devtools/panel/index.ts +3 -1
  143. package/src/devtools/panel/modules/flags/routes.ts +40 -0
  144. package/src/devtools/panel/modules/workflows/routes.ts +63 -0
  145. package/src/devtools/storybook/components/index.ts +1 -0
  146. package/src/universal/auth.ts +5 -9
  147. package/src/universal/config.test.ts +3 -3
  148. package/src/universal/config.ts +3 -3
  149. package/src/web/admin.ts +159 -0
  150. package/src/web/client/admin/context.tsx +179 -0
  151. package/src/web/client/admin/field-renderers.tsx +537 -0
  152. package/src/web/client/admin/metric-cards.tsx +214 -0
  153. package/src/web/client/auth.ts +6 -0
  154. package/src/web/client/trpc.test.tsx +1023 -0
  155. package/src/web/client/trpc.tsx +1341 -0
  156. package/src/web/hooks/use-feature-flag.ts +87 -0
  157. package/src/web/hooks/use-mobile.ts +20 -0
  158. package/src/web/lib/utils.ts +16 -0
  159. package/src/web/routes/admin/_layout.tsx +206 -0
  160. package/src/web/routes/admin/flags/$id.tsx +90 -0
  161. package/src/web/routes/admin/flags/index.tsx +52 -0
  162. package/src/web/routes/admin/index.tsx +130 -0
  163. package/src/web/routes/admin/observability/errors.tsx +69 -0
  164. package/src/web/routes/admin/observability/index.tsx +83 -0
  165. package/src/web/routes/admin/observability/queries.tsx +71 -0
  166. package/src/web/routes/admin/observability/requests.tsx +97 -0
  167. package/src/web/routes/admin/resources/$resource.$id.edit.tsx +105 -0
  168. package/src/web/routes/admin/resources/$resource.$id.tsx +106 -0
  169. package/src/web/routes/admin/resources/$resource.create.tsx +98 -0
  170. package/src/web/routes/admin/resources/$resource.index.tsx +141 -0
  171. package/src/web/routes/admin/tools/$tool.tsx +40 -0
  172. package/src/web/routes/admin/workflows/$id.tsx +88 -0
  173. package/src/web/routes/admin/workflows/index.tsx +163 -0
  174. package/src/web/trpc.ts +26 -0
  175. package/src/web/ui/auth/__mocks__/auth-context.tsx +1 -0
  176. package/src/web/ui/chart.stories.tsx +0 -8
  177. package/src/web/ui/sidebar.tsx +9 -9
  178. package/dist/app-context-Co0rCDdZ.mjs +0 -3
  179. package/dist/colors-B4arFOdJ.mjs +0 -3
  180. package/dist/panel-c_IJZekd.mjs +0 -5
  181. package/dist/routes-_Bw7IBYS.mjs +0 -4
  182. package/dist/use-mobile-A85-YZ1j.js +0 -19
  183. /package/dist/{auth-Bo3zawb1.mjs → auth-CWiz3z0-.mjs} +0 -0
  184. /package/dist/{auth-schema-DF53iTDS.mjs → auth-schema-uIf08Ee7.mjs} +0 -0
  185. /package/dist/{colors-HSJNJt_Y.mjs → colors-BWLGchst.mjs} +0 -0
  186. /package/dist/{context-hM-p7Yvk.js → context-BNKjCOS5.js} +0 -0
  187. /package/dist/{context-CpUat6CJ.mjs → context-Cbc7vmim.mjs} +0 -0
  188. /package/dist/{env-DEkC2Wod.mjs → env-DIQ_rqIF.mjs} +0 -0
  189. /package/dist/{instrumentation-D3_99Qvn.d.mts → instrumentation-CNF5H7Be.d.mts} +0 -0
  190. /package/dist/{instrumentation-Eq5T7g1h.mjs → instrumentation-nODQuART.mjs} +0 -0
  191. /package/dist/{vite-compat-B119swHE.mjs → vite-compat-BEPv_Akc.mjs} +0 -0
  192. /package/dist/{youch-handler-BTLdunoY.mjs → youch-handler-DBTw2Oqd.mjs} +0 -0
@@ -0,0 +1,411 @@
1
+ import { z } from "zod";
2
+
3
+ //#region src/api/lib/ui/admin.d.ts
4
+ /**
5
+ * Supported admin field types with 3 render modes each (index, detail, form).
6
+ */
7
+ type AdminFieldType = "text" | "number" | "boolean" | "datetime" | "select" | "textarea" | "markdown" | "code" | "json" | "file" | "image" | "belongsTo" | "hasMany" | "color" | "url" | "email" | "badge" | "currency";
8
+ /**
9
+ * Configuration for a single admin field.
10
+ *
11
+ * i18n key: `admin.resources.[resourceSlug].fields.[key]`
12
+ */
13
+ interface AdminFieldConfig {
14
+ /** Column/property key on the resource. */
15
+ key: string;
16
+ /** Field type determining render behavior. */
17
+ type: AdminFieldType;
18
+ /** Show this field in the index (list) table. */
19
+ indexVisible?: boolean;
20
+ /** Enable search on this field. */
21
+ searchable?: boolean;
22
+ /** Enable sorting on this field. */
23
+ sortable?: boolean;
24
+ /** Prevent editing (show as read-only in forms). */
25
+ readonly?: boolean;
26
+ /** Hide this field on the create form. */
27
+ createVisible?: boolean;
28
+ /** Hide this field on the edit form. */
29
+ editVisible?: boolean;
30
+ /** For `belongsTo`: slug of the related admin resource. */
31
+ relatedResource?: string;
32
+ /** For `belongsTo`: field on the related resource used for display. */
33
+ relatedDisplayField?: string;
34
+ /** For `select`/`badge`: possible values (labels come from i18n). */
35
+ options?: Array<{
36
+ value: string | number;
37
+ }>;
38
+ /** For `currency`: prefix string (e.g., "$", "EUR"). */
39
+ currencyPrefix?: string;
40
+ }
41
+ /**
42
+ * Configuration for a resource action.
43
+ *
44
+ * i18n keys:
45
+ * - `admin.resources.[resourceSlug].actions.[slug].label`
46
+ * - `admin.resources.[resourceSlug].actions.[slug].confirmText`
47
+ */
48
+ interface AdminActionConfig {
49
+ /** Unique action identifier. */
50
+ slug: string;
51
+ /** Visual variant for the action button. */
52
+ variant?: "default" | "destructive" | "outline";
53
+ /** Whether this action supports bulk selection. */
54
+ bulk?: boolean;
55
+ /** Permission required (e.g., `{ notes: ["delete"] }`). */
56
+ permission?: Record<string, readonly string[]>;
57
+ }
58
+ /**
59
+ * Configuration for a resource lens (predefined view).
60
+ *
61
+ * i18n key: `admin.resources.[resourceSlug].lenses.[slug]`
62
+ */
63
+ interface AdminLensConfig {
64
+ /** Unique lens identifier. */
65
+ slug: string;
66
+ /** Default sort when this lens is active. */
67
+ defaultSort?: {
68
+ column: string;
69
+ direction: "asc" | "desc";
70
+ };
71
+ /** Default filters when this lens is active. */
72
+ defaultFilters?: Record<string, string | number>;
73
+ }
74
+ /**
75
+ * A section in the resource detail view.
76
+ *
77
+ * i18n key: `admin.resources.[resourceSlug].sections.[key]`
78
+ */
79
+ interface AdminDetailSection {
80
+ /** Section identifier (used for i18n). */
81
+ key: string;
82
+ /** Fields to display in this section. */
83
+ fields: string[];
84
+ }
85
+ /**
86
+ * Admin-specific metadata that wraps a server resource for the admin panel.
87
+ */
88
+ interface AdminResourceMeta {
89
+ /** Lucide icon name for sidebar and headers. */
90
+ icon?: string;
91
+ /**
92
+ * Grouping key for sidebar navigation.
93
+ *
94
+ * i18n key: `admin.groups.[group]`
95
+ */
96
+ group?: string;
97
+ /** Field configurations with render and visibility metadata. */
98
+ fields: AdminFieldConfig[];
99
+ /** Available actions for this resource. */
100
+ actions?: AdminActionConfig[];
101
+ /** Predefined views for this resource. */
102
+ lenses?: AdminLensConfig[];
103
+ /** Detail page layout sections. */
104
+ detailLayout?: AdminDetailSection[];
105
+ }
106
+ /**
107
+ * Complete admin resource configuration as sent to the client via `admin.meta`.
108
+ */
109
+ interface AdminResourceConfig {
110
+ /** Unique slug (used in URLs and i18n keys). */
111
+ slug: string;
112
+ /** Admin-specific metadata. */
113
+ meta: AdminResourceMeta;
114
+ /** Computed permissions for the current user. */
115
+ permissions?: {
116
+ create?: boolean;
117
+ read?: boolean;
118
+ update?: boolean;
119
+ delete?: boolean;
120
+ [action: string]: boolean | undefined;
121
+ };
122
+ }
123
+ /**
124
+ * Metric display types.
125
+ */
126
+ type MetricType = "value" | "trend" | "partition" | "progress" | "table";
127
+ /**
128
+ * Base metric configuration.
129
+ *
130
+ * i18n key: `admin.metrics.[slug].label`
131
+ */
132
+ interface MetricConfig {
133
+ /** Unique metric identifier. */
134
+ slug: string;
135
+ /** How this metric should be displayed. */
136
+ type: MetricType;
137
+ }
138
+ /**
139
+ * Result data for a metric query.
140
+ */
141
+ interface MetricResult {
142
+ /** Current value. */
143
+ value: number | string;
144
+ /** Previous value for trend comparison. */
145
+ previousValue?: number | string;
146
+ /** Percentage change for trend metrics. */
147
+ change?: number;
148
+ /** Partitions for partition metrics. */
149
+ partitions?: Array<{
150
+ key: string;
151
+ value: number;
152
+ }>;
153
+ /** Progress percentage (0-100). */
154
+ progress?: number;
155
+ /** Table rows for table metrics. */
156
+ rows?: Array<Record<string, unknown>>;
157
+ /** Column definitions for table metrics. */
158
+ columns?: Array<{
159
+ key: string;
160
+ type?: string;
161
+ }>;
162
+ /** Custom suffix (e.g., "notes", "%", "ms"). */
163
+ suffix?: string;
164
+ }
165
+ /**
166
+ * Admin filter configuration.
167
+ *
168
+ * i18n key: `admin.resources.[resourceSlug].filters.[slug]`
169
+ */
170
+ interface AdminFilterConfig {
171
+ /** Unique filter identifier. */
172
+ slug: string;
173
+ /** Filter input type. */
174
+ type: "select" | "text" | "date" | "number" | "boolean";
175
+ /** For `select`: available options (labels from i18n). */
176
+ options?: Array<{
177
+ value: string | number;
178
+ }>;
179
+ }
180
+ /**
181
+ * Admin tool configuration for custom admin pages.
182
+ *
183
+ * i18n key: `admin.tools.[slug].*`
184
+ */
185
+ interface AdminToolConfig {
186
+ /** Unique tool identifier (used in URLs). */
187
+ slug: string;
188
+ /** Lucide icon name. */
189
+ icon?: string;
190
+ /** Sidebar group. */
191
+ group?: string;
192
+ }
193
+ /**
194
+ * Feature flag type.
195
+ */
196
+ type FeatureFlagType = "boolean" | "percentage" | "json";
197
+ /**
198
+ * Feature flag configuration.
199
+ *
200
+ * i18n keys:
201
+ * - `admin.flags.[name].label`
202
+ * - `admin.flags.[name].description`
203
+ */
204
+ interface FeatureFlagConfig {
205
+ /** Flag name (used in code and i18n keys). */
206
+ name: string;
207
+ /** Flag type. */
208
+ type: FeatureFlagType;
209
+ /** Default value when flag is not explicitly set. */
210
+ defaultValue: unknown;
211
+ /** Zod schema for the value (serialized as JSON schema to client). */
212
+ schema?: z.ZodType;
213
+ }
214
+ /**
215
+ * Feature flag state as sent to the client.
216
+ */
217
+ interface FeatureFlagState {
218
+ /** Flag name. */
219
+ name: string;
220
+ /** Flag type. */
221
+ type: FeatureFlagType;
222
+ /** Current value. */
223
+ value: unknown;
224
+ /** Whether the flag is enabled (for boolean type). */
225
+ enabled: boolean;
226
+ /** Number of overrides. */
227
+ overrideCount: number;
228
+ /** Last modified timestamp. */
229
+ updatedAt: string | null;
230
+ }
231
+ /**
232
+ * Feature flag override for a specific user or team.
233
+ */
234
+ interface FeatureFlagOverride {
235
+ id: string;
236
+ flagName: string;
237
+ targetType: "user" | "team" | "organization";
238
+ targetId: string;
239
+ value: unknown;
240
+ createdAt: string;
241
+ }
242
+ /**
243
+ * Feature flag audit log entry.
244
+ */
245
+ interface FeatureFlagAuditEntry {
246
+ id: string;
247
+ flagName: string;
248
+ action: "created" | "updated" | "toggled" | "override_added" | "override_removed";
249
+ previousValue: unknown;
250
+ newValue: unknown;
251
+ userId: string;
252
+ createdAt: string;
253
+ }
254
+ /**
255
+ * Workflow status values from DBOS.
256
+ */
257
+ type WorkflowStatus = "PENDING" | "SUCCESS" | "ERROR" | "RETRIES_EXCEEDED" | "CANCELLED" | "ENQUEUED";
258
+ /**
259
+ * Workflow list item.
260
+ */
261
+ interface WorkflowListItem {
262
+ workflowId: string;
263
+ status: WorkflowStatus;
264
+ name: string;
265
+ className: string;
266
+ configName: string | null;
267
+ queueName: string | null;
268
+ authenticatedUser: string | null;
269
+ assumedRole: string | null;
270
+ authenticatedRoles: string | null;
271
+ request: unknown;
272
+ output: unknown;
273
+ error: string | null;
274
+ createdAt: string;
275
+ updatedAt: string;
276
+ applicationVersion: string | null;
277
+ executorId: string | null;
278
+ recoveredBy: string | null;
279
+ }
280
+ /**
281
+ * Workflow queue status.
282
+ */
283
+ interface WorkflowQueueStatus {
284
+ name: string;
285
+ concurrency: number | null;
286
+ limiterPeriod: number | null;
287
+ limiterLimit: number | null;
288
+ activeCount: number;
289
+ pendingCount: number;
290
+ }
291
+ /**
292
+ * Configuration for the observability module.
293
+ */
294
+ interface ObservabilityConfig {
295
+ /** OpenObserve API base URL. */
296
+ openObserveUrl: string;
297
+ /** OpenObserve organization. */
298
+ org: string;
299
+ /** Default log stream name. */
300
+ stream: string;
301
+ /** Basic auth credentials (base64 encoded "user:pass"). */
302
+ credentials?: string;
303
+ }
304
+ /**
305
+ * Observability overview data.
306
+ */
307
+ interface ObservabilityOverview {
308
+ requestRate: number;
309
+ errorRate: number;
310
+ p95Latency: number;
311
+ activeUsers: number;
312
+ }
313
+ /**
314
+ * Configuration for `defineAdminRouter()`.
315
+ */
316
+ interface AdminRouterConfig {
317
+ /** Admin resources to register. */
318
+ resources: AdminResourceDefinition[];
319
+ /** Metrics to register. */
320
+ metrics?: MetricDefinition[];
321
+ /** Custom tools to register. */
322
+ tools?: AdminToolDefinition[];
323
+ /** Enable workflow dashboard. */
324
+ workflows?: {
325
+ enabled: boolean;
326
+ };
327
+ /** Enable feature flags management. */
328
+ flags?: {
329
+ enabled: boolean;
330
+ };
331
+ /** Observability configuration. */
332
+ observability?: ObservabilityConfig;
333
+ /** Panel-level permission check. */
334
+ permission?: Record<string, readonly string[]>;
335
+ }
336
+ /**
337
+ * Opaque type for an admin resource definition created by `defineAdminResource()`.
338
+ */
339
+ interface AdminResourceDefinition {
340
+ readonly __brand: "AdminResourceDefinition";
341
+ readonly slug: string;
342
+ readonly meta: AdminResourceMeta;
343
+ readonly permissions: {
344
+ subject: string;
345
+ };
346
+ readonly createSchema?: z.ZodType;
347
+ readonly updateSchema?: z.ZodType;
348
+ readonly resource: {
349
+ inputSchema: z.ZodType;
350
+ tableName: string;
351
+ defineQueryBuilder: (db: unknown) => {
352
+ listOffset: (params: unknown) => Promise<unknown>;
353
+ };
354
+ };
355
+ }
356
+ /**
357
+ * Opaque type for a metric definition created by `defineMetric()`.
358
+ */
359
+ interface MetricDefinition {
360
+ readonly __brand: "MetricDefinition";
361
+ readonly slug: string;
362
+ readonly type: MetricType;
363
+ readonly resolve: (ctx: unknown) => Promise<MetricResult>;
364
+ }
365
+ /**
366
+ * Opaque type for an action definition created by `defineAction()`.
367
+ */
368
+ interface ActionDefinition {
369
+ readonly __brand: "ActionDefinition";
370
+ readonly slug: string;
371
+ readonly handle: (ctx: unknown, ids: string[], input?: unknown) => Promise<unknown>;
372
+ readonly permission?: Record<string, readonly string[]>;
373
+ readonly inputSchema?: z.ZodType;
374
+ }
375
+ /**
376
+ * Opaque type for a filter definition created by `defineAdminFilter()`.
377
+ */
378
+ interface AdminFilterDefinition {
379
+ readonly __brand: "AdminFilterDefinition";
380
+ readonly slug: string;
381
+ readonly type: AdminFilterConfig["type"];
382
+ readonly apply: (query: unknown, value: unknown) => unknown;
383
+ readonly options?: Array<{
384
+ value: string | number;
385
+ }>;
386
+ }
387
+ /**
388
+ * Opaque type for a lens definition created by `defineAdminLens()`.
389
+ */
390
+ interface AdminLensDefinition {
391
+ readonly __brand: "AdminLensDefinition";
392
+ readonly slug: string;
393
+ readonly defaultSort?: {
394
+ column: string;
395
+ direction: "asc" | "desc";
396
+ };
397
+ readonly defaultFilters?: Record<string, string | number>;
398
+ readonly queryFn?: (ctx: unknown, input: unknown) => Promise<unknown>;
399
+ }
400
+ /**
401
+ * Opaque type for a tool definition created by `defineAdminTool()`.
402
+ */
403
+ interface AdminToolDefinition {
404
+ readonly __brand: "AdminToolDefinition";
405
+ readonly slug: string;
406
+ readonly icon?: string;
407
+ readonly group?: string;
408
+ readonly procedures: Record<string, unknown>;
409
+ }
410
+ //#endregion
411
+ export { MetricResult as C, WorkflowListItem as D, ObservabilityOverview as E, WorkflowQueueStatus as O, MetricDefinition as S, ObservabilityConfig as T, FeatureFlagConfig as _, AdminFieldType as a, FeatureFlagType as b, AdminLensConfig as c, AdminResourceDefinition as d, AdminResourceMeta as f, FeatureFlagAuditEntry as g, AdminToolDefinition as h, AdminFieldConfig as i, WorkflowStatus as k, AdminLensDefinition as l, AdminToolConfig as m, AdminActionConfig as n, AdminFilterConfig as o, AdminRouterConfig as p, AdminDetailSection as r, AdminFilterDefinition as s, ActionDefinition as t, AdminResourceConfig as u, FeatureFlagOverride as v, MetricType as w, MetricConfig as x, FeatureFlagState as y };
@@ -0,0 +1,303 @@
1
+ import { C as MetricResult, D as WorkflowListItem, E as ObservabilityOverview, O as WorkflowQueueStatus, S as MetricDefinition, T as ObservabilityConfig, _ as FeatureFlagConfig, a as AdminFieldType, b as FeatureFlagType, c as AdminLensConfig, d as AdminResourceDefinition, f as AdminResourceMeta, g as FeatureFlagAuditEntry, h as AdminToolDefinition, i as AdminFieldConfig, k as WorkflowStatus, l as AdminLensDefinition, m as AdminToolConfig, n as AdminActionConfig, o as AdminFilterConfig, p as AdminRouterConfig, r as AdminDetailSection, s as AdminFilterDefinition, t as ActionDefinition, u as AdminResourceConfig, v as FeatureFlagOverride, w as MetricType, x as MetricConfig, y as FeatureFlagState } from "../admin-rt00c3tJ.mjs";
2
+ import "../logger-GuMZy8FH.mjs";
3
+ import "../database-CsDWKQ7i.mjs";
4
+ import "../auth-6bcoHRzX.mjs";
5
+ import "../cache-CXBmRwD6.mjs";
6
+ import "../container-DK4Ztu83.mjs";
7
+ import { y as TRPCContext } from "../trpc-C0E6-AHq.mjs";
8
+ import * as _trpc_server0 from "@trpc/server";
9
+ import { z } from "zod";
10
+
11
+ //#region src/api/admin.d.ts
12
+ /**
13
+ * Options for `defineAdminResource()`.
14
+ */
15
+ interface DefineAdminResourceOptions {
16
+ /** Unique slug for this resource (used in URLs and i18n keys). */
17
+ slug: string;
18
+ /**
19
+ * The server resource created by `defineResource()`.
20
+ * Must use offset pagination for admin lists.
21
+ */
22
+ resource: {
23
+ inputSchema: z.ZodType;
24
+ tableName: string;
25
+ defineQueryBuilder: (db: unknown) => {
26
+ listOffset: (params: unknown) => Promise<unknown>;
27
+ listCursor?: (params: unknown) => Promise<unknown>;
28
+ };
29
+ };
30
+ /** Admin-specific metadata (fields, actions, lenses, layout). */
31
+ meta: AdminResourceMeta;
32
+ /** Permission mapping. `subject` maps to `baseResourceDefinitions` keys. */
33
+ permissions: {
34
+ subject: string;
35
+ };
36
+ /** Zod schema for create mutations. */
37
+ createSchema?: z.ZodType;
38
+ /** Zod schema for update mutations. */
39
+ updateSchema?: z.ZodType;
40
+ }
41
+ /**
42
+ * Wraps an existing `defineResource()` result with admin UI metadata.
43
+ *
44
+ * Creates a type-safe admin resource definition that can be registered
45
+ * with `defineAdminRouter()`. No display labels are hardcoded — all
46
+ * user-facing text derives from i18n keys based on the slug and field keys.
47
+ *
48
+ * @param options - Admin resource configuration.
49
+ * @returns An opaque `AdminResourceDefinition` for use with `defineAdminRouter()`.
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * const notesAdmin = defineAdminResource({
54
+ * slug: "notes",
55
+ * resource: notesResource,
56
+ * meta: {
57
+ * icon: "StickyNote",
58
+ * group: "content",
59
+ * fields: [
60
+ * { key: "title", type: "text", indexVisible: true, searchable: true },
61
+ * { key: "createdAt", type: "datetime", sortable: true, readonly: true },
62
+ * ],
63
+ * },
64
+ * permissions: { subject: "notes" },
65
+ * createSchema: z.object({ title: z.string().min(1), content: z.string().default("") }),
66
+ * });
67
+ * ```
68
+ */
69
+ declare function defineAdminResource(options: DefineAdminResourceOptions): AdminResourceDefinition;
70
+ /**
71
+ * Options for `defineMetric()`.
72
+ */
73
+ interface DefineMetricOptions {
74
+ /** Unique metric identifier. */
75
+ slug: string;
76
+ /** Metric display type. */
77
+ type?: MetricType;
78
+ /**
79
+ * Resolver that computes the metric value.
80
+ *
81
+ * @param ctx - The tRPC context.
82
+ * @returns Metric result data.
83
+ */
84
+ resolve: (ctx: TRPCContext) => Promise<MetricResult>;
85
+ }
86
+ /**
87
+ * Defines a metric card for the admin dashboard.
88
+ *
89
+ * Metrics appear on the admin index page as value cards, trend graphs,
90
+ * partition charts, or progress bars.
91
+ *
92
+ * i18n key: `admin.metrics.[slug].label`
93
+ *
94
+ * @param options - Metric configuration.
95
+ * @returns An opaque `MetricDefinition` for use with `defineAdminRouter()`.
96
+ *
97
+ * @example
98
+ * ```typescript
99
+ * const notesCountMetric = defineMetric({
100
+ * slug: "notesCount",
101
+ * type: "value",
102
+ * resolve: async (ctx) => {
103
+ * const [{ count }] = await ctx.container.db.primary
104
+ * .select({ count: sql<number>`cast(count(*) as int)` })
105
+ * .from(notes);
106
+ * return { value: count };
107
+ * },
108
+ * });
109
+ * ```
110
+ */
111
+ declare function defineMetric(options: DefineMetricOptions): MetricDefinition;
112
+ /**
113
+ * Options for `defineAction()`.
114
+ */
115
+ interface DefineActionOptions {
116
+ /** Unique action identifier. */
117
+ slug: string;
118
+ /**
119
+ * Handler function executed when the action is triggered.
120
+ *
121
+ * @param ctx - The tRPC context.
122
+ * @param ids - Selected record IDs.
123
+ * @param input - Optional additional input.
124
+ */
125
+ handle: (ctx: TRPCContext, ids: string[], input?: unknown) => Promise<unknown>;
126
+ /** Permission required to execute this action. */
127
+ permission?: Record<string, readonly string[]>;
128
+ /** Optional Zod schema for additional action input. */
129
+ inputSchema?: z.ZodType;
130
+ }
131
+ /**
132
+ * Defines a resource action (e.g., archive, publish, ban).
133
+ *
134
+ * Actions can target single records or bulk selections.
135
+ * i18n keys: `admin.resources.[resource].actions.[slug].label`, `.confirmText`
136
+ *
137
+ * @param options - Action configuration.
138
+ * @returns An opaque `ActionDefinition`.
139
+ *
140
+ * @example
141
+ * ```typescript
142
+ * const archiveAction = defineAction({
143
+ * slug: "archive",
144
+ * handle: async (ctx, ids) => {
145
+ * await ctx.container.db.primary
146
+ * .update(notes)
147
+ * .set({ archivedAt: sql`NOW()` })
148
+ * .where(inArray(notes.id, ids));
149
+ * },
150
+ * permission: { notes: ["delete"] },
151
+ * });
152
+ * ```
153
+ */
154
+ declare function defineAction(options: DefineActionOptions): ActionDefinition;
155
+ /**
156
+ * Options for `defineAdminFilter()`.
157
+ */
158
+ interface DefineAdminFilterOptions {
159
+ /** Unique filter identifier. */
160
+ slug: string;
161
+ /** Filter input type. */
162
+ type: AdminFilterConfig["type"];
163
+ /**
164
+ * Apply this filter to a query.
165
+ *
166
+ * @param query - The current query builder.
167
+ * @param value - The filter value from the client.
168
+ * @returns Modified query.
169
+ */
170
+ apply: (query: unknown, value: unknown) => unknown;
171
+ /** For `select` type: available options. */
172
+ options?: Array<{
173
+ value: string | number;
174
+ }>;
175
+ }
176
+ /**
177
+ * Defines a custom filter for an admin resource.
178
+ *
179
+ * i18n key: `admin.resources.[resource].filters.[slug]`
180
+ *
181
+ * @param options - Filter configuration.
182
+ * @returns An opaque `AdminFilterDefinition`.
183
+ *
184
+ * @example
185
+ * ```typescript
186
+ * const statusFilter = defineAdminFilter({
187
+ * slug: "status",
188
+ * type: "select",
189
+ * options: [{ value: "active" }, { value: "archived" }],
190
+ * apply: (query, value) => query.where(eq(notes.status, value)),
191
+ * });
192
+ * ```
193
+ */
194
+ declare function defineAdminFilter(options: DefineAdminFilterOptions): AdminFilterDefinition;
195
+ /**
196
+ * Options for `defineAdminLens()`.
197
+ */
198
+ interface DefineAdminLensOptions {
199
+ /** Unique lens identifier. */
200
+ slug: string;
201
+ /** Default sort when this lens is active. */
202
+ defaultSort?: {
203
+ column: string;
204
+ direction: "asc" | "desc";
205
+ };
206
+ /** Default filters when this lens is active. */
207
+ defaultFilters?: Record<string, string | number>;
208
+ /** Custom query function (overrides the default resource query). */
209
+ queryFn?: (ctx: TRPCContext, input: unknown) => Promise<unknown>;
210
+ }
211
+ /**
212
+ * Defines a resource lens (predefined view with specific defaults).
213
+ *
214
+ * i18n key: `admin.resources.[resource].lenses.[slug]`
215
+ *
216
+ * @param options - Lens configuration.
217
+ * @returns An opaque `AdminLensDefinition`.
218
+ *
219
+ * @example
220
+ * ```typescript
221
+ * const recentLens = defineAdminLens({
222
+ * slug: "recent",
223
+ * defaultSort: { column: "createdAt", direction: "desc" },
224
+ * });
225
+ * ```
226
+ */
227
+ declare function defineAdminLens(options: DefineAdminLensOptions): AdminLensDefinition;
228
+ /**
229
+ * Options for `defineAdminTool()`.
230
+ */
231
+ interface DefineAdminToolOptions {
232
+ /** Unique tool identifier (used in URLs). */
233
+ slug: string;
234
+ /** Lucide icon name. */
235
+ icon?: string;
236
+ /** Sidebar group. */
237
+ group?: string;
238
+ /** Custom tRPC procedures for this tool. */
239
+ procedures: Record<string, unknown>;
240
+ }
241
+ /**
242
+ * Defines a custom admin tool (full-page admin route with custom tRPC procedures).
243
+ *
244
+ * i18n keys: `admin.tools.[slug].*`
245
+ *
246
+ * @param options - Tool configuration.
247
+ * @returns An opaque `AdminToolDefinition`.
248
+ *
249
+ * @example
250
+ * ```typescript
251
+ * const databaseViewer = defineAdminTool({
252
+ * slug: "database",
253
+ * icon: "Database",
254
+ * group: "system",
255
+ * procedures: { tables: t.publicProcedure.query(...) },
256
+ * });
257
+ * ```
258
+ */
259
+ declare function defineAdminTool(options: DefineAdminToolOptions): AdminToolDefinition;
260
+ /**
261
+ * Auto-builds the tRPC admin sub-router from resource definitions.
262
+ *
263
+ * Generated procedures:
264
+ * - `admin.meta` — resource list, metric configs, enabled modules
265
+ * - `admin.resources.[slug].list` — paginated list (offset)
266
+ * - `admin.resources.[slug].show` — single record
267
+ * - `admin.resources.[slug].create` — create mutation
268
+ * - `admin.resources.[slug].update` — update mutation
269
+ * - `admin.resources.[slug].delete` — delete mutation
270
+ * - `admin.metrics.[slug]` — metric data
271
+ * - `admin.workflows.*` — workflow management (if enabled)
272
+ * - `admin.flags.*` — feature flag management (if enabled)
273
+ * - `admin.observability.*` — observability queries (if configured)
274
+ *
275
+ * @param config - Admin router configuration.
276
+ * @returns A tRPC router to merge into the app's main router.
277
+ *
278
+ * @example
279
+ * ```typescript
280
+ * const adminRouter = defineAdminRouter({
281
+ * resources: [notesAdmin, usersAdmin],
282
+ * metrics: [notesCountMetric],
283
+ * workflows: { enabled: true },
284
+ * flags: { enabled: true },
285
+ * observability: { openObserveUrl: "...", org: "...", stream: "..." },
286
+ * permission: { admin: ["access"] },
287
+ * });
288
+ *
289
+ * // Merge into main router
290
+ * const trpcRouter = t.router({
291
+ * notes: notesRouter,
292
+ * admin: adminRouter,
293
+ * });
294
+ * ```
295
+ */
296
+ declare function defineAdminRouter(config: AdminRouterConfig): _trpc_server0.TRPCBuiltRouter<{
297
+ ctx: TRPCContext;
298
+ meta: object;
299
+ errorShape: _trpc_server0.TRPCDefaultErrorShape;
300
+ transformer: true;
301
+ }, _trpc_server0.TRPCDecorateCreateRouterOptions<Record<string, any>>>;
302
+ //#endregion
303
+ export { type ActionDefinition, type AdminActionConfig, type AdminDetailSection, type AdminFieldConfig, type AdminFieldType, type AdminFilterConfig, type AdminFilterDefinition, type AdminLensConfig, type AdminLensDefinition, type AdminResourceConfig, type AdminResourceDefinition, type AdminResourceMeta, type AdminRouterConfig, type AdminToolConfig, type AdminToolDefinition, DefineActionOptions, DefineAdminFilterOptions, DefineAdminLensOptions, DefineAdminResourceOptions, DefineAdminToolOptions, DefineMetricOptions, type FeatureFlagAuditEntry, type FeatureFlagConfig, type FeatureFlagOverride, type FeatureFlagState, type FeatureFlagType, type MetricConfig, type MetricDefinition, type MetricResult, type MetricType, type ObservabilityConfig, type ObservabilityOverview, type WorkflowListItem, type WorkflowQueueStatus, type WorkflowStatus, defineAction, defineAdminFilter, defineAdminLens, defineAdminResource, defineAdminRouter, defineAdminTool, defineMetric };