@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
@@ -0,0 +1,131 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { T as Thing, S as SemanticType, h as ThingUpdateInput } from '../thing-BVhCTzOi.js';
3
+ export { DataFilterCondition, DataFilterPopover, DataFilterPopoverProps, DataSidebar, DataSidebarItem, DataSidebarProps, DataSidebarTrigger, DataSidebarTriggerProps, FILTER_OPERATOR_OPTIONS, FilterOperatorType } from '@mdxui/admin';
4
+ import 'zod';
5
+
6
+ interface DataBrowserViewProps {
7
+ /** Initial namespace */
8
+ initialNamespace?: string;
9
+ /** Initial type filter */
10
+ initialType?: string;
11
+ /** Callback when a Thing is selected */
12
+ onSelect?: (thing: Thing) => void;
13
+ /** Callback when a Thing is double-clicked (e.g., to edit) */
14
+ onOpen?: (thing: Thing) => void;
15
+ /** Custom className */
16
+ className?: string;
17
+ }
18
+ declare function DataBrowserView({ initialNamespace, initialType, onSelect, onOpen, className, }: DataBrowserViewProps): react_jsx_runtime.JSX.Element;
19
+
20
+ interface DataGridViewProps {
21
+ /** Initial namespace */
22
+ initialNamespace?: string;
23
+ /** Initial type */
24
+ initialType?: string;
25
+ /** Read-only mode */
26
+ readOnly?: boolean;
27
+ /** Callback when a row is selected */
28
+ onRowSelect?: (thing: Thing | null) => void;
29
+ /** Custom className */
30
+ className?: string;
31
+ }
32
+ declare function DataGridView({ initialNamespace, initialType, readOnly, onRowSelect: _onRowSelect, className, }: DataGridViewProps): react_jsx_runtime.JSX.Element;
33
+ declare namespace DataGridView {
34
+ var displayName: string;
35
+ }
36
+
37
+ interface DocumentEditorViewProps {
38
+ /** Initial namespace */
39
+ initialNamespace?: string;
40
+ /** Initial type */
41
+ initialType?: string;
42
+ /** Initial thing ID */
43
+ initialId?: string;
44
+ /** Callback when save completes */
45
+ onSave?: (thing: Thing) => void;
46
+ /** Callback when delete completes */
47
+ onDelete?: () => void;
48
+ /** Callback when back is clicked */
49
+ onBack?: () => void;
50
+ /** Custom className */
51
+ className?: string;
52
+ }
53
+ declare function DocumentEditorView({ initialNamespace, initialType, initialId, onSave, onDelete, onBack: _onBack, className, }: DocumentEditorViewProps): react_jsx_runtime.JSX.Element;
54
+ declare namespace DocumentEditorView {
55
+ var displayName: string;
56
+ }
57
+
58
+ interface FunctionEditorViewProps {
59
+ /** Initial code */
60
+ initialCode?: string;
61
+ /** Callback when code changes */
62
+ onCodeChange?: (code: string) => void;
63
+ /** Custom className */
64
+ className?: string;
65
+ }
66
+ declare function FunctionEditorView({ initialCode, onCodeChange, className, }: FunctionEditorViewProps): react_jsx_runtime.JSX.Element;
67
+ declare namespace FunctionEditorView {
68
+ var displayName: string;
69
+ }
70
+
71
+ /**
72
+ * Shared types for DataBrowser domain-specific components
73
+ *
74
+ * Generic types (DataFilterCondition, etc.) are now in @mdxui/admin.
75
+ */
76
+
77
+ /**
78
+ * Props for CreateDialog component
79
+ */
80
+ interface CreateDialogProps {
81
+ open: boolean;
82
+ onOpenChange: (open: boolean) => void;
83
+ namespace: string;
84
+ defaultType?: string;
85
+ types: SemanticType[];
86
+ onCreated?: (thing: Thing) => void;
87
+ }
88
+ /**
89
+ * Props for DetailSheet component
90
+ */
91
+ interface DetailSheetProps {
92
+ open: boolean;
93
+ onOpenChange: (open: boolean) => void;
94
+ thing: Thing | null;
95
+ onEdit?: (thing: Thing) => void;
96
+ onSave?: (thing: Thing, updates: ThingUpdateInput) => Promise<void>;
97
+ }
98
+
99
+ declare function CreateDialog({ open, onOpenChange, namespace, defaultType, types, onCreated, }: CreateDialogProps): react_jsx_runtime.JSX.Element;
100
+
101
+ declare function DetailSheet({ open, onOpenChange, thing, onEdit, onSave }: DetailSheetProps): react_jsx_runtime.JSX.Element | null;
102
+
103
+ /**
104
+ * Date Formatting Utilities
105
+ */
106
+ /**
107
+ * Check if a string is an ISO date string
108
+ */
109
+ declare function isISODateString(value: string): boolean;
110
+ /**
111
+ * Format a date value for display
112
+ */
113
+ declare function formatDate(dateValue: Date | string): {
114
+ date: string;
115
+ time: string;
116
+ relative: string;
117
+ };
118
+ /**
119
+ * Format a field name for display (camelCase/snake_case to Title Case)
120
+ */
121
+ declare function formatFieldName(key: string): string;
122
+
123
+ /**
124
+ * Export Utilities
125
+ */
126
+ /**
127
+ * Export data as a JSON file download
128
+ */
129
+ declare function exportToJSON(data: Record<string, unknown>[], filename: string): void;
130
+
131
+ export { CreateDialog, type CreateDialogProps, DataBrowserView, type DataBrowserViewProps, DataGridView, type DataGridViewProps, DetailSheet, type DetailSheetProps, DocumentEditorView, type DocumentEditorViewProps, FunctionEditorView, type FunctionEditorViewProps, exportToJSON, formatDate as formatDateView, formatFieldName, isISODateString };
@@ -0,0 +1,11 @@
1
+ export { CreateDialog, DataBrowserView, DataFilterPopover, DataGridView, DataSidebar, DataSidebarTrigger, DetailSheet, DocumentEditorView, FILTER_OPERATOR_OPTIONS, FunctionEditorView, exportToJSON, formatDate as formatDateView, formatFieldName, isISODateString } from '../chunk-YGIBMNRH.js';
2
+ import '../chunk-5AWTQDRF.js';
3
+ import '../chunk-IESVTECE.js';
4
+ import '../chunk-JWKIONEO.js';
5
+ import '../chunk-4KXVN3EQ.js';
6
+ import '../chunk-FO3N7SXV.js';
7
+ import '../chunk-OWEAW4U6.js';
8
+ import '../chunk-Y52IEYVM.js';
9
+ import '../chunk-GGO5GW72.js';
10
+ //# sourceMappingURL=index.js.map
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@mdxui/do",
3
- "version": "2.1.1",
3
+ "version": "3.0.0",
4
4
  "private": false,
