@contractkit/openapi-to-ck 0.7.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.
Files changed (97) hide show
  1. package/.turbo/turbo-build$colon$ci.log +40 -0
  2. package/.turbo/turbo-build.log +20 -0
  3. package/.turbo/turbo-format.log +36 -0
  4. package/.turbo/turbo-test$colon$ci.log +77 -0
  5. package/.turbo/turbo-test.log +19 -0
  6. package/CHANGELOG.md +108 -0
  7. package/coverage/base.css +224 -0
  8. package/coverage/block-navigation.js +87 -0
  9. package/coverage/clover.xml +878 -0
  10. package/coverage/coverage-final.json +10 -0
  11. package/coverage/favicon.png +0 -0
  12. package/coverage/index.html +131 -0
  13. package/coverage/prettify.css +1 -0
  14. package/coverage/prettify.js +2 -0
  15. package/coverage/sort-arrow-sprite.png +0 -0
  16. package/coverage/sorter.js +210 -0
  17. package/coverage/src/ast-to-ck.ts.html +1336 -0
  18. package/coverage/src/circular-refs.ts.html +298 -0
  19. package/coverage/src/convert.ts.html +535 -0
  20. package/coverage/src/index.html +221 -0
  21. package/coverage/src/normalize.ts.html +1162 -0
  22. package/coverage/src/paths-to-ast.ts.html +1165 -0
  23. package/coverage/src/schema-to-ast.ts.html +1378 -0
  24. package/coverage/src/tag-splitter.ts.html +685 -0
  25. package/coverage/src/warnings.ts.html +154 -0
  26. package/coverage/tests/helpers.ts.html +559 -0
  27. package/coverage/tests/index.html +116 -0
  28. package/dist/ast-to-ck.d.ts +8 -0
  29. package/dist/ast-to-ck.d.ts.map +1 -0
  30. package/dist/chunk-CQGFQKBJ.js +1681 -0
  31. package/dist/chunk-CQGFQKBJ.js.map +1 -0
  32. package/dist/chunk-FNUU2DWY.js +1779 -0
  33. package/dist/chunk-FNUU2DWY.js.map +1 -0
  34. package/dist/chunk-LD2HAFZG.js +1681 -0
  35. package/dist/chunk-LD2HAFZG.js.map +1 -0
  36. package/dist/chunk-LQ2B3EJG.js +1777 -0
  37. package/dist/chunk-LQ2B3EJG.js.map +1 -0
  38. package/dist/chunk-M6JA6WY2.js +1714 -0
  39. package/dist/chunk-M6JA6WY2.js.map +1 -0
  40. package/dist/chunk-MQTKLXTN.js +1681 -0
  41. package/dist/chunk-MQTKLXTN.js.map +1 -0
  42. package/dist/chunk-NV7RGUUS.js +1699 -0
  43. package/dist/chunk-NV7RGUUS.js.map +1 -0
  44. package/dist/chunk-REM25FDE.js +1779 -0
  45. package/dist/chunk-REM25FDE.js.map +1 -0
  46. package/dist/chunk-SNW7GJOM.js +1681 -0
  47. package/dist/chunk-SNW7GJOM.js.map +1 -0
  48. package/dist/chunk-UWOSCBRG.js +1681 -0
  49. package/dist/chunk-UWOSCBRG.js.map +1 -0
  50. package/dist/chunk-YP7FWA4H.js +1779 -0
  51. package/dist/chunk-YP7FWA4H.js.map +1 -0
  52. package/dist/circular-refs.d.ts +12 -0
  53. package/dist/circular-refs.d.ts.map +1 -0
  54. package/dist/convert.d.ts +6 -0
  55. package/dist/convert.d.ts.map +1 -0
  56. package/dist/index.d.ts +9 -0
  57. package/dist/index.d.ts.map +1 -0
  58. package/dist/index.js +29 -0
  59. package/dist/index.js.map +1 -0
  60. package/dist/normalize.d.ts +12 -0
  61. package/dist/normalize.d.ts.map +1 -0
  62. package/dist/paths-to-ast.d.ts +22 -0
  63. package/dist/paths-to-ast.d.ts.map +1 -0
  64. package/dist/plugin.d.ts +4 -0
  65. package/dist/plugin.d.ts.map +1 -0
  66. package/dist/plugin.js +86 -0
  67. package/dist/plugin.js.map +1 -0
  68. package/dist/schema-to-ast.d.ts +39 -0
  69. package/dist/schema-to-ast.d.ts.map +1 -0
  70. package/dist/tag-splitter.d.ts +16 -0
  71. package/dist/tag-splitter.d.ts.map +1 -0
  72. package/dist/types.d.ts +137 -0
  73. package/dist/types.d.ts.map +1 -0
  74. package/dist/warnings.d.ts +10 -0
  75. package/dist/warnings.d.ts.map +1 -0
  76. package/eslint.config.js +6 -0
  77. package/package.json +46 -0
  78. package/src/ast-to-ck.ts +417 -0
  79. package/src/circular-refs.ts +71 -0
  80. package/src/convert.ts +150 -0
  81. package/src/index.ts +8 -0
  82. package/src/normalize.ts +359 -0
  83. package/src/paths-to-ast.ts +360 -0
  84. package/src/plugin.ts +89 -0
  85. package/src/schema-to-ast.ts +431 -0
  86. package/src/tag-splitter.ts +200 -0
  87. package/src/types.ts +133 -0
  88. package/src/warnings.ts +23 -0
  89. package/tests/ast-to-ck.test.ts +425 -0
  90. package/tests/circular-refs.test.ts +71 -0
  91. package/tests/convert.test.ts +330 -0
  92. package/tests/fixtures/petstore-3.1.json +187 -0
  93. package/tests/helpers.ts +158 -0
  94. package/tests/normalize.test.ts +114 -0
  95. package/tests/schema-to-ast.test.ts +341 -0
  96. package/tests/tag-splitter.test.ts +75 -0
  97. package/tsconfig.json +9 -0
