@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.
- package/README.md +253 -266
- 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 +13 -0
- package/dist/app/index.js.map +1 -0
- package/dist/chunk-4KXVN3EQ.js +56 -0
- package/dist/chunk-4KXVN3EQ.js.map +1 -0
- package/dist/chunk-5AWTQDRF.js +76 -0
- package/dist/chunk-5AWTQDRF.js.map +1 -0
- package/dist/chunk-EQVOEEQO.js +95 -0
- package/dist/chunk-EQVOEEQO.js.map +1 -0
- package/dist/chunk-FO3N7SXV.js +469 -0
- package/dist/chunk-FO3N7SXV.js.map +1 -0
- package/dist/chunk-IESVTECE.js +536 -0
- package/dist/chunk-IESVTECE.js.map +1 -0
- package/dist/chunk-JWKIONEO.js +234 -0
- package/dist/chunk-JWKIONEO.js.map +1 -0
- package/dist/chunk-NTSEARBC.js +715 -0
- package/dist/chunk-NTSEARBC.js.map +1 -0
- package/dist/chunk-OWEAW4U6.js +116 -0
- package/dist/chunk-OWEAW4U6.js.map +1 -0
- package/dist/chunk-VRLUXCLD.js +31 -0
- package/dist/chunk-VRLUXCLD.js.map +1 -0
- package/dist/chunk-Y52IEYVM.js +131 -0
- package/dist/chunk-Y52IEYVM.js.map +1 -0
- package/dist/chunk-YGIBMNRH.js +1991 -0
- package/dist/chunk-YGIBMNRH.js.map +1 -0
- package/dist/components/index.d.ts +1 -738
- package/dist/components/index.js +2 -6
- package/dist/config-CmZBQQaT.d.ts +122 -0
- package/dist/{do-CaQVueZw.d.ts → do-C-t9UgjT.d.ts} +31 -33
- package/dist/errors-B4Oyyj4Z.d.ts +346 -0
- package/dist/hooks/index.d.ts +428 -696
- 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 +21 -1010
- package/dist/index.js +11 -839
- package/dist/index.js.map +1 -1
- package/dist/lib/index.d.ts +100 -0
- package/dist/lib/index.js +6 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/providers/index.d.ts +244 -32
- package/dist/providers/index.js +3 -2
- package/dist/query-keys-BC901wog.d.ts +153 -0
- package/dist/schemas/index.d.ts +1 -1
- package/dist/schemas/index.js +2 -2
- package/dist/schemas/index.js.map +1 -1
- package/dist/{thing-DtI25yZh.d.ts → thing-BVhCTzOi.d.ts} +4 -4
- package/dist/types/index.d.ts +251 -216
- 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,11 +3,11 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/@mdxui/do)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
|
|
6
|
-
Admin interface for the .do platform - manage Durable Objects
|
|
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
|
|
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
|
-
|
|
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
|
|
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:
|
|
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
|
-
<
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
|
|
108
|
+
### Using the RPC Client Directly
|
|
86
109
|
|
|
87
|
-
|
|
110
|
+
Access the capnweb client instance for direct RPC calls:
|
|
88
111
|
|
|
89
|
-
|
|
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
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
130
|
+
## Shell Components
|
|
131
|
+
|
|
132
|
+
### DOApp
|
|
133
|
+
|
|
134
|
+
Complete routed application with authentication and navigation:
|
|
95
135
|
|
|
96
136
|
```tsx
|
|
97
|
-
|
|
98
|
-
|
|
137
|
+
import { DOApp } from '@mdxui/do/app'
|
|
138
|
+
|
|
139
|
+
<DOApp config={shellConfig} />
|
|
99
140
|
```
|
|
100
141
|
|
|
101
|
-
###
|
|
142
|
+
### DOShell
|
|
102
143
|
|
|
103
|
-
|
|
144
|
+
Dashboard shell layout for custom routing setups:
|
|
104
145
|
|
|
105
146
|
```tsx
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
-
###
|
|
154
|
+
### AuthGate
|
|
122
155
|
|
|
123
|
-
|
|
156
|
+
Authentication guard that shows sign-in when unauthenticated:
|
|
124
157
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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
|
-
|
|
132
|
-
const triggerWorkflow = useTriggerWorkflow('workflow-id')
|
|
178
|
+
import { DataBrowserView, DataGridView, DocumentEditorView } from '@mdxui/do/views'
|
|
133
179
|
|
|
134
|
-
//
|
|
135
|
-
|
|
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
|
-
|
|
190
|
+
## Core Concepts
|
|
191
|
+
|
|
192
|
+
### Things
|
|
139
193
|
|
|
140
|
-
|
|
194
|
+
Things are semantic entities (nouns) that form the foundation of your data model:
|
|
141
195
|
|
|
142
|
-
-
|
|
143
|
-
-
|
|
144
|
-
-
|
|
145
|
-
-
|
|
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
|
-
|
|
149
|
-
|
|
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
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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
|
-
|
|
220
|
+
### Schema Discovery
|
|
158
221
|
|
|
159
|
-
|
|
222
|
+
Automatically discover available types and their schemas:
|
|
160
223
|
|
|
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 |
|
|
224
|
+
```tsx
|
|
225
|
+
import { useSchema, useTypes, useNamespaces } from '@mdxui/do'
|
|
165
226
|
|
|
166
|
-
|
|
227
|
+
// Get all namespaces
|
|
228
|
+
const { data: namespaces } = useNamespaces()
|
|
167
229
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
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
|
-
###
|
|
237
|
+
### Real-time Subscriptions
|
|
238
|
+
|
|
239
|
+
Subscribe to Thing changes for real-time updates:
|
|
183
240
|
|
|
184
241
|
```tsx
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
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
|
-
###
|
|
265
|
+
### DOShellConfig
|
|
205
266
|
|
|
206
|
-
|
|
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
|
-
|
|
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
|
-
| `
|
|
224
|
-
| `
|
|
225
|
-
| `
|
|
226
|
-
| `
|
|
227
|
-
| `
|
|
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
|
|
236
|
-
| `
|
|
237
|
-
| `
|
|
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
|
|
244
|
-
| `useThing(ns, type, id)` | Fetch a single Thing
|
|
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(
|
|
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)` |
|
|
325
|
+
| `useDeleteThing(ns, type, id)` | Delete a Thing |
|
|
250
326
|
|
|
251
|
-
###
|
|
327
|
+
### Discovery Hooks
|
|
252
328
|
|
|
253
329
|
| Hook | Description |
|
|
254
330
|
|------|-------------|
|
|
255
|
-
| `
|
|
256
|
-
| `
|
|
257
|
-
| `
|
|
258
|
-
| `
|
|
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
|
-
|
|
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
|
-
| `
|
|
281
|
-
| `
|
|
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
|
-
##
|
|
292
|
-
|
|
293
|
-
Each hook module exports query key factories for cache management:
|
|
343
|
+
## Subpath Exports
|
|
294
344
|
|
|
295
345
|
```tsx
|
|
296
|
-
|
|
297
|
-
import {
|
|
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
|
-
//
|
|
302
|
-
|
|
349
|
+
// App components - DOApp, DOShell, pages, routes
|
|
350
|
+
import { DOApp, DOShell, DOShellNav, AuthGate } from '@mdxui/do/app'
|
|
303
351
|
|
|
304
|
-
//
|
|
305
|
-
|
|
352
|
+
// Providers - DOProvider and context hooks
|
|
353
|
+
import { DOProvider, useDO, useDOClient } from '@mdxui/do/providers'
|
|
306
354
|
|
|
307
|
-
//
|
|
308
|
-
|
|
309
|
-
```
|
|
355
|
+
// Hooks - all data fetching hooks
|
|
356
|
+
import { useThings, useSchema, useNamespaces } from '@mdxui/do/hooks'
|
|
310
357
|
|
|
311
|
-
|
|
358
|
+
// Things-specific hooks
|
|
359
|
+
import { useThings, useCreateThing } from '@mdxui/do/hooks/things'
|
|
312
360
|
|
|
313
|
-
|
|
361
|
+
// Views - the 4 view experiences
|
|
362
|
+
import { DataBrowserView, DataGridView } from '@mdxui/do/views'
|
|
314
363
|
|
|
315
|
-
|
|
316
|
-
import {
|
|
317
|
-
```
|
|
364
|
+
// Components - UI components
|
|
365
|
+
import { ErrorBoundary } from '@mdxui/do/components'
|
|
318
366
|
|
|
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 |
|
|
367
|
+
// Types - TypeScript types
|
|
368
|
+
import type { Thing, DOAdminConfig, ThingFilter } from '@mdxui/do/types'
|
|
327
369
|
|
|
328
|
-
|
|
370
|
+
// Schemas - Zod schemas for validation
|
|
371
|
+
import { ThingSchema, ThingFilterSchema } from '@mdxui/do/schemas'
|
|
329
372
|
|
|
330
|
-
|
|
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
|
-
##
|
|
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
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
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
|