@mdxui/do 2.1.1 → 3.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 (71) hide show
  1. package/README.md +253 -266
  2. package/dist/{agents-xcIn2dUB.d.ts → agents-2_r9e9i7.d.ts} +213 -2
  3. package/dist/app/index.d.ts +347 -0
  4. package/dist/app/index.js +13 -0
  5. package/dist/app/index.js.map +1 -0
  6. package/dist/chunk-4KXVN3EQ.js +56 -0
  7. package/dist/chunk-4KXVN3EQ.js.map +1 -0
  8. package/dist/chunk-5AWTQDRF.js +76 -0
  9. package/dist/chunk-5AWTQDRF.js.map +1 -0
  10. package/dist/chunk-EQVOEEQO.js +95 -0
  11. package/dist/chunk-EQVOEEQO.js.map +1 -0
  12. package/dist/chunk-FO3N7SXV.js +469 -0
  13. package/dist/chunk-FO3N7SXV.js.map +1 -0
  14. package/dist/chunk-IESVTECE.js +536 -0
  15. package/dist/chunk-IESVTECE.js.map +1 -0
  16. package/dist/chunk-JWKIONEO.js +234 -0
  17. package/dist/chunk-JWKIONEO.js.map +1 -0
  18. package/dist/chunk-NTSEARBC.js +715 -0
  19. package/dist/chunk-NTSEARBC.js.map +1 -0
  20. package/dist/chunk-OWEAW4U6.js +116 -0
  21. package/dist/chunk-OWEAW4U6.js.map +1 -0
  22. package/dist/chunk-VRLUXCLD.js +31 -0
  23. package/dist/chunk-VRLUXCLD.js.map +1 -0
  24. package/dist/chunk-Y52IEYVM.js +131 -0
  25. package/dist/chunk-Y52IEYVM.js.map +1 -0
  26. package/dist/chunk-YGIBMNRH.js +1991 -0
  27. package/dist/chunk-YGIBMNRH.js.map +1 -0
  28. package/dist/components/index.d.ts +1 -738
  29. package/dist/components/index.js +2 -6
  30. package/dist/config-CmZBQQaT.d.ts +122 -0
  31. package/dist/{do-CaQVueZw.d.ts → do-C-t9UgjT.d.ts} +31 -33
  32. package/dist/errors-B4Oyyj4Z.d.ts +346 -0
  33. package/dist/hooks/index.d.ts +428 -696
  34. package/dist/hooks/index.js +6 -4
  35. package/dist/hooks/things/index.d.ts +298 -0
  36. package/dist/hooks/things/index.js +8 -0
  37. package/dist/hooks/things/index.js.map +1 -0
  38. package/dist/index.d.ts +21 -1010
  39. package/dist/index.js +11 -839
  40. package/dist/index.js.map +1 -1
  41. package/dist/lib/index.d.ts +100 -0
  42. package/dist/lib/index.js +6 -0
  43. package/dist/lib/index.js.map +1 -0
  44. package/dist/providers/index.d.ts +244 -32
  45. package/dist/providers/index.js +3 -2
  46. package/dist/query-keys-BC901wog.d.ts +153 -0
  47. package/dist/schemas/index.d.ts +1 -1
  48. package/dist/schemas/index.js +2 -2
  49. package/dist/schemas/index.js.map +1 -1
  50. package/dist/{thing-DtI25yZh.d.ts → thing-BVhCTzOi.d.ts} +4 -4
  51. package/dist/types/index.d.ts +251 -216
  52. package/dist/types/index.js +1 -2
  53. package/dist/views/index.d.ts +131 -0
  54. package/dist/views/index.js +11 -0
  55. package/dist/views/index.js.map +1 -0
  56. package/package.json +39 -17
  57. package/dist/__test-utils__/index.d.ts +0 -399
  58. package/dist/__test-utils__/index.js +0 -34641
  59. package/dist/__test-utils__/index.js.map +0 -1
  60. package/dist/chunk-EEDMN7UF.js +0 -1351
  61. package/dist/chunk-EEDMN7UF.js.map +0 -1
  62. package/dist/chunk-G3PMV62Z.js +0 -33
  63. package/dist/chunk-G3PMV62Z.js.map +0 -1
  64. package/dist/chunk-NXPXL5NA.js +0 -3789
  65. package/dist/chunk-NXPXL5NA.js.map +0 -1
  66. package/dist/chunk-PC5FJY6M.js +0 -20
  67. package/dist/chunk-PC5FJY6M.js.map +0 -1
  68. package/dist/chunk-XF6LKY2M.js +0 -445
  69. package/dist/chunk-XF6LKY2M.js.map +0 -1
  70. package/dist/magic-string.es-J7BYFTTJ.js +0 -1307
  71. package/dist/magic-string.es-J7BYFTTJ.js.map +0 -1
