@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
package/README.md CHANGED
@@ -3,11 +3,11 @@
3
3
  [![npm version](https://img.shields.io/npm/v/@mdxui/do.svg)](https://www.npmjs.com/package/@mdxui/do)
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
5
5
 
6
- Admin interface for the .do platform - manage Durable Objects, Things, Relationships, Workflows, Agents, and Integrations.
6
+ Admin interface for the .do platform - manage Durable Objects and Things with a full dashboard shell.
7
7
 
8
8
  ## What is @mdxui/do?
9
9
 
10
- `@mdxui/do` provides a React-based admin interface for the [.do platform](https://do.md). It enables you to manage semantic entities (Things), graph relationships, business process workflows, and autonomous AI agents. Built on TanStack Query, the library supports two operational modes: traditional REST API fetching or local-first reactive data with TanStack DB and WebSocket sync.
10
+ `@mdxui/do` provides a React-based admin interface for the [.do platform](https://do.md). It includes a complete dashboard shell with routing, authentication (WorkOS AuthKit), and multiple view experiences: data browser, spreadsheet-style grid, document editor, and function executor. The library uses capnweb for RPC communication and `@mdxui/admin` for UI components.
11
11
 
12
12
  ## Installation
13
13
 
@@ -27,7 +27,46 @@ npm install react react-dom
27
27
 
28
28
  ## Quick Start
29
29
 
30
- Wrap your application with `DOProvider` and start using hooks to fetch and mutate data:
30
+ ### Complete Admin App
31
+
32
+ The easiest way to get started is with the `DOApp` component:
33
+
34
+ ```tsx
35
+ import { DOApp } from '@mdxui/do/app'
36
+
37
+ function App() {
38
+ return (
39
+ <DOApp
40
+ config={{
41
+ do: {
42
+ apiEndpoint: 'https://api.example.do',
43
+ authMethod: 'jwt',
44
+ bindings: [],
45
+ realTimeUpdates: false,
46
+ },
47
+ identity: {
48
+ clientId: 'client_xxx',
49
+ devMode: true,
50
+ },
51
+ branding: {
52
+ name: 'My Admin',
53
+ },
54
+ defaultNamespace: 'production',
55
+ }}
56
+ />
57
+ )
58
+ }
59
+ ```
60
+
61
+ This provides a complete admin experience with:
62
+ - Dashboard shell with sidebar navigation
63
+ - WorkOS AuthKit authentication
64
+ - URL-based routing (Things, Databases, Functions, etc.)
65
+ - Multiple view modes (browser, grid, document, function)
66
+
67
+ ### Using the Provider Directly
68
+
69
+ For custom UIs, wrap your app with `DOProvider`:
31
70
 
32
71
  ```tsx
33
72
  import { DOProvider, useThings, useCreateThing } from '@mdxui/do'
@@ -36,13 +75,11 @@ function App() {
36
75
  return (
37
76
  <DOProvider
38
77
  config={{
39
- apiEndpoint: 'https://api.example.do/admin',
40
- doUrl: 'wss://api.example.do/do/workspace',
78
+ apiEndpoint: 'https://api.example.do',
41
79
  authMethod: 'jwt',
42
80
  authToken: 'your-token',
43
81
  bindings: [],
44
- realTimeUpdates: true,
45
- collections: ['Task', 'User', 'Project'],
82
+ realTimeUpdates: false,
46
83
  }}
47
84
  initialNamespace="default"
48
85
  >
@@ -58,173 +95,210 @@ function TaskList() {
58
95
  if (isLoading) return <div>Loading...</div>
59
96
  if (error) return <div>Error: {error.message}</div>
60
97
 
61
- const handleCreate = () => {
62
- createThing.mutate({
63
- ns: 'default',
64
- type: 'Task',
65
- name: 'New Task',
66
- data: { status: 'todo', priority: 'medium' },
67
- })
68
- }
69
-
70
98
  return (
71
- <div>
72
- <button onClick={handleCreate} disabled={createThing.isLoading}>
73
- Add Task
74
- </button>
75
- <ul>
76
- {data?.data.map((task) => (
77
- <li key={task.id}>{task.name}</li>
78
- ))}
79
- </ul>
80
- </div>
99
+ <ul>
100
+ {data?.data.map((task) => (
101
+ <li key={task.id}>{task.name}</li>
102
+ ))}
103
+ </ul>
81
104
  )
82
105
  }
83
106
  ```
84
107
 
85
- ## Core Concepts
108
+ ### Using the RPC Client Directly
86
109
 
87
- ### Things
110
+ Access the capnweb client instance for direct RPC calls:
88
111
 
89
- Things are semantic entities (nouns) that form the foundation of your data model. Each Thing has:
112
+ ```tsx
113
+ import { useDO, useDOClient } from '@mdxui/do'
114
+
115
+ function MyComponent() {
116
+ const { client, isConnected } = useDO()
117
+ // or just: const client = useDOClient()
118
+
119
+ const fetchData = async () => {
120
+ // Promise pipelining - efficient batched RPC calls
121
+ const [users, projects] = await Promise.all([
122
+ client.Thing.list({ type: 'User' }),
123
+ client.Thing.list({ type: 'Project' }),
124
+ ])
125
+ return { users, projects }
126
+ }
127
+ }
128
+ ```
90
129
 
91
- - **Namespace (`ns`)**: Tenant or domain isolation (e.g., `"default"`, `"production"`)
92
- - **Type**: Entity classification (e.g., `"Task"`, `"User"`, `"Project"`)
93
- - **ID**: Unique identifier within namespace/type
94
- - **Data**: JSON-LD compatible payload with flexible schema
130
+ ## Shell Components
131
+
132
+ ### DOApp
133
+
134
+ Complete routed application with authentication and navigation:
95
135
 
96
136
  ```tsx
97
- const { data } = useThings({ type: 'Task', nameSearch: 'urgent' })
98
- const { data: task } = useThing('default', 'Task', 'task-123')
137
+ import { DOApp } from '@mdxui/do/app'
138
+
139
+ <DOApp config={shellConfig} />
99
140
  ```
100
141
 
101
- ### Relationships
142
+ ### DOShell
102
143
 
103
- Relationships form a semantic knowledge graph connecting Things using 64+ built-in predicates across temporal, spatial, directional, relational, and causal categories.
144
+ Dashboard shell layout for custom routing setups:
104
145
 
105
146
  ```tsx
106
- // Fetch relationships for an entity
107
- const { data } = useEntityRelationships(
108
- { ns: 'default', type: 'Task', id: 'task-1', semanticId: 'default/Task/task-1' },
109
- 'both'
110
- )
111
-
112
- // Create a relationship
113
- const createRelationship = useCreateRelationship()
114
- createRelationship.mutate({
115
- relationshipType: 'dependsOn',
116
- from: { ns: 'default', type: 'Task', id: 'task-2', semanticId: 'default/Task/task-2' },
117
- to: { ns: 'default', type: 'Task', id: 'task-1', semanticId: 'default/Task/task-1' },
118
- })
147
+ import { DOShell, DOShellNav } from '@mdxui/do/app'
148
+
149
+ <DOShell>
150
+ <YourContent />
151
+ </DOShell>
119
152
  ```
120
153
 
121
- ### Workflows
154
+ ### AuthGate
122
155
 
123
- Workflows orchestrate multi-step business processes with support for:
156
+ Authentication guard that shows sign-in when unauthenticated:
124
157
 
125
- - Event, schedule, manual, or webhook triggers
126
- - Function steps (Code, Generative, Agentic, Human)
127
- - Conditional branching and parallel execution
128
- - Saga pattern for compensation/rollback
158
+ ```tsx
159
+ import { AuthGate } from '@mdxui/do/app'
160
+
161
+ <AuthGate>
162
+ <ProtectedContent />
163
+ </AuthGate>
164
+ ```
165
+
166
+ ## View Modes
167
+
168
+ `@mdxui/do` provides four view experiences for managing Things:
169
+
170
+ | View | Component | Description |
171
+ |------|-----------|-------------|
172
+ | **Data Browser** | `DataBrowserView` | Browse and search Things with filtering and sorting |
173
+ | **Data Grid** | `DataGridView` | Spreadsheet-style editing with inline cell editing |
174
+ | **Document Editor** | `DocumentEditorView` | Form-based editing for individual Things |
175
+ | **Function Editor** | `FunctionEditorView` | Execute code/functions against the DO |
129
176
 
130
177
  ```tsx
131
- const { data: workflows } = useWorkflows({ status: ['active'] })
132
- const triggerWorkflow = useTriggerWorkflow('workflow-id')
178
+ import { DataBrowserView, DataGridView, DocumentEditorView } from '@mdxui/do/views'
133
179
 
134
- // Trigger with input
135
- triggerWorkflow.mutate({ customerId: 'cust-123' })
180
+ // Use individual views in your own layout
181
+ function CustomAdmin() {
182
+ return (
183
+ <DOProvider config={config}>
184
+ <DataBrowserView />
185
+ </DOProvider>
186
+ )
187
+ }
136
188
  ```
137
189
 
138
- ### Agents
190
+ ## Core Concepts
191
+
192
+ ### Things
139
193
 
140
- Agents are autonomous AI workers derived from O*NET occupations and NAICS industries, creating 40,000+ potential agent types. They include:
194
+ Things are semantic entities (nouns) that form the foundation of your data model:
141
195
 
142
- - System prompts and character bibles for persona
143
- - Tool access and guardrails for safety
144
- - Handoff rules for multi-agent coordination
145
- - Performance metrics and feedback collection
196
+ - **Namespace (`ns`)**: Tenant or domain isolation
197
+ - **Type**: Entity classification (e.g., `"Task"`, `"User"`)
198
+ - **ID**: Unique identifier within namespace/type
199
+ - **Data**: JSON-LD compatible payload
146
200
 
147
201
  ```tsx
148
- const { data: agents } = useAgents({ roleCategory: ['engineer'], status: ['active'] })
149
- const executeAgent = useExecuteAgent('agent-id')
202
+ import { useThings, useThing, useCreateThing } from '@mdxui/do'
203
+
204
+ // Fetch multiple Things with filtering
205
+ const { data } = useThings({ type: 'Task', nameSearch: 'urgent' })
150
206
 
151
- executeAgent.mutate({
152
- task: 'Review this pull request for security issues',
153
- context: { prUrl: 'https://github.com/...' },
207
+ // Fetch a single Thing
208
+ const { data: task } = useThing('default', 'Task', 'task-123')
209
+
210
+ // Create a new Thing
211
+ const createThing = useCreateThing()
212
+ createThing.mutate({
213
+ ns: 'default',
214
+ type: 'Task',
215
+ name: 'New Task',
216
+ data: { priority: 'high' },
154
217
  })
155
218
  ```
156
219
 
157
- ## Dual Mode Operation
220
+ ### Schema Discovery
158
221
 
159
- `@mdxui/do` supports two operational modes depending on your configuration:
222
+ Automatically discover available types and their schemas:
160
223
 
161
- | Mode | Configuration | Use Case | Features |
162
- |------|---------------|----------|----------|
163
- | **REST API** | `apiEndpoint` only | Traditional server-rendered apps | Standard fetch, server-side caching |
164
- | **TanStack DB** | `apiEndpoint` + `doUrl` | Real-time collaborative apps | Local-first, WebSocket sync, offline support |
224
+ ```tsx
225
+ import { useSchema, useTypes, useNamespaces } from '@mdxui/do'
165
226
 
166
- ### REST API Mode
227
+ // Get all namespaces
228
+ const { data: namespaces } = useNamespaces()
167
229
 
168
- ```tsx
169
- <DOProvider
170
- config={{
171
- apiEndpoint: 'https://api.example.do/admin',
172
- authMethod: 'jwt',
173
- authToken: 'your-token',
174
- bindings: [],
175
- realTimeUpdates: false,
176
- }}
177
- >
178
- {children}
179
- </DOProvider>
230
+ // Get all types in a namespace
231
+ const { data: types } = useTypes({ namespace: 'default' })
232
+
233
+ // Get schema for a specific type
234
+ const { data: schema } = useSchema('Task')
180
235
  ```
181
236
 
182
- ### TanStack DB Mode (Recommended)
237
+ ### Real-time Subscriptions
238
+
239
+ Subscribe to Thing changes for real-time updates:
183
240
 
184
241
  ```tsx
185
- <DOProvider
186
- config={{
187
- apiEndpoint: 'https://api.example.do/admin',
188
- doUrl: 'wss://api.example.do/do/workspace',
189
- authMethod: 'jwt',
190
- authToken: 'your-token',
191
- bindings: [],
192
- realTimeUpdates: true,
193
- collections: ['Task', 'User', 'Project'],
194
- conflictStrategy: 'last-write-wins',
195
- offline: { enabled: true, dbName: 'my-app-cache' },
196
- }}
197
- >
198
- {children}
199
- </DOProvider>
242
+ import { useThingSubscription, useSingleThingSubscription } from '@mdxui/do'
243
+
244
+ // Subscribe to all Things of a type
245
+ useThingSubscription({
246
+ type: 'Task',
247
+ onEvent: (event) => {
248
+ console.log('Thing changed:', event)
249
+ },
250
+ })
251
+
252
+ // Subscribe to a single Thing
253
+ useSingleThingSubscription({
254
+ ns: 'default',
255
+ type: 'Task',
256
+ id: 'task-123',
257
+ onEvent: (event) => {
258
+ console.log('Task updated:', event)
259
+ },
260
+ })
200
261
  ```
201
262
 
202
263
  ## Configuration
203
264
 
204
- ### DOAdminConfig
265
+ ### DOShellConfig
205
266
 
206
- | Property | Type | Required | Default | Description |
207
- |----------|------|----------|---------|-------------|
208
- | `apiEndpoint` | `string` | Yes | - | Base URL for REST API calls |
209
- | `doUrl` | `string` | No | - | WebSocket URL for Durable Object sync (enables TanStack DB mode) |
210
- | `authMethod` | `'jwt' \| 'api-key' \| 'oauth'` | Yes | - | Authentication method |
211
- | `authToken` | `string` | No | - | JWT token or API key |
212
- | `bindings` | `DOBinding[]` | Yes | - | Available Durable Object bindings |
213
- | `realTimeUpdates` | `boolean` | Yes | - | Enable real-time data updates |
214
- | `wsEndpoint` | `string` | No | - | Legacy WebSocket endpoint (prefer `doUrl`) |
215
- | `conflictStrategy` | `'last-write-wins' \| 'merge' \| ConflictResolver` | No | `'last-write-wins'` | How to resolve sync conflicts |
216
- | `offline` | `OfflineConfig` | No | - | Offline persistence settings |
217
- | `collections` | `string[]` | No | - | Entity types to auto-sync |
267
+ Configuration for the complete `DOApp`:
218
268
 
219
- ### DOProviderProps
269
+ | Property | Type | Required | Description |
270
+ |----------|------|----------|-------------|
271
+ | `do` | `DOAdminConfig` | Yes | RPC and API configuration |
272
+ | `identity` | `DOIdentity` | Yes | WorkOS AuthKit configuration |
273
+ | `basePath` | `string` | No | Base URL path for routing |
274
+ | `defaultNamespace` | `string` | No | Initial namespace |
275
+ | `branding` | `{ name?, logo? }` | No | Custom branding |
276
+ | `theme` | `{ mode? }` | No | Theme preference (light/dark/system) |
277
+ | `routes` | `Record<string, boolean>` | No | Enable/disable specific routes |
278
+
279
+ ### DOAdminConfig
220
280
 
221
281
  | Property | Type | Required | Default | Description |
222
282
  |----------|------|----------|---------|-------------|
223
- | `config` | `DOAdminConfig` | Yes | - | Admin configuration |
224
- | `initialNamespace` | `string` | No | `'default'` | Starting namespace |
225
- | `userId` | `string` | No | - | Current user ID |
226
- | `children` | `ReactNode` | Yes | - | Child components |
227
- | `queryClient` | `QueryClient` | No | - | Custom TanStack Query client |
283
+ | `apiEndpoint` | `string` | Yes | - | Base URL for API calls |
284
+ | `rpcUrl` | `string` | No | `${apiEndpoint}/rpc` | Explicit RPC URL for capnweb session |
285
+ | `authMethod` | `'none' \| 'jwt' \| 'api-key' \| 'oauth'` | Yes | - | Authentication method |
286
+ | `authToken` | `string` | No | - | JWT token or API key |
287
+ | `bindings` | `DOBinding[]` | Yes | - | Durable Object bindings |
288
+ | `realTimeUpdates` | `boolean` | Yes | - | Enable real-time updates via RPC subscriptions |
289
+ | `clientType` | `'capnweb' \| 'json-rpc'` | No | `'capnweb'` | RPC client type |
290
+ | `requestTimeout` | `number` | No | `30000` | Request timeout in ms |
291
+ | `skipHealthCheck` | `boolean` | No | `false` | Skip health check on connection |
292
+ | `healthCheckRetries` | `number` | No | `3` | Number of health check retries |
293
+
294
+ ### DOIdentity
295
+
296
+ | Property | Type | Required | Description |
297
+ |----------|------|----------|-------------|
298
+ | `clientId` | `string` | Yes | WorkOS client ID |
299
+ | `apiHostname` | `string` | No | WorkOS API hostname |
300
+ | `devMode` | `boolean` | No | Enable development mode |
301
+ | `redirectUri` | `string` | No | OAuth redirect URI |
228
302
 
229
303
  ## Available Hooks
230
304
 
@@ -232,179 +306,92 @@ executeAgent.mutate({
232
306
 
233
307
  | Hook | Description |
234
308
  |------|-------------|
235
- | `useDO()` | Access the DO context (config, namespace, connection status) |
236
- | `useDOUrls()` | Get derived URLs (rpcUrl, syncUrl, apiEndpoint) |
237
- | `useSyncStatus()` | Get current sync status (`'disconnected'`, `'connecting'`, `'syncing'`, `'synced'`, `'error'`) |
309
+ | `useDO()` | Access DO context (config, namespace, client, connection state) |
310
+ | `useDOClient()` | Access the capnweb client instance directly |
311
+ | `useDOUrls()` | Get derived URLs (rpcUrl, apiEndpoint) |
312
+ | `useIdentity()` | Access WorkOS auth state (from AuthKit) |
313
+ | `useDOShell()` | Access shell config and navigation state |
238
314
 
239
315
  ### Things Hooks
240
316
 
241
317
  | Hook | Description |
242
318
  |------|-------------|
243
- | `useThings(filter?, sort?, pagination?)` | Fetch a paginated list of Things |
244
- | `useThing(ns, type, id)` | Fetch a single Thing by semantic ID |
319
+ | `useThings(filter?)` | Fetch paginated Things with filtering |
320
+ | `useThing(ns, type, id)` | Fetch a single Thing |
245
321
  | `useThingVersions(ns, type, id)` | Fetch version history for a Thing |
246
- | `useTypeStats(ns, type)` | Fetch statistics for a Thing type |
322
+ | `useTypeStats(type)` | Fetch statistics for a Thing type |
247
323
  | `useCreateThing()` | Create a new Thing |
248
324
  | `useUpdateThing(ns, type, id)` | Update an existing Thing |
249
- | `useDeleteThing(ns, type, id)` | Soft or hard delete a Thing |
325
+ | `useDeleteThing(ns, type, id)` | Delete a Thing |
250
326
 
251
- ### Relationships Hooks
327
+ ### Discovery Hooks
252
328
 
253
329
  | Hook | Description |
254
330
  |------|-------------|
255
- | `useRelationships(filter?)` | Fetch relationships with optional filters |
256
- | `useEntityRelationships(entity, direction?)` | Fetch relationships for a specific entity |
257
- | `useGraphTraversal(entity, pattern)` | Traverse the graph from a starting entity |
258
- | `useGraphStats()` | Fetch graph statistics |
259
- | `useCreateRelationship()` | Create a new relationship |
260
- | `useDeleteRelationship()` | Delete a relationship |
261
-
262
- ### Workflows Hooks
331
+ | `useSchema(type)` | Get schema for a Thing type |
332
+ | `useSchemaDefinition(type)` | Get detailed schema definition |
333
+ | `useNamespaces()` | List available namespaces |
334
+ | `useTypes(options?)` | List available Thing types |
263
335
 
264
- | Hook | Description |
265
- |------|-------------|
266
- | `useWorkflows(filter?)` | Fetch workflows with optional filters |
267
- | `useWorkflow(id)` | Fetch a single workflow |
268
- | `useWorkflowExecutions(filter?)` | Fetch workflow executions |
269
- | `useWorkflowExecution(id)` | Fetch a single execution (auto-refetch while running) |
270
- | `useCreateWorkflow()` | Create a new workflow |
271
- | `useUpdateWorkflow(id)` | Update an existing workflow |
272
- | `useTriggerWorkflow(id)` | Manually trigger a workflow |
273
- | `useCancelExecution()` | Cancel a running execution |
274
- | `useDeleteWorkflow()` | Delete a workflow |
275
-
276
- ### Agents Hooks
336
+ ### Subscription Hooks
277
337
 
278
338
  | Hook | Description |
279
339
  |------|-------------|
280
- | `useAgents(filter?)` | Fetch agents with optional filters |
281
- | `useAgent(id)` | Fetch a single agent |
282
- | `useAgentMetrics(id, periodDays?)` | Fetch performance metrics for an agent |
283
- | `useAgentExecutions(filter?)` | Fetch agent executions |
284
- | `useAgentExecution(id)` | Fetch a single execution (auto-refetch while running) |
285
- | `useCreateAgent()` | Create a new agent |
286
- | `useUpdateAgent(id)` | Update an existing agent |
287
- | `useExecuteAgent(id)` | Execute an agent with a task |
288
- | `useSubmitAgentFeedback(executionId)` | Submit feedback for an execution |
289
- | `useDeleteAgent()` | Delete an agent |
340
+ | `useThingSubscription(options)` | Subscribe to Thing changes |
341
+ | `useSingleThingSubscription(options)` | Subscribe to a single Thing |
290
342
 
291
- ## Query Keys
292
-
293
- Each hook module exports query key factories for cache management:
343
+ ## Subpath Exports
294
344
 
295
345
  ```tsx
296
- import { thingsKeys, relationshipsKeys, workflowsKeys, agentsKeys } from '@mdxui/do/hooks'
297
- import { useQueryClient } from '@tanstack/react-query'
298
-
299
- const queryClient = useQueryClient()
346
+ // Full package - types, providers, hooks, components, views, app
347
+ import { DOProvider, useThings, DOApp } from '@mdxui/do'
300
348
 
301
- // Invalidate all things queries
302
- queryClient.invalidateQueries({ queryKey: thingsKeys.all })
349
+ // App components - DOApp, DOShell, pages, routes
350
+ import { DOApp, DOShell, DOShellNav, AuthGate } from '@mdxui/do/app'
303
351
 
304
- // Invalidate a specific thing
305
- queryClient.invalidateQueries({ queryKey: thingsKeys.detail('default', 'Task', 'task-1') })
352
+ // Providers - DOProvider and context hooks
353
+ import { DOProvider, useDO, useDOClient } from '@mdxui/do/providers'
306
354
 
307
- // Invalidate all workflow executions
308
- queryClient.invalidateQueries({ queryKey: workflowsKeys.executions() })
309
- ```
355
+ // Hooks - all data fetching hooks
356
+ import { useThings, useSchema, useNamespaces } from '@mdxui/do/hooks'
310
357
 
311
- ## Components
358
+ // Things-specific hooks
359
+ import { useThings, useCreateThing } from '@mdxui/do/hooks/things'
312
360
 
313
- The package includes pre-built UI components:
361
+ // Views - the 4 view experiences
362
+ import { DataBrowserView, DataGridView } from '@mdxui/do/views'
314
363
 
315
- ```tsx
316
- import { DOShell, DOSidebar, DOHeader, ThingsList, StatsCards, ErrorBoundary } from '@mdxui/do/components'
317
- ```
364
+ // Components - UI components
365
+ import { ErrorBoundary } from '@mdxui/do/components'
318
366
 
319
- | Component | Description |
320
- |-----------|-------------|
321
- | `DOShell` | Main application shell with sidebar and header |
322
- | `DOSidebar` | Navigation sidebar with customizable items |
323
- | `DOHeader` | Application header with namespace selector |
324
- | `ThingsList` | Data table for displaying Things |
325
- | `StatsCards` | Dashboard statistics cards |
326
- | `ErrorBoundary` | Error boundary with fallback UI |
367
+ // Types - TypeScript types
368
+ import type { Thing, DOAdminConfig, ThingFilter } from '@mdxui/do/types'
327
369
 
328
- ## Types
370
+ // Schemas - Zod schemas for validation
371
+ import { ThingSchema, ThingFilterSchema } from '@mdxui/do/schemas'
329
372
 
330
- Import types for TypeScript projects:
331
-
332
- ```tsx
333
- import type {
334
- // Things
335
- Thing,
336
- ThingFilter,
337
- ThingCreateInput,
338
- ThingUpdateInput,
339
- ThingQueryResult,
340
-
341
- // Relationships
342
- Relationship,
343
- SemanticPredicate,
344
- EntityReference,
345
- GraphTraversalResult,
346
-
347
- // Workflows
348
- Workflow,
349
- WorkflowExecution,
350
- WorkflowStep,
351
-
352
- // Agents
353
- Agent,
354
- AgentExecution,
355
- AgentMetrics,
356
-
357
- // Config
358
- DOAdminConfig,
359
- DOBinding,
360
- SyncStatus,
361
- } from '@mdxui/do/types'
373
+ // Lib - utilities
374
+ import { cn, formatDate, APIError } from '@mdxui/do/lib'
362
375
  ```
363
376
 
364
- ## Subpath Exports
377
+ ## Architecture
365
378
 
366
- The package provides granular imports for tree-shaking:
367
-
368
- ```tsx
369
- // Full package
370
- import { DOProvider, useThings, Thing } from '@mdxui/do'
371
-
372
- // Just providers
373
- import { DOProvider, useDO } from '@mdxui/do/providers'
374
-
375
- // Just hooks
376
- import { useThings, useAgents } from '@mdxui/do/hooks'
377
-
378
- // Just components
379
- import { DOShell, ThingsList } from '@mdxui/do/components'
380
-
381
- // Just types
382
- import type { Thing, Agent } from '@mdxui/do/types'
383
379
  ```
384
-
385
- ## Error Handling
386
-
387
- The package provides type guards for handling API errors:
388
-
389
- ```tsx
390
- import { isValidationErrorData, isNotFoundError, isRateLimitError, isAppError } from '@mdxui/do/types'
391
-
392
- try {
393
- await createThing.mutateAsync({ /* ... */ })
394
- } catch (error) {
395
- if (isAppError(error)) {
396
- if (isValidationErrorData(error)) {
397
- // Handle validation errors (API response data)
398
- error.errors.forEach(e => console.log(e.field, e.message))
399
- } else if (isNotFoundError(error)) {
400
- // Handle not found
401
- console.log(`${error.resourceType}/${error.resourceId} not found`)
402
- } else if (isRateLimitError(error)) {
403
- // Handle rate limiting
404
- console.log(`Retry after ${error.retryAfter}ms`)
405
- }
406
- }
407
- }
380
+ @mdxui/do
381
+ ├── app/ # DOApp, DOShell, pages, routes, auth
382
+ ├── providers/ # DOProvider, context hooks
383
+ ├── hooks/ # Data fetching hooks (Things, Schema, etc.)
384
+ ├── views/ # View components (Browser, Grid, Document, Function)
385
+ ├── components/ # Shared UI components
386
+ ├── types/ # TypeScript types + Zod schemas
387
+ └── lib/ # Utilities (cn, errors, formatters)
388
+
389
+ Dependencies:
390
+ ├── capnweb # Binary RPC over HTTP
391
+ ├── @workos-inc/authkit # Authentication
392
+ ├── @mdxui/admin # UI components
393
+ ├── @mdxui/primitives # Base UI primitives
394
+ └── @tanstack/react-query # Data fetching & caching
408
395
  ```
409
396
 
410
397
  ## License