5
- "description": "Admin interface for .do platform - manage Durable Objects, Things, Relationships, Workflows, Agents, and Integrations",
5
+ "description": "Admin interface for .do platform - manage Durable Objects via RPC",
6
6
  "license": "MIT",
7
7
  "author": "mdxui",
8
8
  "type": "module",
@@ -11,9 +11,9 @@
11
11
  "types": "./dist/index.d.ts",
12
12
  "import": "./dist/index.js"
13
13
  },
14
- "./admin": {
15
- "types": "./dist/admin/index.d.ts",
16
- "import": "./dist/admin/index.js"
14
+ "./app": {
15
+ "types": "./dist/app/index.d.ts",
16
+ "import": "./dist/app/index.js"
17
17
  },
18
18
  "./providers": {
19
19
  "types": "./dist/providers/index.d.ts",
@@ -23,6 +23,10 @@
23
23
  "types": "./dist/hooks/index.d.ts",
24
24
  "import": "./dist/hooks/index.js"
25
25
  },
26
+ "./hooks/things": {
27
+ "types": "./dist/hooks/things/index.d.ts",
28
+ "import": "./dist/hooks/things/index.js"
29
+ },
26
30
  "./components": {
27
31
  "types": "./dist/components/index.d.ts",
28
32
  "import": "./dist/components/index.js"
@@ -35,22 +39,29 @@
35
39
  "types": "./dist/schemas/index.d.ts",
36
40
  "import": "./dist/schemas/index.js"
37
41
  },
38
- "./__test-utils__": {
39
- "types": "./dist/__test-utils__/index.d.ts",
40
- "import": "./dist/__test-utils__/index.js"
42
+ "./views": {
43
+ "types": "./dist/views/index.d.ts",
44
+ "import": "./dist/views/index.js"
45
+ },
46
+ "./lib": {
47
+ "types": "./dist/lib/index.d.ts",
48
+ "import": "./dist/lib/index.js"
41
49
  }
42
50
  },
43
51
  "main": "./dist/index.js",
44
52
  "types": "./dist/index.d.ts",
45
53
  "files": [
46
- "dist"
54
+ "dist",
55
+ "dist-app"
47
56
  ],
48
57
  "scripts": {
49
- "build": "tsup",
58
+ "build": "NODE_OPTIONS='--max-old-space-size=6144' tsup",
59
+ "build:app": "vite build",
50
60
  "dev": "tsup --watch",
61
+ "dev:app": "vite",
62
+ "preview:app": "vite preview",
51
63
  "typecheck": "tsc --noEmit",
52
- "lint": "eslint src/",
53
- "clean": "rm -rf dist",
64
+ "clean": "rm -rf dist dist-app",
54
65
  "test": "vitest",
55
66
  "test:run": "vitest run",
56
67
  "test:coverage": "vitest run --coverage"
@@ -62,18 +73,27 @@
62
73
  "dependencies": {
63
74
  "@dotdo/client": "^0.3.0",
64
75
  "@dotdo/react": "^1.0.0",
65
- "@mdxui/admin": "2.1.1",
66
- "@mdxui/app": "2.1.1",
67
- "@mdxui/primitives": "2.1.1",
68
- "@tanstack/db": "^0.5.17",
69
- "@tanstack/react-db": "^0.1.61",
76
+ "capnweb": "^0.1.0",
77
+ "@mdxui/admin": "workspace:*",
78
+ "@mdxui/app": "workspace:*",
79
+ "@mdxui/navigation": "workspace:*",
80
+ "@mdxui/primitives": "workspace:*",
70
81
  "@tanstack/react-query": "^5.90.16",
82
+ "@tanstack/react-router": "^1.95.0",
83
+ "@tanstack/react-table": "^8.20.6",
84
+ "@workos-inc/authkit-react": "^0.16.0",
85
+ "@workos-inc/widgets": "^1.7.2",
71
86
  "clsx": "^2.1.1",
72
87
  "lucide-react": "^0.474.0",
88
+ "next-themes": "^0.4.4",
89
+ "react-router-dom": "^7.12.0",
90
+ "sonner": "^2.0.7",
73
91
  "tailwind-merge": "^3.0.2",
92
+ "use-deep-compare": "^1.3.0",
74
93
  "zod": "^3.24.2"
75
94
  },
76
95
  "devDependencies": {
96
+ "@tailwindcss/vite": "^4.0.9",
77
97
  "@testing-library/jest-dom": "^6.6.3",
78
98
  "@testing-library/react": "^16.2.0",
79
99
  "@testing-library/user-event": "^14.6.1",
@@ -84,8 +104,10 @@
84
104
  "jsdom": "^26.0.0",
85
105
  "react": "^19.0.0",
86
106
  "react-dom": "^19.0.0",
107
+ "tailwindcss": "^4.0.9",
87
108
  "tsup": "^8.4.0",
88
109
  "typescript": "^5.7.3",
110
+ "vite": "^6.0.7",
89
111
  "vitest": "^3.0.4"
90
112
  },
91
113
  "publishConfig": {
@@ -1,399 +0,0 @@
1
- import * as React$1 from 'react';
2
- import { T as Thing, a as ThingQueryResult, b as ThingCreateInput, c as ThingFilter, d as ThingSort, e as ThingPagination } from '../thing-DtI25yZh.js';
3
- import { RenderOptions, RenderResult, RenderHookOptions, RenderHookResult } from '@testing-library/react';
4
- export { act, cleanup, fireEvent, render, renderHook, screen, waitFor, within } from '@testing-library/react';
5
- import { QueryClient } from '@tanstack/react-query';
6
- import { D as DOAdminConfig } from '../do-CaQVueZw.js';
7
- import * as vitest from 'vitest';
8
- export { default as userEvent } from '@testing-library/user-event';
9
- import 'zod';
10
-
11
- /**
12
- * Test Fixtures for @mdxui/do
13
- *
14
- * Factory functions for creating consistent test data across unit and E2E tests.
15
- * These fixtures provide type-safe defaults with optional override capabilities.
16
- *
17
- * @example
18
- * ```typescript
19
- * // Create a default Thing
20
- * const thing = fixtures.thing()
21
- *
22
- * // Create with overrides
23
- * const customThing = fixtures.thing({ type: 'User', name: 'John' })
24
- *
25
- * // Create a ThingQueryResult with multiple items
26
- * const queryResult = fixtures.thingQueryResult([
27
- * fixtures.thing({ type: 'Task' }),
28
- * fixtures.thing({ type: 'Task', name: 'Task 2' }),
29
- * ])
30
- * ```
31
- */
32
-
33
- /**
34
- * Reset the ID counter (useful in beforeEach)
35
- */
36
- declare function resetIdCounter(): void;
37
- /**
38
- * Generate a unique test ID
39
- */
40
- declare function generateTestId(prefix?: string): string;
41
- /**
42
- * Test fixtures factory
43
- */
44
- declare const fixtures: {
45
- /**
46
- * Create a Thing with sensible defaults
47
- *
48
- * @param overrides - Optional partial Thing to merge
49
- * @returns A complete Thing object
50
- */
51
- thing: (overrides?: Partial<Thing>) => Thing;
52
- /**
53
- * Create a ThingQueryResult with pagination
54
- *
55
- * @param things - Array of Things (defaults to single test thing)
56
- * @param pagination - Pagination overrides
57
- * @returns A complete ThingQueryResult
58
- */
59
- thingQueryResult: (things?: Thing[], pagination?: Partial<Pick<ThingQueryResult, "page" | "perPage" | "total" | "totalPages">>) => ThingQueryResult;
60
- /**
61
- * Create a ThingCreateInput for mutation tests
62
- *
63
- * @param overrides - Optional partial input to merge
64
- * @returns A complete ThingCreateInput
65
- */
66
- thingCreateInput: (overrides?: Partial<ThingCreateInput>) => ThingCreateInput;
67
- /**
68
- * Create a ThingFilter for query tests
69
- *
70
- * @param overrides - Optional partial filter to merge
71
- * @returns A ThingFilter
72
- */
73
- thingFilter: (overrides?: Partial<ThingFilter>) => ThingFilter;
74
- /**
75
- * Create a ThingSort for query tests
76
- *
77
- * @param overrides - Optional partial sort to merge
78
- * @returns A ThingSort
79
- */
80
- thingSort: (overrides?: Partial<ThingSort>) => ThingSort;
81
- /**
82
- * Create a ThingPagination for query tests
83
- *
84
- * @param overrides - Optional partial pagination to merge
85
- * @returns A ThingPagination
86
- */
87
- thingPagination: (overrides?: Partial<ThingPagination>) => ThingPagination;
88
- };
89
- /**
90
- * Type guard to assert a value is a Thing
91
- *
92
- * @param value - Unknown value to check
93
- * @throws If value is not a Thing
94
- */
95
- declare function assertThing(value: unknown): asserts value is Thing;
96
- /**
97
- * Type guard to assert a value is a ThingQueryResult
98
- *
99
- * @param value - Unknown value to check
100
- * @throws If value is not a ThingQueryResult
101
- */
102
- declare function assertThingQueryResult(value: unknown): asserts value is ThingQueryResult;
103
-
104
- /**
105
- * Test Wrappers for @mdxui/do
106
- *
107
- * React component wrappers for testing hooks and components with proper provider context.
108
- * Supports both unit tests (mocked) and E2E tests (live backend).
109
- *
110
- * @example
111
- * ```typescript
112
- * // Unit test with mocked provider
113
- * const { wrapper } = createTestWrapper({ namespace: 'test-ns' })
114
- * const { result } = renderHook(() => useThings({ type: 'Task' }), { wrapper })
115
- *
116
- * // E2E test with live backend
117
- * const { wrapper } = createTestWrapper({
118
- * mode: 'e2e',
119
- * config: { doUrl: 'wss://api.do/do/test' },
120
- * })
121
- * ```
122
- */
123
-
124
- /**
125
- * Default test config for unit tests
126
- *
127
- * NOTE: doUrl is NOT set by default, which keeps tests in REST mode.
128
- * This allows fetch mocking to work correctly since TanStack DB mode
129
- * uses WebSocket connections that can't be mocked with global.fetch.
130
- *
131
- * For tests that need TanStack DB/RPC mode, explicitly set doUrl:
132
- * createWrapper({ config: { doUrl: 'wss://...' } })
133
- */
134
- declare const defaultTestConfig: DOAdminConfig;
135
- /**
136
- * Create a QueryClient configured for testing
137
- *
138
- * Features:
139
- * - No retries (tests should fail fast)
140
- * - No caching (each test starts fresh)
141
- * - No background refetching (predictable test behavior)
142
- */
143
- declare function createTestQueryClient(): QueryClient;
144
- /**
145
- * Options for creating test wrappers
146
- */
147
- interface TestWrapperOptions {
148
- /**
149
- * Test mode:
150
- * - 'unit': Uses mocked config, fast health check
151
- * - 'e2e': Uses provided config for live backend
152
- */
153
- mode?: 'unit' | 'e2e';
154
- /** DOProvider config overrides */
155
- config?: Partial<DOAdminConfig>;
156
- /** Namespace for the test */
157
- namespace?: string;
158
- /** User ID for the test */
159
- userId?: string;
160
- /** Pre-configured QueryClient */
161
- queryClient?: QueryClient;
162
- }
163
- /**
164
- * Create a test wrapper component for hooks and components
165
- *
166
- * @param options - Wrapper configuration
167
- * @returns An object with the wrapper component and helper metadata
168
- *
169
- * @example
170
- * ```typescript
171
- * const { wrapper, namespace, queryClient } = createTestWrapper({
172
- * namespace: 'my-ns',
173
- * config: { realTimeUpdates: true },
174
- * })
175
- *
176
- * const { result } = renderHook(() => useDO(), { wrapper })
177
- * ```
178
- */
179
- declare function createTestWrapper(options?: TestWrapperOptions): {
180
- wrapper: React$1.FC<{
181
- children: React$1.ReactNode;
182
- }>;
183
- namespace: string;
184
- userId: string;
185
- queryClient: QueryClient;
186
- config: DOAdminConfig;
187
- };
188
- /**
189
- * Render a component with DOProvider wrapper
190
- *
191
- * Convenience function that combines render() with createTestWrapper().
192
- *
193
- * @param ui - React element to render
194
- * @param options - Render and wrapper options
195
- * @returns React Testing Library render result
196
- */
197
- declare function renderWithProvider(ui: React$1.ReactElement, options?: Omit<RenderOptions, 'wrapper'> & TestWrapperOptions): RenderResult;
198
- /**
199
- * Render a hook with DOProvider wrapper
200
- *
201
- * Convenience function that combines renderHook() with createTestWrapper().
202
- *
203
- * @param hook - Hook function to render
204
- * @param options - RenderHook and wrapper options
205
- * @returns React Testing Library renderHook result
206
- */
207
- declare function renderHookWithProvider<Result, Props>(hook: (props: Props) => Result, options?: Omit<RenderHookOptions<Props>, 'wrapper'> & TestWrapperOptions): RenderHookResult<Result, Props>;
208
- /**
209
- * Wait for pending promises to resolve
210
- *
211
- * Useful for ensuring async state updates have completed.
212
- *
213
- * @param ms - Optional milliseconds to wait (default: 0)
214
- */
215
- declare function flushPromises(ms?: number): Promise<void>;
216
- /**
217
- * Wait for a condition to be true with timeout
218
- *
219
- * Useful for waiting for async sync operations to complete.
220
- *
221
- * @param condition - Function that returns true when condition is met
222
- * @param options - Timeout and polling options
223
- * @throws If condition is not met within timeout
224
- */
225
- declare function waitForCondition(condition: () => boolean | Promise<boolean>, options?: {
226
- timeout?: number;
227
- interval?: number;
228
- }): Promise<void>;
229
-
230
- /**
231
- * DataProvider interface for admin operations
232
- *
233
- * Modeled after react-admin's DataProvider pattern.
234
- */
235
- interface DataProvider {
236
- getList: <RecordType>(resource: string, params: {
237
- pagination?: {
238
- page: number;
239
- perPage: number;
240
- };
241
- sort?: {
242
- field: string;
243
- order: 'ASC' | 'DESC';
244
- };
245
- filter?: Record<string, unknown>;
246
- }) => Promise<{
247
- data: RecordType[];
248
- total: number;
249
- }>;
250
- getOne: <RecordType>(resource: string, params: {
251
- id: string | number;
252
- }) => Promise<{
253
- data: RecordType;
254
- }>;
255
- getMany: <RecordType>(resource: string, params: {
256
- ids: (string | number)[];
257
- }) => Promise<{
258
- data: RecordType[];
259
- }>;
260
- getManyReference: <RecordType>(resource: string, params: {
261
- target: string;
262
- id: string | number;
263
- pagination?: {
264
- page: number;
265
- perPage: number;
266
- };
267
- sort?: {
268
- field: string;
269
- order: 'ASC' | 'DESC';
270
- };
271
- filter?: Record<string, unknown>;
272
- }) => Promise<{
273
- data: RecordType[];
274
- total: number;
275
- }>;
276
- create: <RecordType>(resource: string, params: {
277
- data: Partial<RecordType>;
278
- }) => Promise<{
279
- data: RecordType;
280
- }>;
281
- update: <RecordType>(resource: string, params: {
282
- id: string | number;
283
- data: Partial<RecordType>;
284
- previousData: RecordType;
285
- }) => Promise<{
286
- data: RecordType;
287
- }>;
288
- updateMany: (resource: string, params: {
289
- ids: (string | number)[];
290
- data: Record<string, unknown>;
291
- }) => Promise<{
292
- data: (string | number)[];
293
- }>;
294
- delete: <RecordType>(resource: string, params: {
295
- id: string | number;
296
- previousData: RecordType;
297
- }) => Promise<{
298
- data: RecordType;
299
- }>;
300
- deleteMany: (resource: string, params: {
301
- ids: (string | number)[];
302
- }) => Promise<{
303
- data: (string | number)[];
304
- }>;
305
- }
306
- /**
307
- * Create a mock DataProvider with sensible defaults
308
- *
309
- * All methods are mocked with vi.fn() and return empty/success responses.
310
- * Override specific methods to customize behavior for your tests.
311
- *
312
- * @param overrides - Partial DataProvider to merge
313
- * @returns A complete mocked DataProvider
314
- */
315
- declare function createMockDataProvider(overrides?: Partial<DataProvider>): DataProvider;
316
- /**
317
- * Mock a successful fetch response
318
- *
319
- * @param data - Response data to return from json()
320
- * @returns The mocked fetch function
321
- */
322
- declare function mockFetchSuccess<T>(data: T): vitest.MockedFunction<typeof fetch>;
323
- /**
324
- * Mock a failed fetch response
325
- *
326
- * @param status - HTTP status code
327
- * @param statusText - HTTP status text
328
- * @returns The mocked fetch function
329
- */
330
- declare function mockFetchError(status: number, statusText?: string): vitest.MockedFunction<typeof fetch>;
331
- /**
332
- * Mock a fetch network error (failed to connect)
333
- *
334
- * @param message - Error message
335
- * @returns The mocked fetch function
336
- */
337
- declare function mockFetchNetworkError(message?: string): vitest.MockedFunction<typeof fetch>;
338
- /**
339
- * Mock a successful RPC response
340
- *
341
- * Wraps the value in the expected RPC response structure.
342
- *
343
- * @param value - The value to return
344
- * @returns The mocked fetch function
345
- */
346
- declare function mockRpcResponse<T>(value: T): vitest.MockedFunction<typeof fetch>;
347
- /**
348
- * Mock an RPC error response
349
- *
350
- * @param message - Error message
351
- * @param code - Optional error code
352
- * @returns The mocked fetch function
353
- */
354
- declare function mockRpcError(message: string, code?: string): vitest.MockedFunction<typeof fetch>;
355
- /**
356
- * Mock multiple RPC responses in sequence
357
- *
358
- * Useful for testing retry logic or sequential calls.
359
- *
360
- * @param responses - Array of values or errors to return
361
- * @returns The mocked fetch function
362
- */
363
- declare function mockRpcResponses(responses: Array<{
364
- success: true;
365
- value: unknown;
366
- } | {
367
- success: false;
368
- message: string;
369
- }>): void;
370
- /**
371
- * Legacy alias for fixtures.thing()
372
- * @deprecated Use fixtures.thing() instead
373
- */
374
- declare function createMockThing(overrides?: Partial<Thing>): Thing;
375
- /**
376
- * Legacy alias for fixtures.thingQueryResult()
377
- * @deprecated Use fixtures.thingQueryResult() instead
378
- */
379
- declare function createMockThingQueryResult(things?: Thing[], pagination?: {
380
- page?: number;
381
- perPage?: number;
382
- total?: number;
383
- totalPages?: number;
384
- }): ThingQueryResult;
385
-
386
- /**
387
- * Backwards-compatible wrapper creator
388
- *
389
- * Returns just the wrapper function (not the full object from createTestWrapper).
390
- * This maintains compatibility with existing tests that use:
391
- * { wrapper: createWrapper() }
392
- *
393
- * @deprecated Use createTestWrapper() for new code
394
- */
395
- declare function createWrapper(options?: TestWrapperOptions): React$1.FC<{
396
- children: React.ReactNode;
397
- }>;
398
-
399
- export { type DataProvider, type TestWrapperOptions, assertThing, assertThingQueryResult, createMockDataProvider, createMockThing, createMockThingQueryResult, createTestQueryClient, createTestWrapper, createWrapper, defaultTestConfig, fixtures, flushPromises, generateTestId, mockFetchError, mockFetchNetworkError, mockFetchSuccess, mockRpcError, mockRpcResponse, mockRpcResponses, renderHookWithProvider, renderWithProvider, resetIdCounter, waitForCondition };