@mdxui/do 2.1.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/README.md +253 -266
  2. package/dist/{agents-xcIn2dUB.d.ts → agents-2_r9e9i7.d.ts} +213 -2
  3. package/dist/app/index.d.ts +347 -0
  4. package/dist/app/index.js +13 -0
  5. package/dist/app/index.js.map +1 -0
  6. package/dist/chunk-4KXVN3EQ.js +56 -0
  7. package/dist/chunk-4KXVN3EQ.js.map +1 -0
  8. package/dist/chunk-5AWTQDRF.js +76 -0
  9. package/dist/chunk-5AWTQDRF.js.map +1 -0
  10. package/dist/chunk-EQVOEEQO.js +95 -0
  11. package/dist/chunk-EQVOEEQO.js.map +1 -0
  12. package/dist/chunk-FO3N7SXV.js +469 -0
  13. package/dist/chunk-FO3N7SXV.js.map +1 -0
  14. package/dist/chunk-IESVTECE.js +536 -0
  15. package/dist/chunk-IESVTECE.js.map +1 -0
  16. package/dist/chunk-JWKIONEO.js +234 -0
  17. package/dist/chunk-JWKIONEO.js.map +1 -0
  18. package/dist/chunk-NTSEARBC.js +715 -0
  19. package/dist/chunk-NTSEARBC.js.map +1 -0
  20. package/dist/chunk-OWEAW4U6.js +116 -0
  21. package/dist/chunk-OWEAW4U6.js.map +1 -0
  22. package/dist/chunk-VRLUXCLD.js +31 -0
  23. package/dist/chunk-VRLUXCLD.js.map +1 -0
  24. package/dist/chunk-Y52IEYVM.js +131 -0
  25. package/dist/chunk-Y52IEYVM.js.map +1 -0
  26. package/dist/chunk-YGIBMNRH.js +1991 -0
  27. package/dist/chunk-YGIBMNRH.js.map +1 -0
  28. package/dist/components/index.d.ts +1 -738
  29. package/dist/components/index.js +2 -6
  30. package/dist/config-CmZBQQaT.d.ts +122 -0
  31. package/dist/{do-CaQVueZw.d.ts → do-C-t9UgjT.d.ts} +31 -33
  32. package/dist/errors-B4Oyyj4Z.d.ts +346 -0
  33. package/dist/hooks/index.d.ts +428 -696
  34. package/dist/hooks/index.js +6 -4
  35. package/dist/hooks/things/index.d.ts +298 -0
  36. package/dist/hooks/things/index.js +8 -0
  37. package/dist/hooks/things/index.js.map +1 -0
  38. package/dist/index.d.ts +21 -1010
  39. package/dist/index.js +11 -839
  40. package/dist/index.js.map +1 -1
  41. package/dist/lib/index.d.ts +100 -0
  42. package/dist/lib/index.js +6 -0
  43. package/dist/lib/index.js.map +1 -0
  44. package/dist/providers/index.d.ts +244 -32
  45. package/dist/providers/index.js +3 -2
  46. package/dist/query-keys-BC901wog.d.ts +153 -0
  47. package/dist/schemas/index.d.ts +1 -1
  48. package/dist/schemas/index.js +2 -2
  49. package/dist/schemas/index.js.map +1 -1
  50. package/dist/{thing-DtI25yZh.d.ts → thing-BVhCTzOi.d.ts} +4 -4
  51. package/dist/types/index.d.ts +251 -216
  52. package/dist/types/index.js +1 -2
  53. package/dist/views/index.d.ts +131 -0
  54. package/dist/views/index.js +11 -0
  55. package/dist/views/index.js.map +1 -0
  56. package/package.json +39 -17
  57. package/dist/__test-utils__/index.d.ts +0 -399
  58. package/dist/__test-utils__/index.js +0 -34641
  59. package/dist/__test-utils__/index.js.map +0 -1
  60. package/dist/chunk-EEDMN7UF.js +0 -1351
  61. package/dist/chunk-EEDMN7UF.js.map +0 -1
  62. package/dist/chunk-G3PMV62Z.js +0 -33
  63. package/dist/chunk-G3PMV62Z.js.map +0 -1
  64. package/dist/chunk-NXPXL5NA.js +0 -3789
  65. package/dist/chunk-NXPXL5NA.js.map +0 -1
  66. package/dist/chunk-PC5FJY6M.js +0 -20
  67. package/dist/chunk-PC5FJY6M.js.map +0 -1
  68. package/dist/chunk-XF6LKY2M.js +0 -445
  69. package/dist/chunk-XF6LKY2M.js.map +0 -1
  70. package/dist/magic-string.es-J7BYFTTJ.js +0 -1307
  71. package/dist/magic-string.es-J7BYFTTJ.js.map +0 -1
