@bobbykim/manguito-cms-api 0.1.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.
@@ -0,0 +1,701 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/codegen/index.ts
21
+ var codegen_exports = {};
22
+ __export(codegen_exports, {
23
+ fieldToZodSchema: () => fieldToZodSchema,
24
+ generateContentSchema: () => generateContentSchema,
25
+ generateRoutes: () => generateRoutes
26
+ });
27
+ module.exports = __toCommonJS(codegen_exports);
28
+
29
+ // src/codegen/routes.ts
30
+ function getSegment(machineName) {
31
+ const idx = machineName.indexOf("--");
32
+ return idx !== -1 ? machineName.slice(idx + 2) : machineName;
33
+ }
34
+ function toPascalCase(snakeOrKebab) {
35
+ return snakeOrKebab.split(/[_-]/).filter(Boolean).map((p) => p.charAt(0).toUpperCase() + p.slice(1)).join("");
36
+ }
37
+ function schemaVar(machineName) {
38
+ return toPascalCase(getSegment(machineName)) + "Schema";
39
+ }
40
+ function routeVar(prefix, machineName, suffix) {
41
+ return `${prefix}${toPascalCase(getSegment(machineName))}${suffix}Route`;
42
+ }
43
+ function openApiPath(honoPath) {
44
+ return honoPath.replace(/:([^/]+)/g, "{$1}");
45
+ }
46
+ function fieldToZodSchema(field, registry) {
47
+ const { field_type, validation } = field;
48
+ switch (field_type) {
49
+ case "text/plain": {
50
+ let s = "z.string()";
51
+ if (validation.limit !== void 0) s += `.max(${validation.limit})`;
52
+ if (validation.pattern !== void 0) s += `.regex(new RegExp(${JSON.stringify(validation.pattern)}))`;
53
+ return s;
54
+ }
55
+ case "text/rich":
56
+ return "z.string()";
57
+ case "integer": {
58
+ let s = "z.number().int()";
59
+ if (validation.min !== void 0) s += `.min(${validation.min})`;
60
+ if (validation.max !== void 0) s += `.max(${validation.max})`;
61
+ return s;
62
+ }
63
+ case "float": {
64
+ let s = "z.number()";
65
+ if (validation.min !== void 0) s += `.min(${validation.min})`;
66
+ if (validation.max !== void 0) s += `.max(${validation.max})`;
67
+ return s;
68
+ }
69
+ case "boolean":
70
+ return "z.boolean()";
71
+ case "date":
72
+ return "z.string().datetime()";
73
+ case "image": {
74
+ const fields = [
75
+ "id: z.string().uuid()",
76
+ "url: z.string().url()",
77
+ "mime_type: z.string()",
78
+ "alt: z.string().optional()",
79
+ "file_size: z.number().int()",
80
+ "width: z.number().int().optional()",
81
+ "height: z.number().int().optional()"
82
+ ];
83
+ return `z.object({ ${fields.join(", ")} })`;
84
+ }
85
+ case "video": {
86
+ const fields = [
87
+ "id: z.string().uuid()",
88
+ "url: z.string().url()",
89
+ "mime_type: z.string()",
90
+ "alt: z.string().optional()",
91
+ "file_size: z.number().int()",
92
+ "width: z.number().int().optional()",
93
+ "height: z.number().int().optional()",
94
+ "duration: z.number().optional()"
95
+ ];
96
+ return `z.object({ ${fields.join(", ")} })`;
97
+ }
98
+ case "file": {
99
+ const fields = [
100
+ "id: z.string().uuid()",
101
+ "url: z.string().url()",
102
+ "mime_type: z.string()",
103
+ "alt: z.string().optional()",
104
+ "file_size: z.number().int()"
105
+ ];
106
+ return `z.object({ ${fields.join(", ")} })`;
107
+ }
108
+ case "enum": {
109
+ const values = validation.allowed_values ?? [];
110
+ if (values.length === 0) return "z.string()";
111
+ const quoted = values.map((v) => JSON.stringify(v)).join(", ");
112
+ return `z.enum([${quoted}])`;
113
+ }
114
+ case "paragraph": {
115
+ const ui = field.ui_component;
116
+ if (ui.component !== "paragraph-embed") return "z.unknown()";
117
+ const paragraphType = registry?.paragraph_types[ui.ref];
118
+ if (!paragraphType) return "z.unknown()";
119
+ const inner = generateParagraphObjectSchema(paragraphType, registry);
120
+ return ui.rel === "one-to-many" ? `z.array(${inner})` : inner;
121
+ }
122
+ case "reference": {
123
+ const ui = field.ui_component;
124
+ if (ui.component !== "typeahead-select") return "z.string().uuid()";
125
+ return ui.rel === "one-to-many" ? "z.array(z.string().uuid())" : "z.string().uuid()";
126
+ }
127
+ default:
128
+ return "z.unknown()";
129
+ }
130
+ }
131
+ function generateParagraphObjectSchema(paragraph, registry) {
132
+ const entries = paragraph.fields.map((f) => {
133
+ const zodType = fieldToZodSchema(f, registry);
134
+ return `${f.name}: ${f.required ? zodType : `${zodType}.optional()`}`;
135
+ });
136
+ if (entries.length === 0) return "z.object({})";
137
+ return `z.object({ ${entries.join(", ")} })`;
138
+ }
139
+ function systemFieldEntries(schema) {
140
+ const entries = ["id: z.string().uuid()"];
141
+ if (schema.schema_type === "content-type" && !schema.only_one) {
142
+ entries.push("slug: z.string()");
143
+ }
144
+ entries.push("published: z.boolean()");
145
+ entries.push("created_at: z.string().datetime()");
146
+ entries.push("updated_at: z.string().datetime()");
147
+ return entries;
148
+ }
149
+ function schemaFieldEntries(fields, registry) {
150
+ return fields.map((f) => {
151
+ const zodType = fieldToZodSchema(f, registry);
152
+ return ` ${f.name}: ${f.required ? zodType : `${zodType}.optional()`}`;
153
+ });
154
+ }
155
+ function generateContentSchema(schema, registry) {
156
+ const name = schemaVar(schema.name);
157
+ const sysEntries = systemFieldEntries(schema).map((e) => ` ${e}`);
158
+ const fieldEntries = schemaFieldEntries(schema.fields, registry);
159
+ const allEntries = [...sysEntries, ...fieldEntries];
160
+ return `const ${name} = z.object({
161
+ ${allEntries.join(",\n")},
162
+ })`;
163
+ }
164
+ function generateParagraphSchemaDecl(paragraph, registry) {
165
+ const name = schemaVar(paragraph.name);
166
+ const inner = generateParagraphObjectSchema(paragraph, registry);
167
+ return `const ${name} = ${inner}`;
168
+ }
169
+ var SHARED_SCHEMAS_BLOCK = `const ErrorResponseSchema = z.object({
170
+ ok: z.literal(false),
171
+ error: z.object({
172
+ code: z.string(),
173
+ message: z.string(),
174
+ details: z.unknown().optional(),
175
+ }),
176
+ })
177
+
178
+ function listResponseSchema<T extends z.ZodTypeAny>(dataSchema: T) {
179
+ return z.object({
180
+ ok: z.literal(true),
181
+ data: z.array(dataSchema),
182
+ meta: z.object({
183
+ total: z.number().int(),
184
+ page: z.number().int(),
185
+ per_page: z.number().int(),
186
+ total_pages: z.number().int(),
187
+ has_next: z.boolean(),
188
+ has_prev: z.boolean(),
189
+ }),
190
+ })
191
+ }
192
+
193
+ function itemResponseSchema<T extends z.ZodTypeAny>(dataSchema: T) {
194
+ return z.object({
195
+ ok: z.literal(true),
196
+ data: dataSchema,
197
+ })
198
+ }`;
199
+ var PUBLIC_LIST_QUERY = `z.object({
200
+ page: z.coerce.number().int().min(1).default(1),
201
+ per_page: z.coerce.number().int().min(1).max(100).default(10),
202
+ include: z.string().optional().describe('Comma-separated relation field names to expand'),
203
+ sort_by: z.enum(['title', 'created_at', 'updated_at']).optional().default('created_at'),
204
+ sort_order: z.enum(['asc', 'desc']).optional().default('asc'),
205
+ })`;
206
+ var ADMIN_LIST_QUERY = `z.object({
207
+ page: z.coerce.number().int().min(1).default(1),
208
+ per_page: z.coerce.number().int().min(1).max(100).default(10),
209
+ include: z.string().optional().describe('Comma-separated relation field names to expand'),
210
+ sort_by: z.enum(['title', 'created_at', 'updated_at']).optional().default('created_at'),
211
+ sort_order: z.enum(['asc', 'desc']).optional().default('asc'),
212
+ published: z.enum(['true', 'false']).optional().describe('Filter by published state'),
213
+ })`;
214
+ var SLUG_PARAMS = `z.object({ slug: z.string() })`;
215
+ var ID_PARAMS = `z.object({ id: z.string().uuid() })`;
216
+ var INCLUDE_QUERY = `z.object({ include: z.string().optional().describe('Comma-separated relation field names to expand') })`;
217
+ function generateContentRoutes(contentType) {
218
+ const sVar = schemaVar(contentType.name);
219
+ const label = contentType.label;
220
+ const tag = label;
221
+ const lines = [];
222
+ if (!contentType.only_one) {
223
+ const collPath = contentType.api.collection_path;
224
+ const itemPath = contentType.api.item_path;
225
+ lines.push(
226
+ `export const ${routeVar("get", contentType.name, "List")} = createRoute({
227
+ method: 'get',
228
+ path: '${collPath}',
229
+ tags: [${JSON.stringify(tag)}],
230
+ request: {
231
+ query: ${PUBLIC_LIST_QUERY},
232
+ },
233
+ responses: {
234
+ 200: {
235
+ content: { 'application/json': { schema: listResponseSchema(${sVar}) } },
236
+ description: 'List of ${label}',
237
+ },
238
+ 400: {
239
+ content: { 'application/json': { schema: ErrorResponseSchema } },
240
+ description: 'Invalid query parameters',
241
+ },
242
+ },
243
+ })`
244
+ );
245
+ lines.push(
246
+ `export const ${routeVar("get", contentType.name, "")} = createRoute({
247
+ method: 'get',
248
+ path: '${openApiPath(itemPath)}',
249
+ tags: [${JSON.stringify(tag)}],
250
+ request: {
251
+ params: ${SLUG_PARAMS},
252
+ query: ${INCLUDE_QUERY},
253
+ },
254
+ responses: {
255
+ 200: {
256
+ content: { 'application/json': { schema: itemResponseSchema(${sVar}) } },
257
+ description: '${label}',
258
+ },
259
+ 404: {
260
+ content: { 'application/json': { schema: ErrorResponseSchema } },
261
+ description: '${label} not found',
262
+ },
263
+ },
264
+ })`
265
+ );
266
+ const adminCollPath = "/admin" + collPath;
267
+ const adminItemPath = adminCollPath + "/{id}";
268
+ lines.push(
269
+ `export const ${routeVar("adminGet", contentType.name, "List")} = createRoute({
270
+ method: 'get',
271
+ path: '${adminCollPath}',
272
+ tags: [${JSON.stringify(tag)}],
273
+ request: {
274
+ query: ${ADMIN_LIST_QUERY},
275
+ },
276
+ responses: {
277
+ 200: {
278
+ content: { 'application/json': { schema: listResponseSchema(${sVar}) } },
279
+ description: 'List of ${label}',
280
+ },
281
+ 400: {
282
+ content: { 'application/json': { schema: ErrorResponseSchema } },
283
+ description: 'Invalid query parameters',
284
+ },
285
+ },
286
+ })`
287
+ );
288
+ lines.push(
289
+ `export const ${routeVar("adminGet", contentType.name, "")} = createRoute({
290
+ method: 'get',
291
+ path: '${adminItemPath}',
292
+ tags: [${JSON.stringify(tag)}],
293
+ request: {
294
+ params: ${ID_PARAMS},
295
+ query: ${INCLUDE_QUERY},
296
+ },
297
+ responses: {
298
+ 200: {
299
+ content: { 'application/json': { schema: itemResponseSchema(${sVar}) } },
300
+ description: '${label}',
301
+ },
302
+ 404: {
303
+ content: { 'application/json': { schema: ErrorResponseSchema } },
304
+ description: '${label} not found',
305
+ },
306
+ },
307
+ })`
308
+ );
309
+ lines.push(
310
+ `export const ${routeVar("adminCreate", contentType.name, "")} = createRoute({
311
+ method: 'post',
312
+ path: '${adminCollPath}',
313
+ tags: [${JSON.stringify(tag)}],
314
+ request: {
315
+ body: {
316
+ content: { 'application/json': { schema: ${sVar} } },
317
+ },
318
+ },
319
+ responses: {
320
+ 201: {
321
+ content: { 'application/json': { schema: itemResponseSchema(${sVar}) } },
322
+ description: '${label} created',
323
+ },
324
+ 422: {
325
+ content: { 'application/json': { schema: ErrorResponseSchema } },
326
+ description: 'Validation error',
327
+ },
328
+ },
329
+ })`
330
+ );
331
+ lines.push(
332
+ `export const ${routeVar("adminUpdate", contentType.name, "")} = createRoute({
333
+ method: 'patch',
334
+ path: '${adminItemPath}',
335
+ tags: [${JSON.stringify(tag)}],
336
+ request: {
337
+ params: ${ID_PARAMS},
338
+ body: {
339
+ content: { 'application/json': { schema: ${sVar}.partial().extend({ published: z.boolean().optional() }) } },
340
+ },
341
+ },
342
+ responses: {
343
+ 200: {
344
+ content: { 'application/json': { schema: itemResponseSchema(${sVar}) } },
345
+ description: '${label} updated',
346
+ },
347
+ 404: {
348
+ content: { 'application/json': { schema: ErrorResponseSchema } },
349
+ description: '${label} not found',
350
+ },
351
+ 422: {
352
+ content: { 'application/json': { schema: ErrorResponseSchema } },
353
+ description: 'Validation error',
354
+ },
355
+ },
356
+ })`
357
+ );
358
+ lines.push(
359
+ `export const ${routeVar("adminDelete", contentType.name, "")} = createRoute({
360
+ method: 'delete',
361
+ path: '${adminItemPath}',
362
+ tags: [${JSON.stringify(tag)}],
363
+ request: {
364
+ params: ${ID_PARAMS},
365
+ },
366
+ responses: {
367
+ 200: {
368
+ content: { 'application/json': { schema: z.object({ ok: z.literal(true) }) } },
369
+ description: '${label} deleted',
370
+ },
371
+ 404: {
372
+ content: { 'application/json': { schema: ErrorResponseSchema } },
373
+ description: '${label} not found',
374
+ },
375
+ },
376
+ })`
377
+ );
378
+ } else {
379
+ const itemPath = contentType.api.item_path;
380
+ const adminItemBase = "/admin" + itemPath;
381
+ const adminPatchPath = "/admin/api/" + contentType.default_base_path + "/{id}";
382
+ lines.push(
383
+ `export const ${routeVar("get", contentType.name, "")} = createRoute({
384
+ method: 'get',
385
+ path: '${itemPath}',
386
+ tags: [${JSON.stringify(tag)}],
387
+ request: {
388
+ query: ${INCLUDE_QUERY},
389
+ },
390
+ responses: {
391
+ 200: {
392
+ content: { 'application/json': { schema: itemResponseSchema(${sVar}) } },
393
+ description: '${label}',
394
+ },
395
+ 404: {
396
+ content: { 'application/json': { schema: ErrorResponseSchema } },
397
+ description: '${label} not found',
398
+ },
399
+ },
400
+ })`
401
+ );
402
+ lines.push(
403
+ `export const ${routeVar("adminGet", contentType.name, "")} = createRoute({
404
+ method: 'get',
405
+ path: '${adminItemBase}',
406
+ tags: [${JSON.stringify(tag)}],
407
+ request: {
408
+ query: ${INCLUDE_QUERY},
409
+ },
410
+ responses: {
411
+ 200: {
412
+ content: { 'application/json': { schema: itemResponseSchema(${sVar}) } },
413
+ description: '${label}',
414
+ },
415
+ 404: {
416
+ content: { 'application/json': { schema: ErrorResponseSchema } },
417
+ description: '${label} not found',
418
+ },
419
+ },
420
+ })`
421
+ );
422
+ const adminPostPath = "/admin/api/" + contentType.default_base_path;
423
+ lines.push(
424
+ `export const ${routeVar("adminCreate", contentType.name, "")} = createRoute({
425
+ method: 'post',
426
+ path: '${adminPostPath}',
427
+ tags: [${JSON.stringify(tag)}],
428
+ request: {
429
+ body: {
430
+ content: { 'application/json': { schema: ${sVar} } },
431
+ },
432
+ },
433
+ responses: {
434
+ 201: {
435
+ content: { 'application/json': { schema: itemResponseSchema(${sVar}) } },
436
+ description: '${label} created',
437
+ },
438
+ 409: {
439
+ content: { 'application/json': { schema: ErrorResponseSchema } },
440
+ description: 'Singleton already exists',
441
+ },
442
+ 422: {
443
+ content: { 'application/json': { schema: ErrorResponseSchema } },
444
+ description: 'Validation error',
445
+ },
446
+ },
447
+ })`
448
+ );
449
+ lines.push(
450
+ `export const ${routeVar("adminUpdate", contentType.name, "")} = createRoute({
451
+ method: 'patch',
452
+ path: '${adminPatchPath}',
453
+ tags: [${JSON.stringify(tag)}],
454
+ request: {
455
+ params: ${ID_PARAMS},
456
+ body: {
457
+ content: { 'application/json': { schema: ${sVar}.partial().extend({ published: z.boolean().optional() }) } },
458
+ },
459
+ },
460
+ responses: {
461
+ 200: {
462
+ content: { 'application/json': { schema: itemResponseSchema(${sVar}) } },
463
+ description: '${label} updated',
464
+ },
465
+ 404: {
466
+ content: { 'application/json': { schema: ErrorResponseSchema } },
467
+ description: '${label} not found',
468
+ },
469
+ 422: {
470
+ content: { 'application/json': { schema: ErrorResponseSchema } },
471
+ description: 'Validation error',
472
+ },
473
+ },
474
+ })`
475
+ );
476
+ }
477
+ return lines.join("\n\n");
478
+ }
479
+ function generateTaxonomyRoutes(taxonomyType) {
480
+ const sVar = schemaVar(taxonomyType.name);
481
+ const label = taxonomyType.label;
482
+ const tag = label;
483
+ const collPath = taxonomyType.api.collection_path;
484
+ const itemPath = taxonomyType.api.item_path;
485
+ const adminCollPath = "/admin" + collPath;
486
+ const adminItemPath = "/admin" + openApiPath(itemPath);
487
+ const lines = [];
488
+ lines.push(
489
+ `export const ${routeVar("get", taxonomyType.name, "List")} = createRoute({
490
+ method: 'get',
491
+ path: '${collPath}',
492
+ tags: [${JSON.stringify(tag)}],
493
+ request: {
494
+ query: ${PUBLIC_LIST_QUERY},
495
+ },
496
+ responses: {
497
+ 200: {
498
+ content: { 'application/json': { schema: listResponseSchema(${sVar}) } },
499
+ description: 'List of ${label}',
500
+ },
501
+ 400: {
502
+ content: { 'application/json': { schema: ErrorResponseSchema } },
503
+ description: 'Invalid query parameters',
504
+ },
505
+ },
506
+ })`
507
+ );
508
+ lines.push(
509
+ `export const ${routeVar("get", taxonomyType.name, "")} = createRoute({
510
+ method: 'get',
511
+ path: '${openApiPath(itemPath)}',
512
+ tags: [${JSON.stringify(tag)}],
513
+ request: {
514
+ params: ${ID_PARAMS},
515
+ query: ${INCLUDE_QUERY},
516
+ },
517
+ responses: {
518
+ 200: {
519
+ content: { 'application/json': { schema: itemResponseSchema(${sVar}) } },
520
+ description: '${label}',
521
+ },
522
+ 404: {
523
+ content: { 'application/json': { schema: ErrorResponseSchema } },
524
+ description: '${label} not found',
525
+ },
526
+ },
527
+ })`
528
+ );
529
+ lines.push(
530
+ `export const ${routeVar("adminGet", taxonomyType.name, "List")} = createRoute({
531
+ method: 'get',
532
+ path: '${adminCollPath}',
533
+ tags: [${JSON.stringify(tag)}],
534
+ request: {
535
+ query: ${ADMIN_LIST_QUERY},
536
+ },
537
+ responses: {
538
+ 200: {
539
+ content: { 'application/json': { schema: listResponseSchema(${sVar}) } },
540
+ description: 'List of ${label}',
541
+ },
542
+ 400: {
543
+ content: { 'application/json': { schema: ErrorResponseSchema } },
544
+ description: 'Invalid query parameters',
545
+ },
546
+ },
547
+ })`
548
+ );
549
+ lines.push(
550
+ `export const ${routeVar("adminGet", taxonomyType.name, "")} = createRoute({
551
+ method: 'get',
552
+ path: '${adminItemPath}',
553
+ tags: [${JSON.stringify(tag)}],
554
+ request: {
555
+ params: ${ID_PARAMS},
556
+ query: ${INCLUDE_QUERY},
557
+ },
558
+ responses: {
559
+ 200: {
560
+ content: { 'application/json': { schema: itemResponseSchema(${sVar}) } },
561
+ description: '${label}',
562
+ },
563
+ 404: {
564
+ content: { 'application/json': { schema: ErrorResponseSchema } },
565
+ description: '${label} not found',
566
+ },
567
+ },
568
+ })`
569
+ );
570
+ lines.push(
571
+ `export const ${routeVar("adminCreate", taxonomyType.name, "")} = createRoute({
572
+ method: 'post',
573
+ path: '${adminCollPath}',
574
+ tags: [${JSON.stringify(tag)}],
575
+ request: {
576
+ body: {
577
+ content: { 'application/json': { schema: ${sVar} } },
578
+ },
579
+ },
580
+ responses: {
581
+ 201: {
582
+ content: { 'application/json': { schema: itemResponseSchema(${sVar}) } },
583
+ description: '${label} created',
584
+ },
585
+ 422: {
586
+ content: { 'application/json': { schema: ErrorResponseSchema } },
587
+ description: 'Validation error',
588
+ },
589
+ },
590
+ })`
591
+ );
592
+ lines.push(
593
+ `export const ${routeVar("adminUpdate", taxonomyType.name, "")} = createRoute({
594
+ method: 'patch',
595
+ path: '${adminItemPath}',
596
+ tags: [${JSON.stringify(tag)}],
597
+ request: {
598
+ params: ${ID_PARAMS},
599
+ body: {
600
+ content: { 'application/json': { schema: ${sVar}.partial().extend({ published: z.boolean().optional() }) } },
601
+ },
602
+ },
603
+ responses: {
604
+ 200: {
605
+ content: { 'application/json': { schema: itemResponseSchema(${sVar}) } },
606
+ description: '${label} updated',
607
+ },
608
+ 404: {
609
+ content: { 'application/json': { schema: ErrorResponseSchema } },
610
+ description: '${label} not found',
611
+ },
612
+ 422: {
613
+ content: { 'application/json': { schema: ErrorResponseSchema } },
614
+ description: 'Validation error',
615
+ },
616
+ },
617
+ })`
618
+ );
619
+ lines.push(
620
+ `export const ${routeVar("adminDelete", taxonomyType.name, "")} = createRoute({
621
+ method: 'delete',
622
+ path: '${adminItemPath}',
623
+ tags: [${JSON.stringify(tag)}],
624
+ request: {
625
+ params: ${ID_PARAMS},
626
+ },
627
+ responses: {
628
+ 200: {
629
+ content: { 'application/json': { schema: z.object({ ok: z.literal(true) }) } },
630
+ description: '${label} deleted',
631
+ },
632
+ 404: {
633
+ content: { 'application/json': { schema: ErrorResponseSchema } },
634
+ description: '${label} not found',
635
+ },
636
+ },
637
+ })`
638
+ );
639
+ return lines.join("\n\n");
640
+ }
641
+ function generateRoutes(registry) {
642
+ const parts = [];
643
+ parts.push("// Auto-generated by generateRoutes() \u2014 do not hand-edit");
644
+ parts.push("import { createRoute, z } from '@hono/zod-openapi'");
645
+ parts.push("");
646
+ parts.push("// \u2500\u2500\u2500 Shared schemas \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
647
+ parts.push("");
648
+ parts.push(SHARED_SCHEMAS_BLOCK);
649
+ parts.push("");
650
+ const paragraphEntries = Object.entries(registry.paragraph_types);
651
+ if (paragraphEntries.length > 0) {
652
+ parts.push("// \u2500\u2500\u2500 Paragraph schemas \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
653
+ parts.push("");
654
+ for (const [, paragraphType] of paragraphEntries) {
655
+ parts.push(generateParagraphSchemaDecl(paragraphType, registry));
656
+ }
657
+ parts.push("");
658
+ }
659
+ const contentEntries = Object.entries(registry.content_types);
660
+ if (contentEntries.length > 0) {
661
+ parts.push("// \u2500\u2500\u2500 Content type schemas \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
662
+ parts.push("");
663
+ for (const [, contentType] of contentEntries) {
664
+ parts.push(generateContentSchema(contentType, registry));
665
+ parts.push("");
666
+ }
667
+ }
668
+ const taxonomyEntries = Object.entries(registry.taxonomy_types);
669
+ if (taxonomyEntries.length > 0) {
670
+ parts.push("// \u2500\u2500\u2500 Taxonomy type schemas \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
671
+ parts.push("");
672
+ for (const [, taxonomyType] of taxonomyEntries) {
673
+ parts.push(generateContentSchema(taxonomyType, registry));
674
+ parts.push("");
675
+ }
676
+ }
677
+ if (contentEntries.length > 0) {
678
+ parts.push("// \u2500\u2500\u2500 Content routes \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
679
+ parts.push("");
680
+ for (const [, contentType] of contentEntries) {
681
+ parts.push(generateContentRoutes(contentType));
682
+ parts.push("");
683
+ }
684
+ }
685
+ if (taxonomyEntries.length > 0) {
686
+ parts.push("// \u2500\u2500\u2500 Taxonomy routes \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
687
+ parts.push("");
688
+ for (const [, taxonomyType] of taxonomyEntries) {
689
+ parts.push(generateTaxonomyRoutes(taxonomyType));
690
+ parts.push("");
691
+ }
692
+ }
693
+ return parts.join("\n");
694
+ }
695
+ // Annotate the CommonJS export names for ESM import in node:
696
+ 0 && (module.exports = {
697
+ fieldToZodSchema,
698
+ generateContentSchema,
699
+ generateRoutes
700
+ });
701
+ //# sourceMappingURL=index.js.map