@@ -0,0 +1,715 @@
1
+ import { DataBrowserView, DataGridView, DocumentEditorView, FunctionEditorView } from './chunk-YGIBMNRH.js';
2
+ import { useNamespaces, useTypes } from './chunk-IESVTECE.js';
3
+ import { useThings } from './chunk-JWKIONEO.js';
4
+ import { DOProvider, useDO } from './chunk-FO3N7SXV.js';
5
+ import { useLocation, NavLink, Outlet, useParams, useNavigate, BrowserRouter, Routes, Route } from 'react-router-dom';
6
+ import { ThemeProvider } from 'next-themes';
7
+ import * as React from 'react';
8
+ import { createContext, useState, useMemo, useContext, useEffect } from 'react';
9
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
10
+ import { useAuth, AuthKitProvider } from '@workos-inc/authkit-react';
11
+ import { WorkOsWidgets } from '@workos-inc/widgets';
12
+ import { DropdownMenu, DropdownMenuTrigger, SidebarMenuButton, Avatar, AvatarImage, AvatarFallback, DropdownMenuContent, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuItem, Sidebar, SidebarHeader, SidebarMenu, SidebarMenuItem, SidebarContent, SidebarGroup, SidebarGroupLabel, SidebarFooter, SidebarProvider, SidebarInset, SidebarTrigger, Separator, Toaster, Card, CardHeader, CardTitle, CardDescription, CardContent } from '@mdxui/primitives';
13
+ import { ChevronsUpDown, User, Settings, LogOut, Database, Shapes, Activity, Network, Code, Users, CreditCard, Building, Construction, Home, Bot, GitBranch, BookOpen, Zap, Play, Plug, Shield, UserCog, Key } from 'lucide-react';
14
+ import { z } from 'zod';
15
+
16
+ var DOShellContext = createContext(null);
17
+ var defaultIdentity = {
18
+ clientId: "",
19
+ devMode: false,
20
+ required: true,
21
+ onUnauthenticated: "landing"
22
+ };
23
+ var defaultConfig = {
24
+ basePath: "/",
25
+ defaultNamespace: "default",
26
+ branding: { name: "DO Admin" },
27
+ theme: { mode: "system" },
28
+ routes: {},
29
+ customRoutes: []
30
+ };
31
+ function DOShellProvider({ config, children }) {
32
+ const [namespace, setNamespace] = useState(config.defaultNamespace ?? "default");
33
+ const value = useMemo(() => {
34
+ const mergedConfig = {
35
+ ...defaultConfig,
36
+ ...config,
37
+ branding: { ...defaultConfig.branding, ...config.branding },
38
+ theme: { ...defaultConfig.theme, ...config.theme },
39
+ identity: { ...defaultIdentity, ...config.identity }
40
+ };
41
+ return {
42
+ config: mergedConfig,
43
+ namespace,
44
+ setNamespace
45
+ };
46
+ }, [config, namespace]);
47
+ return /* @__PURE__ */ jsx(DOShellContext.Provider, { value, children });
48
+ }
49
+ function useDOShell() {
50
+ const context = useContext(DOShellContext);
51
+ if (!context) {
52
+ throw new Error("useDOShell must be used within a DOShellProvider");
53
+ }
54
+ return context;
55
+ }
56
+ function useDOShellRoutes() {
57
+ const { config } = useDOShell();
58
+ return config.routes ?? {};
59
+ }
60
+ var useIdentity = useAuth;
61
+ function IdentityWidgetsWrapper({ children }) {
62
+ const [mounted, setMounted] = useState(false);
63
+ const [isDark, setIsDark] = useState(false);
64
+ useEffect(() => {
65
+ setMounted(true);
66
+ const checkDarkMode = () => {
67
+ const isDarkClass = document.documentElement.classList.contains("dark");
68
+ const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
69
+ setIsDark(isDarkClass || !document.documentElement.classList.contains("light") && prefersDark);
70
+ };
71
+ checkDarkMode();
72
+ const observer = new MutationObserver(checkDarkMode);
73
+ observer.observe(document.documentElement, { attributes: true, attributeFilter: ["class"] });
74
+ const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
75
+ mediaQuery.addEventListener("change", checkDarkMode);
76
+ return () => {
77
+ observer.disconnect();
78
+ mediaQuery.removeEventListener("change", checkDarkMode);
79
+ };
80
+ }, []);
81
+ const appearance = mounted ? isDark ? "dark" : "light" : "inherit";
82
+ return /* @__PURE__ */ jsx(
83
+ WorkOsWidgets,
84
+ {
85
+ theme: {
86
+ appearance,
87
+ radius: "medium",
88
+ scaling: "100%"
89
+ },
90
+ elements: {
91
+ primaryButton: {
92
+ variant: "solid"
93
+ },
94
+ secondaryButton: {
95
+ variant: "outline"
96
+ }
97
+ },
98
+ children
99
+ }
100
+ );
101
+ }
102
+ function DOIdentityProvider({ children }) {
103
+ const { config } = useDOShell();
104
+ const { identity } = config;
105
+ const redirectUri = identity.redirectUri ?? (typeof window !== "undefined" ? `${window.location.origin}${config.basePath ?? "/"}` : void 0);
106
+ const onRedirectCallback = () => {
107
+ if (typeof window !== "undefined") {
108
+ const url = new URL(window.location.href);
109
+ url.searchParams.delete("code");
110
+ url.searchParams.delete("state");
111
+ window.history.replaceState({}, "", url.pathname);
112
+ }
113
+ };
114
+ return /* @__PURE__ */ jsx(
115
+ AuthKitProvider,
116
+ {
117
+ clientId: identity.clientId,
118
+ apiHostname: identity.apiHostname,
119
+ devMode: identity.devMode,
120
+ redirectUri,
121
+ onRedirectCallback,
122
+ children: /* @__PURE__ */ jsx(IdentityWidgetsWrapper, { children })
123
+ }
124
+ );
125
+ }
126
+ function AppProviders({ config, children }) {
127
+ const themeMode = config.theme?.mode ?? "system";
128
+ return /* @__PURE__ */ jsx(
129
+ ThemeProvider,
130
+ {
131
+ attribute: "class",
132
+ defaultTheme: themeMode,
133
+ enableSystem: themeMode === "system",
134
+ disableTransitionOnChange: true,
135
+ children: /* @__PURE__ */ jsx(DOShellProvider, { config, children: /* @__PURE__ */ jsx(DOIdentityProvider, { children: /* @__PURE__ */ jsx(
136
+ DOProvider,
137
+ {
138
+ config: config.do,
139
+ initialNamespace: config.defaultNamespace,
140
+ children
141
+ }
142
+ ) }) })
143
+ }
144
+ );
145
+ }
146
+ var DOAppProviders = AppProviders;
147
+ function getInitials(name) {
148
+ if (!name) return "?";
149
+ const parts = name.trim().split(/\s+/);
150
+ if (parts.length === 1) return parts[0].charAt(0).toUpperCase();
151
+ return (parts[0].charAt(0) + parts[parts.length - 1].charAt(0)).toUpperCase();
152
+ }
153
+ function UserMenu({ compact = false }) {
154
+ const { user, signOut, isLoading } = useAuth();
155
+ if (isLoading) {
156
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 p-2", children: [
157
+ /* @__PURE__ */ jsx("div", { className: "h-8 w-8 animate-pulse rounded-full bg-muted" }),
158
+ !compact && /* @__PURE__ */ jsx("div", { className: "h-4 w-24 animate-pulse rounded bg-muted" })
159
+ ] });
160
+ }
161
+ if (!user) {
162
+ return null;
163
+ }
164
+ const displayName = user.firstName ? `${user.firstName}${user.lastName ? ` ${user.lastName}` : ""}` : user.email;
165
+ const initials = getInitials(user.firstName ? `${user.firstName} ${user.lastName ?? ""}` : user.email);
166
+ return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
167
+ /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
168
+ SidebarMenuButton,
169
+ {
170
+ size: "lg",
171
+ className: "data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground",
172
+ children: [
173
+ /* @__PURE__ */ jsxs(Avatar, { className: "h-8 w-8 rounded-lg", children: [
174
+ /* @__PURE__ */ jsx(AvatarImage, { src: user.profilePictureUrl ?? void 0, alt: displayName }),
175
+ /* @__PURE__ */ jsx(AvatarFallback, { className: "rounded-lg", children: initials })
176
+ ] }),
177
+ !compact && /* @__PURE__ */ jsxs("div", { className: "grid flex-1 text-left text-sm leading-tight", children: [
178
+ /* @__PURE__ */ jsx("span", { className: "truncate font-semibold", children: displayName }),
179
+ /* @__PURE__ */ jsx("span", { className: "truncate text-xs text-muted-foreground", children: user.email })
180
+ ] }),
181
+ /* @__PURE__ */ jsx(ChevronsUpDown, { className: "ml-auto size-4" })
182
+ ]
183
+ }
184
+ ) }),
185
+ /* @__PURE__ */ jsxs(
186
+ DropdownMenuContent,
187
+ {
188
+ className: "w-[--radix-dropdown-menu-trigger-width] min-w-56 rounded-[var(--radius)]",
189
+ side: "bottom",
190
+ align: "end",
191
+ sideOffset: 4,
192
+ children: [
193
+ /* @__PURE__ */ jsx(DropdownMenuLabel, { className: "p-0 font-normal", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 px-1 py-1.5 text-left text-sm", children: [
194
+ /* @__PURE__ */ jsxs(Avatar, { className: "h-8 w-8 rounded-lg", children: [
195
+ /* @__PURE__ */ jsx(AvatarImage, { src: user.profilePictureUrl ?? void 0, alt: displayName }),
196
+ /* @__PURE__ */ jsx(AvatarFallback, { className: "rounded-lg", children: initials })
197
+ ] }),
198
+ /* @__PURE__ */ jsxs("div", { className: "grid flex-1 text-left text-sm leading-tight", children: [
199
+ /* @__PURE__ */ jsx("span", { className: "truncate font-semibold", children: displayName }),
200
+ /* @__PURE__ */ jsx("span", { className: "truncate text-xs text-muted-foreground", children: user.email })
201
+ ] })
202
+ ] }) }),
203
+ /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
204
+ /* @__PURE__ */ jsxs(DropdownMenuItem, { children: [
205
+ /* @__PURE__ */ jsx(User, { className: "mr-2 size-4" }),
206
+ "Account"
207
+ ] }),
208
+ /* @__PURE__ */ jsxs(DropdownMenuItem, { children: [
209
+ /* @__PURE__ */ jsx(Settings, { className: "mr-2 size-4" }),
210
+ "Settings"
211
+ ] }),
212
+ /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
213
+ /* @__PURE__ */ jsxs(DropdownMenuItem, { onClick: () => signOut(), children: [
214
+ /* @__PURE__ */ jsx(LogOut, { className: "mr-2 size-4" }),
215
+ "Sign Out"
216
+ ] })
217
+ ]
218
+ }
219
+ )
220
+ ] });
221
+ }
222
+ var navGroups = {
223
+ main: [{ title: "Overview", url: "/", icon: Home, routeKey: "overview" }],
224
+ development: [
225
+ { title: "Agents", url: "/agents", icon: Bot, routeKey: "agents" },
226
+ { title: "Functions", url: "/functions", icon: Code, routeKey: "functions" },
227
+ { title: "Workflows", url: "/workflows", icon: GitBranch, routeKey: "workflows" },
228
+ { title: "Databases", url: "/databases", icon: Database, routeKey: "databases" }
229
+ ],
230
+ dataModel: [
231
+ { title: "Things", url: "/things", icon: Shapes, routeKey: "things" },
232
+ { title: "Nouns", url: "/nouns", icon: BookOpen, routeKey: "nouns" },
233
+ { title: "Verbs", url: "/verbs", icon: Zap, routeKey: "verbs" },
234
+ { title: "Actions", url: "/actions", icon: Play, routeKey: "actions" },
235
+ { title: "Relationships", url: "/relationships", icon: Network, routeKey: "relationships" },
236
+ { title: "Events", url: "/events", icon: Activity, routeKey: "events" }
237
+ ],
238
+ saas: [
239
+ { title: "Customers", url: "/customers", icon: Users, routeKey: "customers" },
240
+ { title: "Subscriptions", url: "/subscriptions", icon: CreditCard, routeKey: "subscriptions" },
241
+ { title: "Integrations", url: "/integrations", icon: Plug, routeKey: "integrations" }
242
+ ],
243
+ admin: [
244
+ { title: "Organizations", url: "/orgs", icon: Building, routeKey: "orgs" },
245
+ { title: "Roles", url: "/roles", icon: Shield, routeKey: "roles" },
246
+ { title: "Users", url: "/users", icon: UserCog, routeKey: "users" },
247
+ { title: "API Keys", url: "/api-keys", icon: Key, routeKey: "apiKeys" },
248
+ { title: "Settings", url: "/settings", icon: Settings, routeKey: "settings" }
249
+ ]
250
+ };
251
+ function DOShellNav({ headerContent, ...props }) {
252
+ const location = useLocation();
253
+ const { config } = useDOShell();
254
+ const routesConfig = useDOShellRoutes();
255
+ const branding = config.branding;
256
+ const isActive = (url) => {
257
+ if (url === "/") {
258
+ return location.pathname === "/" || location.pathname === "";
259
+ }
260
+ return location.pathname.startsWith(url);
261
+ };
262
+ const isRouteEnabled = (routeKey) => {
263
+ if (!routeKey) return true;
264
+ if (routesConfig[routeKey] === false) return false;
265
+ return true;
266
+ };
267
+ const filterNavItems = (items) => {
268
+ return items.filter((item) => isRouteEnabled(item.routeKey));
269
+ };
270
+ return /* @__PURE__ */ jsxs(Sidebar, { variant: "inset", ...props, children: [
271
+ /* @__PURE__ */ jsxs(SidebarHeader, { children: [
272
+ /* @__PURE__ */ jsx(SidebarMenu, { children: /* @__PURE__ */ jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsx(SidebarMenuButton, { size: "lg", asChild: true, children: /* @__PURE__ */ jsxs(NavLink, { to: "/", children: [
273
+ /* @__PURE__ */ jsx("div", { className: "bg-sidebar-primary text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-(--radius)", children: branding?.logo ?? /* @__PURE__ */ jsx(Database, { className: "size-4" }) }),
274
+ /* @__PURE__ */ jsxs("div", { className: "grid flex-1 text-left text-sm leading-tight", children: [
275
+ /* @__PURE__ */ jsx("span", { className: "truncate font-medium", children: branding?.name ?? "DO Admin" }),
276
+ /* @__PURE__ */ jsx("span", { className: "truncate text-xs", children: "Dashboard" })
277
+ ] })
278
+ ] }) }) }) }),
279
+ headerContent
280
+ ] }),
281
+ /* @__PURE__ */ jsxs(SidebarContent, { children: [
282
+ /* @__PURE__ */ jsx(SidebarGroup, { children: /* @__PURE__ */ jsx(SidebarMenu, { children: filterNavItems(navGroups.main).map((item) => /* @__PURE__ */ jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsx(SidebarMenuButton, { asChild: true, isActive: isActive(item.url), tooltip: item.title, children: /* @__PURE__ */ jsxs(NavLink, { to: item.url, children: [
283
+ /* @__PURE__ */ jsx(item.icon, { className: "size-4" }),
284
+ /* @__PURE__ */ jsx("span", { children: item.title })
285
+ ] }) }) }, item.title)) }) }),
286
+ filterNavItems(navGroups.development).length > 0 && /* @__PURE__ */ jsxs(SidebarGroup, { children: [
287
+ /* @__PURE__ */ jsx(SidebarGroupLabel, { children: "Development" }),
288
+ /* @__PURE__ */ jsx(SidebarMenu, { children: filterNavItems(navGroups.development).map((item) => /* @__PURE__ */ jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsx(SidebarMenuButton, { asChild: true, isActive: isActive(item.url), tooltip: item.title, children: /* @__PURE__ */ jsxs(NavLink, { to: item.url, children: [
289
+ /* @__PURE__ */ jsx(item.icon, { className: "size-4" }),
290
+ /* @__PURE__ */ jsx("span", { children: item.title })
291
+ ] }) }) }, item.title)) })
292
+ ] }),
293
+ filterNavItems(navGroups.dataModel).length > 0 && /* @__PURE__ */ jsxs(SidebarGroup, { children: [
294
+ /* @__PURE__ */ jsx(SidebarGroupLabel, { children: "Data Model" }),
295
+ /* @__PURE__ */ jsx(SidebarMenu, { children: filterNavItems(navGroups.dataModel).map((item) => /* @__PURE__ */ jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsx(SidebarMenuButton, { asChild: true, isActive: isActive(item.url), tooltip: item.title, children: /* @__PURE__ */ jsxs(NavLink, { to: item.url, children: [
296
+ /* @__PURE__ */ jsx(item.icon, { className: "size-4" }),
297
+ /* @__PURE__ */ jsx("span", { children: item.title })
298
+ ] }) }) }, item.title)) })
299
+ ] }),
300
+ filterNavItems(navGroups.saas).length > 0 && /* @__PURE__ */ jsxs(SidebarGroup, { children: [
301
+ /* @__PURE__ */ jsx(SidebarGroupLabel, { children: "SaaS" }),
302
+ /* @__PURE__ */ jsx(SidebarMenu, { children: filterNavItems(navGroups.saas).map((item) => /* @__PURE__ */ jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsx(SidebarMenuButton, { asChild: true, isActive: isActive(item.url), tooltip: item.title, children: /* @__PURE__ */ jsxs(NavLink, { to: item.url, children: [
303
+ /* @__PURE__ */ jsx(item.icon, { className: "size-4" }),
304
+ /* @__PURE__ */ jsx("span", { children: item.title })
305
+ ] }) }) }, item.title)) })
306
+ ] }),
307
+ filterNavItems(navGroups.admin).length > 0 && /* @__PURE__ */ jsxs(SidebarGroup, { children: [
308
+ /* @__PURE__ */ jsx(SidebarGroupLabel, { children: "Admin" }),
309
+ /* @__PURE__ */ jsx(SidebarMenu, { children: filterNavItems(navGroups.admin).map((item) => /* @__PURE__ */ jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsx(SidebarMenuButton, { asChild: true, isActive: isActive(item.url), tooltip: item.title, children: /* @__PURE__ */ jsxs(NavLink, { to: item.url, children: [
310
+ /* @__PURE__ */ jsx(item.icon, { className: "size-4" }),
311
+ /* @__PURE__ */ jsx("span", { children: item.title })
312
+ ] }) }) }, item.title)) })
313
+ ] })
314
+ ] }),
315
+ /* @__PURE__ */ jsx(SidebarFooter, { children: /* @__PURE__ */ jsx(SidebarMenu, { children: /* @__PURE__ */ jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsx(UserMenu, {}) }) }) })
316
+ ] });
317
+ }
318
+ function DefaultLandingPage() {
319
+ const { signIn } = useAuth();
320
+ return /* @__PURE__ */ jsx("div", { className: "min-h-screen bg-background flex flex-col items-center justify-center p-4", children: /* @__PURE__ */ jsxs("div", { className: "text-center max-w-md", children: [
321
+ /* @__PURE__ */ jsx("h1", { className: "text-3xl font-bold tracking-tight mb-4", children: "DO Admin" }),
322
+ /* @__PURE__ */ jsx("p", { className: "text-muted-foreground mb-8", children: "Sign in to access the admin dashboard and manage your Durable Objects." }),
323
+ /* @__PURE__ */ jsx(
324
+ "button",
325
+ {
326
+ type: "button",
327
+ onClick: () => signIn(),
328
+ className: "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-[var(--radius-md)] text-sm font-medium transition-colors bg-primary text-primary-foreground hover:bg-primary/90 h-10 px-6",
329
+ children: "Sign In"
330
+ }
331
+ )
332
+ ] }) });
333
+ }
334
+ function AuthGate({ children }) {
335
+ const { config } = useDOShell();
336
+ const { user, isLoading } = useAuth();
337
+ const { identity } = config;
338
+ const required = identity.required ?? true;
339
+ const onUnauthenticated = identity.onUnauthenticated ?? "landing";
340
+ if (!required) {
341
+ return /* @__PURE__ */ jsx(Fragment, { children });
342
+ }
343
+ if (isLoading) {
344
+ return /* @__PURE__ */ jsx("div", { className: "min-h-screen bg-background flex items-center justify-center", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-4", children: [
345
+ /* @__PURE__ */ jsx("div", { className: "h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent" }),
346
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Loading..." })
347
+ ] }) });
348
+ }
349
+ if (user) {
350
+ return /* @__PURE__ */ jsx(Fragment, { children });
351
+ }
352
+ switch (onUnauthenticated) {
353
+ case "redirect":
354
+ if (identity.unauthenticatedRedirectUrl && typeof window !== "undefined") {
355
+ window.location.href = identity.unauthenticatedRedirectUrl;
356
+ return /* @__PURE__ */ jsx("div", { className: "min-h-screen bg-background flex items-center justify-center", children: /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Redirecting..." }) });
357
+ }
358
+ return identity.landingComponent ? /* @__PURE__ */ jsx(Fragment, { children: identity.landingComponent }) : /* @__PURE__ */ jsx(DefaultLandingPage, {});
359
+ case "allow":
360
+ return /* @__PURE__ */ jsx(Fragment, { children });
361
+ case "landing":
362
+ default:
363
+ return identity.landingComponent ? /* @__PURE__ */ jsx(Fragment, { children: identity.landingComponent }) : /* @__PURE__ */ jsx(DefaultLandingPage, {});
364
+ }
365
+ }
366
+ function DOShell({
367
+ children,
368
+ sidebarHeaderContent,
369
+ headerContent,
370
+ breadcrumbs
371
+ }) {
372
+ return /* @__PURE__ */ jsx(AuthGate, { children: /* @__PURE__ */ jsxs(SidebarProvider, { className: "h-svh!", children: [
373
+ /* @__PURE__ */ jsx(DOShellNav, { headerContent: sidebarHeaderContent }),
374
+ /* @__PURE__ */ jsxs(SidebarInset, { className: "overflow-hidden", children: [
375
+ /* @__PURE__ */ jsxs("header", { className: "flex h-16 shrink-0 items-center gap-2 border-b bg-background transition-[width,height] ease-linear group-has-data-[collapsible=icon]/sidebar-wrapper:h-12", children: [
376
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 px-4", children: [
377
+ /* @__PURE__ */ jsx(SidebarTrigger, { className: "-ml-1" }),
378
+ /* @__PURE__ */ jsx(Separator, { orientation: "vertical", className: "mr-2 h-4" }),
379
+ breadcrumbs && breadcrumbs.length > 0 && /* @__PURE__ */ jsx("nav", { className: "flex items-center gap-1 text-sm", children: breadcrumbs.map((crumb, index) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
380
+ index > 0 && /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "/" }),
381
+ crumb.href ? /* @__PURE__ */ jsx(
382
+ "a",
383
+ {
384
+ href: crumb.href,
385
+ className: "text-muted-foreground hover:text-foreground transition-colors",
386
+ children: crumb.label
387
+ }
388
+ ) : /* @__PURE__ */ jsx("span", { className: "text-foreground", children: crumb.label })
389
+ ] }, crumb.label)) })
390
+ ] }),
391
+ headerContent && /* @__PURE__ */ jsx("div", { className: "ml-auto flex items-center gap-2 px-4", children: headerContent })
392
+ ] }),
393
+ /* @__PURE__ */ jsx("main", { className: "flex-1 overflow-auto p-4", children: children ?? /* @__PURE__ */ jsx(Outlet, {}) })
394
+ ] }),
395
+ /* @__PURE__ */ jsx(Toaster, { closeButton: true, position: "top-right" })
396
+ ] }) });
397
+ }
398
+ function StatCard({ title, value, description, icon: Icon, href }) {
399
+ const content = /* @__PURE__ */ jsxs(Card, { className: "hover:bg-muted/50 transition-colors", children: [
400
+ /* @__PURE__ */ jsxs(CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
401
+ /* @__PURE__ */ jsx(CardTitle, { className: "text-sm font-medium", children: title }),
402
+ /* @__PURE__ */ jsx(Icon, { className: "h-4 w-4 text-muted-foreground" })
403
+ ] }),
404
+ /* @__PURE__ */ jsxs(CardContent, { children: [
405
+ /* @__PURE__ */ jsx("div", { className: "text-2xl font-bold", children: value }),
406
+ description && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: description })
407
+ ] })
408
+ ] });
409
+ if (href) {
410
+ return /* @__PURE__ */ jsx(NavLink, { to: href, className: "block", children: content });
411
+ }
412
+ return content;
413
+ }
414
+ function QuickAction({ title, description, icon: Icon, href }) {
415
+ return /* @__PURE__ */ jsxs(
416
+ NavLink,
417
+ {
418
+ to: href,
419
+ className: "flex items-center gap-4 rounded-(--radius) border p-4 hover:bg-muted/50 transition-colors",
420
+ children: [
421
+ /* @__PURE__ */ jsx("div", { className: "flex h-10 w-10 items-center justify-center rounded-(--radius) bg-primary/10", children: /* @__PURE__ */ jsx(Icon, { className: "h-5 w-5 text-primary" }) }),
422
+ /* @__PURE__ */ jsxs("div", { children: [
423
+ /* @__PURE__ */ jsx("h3", { className: "font-medium", children: title }),
424
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: description })
425
+ ] })
426
+ ]
427
+ }
428
+ );
429
+ }
430
+ function OverviewPage() {
431
+ const { namespace, isConnected } = useDO();
432
+ const { data: namespaces } = useNamespaces();
433
+ const { data: types } = useTypes({ ns: namespace });
434
+ const { data: thingsResult } = useThings({ ns: namespace, limit: 1 });
435
+ const namespaceCount = namespaces?.length ?? 0;
436
+ const typeCount = types?.length ?? 0;
437
+ const thingCount = thingsResult?.total ?? 0;
438
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-8", children: [
439
+ /* @__PURE__ */ jsxs("div", { children: [
440
+ /* @__PURE__ */ jsx("h1", { className: "text-3xl font-bold tracking-tight", children: "Dashboard" }),
441
+ /* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: "Welcome to DO Admin. Manage your Durable Objects and data." })
442
+ ] }),
443
+ !isConnected && /* @__PURE__ */ jsx(Card, { className: "border-destructive", children: /* @__PURE__ */ jsxs(CardHeader, { children: [
444
+ /* @__PURE__ */ jsx(CardTitle, { className: "text-destructive", children: "Connection Error" }),
445
+ /* @__PURE__ */ jsx(CardDescription, { children: "Unable to connect to the backend. Please check your configuration." })
446
+ ] }) }),
447
+ /* @__PURE__ */ jsxs("div", { className: "grid gap-4 md:grid-cols-2 lg:grid-cols-4", children: [
448
+ /* @__PURE__ */ jsx(
449
+ StatCard,
450
+ {
451
+ title: "Namespaces",
452
+ value: namespaceCount,
453
+ description: "Active namespaces",
454
+ icon: Database,
455
+ href: "/databases"
456
+ }
457
+ ),
458
+ /* @__PURE__ */ jsx(
459
+ StatCard,
460
+ {
461
+ title: "Types",
462
+ value: typeCount,
463
+ description: "Defined types",
464
+ icon: Shapes,
465
+ href: "/things"
466
+ }
467
+ ),
468
+ /* @__PURE__ */ jsx(
469
+ StatCard,
470
+ {
471
+ title: "Things",
472
+ value: thingCount,
473
+ description: "Total records",
474
+ icon: Activity,
475
+ href: "/things"
476
+ }
477
+ ),
478
+ /* @__PURE__ */ jsx(
479
+ StatCard,
480
+ {
481
+ title: "Namespace",
482
+ value: namespace,
483
+ description: "Currently selected",
484
+ icon: Network
485
+ }
486
+ )
487
+ ] }),
488
+ /* @__PURE__ */ jsxs("div", { children: [
489
+ /* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold mb-4", children: "Quick Actions" }),
490
+ /* @__PURE__ */ jsxs("div", { className: "grid gap-4 md:grid-cols-2 lg:grid-cols-3", children: [
491
+ /* @__PURE__ */ jsx(
492
+ QuickAction,
493
+ {
494
+ title: "Browse Things",
495
+ description: "View and manage all your Things",
496
+ icon: Shapes,
497
+ href: "/things"
498
+ }
499
+ ),
500
+ /* @__PURE__ */ jsx(
501
+ QuickAction,
502
+ {
503
+ title: "Query Database",
504
+ description: "Run queries on your data",
505
+ icon: Database,
506
+ href: "/databases"
507
+ }
508
+ ),
509
+ /* @__PURE__ */ jsx(
510
+ QuickAction,
511
+ {
512
+ title: "Run Functions",
513
+ description: "Execute code against your DO",
514
+ icon: Code,
515
+ href: "/functions"
516
+ }
517
+ ),
518
+ /* @__PURE__ */ jsx(
519
+ QuickAction,
520
+ {
521
+ title: "Manage Customers",
522
+ description: "View and manage customers",
523
+ icon: Users,
524
+ href: "/customers"
525
+ }
526
+ ),
527
+ /* @__PURE__ */ jsx(
528
+ QuickAction,
529
+ {
530
+ title: "View Subscriptions",
531
+ description: "Manage billing and subscriptions",
532
+ icon: CreditCard,
533
+ href: "/subscriptions"
534
+ }
535
+ ),
536
+ /* @__PURE__ */ jsx(
537
+ QuickAction,
538
+ {
539
+ title: "Organizations",
540
+ description: "Manage organizations and teams",
541
+ icon: Building,
542
+ href: "/orgs"
543
+ }
544
+ )
545
+ ] })
546
+ ] }),
547
+ /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsxs(CardHeader, { children: [
548
+ /* @__PURE__ */ jsxs(CardTitle, { children: [
549
+ "Current Namespace: ",
550
+ namespace
551
+ ] }),
552
+ /* @__PURE__ */ jsxs(CardDescription, { children: [
553
+ 'You are currently working in the "',
554
+ namespace,
555
+ '" namespace. Switch namespaces from the Things or Databases view.'
556
+ ] })
557
+ ] }) })
558
+ ] });
559
+ }
560
+ function ThingsPage() {
561
+ const { ns, type } = useParams();
562
+ const navigate = useNavigate();
563
+ const handleOpen = (thing) => {
564
+ navigate(`/things/${thing.ns}/${thing.type}/${thing.id}`);
565
+ };
566
+ return /* @__PURE__ */ jsx(
567
+ DataBrowserView,
568
+ {
569
+ initialNamespace: ns,
570
+ initialType: type,
571
+ onOpen: handleOpen,
572
+ className: "h-full"
573
+ }
574
+ );
575
+ }
576
+ function DatabasesPage() {
577
+ const { ns, type } = useParams();
578
+ return /* @__PURE__ */ jsx(
579
+ DataGridView,
580
+ {
581
+ initialNamespace: ns,
582
+ initialType: type,
583
+ className: "h-full"
584
+ }
585
+ );
586
+ }
587
+ function DocumentPage() {
588
+ const { ns, type, id } = useParams();
589
+ const navigate = useNavigate();
590
+ const handleBack = () => {
591
+ navigate(`/things/${ns}/${type}`);
592
+ };
593
+ const handleDelete = () => {
594
+ navigate(`/things/${ns}/${type}`);
595
+ };
596
+ return /* @__PURE__ */ jsx(
597
+ DocumentEditorView,
598
+ {
599
+ initialNamespace: ns,
600
+ initialType: type,
601
+ initialId: id,
602
+ onBack: handleBack,
603
+ onDelete: handleDelete,
604
+ className: "h-full"
605
+ }
606
+ );
607
+ }
608
+ function FunctionsPage() {
609
+ return /* @__PURE__ */ jsx(FunctionEditorView, { className: "h-full" });
610
+ }
611
+ function PlaceholderPage({ title, description }) {
612
+ return /* @__PURE__ */ jsx("div", { className: "flex h-full items-center justify-center p-4", children: /* @__PURE__ */ jsxs(Card, { className: "max-w-md", children: [
613
+ /* @__PURE__ */ jsxs(CardHeader, { className: "text-center", children: [
614
+ /* @__PURE__ */ jsx("div", { className: "mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-muted", children: /* @__PURE__ */ jsx(Construction, { className: "h-8 w-8 text-muted-foreground" }) }),
615
+ /* @__PURE__ */ jsx(CardTitle, { children: title }),
616
+ /* @__PURE__ */ jsx(CardDescription, { children: description ?? "This feature is coming soon." })
617
+ ] }),
618
+ /* @__PURE__ */ jsxs(CardContent, { className: "text-center text-sm text-muted-foreground", children: [
619
+ /* @__PURE__ */ jsx("p", { children: "We're working hard to bring you this functionality." }),
620
+ /* @__PURE__ */ jsx("p", { children: "Check back soon for updates." })
621
+ ] })
622
+ ] }) });
623
+ }
624
+ function DOApp({ config, headerContent, sidebarHeaderContent }) {
625
+ const basePath = config.basePath ?? "";
626
+ return /* @__PURE__ */ jsx(AppProviders, { config, children: /* @__PURE__ */ jsx(BrowserRouter, { basename: basePath, children: /* @__PURE__ */ jsx(Routes, { children: /* @__PURE__ */ jsxs(
627
+ Route,
628
+ {
629
+ path: "/",
630
+ element: /* @__PURE__ */ jsx(
631
+ DOShell,
632
+ {
633
+ headerContent,
634
+ sidebarHeaderContent
635
+ }
636
+ ),
637
+ children: [
638
+ /* @__PURE__ */ jsx(Route, { index: true, element: /* @__PURE__ */ jsx(OverviewPage, {}) }),
639
+ /* @__PURE__ */ jsx(Route, { path: "agents", element: /* @__PURE__ */ jsx(PlaceholderPage, { title: "Agents", description: "Autonomous AI workers" }) }),
640
+ /* @__PURE__ */ jsx(Route, { path: "functions", element: /* @__PURE__ */ jsx(FunctionsPage, {}) }),
641
+ /* @__PURE__ */ jsx(Route, { path: "workflows", element: /* @__PURE__ */ jsx(PlaceholderPage, { title: "Workflows", description: "Business process orchestration" }) }),
642
+ /* @__PURE__ */ jsx(Route, { path: "databases", element: /* @__PURE__ */ jsx(DatabasesPage, {}) }),
643
+ /* @__PURE__ */ jsx(Route, { path: "databases/:ns/:type", element: /* @__PURE__ */ jsx(DatabasesPage, {}) }),
644
+ /* @__PURE__ */ jsx(Route, { path: "things", element: /* @__PURE__ */ jsx(ThingsPage, {}) }),
645
+ /* @__PURE__ */ jsx(Route, { path: "things/:ns", element: /* @__PURE__ */ jsx(ThingsPage, {}) }),
646
+ /* @__PURE__ */ jsx(Route, { path: "things/:ns/:type", element: /* @__PURE__ */ jsx(ThingsPage, {}) }),
647
+ /* @__PURE__ */ jsx(Route, { path: "things/:ns/:type/:id", element: /* @__PURE__ */ jsx(DocumentPage, {}) }),
648
+ /* @__PURE__ */ jsx(Route, { path: "nouns", element: /* @__PURE__ */ jsx(PlaceholderPage, { title: "Nouns", description: "Semantic entities and concepts" }) }),
649
+ /* @__PURE__ */ jsx(Route, { path: "verbs", element: /* @__PURE__ */ jsx(PlaceholderPage, { title: "Verbs", description: "Actions and operations" }) }),
650
+ /* @__PURE__ */ jsx(Route, { path: "actions", element: /* @__PURE__ */ jsx(PlaceholderPage, { title: "Actions", description: "Executable operations" }) }),
651
+ /* @__PURE__ */ jsx(Route, { path: "relationships", element: /* @__PURE__ */ jsx(PlaceholderPage, { title: "Relationships", description: "Entity connections and graph" }) }),
652
+ /* @__PURE__ */ jsx(Route, { path: "events", element: /* @__PURE__ */ jsx(PlaceholderPage, { title: "Events", description: "Operation log and semantic events" }) }),
653
+ /* @__PURE__ */ jsx(Route, { path: "customers", element: /* @__PURE__ */ jsx(PlaceholderPage, { title: "Customers", description: "Customer management" }) }),
654
+ /* @__PURE__ */ jsx(Route, { path: "subscriptions", element: /* @__PURE__ */ jsx(PlaceholderPage, { title: "Subscriptions", description: "Subscription management" }) }),
655
+ /* @__PURE__ */ jsx(Route, { path: "integrations", element: /* @__PURE__ */ jsx(PlaceholderPage, { title: "Integrations", description: "External service connections" }) }),
656
+ /* @__PURE__ */ jsx(Route, { path: "orgs", element: /* @__PURE__ */ jsx(PlaceholderPage, { title: "Organizations", description: "Organization management" }) }),
657
+ /* @__PURE__ */ jsx(Route, { path: "roles", element: /* @__PURE__ */ jsx(PlaceholderPage, { title: "Roles", description: "Role-based access control" }) }),
658
+ /* @__PURE__ */ jsx(Route, { path: "users", element: /* @__PURE__ */ jsx(PlaceholderPage, { title: "Users", description: "User management" }) }),
659
+ /* @__PURE__ */ jsx(Route, { path: "api-keys", element: /* @__PURE__ */ jsx(PlaceholderPage, { title: "API Keys", description: "API key management" }) }),
660
+ /* @__PURE__ */ jsx(Route, { path: "settings", element: /* @__PURE__ */ jsx(PlaceholderPage, { title: "Settings", description: "Application settings" }) })
661
+ ]
662
+ }
663
+ ) }) }) });
664
+ }
665
+ var DatabaseRouteParams = z.object({
666
+ ns: z.string().optional(),
667
+ type: z.string().optional()
668
+ });
669
+ var ThingsRouteParams = z.object({
670
+ ns: z.string().optional(),
671
+ type: z.string().optional()
672
+ });
673
+ var DocumentRouteParams = z.object({
674
+ ns: z.string(),
675
+ type: z.string(),
676
+ id: z.string()
677
+ });
678
+ var TypeFilteredRouteParams = z.object({
679
+ type: z.string().optional()
680
+ });
681
+
682
+ // src/app/routes.ts
683
+ var doRoutePaths = {
684
+ // Main
685
+ overview: "/",
686
+ // Development
687
+ agents: "/agents",
688
+ functions: "/functions",
689
+ workflows: "/workflows",
690
+ databases: "/databases",
691
+ databaseTable: "/databases/:ns/:type",
692
+ // Data Model
693
+ things: "/things",
694
+ thingsBrowse: "/things/:ns/:type?",
695
+ document: "/things/:ns/:type/:id",
696
+ nouns: "/nouns",
697
+ verbs: "/verbs",
698
+ actions: "/actions",
699
+ relationships: "/relationships",
700
+ events: "/events",
701
+ // SaaS
702
+ customers: "/customers",
703
+ subscriptions: "/subscriptions",
704
+ integrations: "/integrations",
705
+ // Admin
706
+ orgs: "/orgs",
707
+ roles: "/roles",
708
+ users: "/users",
709
+ apiKeys: "/api-keys",
710
+ settings: "/settings"
711
+ };
712
+
713
+ export { AppProviders, AuthGate, DOApp, DOAppProviders, DOIdentityProvider, DOShell, DOShellNav, DOShellProvider, DatabaseRouteParams, DatabasesPage, DocumentPage, DocumentRouteParams, FunctionsPage, OverviewPage, PlaceholderPage, ThingsPage, ThingsRouteParams, TypeFilteredRouteParams, UserMenu, doRoutePaths, useDOShell, useDOShellRoutes, useIdentity };
714
+ //# sourceMappingURL=chunk-NTSEARBC.js.map
715
+ //# sourceMappingURL=chunk-NTSEARBC.js.map