@@ -1,801 +1,533 @@
1
- import { a as ThingQueryResult, T as Thing, j as ThingVersion, k as TypeStats, b as ThingCreateInput, h as ThingUpdateInput, c as ThingFilter, d as ThingSort, e as ThingPagination } from '../thing-DtI25yZh.js';
2
- import { QueryObserverResult, UseQueryResult, UseMutationResult } from '@tanstack/react-query';
3
- import * as zod from 'zod';
4
- import { EntityReference } from '../schemas/index.js';
5
- import { RelationshipFilter, GraphPattern, Relationship, GraphTraversalResult, GraphStats, RelationshipCreateInput, PaginatedResult } from '../types/index.js';
6
- import { q as WorkflowFilter, r as ExecutionFilter, U as AgentFilter, V as AgentExecutionFilter, a as Workflow, m as WorkflowExecution, s as Agent, B as AgentMetrics, F as AgentExecution, Q as AgentFeedback } from '../agents-xcIn2dUB.js';
7
- import * as React from 'react';
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
- * Type definitions for Things hooks
17
- *
18
- * Provides return types for query and mutation hooks.
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
- * Return type for useThings hook
29
+ * Schema definition for a resource type
23
30
  */
24
- interface UseThingsResult {
25
- /** The query result data, or null if not yet loaded */
26
- data: ThingQueryResult | null;
27
- /** True during initial load */
28
- isLoading: boolean;
29
- /** Error from the query, or null */
30
- error: Error | null;
31
- /** Function to manually refetch the data */
32
- refetch: () => Promise<QueryObserverResult<ThingQueryResult, Error>>;
33
- /** The query key used for cache management */
34
- queryKey: readonly unknown[];
35
- /** True if refetching in the background */
36
- isRefetching: boolean;
37
- /** True if any fetch is in progress */
38
- isFetching: boolean;
39
- /** Query status: 'pending', 'success', or 'error' */
40
- status: 'pending' | 'success' | 'error';
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
- * Return type for useThing hook
44
- */
45
- interface UseThingResult {
46
- /** The Thing data, or null if not yet loaded */
47
- data: Thing | null;
48
- /** True during initial load */
49
- isLoading: boolean;
50
- /** Error from the query, or null */
51
- error: Error | null;
52
- /** Function to manually refetch the data */
53
- refetch: () => Promise<QueryObserverResult<Thing, Error>>;
54
- /** The query key used for cache management */
55
- queryKey: readonly unknown[];
56
- /** True if refetching in the background */
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
- * Return type for useThingVersions hook
69
+ * Options for useSchema hook
65
70
  */
66
- interface UseThingVersionsResult {
67
- /** The versions array, or null if not yet loaded */
68
- data: ThingVersion[] | null;
69
- /** True during initial load */
70
- isLoading: boolean;
71
- /** Error from the query, or null */
72
- error: Error | null;
73
- /** Function to manually refetch the data */
74
- refetch: () => Promise<QueryObserverResult<ThingVersion[], Error>>;
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
- * Return type for useTypeStats hook
82
+ * Result from useSchema hook
86
83
  */
87
- interface UseTypeStatsResult {
88
- /** The type statistics, or null if not yet loaded */
89
- data: TypeStats | null;
90
- /** True during initial load */
84
+ interface UseSchemaResult {
85
+ /** Schema discovery result */
86
+ data: SchemaDiscoveryResult | null;
87
+ /** Loading state */
91
88
  isLoading: boolean;
92
- /** Error from the query, or null */
89
+ /** Error if any */
93
90
  error: Error | null;
94
- /** Function to manually refetch the data */
95
- refetch: () => Promise<QueryObserverResult<TypeStats, Error>>;
96
- /** The query key used for cache management */
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
- * Return type for useCreateThing hook
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
- interface UseCreateThingResult {
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
- * Return type for useUpdateThing hook
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
- interface UseUpdateThingResult {
126
- /** Trigger the mutation */
127
- mutate: (input: ThingUpdateInput) => void;
128
- /** Trigger the mutation and return a promise */
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
- /** True if the mutation succeeded */
135
- isSuccess: boolean;
136
- /** Reset the mutation state */
137
- reset: () => void;
138
- }
144
+ refetch: () => Promise<unknown>;
145
+ };
146
+
139
147
  /**
140
- * Options for delete operation
148
+ * Options for useNamespaces hook
141
149
  */
142
- interface DeleteThingOptions {
143
- /** If true, permanently delete instead of soft delete */
144
- hard?: boolean;
150
+ interface UseNamespacesOptions {
151
+ /** Include hidden/system namespaces */
152
+ includeSystem?: boolean;
153
+ /** Enable/disable the query */
154
+ enabled?: boolean;
145
155
  }
146
156
  /**
147
- * Return type for useDeleteThing hook
157
+ * Result from useNamespaces hook
148
158
  */
149
- interface UseDeleteThingResult {
150
- /** Trigger the mutation */
151
- mutate: (options?: DeleteThingOptions) => void;
152
- /** Trigger the mutation and return a promise */
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 from the mutation, or null */
164
+ /** Error if any */
157
165
  error: Error | null;
158
- /** True if the mutation succeeded */
159
- isSuccess: boolean;
160
- /** Reset the mutation state */
161
- reset: () => void;
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
- * Hook to fetch a list of Things
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 delete a Thing (soft delete by default)
178
+ * Hook to fetch available namespaces
212
179
  *
213
- * Automatically invalidates the related cache entries on success.
180
+ * @example
181
+ * ```tsx
182
+ * function NamespaceSelector() {
183
+ * const { data: namespaces, isLoading } = useNamespaces()
214
184
  *
215
- * Supports three modes:
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
- * Note: DataProvider mode always performs soft delete. For hard delete,
221
- * use RPC or REST API modes with `{ hard: true }` option.
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 useDeleteThing(ns: string, type: string, id: string): UseDeleteThingResult;
199
+ declare function useNamespaces(options?: UseNamespacesOptions): UseNamespacesResult;
224
200
 
225
201
  /**
226
- * Query keys for Things resource
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
- declare const thingsKeys: {
234
- all: readonly ["things"];
235
- lists: () => readonly ["things", "list"];
236
- list: (filter: ThingFilter, sort?: ThingSort, pagination?: ThingPagination) => readonly ["things", "list", {
237
- readonly filter: zod.objectOutputType<{
238
- ns: zod.ZodOptional<zod.ZodUnion<[zod.ZodString, zod.ZodArray<zod.ZodString, "many">]>>;
239
- type: zod.ZodOptional<zod.ZodUnion<[zod.ZodString, zod.ZodArray<zod.ZodString, "many">]>>;
240
- idPattern: zod.ZodOptional<zod.ZodString>;
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
- * Query keys for Agents resource
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
- declare const agentsKeys: {
274
- all: readonly ["agents"];
275
- lists: () => readonly ["agents", "list"];
276
- list: (filter: AgentFilter) => readonly ["agents", "list", AgentFilter];
277
- details: () => readonly ["agents", "detail"];
278
- detail: (id: string) => readonly ["agents", "detail", string];
279
- metrics: (id: string) => readonly ["agents", "detail", string, "metrics"];
280
- executions: () => readonly ["agents", "executions"];
281
- executionsList: (filter: AgentExecutionFilter) => readonly ["agents", "executions", "list", AgentExecutionFilter];
282
- execution: (id: string) => readonly ["agents", "executions", "detail", string];
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
- * Query keys for Workflows resource
234
+ * Hook to fetch available types within a namespace
286
235
  *
287
- * Includes keys for:
288
- * - Workflow lists and details
289
- * - Workflow executions (list and detail)
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
- * Includes keys for:
305
- * - Relationship lists and details
306
- * - Graph traversal queries
307
- * - Graph statistics
308
- */
309
- declare const relationshipsKeys: {
310
- all: readonly ["relationships"];
311
- lists: () => readonly ["relationships", "list"];
312
- list: (filter: RelationshipFilter) => readonly ["relationships", "list", RelationshipFilter];
313
- details: () => readonly ["relationships", "detail"];
314
- detail: (id: string) => readonly ["relationships", "detail", string];
315
- graph: () => readonly ["relationships", "graph"];
316
- traverse: (entity: EntityReference, pattern: GraphPattern) => readonly ["relationships", "graph", {
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 useDeleteWorkflow(): UseDeleteWorkflowResult;
255
+ declare function useTypes(options?: UseTypesOptions): UseTypesResult;
456
256
 
457
257
  /**
458
- * Return type for useAgents hook
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 UseUpdateAgentResult = UseMutationResult<Agent, Error, Partial<Agent>>;
260
+ type SubscriptionEventType = 'created' | 'updated' | 'deleted' | 'connected' | 'disconnected' | 'error';
485
261
  /**
486
- * Input type for useExecuteAgent mutation
262
+ * Subscription event payload
487
263
  */
488
- interface ExecuteAgentInput {
489
- task: string;
490
- context?: Record<string, unknown>;
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
- * Return type for useExecuteAgent hook
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
- declare function useAgentExecutions(filter?: AgentExecutionFilter): UseAgentExecutionsResult;
279
+ type SubscriptionState = 'connecting' | 'connected' | 'disconnected' | 'error';
525
280
  /**
526
- * Hook to fetch a single agent execution
281
+ * Options for useThingSubscription hook
527
282
  */
528
- declare function useAgentExecution(id: string): UseAgentExecutionResult;
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
- * Pre-configured DataProvider instance.
573
- * Use this for custom data provider configurations.
574
- * Takes precedence over `ns` if both are provided.
575
- */
576
- dataProvider?: DataProvider;
577
- /**
578
- * Additional configuration for DotdoDataProvider.
579
- * Only used when `ns` is provided.
580
- */
581
- dotdoConfig?: Omit<DotdoDataProviderConfig, 'ns'>;
582
- /**
583
- * @mdxui/admin AdminProvider configuration.
584
- */
585
- adminConfig?: Omit<AdminProviderProps, 'children'>;
586
- /**
587
- * Theme preference for the admin UI.
588
- * @default 'system'
589
- */
590
- theme?: 'light' | 'dark' | 'system';
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
- * Context value for DO Admin specific features (dotdo integration)
308
+ * Result from useThingSubscription hook
608
309
  */
609
- interface DOAdminContextValue {
610
- /** The configured data provider */
611
- dataProvider: DataProvider | null;
612
- /** Whether DO integration is enabled */
613
- isDOEnabled: boolean;
614
- /** The DO namespace URL if configured */
615
- ns: string | null;
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
- * Combined admin provider for @mdxui/admin with Durable Objects support.
325
+ * Hook for real-time Thing subscriptions
619
326
  *
620
- * Wraps both the @mdxui/admin AdminProvider and @dotdo/react AdminProvider,
621
- * providing a unified context for admin applications backed by Durable Objects.
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
- * import { DO } from '@mdxui/do'
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
- * <DO
630
- * ns="https://api.example.com.ai/do/workspace"
631
- * title="My Admin"
632
- * theme="dark"
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
- * // With custom data provider configuration
644
- * import { DO, DotdoDataProvider } from '@mdxui/do'
645
- *
646
- * function App() {
647
- * const dataProvider = DotdoDataProvider({
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
- * return (
654
- * <DO dataProvider={dataProvider} title="My Admin">
655
- * <AdminRoutes />
656
- * </DO>
657
- * )
357
+ * // ...
658
358
  * }
659
359
  * ```
660
360
  */
661
- declare function DO({ children, ns, dataProvider: providedDataProvider, dotdoConfig, adminConfig, theme, basename, title, logo, }: DOProps): React.ReactElement;
662
- declare namespace DO {
663
- var displayName: string;
664
- }
361
+ declare function useThingSubscription(options?: UseThingSubscriptionOptions): UseThingSubscriptionResult;
665
362
  /**
666
- * Hook to access DO-specific admin context.
363
+ * Hook to subscribe to a single Thing's changes
667
364
  *
668
- * @returns DO context value
365
+ * Convenience wrapper around useThingSubscription for single-Thing use cases.
669
366
  *
670
367
  * @example
671
368
  * ```tsx
672
- * function MyComponent() {
673
- * const { isDOEnabled, ns } = useDOContext()
674
- *
675
- * if (!isDOEnabled) {
676
- * return <div>DO backend not configured</div>
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 <div>Connected to: {ns}</div>
379
+ * return (
380
+ * <div>
381
+ * {isConnected && <Badge>Live</Badge>}
382
+ * {/* Editor UI *\/}
383
+ * </div>
384
+ * )
680
385
  * }
681
386
  * ```
682
387
  */
683
- declare function useDOContext(): DOAdminContextValue;
684
- /**
685
- * Hook to check if DO integration is enabled.
686
- *
687
- * @returns Whether DO backend is configured
688
- */
689
- declare function useIsDOEnabled(): boolean;
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
- * useDO Hook
693
- *
694
- * Wrapper around @dotdo/react/admin useResource that provides
695
- * @mdxui/do-specific defaults and type safety.
696
- *
697
- * @module @mdxui/do/hooks/dotdo
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
- * Base record type for DO-backed resources.
702
- * Records must have either $id (dotdo style) or id (standard style).
419
+ * Configuration for the edit history hook
703
420
  */
704
- interface BaseRecord {
705
- /** Dotdo-style unique identifier */
706
- $id?: string;
707
- /** Standard unique identifier */
708
- id?: string;
709
- /** Additional fields */
710
- [key: string]: unknown;
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
- * Configuration for useDO hook
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
- * Extends the base @dotdo/react useResource config with
716
- * @mdxui/do-specific options.
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
- interface UseDOConfig<T extends BaseRecord = BaseRecord> extends UseResourceConfig<T> {
719
- /**
720
- * Whether to show toast notifications on errors.
721
- * @default true
722
- */
723
- showToasts?: boolean;
724
- /**
725
- * Transform function to apply to fetched data.
726
- * Useful for mapping DO response to UI-expected format.
727
- */
728
- transform?: (data: T[]) => T[];
729
- /**
730
- * Custom empty state message when no data is returned.
731
- */
732
- emptyMessage?: string;
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
- * Return type for useDO hook
736
- *
737
- * Extends base result with additional @mdxui/do utilities.
493
+ * Options for the useKeyboardShortcuts hook
738
494
  */
739
- interface UseDOResult<T extends BaseRecord> extends UseResourceResult<T> {
740
- /**
741
- * Whether the data set is empty (no items after loading completes).
742
- */
743
- isEmpty: boolean;
744
- /**
745
- * Message to display when data is empty.
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
- * React hook for working with a Durable Objects resource collection.
504
+ * Custom hook for registering global keyboard shortcuts
759
505
  *
760
- * Wraps @dotdo/react/admin useResource with @mdxui/do conventions
761
- * and additional utilities.
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
- * import { useDOResource } from '@mdxui/do'
766
- *
767
- * function UserList() {
768
- * const {
769
- * data: users,
770
- * isLoading,
771
- * isEmpty,
772
- * emptyMessage,
773
- * create,
774
- * update,
775
- * remove,
776
- * } = useDOResource<User>({
777
- * resource: 'User',
778
- * perPage: 20,
779
- * sort: { field: 'createdAt', order: 'desc' },
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 const useDOAdmin: typeof useDOResource;
531
+ declare function useKeyboardShortcuts(shortcuts: KeyboardShortcutConfig[], options?: UseKeyboardShortcutsOptions): void;
800
532
 
801
- export { type BaseRecord, DO, type DOAdminContextValue, type DOProps, type DeleteThingOptions, type EntityRelationshipsData, type ExecuteAgentInput, type SubmitAgentFeedbackInput, type UseAgentExecutionResult, type UseAgentExecutionsResult, type UseAgentMetricsResult, type UseAgentResult, type UseAgentsResult, type UseCancelExecutionResult, type UseCreateAgentResult, type UseCreateRelationshipResult, type UseCreateThingResult, type UseCreateWorkflowResult, type UseDOConfig, type UseDOResult, type UseDeleteAgentResult, type UseDeleteRelationshipResult, type UseDeleteThingResult, type UseDeleteWorkflowResult, type UseEntityRelationshipsResult, type UseExecuteAgentResult, type UseGraphStatsResult, type UseGraphTraversalResult, type UseRelationshipsResult, type UseSubmitAgentFeedbackResult, type UseThingResult, type UseThingVersionsResult, type UseThingsResult, type UseTriggerWorkflowResult, type UseTypeStatsResult, type UseUpdateAgentResult, type UseUpdateThingResult, type UseUpdateWorkflowResult, type UseWorkflowExecutionResult, type UseWorkflowExecutionsResult, type UseWorkflowResult, type UseWorkflowsResult, agentsKeys, relationshipsKeys, thingsKeys, useAgent, useAgentExecution, useAgentExecutions, useAgentMetrics, useAgents, useCancelExecution, useCreateAgent, useCreateRelationship, useCreateThing, useCreateWorkflow, useDOAdmin, useDOContext, useDOResource, useDeleteAgent, useDeleteRelationship, useDeleteThing, useDeleteWorkflow, useEntityRelationships, useExecuteAgent, useGraphStats, useGraphTraversal, useIsDOEnabled, useRelationships, useSubmitAgentFeedback, useThing, useThingVersions, useThings, useTriggerWorkflow, useTypeStats, useUpdateAgent, useUpdateThing, useUpdateWorkflow, useWorkflow, useWorkflowExecution, useWorkflowExecutions, useWorkflows, workflowsKeys };
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 };