@donkeylabs/cli 1.1.4 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@donkeylabs/cli",
3
- "version": "1.1.4",
3
+ "version": "1.1.7",
4
4
  "type": "module",
5
5
  "description": "CLI for @donkeylabs/server - project scaffolding and code generation",
6
6
  "main": "./src/index.ts",
@@ -1,202 +1,185 @@
1
- // Auto-generated by @donkeylabs/server
1
+ // Auto-generated by donkeylabs generate
2
2
  // DO NOT EDIT MANUALLY
3
3
 
4
- import { UnifiedApiClientBase, type ClientOptions } from "@donkeylabs/adapter-sveltekit/client";
4
+ import { UnifiedApiClientBase, SSEConnection, type ClientOptions } from "@donkeylabs/adapter-sveltekit/client";
5
5
 
6
6
  // Utility type that forces TypeScript to expand types on hover
7
7
  type Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never;
8
8
 
9
- /**
10
- * Handler interface for implementing route handlers in model classes.
11
- * @example
12
- * class CounterModel implements Handler<Routes.Counter.get> {
13
- * handle(input: Routes.Counter.get.Input): Routes.Counter.get.Output {
14
- * return { count: 0 };
15
- * }
16
- * }
17
- */
18
- export interface Handler<T extends { Input: any; Output: any }> {
19
- handle(input: T["Input"]): T["Output"] | Promise<T["Output"]>;
20
- }
21
-
22
- // Re-export server context for model classes
23
- export { type ServerContext as AppContext } from "@donkeylabs/server";
24
-
25
9
  // ============================================
26
10
  // Route Types
27
11
  // ============================================
28
12
 
