@mdxui/do 2.1.1 → 4.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.
- package/README.md +115 -323
- package/dist/{agents-xcIn2dUB.d.ts → agents-2_r9e9i7.d.ts} +213 -2
- package/dist/app/index.d.ts +347 -0
- package/dist/app/index.js +14 -0
- package/dist/app/index.js.map +1 -0
- package/dist/breadcrumbs-C9Qn3S7d.d.ts +81 -0
- package/dist/capnweb-client-Bq78FtEA.d.ts +229 -0
- package/dist/chunk-3XKYQRXY.js +192 -0
- package/dist/chunk-3XKYQRXY.js.map +1 -0
- package/dist/chunk-4KXVN3EQ.js +56 -0
- package/dist/chunk-4KXVN3EQ.js.map +1 -0
- package/dist/chunk-5SHZZC7L.js +234 -0
- package/dist/chunk-5SHZZC7L.js.map +1 -0
- package/dist/chunk-7UFINK3Q.js +1994 -0
- package/dist/chunk-7UFINK3Q.js.map +1 -0
- package/dist/chunk-JJLAES6W.js +76 -0
- package/dist/chunk-JJLAES6W.js.map +1 -0
- package/dist/chunk-KT52UU3U.js +985 -0
- package/dist/chunk-KT52UU3U.js.map +1 -0
- package/dist/chunk-LJIWB7KE.js +95 -0
- package/dist/chunk-LJIWB7KE.js.map +1 -0
- package/dist/chunk-NA652ART.js +596 -0
- package/dist/chunk-NA652ART.js.map +1 -0
- package/dist/chunk-OVLO7UOH.js +1071 -0
- package/dist/chunk-OVLO7UOH.js.map +1 -0
- package/dist/chunk-VRLUXCLD.js +31 -0
- package/dist/chunk-VRLUXCLD.js.map +1 -0
- package/dist/chunk-WMNT4OIE.js +249 -0
- package/dist/chunk-WMNT4OIE.js.map +1 -0
- package/dist/chunk-Y52IEYVM.js +131 -0
- package/dist/chunk-Y52IEYVM.js.map +1 -0
- package/dist/components/index.d.ts +14 -732
- package/dist/components/index.js +3 -6
- package/dist/config-CxvpD8Y6.d.ts +111 -0
- package/dist/{do-CaQVueZw.d.ts → do-D27i5bU0.d.ts} +32 -33
- package/dist/errors-DratdVIz.d.ts +346 -0
- package/dist/hooks/index.d.ts +450 -691
- package/dist/hooks/index.js +6 -4
- package/dist/hooks/things/index.d.ts +298 -0
- package/dist/hooks/things/index.js +8 -0
- package/dist/hooks/things/index.js.map +1 -0
- package/dist/index.d.ts +62 -989
- package/dist/index.js +12 -839
- package/dist/index.js.map +1 -1
- package/dist/lib/index.d.ts +798 -0
- package/dist/lib/index.js +6 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/providers/index.d.ts +130 -34
- package/dist/providers/index.js +3 -2
- package/dist/query-keys-CZNFikIi.d.ts +153 -0
- package/dist/schemas/index.d.ts +5 -5
- package/dist/schemas/index.js +2 -2
- package/dist/schemas/index.js.map +1 -1
- package/dist/{thing-DtI25yZh.d.ts → thing-BF25aUtJ.d.ts} +72 -72
- package/dist/types/index.d.ts +693 -658
- package/dist/types/index.js +1 -2
- package/dist/views/index.d.ts +131 -0
- package/dist/views/index.js +11 -0
- package/dist/views/index.js.map +1 -0
- package/package.json +39 -17
- package/dist/__test-utils__/index.d.ts +0 -399
- package/dist/__test-utils__/index.js +0 -34641
- package/dist/__test-utils__/index.js.map +0 -1
- package/dist/chunk-EEDMN7UF.js +0 -1351
- package/dist/chunk-EEDMN7UF.js.map +0 -1
- package/dist/chunk-G3PMV62Z.js +0 -33
- package/dist/chunk-G3PMV62Z.js.map +0 -1
- package/dist/chunk-NXPXL5NA.js +0 -3789
- package/dist/chunk-NXPXL5NA.js.map +0 -1
- package/dist/chunk-PC5FJY6M.js +0 -20
- package/dist/chunk-PC5FJY6M.js.map +0 -1
- package/dist/chunk-XF6LKY2M.js +0 -445
- package/dist/chunk-XF6LKY2M.js.map +0 -1
- package/dist/magic-string.es-J7BYFTTJ.js +0 -1307
- package/dist/magic-string.es-J7BYFTTJ.js.map +0 -1
package/README.md
CHANGED
|
@@ -3,48 +3,59 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/@mdxui/do)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
## What is @mdxui/do?
|
|
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.
|
|
6
|
+
React components and hooks for building admin interfaces for .do Durable Objects.
|
|
11
7
|
|
|
12
8
|
## Installation
|
|
13
9
|
|
|
14
10
|
```bash
|
|
15
|
-
npm install @mdxui/do
|
|
16
|
-
# or
|
|
17
11
|
pnpm add @mdxui/do
|
|
18
|
-
# or
|
|
19
|
-
yarn add @mdxui/do
|
|
20
12
|
```
|
|
21
13
|
|
|
22
|
-
|
|
14
|
+
## Quick Start
|
|
15
|
+
|
|
16
|
+
### Full Admin Dashboard
|
|
23
17
|
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
Use `DOApp` for a complete admin experience with routing and authentication:
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
import { DOApp } from '@mdxui/do/app'
|
|
22
|
+
|
|
23
|
+
function App() {
|
|
24
|
+
return (
|
|
25
|
+
<DOApp
|
|
26
|
+
config={{
|
|
27
|
+
do: {
|
|
28
|
+
apiEndpoint: 'https://api.example.do',
|
|
29
|
+
authMethod: 'jwt',
|
|
30
|
+
bindings: [],
|
|
31
|
+
realTimeUpdates: false,
|
|
32
|
+
},
|
|
33
|
+
identity: {
|
|
34
|
+
clientId: 'client_xxx', // WorkOS client ID
|
|
35
|
+
devMode: true,
|
|
36
|
+
},
|
|
37
|
+
}}
|
|
38
|
+
/>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
26
41
|
```
|
|
27
42
|
|
|
28
|
-
|
|
43
|
+
### Custom UI with Provider
|
|
29
44
|
|
|
30
|
-
|
|
45
|
+
For custom UIs, use `DOProvider` directly:
|
|
31
46
|
|
|
32
47
|
```tsx
|
|
33
|
-
import { DOProvider, useThings
|
|
48
|
+
import { DOProvider, useThings } from '@mdxui/do'
|
|
34
49
|
|
|
35
50
|
function App() {
|
|
36
51
|
return (
|
|
37
52
|
<DOProvider
|
|
38
53
|
config={{
|
|
39
|
-
apiEndpoint: 'https://api.example.do
|
|
40
|
-
|
|
41
|
-
authMethod: 'jwt',
|
|
42
|
-
authToken: 'your-token',
|
|
54
|
+
apiEndpoint: 'https://api.example.do',
|
|
55
|
+
authMethod: 'none',
|
|
43
56
|
bindings: [],
|
|
44
|
-
realTimeUpdates:
|
|
45
|
-
collections: ['Task', 'User', 'Project'],
|
|
57
|
+
realTimeUpdates: false,
|
|
46
58
|
}}
|
|
47
|
-
initialNamespace="default"
|
|
48
59
|
>
|
|
49
60
|
<TaskList />
|
|
50
61
|
</DOProvider>
|
|
@@ -52,359 +63,140 @@ function App() {
|
|
|
52
63
|
}
|
|
53
64
|
|
|
54
65
|
function TaskList() {
|
|
55
|
-
const { data, isLoading
|
|
56
|
-
const createThing = useCreateThing()
|
|
66
|
+
const { data, isLoading } = useThings({ type: 'Task' })
|
|
57
67
|
|
|
58
68
|
if (isLoading) return <div>Loading...</div>
|
|
59
|
-
if (error) return <div>Error: {error.message}</div>
|
|
60
|
-
|
|
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
69
|
|
|
70
70
|
return (
|
|
71
|
-
<
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
{data?.data.map((task) => (
|
|
77
|
-
<li key={task.id}>{task.name}</li>
|
|
78
|
-
))}
|
|
79
|
-
</ul>
|
|
80
|
-
</div>
|
|
71
|
+
<ul>
|
|
72
|
+
{data?.data.map((task) => (
|
|
73
|
+
<li key={task.id}>{task.name}</li>
|
|
74
|
+
))}
|
|
75
|
+
</ul>
|
|
81
76
|
)
|
|
82
77
|
}
|
|
83
78
|
```
|
|
84
79
|
|
|
85
|
-
##
|
|
86
|
-
|
|
87
|
-
### Things
|
|
88
|
-
|
|
89
|
-
Things are semantic entities (nouns) that form the foundation of your data model. Each Thing has:
|
|
80
|
+
## Views
|
|
90
81
|
|
|
91
|
-
|
|
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
|
|
82
|
+
Four view components for managing Things:
|
|
95
83
|
|
|
96
84
|
```tsx
|
|
97
|
-
|
|
98
|
-
|
|
85
|
+
import {
|
|
86
|
+
DataBrowserView, // Browse/search with filtering
|
|
87
|
+
DataGridView, // Spreadsheet-style editing
|
|
88
|
+
DocumentEditorView, // Form-based editing
|
|
89
|
+
FunctionEditorView // Execute functions
|
|
90
|
+
} from '@mdxui/do/views'
|
|
99
91
|
```
|
|
100
92
|
|
|
101
|
-
|
|
93
|
+
## Hooks
|
|
102
94
|
|
|
103
|
-
|
|
95
|
+
### Data Fetching
|
|
104
96
|
|
|
105
97
|
```tsx
|
|
106
|
-
|
|
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
|
-
})
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
### Workflows
|
|
98
|
+
import { useThings, useThing, useCreateThing } from '@mdxui/do'
|
|
122
99
|
|
|
123
|
-
|
|
100
|
+
// List things
|
|
101
|
+
const { data } = useThings({ type: 'Task' })
|
|
124
102
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
- Conditional branching and parallel execution
|
|
128
|
-
- Saga pattern for compensation/rollback
|
|
103
|
+
// Get single thing
|
|
104
|
+
const { data } = useThing({ ns: 'default', type: 'Task', id: 'task-1' })
|
|
129
105
|
|
|
130
|
-
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
// Trigger with input
|
|
135
|
-
triggerWorkflow.mutate({ customerId: 'cust-123' })
|
|
106
|
+
// Create thing
|
|
107
|
+
const create = useCreateThing()
|
|
108
|
+
create.mutate({ ns: 'default', type: 'Task', name: 'New Task', data: {} })
|
|
136
109
|
```
|
|
137
110
|
|
|
138
|
-
###
|
|
139
|
-
|
|
140
|
-
Agents are autonomous AI workers derived from O*NET occupations and NAICS industries, creating 40,000+ potential agent types. They include:
|
|
141
|
-
|
|
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
|
|
111
|
+
### Discovery
|
|
146
112
|
|
|
147
113
|
```tsx
|
|
148
|
-
|
|
149
|
-
const executeAgent = useExecuteAgent('agent-id')
|
|
114
|
+
import { useNamespaces, useTypes, useSchema } from '@mdxui/do'
|
|
150
115
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
})
|
|
116
|
+
const { data: namespaces } = useNamespaces()
|
|
117
|
+
const { data: types } = useTypes()
|
|
118
|
+
const { data: schema } = useSchema('Task')
|
|
155
119
|
```
|
|
156
120
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
`@mdxui/do` supports two operational modes depending on your configuration:
|
|
121
|
+
### State Management
|
|
160
122
|
|
|
161
|
-
|
|
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 |
|
|
165
|
-
|
|
166
|
-
### REST API Mode
|
|
123
|
+
Endpoint and namespace state is managed via TanStack Query with localStorage persistence:
|
|
167
124
|
|
|
168
125
|
```tsx
|
|
169
|
-
|
|
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>
|
|
180
|
-
```
|
|
126
|
+
import { useDOState, useEndpoint, useSetEndpoint } from '@mdxui/do'
|
|
181
127
|
|
|
182
|
-
|
|
128
|
+
// Combined hook for all state
|
|
129
|
+
const { endpoint, setEndpoint, namespace, setNamespace, recentEndpoints } = useDOState({
|
|
130
|
+
endpoint: 'https://api.example.do', // Required: fallback from config
|
|
131
|
+
})
|
|
183
132
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
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>
|
|
133
|
+
// Or use individual hooks
|
|
134
|
+
const endpoint = useEndpoint('https://api.example.do')
|
|
135
|
+
const { mutate: setEndpoint } = useSetEndpoint()
|
|
200
136
|
```
|
|
201
137
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
### DOAdminConfig
|
|
205
|
-
|
|
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 |
|
|
218
|
-
|
|
219
|
-
### DOProviderProps
|
|
220
|
-
|
|
221
|
-
| Property | Type | Required | Default | Description |
|
|
222
|
-
|----------|------|----------|---------|-------------|
|
|
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 |
|
|
228
|
-
|
|
229
|
-
## Available Hooks
|
|
230
|
-
|
|
231
|
-
### Context Hooks
|
|
232
|
-
|
|
233
|
-
| Hook | Description |
|
|
234
|
-
|------|-------------|
|
|
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'`) |
|
|
238
|
-
|
|
239
|
-
### Things Hooks
|
|
240
|
-
|
|
241
|
-
| Hook | Description |
|
|
242
|
-
|------|-------------|
|
|
243
|
-
| `useThings(filter?, sort?, pagination?)` | Fetch a paginated list of Things |
|
|
244
|
-
| `useThing(ns, type, id)` | Fetch a single Thing by semantic ID |
|
|
245
|
-
| `useThingVersions(ns, type, id)` | Fetch version history for a Thing |
|
|
246
|
-
| `useTypeStats(ns, type)` | Fetch statistics for a Thing type |
|
|
247
|
-
| `useCreateThing()` | Create a new Thing |
|
|
248
|
-
| `useUpdateThing(ns, type, id)` | Update an existing Thing |
|
|
249
|
-
| `useDeleteThing(ns, type, id)` | Soft or hard delete a Thing |
|
|
250
|
-
|
|
251
|
-
### Relationships Hooks
|
|
252
|
-
|
|
253
|
-
| Hook | Description |
|
|
254
|
-
|------|-------------|
|
|
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
|
|
263
|
-
|
|
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
|
|
277
|
-
|
|
278
|
-
| Hook | Description |
|
|
279
|
-
|------|-------------|
|
|
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 |
|
|
290
|
-
|
|
291
|
-
## Query Keys
|
|
292
|
-
|
|
293
|
-
Each hook module exports query key factories for cache management:
|
|
138
|
+
State persists across sessions via localStorage and automatically invalidates data queries when the endpoint changes.
|
|
294
139
|
|
|
295
|
-
|
|
296
|
-
import { thingsKeys, relationshipsKeys, workflowsKeys, agentsKeys } from '@mdxui/do/hooks'
|
|
297
|
-
import { useQueryClient } from '@tanstack/react-query'
|
|
298
|
-
|
|
299
|
-
const queryClient = useQueryClient()
|
|
140
|
+
## Architecture
|
|
300
141
|
|
|
301
|
-
|
|
302
|
-
queryClient.invalidateQueries({ queryKey: thingsKeys.all })
|
|
142
|
+
`DOApp` provides a complete admin dashboard with:
|
|
303
143
|
|
|
304
|
-
|
|
305
|
-
|
|
144
|
+
- **TanStack Router** for client-side navigation
|
|
145
|
+
- **WorkOS AuthKit** for authentication
|
|
146
|
+
- **TanStack Query** for data fetching/caching
|
|
147
|
+
- **capnweb** for WebSocket RPC to Durable Objects
|
|
306
148
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
149
|
+
The auth flow:
|
|
150
|
+
1. User signs in via WorkOS
|
|
151
|
+
2. Access token is passed to `DOProvider`
|
|
152
|
+
3. RPC calls include token as `?token=` query param
|
|
153
|
+
4. Backend validates JWT
|
|
310
154
|
|
|
311
|
-
##
|
|
155
|
+
## Configuration
|
|
312
156
|
|
|
313
|
-
|
|
157
|
+
### DOAdminConfig (for DOProvider)
|
|
314
158
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
159
|
+
| Property | Type | Required | Description |
|
|
160
|
+
|----------|------|----------|-------------|
|
|
161
|
+
| `apiEndpoint` | `string` | Yes | Base URL for API |
|
|
162
|
+
| `authMethod` | `'none' \| 'jwt' \| 'api-key'` | Yes | Auth method |
|
|
163
|
+
| `authToken` | `string` | No | JWT or API key |
|
|
164
|
+
| `bindings` | `DOBinding[]` | Yes | DO bindings |
|
|
165
|
+
| `realTimeUpdates` | `boolean` | Yes | Enable subscriptions |
|
|
166
|
+
| `clientType` | `'capnweb' \| 'json-rpc'` | No | RPC client type |
|
|
318
167
|
|
|
319
|
-
|
|
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 |
|
|
168
|
+
### DOShellConfig (for DOApp)
|
|
327
169
|
|
|
328
|
-
|
|
170
|
+
| Property | Type | Required | Description |
|
|
171
|
+
|----------|------|----------|-------------|
|
|
172
|
+
| `do` | `DOAdminConfig` | Yes | API config |
|
|
173
|
+
| `identity` | `DOIdentity` | Yes | WorkOS auth config |
|
|
174
|
+
| `branding` | `{ name?, logo? }` | No | Branding |
|
|
175
|
+
| `basePath` | `string` | No | URL base path |
|
|
329
176
|
|
|
330
|
-
|
|
177
|
+
## Exports
|
|
331
178
|
|
|
332
179
|
```tsx
|
|
333
|
-
|
|
334
|
-
|
|
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'
|
|
362
|
-
```
|
|
363
|
-
|
|
364
|
-
## Subpath Exports
|
|
365
|
-
|
|
366
|
-
The package provides granular imports for tree-shaking:
|
|
180
|
+
// Main
|
|
181
|
+
import { DOProvider, useThings, DOApp } from '@mdxui/do'
|
|
367
182
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
import { DOProvider, useThings, Thing } from '@mdxui/do'
|
|
183
|
+
// App (routing, shell, auth)
|
|
184
|
+
import { DOApp, DOShell, AuthGate } from '@mdxui/do/app'
|
|
371
185
|
|
|
372
|
-
//
|
|
186
|
+
// Providers
|
|
373
187
|
import { DOProvider, useDO } from '@mdxui/do/providers'
|
|
374
188
|
|
|
375
|
-
//
|
|
376
|
-
import { useThings,
|
|
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
|
-
```
|
|
189
|
+
// Hooks
|
|
190
|
+
import { useThings, useCreateThing } from '@mdxui/do/hooks'
|
|
384
191
|
|
|
385
|
-
|
|
192
|
+
// State (TanStack Query-based)
|
|
193
|
+
import { useDOState, useEndpoint, useSetEndpoint, useNamespace } from '@mdxui/do'
|
|
386
194
|
|
|
387
|
-
|
|
195
|
+
// Views
|
|
196
|
+
import { DataBrowserView, DataGridView } from '@mdxui/do/views'
|
|
388
197
|
|
|
389
|
-
|
|
390
|
-
import {
|
|
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
|
-
}
|
|
198
|
+
// Types
|
|
199
|
+
import type { Thing, DOAdminConfig } from '@mdxui/do/types'
|
|
408
200
|
```
|
|
409
201
|
|
|
410
202
|
## License
|