@@ -0,0 +1,1779 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/normalize.ts
5
+ function normalize(doc, warnings) {
6
+ const version = detectVersion(doc);
7
+ if (version === "2.0") {
8
+ return normalizeSwagger2(doc, warnings);
9
+ }
10
+ if (version === "3.0") {
11
+ return normalizeOas30(doc, warnings);
12
+ }
13
+ return doc;
14
+ }
15
+ __name(normalize, "normalize");
16
+ function detectVersion(doc) {
17
+ if (typeof doc.swagger === "string" && doc.swagger.startsWith("2")) return "2.0";
18
+ if (typeof doc.openapi === "string") {
19
+ if (doc.openapi.startsWith("3.0")) return "3.0";
20
+ }
21
+ return "3.1";
22
+ }
23
+ __name(detectVersion, "detectVersion");
24
+ function normalizeSwagger2(doc, warnings) {
25
+ const info = doc.info ?? {
26
+ title: "Untitled",
27
+ version: "0.0.0"
28
+ };
29
+ const basePath = doc.basePath ?? "";
30
+ const schemes = doc.schemes ?? [
31
+ "https"
32
+ ];
33
+ const host = doc.host ?? "localhost";
34
+ const globalConsumes = doc.consumes ?? [
35
+ "application/json"
36
+ ];
37
+ const globalProduces = doc.produces ?? [
38
+ "application/json"
39
+ ];
40
+ const result = {
41
+ openapi: "3.1.0",
42
+ info: {
43
+ title: info.title ?? "Untitled",
44
+ version: info.version ?? "0.0.0",
45
+ description: info.description
46
+ },
47
+ servers: [
48
+ {
49
+ url: `${schemes[0]}://${host}${basePath}`
50
+ }
51
+ ],
52
+ paths: {},
53
+ components: {
54
+ schemas: {},
55
+ securitySchemes: {}
56
+ },
57
+ tags: doc.tags ?? []
58
+ };
59
+ const definitions = doc.definitions ?? {};
60
+ for (const [name, schema] of Object.entries(definitions)) {
61
+ result.components.schemas[name] = normalizeNullable30(schema);
62
+ }
63
+ const secDefs = doc.securityDefinitions ?? {};
64
+ for (const [name, scheme] of Object.entries(secDefs)) {
65
+ result.components.securitySchemes[name] = convertSecurityScheme2(scheme);
66
+ }
67
+ const paths = doc.paths ?? {};
68
+ for (const [path, pathItem] of Object.entries(paths)) {
69
+ result.paths[path] = normalizePathItem2(pathItem, globalConsumes, globalProduces, warnings);
70
+ }
71
+ if (doc.security) {
72
+ result.security = doc.security;
73
+ }
74
+ return result;
75
+ }
76
+ __name(normalizeSwagger2, "normalizeSwagger2");
77
+ function normalizePathItem2(pathItem, globalConsumes, globalProduces, warnings) {
78
+ const methods = [
79
+ "get",
80
+ "post",
81
+ "put",
82
+ "patch",
83
+ "delete",
84
+ "head",
85
+ "options"
86
+ ];
87
+ const normalized = {};
88
+ const pathParams = pathItem.parameters ?? [];
89
+ for (const method of methods) {
90
+ const op = pathItem[method];
91
+ if (!op) continue;
92
+ const opConsumes = op.consumes ?? globalConsumes;
93
+ const opProduces = op.produces ?? globalProduces;
94
+ const params = [
95
+ ...pathParams,
96
+ ...op.parameters ?? []
97
+ ];
98
+ const nonBodyParams = [];
99
+ let requestBody;
100
+ for (const param of params) {
101
+ if (param.in === "body") {
102
+ const contentType = opConsumes[0] ?? "application/json";
103
+ requestBody = {
104
+ description: param.description,
105
+ required: param.required ?? true,
106
+ content: {
107
+ [contentType]: {
108
+ schema: normalizeNullable30(param.schema ?? {})
109
+ }
110
+ }
111
+ };
112
+ } else if (param.in === "formData") {
113
+ warnings.info(`#/paths/${encodePathSegment(method)}`, "formData parameters converted to multipart/form-data requestBody");
114
+ if (!requestBody) {
115
+ requestBody = {
116
+ content: {
117
+ "multipart/form-data": {
118
+ schema: {
119
+ type: "object",
120
+ properties: {},
121
+ required: []
122
+ }
123
+ }
124
+ }
125
+ };
126
+ }
127
+ const formSchema = requestBody.content["multipart/form-data"].schema;
128
+ const props = formSchema.properties;
129
+ props[param.name] = normalizeNullable30(param);
130
+ if (param.required) {
131
+ formSchema.required.push(param.name);
132
+ }
133
+ } else {
134
+ const normalizedParam = {
135
+ ...param
136
+ };
137
+ if (param.type) {
138
+ normalizedParam.schema = normalizeNullable30({
139
+ type: param.type,
140
+ format: param.format,
141
+ enum: param.enum,
142
+ items: param.items,
143
+ default: param.default,
144
+ minimum: param.minimum,
145
+ maximum: param.maximum,
146
+ minLength: param.minLength,
147
+ maxLength: param.maxLength,
148
+ pattern: param.pattern
149
+ });
150
+ delete normalizedParam.type;
151
+ delete normalizedParam.format;
152
+ delete normalizedParam.enum;
153
+ delete normalizedParam.items;
154
+ }
155
+ nonBodyParams.push(normalizedParam);
156
+ }
157
+ }
158
+ const responses = {};
159
+ const opResponses = op.responses ?? {};
160
+ for (const [code, resp] of Object.entries(opResponses)) {
161
+ const contentType = opProduces[0] ?? "application/json";
162
+ const headers = convertResponseHeaders2(resp.headers);
163
+ const responseEntry = {
164
+ description: resp.description ?? ""
165
+ };
166
+ if (resp.schema) {
167
+ responseEntry.content = {
168
+ [contentType]: {
169
+ schema: normalizeNullable30(resp.schema)
170
+ }
171
+ };
172
+ }
173
+ if (headers) {
174
+ responseEntry.headers = headers;
175
+ }
176
+ responses[code] = responseEntry;
177
+ }
178
+ normalized[method] = {
179
+ operationId: op.operationId,
180
+ summary: op.summary,
181
+ description: op.description,
182
+ tags: op.tags,
183
+ parameters: nonBodyParams.length > 0 ? nonBodyParams : void 0,
184
+ requestBody,
185
+ responses,
186
+ security: op.security,
187
+ deprecated: op.deprecated
188
+ };
189
+ }
190
+ return normalized;
191
+ }
192
+ __name(normalizePathItem2, "normalizePathItem2");
193
+ function convertResponseHeaders2(headers) {
194
+ if (!headers) return void 0;
195
+ const out = {};
196
+ for (const [name, header] of Object.entries(headers)) {
197
+ if (!header || typeof header !== "object") continue;
198
+ const { description, type, format, items, ...rest } = header;
199
+ const schema = {
200
+ ...rest
201
+ };
202
+ if (type !== void 0) schema.type = type;
203
+ if (format !== void 0) schema.format = format;
204
+ if (items !== void 0) schema.items = items;
205
+ const normalized = {};
206
+ if (description !== void 0) normalized.description = description;
207
+ if (Object.keys(schema).length > 0) normalized.schema = normalizeNullable30(schema);
208
+ out[name] = normalized;
209
+ }
210
+ return Object.keys(out).length > 0 ? out : void 0;
211
+ }
212
+ __name(convertResponseHeaders2, "convertResponseHeaders2");
213
+ function convertSecurityScheme2(scheme) {
214
+ const type = scheme.type;
215
+ if (type === "basic") {
216
+ return {
217
+ type: "http",
218
+ scheme: "basic"
219
+ };
220
+ }
221
+ if (type === "apiKey") {
222
+ return {
223
+ type: "apiKey",
224
+ name: scheme.name,
225
+ in: scheme.in
226
+ };
227
+ }
228
+ if (type === "oauth2") {
229
+ const flow = scheme.flow;
230
+ const flows = {};
231
+ if (flow === "implicit") {
232
+ flows.implicit = {
233
+ authorizationUrl: scheme.authorizationUrl,
234
+ scopes: scheme.scopes ?? {}
235
+ };
236
+ } else if (flow === "password") {
237
+ flows.password = {
238
+ tokenUrl: scheme.tokenUrl,
239
+ scopes: scheme.scopes ?? {}
240
+ };
241
+ } else if (flow === "application") {
242
+ flows.clientCredentials = {
243
+ tokenUrl: scheme.tokenUrl,
244
+ scopes: scheme.scopes ?? {}
245
+ };
246
+ } else if (flow === "accessCode") {
247
+ flows.authorizationCode = {
248
+ authorizationUrl: scheme.authorizationUrl,
249
+ tokenUrl: scheme.tokenUrl,
250
+ scopes: scheme.scopes ?? {}
251
+ };
252
+ }
253
+ return {
254
+ type: "oauth2",
255
+ flows
256
+ };
257
+ }
258
+ return scheme;
259
+ }
260
+ __name(convertSecurityScheme2, "convertSecurityScheme2");
261
+ function normalizeOas30(doc, _warnings) {
262
+ if (doc.components?.schemas) {
263
+ for (const [name, schema] of Object.entries(doc.components.schemas)) {
264
+ doc.components.schemas[name] = normalizeNullable30(schema);
265
+ }
266
+ }
267
+ if (doc.paths) {
268
+ for (const pathItem of Object.values(doc.paths)) {
269
+ normalizePathItemSchemas(pathItem);
270
+ }
271
+ }
272
+ doc.openapi = "3.1.0";
273
+ return doc;
274
+ }
275
+ __name(normalizeOas30, "normalizeOas30");
276
+ function normalizePathItemSchemas(pathItem) {
277
+ const methods = [
278
+ "get",
279
+ "post",
280
+ "put",
281
+ "patch",
282
+ "delete",
283
+ "head",
284
+ "options"
285
+ ];
286
+ for (const method of methods) {
287
+ const op = pathItem[method];
288
+ if (!op) continue;
289
+ const params = op.parameters ?? [];
290
+ for (const param of params) {
291
+ if (param.schema) {
292
+ param.schema = normalizeNullable30(param.schema);
293
+ }
294
+ }
295
+ const reqBody = op.requestBody;
296
+ if (reqBody?.content) {
297
+ for (const mediaType of Object.values(reqBody.content)) {
298
+ if (mediaType.schema) {
299
+ mediaType.schema = normalizeNullable30(mediaType.schema);
300
+ }
301
+ }
302
+ }
303
+ const responses = op.responses ?? {};
304
+ for (const resp of Object.values(responses)) {
305
+ if (resp.content) {
306
+ for (const mediaType of Object.values(resp.content)) {
307
+ if (mediaType.schema) {
308
+ mediaType.schema = normalizeNullable30(mediaType.schema);
309
+ }
310
+ }
311
+ }
312
+ }
313
+ }
314
+ }
315
+ __name(normalizePathItemSchemas, "normalizePathItemSchemas");
316
+ function normalizeNullable30(schema) {
317
+ if (!schema || typeof schema !== "object") return schema;
318
+ const result = {
319
+ ...schema
320
+ };
321
+ if (result.nullable === true && typeof result.type === "string") {
322
+ result.type = [
323
+ result.type,
324
+ "null"
325
+ ];
326
+ delete result.nullable;
327
+ }
328
+ if (result.properties && typeof result.properties === "object") {
329
+ const props = result.properties;
330
+ for (const [key, val] of Object.entries(props)) {
331
+ props[key] = normalizeNullable30(val);
332
+ }
333
+ }
334
+ if (result.items && typeof result.items === "object" && !Array.isArray(result.items)) {
335
+ result.items = normalizeNullable30(result.items);
336
+ }
337
+ if (result.additionalProperties && typeof result.additionalProperties === "object") {
338
+ result.additionalProperties = normalizeNullable30(result.additionalProperties);
339
+ }
340
+ for (const combiner of [
341
+ "allOf",
342
+ "oneOf",
343
+ "anyOf"
344
+ ]) {
345
+ if (Array.isArray(result[combiner])) {
346
+ result[combiner] = result[combiner].map(normalizeNullable30);
347
+ }
348
+ }
349
+ return result;
350
+ }
351
+ __name(normalizeNullable30, "normalizeNullable30");
352
+ function encodePathSegment(s) {
353
+ return s.replace(/~/g, "~0").replace(/\//g, "~1");
354
+ }
355
+ __name(encodePathSegment, "encodePathSegment");
356
+
357
+ // src/circular-refs.ts
358
+ function detectCircularRefs(schemas) {
359
+ const circular = /* @__PURE__ */ new Set();
360
+ const visiting = /* @__PURE__ */ new Set();
361
+ const visited = /* @__PURE__ */ new Set();
362
+ function visit(name) {
363
+ if (visited.has(name)) return;
364
+ if (visiting.has(name)) {
365
+ circular.add(name);
366
+ return;
367
+ }
368
+ visiting.add(name);
369
+ const schema = schemas[name];
370
+ if (schema && typeof schema === "object") {
371
+ for (const ref of collectRefs(schema)) {
372
+ const refName = extractRefName(ref);
373
+ if (refName && schemas[refName]) {
374
+ visit(refName);
375
+ }
376
+ }
377
+ }
378
+ visiting.delete(name);
379
+ visited.add(name);
380
+ }
381
+ __name(visit, "visit");
382
+ for (const name of Object.keys(schemas)) {
383
+ visit(name);
384
+ }
385
+ return circular;
386
+ }
387
+ __name(detectCircularRefs, "detectCircularRefs");
388
+ function collectRefs(obj) {
389
+ const refs = [];
390
+ function walk(val) {
391
+ if (!val || typeof val !== "object") return;
392
+ if (Array.isArray(val)) {
393
+ for (const item of val) walk(item);
394
+ return;
395
+ }
396
+ const record = val;
397
+ if (typeof record.$ref === "string") {
398
+ refs.push(record.$ref);
399
+ }
400
+ for (const v of Object.values(record)) {
401
+ walk(v);
402
+ }
403
+ }
404
+ __name(walk, "walk");
405
+ walk(obj);
406
+ return refs;
407
+ }
408
+ __name(collectRefs, "collectRefs");
409
+ function extractRefName(ref) {
410
+ const match = ref.match(/^#\/(?:components\/schemas|definitions)\/(.+)$/);
411
+ return match?.[1];
412
+ }
413
+ __name(extractRefName, "extractRefName");
414
+
415
+ // src/schema-to-ast.ts
416
+ var LOC = {
417
+ file: "",
418
+ line: 0
419
+ };
420
+ var FORMAT_TO_SCALAR = {
421
+ email: "email",
422
+ uri: "url",
423
+ url: "url",
424
+ uuid: "uuid",
425
+ date: "date",
426
+ "date-time": "datetime",
427
+ time: "time",
428
+ binary: "binary",
429
+ int64: "bigint"
430
+ };
431
+ function schemasToModels(schemas, ctx) {
432
+ const models = [];
433
+ for (const [name, schema] of Object.entries(schemas)) {
434
+ const modelCtx = {
435
+ ...ctx,
436
+ path: `#/components/schemas/${name}`
437
+ };
438
+ const model = schemaToModel(name, schema, modelCtx);
439
+ if (model) models.push(model);
440
+ }
441
+ models.push(...ctx.extractedModels);
442
+ return models;
443
+ }
444
+ __name(schemasToModels, "schemasToModels");
445
+ function schemaToModel(name, schema, ctx) {
446
+ warnUnsupported(schema, ctx);
447
+ const description = ctx.includeComments ? schema.description : void 0;
448
+ if (schema.allOf && schema.allOf.length === 2) {
449
+ const [first, second] = schema.allOf;
450
+ const refMember = first?.$ref ? first : second?.$ref ? second : null;
451
+ const objectMember = first?.$ref ? second : first;
452
+ if (refMember?.$ref && objectMember?.properties) {
453
+ const baseName = extractRefName(refMember.$ref);
454
+ if (baseName) {
455
+ const fields = schemaPropertiesToFields(objectMember, ctx);
456
+ return {
457
+ kind: "model",
458
+ name,
459
+ bases: [
460
+ baseName
461
+ ],
462
+ fields,
463
+ description,
464
+ loc: LOC
465
+ };
466
+ }
467
+ }
468
+ }
469
+ if (schema.properties || schema.type === "object" && !schema.additionalProperties) {
470
+ const fields = schemaPropertiesToFields(schema, ctx);
471
+ return {
472
+ kind: "model",
473
+ name,
474
+ fields,
475
+ description,
476
+ loc: LOC
477
+ };
478
+ }
479
+ const typeNode = schemaToTypeNode(schema, ctx);
480
+ return {
481
+ kind: "model",
482
+ name,
483
+ fields: [],
484
+ type: typeNode,
485
+ description,
486
+ loc: LOC
487
+ };
488
+ }
489
+ __name(schemaToModel, "schemaToModel");
490
+ function schemaToTypeNode(schema, ctx) {
491
+ if (schema.$ref) {
492
+ const refName = extractRefName(schema.$ref);
493
+ if (refName) {
494
+ if (ctx.circularRefs.has(refName)) {
495
+ return {
496
+ kind: "lazy",
497
+ inner: {
498
+ kind: "ref",
499
+ name: refName
500
+ }
501
+ };
502
+ }
503
+ return {
504
+ kind: "ref",
505
+ name: refName
506
+ };
507
+ }
508
+ ctx.warnings.warn(ctx.path, `Unresolvable $ref: ${schema.$ref}`);
509
+ return {
510
+ kind: "scalar",
511
+ name: "unknown"
512
+ };
513
+ }
514
+ if (schema.const !== void 0) {
515
+ return {
516
+ kind: "literal",
517
+ value: schema.const
518
+ };
519
+ }
520
+ if (schema.enum) {
521
+ return {
522
+ kind: "enum",
523
+ values: schema.enum.map(String)
524
+ };
525
+ }
526
+ if (schema.oneOf && schema.oneOf.length > 0) {
527
+ if (schema.discriminator?.propertyName) {
528
+ return toDiscriminatedUnion(schema.oneOf, schema.discriminator.propertyName, ctx);
529
+ }
530
+ return toUnion(schema.oneOf, ctx);
531
+ }
532
+ if (schema.anyOf && schema.anyOf.length > 0) {
533
+ if (schema.discriminator?.propertyName) {
534
+ return toDiscriminatedUnion(schema.anyOf, schema.discriminator.propertyName, ctx);
535
+ }
536
+ return toUnion(schema.anyOf, ctx);
537
+ }
538
+ if (schema.allOf && schema.allOf.length > 0) {
539
+ if (schema.allOf.length === 1) {
540
+ return schemaToTypeNode(schema.allOf[0], ctx);
541
+ }
542
+ return {
543
+ kind: "intersection",
544
+ members: schema.allOf.map((s) => schemaToTypeNode(s, ctx))
545
+ };
546
+ }
547
+ const types = normalizeTypeField(schema);
548
+ if (types === null) {
549
+ if (schema.properties) {
550
+ return schemaToInlineObject(schema, ctx);
551
+ }
552
+ return {
553
+ kind: "scalar",
554
+ name: "unknown"
555
+ };
556
+ }
557
+ const { baseType, nullable } = types;
558
+ let typeNode;
559
+ switch (baseType) {
560
+ case "string":
561
+ typeNode = stringSchemaToType(schema);
562
+ break;
563
+ case "integer":
564
+ typeNode = integerSchemaToType(schema);
565
+ break;
566
+ case "number":
567
+ typeNode = numberSchemaToType(schema);
568
+ break;
569
+ case "boolean":
570
+ typeNode = {
571
+ kind: "scalar",
572
+ name: "boolean"
573
+ };
574
+ break;
575
+ case "null":
576
+ typeNode = {
577
+ kind: "scalar",
578
+ name: "null"
579
+ };
580
+ break;
581
+ case "array":
582
+ typeNode = arraySchemaToType(schema, ctx);
583
+ break;
584
+ case "object":
585
+ typeNode = objectSchemaToType(schema, ctx);
586
+ break;
587
+ default:
588
+ ctx.warnings.warn(ctx.path, `Unknown type: ${baseType}`);
589
+ typeNode = {
590
+ kind: "scalar",
591
+ name: "unknown"
592
+ };
593
+ }
594
+ if (nullable) {
595
+ return {
596
+ kind: "union",
597
+ members: [
598
+ typeNode,
599
+ {
600
+ kind: "scalar",
601
+ name: "null"
602
+ }
603
+ ]
604
+ };
605
+ }
606
+ return typeNode;
607
+ }
608
+ __name(schemaToTypeNode, "schemaToTypeNode");
609
+ function stringSchemaToType(schema) {
610
+ if (schema.format) {
611
+ const scalarName = FORMAT_TO_SCALAR[schema.format];
612
+ if (scalarName) {
613
+ return {
614
+ kind: "scalar",
615
+ name: scalarName
616
+ };
617
+ }
618
+ }
619
+ const mods = {};
620
+ if (schema.minLength !== void 0 && schema.maxLength !== void 0 && schema.minLength === schema.maxLength) {
621
+ mods.len = schema.minLength;
622
+ } else {
623
+ if (schema.minLength !== void 0) mods.min = schema.minLength;
624
+ if (schema.maxLength !== void 0) mods.max = schema.maxLength;
625
+ }
626
+ if (schema.pattern) mods.regex = `/${schema.pattern}/`;
627
+ if (schema.format && !FORMAT_TO_SCALAR[schema.format]) mods.format = schema.format;
628
+ return {
629
+ kind: "scalar",
630
+ name: "string",
631
+ ...mods
632
+ };
633
+ }
634
+ __name(stringSchemaToType, "stringSchemaToType");
635
+ function integerSchemaToType(schema) {
636
+ const name = schema.format === "int64" ? "bigint" : "int";
637
+ const mods = {};
638
+ if (schema.minimum !== void 0) mods.min = schema.minimum;
639
+ if (schema.maximum !== void 0) mods.max = schema.maximum;
640
+ return {
641
+ kind: "scalar",
642
+ name,
643
+ ...mods
644
+ };
645
+ }
646
+ __name(integerSchemaToType, "integerSchemaToType");
647
+ function numberSchemaToType(schema) {
648
+ const mods = {};
649
+ if (schema.minimum !== void 0) mods.min = schema.minimum;
650
+ if (schema.maximum !== void 0) mods.max = schema.maximum;
651
+ return {
652
+ kind: "scalar",
653
+ name: "number",
654
+ ...mods
655
+ };
656
+ }
657
+ __name(numberSchemaToType, "numberSchemaToType");
658
+ function arraySchemaToType(schema, ctx) {
659
+ if (schema.prefixItems && schema.prefixItems.length > 0) {
660
+ return {
661
+ kind: "tuple",
662
+ items: schema.prefixItems.map((s) => schemaToTypeNode(s, ctx))
663
+ };
664
+ }
665
+ const item = schema.items ? schemaToTypeNode(schema.items, ctx) : {
666
+ kind: "scalar",
667
+ name: "unknown"
668
+ };
669
+ const mods = {};
670
+ if (schema.minItems !== void 0) mods.min = schema.minItems;
671
+ if (schema.maxItems !== void 0) mods.max = schema.maxItems;
672
+ return {
673
+ kind: "array",
674
+ item,
675
+ ...mods
676
+ };
677
+ }
678
+ __name(arraySchemaToType, "arraySchemaToType");
679
+ function objectSchemaToType(schema, ctx) {
680
+ if (schema.additionalProperties && typeof schema.additionalProperties === "object" && !schema.properties) {
681
+ return {
682
+ kind: "record",
683
+ key: {
684
+ kind: "scalar",
685
+ name: "string"
686
+ },
687
+ value: schemaToTypeNode(schema.additionalProperties, ctx)
688
+ };
689
+ }
690
+ if (schema.properties) {
691
+ return schemaToInlineObject(schema, ctx);
692
+ }
693
+ return {
694
+ kind: "scalar",
695
+ name: "object"
696
+ };
697
+ }
698
+ __name(objectSchemaToType, "objectSchemaToType");
699
+ function schemaToInlineObject(schema, ctx) {
700
+ const fields = schemaPropertiesToFields(schema, ctx);
701
+ return {
702
+ kind: "inlineObject",
703
+ fields
704
+ };
705
+ }
706
+ __name(schemaToInlineObject, "schemaToInlineObject");
707
+ function schemaPropertiesToFields(schema, ctx) {
708
+ const properties = schema.properties ?? {};
709
+ const required = new Set(schema.required ?? []);
710
+ const fields = [];
711
+ for (const [name, propSchema] of Object.entries(properties)) {
712
+ const propCtx = {
713
+ ...ctx,
714
+ path: `${ctx.path}/properties/${name}`
715
+ };
716
+ const fieldType = schemaToTypeNode(propSchema, propCtx);
717
+ let nullable = false;
718
+ let effectiveType = fieldType;
719
+ if (fieldType.kind === "union") {
720
+ const nonNull = fieldType.members.filter((m) => !(m.kind === "scalar" && m.name === "null"));
721
+ if (nonNull.length < fieldType.members.length) {
722
+ nullable = true;
723
+ effectiveType = nonNull.length === 1 ? nonNull[0] : {
724
+ kind: "union",
725
+ members: nonNull
726
+ };
727
+ }
728
+ }
729
+ const visibility = propSchema.readOnly ? "readonly" : propSchema.writeOnly ? "writeonly" : "normal";
730
+ fields.push({
731
+ name,
732
+ optional: !required.has(name),
733
+ nullable,
734
+ visibility,
735
+ type: effectiveType,
736
+ default: propSchema.default,
737
+ deprecated: propSchema.deprecated,
738
+ description: ctx.includeComments ? propSchema.description : void 0,
739
+ loc: LOC
740
+ });
741
+ }
742
+ return fields;
743
+ }
744
+ __name(schemaPropertiesToFields, "schemaPropertiesToFields");
745
+ function normalizeTypeField(schema) {
746
+ if (!schema.type) return null;
747
+ if (typeof schema.type === "string") {
748
+ return {
749
+ baseType: schema.type,
750
+ nullable: false
751
+ };
752
+ }
753
+ if (Array.isArray(schema.type)) {
754
+ const types = schema.type;
755
+ const nonNull = types.filter((t) => t !== "null");
756
+ const nullable = types.includes("null");
757
+ if (nonNull.length === 1) {
758
+ return {
759
+ baseType: nonNull[0],
760
+ nullable
761
+ };
762
+ }
763
+ if (nonNull.length === 0) {
764
+ return {
765
+ baseType: "null",
766
+ nullable: false
767
+ };
768
+ }
769
+ return {
770
+ baseType: nonNull[0],
771
+ nullable
772
+ };
773
+ }
774
+ return null;
775
+ }
776
+ __name(normalizeTypeField, "normalizeTypeField");
777
+ function toUnion(schemas, ctx) {
778
+ const members = schemas.map((s) => schemaToTypeNode(s, ctx));
779
+ if (members.length === 1) return members[0];
780
+ return {
781
+ kind: "union",
782
+ members
783
+ };
784
+ }
785
+ __name(toUnion, "toUnion");
786
+ function toDiscriminatedUnion(schemas, discriminator, ctx) {
787
+ const members = schemas.map((s) => schemaToTypeNode(s, ctx));
788
+ if (members.length === 1) return members[0];
789
+ return {
790
+ kind: "discriminatedUnion",
791
+ discriminator,
792
+ members
793
+ };
794
+ }
795
+ __name(toDiscriminatedUnion, "toDiscriminatedUnion");
796
+ function warnUnsupported(schema, ctx) {
797
+ if (schema.xml) ctx.warnings.warn(ctx.path, "xml metadata is not supported, skipping");
798
+ if (schema.externalDocs) ctx.warnings.info(ctx.path, "externalDocs is not supported, skipping");
799
+ if (schema.not) ctx.warnings.warn(ctx.path, "not keyword is not supported, skipping");
800
+ }
801
+ __name(warnUnsupported, "warnUnsupported");
802
+ function extractInlineModel(schema, suggestedName, ctx) {
803
+ if (schema.$ref) {
804
+ return {
805
+ typeNode: schemaToTypeNode(schema, ctx)
806
+ };
807
+ }
808
+ if (schema.properties || schema.type === "object" && schema.additionalProperties === void 0) {
809
+ const fields = schemaPropertiesToFields(schema, ctx);
810
+ const model = {
811
+ kind: "model",
812
+ name: suggestedName,
813
+ fields,
814
+ description: ctx.includeComments ? schema.description : void 0,
815
+ loc: LOC
816
+ };
817
+ return {
818
+ typeNode: {
819
+ kind: "ref",
820
+ name: suggestedName
821
+ },
822
+ model
823
+ };
824
+ }
825
+ return {
826
+ typeNode: schemaToTypeNode(schema, ctx)
827
+ };
828
+ }
829
+ __name(extractInlineModel, "extractInlineModel");
830
+ function sanitizeName(name, warnings) {
831
+ const cleaned = name.replace(/[^a-zA-Z0-9_$]/g, " ").split(/\s+/).filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
832
+ if (cleaned !== name) {
833
+ warnings.info(`#/components/schemas/${name}`, `Schema name sanitized: "${name}" \u2192 "${cleaned}"`);
834
+ }
835
+ return cleaned || "UnnamedSchema";
836
+ }
837
+ __name(sanitizeName, "sanitizeName");
838
+
839
+ // src/paths-to-ast.ts
840
+ var LOC2 = {
841
+ file: "",
842
+ line: 0
843
+ };
844
+ var HTTP_METHODS = [
845
+ "get",
846
+ "post",
847
+ "put",
848
+ "patch",
849
+ "delete"
850
+ ];
851
+ function pathsToRoutes(doc, ctx) {
852
+ const routes = [];
853
+ const routeTags = /* @__PURE__ */ new Map();
854
+ const paths = doc.paths ?? {};
855
+ for (const [path, pathItem] of Object.entries(paths)) {
856
+ if (!pathItem) continue;
857
+ const result = pathItemToRoute(path, pathItem, ctx);
858
+ if (result) {
859
+ routes.push(result.route);
860
+ routeTags.set(result.route, result.tag);
861
+ }
862
+ }
863
+ return {
864
+ routes,
865
+ routeTags
866
+ };
867
+ }
868
+ __name(pathsToRoutes, "pathsToRoutes");
869
+ function pathItemToRoute(path, pathItem, ctx) {
870
+ const operations = [];
871
+ let primaryTag = "default";
872
+ const pathParams = (pathItem.parameters ?? []).filter((p) => p.in === "path");
873
+ for (const method of HTTP_METHODS) {
874
+ const op = pathItem[method];
875
+ if (!op) continue;
876
+ const opNode = operationToNode(method, op, path, ctx);
877
+ operations.push(opNode);
878
+ if (op.tags && op.tags.length > 0 && primaryTag === "default") {
879
+ primaryTag = op.tags[0];
880
+ }
881
+ }
882
+ if (operations.length === 0) return null;
883
+ const params = buildPathParams(path, pathParams, pathItem, ctx);
884
+ const route = {
885
+ path,
886
+ operations,
887
+ loc: LOC2
888
+ };
889
+ if (params.length > 0) {
890
+ route.params = {
891
+ kind: "params",
892
+ nodes: params
893
+ };
894
+ }
895
+ if (pathItem.description && ctx.includeComments) {
896
+ route.description = pathItem.description;
897
+ }
898
+ return {
899
+ route,
900
+ tag: primaryTag
901
+ };
902
+ }
903
+ __name(pathItemToRoute, "pathItemToRoute");
904
+ function operationToNode(method, op, path, ctx) {
905
+ const pathPrefix = `#/paths/${encodePathSegment2(path)}/${method}`;
906
+ const schemaCtx = makeSchemaCtx(ctx, pathPrefix);
907
+ const node = {
908
+ method,
909
+ responses: [],
910
+ loc: LOC2
911
+ };
912
+ if (op.operationId) {
913
+ node.sdk = op.operationId;
914
+ }
915
+ if (op.description && ctx.includeComments) {
916
+ node.description = op.description;
917
+ }
918
+ if (op.deprecated) {
919
+ node.modifiers = [
920
+ "deprecated"
921
+ ];
922
+ }
923
+ const queryParams = [];
924
+ const headerParams = [];
925
+ for (const param of op.parameters ?? []) {
926
+ if (param.in === "query") {
927
+ queryParams.push(parameterToNode(param, schemaCtx));
928
+ } else if (param.in === "header") {
929
+ headerParams.push(parameterToNode(param, schemaCtx));
930
+ }
931
+ }
932
+ if (queryParams.length > 0) {
933
+ node.query = {
934
+ kind: "params",
935
+ nodes: queryParams
936
+ };
937
+ }
938
+ if (headerParams.length > 0) {
939
+ node.headers = {
940
+ kind: "params",
941
+ nodes: headerParams
942
+ };
943
+ }
944
+ if (op.requestBody) {
945
+ node.request = requestBodyToNode(op.requestBody, op.operationId ?? `${method}${toPascalCase(path)}`, schemaCtx, ctx);
946
+ }
947
+ const responses = op.responses ?? {};
948
+ for (const [code, resp] of Object.entries(responses)) {
949
+ const statusCode = parseInt(code, 10);
950
+ if (isNaN(statusCode)) continue;
951
+ const respNode = responseToNode(statusCode, resp, op.operationId ?? `${method}${toPascalCase(path)}`, schemaCtx, ctx);
952
+ node.responses.push(respNode);
953
+ }
954
+ if (op.security !== void 0) {
955
+ node.security = convertSecurity(op.security);
956
+ }
957
+ return node;
958
+ }
959
+ __name(operationToNode, "operationToNode");
960
+ function buildPathParams(path, pathLevelParams, pathItem, ctx) {
961
+ const schemaCtx = makeSchemaCtx(ctx, `#/paths/${encodePathSegment2(path)}`);
962
+ const paramMap = /* @__PURE__ */ new Map();
963
+ for (const p of pathLevelParams) {
964
+ paramMap.set(p.name, p);
965
+ }
966
+ for (const method of HTTP_METHODS) {
967
+ const op = pathItem[method];
968
+ if (!op?.parameters) continue;
969
+ for (const p of op.parameters) {
970
+ if (p.in === "path" && !paramMap.has(p.name)) {
971
+ paramMap.set(p.name, p);
972
+ }
973
+ }
974
+ }
975
+ const templateNames = [
976
+ ...path.matchAll(/\{([^}]+)\}/g)
977
+ ].map((m) => m[1]);
978
+ return templateNames.map((name) => {
979
+ const param = paramMap.get(name);
980
+ if (param) {
981
+ return parameterToNode(param, schemaCtx);
982
+ }
983
+ return {
984
+ name,
985
+ optional: false,
986
+ nullable: false,
987
+ type: {
988
+ kind: "scalar",
989
+ name: "string"
990
+ },
991
+ loc: LOC2
992
+ };
993
+ });
994
+ }
995
+ __name(buildPathParams, "buildPathParams");
996
+ function parameterToNode(param, ctx) {
997
+ const type = param.schema ? schemaToTypeNode(param.schema, ctx) : {
998
+ kind: "scalar",
999
+ name: "string"
1000
+ };
1001
+ return {
1002
+ name: param.name,
1003
+ optional: param.in !== "path" && !param.required,
1004
+ nullable: false,
1005
+ type,
1006
+ description: ctx.includeComments ? param.description : void 0,
1007
+ loc: LOC2
1008
+ };
1009
+ }
1010
+ __name(parameterToNode, "parameterToNode");
1011
+ function requestBodyToNode(reqBody, operationName, schemaCtx, ctx) {
1012
+ const content = reqBody.content;
1013
+ if (!content) return void 0;
1014
+ const supported = /* @__PURE__ */ new Set([
1015
+ "application/json",
1016
+ "application/x-www-form-urlencoded",
1017
+ "multipart/form-data"
1018
+ ]);
1019
+ const bodies = [];
1020
+ for (const [contentType, mediaType] of Object.entries(content)) {
1021
+ if (!supported.has(contentType) || !mediaType?.schema) continue;
1022
+ const { typeNode, model } = extractInlineModel(mediaType.schema, `${toPascalCase(operationName)}Request`, schemaCtx);
1023
+ if (model) {
1024
+ ctx.extractedModels.push(model);
1025
+ }
1026
+ bodies.push({
1027
+ contentType,
1028
+ bodyType: typeNode
1029
+ });
1030
+ }
1031
+ if (bodies.length === 0) return void 0;
1032
+ return {
1033
+ bodies
1034
+ };
1035
+ }
1036
+ __name(requestBodyToNode, "requestBodyToNode");
1037
+ function responseToNode(statusCode, resp, operationName, schemaCtx, ctx) {
1038
+ const headers = convertResponseHeaders(resp.headers, schemaCtx);
1039
+ if (!resp.content) {
1040
+ return headers ? {
1041
+ statusCode,
1042
+ headers
1043
+ } : {
1044
+ statusCode
1045
+ };
1046
+ }
1047
+ const [contentType, mediaType] = Object.entries(resp.content)[0] ?? [];
1048
+ if (!contentType || !mediaType?.schema) {
1049
+ return headers ? {
1050
+ statusCode,
1051
+ headers
1052
+ } : {
1053
+ statusCode
1054
+ };
1055
+ }
1056
+ const { typeNode, model } = extractInlineModel(mediaType.schema, `${toPascalCase(operationName)}Response${statusCode}`, schemaCtx);
1057
+ if (model) {
1058
+ ctx.extractedModels.push(model);
1059
+ }
1060
+ return {
1061
+ statusCode,
1062
+ contentType,
1063
+ bodyType: typeNode,
1064
+ ...headers ? {
1065
+ headers
1066
+ } : {}
1067
+ };
1068
+ }
1069
+ __name(responseToNode, "responseToNode");
1070
+ function convertResponseHeaders(headers, schemaCtx) {
1071
+ if (!headers) return void 0;
1072
+ const out = [];
1073
+ for (const [name, header] of Object.entries(headers)) {
1074
+ if (!header) continue;
1075
+ const type = header.schema ? schemaToTypeNode(header.schema, schemaCtx) : {
1076
+ kind: "scalar",
1077
+ name: "string"
1078
+ };
1079
+ out.push({
1080
+ name,
1081
+ optional: !header.required,
1082
+ type,
1083
+ description: schemaCtx.includeComments ? header.description : void 0
1084
+ });
1085
+ }
1086
+ return out.length > 0 ? out : void 0;
1087
+ }
1088
+ __name(convertResponseHeaders, "convertResponseHeaders");
1089
+ function convertSecurity(security) {
1090
+ if (security.length === 0) {
1091
+ return "none";
1092
+ }
1093
+ const allScopes = [];
1094
+ for (const requirement of security) {
1095
+ for (const scopes of Object.values(requirement)) {
1096
+ allScopes.push(...scopes);
1097
+ }
1098
+ }
1099
+ if (allScopes.length > 0) {
1100
+ return {
1101
+ roles: allScopes,
1102
+ loc: LOC2
1103
+ };
1104
+ }
1105
+ return {
1106
+ roles: [],
1107
+ loc: LOC2
1108
+ };
1109
+ }
1110
+ __name(convertSecurity, "convertSecurity");
1111
+ function makeSchemaCtx(ctx, path) {
1112
+ return {
1113
+ circularRefs: ctx.circularRefs,
1114
+ warnings: ctx.warnings,
1115
+ path,
1116
+ includeComments: ctx.includeComments,
1117
+ namedSchemas: ctx.namedSchemas,
1118
+ extractedModels: ctx.extractedModels,
1119
+ inlineCounter: 0
1120
+ };
1121
+ }
1122
+ __name(makeSchemaCtx, "makeSchemaCtx");
1123
+ function toPascalCase(input) {
1124
+ return input.replace(/[^a-zA-Z0-9]/g, " ").split(/\s+/).filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
1125
+ }
1126
+ __name(toPascalCase, "toPascalCase");
1127
+ function encodePathSegment2(s) {
1128
+ return s.replace(/~/g, "~0").replace(/\//g, "~1");
1129
+ }
1130
+ __name(encodePathSegment2, "encodePathSegment");
1131
+
1132
+ // src/tag-splitter.ts
1133
+ function splitByTag(models, routes, routeTags) {
1134
+ const routesByTag = /* @__PURE__ */ new Map();
1135
+ for (const route of routes) {
1136
+ const tag = routeTags.get(route) ?? "default";
1137
+ const group = routesByTag.get(tag) ?? [];
1138
+ group.push(route);
1139
+ routesByTag.set(tag, group);
1140
+ }
1141
+ const modelsByTag = /* @__PURE__ */ new Map();
1142
+ for (const [tag, tagRoutes] of routesByTag) {
1143
+ const refs = /* @__PURE__ */ new Set();
1144
+ for (const route of tagRoutes) {
1145
+ collectRouteRefs(route, refs);
1146
+ }
1147
+ modelsByTag.set(tag, refs);
1148
+ }
1149
+ const modelNameToModel = new Map(models.map((m) => [
1150
+ m.name,
1151
+ m
1152
+ ]));
1153
+ const modelAssignment = /* @__PURE__ */ new Map();
1154
+ for (const model of models) {
1155
+ const tags = [];
1156
+ for (const [tag, refs] of modelsByTag) {
1157
+ if (refs.has(model.name)) {
1158
+ tags.push(tag);
1159
+ }
1160
+ }
1161
+ if (tags.length === 0) {
1162
+ modelAssignment.set(model.name, "shared");
1163
+ } else if (tags.length === 1) {
1164
+ modelAssignment.set(model.name, tags[0]);
1165
+ } else {
1166
+ modelAssignment.set(model.name, "shared");
1167
+ }
1168
+ }
1169
+ for (const model of models) {
1170
+ if (modelAssignment.get(model.name) === "shared") {
1171
+ const refs = /* @__PURE__ */ new Set();
1172
+ collectModelRefs(model, refs);
1173
+ for (const ref of refs) {
1174
+ if (modelNameToModel.has(ref)) {
1175
+ const currentTag = modelAssignment.get(ref);
1176
+ if (currentTag && currentTag !== "shared") {
1177
+ const otherTags = [
1178
+ ...modelsByTag.entries()
1179
+ ].filter(([t, r]) => t !== currentTag && r.has(ref)).map(([t]) => t);
1180
+ if (otherTags.length > 0) {
1181
+ modelAssignment.set(ref, "shared");
1182
+ }
1183
+ }
1184
+ }
1185
+ }
1186
+ }
1187
+ }
1188
+ const result = /* @__PURE__ */ new Map();
1189
+ const allTags = /* @__PURE__ */ new Set([
1190
+ ...routesByTag.keys(),
1191
+ ...new Set(modelAssignment.values())
1192
+ ]);
1193
+ for (const tag of allTags) {
1194
+ const tagModels = models.filter((m) => modelAssignment.get(m.name) === tag);
1195
+ const tagRoutes = routesByTag.get(tag) ?? [];
1196
+ if (tagModels.length === 0 && tagRoutes.length === 0) continue;
1197
+ const filename = sanitizeFilename(tag);
1198
+ result.set(`${filename}.ck`, {
1199
+ kind: "ckRoot",
1200
+ meta: tag !== "shared" ? {
1201
+ area: tag
1202
+ } : {},
1203
+ services: {},
1204
+ models: tagModels,
1205
+ routes: tagRoutes,
1206
+ file: `${filename}.ck`
1207
+ });
1208
+ }
1209
+ return result;
1210
+ }
1211
+ __name(splitByTag, "splitByTag");
1212
+ function mergeIntoSingle(models, routes, filename = "api") {
1213
+ return {
1214
+ kind: "ckRoot",
1215
+ meta: {},
1216
+ services: {},
1217
+ models,
1218
+ routes,
1219
+ file: `${filename}.ck`
1220
+ };
1221
+ }
1222
+ __name(mergeIntoSingle, "mergeIntoSingle");
1223
+ function collectRouteRefs(route, refs) {
1224
+ if (route.params) {
1225
+ collectParamSourceRefs(route.params, refs);
1226
+ }
1227
+ for (const op of route.operations) {
1228
+ if (op.query) collectParamSourceRefs(op.query, refs);
1229
+ if (op.headers) collectParamSourceRefs(op.headers, refs);
1230
+ if (op.request) {
1231
+ for (const body of op.request.bodies) collectTypeRefs(body.bodyType, refs);
1232
+ }
1233
+ for (const resp of op.responses) {
1234
+ if (resp.bodyType) collectTypeRefs(resp.bodyType, refs);
1235
+ }
1236
+ }
1237
+ }
1238
+ __name(collectRouteRefs, "collectRouteRefs");
1239
+ function collectParamSourceRefs(source, refs) {
1240
+ if (typeof source === "string") {
1241
+ refs.add(source);
1242
+ return;
1243
+ }
1244
+ if (Array.isArray(source)) {
1245
+ for (const param of source) {
1246
+ if (param && typeof param === "object" && "type" in param) {
1247
+ collectTypeRefs(param.type, refs);
1248
+ }
1249
+ }
1250
+ return;
1251
+ }
1252
+ if (source && typeof source === "object" && "kind" in source) {
1253
+ collectTypeRefs(source, refs);
1254
+ }
1255
+ }
1256
+ __name(collectParamSourceRefs, "collectParamSourceRefs");
1257
+ function collectTypeRefs(type, refs) {
1258
+ switch (type.kind) {
1259
+ case "ref":
1260
+ refs.add(type.name);
1261
+ break;
1262
+ case "array":
1263
+ collectTypeRefs(type.item, refs);
1264
+ break;
1265
+ case "tuple":
1266
+ for (const item of type.items) collectTypeRefs(item, refs);
1267
+ break;
1268
+ case "record":
1269
+ collectTypeRefs(type.key, refs);
1270
+ collectTypeRefs(type.value, refs);
1271
+ break;
1272
+ case "union":
1273
+ case "discriminatedUnion":
1274
+ case "intersection":
1275
+ for (const member of type.members) collectTypeRefs(member, refs);
1276
+ break;
1277
+ case "inlineObject":
1278
+ for (const field of type.fields) collectTypeRefs(field.type, refs);
1279
+ break;
1280
+ case "lazy":
1281
+ collectTypeRefs(type.inner, refs);
1282
+ break;
1283
+ }
1284
+ }
1285
+ __name(collectTypeRefs, "collectTypeRefs");
1286
+ function collectModelRefs(model, refs) {
1287
+ if (model.bases) for (const b of model.bases) refs.add(b);
1288
+ if (model.type) collectTypeRefs(model.type, refs);
1289
+ for (const field of model.fields) {
1290
+ collectTypeRefs(field.type, refs);
1291
+ }
1292
+ }
1293
+ __name(collectModelRefs, "collectModelRefs");
1294
+ function sanitizeFilename(tag) {
1295
+ return tag.toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "") || "default";
1296
+ }
1297
+ __name(sanitizeFilename, "sanitizeFilename");
1298
+
1299
+ // src/ast-to-ck.ts
1300
+ var INDENT = " ";
1301
+ function astToCk(root, options = {}) {
1302
+ const { includeComments = true } = options;
1303
+ const ctx = {
1304
+ includeComments
1305
+ };
1306
+ const parts = [];
1307
+ const optionsBlock = serializeOptions(root);
1308
+ if (optionsBlock) parts.push(optionsBlock);
1309
+ for (const model of root.models) {
1310
+ parts.push(serializeModel(model, ctx));
1311
+ }
1312
+ for (const route of root.routes) {
1313
+ parts.push(serializeRoute(route, ctx));
1314
+ }
1315
+ return parts.join("\n\n") + "\n";
1316
+ }
1317
+ __name(astToCk, "astToCk");
1318
+ function serializeOptions(root) {
1319
+ const hasKeys = Object.keys(root.meta).length > 0;
1320
+ const hasServices = root.services && Object.keys(root.services).length > 0;
1321
+ const hasSecurity = root.security !== void 0;
1322
+ if (!hasKeys && !hasServices && !hasSecurity) return null;
1323
+ const lines = [
1324
+ "options {"
1325
+ ];
1326
+ if (hasKeys) {
1327
+ lines.push(`${INDENT}keys: {`);
1328
+ for (const [key, value] of Object.entries(root.meta)) {
1329
+ lines.push(`${INDENT}${INDENT}${key}: ${value}`);
1330
+ }
1331
+ lines.push(`${INDENT}}`);
1332
+ }
1333
+ if (hasServices) {
1334
+ lines.push(`${INDENT}services: {`);
1335
+ for (const [name, path] of Object.entries(root.services)) {
1336
+ lines.push(`${INDENT}${INDENT}${name}: "${path}"`);
1337
+ }
1338
+ lines.push(`${INDENT}}`);
1339
+ }
1340
+ if (hasSecurity) {
1341
+ lines.push(`${INDENT}security: {`);
1342
+ if (root.security === "none") {
1343
+ lines.push(`${INDENT}${INDENT}none`);
1344
+ } else {
1345
+ const sec = root.security;
1346
+ if (sec.roles && sec.roles.length > 0) {
1347
+ lines.push(`${INDENT}${INDENT}roles: [${sec.roles.join(", ")}]`);
1348
+ }
1349
+ }
1350
+ lines.push(`${INDENT}}`);
1351
+ }
1352
+ lines.push("}");
1353
+ return lines.join("\n");
1354
+ }
1355
+ __name(serializeOptions, "serializeOptions");
1356
+ function serializeModel(model, ctx) {
1357
+ const parts = [];
1358
+ const prefixes = [];
1359
+ if (model.inputCase && model.inputCase !== "camel") {
1360
+ prefixes.push(`format(input=${model.inputCase})`);
1361
+ }
1362
+ if (model.mode && model.mode !== "strict") {
1363
+ prefixes.push(`mode(${model.mode})`);
1364
+ }
1365
+ if (model.deprecated) {
1366
+ prefixes.push("deprecated");
1367
+ }
1368
+ const prefix = prefixes.length > 0 ? prefixes.join(" ") + " " : "";
1369
+ const comment = ctx.includeComments && model.description ? ` # ${model.description}` : "";
1370
+ if (model.type) {
1371
+ parts.push(`contract ${prefix}${model.name}: ${serializeType(model.type)}${comment}`);
1372
+ return parts.join("");
1373
+ }
1374
+ if (model.bases && model.bases.length > 0) {
1375
+ parts.push(`contract ${prefix}${model.name}: ${model.bases.join(" & ")} & {${comment}`);
1376
+ } else {
1377
+ parts.push(`contract ${prefix}${model.name}: {${comment}`);
1378
+ }
1379
+ for (const field of model.fields) {
1380
+ parts.push(serializeField(field, 1, ctx));
1381
+ }
1382
+ parts.push("}");
1383
+ return parts.join("\n");
1384
+ }
1385
+ __name(serializeModel, "serializeModel");
1386
+ function serializeField(field, depth, ctx) {
1387
+ const indent = INDENT.repeat(depth);
1388
+ const optional = field.optional ? "?" : "";
1389
+ const visibility = field.visibility !== "normal" ? `${field.visibility} ` : "";
1390
+ const deprecated = field.deprecated ? "deprecated " : "";
1391
+ let typeStr = serializeType(field.type);
1392
+ if (field.nullable && !typeContainsNull(field.type)) {
1393
+ typeStr = `${typeStr} | null`;
1394
+ }
1395
+ const defaultVal = field.default !== void 0 ? ` = ${serializeDefault(field.default)}` : "";
1396
+ const comment = ctx.includeComments && field.description ? ` # ${field.description}` : "";
1397
+ return `${indent}${field.name}${optional}: ${deprecated}${visibility}${typeStr}${defaultVal}${comment}`;
1398
+ }
1399
+ __name(serializeField, "serializeField");
1400
+ function typeContainsNull(type) {
1401
+ if (type.kind === "scalar" && type.name === "null") return true;
1402
+ if (type.kind === "union") return type.members.some(typeContainsNull);
1403
+ return false;
1404
+ }
1405
+ __name(typeContainsNull, "typeContainsNull");
1406
+ function serializeDefault(value) {
1407
+ if (typeof value === "string") {
1408
+ if (/^[a-zA-Z_$][a-zA-Z0-9_$\-.]*$/.test(value)) return value;
1409
+ return `"${value}"`;
1410
+ }
1411
+ return String(value);
1412
+ }
1413
+ __name(serializeDefault, "serializeDefault");
1414
+ function serializeType(type) {
1415
+ switch (type.kind) {
1416
+ case "scalar":
1417
+ return serializeScalar(type);
1418
+ case "array":
1419
+ return serializeArray(type);
1420
+ case "tuple":
1421
+ return `tuple(${type.items.map(serializeType).join(", ")})`;
1422
+ case "record":
1423
+ return `record(${serializeType(type.key)}, ${serializeType(type.value)})`;
1424
+ case "enum":
1425
+ return `enum(${type.values.join(", ")})`;
1426
+ case "literal":
1427
+ return serializeLiteral(type);
1428
+ case "union":
1429
+ return type.members.map(serializeType).join(" | ");
1430
+ case "discriminatedUnion":
1431
+ return `discriminated(by=${type.discriminator}, ${type.members.map(serializeType).join(" | ")})`;
1432
+ case "intersection":
1433
+ return type.members.map(serializeType).join(" & ");
1434
+ case "ref":
1435
+ return type.name;
1436
+ case "inlineObject":
1437
+ return serializeInlineObject(type);
1438
+ case "lazy":
1439
+ return `lazy(${serializeType(type.inner)})`;
1440
+ }
1441
+ }
1442
+ __name(serializeType, "serializeType");
1443
+ function serializeScalar(type) {
1444
+ const args = [];
1445
+ if (type.len !== void 0) args.push(`length=${type.len}`);
1446
+ if (type.min !== void 0) args.push(typeof type.min === "string" ? `min="${type.min}"` : `min=${type.min}`);
1447
+ if (type.max !== void 0) args.push(typeof type.max === "string" ? `max="${type.max}"` : `max=${type.max}`);
1448
+ if (type.regex !== void 0) args.push(`regex=${type.regex}`);
1449
+ if (type.format !== void 0) args.push(`format=${type.format}`);
1450
+ if (args.length === 0) return type.name;
1451
+ return `${type.name}(${args.join(", ")})`;
1452
+ }
1453
+ __name(serializeScalar, "serializeScalar");
1454
+ function serializeArray(type) {
1455
+ const args = [
1456
+ serializeType(type.item)
1457
+ ];
1458
+ if (type.min !== void 0) args.push(`min=${type.min}`);
1459
+ if (type.max !== void 0) args.push(`max=${type.max}`);
1460
+ return `array(${args.join(", ")})`;
1461
+ }
1462
+ __name(serializeArray, "serializeArray");
1463
+ function serializeLiteral(type) {
1464
+ if (typeof type.value === "string") return `literal("${type.value}")`;
1465
+ return `literal(${type.value})`;
1466
+ }
1467
+ __name(serializeLiteral, "serializeLiteral");
1468
+ function serializeInlineObject(type) {
1469
+ const modePrefix = type.mode ? `mode(${type.mode}) ` : "";
1470
+ if (type.fields.length === 0) return `${modePrefix}{}`;
1471
+ const lines = [
1472
+ `${modePrefix}{`
1473
+ ];
1474
+ for (const field of type.fields) {
1475
+ lines.push(serializeField(field, 2, {
1476
+ includeComments: true
1477
+ }));
1478
+ }
1479
+ lines.push(`${INDENT}}`);
1480
+ return lines.join("\n");
1481
+ }
1482
+ __name(serializeInlineObject, "serializeInlineObject");
1483
+ function serializeRoute(route, ctx) {
1484
+ const lines = [];
1485
+ const modStr = serializeModifiers(route.modifiers);
1486
+ const comment = ctx.includeComments && route.description ? ` # ${route.description}` : "";
1487
+ lines.push(`operation${modStr} ${route.path}: {${comment}`);
1488
+ if (route.params) {
1489
+ serializeParamSource(lines, "params", route.params, route.paramsMode, 1, ctx);
1490
+ }
1491
+ if (route.security !== void 0) {
1492
+ serializeSecurityBlock(lines, route.security, 1, ctx);
1493
+ }
1494
+ for (const op of route.operations) {
1495
+ serializeOperation(lines, op, 1, ctx);
1496
+ }
1497
+ lines.push("}");
1498
+ return lines.join("\n");
1499
+ }
1500
+ __name(serializeRoute, "serializeRoute");
1501
+ function serializeOperation(lines, op, depth, ctx) {
1502
+ const indent = INDENT.repeat(depth);
1503
+ const modStr = serializeModifiers(op.modifiers);
1504
+ const comment = ctx.includeComments && op.description ? ` # ${op.description}` : "";
1505
+ lines.push(`${indent}${op.method}${modStr}: {${comment}`);
1506
+ const inner = INDENT.repeat(depth + 1);
1507
+ if (op.service) {
1508
+ lines.push(`${inner}service: ${op.service}`);
1509
+ }
1510
+ if (op.sdk) {
1511
+ lines.push(`${inner}sdk: ${op.sdk}`);
1512
+ }
1513
+ if (op.signature) {
1514
+ const sigComment = ctx.includeComments && op.signatureDescription ? ` # ${op.signatureDescription}` : "";
1515
+ lines.push(`${inner}signature: ${op.signature}${sigComment}`);
1516
+ }
1517
+ if (op.security !== void 0) {
1518
+ serializeSecurityBlock(lines, op.security, depth + 1, ctx);
1519
+ }
1520
+ if (op.query) {
1521
+ serializeParamSource(lines, "query", op.query, op.queryMode, depth + 1, ctx);
1522
+ }
1523
+ if (op.headers) {
1524
+ serializeParamSource(lines, "headers", op.headers, op.headersMode, depth + 1, ctx);
1525
+ }
1526
+ if (op.request) {
1527
+ serializeRequest(lines, op.request, depth + 1);
1528
+ }
1529
+ if (op.responses.length > 0) {
1530
+ serializeResponses(lines, op.responses, depth + 1);
1531
+ }
1532
+ lines.push(`${indent}}`);
1533
+ return lines;
1534
+ }
1535
+ __name(serializeOperation, "serializeOperation");
1536
+ function serializeModifiers(modifiers) {
1537
+ if (!modifiers || modifiers.length === 0) return "";
1538
+ return `(${modifiers.join(", ")})`;
1539
+ }
1540
+ __name(serializeModifiers, "serializeModifiers");
1541
+ function serializeParamSource(lines, keyword, source, mode, depth, ctx) {
1542
+ const indent = INDENT.repeat(depth);
1543
+ if (source.kind === "ref") {
1544
+ lines.push(`${indent}${keyword}: ${source.name}`);
1545
+ return;
1546
+ }
1547
+ if (source.kind === "type") {
1548
+ lines.push(`${indent}${keyword}: ${serializeType(source.node)}`);
1549
+ return;
1550
+ }
1551
+ const modeStr = mode ? `mode(${mode}) ` : "";
1552
+ lines.push(`${indent}${keyword}: ${modeStr}{`);
1553
+ for (const param of source.nodes) {
1554
+ const optional = param.optional ? "?" : "";
1555
+ let typeStr = serializeType(param.type);
1556
+ if (param.nullable && !typeContainsNull(param.type)) {
1557
+ typeStr = `${typeStr} | null`;
1558
+ }
1559
+ const defaultVal = param.default !== void 0 ? ` = ${serializeDefault(param.default)}` : "";
1560
+ const comment = ctx.includeComments && param.description ? ` # ${param.description}` : "";
1561
+ lines.push(`${INDENT.repeat(depth + 1)}${param.name}${optional}: ${typeStr}${defaultVal}${comment}`);
1562
+ }
1563
+ lines.push(`${indent}}`);
1564
+ }
1565
+ __name(serializeParamSource, "serializeParamSource");
1566
+ function serializeRequest(lines, request, depth) {
1567
+ const indent = INDENT.repeat(depth);
1568
+ lines.push(`${indent}request: {`);
1569
+ for (const body of request.bodies) {
1570
+ lines.push(`${INDENT.repeat(depth + 1)}${body.contentType}: ${serializeType(body.bodyType)}`);
1571
+ }
1572
+ lines.push(`${indent}}`);
1573
+ }
1574
+ __name(serializeRequest, "serializeRequest");
1575
+ function serializeResponses(lines, responses, depth) {
1576
+ const indent = INDENT.repeat(depth);
1577
+ lines.push(`${indent}response: {`);
1578
+ for (const resp of responses) {
1579
+ const hasBody = resp.bodyType && resp.contentType;
1580
+ const hasHeaders = resp.headers && resp.headers.length > 0;
1581
+ if (hasBody || hasHeaders) {
1582
+ lines.push(`${INDENT.repeat(depth + 1)}${resp.statusCode}: {`);
1583
+ if (hasBody) {
1584
+ lines.push(`${INDENT.repeat(depth + 2)}${resp.contentType}: ${serializeType(resp.bodyType)}`);
1585
+ }
1586
+ if (hasHeaders) {
1587
+ lines.push(`${INDENT.repeat(depth + 2)}headers: {`);
1588
+ for (const h of resp.headers) {
1589
+ const opt = h.optional ? "?" : "";
1590
+ const trail = h.description ? ` # ${h.description}` : "";
1591
+ lines.push(`${INDENT.repeat(depth + 3)}${h.name}${opt}: ${serializeType(h.type)}${trail}`);
1592
+ }
1593
+ lines.push(`${INDENT.repeat(depth + 2)}}`);
1594
+ }
1595
+ lines.push(`${INDENT.repeat(depth + 1)}}`);
1596
+ } else {
1597
+ lines.push(`${INDENT.repeat(depth + 1)}${resp.statusCode}:`);
1598
+ }
1599
+ }
1600
+ lines.push(`${indent}}`);
1601
+ }
1602
+ __name(serializeResponses, "serializeResponses");
1603
+ function serializeSecurityBlock(lines, security, depth, ctx) {
1604
+ const indent = INDENT.repeat(depth);
1605
+ if (security === "none") {
1606
+ lines.push(`${indent}security: none`);
1607
+ return;
1608
+ }
1609
+ const sec = security;
1610
+ if (sec.roles && sec.roles.length > 0) {
1611
+ const rolesComment = ctx.includeComments && sec.rolesDescription ? ` # ${sec.rolesDescription}` : "";
1612
+ lines.push(`${indent}security: {`);
1613
+ lines.push(`${INDENT.repeat(depth + 1)}roles: [${sec.roles.join(", ")}]${rolesComment}`);
1614
+ lines.push(`${indent}}`);
1615
+ } else {
1616
+ lines.push(`${indent}security: {}`);
1617
+ }
1618
+ }
1619
+ __name(serializeSecurityBlock, "serializeSecurityBlock");
1620
+
1621
+ // src/convert.ts
1622
+ import { readFileSync } from "fs";
1623
+ import { parse as parseYaml } from "yaml";
1624
+
1625
+ // src/warnings.ts
1626
+ var WarningCollector = class {
1627
+ static {
1628
+ __name(this, "WarningCollector");
1629
+ }
1630
+ warnings = [];
1631
+ onWarning;
1632
+ constructor(onWarning) {
1633
+ this.onWarning = onWarning;
1634
+ }
1635
+ warn(path, message) {
1636
+ this.add({
1637
+ path,
1638
+ message,
1639
+ severity: "warn"
1640
+ });
1641
+ }
1642
+ info(path, message) {
1643
+ this.add({
1644
+ path,
1645
+ message,
1646
+ severity: "info"
1647
+ });
1648
+ }
1649
+ add(warning) {
1650
+ this.warnings.push(warning);
1651
+ this.onWarning?.(warning);
1652
+ }
1653
+ };
1654
+
1655
+ // src/convert.ts
1656
+ async function convertOpenApiToCk(options) {
1657
+ const { split = "by-tag", includeComments = true } = options;
1658
+ const warnings = new WarningCollector(options.onWarning);
1659
+ const rawDoc = await parseInput(options.input);
1660
+ const doc = normalize(rawDoc, warnings);
1661
+ const schemas = sanitizeSchemaNames(doc, warnings);
1662
+ const circularRefs = detectCircularRefs(schemas);
1663
+ const extractedModels = [];
1664
+ const schemaCtx = {
1665
+ circularRefs,
1666
+ warnings,
1667
+ path: "#/components/schemas",
1668
+ includeComments,
1669
+ namedSchemas: schemas,
1670
+ extractedModels,
1671
+ inlineCounter: 0
1672
+ };
1673
+ const models = schemasToModels(schemas, schemaCtx);
1674
+ const { routes, routeTags } = pathsToRoutes(doc, {
1675
+ circularRefs,
1676
+ warnings,
1677
+ includeComments,
1678
+ namedSchemas: schemas,
1679
+ extractedModels,
1680
+ globalSecurity: doc.security
1681
+ });
1682
+ const files = /* @__PURE__ */ new Map();
1683
+ if (split === "by-tag") {
1684
+ const ckRoots = splitByTag(models, routes, routeTags);
1685
+ for (const [filename, root] of ckRoots) {
1686
+ files.set(filename, astToCk(root, {
1687
+ includeComments
1688
+ }));
1689
+ }
1690
+ } else {
1691
+ const root = mergeIntoSingle(models, routes);
1692
+ files.set("api.ck", astToCk(root, {
1693
+ includeComments
1694
+ }));
1695
+ }
1696
+ return {
1697
+ files,
1698
+ warnings: warnings.warnings
1699
+ };
1700
+ }
1701
+ __name(convertOpenApiToCk, "convertOpenApiToCk");
1702
+ async function parseInput(input) {
1703
+ if (typeof input === "object") {
1704
+ return input;
1705
+ }
1706
+ try {
1707
+ const content = readFileSync(input, "utf-8");
1708
+ return parseJsonOrYaml(content);
1709
+ } catch {
1710
+ return parseJsonOrYaml(input);
1711
+ }
1712
+ }
1713
+ __name(parseInput, "parseInput");
1714
+ function parseJsonOrYaml(content) {
1715
+ try {
1716
+ return JSON.parse(content);
1717
+ } catch {
1718
+ return parseYaml(content);
1719
+ }
1720
+ }
1721
+ __name(parseJsonOrYaml, "parseJsonOrYaml");
1722
+ function sanitizeSchemaNames(doc, warnings) {
1723
+ const original = doc.components?.schemas ?? {};
1724
+ const sanitized = {};
1725
+ const nameMap = /* @__PURE__ */ new Map();
1726
+ for (const name of Object.keys(original)) {
1727
+ const clean = sanitizeName(name, warnings);
1728
+ if (sanitized[clean]) {
1729
+ warnings.warn(`#/components/schemas/${name}`, `Name collision after sanitization: "${name}" and another schema both map to "${clean}"`);
1730
+ let i = 2;
1731
+ while (sanitized[`${clean}${i}`]) i++;
1732
+ nameMap.set(name, `${clean}${i}`);
1733
+ sanitized[`${clean}${i}`] = original[name];
1734
+ } else {
1735
+ nameMap.set(name, clean);
1736
+ sanitized[clean] = original[name];
1737
+ }
1738
+ }
1739
+ if (nameMap.size > 0) {
1740
+ updateRefs(doc, nameMap);
1741
+ }
1742
+ return sanitized;
1743
+ }
1744
+ __name(sanitizeSchemaNames, "sanitizeSchemaNames");
1745
+ function updateRefs(obj, nameMap) {
1746
+ if (!obj || typeof obj !== "object") return;
1747
+ if (Array.isArray(obj)) {
1748
+ for (const item of obj) updateRefs(item, nameMap);
1749
+ return;
1750
+ }
1751
+ const record = obj;
1752
+ if (typeof record.$ref === "string") {
1753
+ const match = record.$ref.match(/^#\/components\/schemas\/(.+)$/);
1754
+ if (match?.[1] && nameMap.has(match[1])) {
1755
+ record.$ref = `#/components/schemas/${nameMap.get(match[1])}`;
1756
+ }
1757
+ }
1758
+ for (const value of Object.values(record)) {
1759
+ updateRefs(value, nameMap);
1760
+ }
1761
+ }
1762
+ __name(updateRefs, "updateRefs");
1763
+
1764
+ export {
1765
+ __name,
1766
+ normalize,
1767
+ detectCircularRefs,
1768
+ extractRefName,
1769
+ schemasToModels,
1770
+ schemaToTypeNode,
1771
+ sanitizeName,
1772
+ pathsToRoutes,
1773
+ splitByTag,
1774
+ mergeIntoSingle,
1775
+ astToCk,
1776
+ serializeType,
1777
+ convertOpenApiToCk
1778
+ };
1779
+ //# sourceMappingURL=chunk-REM25FDE.js.map