@demokit-ai/trpc 0.0.1

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.
@@ -0,0 +1,369 @@
1
+ import { TRPCLink } from '@trpc/client';
2
+ import { AnyRouter, inferRouterInputs, inferRouterOutputs } from '@trpc/server';
3
+ import * as _trpc_server_unstable_core_do_not_import from '@trpc/server/unstable-core-do-not-import';
4
+ import { ReactNode } from 'react';
5
+
6
+ /**
7
+ * Context provided to tRPC fixture handlers
8
+ */
9
+ interface TRPCFixtureContext<TInput = unknown> {
10
+ /**
11
+ * The procedure path (e.g., 'user.get', 'post.list')
12
+ */
13
+ path: string;
14
+ /**
15
+ * The input passed to the procedure
16
+ */
17
+ input: TInput;
18
+ /**
19
+ * The type of procedure ('query' | 'mutation' | 'subscription')
20
+ */
21
+ type: 'query' | 'mutation' | 'subscription';
22
+ }
23
+ /**
24
+ * A fixture handler can be:
25
+ * - A static value (object, array, primitive)
26
+ * - A function that receives context and returns data
27
+ * - An async function for dynamic fixtures
28
+ */
29
+ type TRPCFixtureHandler<TInput = unknown, TOutput = unknown> = TOutput | ((context: TRPCFixtureContext<TInput>) => TOutput) | ((context: TRPCFixtureContext<TInput>) => Promise<TOutput>);
30
+ /**
31
+ * Infer input types from a router
32
+ */
33
+ type RouterInputs<TRouter extends AnyRouter> = inferRouterInputs<TRouter>;
34
+ /**
35
+ * Infer output types from a router
36
+ */
37
+ type RouterOutputs<TRouter extends AnyRouter> = inferRouterOutputs<TRouter>;
38
+ /**
39
+ * Deep partial type for fixture maps
40
+ */
41
+ type DeepPartial<T> = T extends object ? {
42
+ [P in keyof T]?: T[P] extends object ? T[P] extends (...args: unknown[]) => unknown ? TRPCFixtureHandler<Parameters<T[P]>[0] extends {
43
+ input: infer I;
44
+ } ? I : undefined, Awaited<ReturnType<T[P]>>> : DeepPartial<T[P]> : T[P];
45
+ } : T;
46
+ /**
47
+ * Flat fixture map using dot-notation paths
48
+ */
49
+ type FlatFixtureMap = Map<string, TRPCFixtureHandler>;
50
+ /**
51
+ * Object-based fixture map (easier to define, keys are procedure paths)
52
+ */
53
+ type FlatFixtureMapObject = Record<string, TRPCFixtureHandler>;
54
+ /**
55
+ * Options for creating a demo tRPC link
56
+ */
57
+ interface CreateDemoLinkOptions<TRouter extends AnyRouter = AnyRouter> {
58
+ /**
59
+ * Type-safe fixture definitions
60
+ * Can be a nested object matching router structure or a flat Map
61
+ */
62
+ fixtures?: NestedFixtures<TRouter> | FlatFixtureMap | FlatFixtureMapObject;
63
+ /**
64
+ * Function to check if demo mode is enabled
65
+ * @default () => false
66
+ */
67
+ isEnabled?: () => boolean;
68
+ /**
69
+ * Delay in ms before returning fixture data (simulates network latency)
70
+ * @default 0
71
+ */
72
+ delay?: number;
73
+ /**
74
+ * Only intercept these procedure paths (dot notation)
75
+ * If not provided, intercepts all matching procedures
76
+ * @example ['user.list', 'user.get']
77
+ */
78
+ include?: string[];
79
+ /**
80
+ * Exclude these procedure paths from interception
81
+ * Takes precedence over include
82
+ * @example ['auth.login']
83
+ */
84
+ exclude?: string[];
85
+ /**
86
+ * Called when no fixture is found for a procedure
87
+ */
88
+ onMissing?: (path: string, input: unknown) => void;
89
+ }
90
+ /**
91
+ * Result of fixture matching
92
+ */
93
+ interface FixtureMatchResult<TOutput = unknown> {
94
+ /**
95
+ * Whether a fixture was found
96
+ */
97
+ matched: boolean;
98
+ /**
99
+ * The fixture handler (if found)
100
+ */
101
+ handler?: TRPCFixtureHandler<unknown, TOutput>;
102
+ /**
103
+ * The matched procedure path
104
+ */
105
+ path: string;
106
+ }
107
+ /**
108
+ * Type for nested fixture structure matching router
109
+ */
110
+ type NestedFixtures<TRouter extends AnyRouter> = DeepPartial<TRouter>;
111
+ /**
112
+ * Configuration for DemoTRPCProvider
113
+ */
114
+ interface DemoTRPCProviderConfig<TRouter extends AnyRouter = AnyRouter> {
115
+ /**
116
+ * Type-safe fixture definitions
117
+ */
118
+ fixtures?: NestedFixtures<TRouter> | FlatFixtureMap | FlatFixtureMapObject;
119
+ /**
120
+ * Whether demo mode is enabled
121
+ */
122
+ enabled?: boolean;
123
+ /**
124
+ * Delay in ms before returning fixture data
125
+ * @default 0
126
+ */
127
+ delay?: number;
128
+ /**
129
+ * Procedure paths to include
130
+ */
131
+ include?: string[];
132
+ /**
133
+ * Procedure paths to exclude
134
+ */
135
+ exclude?: string[];
136
+ }
137
+ /**
138
+ * Props for DemoTRPCProvider
139
+ */
140
+ interface DemoTRPCProviderProps<TRouter extends AnyRouter = AnyRouter> extends DemoTRPCProviderConfig<TRouter> {
141
+ /**
142
+ * Child components
143
+ */
144
+ children: ReactNode;
145
+ }
146
+ /**
147
+ * State returned by useDemoTRPC hook
148
+ */
149
+ interface DemoTRPCState {
150
+ /**
151
+ * Whether demo mode is enabled
152
+ */
153
+ isDemoMode: boolean;
154
+ /**
155
+ * Set a fixture for a specific procedure path
156
+ */
157
+ setFixture: (path: string, handler: TRPCFixtureHandler) => void;
158
+ /**
159
+ * Remove a fixture
160
+ */
161
+ removeFixture: (path: string) => void;
162
+ /**
163
+ * Get all registered fixtures
164
+ */
165
+ getFixtures: () => FlatFixtureMap;
166
+ }
167
+
168
+ /**
169
+ * Create a demo-aware tRPC link
170
+ *
171
+ * This link intercepts tRPC procedure calls when demo mode is enabled
172
+ * and returns fixture data instead of making real API calls.
173
+ *
174
+ * The demo link should be placed before the terminating link (like httpBatchLink)
175
+ * in your link chain.
176
+ *
177
+ * @example
178
+ * import { createTRPCClient, httpBatchLink } from '@trpc/client'
179
+ * import { createDemoLink } from '@demokit-ai/trpc'
180
+ *
181
+ * // Simple usage with fixtures
182
+ * const client = createTRPCClient<AppRouter>({
183
+ * links: [
184
+ * createDemoLink({
185
+ * fixtures: {
186
+ * user: {
187
+ * list: () => [{ id: '1', name: 'Demo User' }],
188
+ * get: ({ input }) => ({ id: input.id, name: 'Demo User' }),
189
+ * },
190
+ * },
191
+ * isEnabled: () => localStorage.getItem('demoMode') === 'true',
192
+ * }),
193
+ * httpBatchLink({ url: '/api/trpc' }),
194
+ * ],
195
+ * })
196
+ *
197
+ * @example
198
+ * // With include/exclude filtering
199
+ * createDemoLink({
200
+ * fixtures: myFixtures,
201
+ * include: ['user.*', 'post.list'], // Only intercept user.* and post.list
202
+ * exclude: ['user.delete'], // Never intercept user.delete
203
+ * delay: 200, // Simulate 200ms network latency
204
+ * onMissing: (path, input) => {
205
+ * console.warn(`No fixture for: ${path}`)
206
+ * },
207
+ * })
208
+ */
209
+ declare function createDemoLink<TRouter extends AnyRouter = AnyRouter>(options?: CreateDemoLinkOptions<TRouter>): TRPCLink<TRouter>;
210
+ /**
211
+ * Create a demo link with state management
212
+ *
213
+ * Returns the link along with controls to enable/disable demo mode
214
+ * and manage fixtures at runtime.
215
+ *
216
+ * @example
217
+ * const { link, enable, disable, isEnabled, setFixture, removeFixture } =
218
+ * createDemoLinkWithState({
219
+ * fixtures: myFixtures,
220
+ * })
221
+ *
222
+ * const client = createTRPCClient<AppRouter>({
223
+ * links: [link, httpBatchLink({ url: '/api/trpc' })],
224
+ * })
225
+ *
226
+ * // Later...
227
+ * enable() // Turn on demo mode
228
+ * disable() // Turn off demo mode
229
+ *
230
+ * // Add fixture at runtime
231
+ * setFixture('user.get', ({ input }) => ({ id: input.id, name: 'Runtime User' }))
232
+ */
233
+ declare function createDemoLinkWithState<TRouter extends AnyRouter = AnyRouter>(options?: Omit<CreateDemoLinkOptions<TRouter>, 'isEnabled'> & {
234
+ /**
235
+ * Initial enabled state
236
+ * @default false
237
+ */
238
+ enabled?: boolean;
239
+ }): {
240
+ /**
241
+ * The tRPC link to use in your client
242
+ */
243
+ link: TRPCLink<TRouter>;
244
+ /**
245
+ * Enable demo mode
246
+ */
247
+ enable: () => void;
248
+ /**
249
+ * Disable demo mode
250
+ */
251
+ disable: () => void;
252
+ /**
253
+ * Check if demo mode is enabled
254
+ */
255
+ isEnabled: () => boolean;
256
+ /**
257
+ * Toggle demo mode
258
+ */
259
+ toggle: () => boolean;
260
+ /**
261
+ * Set or update a fixture
262
+ */
263
+ setFixture: (path: string, handler: TRPCFixtureHandler) => void;
264
+ /**
265
+ * Remove a fixture
266
+ */
267
+ removeFixture: (path: string) => void;
268
+ /**
269
+ * Get all fixtures
270
+ */
271
+ getFixtures: () => FlatFixtureMap;
272
+ /**
273
+ * Clear all fixtures
274
+ */
275
+ clearFixtures: () => void;
276
+ };
277
+ type DemoLinkWithState<TRouter extends AnyRouter = AnyRouter> = ReturnType<typeof createDemoLinkWithState<TRouter>>;
278
+
279
+ /**
280
+ * Type helper to create fixture handlers with full type inference
281
+ *
282
+ * This helper infers input/output types from your router definition,
283
+ * providing autocomplete and type checking for fixture definitions.
284
+ *
285
+ * @example
286
+ * import { defineTRPCFixtures } from '@demokit-ai/trpc'
287
+ * import type { AppRouter } from '../server/router'
288
+ *
289
+ * // Nested structure matching your router
290
+ * const fixtures = defineTRPCFixtures<AppRouter>()({
291
+ * user: {
292
+ * list: () => [
293
+ * { id: '1', name: 'Demo User', email: 'demo@example.com' }
294
+ * ],
295
+ * get: ({ input }) => ({
296
+ * id: input.id,
297
+ * name: 'Demo User',
298
+ * email: 'demo@example.com',
299
+ * }),
300
+ * create: async ({ input }) => ({
301
+ * id: crypto.randomUUID(),
302
+ * ...input,
303
+ * createdAt: new Date(),
304
+ * }),
305
+ * },
306
+ * post: {
307
+ * list: () => [],
308
+ * },
309
+ * })
310
+ */
311
+ declare function defineTRPCFixtures<TRouter extends AnyRouter>(): <T extends { [K in keyof TRouter["_def"]["record"]]?: (_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K] extends object ? _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K] extends object ? keyof _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K] extends never ? TRPCFixtureHandler<_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K], _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K]> : { [K_2 in keyof _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K] & keyof _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K]]?: (_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2] extends object ? _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2] extends object ? keyof _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2] extends never ? TRPCFixtureHandler<_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2], _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2]> : { [K_3 in keyof _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2] & keyof _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2]]?: (_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3] extends object ? _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3] extends object ? keyof _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3] extends never ? TRPCFixtureHandler<_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3], _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3]> : { [K_4 in keyof _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3] & keyof _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3]]?: (_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4] extends object ? _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4] extends object ? keyof _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4] extends never ? TRPCFixtureHandler<_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4], _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4]> : { [K_5 in keyof _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4] & keyof _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4]]?: (_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5] extends object ? _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5] extends object ? keyof _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5] extends never ? TRPCFixtureHandler<_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5], _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5]> : { [K_6 in keyof _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5] & keyof _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5]]?: (_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6] extends object ? _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6] extends object ? keyof _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6] extends never ? TRPCFixtureHandler<_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6], _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6]> : { [K_7 in keyof _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6] & keyof _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6]]?: (_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7] extends object ? _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7] extends object ? keyof _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7] extends never ? TRPCFixtureHandler<_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7], _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7]> : { [K_8 in keyof _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7] & keyof _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7]]?: (_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8] extends object ? _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8] extends object ? keyof _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8] extends never ? TRPCFixtureHandler<_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8], _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8]> : { [K_9 in keyof _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8] & keyof _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8]]?: (_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9] extends object ? _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9] extends object ? keyof _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9] extends never ? TRPCFixtureHandler<_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9], _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9]> : { [K_10 in keyof _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9] & keyof _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9]]?: (_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9][K_10] extends object ? _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9][K_10] extends object ? keyof _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9][K_10] extends never ? TRPCFixtureHandler<_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9][K_10], _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9][K_10]> : { [K_11 in keyof _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9][K_10] & keyof _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9][K_10]]?: (_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9][K_10][K_11] extends object ? _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9][K_10][K_11] extends object ? keyof _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9][K_10][K_11] extends never ? TRPCFixtureHandler<_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9][K_10][K_11], _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9][K_10][K_11]> : /*elided*/ any : TRPCFixtureHandler<_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9][K_10][K_11], _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9][K_10][K_11]> : TRPCFixtureHandler<_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9][K_10][K_11], _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9][K_10][K_11]>) | undefined; } : TRPCFixtureHandler<_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9][K_10], _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9][K_10]> : TRPCFixtureHandler<_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9][K_10], _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9][K_10]>) | undefined; } : TRPCFixtureHandler<_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9], _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9]> : TRPCFixtureHandler<_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9], _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9]>) | undefined; } : TRPCFixtureHandler<_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8], _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8]> : TRPCFixtureHandler<_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8], _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7][K_8]>) | undefined; } : TRPCFixtureHandler<_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7], _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7]> : TRPCFixtureHandler<_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7], _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6][K_7]>) | undefined; } : TRPCFixtureHandler<_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6], _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6]> : TRPCFixtureHandler<_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6], _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5][K_6]>) | undefined; } : TRPCFixtureHandler<_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5], _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5]> : TRPCFixtureHandler<_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5], _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4][K_5]>) | undefined; } : TRPCFixtureHandler<_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4], _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4]> : TRPCFixtureHandler<_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4], _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3][K_4]>) | undefined; } : TRPCFixtureHandler<_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3], _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3]> : TRPCFixtureHandler<_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3], _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2][K_3]>) | undefined; } : TRPCFixtureHandler<_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2], _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2]> : TRPCFixtureHandler<_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2], _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K][K_2]>) | undefined; } : TRPCFixtureHandler<_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K], _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K]> : TRPCFixtureHandler<_trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"input", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K], _trpc_server_unstable_core_do_not_import.GetInferenceHelpers<"output", TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>[K]>) | undefined; }>(fixtures: T) => T;
312
+ /**
313
+ * Alternative: define fixtures using flat dot-notation paths
314
+ *
315
+ * Useful when you want to define fixtures independently of router structure.
316
+ *
317
+ * @example
318
+ * const fixtures = defineFixtureMap<AppRouter>({
319
+ * 'user.list': () => [{ id: '1', name: 'Demo' }],
320
+ * 'user.get': ({ input }) => ({ id: input.id, name: 'Demo' }),
321
+ * })
322
+ */
323
+ declare function defineFixtureMap<TRouter extends AnyRouter>(fixtures: FlatFixtureRecord<TRouter>): FlatFixtureMap;
324
+ /**
325
+ * Type for flat fixture map with path-based keys
326
+ */
327
+ type FlatFixtureRecord<TRouter extends AnyRouter> = {
328
+ [K in ProcedurePaths<TRouter>]?: TRPCFixtureHandler<PathInput<TRouter, K>, PathOutput<TRouter, K>>;
329
+ };
330
+ /**
331
+ * Extract all procedure paths from a router using dot notation
332
+ */
333
+ type ProcedurePaths<TRouter extends AnyRouter> = inferRouterInputs<TRouter> extends infer TIn ? TIn extends object ? FlattenPaths<TIn> : never : never;
334
+ /**
335
+ * Flatten nested object keys to dot notation
336
+ */
337
+ type FlattenPaths<T, Prefix extends string = ''> = T extends object ? {
338
+ [K in keyof T]: K extends string ? T[K] extends object ? keyof T[K] extends never ? `${Prefix}${K}` : FlattenPaths<T[K], `${Prefix}${K}.`> : `${Prefix}${K}` : never;
339
+ }[keyof T] : never;
340
+ /**
341
+ * Get input type for a specific procedure path
342
+ */
343
+ type PathInput<TRouter extends AnyRouter, Path extends string> = Path extends `${infer First}.${infer Rest}` ? inferRouterInputs<TRouter>[First] extends object ? PathInput<inferRouterInputs<TRouter>[First] extends AnyRouter ? inferRouterInputs<TRouter>[First] : never, Rest> : never : inferRouterInputs<TRouter>[Path];
344
+ /**
345
+ * Get output type for a specific procedure path
346
+ */
347
+ type PathOutput<TRouter extends AnyRouter, Path extends string> = Path extends `${infer First}.${infer Rest}` ? inferRouterOutputs<TRouter>[First] extends object ? PathOutput<inferRouterOutputs<TRouter>[First] extends AnyRouter ? inferRouterOutputs<TRouter>[First] : never, Rest> : never : inferRouterOutputs<TRouter>[Path];
348
+ /**
349
+ * Create a fixture handler with explicit types
350
+ *
351
+ * Useful when you need to define a fixture outside of the main fixture object.
352
+ *
353
+ * @example
354
+ * const getUserFixture = createFixtureHandler<{ id: string }, User>(
355
+ * ({ input }) => ({
356
+ * id: input.id,
357
+ * name: 'Demo User',
358
+ * })
359
+ * )
360
+ */
361
+ declare function createFixtureHandler<TInput, TOutput>(handler: TRPCFixtureHandler<TInput, TOutput>): TRPCFixtureHandler<TInput, TOutput>;
362
+ /**
363
+ * Normalize fixture definitions to a flat Map
364
+ *
365
+ * Converts nested fixture objects to a flat map with dot-notation paths.
366
+ */
367
+ declare function normalizeFixtures(fixtures: Record<string, unknown> | FlatFixtureMap | undefined): FlatFixtureMap;
368
+
369
+ export { type CreateDemoLinkOptions as C, type DemoLinkWithState as D, type FlatFixtureMap as F, type NestedFixtures as N, type RouterInputs as R, type TRPCFixtureContext as T, type FixtureMatchResult as a, createDemoLinkWithState as b, createDemoLink as c, defineTRPCFixtures as d, defineFixtureMap as e, createFixtureHandler as f, type TRPCFixtureHandler as g, type RouterOutputs as h, type FlatFixtureMapObject as i, type DemoTRPCProviderConfig as j, type DemoTRPCProviderProps as k, type DemoTRPCState as l, normalizeFixtures as n };