@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/dist/hooks/index.d.ts
CHANGED
|
@@ -1,801 +1,533 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { DataProvider, DotdoDataProviderConfig, UseResourceConfig, UseResourceResult } from '@dotdo/react/admin';
|
|
9
|
-
export { AdminError, AdminErrorCode, AdminErrorDetails, CacheConfig, CreateParams, CreateResult, DataProvider, DataProviderConfig, DeleteManyParams, DeleteManyResult, DeleteParams, DeleteResult, AdminContextValue as DotdoAdminContextValue, AdminProvider as DotdoAdminProvider, DotdoDataProvider, DotdoDataProviderConfig, FilterOperator, GetListParams, GetListResult, GetManyParams, GetManyResult, GetOneParams, GetOneResult, InferredField, OptimisticConfig, QueryFilter, ResourceConfig, ResourceDefinition, SortOrder, UpdateParams, UpdateResult, createCacheKey, createResourceFromSchema, formatAdminError, inferFieldsFromSchema, invalidateCache, isAdminError, useAdminContext, useOptimisticUpdate } from '@dotdo/react/admin';
|
|
10
|
-
import { AdminProviderProps } from '@mdxui/admin/components';
|
|
11
|
-
export { AdminProvider } from '@mdxui/admin/components';
|
|
12
|
-
export { WorkflowContext, use$ } from '@dotdo/react';
|
|
13
|
-
import '../do-CaQVueZw.js';
|
|
1
|
+
import { N as Namespace, S as SemanticType, c as ThingFilter, T as Thing } from '../thing-BVhCTzOi.js';
|
|
2
|
+
export { DeleteThingOptions, UseCreateThingResult, UseDeleteThingResult, UseThingResult, UseThingVersionsResult, UseThingsResult, UseTypeStatsResult, UseUpdateThingResult, useCreateThing, useDeleteThing, useThing, useThingVersions, useThings, useTypeStats, useUpdateThing } from './things/index.js';
|
|
3
|
+
export { t as thingsKeys } from '../query-keys-BC901wog.js';
|
|
4
|
+
import 'zod';
|
|
5
|
+
import '@tanstack/react-query';
|
|
6
|
+
import '../schemas/index.js';
|
|
7
|
+
import '../agents-2_r9e9i7.js';
|
|
14
8
|
|
|
15
9
|
/**
|
|
16
|
-
*
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
*/
|
|
20
|
-
|
|
10
|
+
* Property definition in a schema
|
|
11
|
+
*/
|
|
12
|
+
interface SchemaProperty {
|
|
13
|
+
/** Property name */
|
|
14
|
+
name: string;
|
|
15
|
+
/** Property type (string, number, boolean, object, array, etc.) */
|
|
16
|
+
type: string;
|
|
17
|
+
/** Whether the property is required */
|
|
18
|
+
required?: boolean;
|
|
19
|
+
/** Property description */
|
|
20
|
+
description?: string;
|
|
21
|
+
/** Default value */
|
|
22
|
+
default?: unknown;
|
|
23
|
+
/** For array types, the item type */
|
|
24
|
+
items?: SchemaProperty;
|
|
25
|
+
/** For object types, nested properties */
|
|
26
|
+
properties?: SchemaProperty[];
|
|
27
|
+
}
|
|
21
28
|
/**
|
|
22
|
-
*
|
|
29
|
+
* Schema definition for a resource type
|
|
23
30
|
*/
|
|
24
|
-
interface
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
31
|
+
interface SchemaDefinition {
|
|
32
|
+
/** Schema name (usually the type name) */
|
|
33
|
+
name: string;
|
|
34
|
+
/** Namespace this schema belongs to */
|
|
35
|
+
ns?: string;
|
|
36
|
+
/** Human-readable description */
|
|
37
|
+
description?: string;
|
|
38
|
+
/** Properties defined in this schema */
|
|
39
|
+
properties: SchemaProperty[];
|
|
40
|
+
/** Primary key field(s) */
|
|
41
|
+
primaryKey?: string | string[];
|
|
42
|
+
/** Indexes defined on this schema */
|
|
43
|
+
indexes?: Array<{
|
|
44
|
+
name: string;
|
|
45
|
+
fields: string[];
|
|
46
|
+
unique?: boolean;
|
|
47
|
+
}>;
|
|
48
|
+
/** Timestamps */
|
|
49
|
+
createdAt?: Date;
|
|
50
|
+
updatedAt?: Date;
|
|
41
51
|
}
|
|
42
52
|
/**
|
|
43
|
-
*
|
|
44
|
-
*/
|
|
45
|
-
interface
|
|
46
|
-
/**
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
isRefetching: boolean;
|
|
58
|
-
/** True if any fetch is in progress */
|
|
59
|
-
isFetching: boolean;
|
|
60
|
-
/** Query status: 'pending', 'success', or 'error' */
|
|
61
|
-
status: 'pending' | 'success' | 'error';
|
|
53
|
+
* Result from schema discovery
|
|
54
|
+
*/
|
|
55
|
+
interface SchemaDiscoveryResult {
|
|
56
|
+
/** Available schemas */
|
|
57
|
+
schemas: SchemaDefinition[];
|
|
58
|
+
/** Available namespaces */
|
|
59
|
+
namespaces: string[];
|
|
60
|
+
/** Types by namespace */
|
|
61
|
+
typesByNamespace: Record<string, string[]>;
|
|
62
|
+
/** Server version/info */
|
|
63
|
+
serverInfo?: {
|
|
64
|
+
version?: string;
|
|
65
|
+
capabilities?: string[];
|
|
66
|
+
};
|
|
62
67
|
}
|
|
63
68
|
/**
|
|
64
|
-
*
|
|
69
|
+
* Options for useSchema hook
|
|
65
70
|
*/
|
|
66
|
-
interface
|
|
67
|
-
/**
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
|
|
75
|
-
/** The query key used for cache management */
|
|
76
|
-
queryKey: readonly unknown[];
|
|
77
|
-
/** True if refetching in the background */
|
|
78
|
-
isRefetching: boolean;
|
|
79
|
-
/** True if any fetch is in progress */
|
|
80
|
-
isFetching: boolean;
|
|
81
|
-
/** Query status: 'pending', 'success', or 'error' */
|
|
82
|
-
status: 'pending' | 'success' | 'error';
|
|
71
|
+
interface UseSchemaOptions {
|
|
72
|
+
/** Filter by namespace */
|
|
73
|
+
ns?: string;
|
|
74
|
+
/** Filter by type name */
|
|
75
|
+
type?: string;
|
|
76
|
+
/** Whether to include system schemas */
|
|
77
|
+
includeSystem?: boolean;
|
|
78
|
+
/** Enable/disable the query */
|
|
79
|
+
enabled?: boolean;
|
|
83
80
|
}
|
|
84
81
|
/**
|
|
85
|
-
*
|
|
82
|
+
* Result from useSchema hook
|
|
86
83
|
*/
|
|
87
|
-
interface
|
|
88
|
-
/**
|
|
89
|
-
data:
|
|
90
|
-
/**
|
|
84
|
+
interface UseSchemaResult {
|
|
85
|
+
/** Schema discovery result */
|
|
86
|
+
data: SchemaDiscoveryResult | null;
|
|
87
|
+
/** Loading state */
|
|
91
88
|
isLoading: boolean;
|
|
92
|
-
/** Error
|
|
89
|
+
/** Error if any */
|
|
93
90
|
error: Error | null;
|
|
94
|
-
/**
|
|
95
|
-
refetch: () => Promise<
|
|
96
|
-
/**
|
|
97
|
-
queryKey: readonly unknown[];
|
|
98
|
-
/** True if refetching in the background */
|
|
91
|
+
/** Refetch function */
|
|
92
|
+
refetch: () => Promise<unknown>;
|
|
93
|
+
/** Whether data is being refetched */
|
|
99
94
|
isRefetching: boolean;
|
|
100
|
-
/** True if any fetch is in progress */
|
|
101
|
-
isFetching: boolean;
|
|
102
|
-
/** Query status: 'pending', 'success', or 'error' */
|
|
103
|
-
status: 'pending' | 'success' | 'error';
|
|
104
95
|
}
|
|
96
|
+
declare const schemaKeys: {
|
|
97
|
+
all: readonly ["schema"];
|
|
98
|
+
discovery: (ns?: string) => readonly ["schema", "discovery", string];
|
|
99
|
+
definition: (ns: string, type: string) => readonly ["schema", "definition", string, string];
|
|
100
|
+
};
|
|
105
101
|
/**
|
|
106
|
-
*
|
|
102
|
+
* Hook to discover schemas from the DO backend
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```tsx
|
|
106
|
+
* function SchemaExplorer() {
|
|
107
|
+
* const { data, isLoading } = useSchema()
|
|
108
|
+
*
|
|
109
|
+
* if (isLoading) return <div>Loading schemas...</div>
|
|
110
|
+
*
|
|
111
|
+
* return (
|
|
112
|
+
* <ul>
|
|
113
|
+
* {data?.schemas.map(schema => (
|
|
114
|
+
* <li key={schema.name}>{schema.name}</li>
|
|
115
|
+
* ))}
|
|
116
|
+
* </ul>
|
|
117
|
+
* )
|
|
118
|
+
* }
|
|
119
|
+
* ```
|
|
107
120
|
*/
|
|
108
|
-
|
|
109
|
-
/** Trigger the mutation */
|
|
110
|
-
mutate: (input: ThingCreateInput) => void;
|
|
111
|
-
/** Trigger the mutation and return a promise */
|
|
112
|
-
mutateAsync: (input: ThingCreateInput) => Promise<Thing>;
|
|
113
|
-
/** True while mutation is in progress */
|
|
114
|
-
isLoading: boolean;
|
|
115
|
-
/** Error from the mutation, or null */
|
|
116
|
-
error: Error | null;
|
|
117
|
-
/** True if the mutation succeeded */
|
|
118
|
-
isSuccess: boolean;
|
|
119
|
-
/** Reset the mutation state */
|
|
120
|
-
reset: () => void;
|
|
121
|
-
}
|
|
121
|
+
declare function useSchema(options?: UseSchemaOptions): UseSchemaResult;
|
|
122
122
|
/**
|
|
123
|
-
*
|
|
123
|
+
* Hook to get a specific schema definition
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```tsx
|
|
127
|
+
* function SchemaViewer({ ns, type }: { ns: string; type: string }) {
|
|
128
|
+
* const { data, isLoading } = useSchemaDefinition(ns, type)
|
|
129
|
+
*
|
|
130
|
+
* if (isLoading) return <div>Loading...</div>
|
|
131
|
+
*
|
|
132
|
+
* return (
|
|
133
|
+
* <pre>{JSON.stringify(data, null, 2)}</pre>
|
|
134
|
+
* )
|
|
135
|
+
* }
|
|
136
|
+
* ```
|
|
124
137
|
*/
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
mutateAsync: (input: ThingUpdateInput) => Promise<Thing>;
|
|
130
|
-
/** True while mutation is in progress */
|
|
138
|
+
declare function useSchemaDefinition(ns: string, type: string, options?: {
|
|
139
|
+
enabled?: boolean;
|
|
140
|
+
}): {
|
|
141
|
+
data: SchemaDefinition | null;
|
|
131
142
|
isLoading: boolean;
|
|
132
|
-
/** Error from the mutation, or null */
|
|
133
143
|
error: Error | null;
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
reset: () => void;
|
|
138
|
-
}
|
|
144
|
+
refetch: () => Promise<unknown>;
|
|
145
|
+
};
|
|
146
|
+
|
|
139
147
|
/**
|
|
140
|
-
* Options for
|
|
148
|
+
* Options for useNamespaces hook
|
|
141
149
|
*/
|
|
142
|
-
interface
|
|
143
|
-
/**
|
|
144
|
-
|
|
150
|
+
interface UseNamespacesOptions {
|
|
151
|
+
/** Include hidden/system namespaces */
|
|
152
|
+
includeSystem?: boolean;
|
|
153
|
+
/** Enable/disable the query */
|
|
154
|
+
enabled?: boolean;
|
|
145
155
|
}
|
|
146
156
|
/**
|
|
147
|
-
*
|
|
157
|
+
* Result from useNamespaces hook
|
|
148
158
|
*/
|
|
149
|
-
interface
|
|
150
|
-
/**
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
mutateAsync: (options?: DeleteThingOptions) => Promise<void>;
|
|
154
|
-
/** True while mutation is in progress */
|
|
159
|
+
interface UseNamespacesResult {
|
|
160
|
+
/** List of namespaces */
|
|
161
|
+
data: Namespace[] | null;
|
|
162
|
+
/** Loading state */
|
|
155
163
|
isLoading: boolean;
|
|
156
|
-
/** Error
|
|
164
|
+
/** Error if any */
|
|
157
165
|
error: Error | null;
|
|
158
|
-
/**
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
|
|
166
|
+
/** Refetch function */
|
|
167
|
+
refetch: () => Promise<unknown>;
|
|
168
|
+
/** Whether data is being refetched */
|
|
169
|
+
isRefetching: boolean;
|
|
170
|
+
/** Query status */
|
|
171
|
+
status: 'pending' | 'error' | 'success';
|
|
162
172
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
* Uses two modes:
|
|
168
|
-
* - **TanStack DB mode**: Real-time sync via @dotdo/react useCollection
|
|
169
|
-
* - **REST/RPC mode**: React Query for caching with fetch or RPC calls
|
|
170
|
-
*/
|
|
171
|
-
declare function useThings(filter?: ThingFilter, sort?: ThingSort, pagination?: ThingPagination): UseThingsResult;
|
|
172
|
-
/**
|
|
173
|
-
* Hook to fetch a single Thing
|
|
174
|
-
*
|
|
175
|
-
* Uses the useRPCClient hook for RPC calls instead of inline fetch,
|
|
176
|
-
* demonstrating the pattern for utilizing extracted utilities.
|
|
177
|
-
*/
|
|
178
|
-
declare function useThing(ns: string, type: string, id: string): UseThingResult;
|
|
179
|
-
/**
|
|
180
|
-
* Hook to fetch Thing version history
|
|
181
|
-
*/
|
|
182
|
-
declare function useThingVersions(ns: string, type: string, id: string): UseThingVersionsResult;
|
|
183
|
-
/**
|
|
184
|
-
* Hook to fetch type statistics
|
|
185
|
-
*/
|
|
186
|
-
declare function useTypeStats(ns: string, type: string): UseTypeStatsResult;
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Hook to create a Thing
|
|
190
|
-
*
|
|
191
|
-
* Automatically invalidates the things list cache on success.
|
|
192
|
-
*
|
|
193
|
-
* Supports three modes:
|
|
194
|
-
* 1. **DataProvider mode**: Uses DataProvider.create() when available (via DoDataProviderProvider)
|
|
195
|
-
* 2. **TanStack DB mode**: Uses RPC when doUrl is configured
|
|
196
|
-
* 3. **REST API mode**: Falls back to fetch-based API calls
|
|
197
|
-
*/
|
|
198
|
-
declare function useCreateThing(): UseCreateThingResult;
|
|
199
|
-
/**
|
|
200
|
-
* Hook to update a Thing
|
|
201
|
-
*
|
|
202
|
-
* Automatically invalidates the related cache entries on success.
|
|
203
|
-
*
|
|
204
|
-
* Supports three modes:
|
|
205
|
-
* 1. **DataProvider mode**: Uses DataProvider.update() when available (via DoDataProviderProvider)
|
|
206
|
-
* 2. **TanStack DB mode**: Uses RPC when doUrl is configured
|
|
207
|
-
* 3. **REST API mode**: Falls back to fetch-based API calls
|
|
208
|
-
*/
|
|
209
|
-
declare function useUpdateThing(ns: string, type: string, id: string): UseUpdateThingResult;
|
|
173
|
+
declare const namespacesKeys: {
|
|
174
|
+
all: readonly ["namespaces"];
|
|
175
|
+
list: (includeSystem?: boolean) => readonly ["namespaces", "list", boolean];
|
|
176
|
+
};
|
|
210
177
|
/**
|
|
211
|
-
* Hook to
|
|
178
|
+
* Hook to fetch available namespaces
|
|
212
179
|
*
|
|
213
|
-
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```tsx
|
|
182
|
+
* function NamespaceSelector() {
|
|
183
|
+
* const { data: namespaces, isLoading } = useNamespaces()
|
|
214
184
|
*
|
|
215
|
-
*
|
|
216
|
-
* 1. **DataProvider mode**: Uses DataProvider.delete() when available (via DoDataProviderProvider)
|
|
217
|
-
* 2. **TanStack DB mode**: Uses RPC when doUrl is configured
|
|
218
|
-
* 3. **REST API mode**: Falls back to fetch-based API calls
|
|
185
|
+
* if (isLoading) return <div>Loading namespaces...</div>
|
|
219
186
|
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
187
|
+
* return (
|
|
188
|
+
* <select>
|
|
189
|
+
* {namespaces?.map(ns => (
|
|
190
|
+
* <option key={ns.id} value={ns.name}>
|
|
191
|
+
* {ns.name}
|
|
192
|
+
* </option>
|
|
193
|
+
* ))}
|
|
194
|
+
* </select>
|
|
195
|
+
* )
|
|
196
|
+
* }
|
|
197
|
+
* ```
|
|
222
198
|
*/
|
|
223
|
-
declare function
|
|
199
|
+
declare function useNamespaces(options?: UseNamespacesOptions): UseNamespacesResult;
|
|
224
200
|
|
|
225
201
|
/**
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
* Things have a special key structure because:
|
|
229
|
-
* - List queries include filter, sort, and pagination
|
|
230
|
-
* - Detail queries use composite keys (ns, type, id) instead of a single id
|
|
231
|
-
* - Additional sub-queries for versions and type stats
|
|
202
|
+
* Options for useTypes hook
|
|
232
203
|
*/
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
nameSearch: zod.ZodOptional<zod.ZodString>;
|
|
242
|
-
createdAfter: zod.ZodOptional<zod.ZodDate>;
|
|
243
|
-
createdBefore: zod.ZodOptional<zod.ZodDate>;
|
|
244
|
-
updatedAfter: zod.ZodOptional<zod.ZodDate>;
|
|
245
|
-
updatedBefore: zod.ZodOptional<zod.ZodDate>;
|
|
246
|
-
includeDeleted: zod.ZodOptional<zod.ZodBoolean>;
|
|
247
|
-
properties: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
|
|
248
|
-
variant: zod.ZodOptional<zod.ZodString>;
|
|
249
|
-
}, zod.ZodTypeAny, "passthrough">;
|
|
250
|
-
readonly sort: {
|
|
251
|
-
field: "type" | "name" | "ts" | "createdAt" | "updatedAt";
|
|
252
|
-
order: "asc" | "desc";
|
|
253
|
-
} | undefined;
|
|
254
|
-
readonly pagination: {
|
|
255
|
-
page: number;
|
|
256
|
-
perPage: number;
|
|
257
|
-
} | undefined;
|
|
258
|
-
}];
|
|
259
|
-
details: () => readonly ["things", "detail"];
|
|
260
|
-
detail: (ns: string, type: string, id: string) => readonly ["things", "detail", string, string, string];
|
|
261
|
-
versions: (ns: string, type: string, id: string) => readonly ["things", "detail", string, string, string, "versions"];
|
|
262
|
-
types: () => readonly ["things", "types"];
|
|
263
|
-
typeStats: (ns: string, type: string) => readonly ["things", "types", string, string];
|
|
264
|
-
};
|
|
204
|
+
interface UseTypesOptions {
|
|
205
|
+
/** Namespace to fetch types from (defaults to current namespace) */
|
|
206
|
+
ns?: string;
|
|
207
|
+
/** Include hidden/system types */
|
|
208
|
+
includeSystem?: boolean;
|
|
209
|
+
/** Enable/disable the query */
|
|
210
|
+
enabled?: boolean;
|
|
211
|
+
}
|
|
265
212
|
/**
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
* Includes keys for:
|
|
269
|
-
* - Agent lists and details
|
|
270
|
-
* - Agent metrics (per-agent)
|
|
271
|
-
* - Agent executions (list and detail)
|
|
213
|
+
* Result from useTypes hook
|
|
272
214
|
*/
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
215
|
+
interface UseTypesResult {
|
|
216
|
+
/** List of types */
|
|
217
|
+
data: SemanticType[] | null;
|
|
218
|
+
/** Loading state */
|
|
219
|
+
isLoading: boolean;
|
|
220
|
+
/** Error if any */
|
|
221
|
+
error: Error | null;
|
|
222
|
+
/** Refetch function */
|
|
223
|
+
refetch: () => Promise<unknown>;
|
|
224
|
+
/** Whether data is being refetched */
|
|
225
|
+
isRefetching: boolean;
|
|
226
|
+
/** Query status */
|
|
227
|
+
status: 'pending' | 'error' | 'success';
|
|
228
|
+
}
|
|
229
|
+
declare const typesKeys: {
|
|
230
|
+
all: readonly ["types"];
|
|
231
|
+
list: (ns: string, includeSystem?: boolean) => readonly ["types", "list", string, boolean];
|
|
283
232
|
};
|
|
284
233
|
/**
|
|
285
|
-
*
|
|
234
|
+
* Hook to fetch available types within a namespace
|
|
286
235
|
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
*
|
|
290
|
-
|
|
291
|
-
declare const workflowsKeys: {
|
|
292
|
-
all: readonly ["workflows"];
|
|
293
|
-
lists: () => readonly ["workflows", "list"];
|
|
294
|
-
list: (filter: WorkflowFilter) => readonly ["workflows", "list", WorkflowFilter];
|
|
295
|
-
details: () => readonly ["workflows", "detail"];
|
|
296
|
-
detail: (id: string) => readonly ["workflows", "detail", string];
|
|
297
|
-
executions: () => readonly ["workflows", "executions"];
|
|
298
|
-
executionsList: (filter: ExecutionFilter) => readonly ["workflows", "executions", "list", ExecutionFilter];
|
|
299
|
-
execution: (id: string) => readonly ["workflows", "executions", "detail", string];
|
|
300
|
-
};
|
|
301
|
-
/**
|
|
302
|
-
* Query keys for Relationships resource
|
|
236
|
+
* @example
|
|
237
|
+
* ```tsx
|
|
238
|
+
* function TypeSelector({ ns }: { ns: string }) {
|
|
239
|
+
* const { data: types, isLoading } = useTypes({ ns })
|
|
303
240
|
*
|
|
304
|
-
*
|
|
305
|
-
*
|
|
306
|
-
*
|
|
307
|
-
*
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
type: string;
|
|
318
|
-
ns: string;
|
|
319
|
-
id: string;
|
|
320
|
-
semanticId: string;
|
|
321
|
-
name?: string | undefined;
|
|
322
|
-
}, GraphPattern];
|
|
323
|
-
stats: () => readonly ["relationships", "stats"];
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
* Return type for useRelationships hook
|
|
328
|
-
*/
|
|
329
|
-
type UseRelationshipsResult = UseQueryResult<Relationship[], Error>;
|
|
330
|
-
/**
|
|
331
|
-
* Result type for entity relationships containing both directions
|
|
332
|
-
*/
|
|
333
|
-
interface EntityRelationshipsData {
|
|
334
|
-
outgoing: Relationship[];
|
|
335
|
-
incoming: Relationship[];
|
|
336
|
-
}
|
|
337
|
-
/**
|
|
338
|
-
* Return type for useEntityRelationships hook
|
|
339
|
-
*/
|
|
340
|
-
type UseEntityRelationshipsResult = UseQueryResult<EntityRelationshipsData, Error>;
|
|
341
|
-
/**
|
|
342
|
-
* Return type for useGraphTraversal hook
|
|
343
|
-
*/
|
|
344
|
-
type UseGraphTraversalResult = UseQueryResult<GraphTraversalResult, Error>;
|
|
345
|
-
/**
|
|
346
|
-
* Return type for useGraphStats hook
|
|
347
|
-
*/
|
|
348
|
-
type UseGraphStatsResult = UseQueryResult<GraphStats, Error>;
|
|
349
|
-
/**
|
|
350
|
-
* Return type for useCreateRelationship hook
|
|
351
|
-
*/
|
|
352
|
-
type UseCreateRelationshipResult = UseMutationResult<Relationship, Error, RelationshipCreateInput>;
|
|
353
|
-
/**
|
|
354
|
-
* Return type for useDeleteRelationship hook
|
|
355
|
-
*/
|
|
356
|
-
type UseDeleteRelationshipResult = UseMutationResult<void, Error, string>;
|
|
357
|
-
|
|
358
|
-
/**
|
|
359
|
-
* Hook to fetch relationships
|
|
360
|
-
*/
|
|
361
|
-
declare function useRelationships(filter?: RelationshipFilter): UseRelationshipsResult;
|
|
362
|
-
/**
|
|
363
|
-
* Hook to fetch relationships for a specific entity
|
|
364
|
-
*/
|
|
365
|
-
declare function useEntityRelationships(entity: EntityReference, direction?: 'outgoing' | 'incoming' | 'both'): UseEntityRelationshipsResult;
|
|
366
|
-
/**
|
|
367
|
-
* Hook to traverse the graph from a starting entity
|
|
368
|
-
*/
|
|
369
|
-
declare function useGraphTraversal(entity: EntityReference, pattern: GraphPattern): UseGraphTraversalResult;
|
|
370
|
-
/**
|
|
371
|
-
* Hook to get graph statistics
|
|
372
|
-
*/
|
|
373
|
-
declare function useGraphStats(): UseGraphStatsResult;
|
|
374
|
-
/**
|
|
375
|
-
* Hook to create a relationship
|
|
376
|
-
*/
|
|
377
|
-
declare function useCreateRelationship(): UseCreateRelationshipResult;
|
|
378
|
-
/**
|
|
379
|
-
* Hook to delete a relationship
|
|
380
|
-
*/
|
|
381
|
-
declare function useDeleteRelationship(): UseDeleteRelationshipResult;
|
|
382
|
-
|
|
383
|
-
/**
|
|
384
|
-
* Return type for useWorkflows hook
|
|
385
|
-
*/
|
|
386
|
-
type UseWorkflowsResult = UseQueryResult<PaginatedResult<Workflow>, Error>;
|
|
387
|
-
/**
|
|
388
|
-
* Return type for useWorkflow hook
|
|
389
|
-
*/
|
|
390
|
-
type UseWorkflowResult = UseQueryResult<Workflow, Error>;
|
|
391
|
-
/**
|
|
392
|
-
* Return type for useWorkflowExecutions hook
|
|
393
|
-
*/
|
|
394
|
-
type UseWorkflowExecutionsResult = UseQueryResult<PaginatedResult<WorkflowExecution>, Error>;
|
|
395
|
-
/**
|
|
396
|
-
* Return type for useWorkflowExecution hook
|
|
397
|
-
*/
|
|
398
|
-
type UseWorkflowExecutionResult = UseQueryResult<WorkflowExecution, Error>;
|
|
399
|
-
/**
|
|
400
|
-
* Return type for useCreateWorkflow hook
|
|
401
|
-
*/
|
|
402
|
-
type UseCreateWorkflowResult = UseMutationResult<Workflow, Error, Partial<Workflow>>;
|
|
403
|
-
/**
|
|
404
|
-
* Return type for useUpdateWorkflow hook
|
|
405
|
-
*/
|
|
406
|
-
type UseUpdateWorkflowResult = UseMutationResult<Workflow, Error, Partial<Workflow>>;
|
|
407
|
-
/**
|
|
408
|
-
* Return type for useTriggerWorkflow hook
|
|
409
|
-
*/
|
|
410
|
-
type UseTriggerWorkflowResult = UseMutationResult<WorkflowExecution, Error, Record<string, unknown> | undefined>;
|
|
411
|
-
/**
|
|
412
|
-
* Return type for useCancelExecution hook
|
|
413
|
-
*/
|
|
414
|
-
type UseCancelExecutionResult = UseMutationResult<void, Error, string>;
|
|
415
|
-
/**
|
|
416
|
-
* Return type for useDeleteWorkflow hook
|
|
417
|
-
*/
|
|
418
|
-
type UseDeleteWorkflowResult = UseMutationResult<void, Error, string>;
|
|
419
|
-
|
|
420
|
-
/**
|
|
421
|
-
* Hook to fetch workflows
|
|
422
|
-
*/
|
|
423
|
-
declare function useWorkflows(filter?: WorkflowFilter): UseWorkflowsResult;
|
|
424
|
-
/**
|
|
425
|
-
* Hook to fetch a single workflow
|
|
426
|
-
*/
|
|
427
|
-
declare function useWorkflow(id: string): UseWorkflowResult;
|
|
428
|
-
/**
|
|
429
|
-
* Hook to fetch workflow executions
|
|
430
|
-
*/
|
|
431
|
-
declare function useWorkflowExecutions(filter?: ExecutionFilter): UseWorkflowExecutionsResult;
|
|
432
|
-
/**
|
|
433
|
-
* Hook to fetch a single execution
|
|
434
|
-
*/
|
|
435
|
-
declare function useWorkflowExecution(id: string): UseWorkflowExecutionResult;
|
|
436
|
-
/**
|
|
437
|
-
* Hook to create a workflow
|
|
438
|
-
*/
|
|
439
|
-
declare function useCreateWorkflow(): UseCreateWorkflowResult;
|
|
440
|
-
/**
|
|
441
|
-
* Hook to update a workflow
|
|
442
|
-
*/
|
|
443
|
-
declare function useUpdateWorkflow(id: string): UseUpdateWorkflowResult;
|
|
444
|
-
/**
|
|
445
|
-
* Hook to trigger a workflow manually
|
|
446
|
-
*/
|
|
447
|
-
declare function useTriggerWorkflow(id: string): UseTriggerWorkflowResult;
|
|
448
|
-
/**
|
|
449
|
-
* Hook to cancel a workflow execution
|
|
450
|
-
*/
|
|
451
|
-
declare function useCancelExecution(): UseCancelExecutionResult;
|
|
452
|
-
/**
|
|
453
|
-
* Hook to delete a workflow
|
|
241
|
+
* if (isLoading) return <div>Loading types...</div>
|
|
242
|
+
*
|
|
243
|
+
* return (
|
|
244
|
+
* <select>
|
|
245
|
+
* {types?.map(type => (
|
|
246
|
+
* <option key={type.id} value={type.name}>
|
|
247
|
+
* {type.label}
|
|
248
|
+
* </option>
|
|
249
|
+
* ))}
|
|
250
|
+
* </select>
|
|
251
|
+
* )
|
|
252
|
+
* }
|
|
253
|
+
* ```
|
|
454
254
|
*/
|
|
455
|
-
declare function
|
|
255
|
+
declare function useTypes(options?: UseTypesOptions): UseTypesResult;
|
|
456
256
|
|
|
457
257
|
/**
|
|
458
|
-
*
|
|
459
|
-
*/
|
|
460
|
-
type UseAgentsResult = UseQueryResult<PaginatedResult<Agent>, Error>;
|
|
461
|
-
/**
|
|
462
|
-
* Return type for useAgent hook
|
|
463
|
-
*/
|
|
464
|
-
type UseAgentResult = UseQueryResult<Agent, Error>;
|
|
465
|
-
/**
|
|
466
|
-
* Return type for useAgentMetrics hook
|
|
467
|
-
*/
|
|
468
|
-
type UseAgentMetricsResult = UseQueryResult<AgentMetrics, Error>;
|
|
469
|
-
/**
|
|
470
|
-
* Return type for useAgentExecutions hook
|
|
471
|
-
*/
|
|
472
|
-
type UseAgentExecutionsResult = UseQueryResult<PaginatedResult<AgentExecution>, Error>;
|
|
473
|
-
/**
|
|
474
|
-
* Return type for useAgentExecution hook
|
|
475
|
-
*/
|
|
476
|
-
type UseAgentExecutionResult = UseQueryResult<AgentExecution, Error>;
|
|
477
|
-
/**
|
|
478
|
-
* Return type for useCreateAgent hook
|
|
479
|
-
*/
|
|
480
|
-
type UseCreateAgentResult = UseMutationResult<Agent, Error, Partial<Agent>>;
|
|
481
|
-
/**
|
|
482
|
-
* Return type for useUpdateAgent hook
|
|
258
|
+
* Subscription event types
|
|
483
259
|
*/
|
|
484
|
-
type
|
|
260
|
+
type SubscriptionEventType = 'created' | 'updated' | 'deleted' | 'connected' | 'disconnected' | 'error';
|
|
485
261
|
/**
|
|
486
|
-
*
|
|
262
|
+
* Subscription event payload
|
|
487
263
|
*/
|
|
488
|
-
interface
|
|
489
|
-
|
|
490
|
-
|
|
264
|
+
interface SubscriptionEvent {
|
|
265
|
+
/** Event type */
|
|
266
|
+
type: SubscriptionEventType;
|
|
267
|
+
/** Affected Thing (for created/updated/deleted) */
|
|
268
|
+
thing?: Thing;
|
|
269
|
+
/** Thing ID (for deleted events) */
|
|
270
|
+
thingId?: string;
|
|
271
|
+
/** Error message (for error events) */
|
|
272
|
+
error?: string;
|
|
273
|
+
/** Timestamp */
|
|
274
|
+
timestamp: Date;
|
|
491
275
|
}
|
|
492
276
|
/**
|
|
493
|
-
*
|
|
494
|
-
*/
|
|
495
|
-
type UseExecuteAgentResult = UseMutationResult<AgentExecution, Error, ExecuteAgentInput>;
|
|
496
|
-
/**
|
|
497
|
-
* Input type for useSubmitAgentFeedback mutation
|
|
498
|
-
*/
|
|
499
|
-
type SubmitAgentFeedbackInput = Omit<AgentFeedback, 'submittedAt' | 'submittedBy'>;
|
|
500
|
-
/**
|
|
501
|
-
* Return type for useSubmitAgentFeedback hook
|
|
502
|
-
*/
|
|
503
|
-
type UseSubmitAgentFeedbackResult = UseMutationResult<void, Error, SubmitAgentFeedbackInput>;
|
|
504
|
-
/**
|
|
505
|
-
* Return type for useDeleteAgent hook
|
|
506
|
-
*/
|
|
507
|
-
type UseDeleteAgentResult = UseMutationResult<void, Error, string>;
|
|
508
|
-
|
|
509
|
-
/**
|
|
510
|
-
* Hook to fetch agents
|
|
511
|
-
*/
|
|
512
|
-
declare function useAgents(filter?: AgentFilter): UseAgentsResult;
|
|
513
|
-
/**
|
|
514
|
-
* Hook to fetch a single agent
|
|
515
|
-
*/
|
|
516
|
-
declare function useAgent(id: string): UseAgentResult;
|
|
517
|
-
/**
|
|
518
|
-
* Hook to fetch agent metrics
|
|
519
|
-
*/
|
|
520
|
-
declare function useAgentMetrics(id: string, periodDays?: number): UseAgentMetricsResult;
|
|
521
|
-
/**
|
|
522
|
-
* Hook to fetch agent executions
|
|
277
|
+
* Subscription state
|
|
523
278
|
*/
|
|
524
|
-
|
|
279
|
+
type SubscriptionState = 'connecting' | 'connected' | 'disconnected' | 'error';
|
|
525
280
|
/**
|
|
526
|
-
*
|
|
281
|
+
* Options for useThingSubscription hook
|
|
527
282
|
*/
|
|
528
|
-
|
|
529
|
-
/**
|
|
530
|
-
* Hook to create an agent
|
|
531
|
-
*/
|
|
532
|
-
declare function useCreateAgent(): UseCreateAgentResult;
|
|
533
|
-
/**
|
|
534
|
-
* Hook to update an agent
|
|
535
|
-
*/
|
|
536
|
-
declare function useUpdateAgent(id: string): UseUpdateAgentResult;
|
|
537
|
-
/**
|
|
538
|
-
* Hook to execute an agent
|
|
539
|
-
*/
|
|
540
|
-
declare function useExecuteAgent(id: string): UseExecuteAgentResult;
|
|
541
|
-
/**
|
|
542
|
-
* Hook to submit feedback for an agent execution
|
|
543
|
-
*/
|
|
544
|
-
declare function useSubmitAgentFeedback(executionId: string): UseSubmitAgentFeedbackResult;
|
|
545
|
-
/**
|
|
546
|
-
* Hook to delete an agent
|
|
547
|
-
*/
|
|
548
|
-
declare function useDeleteAgent(): UseDeleteAgentResult;
|
|
549
|
-
|
|
550
|
-
/**
|
|
551
|
-
* DO Provider
|
|
552
|
-
*
|
|
553
|
-
* Combined provider that wraps both @mdxui/admin AdminProvider
|
|
554
|
-
* and @dotdo/react AdminProvider for Durable Objects integration.
|
|
555
|
-
*
|
|
556
|
-
* @module @mdxui/do/hooks/dotdo
|
|
557
|
-
*/
|
|
558
|
-
|
|
559
|
-
/**
|
|
560
|
-
* Configuration for DO provider
|
|
561
|
-
*/
|
|
562
|
-
interface DOProps {
|
|
563
|
-
/** Child components */
|
|
564
|
-
children: React.ReactNode;
|
|
565
|
-
/**
|
|
566
|
-
* Durable Object namespace URL.
|
|
567
|
-
* If provided, creates a DotdoDataProvider automatically.
|
|
568
|
-
* @example 'https://api.example.com.ai/do/workspace'
|
|
569
|
-
*/
|
|
283
|
+
interface UseThingSubscriptionOptions {
|
|
284
|
+
/** Namespace to subscribe to */
|
|
570
285
|
ns?: string;
|
|
571
|
-
/**
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
/**
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
/**
|
|
592
|
-
* Base path for admin routes.
|
|
593
|
-
* @default ''
|
|
594
|
-
*/
|
|
595
|
-
basename?: string;
|
|
596
|
-
/**
|
|
597
|
-
* Admin application title.
|
|
598
|
-
* @default 'Admin'
|
|
599
|
-
*/
|
|
600
|
-
title?: string;
|
|
601
|
-
/**
|
|
602
|
-
* Logo element for the admin UI.
|
|
603
|
-
*/
|
|
604
|
-
logo?: React.ReactNode;
|
|
286
|
+
/** Type to subscribe to (optional, subscribes to all if not specified) */
|
|
287
|
+
type?: string;
|
|
288
|
+
/** Specific Thing ID to subscribe to */
|
|
289
|
+
id?: string;
|
|
290
|
+
/** Filter for subscription */
|
|
291
|
+
filter?: ThingFilter;
|
|
292
|
+
/** Callback when a Thing is created */
|
|
293
|
+
onCreated?: (thing: Thing) => void;
|
|
294
|
+
/** Callback when a Thing is updated */
|
|
295
|
+
onUpdated?: (thing: Thing) => void;
|
|
296
|
+
/** Callback when a Thing is deleted */
|
|
297
|
+
onDeleted?: (thingId: string) => void;
|
|
298
|
+
/** Callback for any event */
|
|
299
|
+
onEvent?: (event: SubscriptionEvent) => void;
|
|
300
|
+
/** Callback for connection state changes */
|
|
301
|
+
onStateChange?: (state: SubscriptionState) => void;
|
|
302
|
+
/** Enable/disable subscription */
|
|
303
|
+
enabled?: boolean;
|
|
304
|
+
/** Auto-invalidate React Query cache on updates */
|
|
305
|
+
invalidateOnUpdate?: boolean;
|
|
605
306
|
}
|
|
606
307
|
/**
|
|
607
|
-
*
|
|
308
|
+
* Result from useThingSubscription hook
|
|
608
309
|
*/
|
|
609
|
-
interface
|
|
610
|
-
/**
|
|
611
|
-
|
|
612
|
-
/**
|
|
613
|
-
|
|
614
|
-
/**
|
|
615
|
-
|
|
310
|
+
interface UseThingSubscriptionResult {
|
|
311
|
+
/** Current subscription state */
|
|
312
|
+
state: SubscriptionState;
|
|
313
|
+
/** Recent events (limited buffer) */
|
|
314
|
+
events: SubscriptionEvent[];
|
|
315
|
+
/** Whether currently connected */
|
|
316
|
+
isConnected: boolean;
|
|
317
|
+
/** Last error if any */
|
|
318
|
+
error: Error | null;
|
|
319
|
+
/** Manually reconnect */
|
|
320
|
+
reconnect: () => void;
|
|
321
|
+
/** Disconnect */
|
|
322
|
+
disconnect: () => void;
|
|
616
323
|
}
|
|
617
324
|
/**
|
|
618
|
-
*
|
|
325
|
+
* Hook for real-time Thing subscriptions
|
|
619
326
|
*
|
|
620
|
-
*
|
|
621
|
-
*
|
|
327
|
+
* Subscribes to changes on Things and provides real-time updates.
|
|
328
|
+
* Automatically invalidates React Query cache when data changes.
|
|
622
329
|
*
|
|
623
|
-
* @example
|
|
330
|
+
* @example Subscribe to all Things of a type
|
|
624
331
|
* ```tsx
|
|
625
|
-
*
|
|
332
|
+
* function TaskList() {
|
|
333
|
+
* const { state, events } = useThingSubscription({
|
|
334
|
+
* type: 'Task',
|
|
335
|
+
* onCreated: (task) => console.log('New task:', task),
|
|
336
|
+
* onUpdated: (task) => console.log('Task updated:', task),
|
|
337
|
+
* })
|
|
626
338
|
*
|
|
627
|
-
* function App() {
|
|
628
339
|
* return (
|
|
629
|
-
* <
|
|
630
|
-
*
|
|
631
|
-
*
|
|
632
|
-
*
|
|
633
|
-
* >
|
|
634
|
-
* <Resource name="users" list={UserList} edit={UserEdit} />
|
|
635
|
-
* <Resource name="posts" list={PostList} create={PostCreate} />
|
|
636
|
-
* </DO>
|
|
340
|
+
* <div>
|
|
341
|
+
* <div>Status: {state}</div>
|
|
342
|
+
* <div>Recent events: {events.length}</div>
|
|
343
|
+
* </div>
|
|
637
344
|
* )
|
|
638
345
|
* }
|
|
639
346
|
* ```
|
|
640
347
|
*
|
|
641
|
-
* @example
|
|
348
|
+
* @example Subscribe to a specific Thing
|
|
642
349
|
* ```tsx
|
|
643
|
-
*
|
|
644
|
-
*
|
|
645
|
-
*
|
|
646
|
-
*
|
|
647
|
-
*
|
|
648
|
-
* ns: 'https://api.example.com.ai/do/workspace',
|
|
649
|
-
* headers: { Authorization: 'Bearer token' },
|
|
650
|
-
* timeout: 60000,
|
|
350
|
+
* function TaskDetail({ id }: { id: string }) {
|
|
351
|
+
* useThingSubscription({
|
|
352
|
+
* type: 'Task',
|
|
353
|
+
* id,
|
|
354
|
+
* onUpdated: (task) => console.log('Task updated:', task),
|
|
651
355
|
* })
|
|
652
356
|
*
|
|
653
|
-
*
|
|
654
|
-
* <DO dataProvider={dataProvider} title="My Admin">
|
|
655
|
-
* <AdminRoutes />
|
|
656
|
-
* </DO>
|
|
657
|
-
* )
|
|
357
|
+
* // ...
|
|
658
358
|
* }
|
|
659
359
|
* ```
|
|
660
360
|
*/
|
|
661
|
-
declare function
|
|
662
|
-
declare namespace DO {
|
|
663
|
-
var displayName: string;
|
|
664
|
-
}
|
|
361
|
+
declare function useThingSubscription(options?: UseThingSubscriptionOptions): UseThingSubscriptionResult;
|
|
665
362
|
/**
|
|
666
|
-
* Hook to
|
|
363
|
+
* Hook to subscribe to a single Thing's changes
|
|
667
364
|
*
|
|
668
|
-
*
|
|
365
|
+
* Convenience wrapper around useThingSubscription for single-Thing use cases.
|
|
669
366
|
*
|
|
670
367
|
* @example
|
|
671
368
|
* ```tsx
|
|
672
|
-
* function
|
|
673
|
-
* const {
|
|
674
|
-
*
|
|
675
|
-
*
|
|
676
|
-
*
|
|
677
|
-
*
|
|
369
|
+
* function TaskEditor({ ns, type, id }: ThingParams) {
|
|
370
|
+
* const { isConnected, lastUpdate } = useSingleThingSubscription({
|
|
371
|
+
* ns,
|
|
372
|
+
* type,
|
|
373
|
+
* id,
|
|
374
|
+
* onUpdated: (thing) => {
|
|
375
|
+
* // Handle optimistic update conflicts
|
|
376
|
+
* },
|
|
377
|
+
* })
|
|
678
378
|
*
|
|
679
|
-
* return
|
|
379
|
+
* return (
|
|
380
|
+
* <div>
|
|
381
|
+
* {isConnected && <Badge>Live</Badge>}
|
|
382
|
+
* {/* Editor UI *\/}
|
|
383
|
+
* </div>
|
|
384
|
+
* )
|
|
680
385
|
* }
|
|
681
386
|
* ```
|
|
682
387
|
*/
|
|
683
|
-
declare function
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
388
|
+
declare function useSingleThingSubscription(options: {
|
|
389
|
+
ns: string;
|
|
390
|
+
type: string;
|
|
391
|
+
id: string;
|
|
392
|
+
onUpdated?: (thing: Thing) => void;
|
|
393
|
+
onDeleted?: () => void;
|
|
394
|
+
enabled?: boolean;
|
|
395
|
+
}): {
|
|
396
|
+
isConnected: boolean;
|
|
397
|
+
lastUpdate: Date | null;
|
|
398
|
+
error: Error | null;
|
|
399
|
+
};
|
|
690
400
|
|
|
691
401
|
/**
|
|
692
|
-
*
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
402
|
+
* Represents a single edit operation that can be undone/redone
|
|
403
|
+
*/
|
|
404
|
+
interface EditOperation {
|
|
405
|
+
/** Type of operation */
|
|
406
|
+
type: 'cell_update';
|
|
407
|
+
/** Row index that was modified */
|
|
408
|
+
rowIndex: number;
|
|
409
|
+
/** Column ID that was modified */
|
|
410
|
+
columnId: string;
|
|
411
|
+
/** Value before the edit */
|
|
412
|
+
oldValue: unknown;
|
|
413
|
+
/** Value after the edit */
|
|
414
|
+
newValue: unknown;
|
|
415
|
+
/** Timestamp of the operation */
|
|
416
|
+
timestamp: number;
|
|
417
|
+
}
|
|
700
418
|
/**
|
|
701
|
-
*
|
|
702
|
-
* Records must have either $id (dotdo style) or id (standard style).
|
|
419
|
+
* Configuration for the edit history hook
|
|
703
420
|
*/
|
|
704
|
-
interface
|
|
705
|
-
/**
|
|
706
|
-
|
|
707
|
-
/**
|
|
708
|
-
|
|
709
|
-
/**
|
|
710
|
-
|
|
421
|
+
interface UseEditHistoryOptions {
|
|
422
|
+
/** Maximum number of operations to keep in history (default: 50) */
|
|
423
|
+
maxHistory?: number;
|
|
424
|
+
/** Callback when undo is triggered */
|
|
425
|
+
onUndo?: (operation: EditOperation) => void;
|
|
426
|
+
/** Callback when redo is triggered */
|
|
427
|
+
onRedo?: (operation: EditOperation) => void;
|
|
711
428
|
}
|
|
712
429
|
/**
|
|
713
|
-
*
|
|
430
|
+
* Return type for the edit history hook
|
|
431
|
+
*/
|
|
432
|
+
interface UseEditHistoryReturn {
|
|
433
|
+
/** Push a new edit operation to history */
|
|
434
|
+
pushOperation: (operation: Omit<EditOperation, 'timestamp'>) => void;
|
|
435
|
+
/** Undo the last operation */
|
|
436
|
+
undo: () => EditOperation | null;
|
|
437
|
+
/** Redo the last undone operation */
|
|
438
|
+
redo: () => EditOperation | null;
|
|
439
|
+
/** Whether undo is available */
|
|
440
|
+
canUndo: boolean;
|
|
441
|
+
/** Whether redo is available */
|
|
442
|
+
canRedo: boolean;
|
|
443
|
+
/** Number of operations that can be undone */
|
|
444
|
+
undoCount: number;
|
|
445
|
+
/** Number of operations that can be redone */
|
|
446
|
+
redoCount: number;
|
|
447
|
+
/** Clear all history */
|
|
448
|
+
clearHistory: () => void;
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Custom hook for managing edit history with undo/redo support
|
|
452
|
+
*
|
|
453
|
+
* This hook provides a dual-stack architecture for undo/redo operations,
|
|
454
|
+
* without keyboard shortcuts (use useKeyboardShortcuts separately).
|
|
714
455
|
*
|
|
715
|
-
*
|
|
716
|
-
*
|
|
456
|
+
* @example
|
|
457
|
+
* ```tsx
|
|
458
|
+
* const { pushOperation, undo, redo, canUndo, canRedo } = useEditHistory({
|
|
459
|
+
* onUndo: (op) => updateCell(op.rowIndex, op.columnId, op.oldValue),
|
|
460
|
+
* onRedo: (op) => updateCell(op.rowIndex, op.columnId, op.newValue),
|
|
461
|
+
* })
|
|
462
|
+
*
|
|
463
|
+
* // When a cell is edited:
|
|
464
|
+
* pushOperation({
|
|
465
|
+
* type: 'cell_update',
|
|
466
|
+
* rowIndex: 0,
|
|
467
|
+
* columnId: 'name',
|
|
468
|
+
* oldValue: 'John',
|
|
469
|
+
* newValue: 'Jane',
|
|
470
|
+
* })
|
|
471
|
+
* ```
|
|
717
472
|
*/
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
/**
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
473
|
+
declare function useEditHistory(options?: UseEditHistoryOptions): UseEditHistoryReturn;
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* Configuration for a single keyboard shortcut
|
|
477
|
+
*/
|
|
478
|
+
interface KeyboardShortcutConfig {
|
|
479
|
+
/** The key to listen for (e.g., 'z', 'y', 'Enter') */
|
|
480
|
+
key: string;
|
|
481
|
+
/** Whether Ctrl key must be pressed (Windows/Linux) */
|
|
482
|
+
ctrl?: boolean;
|
|
483
|
+
/** Whether Shift key must be pressed */
|
|
484
|
+
shift?: boolean;
|
|
485
|
+
/** Whether Meta key must be pressed (Mac Command key) */
|
|
486
|
+
meta?: boolean;
|
|
487
|
+
/** Handler function to call when shortcut is triggered */
|
|
488
|
+
handler: () => void;
|
|
489
|
+
/** Whether this shortcut is disabled */
|
|
490
|
+
disabled?: boolean;
|
|
733
491
|
}
|
|
734
492
|
/**
|
|
735
|
-
*
|
|
736
|
-
*
|
|
737
|
-
* Extends base result with additional @mdxui/do utilities.
|
|
493
|
+
* Options for the useKeyboardShortcuts hook
|
|
738
494
|
*/
|
|
739
|
-
interface
|
|
740
|
-
/**
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
/**
|
|
745
|
-
|
|
746
|
-
*/
|
|
747
|
-
emptyMessage: string;
|
|
748
|
-
/**
|
|
749
|
-
* Whether the current data is stale (from cache, not fresh).
|
|
750
|
-
*/
|
|
751
|
-
isStale: boolean;
|
|
752
|
-
/**
|
|
753
|
-
* Get a record by index from the current data.
|
|
754
|
-
*/
|
|
755
|
-
getByIndex: (index: number) => T | undefined;
|
|
495
|
+
interface UseKeyboardShortcutsOptions {
|
|
496
|
+
/** Whether to enable the shortcuts (default: true) */
|
|
497
|
+
enabled?: boolean;
|
|
498
|
+
/** Whether to prevent default behavior (default: true) */
|
|
499
|
+
preventDefault?: boolean;
|
|
500
|
+
/** Whether to stop propagation (default: false) */
|
|
501
|
+
stopPropagation?: boolean;
|
|
756
502
|
}
|
|
757
503
|
/**
|
|
758
|
-
*
|
|
504
|
+
* Custom hook for registering global keyboard shortcuts
|
|
759
505
|
*
|
|
760
|
-
*
|
|
761
|
-
*
|
|
506
|
+
* This hook registers keyboard event listeners on the document and
|
|
507
|
+
* triggers handlers when matching shortcuts are pressed. It automatically
|
|
508
|
+
* bypasses shortcuts when the user is typing in an input, textarea, or
|
|
509
|
+
* contentEditable element.
|
|
762
510
|
*
|
|
763
511
|
* @example
|
|
764
512
|
* ```tsx
|
|
765
|
-
*
|
|
766
|
-
*
|
|
767
|
-
*
|
|
768
|
-
*
|
|
769
|
-
*
|
|
770
|
-
*
|
|
771
|
-
*
|
|
772
|
-
*
|
|
773
|
-
*
|
|
774
|
-
*
|
|
775
|
-
*
|
|
776
|
-
*
|
|
777
|
-
*
|
|
778
|
-
*
|
|
779
|
-
*
|
|
780
|
-
*
|
|
781
|
-
*
|
|
782
|
-
* if (isLoading) return <LoadingSpinner />
|
|
783
|
-
* if (isEmpty) return <EmptyState message={emptyMessage} />
|
|
784
|
-
*
|
|
785
|
-
* return (
|
|
786
|
-
* <DataGrid columns={columns} data={users} />
|
|
787
|
-
* )
|
|
788
|
-
* }
|
|
513
|
+
* // Basic undo/redo shortcuts
|
|
514
|
+
* useKeyboardShortcuts([
|
|
515
|
+
* { key: 'z', ctrl: true, handler: handleUndo },
|
|
516
|
+
* { key: 'z', ctrl: true, shift: true, handler: handleRedo },
|
|
517
|
+
* ])
|
|
518
|
+
*
|
|
519
|
+
* // With options
|
|
520
|
+
* useKeyboardShortcuts(
|
|
521
|
+
* [{ key: 's', ctrl: true, handler: handleSave }],
|
|
522
|
+
* { preventDefault: true }
|
|
523
|
+
* )
|
|
524
|
+
*
|
|
525
|
+
* // Conditionally disabled
|
|
526
|
+
* useKeyboardShortcuts(
|
|
527
|
+
* [{ key: 'z', ctrl: true, handler: handleUndo, disabled: !canUndo }],
|
|
528
|
+
* )
|
|
789
529
|
* ```
|
|
790
|
-
*
|
|
791
|
-
* @param config - Configuration options for the resource hook
|
|
792
|
-
* @returns Resource state and mutation functions
|
|
793
|
-
*/
|
|
794
|
-
declare function useDOResource<T extends BaseRecord = BaseRecord>(config: UseDOConfig<T>): UseDOResult<T>;
|
|
795
|
-
/**
|
|
796
|
-
* @deprecated Use useDOResource instead. This alias is kept for backward compatibility.
|
|
797
|
-
* Note: This conflicts with useDO from providers/do-provider.tsx, so import explicitly if needed.
|
|
798
530
|
*/
|
|
799
|
-
declare
|
|
531
|
+
declare function useKeyboardShortcuts(shortcuts: KeyboardShortcutConfig[], options?: UseKeyboardShortcutsOptions): void;
|
|
800
532
|
|
|
801
|
-
export { type
|
|
533
|
+
export { type EditOperation as CellEditOperation, type KeyboardShortcutConfig, type SchemaDefinition, type SchemaDiscoveryResult, type SchemaProperty, type SubscriptionEvent, type SubscriptionEventType, type SubscriptionState, type UseEditHistoryReturn as UseEditHistoryHookReturn, type UseEditHistoryOptions, type UseKeyboardShortcutsOptions, type UseNamespacesOptions, type UseNamespacesResult, type UseSchemaOptions, type UseSchemaResult, type UseThingSubscriptionOptions, type UseThingSubscriptionResult, type UseTypesOptions, type UseTypesResult, namespacesKeys, schemaKeys, typesKeys, useEditHistory, useKeyboardShortcuts, useNamespaces, useSchema, useSchemaDefinition, useSingleThingSubscription, useThingSubscription, useTypes };
|