29
13
  export namespace Routes {
30
- export namespace Api {
31
- export namespace Counter {
32
- export namespace Get {
33
- export type Input = Expand<Record<string, never>>;
34
- export type Output = Expand<{
14
+ export namespace Counter {
15
+ export namespace Get {
16
+ export type Input = Expand<Record<string, never>>;
17
+ export type Output = Expand<{
35
18
  count: number;
36
19
  }>;
37
- }
38
- export type Get = { Input: Get.Input; Output: Get.Output };
20
+ }
21
+ export type Get = { Input: Get.Input; Output: Get.Output };
39
22
 
40
- export namespace Increment {
41
- export type Input = Expand<Record<string, never>>;
42
- export type Output = Expand<{
23
+ export namespace Increment {
24
+ export type Input = Expand<Record<string, never>>;
25
+ export type Output = Expand<{
43
26
  count: number;
44
27
  }>;
45
- }
46
- export type Increment = { Input: Increment.Input; Output: Increment.Output };
28
+ }
29
+ export type Increment = { Input: Increment.Input; Output: Increment.Output };
47
30
 
48
- export namespace Decrement {
49
- export type Input = Expand<Record<string, never>>;
50
- export type Output = Expand<{
31
+ export namespace Decrement {
32
+ export type Input = Expand<Record<string, never>>;
33
+ export type Output = Expand<{
51
34
  count: number;
52
35
  }>;
53
- }
54
- export type Decrement = { Input: Decrement.Input; Output: Decrement.Output };
36
+ }
37
+ export type Decrement = { Input: Decrement.Input; Output: Decrement.Output };
55
38
 
56
- export namespace Reset {
57
- export type Input = Expand<Record<string, never>>;
58
- export type Output = Expand<{
39
+ export namespace Reset {
40
+ export type Input = Expand<Record<string, never>>;
41
+ export type Output = Expand<{
59
42
  count: number;
60
43
  }>;
61
- }
62
- export type Reset = { Input: Reset.Input; Output: Reset.Output };
63
44
  }
45
+ export type Reset = { Input: Reset.Input; Output: Reset.Output };
46
+ }
64
47
 
65
- export namespace Cache {
66
- export namespace Set {
67
- export type Input = Expand<{
48
+ export namespace Cache {
49
+ export namespace Set {
50
+ export type Input = Expand<{
68
51
  key: string;
69
52
  value: any;
70
53
  ttl?: number;
71
54
  }>;
72
- export type Output = Expand<{
55
+ export type Output = Expand<{
73
56
  success: boolean;
74
57
  }>;
75
- }
76
- export type Set = { Input: Set.Input; Output: Set.Output };
58
+ }
59
+ export type Set = { Input: Set.Input; Output: Set.Output };
77
60
 
78
- export namespace Get {
79
- export type Input = Expand<{
61
+ export namespace Get {
62
+ export type Input = Expand<{
80
63
  key: string;
81
64
  }>;
82
- export type Output = Expand<{
65
+ export type Output = Expand<{
83
66
  value?: any;
84
67
  exists: boolean;
85
68
  }>;
86
- }
87
- export type Get = { Input: Get.Input; Output: Get.Output };
69
+ }
70
+ export type Get = { Input: Get.Input; Output: Get.Output };
88
71
 
89
- export namespace Delete {
90
- export type Input = Expand<{
72
+ export namespace Delete {
73
+ export type Input = Expand<{
91
74
  key: string;
92
75
  }>;
93
- export type Output = Expand<{
76
+ export type Output = Expand<{
94
77
  success: boolean;
95
78
  }>;
96
- }
97
- export type Delete = { Input: Delete.Input; Output: Delete.Output };
79
+ }
80
+ export type Delete = { Input: Delete.Input; Output: Delete.Output };
98
81
 
99
- export namespace Keys {
100
- export type Input = Expand<Record<string, never>>;
101
- export type Output = Expand<{
82
+ export namespace Keys {
83
+ export type Input = Expand<Record<string, never>>;
84
+ export type Output = Expand<{
102
85
  keys: string[];
103
86
  size: number;
104
87
  }>;
105
- }
106
- export type Keys = { Input: Keys.Input; Output: Keys.Output };
107
88
  }
89
+ export type Keys = { Input: Keys.Input; Output: Keys.Output };
90
+ }
108
91
 
109
- export namespace Sse {
110
- export namespace Broadcast {
111
- export type Input = Expand<{
92
+ export namespace Sse {
93
+ export namespace Broadcast {
94
+ export type Input = Expand<{
112
95
  channel: string;
113
96
  event: string;
114
97
  data: any;
115
98
  }>;
116
- export type Output = Expand<{
99
+ export type Output = Expand<{
117
100
  success: boolean;
118
101
  }>;
119
- }
120
- export type Broadcast = { Input: Broadcast.Input; Output: Broadcast.Output };
102
+ }
103
+ export type Broadcast = { Input: Broadcast.Input; Output: Broadcast.Output };
121
104
 
122
- export namespace Clients {
123
- export type Input = Expand<Record<string, never>>;
124
- export type Output = Expand<{
105
+ export namespace Clients {
106
+ export type Input = Expand<Record<string, never>>;
107
+ export type Output = Expand<{
125
108
  total: number;
126
109
  byChannel: number;
127
110
  }>;
128
- }
129
- export type Clients = { Input: Clients.Input; Output: Clients.Output };
130
111
  }
112
+ export type Clients = { Input: Clients.Input; Output: Clients.Output };
113
+ }
131
114
 
132
- export namespace Jobs {
133
- export namespace Enqueue {
134
- export type Input = Expand<{
115
+ export namespace Jobs {
116
+ export namespace Enqueue {
117
+ export type Input = Expand<{
135
118
  name: string;
136
119
  data?: Record<string, any>;
137
120
  delay?: number;
138
121
  }>;
139
- export type Output = Expand<{
122
+ export type Output = Expand<{
140
123
  jobId: string;
141
124
  }>;
142
- }
143
- export type Enqueue = { Input: Enqueue.Input; Output: Enqueue.Output };
125
+ }
126
+ export type Enqueue = { Input: Enqueue.Input; Output: Enqueue.Output };
144
127
 
145
- export namespace Stats {
146
- export type Input = Expand<Record<string, never>>;
147
- export type Output = Expand<{
128
+ export namespace Stats {
129
+ export type Input = Expand<Record<string, never>>;
130
+ export type Output = Expand<{
148
131
  pending: number;
149
132
  running: number;
150
133
  completed: number;
151
134
  }>;
152
- }
153
- export type Stats = { Input: Stats.Input; Output: Stats.Output };
154
135
  }
136
+ export type Stats = { Input: Stats.Input; Output: Stats.Output };
137
+ }
155
138
 
156
- export namespace Events {
157
- export namespace Emit {
158
- export type Input = Expand<{
139
+ export namespace Events {
140
+ export namespace Emit {
141
+ export type Input = Expand<{
159
142
  event: string;
160
143
  data?: Record<string, any>;
161
144
  }>;
162
- export type Output = Expand<{
145
+ export type Output = Expand<{
163
146
  success: boolean;
164
147
  }>;
165
- }
166
- export type Emit = { Input: Emit.Input; Output: Emit.Output };
167
148
  }
149
+ export type Emit = { Input: Emit.Input; Output: Emit.Output };
150
+ }
168
151
 
169
- export namespace Ratelimit {
170
- export namespace Check {
171
- export type Input = Expand<{
152
+ export namespace Ratelimit {
153
+ export namespace Check {
154
+ export type Input = Expand<{
172
155
  key: string;
173
156
  limit: number;
174
157
  window: number;
175
158
  }>;
176
- export type Output = Expand<{
159
+ export type Output = Expand<{
177
160
  allowed: boolean;
178
161
  remaining: number;
179
162
  limit: number;
180
163
  resetAt: Date;
181
164
  }>;
182
- }
183
- export type Check = { Input: Check.Input; Output: Check.Output };
165
+ }
166
+ export type Check = { Input: Check.Input; Output: Check.Output };
184
167
 
185
- export namespace Reset {
186
- export type Input = Expand<{
168
+ export namespace Reset {
169
+ export type Input = Expand<{
187
170
  key: string;
188
171
  }>;
189
- export type Output = Expand<{
172
+ export type Output = Expand<{
190
173
  success: boolean;
191
174
  }>;
192
- }
193
- export type Reset = { Input: Reset.Input; Output: Reset.Output };
194
175
  }
176
+ export type Reset = { Input: Reset.Input; Output: Reset.Output };
177
+ }
195
178
 
196
- export namespace Cron {
197
- export namespace List {
198
- export type Input = Expand<Record<string, never>>;
199
- export type Output = Expand<{
179
+ export namespace Cron {
180
+ export namespace List {
181
+ export type Input = Expand<Record<string, never>>;
182
+ export type Output = Expand<{
200
183
  tasks: {
201
184
  id: string;
202
185
  name: string;
@@ -206,13 +189,13 @@ export namespace Routes {
206
189
  nextRun?: string;
207
190
  }[];
208
191
  }>;
209
- }
210
- export type List = { Input: List.Input; Output: List.Output };
211
192
  }
193
+ export type List = { Input: List.Input; Output: List.Output };
194
+ }
212
195
 
213
- export namespace Workflow {
214
- export namespace Start {
215
- export type Input = Expand<{
196
+ export namespace Workflow {
197
+ export namespace Start {
198
+ export type Input = Expand<{
216
199
  orderId: string;
217
200
  items: {
218
201
  name: string;
@@ -220,17 +203,17 @@ export namespace Routes {
220
203
  }[];
221
204
  customerEmail: string;
222
205
  }>;
223
- export type Output = Expand<{
206
+ export type Output = Expand<{
224
207
  instanceId: string;
225
208
  }>;
226
- }
227
- export type Start = { Input: Start.Input; Output: Start.Output };
209
+ }
210
+ export type Start = { Input: Start.Input; Output: Start.Output };
228
211
 
229
- export namespace Status {
230
- export type Input = Expand<{
212
+ export namespace Status {
213
+ export type Input = Expand<{
231
214
  instanceId: string;
232
215
  }>;
233
- export type Output = Expand<{
216
+ export type Output = Expand<{
234
217
  id: string;
235
218
  status: string;
236
219
  currentStep?: string;
@@ -242,14 +225,14 @@ export namespace Routes {
242
225
  startedAt?: string;
243
226
  completedAt?: string;
244
227
  } | null>;
245
- }
246
- export type Status = { Input: Status.Input; Output: Status.Output };
228
+ }
229
+ export type Status = { Input: Status.Input; Output: Status.Output };
247
230
 
248
- export namespace List {
249
- export type Input = Expand<{
231
+ export namespace List {
232
+ export type Input = Expand<{
250
233
  status?: string;
251
234
  }>;
252
- export type Output = Expand<{
235
+ export type Output = Expand<{
253
236
  instances: {
254
237
  id: string;
255
238
  status: string;
@@ -258,19 +241,116 @@ export namespace Routes {
258
241
  completedAt?: string;
259
242
  }[];
260
243
  }>;
261
- }
262
- export type List = { Input: List.Input; Output: List.Output };
244
+ }
245
+ export type List = { Input: List.Input; Output: List.Output };
263
246
 
264
- export namespace Cancel {
265
- export type Input = Expand<{
247
+ export namespace Cancel {
248
+ export type Input = Expand<{
266
249
  instanceId: string;
267
250
  }>;
268
- export type Output = Expand<{
251
+ export type Output = Expand<{
252
+ success: boolean;
253
+ }>;
254
+ }
255
+ export type Cancel = { Input: Cancel.Input; Output: Cancel.Output };
256
+ }
257
+
258
+ export namespace Audit {
259
+ export namespace Log {
260
+ export type Input = Expand<{
261
+ action: string;
262
+ resource: string;
263
+ resourceId?: string;
264
+ metadata?: Record<string, any>;
265
+ }>;
266
+ export type Output = Expand<{
267
+ id: string;
268
+ }>;
269
+ }
270
+ export type Log = { Input: Log.Input; Output: Log.Output };
271
+
272
+ export namespace Query {
273
+ export type Input = Expand<{
274
+ action?: string;
275
+ resource?: string;
276
+ limit: number;
277
+ }>;
278
+ export type Output = Expand<{
279
+ entries: {
280
+ id: string;
281
+ timestamp: string;
282
+ action: string;
283
+ actor: string;
284
+ resource: string;
285
+ resourceId?: string;
286
+ metadata?: Record<string, any>;
287
+ }[];
288
+ }>;
289
+ }
290
+ export type Query = { Input: Query.Input; Output: Query.Output };
291
+
292
+ export namespace ByResource {
293
+ export type Input = Expand<{
294
+ resource: string;
295
+ resourceId: string;
296
+ }>;
297
+ export type Output = Expand<{
298
+ entries: {
299
+ id: string;
300
+ timestamp: string;
301
+ action: string;
302
+ actor: string;
303
+ metadata?: Record<string, any>;
304
+ }[];
305
+ }>;
306
+ }
307
+ export type ByResource = { Input: ByResource.Input; Output: ByResource.Output };
308
+ }
309
+
310
+ export namespace Websocket {
311
+ export namespace Broadcast {
312
+ export type Input = Expand<{
313
+ channel: string;
314
+ event: string;
315
+ data: any;
316
+ }>;
317
+ export type Output = Expand<{
269
318
  success: boolean;
270
319
  }>;
271
- }
272
- export type Cancel = { Input: Cancel.Input; Output: Cancel.Output };
273
320
  }
321
+ export type Broadcast = { Input: Broadcast.Input; Output: Broadcast.Output };
322
+
323
+ export namespace BroadcastAll {
324
+ export type Input = Expand<{
325
+ event: string;
326
+ data: any;
327
+ }>;
328
+ export type Output = Expand<{
329
+ success: boolean;
330
+ }>;
331
+ }
332
+ export type BroadcastAll = { Input: BroadcastAll.Input; Output: BroadcastAll.Output };
333
+
334
+ export namespace Clients {
335
+ export type Input = Expand<{
336
+ channel?: string;
337
+ }>;
338
+ export type Output = Expand<{
339
+ count: number;
340
+ clients: string[];
341
+ }>;
342
+ }
343
+ export type Clients = { Input: Clients.Input; Output: Clients.Output };
344
+
345
+ export namespace ClientCount {
346
+ export type Input = Expand<{
347
+ channel?: string;
348
+ }>;
349
+ export type Output = Expand<{
350
+ count: number;
351
+ }>;
352
+ }
353
+ export type ClientCount = { Input: ClientCount.Input; Output: ClientCount.Output };
274
354
  }
275
355
  }
276
356
 
@@ -283,48 +363,90 @@ export class ApiClient extends UnifiedApiClientBase {
283
363
  super(options);
284
364
  }
285
365
 
286
- api = {
287
- counter: {
288
- get: (input: Routes.Api.Counter.Get.Input): Promise<Routes.Api.Counter.Get.Output> => this.request("api.counter.get", input),
289
- increment: (input: Routes.Api.Counter.Increment.Input): Promise<Routes.Api.Counter.Increment.Output> => this.request("api.counter.increment", input),
290
- decrement: (input: Routes.Api.Counter.Decrement.Input): Promise<Routes.Api.Counter.Decrement.Output> => this.request("api.counter.decrement", input),
291
- reset: (input: Routes.Api.Counter.Reset.Input): Promise<Routes.Api.Counter.Reset.Output> => this.request("api.counter.reset", input)
292
- },
293
- cache: {
294
- set: (input: Routes.Api.Cache.Set.Input): Promise<Routes.Api.Cache.Set.Output> => this.request("api.cache.set", input),
295
- get: (input: Routes.Api.Cache.Get.Input): Promise<Routes.Api.Cache.Get.Output> => this.request("api.cache.get", input),
296
- delete: (input: Routes.Api.Cache.Delete.Input): Promise<Routes.Api.Cache.Delete.Output> => this.request("api.cache.delete", input),
297
- keys: (input: Routes.Api.Cache.Keys.Input): Promise<Routes.Api.Cache.Keys.Output> => this.request("api.cache.keys", input)
298
- },
299
- sse: {
300
- broadcast: (input: Routes.Api.Sse.Broadcast.Input): Promise<Routes.Api.Sse.Broadcast.Output> => this.request("api.sse.broadcast", input),
301
- clients: (input: Routes.Api.Sse.Clients.Input): Promise<Routes.Api.Sse.Clients.Output> => this.request("api.sse.clients", input)
302
- },
303
- jobs: {
304
- enqueue: (input: Routes.Api.Jobs.Enqueue.Input): Promise<Routes.Api.Jobs.Enqueue.Output> => this.request("api.jobs.enqueue", input),
305
- stats: (input: Routes.Api.Jobs.Stats.Input): Promise<Routes.Api.Jobs.Stats.Output> => this.request("api.jobs.stats", input)
306
- },
307
- events: {
308
- emit: (input: Routes.Api.Events.Emit.Input): Promise<Routes.Api.Events.Emit.Output> => this.request("api.events.emit", input)
309
- },
310
- ratelimit: {
311
- check: (input: Routes.Api.Ratelimit.Check.Input): Promise<Routes.Api.Ratelimit.Check.Output> => this.request("api.ratelimit.check", input),
312
- reset: (input: Routes.Api.Ratelimit.Reset.Input): Promise<Routes.Api.Ratelimit.Reset.Output> => this.request("api.ratelimit.reset", input)
313
- },
314
- cron: {
315
- list: (input: Routes.Api.Cron.List.Input): Promise<Routes.Api.Cron.List.Output> => this.request("api.cron.list", input)
316
- },
317
- workflow: {
318
- start: (input: Routes.Api.Workflow.Start.Input): Promise<Routes.Api.Workflow.Start.Output> => this.request("api.workflow.start", input),
319
- status: (input: Routes.Api.Workflow.Status.Input): Promise<Routes.Api.Workflow.Status.Output> => this.request("api.workflow.status", input),
320
- list: (input: Routes.Api.Workflow.List.Input): Promise<Routes.Api.Workflow.List.Output> => this.request("api.workflow.list", input),
321
- cancel: (input: Routes.Api.Workflow.Cancel.Input): Promise<Routes.Api.Workflow.Cancel.Output> => this.request("api.workflow.cancel", input)
322
- }
366
+ counter = {
367
+ get: (input: Routes.Counter.Get.Input): Promise<Routes.Counter.Get.Output> => this.request("api.counter.get", input),
368
+ increment: (input: Routes.Counter.Increment.Input): Promise<Routes.Counter.Increment.Output> => this.request("api.counter.increment", input),
369
+ decrement: (input: Routes.Counter.Decrement.Input): Promise<Routes.Counter.Decrement.Output> => this.request("api.counter.decrement", input),
370
+ reset: (input: Routes.Counter.Reset.Input): Promise<Routes.Counter.Reset.Output> => this.request("api.counter.reset", input)
371
+ };
372
+
373
+ cache = {
374
+ set: (input: Routes.Cache.Set.Input): Promise<Routes.Cache.Set.Output> => this.request("api.cache.set", input),
375
+ get: (input: Routes.Cache.Get.Input): Promise<Routes.Cache.Get.Output> => this.request("api.cache.get", input),
376
+ delete: (input: Routes.Cache.Delete.Input): Promise<Routes.Cache.Delete.Output> => this.request("api.cache.delete", input),
377
+ keys: (input: Routes.Cache.Keys.Input): Promise<Routes.Cache.Keys.Output> => this.request("api.cache.keys", input)
378
+ };
379
+
380
+ sse = {
381
+ broadcast: (input: Routes.Sse.Broadcast.Input): Promise<Routes.Sse.Broadcast.Output> => this.request("api.sse.broadcast", input),
382
+ clients: (input: Routes.Sse.Clients.Input): Promise<Routes.Sse.Clients.Output> => this.request("api.sse.clients", input)
383
+ };
384
+
385
+ jobs = {
386
+ enqueue: (input: Routes.Jobs.Enqueue.Input): Promise<Routes.Jobs.Enqueue.Output> => this.request("api.jobs.enqueue", input),
387
+ stats: (input: Routes.Jobs.Stats.Input): Promise<Routes.Jobs.Stats.Output> => this.request("api.jobs.stats", input)
388
+ };
389
+
390
+ events = {
391
+ emit: (input: Routes.Events.Emit.Input): Promise<Routes.Events.Emit.Output> => this.request("api.events.emit", input)
392
+ };
393
+
394
+ ratelimit = {
395
+ check: (input: Routes.Ratelimit.Check.Input): Promise<Routes.Ratelimit.Check.Output> => this.request("api.ratelimit.check", input),
396
+ reset: (input: Routes.Ratelimit.Reset.Input): Promise<Routes.Ratelimit.Reset.Output> => this.request("api.ratelimit.reset", input)
397
+ };
398
+
399
+ cron = {
400
+ list: (input: Routes.Cron.List.Input): Promise<Routes.Cron.List.Output> => this.request("api.cron.list", input)
401
+ };
402
+
403
+ workflow = {
404
+ start: (input: Routes.Workflow.Start.Input): Promise<Routes.Workflow.Start.Output> => this.request("api.workflow.start", input),
405
+ status: (input: Routes.Workflow.Status.Input): Promise<Routes.Workflow.Status.Output> => this.request("api.workflow.status", input),
406
+ list: (input: Routes.Workflow.List.Input): Promise<Routes.Workflow.List.Output> => this.request("api.workflow.list", input),
407
+ cancel: (input: Routes.Workflow.Cancel.Input): Promise<Routes.Workflow.Cancel.Output> => this.request("api.workflow.cancel", input)
408
+ };
409
+
410
+ audit = {
411
+ log: (input: Routes.Audit.Log.Input): Promise<Routes.Audit.Log.Output> => this.request("api.audit.log", input),
412
+ query: (input: Routes.Audit.Query.Input): Promise<Routes.Audit.Query.Output> => this.request("api.audit.query", input),
413
+ byResource: (input: Routes.Audit.ByResource.Input): Promise<Routes.Audit.ByResource.Output> => this.request("api.audit.byResource", input)
414
+ };
415
+
416
+ websocket = {
417
+ broadcast: (input: Routes.Websocket.Broadcast.Input): Promise<Routes.Websocket.Broadcast.Output> => this.request("api.websocket.broadcast", input),
418
+ broadcastAll: (input: Routes.Websocket.BroadcastAll.Input): Promise<Routes.Websocket.BroadcastAll.Output> => this.request("api.websocket.broadcastAll", input),
419
+ clients: (input: Routes.Websocket.Clients.Input): Promise<Routes.Websocket.Clients.Output> => this.request("api.websocket.clients", input),
420
+ clientCount: (input: Routes.Websocket.ClientCount.Input): Promise<Routes.Websocket.ClientCount.Output> => this.request("api.websocket.clientCount", input)
323
421
  };
324
422
  }
325
423
 
326
424
  /**
327
425
  * Create an API client instance
426
+ *
427
+ * @param options.locals - Pass SvelteKit locals for SSR direct calls (no HTTP overhead)
428
+ * @param options.baseUrl - Override the base URL for HTTP calls
429
+ *
430
+ * @example SSR usage in +page.server.ts:
431
+ * ```ts
432
+ * export const load = async ({ locals }) => {
433
+ * const api = createApi({ locals });
434
+ * const data = await api.myRoute.get({}); // Direct call, no HTTP!
435
+ * return { data };
436
+ * };
437
+ * ```
438
+ *
439
+ * @example Browser usage in +page.svelte:
440
+ * ```svelte
441
+ * <script>
442
+ * import { createApi } from '$lib/api';
443
+ * const api = createApi(); // HTTP calls
444
+ * let data = $state(null);
445
+ * async function load() {
446
+ * data = await api.myRoute.get({});
447
+ * }
448
+ * </script>
449
+ * ```
328
450
  */
329
451
  export function createApi(options?: ClientOptions) {
330
452
  return new ApiClient(options);
@@ -28,14 +28,5 @@ server.registerPlugin(workflowDemoPlugin);
28
28
  // Register routes
29
29
  server.use(demoRoutes);
30
30
 
31
- // Handle DONKEYLABS_GENERATE mode for CLI type generation
32
- if (process.env.DONKEYLABS_GENERATE === "1") {
33
- const routes = demoRoutes.getRoutes().map((route) => ({
34
- name: route.name,
35
- handler: route.handler || "typed",
36
- inputType: route.input ? "(generated)" : undefined,
37
- outputType: route.output ? "(generated)" : undefined,
38
- }));
39
- console.log(JSON.stringify({ routes }));
40
- process.exit(0);
41
- }
31
+ // Handle CLI type generation (must be after routes are registered)
32
+ server.handleGenerateMode();