@moinax/orc 0.1.3 → 0.2.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.
package/README.md CHANGED
@@ -97,6 +97,11 @@ export default defineConfig({
97
97
  // Optional: strip a prefix from all API paths
98
98
  // Useful when the spec includes a base path like /public
99
99
  stripPathPrefix: '/public',
100
+
101
+ // Optional: prefix all generated schema/type/enum names
102
+ // Useful when generating multiple clients to avoid naming collisions
103
+ // e.g., 'Charge' → chargePetSchema, ChargePet, ChargeContractStatus
104
+ schemaPrefix: 'Charge',
100
105
  },
101
106
  ],
102
107
  });
package/dist/cli.js CHANGED
@@ -43,18 +43,27 @@ function isBooleanLikeEnum(values) {
43
43
  const sorted = [...values].sort();
44
44
  return sorted[0] === "false" && sorted[1] === "true";
45
45
  }
46
- function getResourcePrefixedParamNames(methodName, resourceClassName) {
46
+ function prefixSchemaConst(name, schemaPrefix) {
47
+ if (!schemaPrefix) return `${camelCase(name)}Schema`;
48
+ return `${camelCase(schemaPrefix)}${pascalCase(name)}Schema`;
49
+ }
50
+ function prefixTypeName(name, schemaPrefix) {
51
+ if (!schemaPrefix) return pascalCase(name);
52
+ return `${pascalCase(schemaPrefix)}${pascalCase(name)}`;
53
+ }
54
+ function getResourcePrefixedParamNames(methodName, resourceClassName, schemaPrefix) {
47
55
  const singularResource = singularize(resourceClassName);
56
+ const prefix = schemaPrefix ? pascalCase(schemaPrefix) : "";
48
57
  if (methodName.startsWith("get")) {
49
58
  const rest = methodName.slice(3);
50
59
  return {
51
- schemaConstName: `get${singularResource}${rest}ParamsSchema`,
52
- typeName: `Get${singularResource}${rest}Params`
60
+ schemaConstName: `get${prefix}${singularResource}${rest}ParamsSchema`,
61
+ typeName: `Get${prefix}${singularResource}${rest}Params`
53
62
  };
54
63
  }
55
64
  return {
56
- schemaConstName: `${camelCase(methodName)}${singularResource}ParamsSchema`,
57
- typeName: `${pascalCase(methodName)}${singularResource}Params`
65
+ schemaConstName: `${camelCase(methodName)}${prefix}${singularResource}ParamsSchema`,
66
+ typeName: `${pascalCase(methodName)}${prefix}${singularResource}Params`
58
67
  };
59
68
  }
60
69
  function validateFileName(name, context) {
@@ -182,6 +191,10 @@ var EnumRegistry = class _EnumRegistry {
182
191
  enums = /* @__PURE__ */ new Map();
183
192
  enumContexts = /* @__PURE__ */ new Map();
184
193
  usedNames = /* @__PURE__ */ new Set();
194
+ schemaPrefix;
195
+ constructor(schemaPrefix) {
196
+ this.schemaPrefix = schemaPrefix || "";
197
+ }
185
198
  static fingerprint(values) {
186
199
  return JSON.stringify([...values].sort());
187
200
  }
@@ -199,6 +212,9 @@ var EnumRegistry = class _EnumRegistry {
199
212
  } else {
200
213
  baseName = camelCase(values[0].toLowerCase());
201
214
  }
215
+ if (this.schemaPrefix) {
216
+ baseName = camelCase(this.schemaPrefix) + pascalCase(baseName);
217
+ }
202
218
  const valuesConstName = pluralizeLib2.isPlural(baseName) ? baseName : pluralizeLib2.plural(baseName);
203
219
  return {
204
220
  valuesConstName,
@@ -277,12 +293,14 @@ var ResourceGenerator = class {
277
293
  collectedInlineSchemas = /* @__PURE__ */ new Map();
278
294
  currentResourceName = null;
279
295
  runtimePackage;
296
+ schemaPrefix;
280
297
  constructor(paths, schemas, clientClassName, options = {}) {
281
298
  this.schemas = schemas || {};
282
299
  this.clientClassName = clientClassName;
283
300
  this.stripPathPrefix = options.stripPathPrefix || null;
284
301
  this.enumRegistry = options.enumRegistry || new EnumRegistry();
285
302
  this.runtimePackage = options.runtimePackage || "@moinax/orc";
303
+ this.schemaPrefix = options.schemaPrefix || "";
286
304
  this.paths = this.stripPathPrefix ? this.stripPrefixFromPaths(paths || {}) : paths || {};
287
305
  this.pathTree = buildPathTree(this.paths);
288
306
  }
@@ -318,7 +336,7 @@ var ResourceGenerator = class {
318
336
  this.collectedInlineSchemas.set(schemaConstName, {
319
337
  schema: bodySchema,
320
338
  isInput: true,
321
- typeName: `${pascalCase(resourceClassName)}${pascalCase(methodName)}Body`
339
+ typeName: prefixTypeName(`${resourceClassName}${pascalCase(methodName)}Body`, this.schemaPrefix)
322
340
  });
323
341
  }
324
342
  }
@@ -335,7 +353,7 @@ var ResourceGenerator = class {
335
353
  this.collectedInlineSchemas.set(schemaConstName, {
336
354
  schema: inlineSchema,
337
355
  isInput: false,
338
- typeName: `${pascalCase(resourceClassName)}${pascalCase(methodName)}Response`
356
+ typeName: prefixTypeName(`${resourceClassName}${pascalCase(methodName)}Response`, this.schemaPrefix)
339
357
  });
340
358
  }
341
359
  }
@@ -430,7 +448,8 @@ var ResourceGenerator = class {
430
448
  return schema.type === "object" && !!schema.properties;
431
449
  }
432
450
  generateInlineSchemaName(resourceName, methodName, purpose) {
433
- const baseName = `${camelCase(resourceName)}${capitalize(methodName)}${capitalize(purpose)}Schema`;
451
+ const prefix = this.schemaPrefix ? camelCase(this.schemaPrefix) : "";
452
+ const baseName = `${prefix}${prefix ? pascalCase(resourceName) : camelCase(resourceName)}${capitalize(methodName)}${capitalize(purpose)}Schema`;
434
453
  return camelCase(baseName);
435
454
  }
436
455
  getPathParams(operation) {
@@ -576,15 +595,15 @@ var ResourceGenerator = class {
576
595
  for (const { pathPattern, operation } of node.operations) {
577
596
  const responseSchema = this.getResponseSchemaName(operation, pathPattern);
578
597
  if (responseSchema) {
579
- const schemaConst = `${camelCase(responseSchema)}Schema`;
598
+ const schemaConst = prefixSchemaConst(responseSchema, this.schemaPrefix);
580
599
  schemaImports.add(schemaConst);
581
- typeImports.set(schemaConst, pascalCase(responseSchema));
600
+ typeImports.set(schemaConst, prefixTypeName(responseSchema, this.schemaPrefix));
582
601
  }
583
602
  const requestSchema = this.getRequestSchemaName(operation, pathPattern);
584
603
  if (requestSchema) {
585
- const schemaConst = `${camelCase(requestSchema)}Schema`;
604
+ const schemaConst = prefixSchemaConst(requestSchema, this.schemaPrefix);
586
605
  schemaImports.add(schemaConst);
587
- typeImports.set(schemaConst, pascalCase(requestSchema));
606
+ typeImports.set(schemaConst, prefixTypeName(requestSchema, this.schemaPrefix));
588
607
  }
589
608
  }
590
609
  const inlineBodySchemas = /* @__PURE__ */ new Map();
@@ -645,7 +664,7 @@ var ResourceGenerator = class {
645
664
  if (queryParams.length > 0) {
646
665
  const opKey = this.getOperationKey(pathPattern, httpMethod);
647
666
  const methodName = operationMethodNames.get(opKey);
648
- const { schemaConstName, typeName } = getResourcePrefixedParamNames(methodName, resourceClassName);
667
+ const { schemaConstName, typeName } = getResourcePrefixedParamNames(methodName, resourceClassName, this.schemaPrefix);
649
668
  const specificParams = queryParams.filter((p) => !this.isPaginationParam(p.name));
650
669
  if (specificParams.length > 0) {
651
670
  const props = specificParams.map((p) => {
@@ -701,14 +720,14 @@ ${props.join(",\n")},
701
720
  params.push(`${p.name}: ${p.type}`);
702
721
  }
703
722
  if (queryParams.length > 0) {
704
- const { typeName } = getResourcePrefixedParamNames(methodName, resourceClassName);
723
+ const { typeName } = getResourcePrefixedParamNames(methodName, resourceClassName, this.schemaPrefix);
705
724
  const hasRequired = queryParams.some((p) => p.required);
706
725
  params.push(`params${hasRequired ? "" : "?"}: ${typeName}`);
707
726
  }
708
727
  const inlineBodySchema = inlineBodySchemas.get(opKey);
709
728
  if (["post", "put", "patch"].includes(httpMethod) && operation.requestBody) {
710
729
  if (requestSchema) {
711
- const schemaConst = `${camelCase(requestSchema)}Schema`;
730
+ const schemaConst = prefixSchemaConst(requestSchema, this.schemaPrefix);
712
731
  const typeName = typeImports.get(schemaConst);
713
732
  params.push(`body: ${typeName}`);
714
733
  } else if (inlineBodySchema) {
@@ -731,8 +750,8 @@ ${props.join(",\n")},
731
750
  if (dataRef) {
732
751
  const rawItemSchema = dataRef.split("/").pop();
733
752
  const itemSchema = cleanSchemaName(rawItemSchema);
734
- const itemSchemaConst = `${camelCase(itemSchema)}Schema`;
735
- const itemTypeName = pascalCase(itemSchema);
753
+ const itemSchemaConst = prefixSchemaConst(itemSchema, this.schemaPrefix);
754
+ const itemTypeName = prefixTypeName(itemSchema, this.schemaPrefix);
736
755
  schemaImports.add(itemSchemaConst);
737
756
  typeImports.set(itemSchemaConst, itemTypeName);
738
757
  returnType = `{ pagination: PaginationResponse; data: ${itemTypeName}[] }`;
@@ -740,8 +759,8 @@ ${props.join(",\n")},
740
759
  return parseSchema(schema, response);`;
741
760
  } else {
742
761
  if (responseSchema) {
743
- const itemSchemaConst = `${camelCase(responseSchema)}Schema`;
744
- const itemTypeName = pascalCase(responseSchema);
762
+ const itemSchemaConst = prefixSchemaConst(responseSchema, this.schemaPrefix);
763
+ const itemTypeName = prefixTypeName(responseSchema, this.schemaPrefix);
745
764
  schemaImports.add(itemSchemaConst);
746
765
  typeImports.set(itemSchemaConst, itemTypeName);
747
766
  returnType = `{ pagination: PaginationResponse; data: ${itemTypeName}[] }`;
@@ -754,8 +773,8 @@ ${props.join(",\n")},
754
773
  }
755
774
  }
756
775
  } else if (responseSchema) {
757
- const schemaConstName = `${camelCase(responseSchema)}Schema`;
758
- const typeName = pascalCase(responseSchema);
776
+ const schemaConstName = prefixSchemaConst(responseSchema, this.schemaPrefix);
777
+ const typeName = prefixTypeName(responseSchema, this.schemaPrefix);
759
778
  returnType = typeName;
760
779
  parseLogic = `return parseSchema(${schemaConstName}, response);`;
761
780
  schemaImports.add(schemaConstName);
@@ -772,7 +791,7 @@ ${props.join(",\n")},
772
791
  lines.push("");
773
792
  lines.push(` async ${methodName}(${params.join(", ")}): Promise<${returnType}> {`);
774
793
  if (queryParams.length > 0) {
775
- const { schemaConstName } = getResourcePrefixedParamNames(methodName, resourceClassName);
794
+ const { schemaConstName } = getResourcePrefixedParamNames(methodName, resourceClassName, this.schemaPrefix);
776
795
  lines.push(` const searchParams = new URLSearchParams();`);
777
796
  lines.push(` if (params) {`);
778
797
  lines.push(` const validated = parseSchema(${schemaConstName}, params);`);
@@ -790,7 +809,7 @@ ${props.join(",\n")},
790
809
  const hasBodyValidation = ["post", "put", "patch"].includes(httpMethod) && hasBodySchema;
791
810
  const bodyVar = hasBodyValidation ? "validatedBody" : "body";
792
811
  if (hasBodyValidation) {
793
- const bodySchemaConst = requestSchema ? `${camelCase(requestSchema)}Schema` : inlineBodySchema.schemaConst;
812
+ const bodySchemaConst = requestSchema ? prefixSchemaConst(requestSchema, this.schemaPrefix) : inlineBodySchema.schemaConst;
794
813
  lines.push(` const validatedBody = parseSchema(${bodySchemaConst}, body);`);
795
814
  }
796
815
  switch (httpMethod) {
@@ -877,9 +896,11 @@ var ZodGenerator = class {
877
896
  };
878
897
  currentSchemaName = null;
879
898
  currentPropertyPath = null;
880
- constructor(schemas, enumRegistry) {
899
+ schemaPrefix;
900
+ constructor(schemas, enumRegistry, schemaPrefix) {
881
901
  this.schemas = schemas || {};
882
902
  this.enumRegistry = enumRegistry || new EnumRegistry();
903
+ this.schemaPrefix = schemaPrefix || "";
883
904
  }
884
905
  addInlineSchemas(inlineSchemas) {
885
906
  this.inlineSchemas = inlineSchemas;
@@ -889,7 +910,7 @@ var ZodGenerator = class {
889
910
  if (schema.$ref) {
890
911
  const refName = schema.$ref.split("/").pop();
891
912
  const cleanedName = cleanSchemaName(refName);
892
- return `${camelCase(cleanedName)}Schema`;
913
+ return prefixSchemaConst(cleanedName, this.schemaPrefix);
893
914
  }
894
915
  if (schema.anyOf) {
895
916
  const options = schema.anyOf.map((s) => this.convertSchema(s, schemaName));
@@ -1174,8 +1195,8 @@ ${properties.join(",\n")}
1174
1195
  } else if (cleanName.endsWith("Schema")) {
1175
1196
  cleanName = cleanName.replace("Schema", "");
1176
1197
  }
1177
- const schemaConstName = camelCase(cleanName) + "Schema";
1178
- const typeName = pascalCase(cleanName);
1198
+ const schemaConstName = prefixSchemaConst(cleanName, this.schemaPrefix);
1199
+ const typeName = prefixTypeName(cleanName, this.schemaPrefix);
1179
1200
  if (usedNames.has(schemaConstName) || usedNames.has(typeName)) {
1180
1201
  continue;
1181
1202
  }
@@ -1241,23 +1262,12 @@ ${properties.join(",\n")}
1241
1262
  // src/generator/file-writer.ts
1242
1263
  import fs from "fs";
1243
1264
  import path from "path";
1244
- import prettier from "prettier";
1245
- async function formatCode(code, filepath) {
1246
- try {
1247
- const options = await prettier.resolveConfig(filepath);
1248
- return prettier.format(code, { ...options, parser: "typescript" });
1249
- } catch (error) {
1250
- console.warn(`Warning: Could not format ${filepath}:`, error.message);
1251
- return code;
1252
- }
1253
- }
1254
1265
  async function writeFile(filepath, content) {
1255
1266
  const dir = path.dirname(filepath);
1256
1267
  if (!fs.existsSync(dir)) {
1257
1268
  fs.mkdirSync(dir, { recursive: true });
1258
1269
  }
1259
- const formatted = await formatCode(content, filepath);
1260
- fs.writeFileSync(filepath, formatted);
1270
+ fs.writeFileSync(filepath, content);
1261
1271
  console.log(`Generated: ${filepath}`);
1262
1272
  }
1263
1273
 
@@ -1313,16 +1323,17 @@ ${"=".repeat(60)}`);
1313
1323
  Cleaned up ${outputDir}`);
1314
1324
  }
1315
1325
  const spec = await loadSpec(specUrl);
1316
- const enumRegistry = new EnumRegistry();
1326
+ const enumRegistry = new EnumRegistry(config.schemaPrefix);
1317
1327
  const resourceGenerator = new ResourceGenerator(spec.paths, spec.components?.schemas, clientClassName, {
1318
1328
  stripPathPrefix: config.stripPathPrefix,
1319
1329
  enumRegistry,
1320
- runtimePackage
1330
+ runtimePackage,
1331
+ schemaPrefix: config.schemaPrefix
1321
1332
  });
1322
1333
  console.log("\nGenerating resource classes...");
1323
1334
  const { resources, tree, inlineSchemas } = resourceGenerator.generateAll();
1324
1335
  console.log("\nGenerating Zod schemas...");
1325
- const zodGenerator = new ZodGenerator(spec.components?.schemas, enumRegistry);
1336
+ const zodGenerator = new ZodGenerator(spec.components?.schemas, enumRegistry, config.schemaPrefix);
1326
1337
  zodGenerator.addInlineSchemas(inlineSchemas);
1327
1338
  const schemasCode = zodGenerator.generateSchemas(runtimePackage);
1328
1339
  const generatedFiles = [];
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli.ts","../src/generator/client-generator.ts","../src/generator/enum-registry.ts","../src/generator/utils.ts","../src/generator/resource-generator.ts","../src/generator/zod-generator.ts","../src/generator/file-writer.ts","../src/generator/spec-loader.ts","../src/cli/commands/generate.ts","../src/cli/commands/init.ts"],"sourcesContent":["import { Command } from 'commander';\nimport path from 'path';\nimport fs from 'fs';\nimport { createJiti } from 'jiti';\nimport type { OrcConfig } from './generator/config';\nimport { runGenerate } from './cli/commands/generate';\nimport { runInit } from './cli/commands/init';\n\nconst CONFIG_NAMES = ['orc.config.ts', 'orc.config.js', 'orc.config.mjs'];\n\nasync function loadConfig(): Promise<OrcConfig> {\n const cwd = process.cwd();\n\n for (const configName of CONFIG_NAMES) {\n const configPath = path.join(cwd, configName);\n if (fs.existsSync(configPath)) {\n console.log(`Using config: ${configPath}`);\n const jiti = createJiti(cwd, { interopDefault: true });\n const config = await jiti.import(configPath) as OrcConfig;\n return config;\n }\n }\n\n throw new Error(\n `No config file found. Create one with 'orc init' or add one of: ${CONFIG_NAMES.join(', ')}`,\n );\n}\n\nconst program = new Command();\n\nprogram\n .name('orc')\n .description('ORC - OpenAPI Rest Client Generator')\n .version('0.1.0');\n\nprogram\n .command('generate')\n .description('Generate TypeScript API clients from OpenAPI specs')\n .option('-c, --client <name>', 'Generate a specific client only')\n .option('-s, --spec <url>', 'Override spec URL (requires --client)')\n .action(async (options) => {\n const config = await loadConfig();\n await runGenerate(config, options);\n });\n\nprogram\n .command('init')\n .description('Scaffold a new orc.config.ts file')\n .action(async () => {\n await runInit();\n });\n\nprogram.parse();\n","import fs from 'fs';\nimport path from 'path';\nimport { EnumRegistry } from './enum-registry';\nimport { ResourceGenerator } from './resource-generator';\nimport { ZodGenerator } from './zod-generator';\nimport { writeFile, type GeneratedFile } from './file-writer';\nimport { loadSpec } from './spec-loader';\nimport {\n validateFileName,\n validateOutputPath,\n pascalCase,\n singularize,\n camelCase,\n} from './utils';\nimport type { ClientConfig } from './config';\n\nexport interface GenerateResult {\n name: string;\n resourceNames: string[];\n files?: GeneratedFile[];\n}\n\nexport async function generateClient(\n config: ClientConfig,\n options: {\n specOverride?: string;\n write?: boolean;\n runtimePackage?: string;\n } = {},\n): Promise<GenerateResult> {\n const { name, output } = config;\n const specUrl = options.specOverride || config.spec;\n const shouldWrite = options.write !== false;\n const runtimePackage = options.runtimePackage || '@moinax/orc';\n\n validateOutputPath(output);\n\n const outputDir = path.join(output, 'generated');\n const clientClassName = `${name}Client`;\n\n validateFileName(clientClassName, 'client class name');\n\n console.log(`\\n${'='.repeat(60)}`);\n console.log(`Generating ${clientClassName}...`);\n console.log(`${'='.repeat(60)}`);\n\n // Clean up previously generated files\n if (shouldWrite && fs.existsSync(outputDir)) {\n fs.rmSync(outputDir, { recursive: true });\n console.log(`\\nCleaned up ${outputDir}`);\n }\n\n // Fetch/load OpenAPI spec\n const spec = await loadSpec(specUrl);\n\n // Create shared enum registry\n const enumRegistry = new EnumRegistry();\n\n // Create resource generator\n const resourceGenerator = new ResourceGenerator(spec.paths, spec.components?.schemas, clientClassName, {\n stripPathPrefix: config.stripPathPrefix,\n enumRegistry,\n runtimePackage,\n });\n\n // Generate resources FIRST (registers query param enums)\n console.log('\\nGenerating resource classes...');\n const { resources, tree, inlineSchemas } = resourceGenerator.generateAll();\n\n // Generate schemas (including inline schemas from resources)\n console.log('\\nGenerating Zod schemas...');\n const zodGenerator = new ZodGenerator(spec.components?.schemas, enumRegistry);\n zodGenerator.addInlineSchemas(inlineSchemas);\n const schemasCode = zodGenerator.generateSchemas(runtimePackage);\n\n const generatedFiles: GeneratedFile[] = [];\n\n // schemas.ts\n generatedFiles.push({\n path: path.join(outputDir, 'schemas.ts'),\n content: schemasCode,\n });\n\n // Resource files\n const resourceNames: string[] = [];\n for (const [resourceName, code] of Object.entries(resources)) {\n validateFileName(resourceName, 'resource name');\n generatedFiles.push({\n path: path.join(outputDir, 'resources', `${resourceName}.resource.ts`),\n content: code,\n });\n resourceNames.push(resourceName);\n }\n\n // Resources index\n const resourceIndexCode = resourceNames\n .map((resourceName) => `export { ${resourceName}Resource } from './${resourceName}.resource';`)\n .join('\\n');\n generatedFiles.push({\n path: path.join(outputDir, 'resources', 'index.ts'),\n content: resourceIndexCode,\n });\n\n // Resource base class\n const resourceBaseCode = `import type ${clientClassName} from './${clientClassName}';\nimport { Resource as BaseResource } from '${runtimePackage}';\n\nexport class Resource extends BaseResource {\n protected declare client: ${clientClassName};\n\n constructor(client: ${clientClassName}) {\n super(client);\n }\n}\n`;\n generatedFiles.push({\n path: path.join(outputDir, 'Resource.ts'),\n content: resourceBaseCode,\n });\n\n // Get top-level resources\n const topLevelResources: Array<{ propertyName: string; className: string }> = [];\n for (const [childName] of tree.children) {\n const className = pascalCase(childName);\n topLevelResources.push({\n propertyName: singularize(camelCase(childName)),\n className,\n });\n }\n\n // Client class\n console.log(`\\nGenerating ${clientClassName}...`);\n const resourceImports = topLevelResources.map((r) => `${r.className}Resource`).join(',\\n ');\n const resourceProperties = topLevelResources\n .map((r) => `public ${r.propertyName}: ${r.className}Resource;`)\n .join('\\n ');\n const resourceInstantiations = topLevelResources\n .map((r) => `this.${r.propertyName} = new ${r.className}Resource(this);`)\n .join('\\n ');\n\n const clientCode = `import { Client, ClientOptions } from '${runtimePackage}';\n\nimport {\n ${resourceImports},\n} from './resources';\n\nexport default class ${clientClassName} extends Client {\n ${resourceProperties}\n\n constructor(baseUrl: string, options: ClientOptions = {}) {\n super(baseUrl, options);\n ${resourceInstantiations}\n }\n}\n`;\n generatedFiles.push({\n path: path.join(outputDir, `${clientClassName}.ts`),\n content: clientCode,\n });\n\n // Main index\n const mainIndexCode = `export { default as ${clientClassName} } from './${clientClassName}';\nexport * from './schemas';\nexport * from './resources';\n`;\n generatedFiles.push({\n path: path.join(outputDir, 'index.ts'),\n content: mainIndexCode,\n });\n\n // Write files if not in dry-run mode\n if (shouldWrite) {\n for (const file of generatedFiles) {\n await writeFile(file.path, file.content);\n }\n }\n\n console.log(`\\n${clientClassName} generation complete!`);\n\n return {\n name,\n resourceNames: topLevelResources.map((r) => r.className),\n files: shouldWrite ? undefined : generatedFiles,\n };\n}\n","import pluralizeLib from 'pluralize';\nimport { camelCase, pascalCase, singularize } from './utils';\n\nexport interface EnumContext {\n source: 'schema' | 'queryParam';\n schemaName?: string;\n propertyPath?: string;\n paramName?: string;\n resourceName?: string;\n}\n\nexport interface EnumInfo {\n valuesConstName: string;\n schemaConstName: string;\n typeName: string;\n values: string[];\n}\n\nexport class EnumRegistry {\n private enums = new Map<string, EnumInfo>();\n private enumContexts = new Map<string, EnumContext[]>();\n private usedNames = new Set<string>();\n\n static fingerprint(values: string[]): string {\n return JSON.stringify([...values].sort());\n }\n\n generateEnumNames(values: string[], context: EnumContext): EnumInfo {\n const { source, schemaName, propertyPath, paramName, resourceName } = context;\n\n let baseName: string;\n if (source === 'schema' && schemaName && propertyPath) {\n const cleanSchemaName = schemaName\n .replace(/Schema$/, '')\n .replace(/SchemaInput$/, '')\n .replace(/Input$/, '');\n\n const pathParts = propertyPath.split('.');\n const contextFromPath = pathParts.map((p) => pascalCase(singularize(p))).join('');\n baseName = camelCase(cleanSchemaName) + contextFromPath;\n } else if (source === 'queryParam' && resourceName && paramName) {\n const singularResource = singularize(resourceName);\n baseName = camelCase(singularResource) + pascalCase(paramName);\n } else {\n baseName = camelCase(values[0].toLowerCase());\n }\n\n const valuesConstName = pluralizeLib.isPlural(baseName) ? baseName : pluralizeLib.plural(baseName);\n\n return {\n valuesConstName,\n schemaConstName: `${singularize(baseName)}Schema`,\n typeName: pascalCase(singularize(baseName)),\n values,\n };\n }\n\n register(values: string[], context: EnumContext): EnumInfo {\n const fingerprint = EnumRegistry.fingerprint(values);\n\n if (!this.enumContexts.has(fingerprint)) {\n this.enumContexts.set(fingerprint, []);\n }\n this.enumContexts.get(fingerprint)!.push(context);\n\n if (this.enums.has(fingerprint)) {\n return this.enums.get(fingerprint)!;\n }\n\n let enumInfo = this.generateEnumNames(values, context);\n\n let counter = 1;\n const hasCollision = () =>\n this.usedNames.has(enumInfo.valuesConstName) ||\n this.usedNames.has(enumInfo.schemaConstName) ||\n this.usedNames.has(enumInfo.typeName);\n\n while (hasCollision()) {\n const baseInfo = this.generateEnumNames(values, context);\n enumInfo = {\n valuesConstName: `${baseInfo.valuesConstName}${counter}`,\n schemaConstName: `${baseInfo.schemaConstName.replace(/Schema$/, '')}${counter}Schema`,\n typeName: `${baseInfo.typeName}${counter}`,\n values: baseInfo.values,\n };\n counter++;\n }\n\n this.usedNames.add(enumInfo.valuesConstName);\n this.usedNames.add(enumInfo.schemaConstName);\n this.usedNames.add(enumInfo.typeName);\n\n this.enums.set(fingerprint, enumInfo);\n return enumInfo;\n }\n\n has(values: string[]): boolean {\n return this.enums.has(EnumRegistry.fingerprint(values));\n }\n\n get(values: string[]): EnumInfo | undefined {\n return this.enums.get(EnumRegistry.fingerprint(values));\n }\n\n getAll(): EnumInfo[] {\n return Array.from(this.enums.values());\n }\n\n generateEnumExports(): string {\n const lines: string[] = [];\n\n if (this.enums.size === 0) {\n return '';\n }\n\n lines.push('// ============================================================================');\n lines.push('// Extracted Enums');\n lines.push('// ============================================================================');\n lines.push('');\n\n for (const enumInfo of this.enums.values()) {\n const { valuesConstName, schemaConstName, typeName, values } = enumInfo;\n const valuesStr = values.map((v) => `'${v}'`).join(', ');\n\n lines.push(`export const ${valuesConstName} = [${valuesStr}] as const;`);\n lines.push(`export const ${schemaConstName} = z.enum(${valuesConstName});`);\n lines.push(`export type ${typeName} = z.output<typeof ${schemaConstName}>;`);\n lines.push('');\n }\n\n return lines.join('\\n');\n }\n}\n","import pluralizeLib from 'pluralize';\n\nexport function capitalize(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n\nexport function camelCase(str: string): string {\n const result = str\n .replace(/[-_.]+/g, '_')\n .replace(/_([a-zA-Z])/g, (_, char) => char.toUpperCase())\n .replace(/_+/g, '');\n\n return result.charAt(0).toLowerCase() + result.slice(1);\n}\n\nexport function pascalCase(str: string): string {\n return capitalize(camelCase(str));\n}\n\nexport function schemaConstToTypeName(schemaConstName: string): string {\n const withoutSuffix = schemaConstName.replace(/Schema$/, '');\n return pascalCase(withoutSuffix);\n}\n\nexport function singularize(str: string): string {\n const match = str.match(/^(.*)([A-Z][a-z]+s)$/);\n if (match) {\n const prefix = match[1];\n const lastWord = match[2];\n return prefix + pluralizeLib.singular(lastWord);\n }\n return pluralizeLib.singular(str);\n}\n\nexport function isBooleanLikeEnum(values: unknown[]): boolean {\n if (!Array.isArray(values) || values.length !== 2) return false;\n const sorted = [...values].sort();\n return sorted[0] === 'false' && sorted[1] === 'true';\n}\n\nexport function getResourcePrefixedParamNames(\n methodName: string,\n resourceClassName: string,\n): { schemaConstName: string; typeName: string } {\n const singularResource = singularize(resourceClassName);\n\n if (methodName.startsWith('get')) {\n const rest = methodName.slice(3);\n return {\n schemaConstName: `get${singularResource}${rest}ParamsSchema`,\n typeName: `Get${singularResource}${rest}Params`,\n };\n }\n\n return {\n schemaConstName: `${camelCase(methodName)}${singularResource}ParamsSchema`,\n typeName: `${pascalCase(methodName)}${singularResource}Params`,\n };\n}\n\nexport function validateFileName(name: string, context: string): void {\n if (!name || typeof name !== 'string') {\n throw new Error(`Invalid ${context}: must be a non-empty string`);\n }\n if (name.includes('..') || name.includes('/') || name.includes('\\\\')) {\n throw new Error(`Invalid ${context}: contains path traversal characters`);\n }\n if (!/^[a-zA-Z][a-zA-Z0-9]*$/.test(name)) {\n throw new Error(`Invalid ${context}: must be alphanumeric starting with a letter`);\n }\n}\n\nexport function validateOutputPath(outputPath: string): void {\n if (!outputPath || typeof outputPath !== 'string') {\n throw new Error('Invalid output path: must be a non-empty string');\n }\n if (outputPath.includes('..')) {\n throw new Error('Invalid output path: contains path traversal characters');\n }\n}\n\nexport interface OpenAPISchema {\n type?: string;\n format?: string;\n enum?: (string | null)[];\n const?: unknown;\n nullable?: boolean;\n $ref?: string;\n anyOf?: OpenAPISchema[];\n oneOf?: OpenAPISchema[];\n allOf?: OpenAPISchema[];\n items?: OpenAPISchema;\n properties?: Record<string, OpenAPISchema>;\n additionalProperties?: boolean | OpenAPISchema;\n required?: string[];\n minLength?: number;\n maxLength?: number;\n pattern?: string;\n minimum?: number;\n maximum?: number;\n minItems?: number;\n maxItems?: number;\n description?: string;\n}\n\nexport interface OpenAPIParameter {\n name: string;\n in: string;\n required?: boolean;\n schema?: OpenAPISchema;\n}\n\nexport interface OpenAPIOperation {\n operationId?: string;\n summary?: string;\n tags?: string[];\n parameters?: OpenAPIParameter[];\n requestBody?: {\n content?: {\n 'application/json'?: {\n schema?: OpenAPISchema;\n };\n };\n };\n responses?: Record<\n string,\n {\n content?: {\n 'application/json'?: {\n schema?: OpenAPISchema;\n };\n };\n }\n >;\n}\n\nexport interface OpenAPISpec {\n openapi: string;\n info: { title: string; version?: string };\n paths: Record<string, Record<string, OpenAPIOperation | OpenAPIParameter[]>>;\n components?: {\n schemas?: Record<string, OpenAPISchema>;\n };\n}\n\nexport interface PathSegment {\n name: string;\n isParam: boolean;\n raw: string;\n}\n\nexport function isListResponse(responseSchema: OpenAPISchema | undefined): boolean {\n if (!responseSchema) return false;\n\n if (responseSchema.type === 'object' && responseSchema.properties?.pagination) {\n return true;\n }\n if (responseSchema.type === 'array') {\n return true;\n }\n if (responseSchema.type === 'object' && responseSchema.properties) {\n for (const arrayProp of ['data', 'items', 'results']) {\n const prop = responseSchema.properties[arrayProp];\n if (prop?.type === 'array') return true;\n }\n }\n if (responseSchema.$ref) {\n const refName = responseSchema.$ref.split('/').pop()!;\n if (refName.includes('Paginated') || refName.includes('List')) {\n return true;\n }\n }\n return false;\n}\n\nexport function deriveEntityFromPath(pathPattern: string, includeParentContext = false): string | null {\n const segments = pathPattern.split('/').filter((seg) => seg && !seg.startsWith('{'));\n if (segments.length === 0) return null;\n\n if (includeParentContext && segments.length >= 2) {\n const parentSegment = segments[segments.length - 2];\n const lastSegment = segments[segments.length - 1];\n const singularParent = parentSegment.endsWith('s') ? parentSegment.slice(0, -1) : parentSegment;\n return pascalCase(singularParent) + pascalCase(lastSegment);\n }\n\n const lastSegment = segments[segments.length - 1];\n return pascalCase(lastSegment);\n}\n\nexport function isActionWord(word: string): boolean {\n const knownActions = ['status', 'approve', 'cancel', 'current', 'download_link', 'preferences'];\n if (knownActions.includes(word.toLowerCase())) return true;\n if (word.endsWith('s') && !word.endsWith('ss') && !word.endsWith('us')) {\n return false;\n }\n return true;\n}\n\nexport function operationIdToMethodName(\n operationId: string | undefined,\n httpMethod: string,\n pathPattern: string,\n resourceName: string,\n responseSchema: OpenAPISchema | undefined,\n): string {\n const isList = isListResponse(responseSchema);\n\n switch (httpMethod) {\n case 'get':\n return isList ? 'getList' : 'getDetail';\n case 'post':\n return 'create';\n case 'put':\n return 'replace';\n case 'patch':\n return 'update';\n case 'delete':\n return 'delete';\n default:\n return operationId ? camelCase(operationId) : httpMethod;\n }\n}\n\nexport function parsePathSegments(pathPattern: string): PathSegment[] {\n return pathPattern\n .split('/')\n .filter((seg) => seg)\n .map((seg) => ({\n name: seg.startsWith('{') ? seg.slice(1, -1) : seg,\n isParam: seg.startsWith('{'),\n raw: seg,\n }));\n}\n\nexport function getResourcePath(pathPattern: string): string[] {\n const segments = parsePathSegments(pathPattern);\n const resourcePath: string[] = [];\n for (const seg of segments) {\n if (!seg.isParam) {\n resourcePath.push(seg.name);\n }\n }\n return resourcePath;\n}\n\nexport interface PathTreeNode {\n name: string;\n children: Map<string, PathTreeNode>;\n operations: Array<{\n pathPattern: string;\n httpMethod: string;\n operation: OpenAPIOperation;\n }>;\n}\n\nexport function buildPathTree(paths: Record<string, Record<string, OpenAPIOperation | OpenAPIParameter[]>>): PathTreeNode {\n const tree: PathTreeNode = {\n name: 'root',\n children: new Map(),\n operations: [],\n };\n\n for (const [pathPattern, methods] of Object.entries(paths)) {\n for (const [httpMethod, operation] of Object.entries(methods)) {\n if (httpMethod === 'parameters') continue;\n\n const resourcePath = getResourcePath(pathPattern);\n\n let current = tree;\n for (const segment of resourcePath) {\n if (!current.children.has(segment)) {\n current.children.set(segment, {\n name: segment,\n children: new Map(),\n operations: [],\n });\n }\n current = current.children.get(segment)!;\n }\n\n current.operations.push({\n pathPattern,\n httpMethod,\n operation: operation as OpenAPIOperation,\n });\n }\n }\n\n return tree;\n}\n\nexport function cleanSchemaName(name: string): string {\n if (name.endsWith('SchemaInput')) {\n name = name.replace('SchemaInput', 'Input');\n } else if (name.endsWith('Schema')) {\n name = name.replace('Schema', '');\n }\n\n if (name.includes('__')) {\n const parts = name.split('__');\n name = parts[parts.length - 1];\n }\n\n name = name.replace(/_+$/, '');\n name = name.replace(/_([A-Za-z])/g, (_, char) => char.toUpperCase());\n\n return name;\n}\n","import { EnumRegistry } from './enum-registry';\nimport { ZodGenerator } from './zod-generator';\nimport {\n camelCase,\n pascalCase,\n singularize,\n capitalize,\n schemaConstToTypeName,\n isBooleanLikeEnum,\n getResourcePrefixedParamNames,\n operationIdToMethodName,\n getResourcePath,\n buildPathTree,\n cleanSchemaName,\n OpenAPISchema,\n OpenAPIOperation,\n OpenAPIParameter,\n PathTreeNode,\n} from './utils';\n\ninterface ResourceResult {\n className: string;\n code: string;\n children: Array<{ propertyName: string; className: string; fileName: string }>;\n}\n\nexport class ResourceGenerator {\n private schemas: Record<string, OpenAPISchema>;\n private clientClassName: string;\n private stripPathPrefix: string | null;\n public enumRegistry: EnumRegistry;\n private paths: Record<string, Record<string, OpenAPIOperation | OpenAPIParameter[]>>;\n private pathTree: PathTreeNode;\n private generatedResources = new Map<string, ResourceResult>();\n public collectedInlineSchemas = new Map<\n string,\n { schema: OpenAPISchema; isInput: boolean; typeName: string }\n >();\n private currentResourceName: string | null = null;\n private runtimePackage: string;\n\n constructor(\n paths: Record<string, Record<string, OpenAPIOperation | OpenAPIParameter[]>> | undefined,\n schemas: Record<string, OpenAPISchema> | undefined,\n clientClassName: string,\n options: {\n stripPathPrefix?: string;\n enumRegistry?: EnumRegistry;\n runtimePackage?: string;\n } = {},\n ) {\n this.schemas = schemas || {};\n this.clientClassName = clientClassName;\n this.stripPathPrefix = options.stripPathPrefix || null;\n this.enumRegistry = options.enumRegistry || new EnumRegistry();\n this.runtimePackage = options.runtimePackage || '@moinax/orc';\n\n this.paths = this.stripPathPrefix ? this.stripPrefixFromPaths(paths || {}) : paths || {};\n this.pathTree = buildPathTree(this.paths);\n }\n\n collectAllInlineSchemas(): Map<string, { schema: OpenAPISchema; isInput: boolean; typeName: string }> {\n this._collectInlineSchemasFromNode(this.pathTree, []);\n return this.collectedInlineSchemas;\n }\n\n private _collectInlineSchemasFromNode(node: PathTreeNode, parentPath: string[]): void {\n const nodeName = node.name === 'root' ? '' : node.name;\n const currentPath = [...parentPath, nodeName].filter(Boolean);\n\n const operationMethodNames = new Map<string, string>();\n for (const { pathPattern, httpMethod, operation } of node.operations) {\n const responseSchemaObj = (\n operation.responses?.['200'] || operation.responses?.['201']\n )?.content?.['application/json']?.schema;\n const methodName = operationIdToMethodName(\n operation.operationId,\n httpMethod,\n pathPattern,\n node.name,\n responseSchemaObj,\n );\n const opKey = this.getOperationKey(pathPattern, httpMethod);\n operationMethodNames.set(opKey, methodName);\n }\n\n const resourceClassName = this.getResourceClassName(currentPath);\n\n for (const { pathPattern, httpMethod, operation } of node.operations) {\n if (this.hasInlineRequestBody(operation)) {\n const requestSchema = this.getRequestSchemaName(operation, pathPattern);\n if (!requestSchema) {\n const opKey = this.getOperationKey(pathPattern, httpMethod);\n const methodName = operationMethodNames.get(opKey)!;\n const schemaConstName = this.generateInlineSchemaName(resourceClassName, methodName, 'body');\n\n const bodySchema = operation.requestBody!.content!['application/json']!.schema!;\n this.collectedInlineSchemas.set(schemaConstName, {\n schema: bodySchema,\n isInput: true,\n typeName: `${pascalCase(resourceClassName)}${pascalCase(methodName)}Body`,\n });\n }\n }\n }\n\n for (const { pathPattern, httpMethod, operation } of node.operations) {\n if (this.hasInlineResponseSchema(operation)) {\n const responseSchema = this.getResponseSchemaName(operation, pathPattern);\n if (!responseSchema) {\n const opKey = this.getOperationKey(pathPattern, httpMethod);\n const methodName = operationMethodNames.get(opKey)!;\n const schemaConstName = this.generateInlineSchemaName(resourceClassName, methodName, 'response');\n\n const successResponse = operation.responses?.['200'] || operation.responses?.['201'];\n const inlineSchema = successResponse!.content!['application/json']!.schema!;\n this.collectedInlineSchemas.set(schemaConstName, {\n schema: inlineSchema,\n isInput: false,\n typeName: `${pascalCase(resourceClassName)}${pascalCase(methodName)}Response`,\n });\n }\n }\n }\n\n for (const [, childNode] of node.children) {\n this._collectInlineSchemasFromNode(childNode, currentPath);\n }\n }\n\n private stripPrefixFromPaths(\n paths: Record<string, Record<string, OpenAPIOperation | OpenAPIParameter[]>>,\n ): Record<string, Record<string, OpenAPIOperation | OpenAPIParameter[]>> {\n const result: Record<string, Record<string, OpenAPIOperation | OpenAPIParameter[]>> = {};\n for (const [pathPattern, methods] of Object.entries(paths)) {\n let newPath = pathPattern;\n if (this.stripPathPrefix && pathPattern.startsWith(this.stripPathPrefix)) {\n newPath = pathPattern.slice(this.stripPathPrefix.length) || '/';\n }\n result[newPath] = methods;\n }\n return result;\n }\n\n private getResponseSchemaName(operation: OpenAPIOperation, pathPattern: string | null = null): string | null {\n const successResponse = operation.responses?.['200'] || operation.responses?.['201'];\n if (!successResponse) return null;\n\n const content = successResponse.content?.['application/json'];\n if (!content?.schema) return null;\n\n const schema = content.schema;\n if (schema.$ref) {\n const rawName = schema.$ref.split('/').pop()!;\n return cleanSchemaName(rawName);\n }\n\n if (schema.type === 'object') {\n if (operation.operationId) {\n const opId = operation.operationId;\n const patterns = [\n /^create[_-]?(.+)$/i,\n /^update[_-]?(.+)$/i,\n /^get[_-]?(.+)$/i,\n /^(.+)[_-]?create$/i,\n /^(.+)[_-]?update$/i,\n /^(.+)[_-]?get$/i,\n ];\n\n for (const pattern of patterns) {\n const match = opId.match(pattern);\n if (match) {\n const entityName = pascalCase(match[1].replace(/[_-]/g, ' '));\n const schemaSchemaName = `${entityName}Schema`;\n if (this.schemas[entityName] || this.schemas[schemaSchemaName]) {\n return entityName;\n }\n }\n }\n }\n\n if (pathPattern) {\n const resourcePath = getResourcePath(pathPattern);\n if (resourcePath.length > 0) {\n const lastSegment = resourcePath[resourcePath.length - 1];\n const entityName = pascalCase(singularize(lastSegment));\n const schemaSchemaName = `${entityName}Schema`;\n if (this.schemas[entityName] || this.schemas[schemaSchemaName]) {\n return entityName;\n }\n }\n }\n }\n\n if (schema.type === 'object' && schema.properties) {\n return null;\n }\n\n return null;\n }\n\n private getRequestSchemaName(operation: OpenAPIOperation, pathPattern: string | null = null): string | null {\n const content = operation.requestBody?.content?.['application/json'];\n if (!content?.schema) return null;\n\n const schema = content.schema;\n if (schema.$ref) {\n const rawName = schema.$ref.split('/').pop()!;\n return cleanSchemaName(rawName);\n }\n\n return null;\n }\n\n private hasInlineRequestBody(operation: OpenAPIOperation): boolean {\n const content = operation.requestBody?.content?.['application/json'];\n if (!content?.schema) return false;\n return !content.schema.$ref && content.schema.type === 'object';\n }\n\n private hasInlineResponseSchema(operation: OpenAPIOperation): boolean {\n const successResponse = operation.responses?.['200'] || operation.responses?.['201'];\n if (!successResponse) return false;\n\n const content = successResponse.content?.['application/json'];\n if (!content?.schema) return false;\n\n const schema = content.schema;\n if (schema.$ref) return false;\n if (schema.type === 'object' && schema.properties?.pagination) return false;\n return schema.type === 'object' && !!schema.properties;\n }\n\n private generateInlineSchemaName(resourceName: string, methodName: string, purpose: string): string {\n const baseName = `${camelCase(resourceName)}${capitalize(methodName)}${capitalize(purpose)}Schema`;\n return camelCase(baseName);\n }\n\n private getPathParams(operation: OpenAPIOperation): Array<{ name: string; type: string; required: boolean }> {\n return (operation.parameters || [])\n .filter((p): p is OpenAPIParameter => 'in' in p && p.in === 'path')\n .map((p) => ({\n name: p.name,\n type: this.paramTypeToTs(p.schema),\n required: p.required !== false,\n }));\n }\n\n private getQueryParams(\n operation: OpenAPIOperation,\n ): Array<{ name: string; type: string; required: boolean; schema?: OpenAPISchema }> {\n return (operation.parameters || [])\n .filter((p): p is OpenAPIParameter => 'in' in p && p.in === 'query')\n .map((p) => ({\n name: p.name,\n type: this.paramTypeToTs(p.schema),\n required: p.required === true,\n schema: p.schema,\n }));\n }\n\n private paramTypeToTs(schema?: OpenAPISchema): string {\n if (!schema) return 'string';\n if (schema.enum) return schema.enum.map((v) => `'${v}'`).join(' | ');\n switch (schema.type) {\n case 'integer':\n case 'number':\n return 'number';\n case 'boolean':\n return 'boolean';\n default:\n return 'string';\n }\n }\n\n private paramToZod(\n param: { name: string; required: boolean; schema?: OpenAPISchema },\n resourceName?: string,\n ): string {\n const { schema, name: paramName } = param;\n if (!schema) return 'z.string()';\n\n let zodType: string;\n if (schema.enum) {\n if (isBooleanLikeEnum(schema.enum)) {\n zodType = 'z.boolean()';\n } else {\n const context = {\n source: 'queryParam' as const,\n resourceName: resourceName || this.currentResourceName || undefined,\n paramName: paramName,\n };\n const enumInfo = this.enumRegistry.register(schema.enum, context);\n zodType = enumInfo.schemaConstName;\n }\n } else {\n switch (schema.type) {\n case 'integer':\n zodType = 'z.number().int()';\n break;\n case 'number':\n zodType = 'z.number()';\n break;\n case 'boolean':\n zodType = 'z.boolean()';\n break;\n default:\n zodType = 'z.string()';\n }\n }\n\n if (!param.required) {\n zodType = `${zodType}.optional()`;\n }\n\n return zodType;\n }\n\n private isPaginationParam(paramName: string): boolean {\n return ['page', 'limit', 'orderBy', 'ordering'].includes(paramName);\n }\n\n private getUniqueMethodName(\n operationId: string | undefined,\n httpMethod: string,\n pathPattern: string,\n usedNames: Set<string>,\n responseSchema?: OpenAPISchema,\n ): string {\n let methodName = operationIdToMethodName(operationId, httpMethod, pathPattern, '', responseSchema);\n\n if (usedNames.has(methodName) && operationId) {\n methodName = camelCase(operationId);\n }\n\n let finalName = methodName;\n let counter = 1;\n while (usedNames.has(finalName)) {\n finalName = `${methodName}${counter}`;\n counter++;\n }\n\n usedNames.add(finalName);\n return finalName;\n }\n\n private getOperationKey(pathPattern: string, httpMethod: string): string {\n return `${httpMethod}:${pathPattern}`;\n }\n\n private getResourceClassName(pathSegments: string[]): string {\n return pathSegments.map((seg) => pascalCase(seg)).join('');\n }\n\n private generateResourceNode(node: PathTreeNode, pathSegments: string[]): ResourceResult {\n const parentImportPath = '../';\n const resourceClassName = this.getResourceClassName(pathSegments);\n\n this.currentResourceName = resourceClassName;\n\n const lines: string[] = [];\n const usedMethodNames = new Set<string>();\n const schemaImports = new Set<string>();\n let hasQueryParams = false;\n let hasPaginatedResponse = false;\n\n const childResources: Array<{ propertyName: string; className: string; fileName: string }> = [];\n for (const [childName, childNode] of node.children) {\n const childPath = [...pathSegments, childName];\n const childClassName = this.getResourceClassName(childPath);\n childResources.push({\n propertyName: singularize(camelCase(childName)),\n className: childClassName,\n fileName: `${childClassName}.resource`,\n });\n }\n\n const operationMethodNames = new Map<string, string>();\n let usesInlineZod = false;\n for (const { pathPattern, httpMethod, operation } of node.operations) {\n const successResponse = operation.responses?.['200'] || operation.responses?.['201'];\n const responseContent = successResponse?.content?.['application/json'];\n const responseSchemaObj = responseContent?.schema;\n\n const methodName = this.getUniqueMethodName(\n operation.operationId,\n httpMethod,\n pathPattern,\n usedMethodNames,\n responseSchemaObj,\n );\n const opKey = this.getOperationKey(pathPattern, httpMethod);\n operationMethodNames.set(opKey, methodName);\n\n const queryParams = this.getQueryParams(operation);\n if (queryParams.length > 0) {\n hasQueryParams = true;\n }\n\n if (responseSchemaObj?.type === 'object' && responseSchemaObj?.properties?.pagination) {\n hasPaginatedResponse = true;\n }\n\n if (\n responseSchemaObj?.type === 'object' &&\n responseSchemaObj?.properties?.pagination &&\n !responseSchemaObj?.properties?.data?.items?.$ref\n ) {\n usesInlineZod = true;\n }\n }\n\n const typeImports = new Map<string, string>();\n\n if (hasQueryParams) {\n schemaImports.add('paginationParamsSchema');\n }\n if (hasPaginatedResponse) {\n schemaImports.add('paginationResponseSchema');\n typeImports.set('paginationResponseSchema', 'PaginationResponse');\n }\n\n for (const { pathPattern, operation } of node.operations) {\n const responseSchema = this.getResponseSchemaName(operation, pathPattern);\n if (responseSchema) {\n const schemaConst = `${camelCase(responseSchema)}Schema`;\n schemaImports.add(schemaConst);\n typeImports.set(schemaConst, pascalCase(responseSchema));\n }\n const requestSchema = this.getRequestSchemaName(operation, pathPattern);\n if (requestSchema) {\n const schemaConst = `${camelCase(requestSchema)}Schema`;\n schemaImports.add(schemaConst);\n typeImports.set(schemaConst, pascalCase(requestSchema));\n }\n }\n\n const inlineBodySchemas = new Map<string, { schemaConst: string; typeName: string }>();\n for (const { pathPattern, httpMethod, operation } of node.operations) {\n if (this.hasInlineRequestBody(operation)) {\n const requestSchema = this.getRequestSchemaName(operation, pathPattern);\n if (!requestSchema) {\n const opKey = this.getOperationKey(pathPattern, httpMethod);\n const methodName = operationMethodNames.get(opKey)!;\n const schemaConstName = this.generateInlineSchemaName(resourceClassName, methodName, 'body');\n const typeName = schemaConstToTypeName(schemaConstName);\n inlineBodySchemas.set(opKey, { schemaConst: schemaConstName, typeName });\n schemaImports.add(schemaConstName);\n typeImports.set(schemaConstName, typeName);\n }\n }\n }\n\n const inlineResponseSchemas = new Map<string, { schemaConst: string; typeName: string }>();\n for (const { pathPattern, httpMethod, operation } of node.operations) {\n if (this.hasInlineResponseSchema(operation)) {\n const responseSchema = this.getResponseSchemaName(operation, pathPattern);\n if (!responseSchema) {\n const opKey = this.getOperationKey(pathPattern, httpMethod);\n const methodName = operationMethodNames.get(opKey)!;\n const schemaConstName = this.generateInlineSchemaName(resourceClassName, methodName, 'response');\n const typeName = schemaConstToTypeName(schemaConstName);\n inlineResponseSchemas.set(opKey, { schemaConst: schemaConstName, typeName });\n schemaImports.add(schemaConstName);\n typeImports.set(schemaConstName, typeName);\n }\n }\n }\n\n const needsZod = hasQueryParams || usesInlineZod;\n if (needsZod) {\n lines.push(\"import { z } from 'zod';\");\n lines.push('');\n }\n\n const hasParsing = node.operations.some(({ httpMethod, operation }) => {\n const successResponse = operation.responses?.['200'] || operation.responses?.['201'];\n const hasResponseParsing = !!successResponse?.content?.['application/json']?.schema;\n const hasBodyParsing = ['post', 'put', 'patch'].includes(httpMethod) && !!operation.requestBody;\n const hasParamsParsing = this.getQueryParams(operation).length > 0;\n return hasResponseParsing || hasBodyParsing || hasParamsParsing;\n });\n if (hasParsing) {\n lines.push(`import { parseSchema } from '${this.runtimePackage}';`);\n }\n\n lines.push(`import { Resource } from '${parentImportPath}Resource';`);\n\n const schemaImportPlaceholderIndex = lines.length;\n lines.push('__SCHEMA_IMPORTS_PLACEHOLDER__');\n\n for (const child of childResources) {\n lines.push(`import { ${child.className}Resource } from './${child.fileName}';`);\n }\n lines.push('');\n\n const queryParamsSchemas: string[] = [];\n for (const { pathPattern, httpMethod, operation } of node.operations) {\n const queryParams = this.getQueryParams(operation);\n if (queryParams.length > 0) {\n const opKey = this.getOperationKey(pathPattern, httpMethod);\n const methodName = operationMethodNames.get(opKey)!;\n const { schemaConstName, typeName } = getResourcePrefixedParamNames(methodName, resourceClassName);\n\n const specificParams = queryParams.filter((p) => !this.isPaginationParam(p.name));\n\n if (specificParams.length > 0) {\n const props = specificParams.map((p) => {\n const zodCode = this.paramToZod(p, resourceClassName);\n if (p.schema?.enum) {\n const enumInfo = this.enumRegistry.get(p.schema.enum);\n if (enumInfo) {\n schemaImports.add(enumInfo.schemaConstName);\n }\n }\n return ` ${p.name}: ${zodCode}`;\n });\n queryParamsSchemas.push(\n `export const ${schemaConstName} = paginationParamsSchema.extend({\\n${props.join(',\\n')},\\n});`,\n );\n } else {\n queryParamsSchemas.push(`export const ${schemaConstName} = paginationParamsSchema;`);\n }\n queryParamsSchemas.push(`export type ${typeName} = z.input<typeof ${schemaConstName}>;`);\n queryParamsSchemas.push('');\n }\n }\n\n if (queryParamsSchemas.length > 0) {\n lines.push('// Query parameter schemas');\n lines.push(queryParamsSchemas.join('\\n'));\n }\n\n lines.push(`export class ${resourceClassName}Resource extends Resource {`);\n\n for (const child of childResources) {\n lines.push(` public ${child.propertyName}: ${child.className}Resource;`);\n }\n\n if (childResources.length > 0) {\n lines.push('');\n lines.push(\n ` constructor(client: InstanceType<typeof import('${parentImportPath}${this.clientClassName}').default>) {`,\n );\n lines.push(' super(client);');\n for (const child of childResources) {\n lines.push(` this.${child.propertyName} = new ${child.className}Resource(client);`);\n }\n lines.push(' }');\n }\n\n for (const { pathPattern, httpMethod, operation } of node.operations) {\n const opKey = this.getOperationKey(pathPattern, httpMethod);\n const methodName = operationMethodNames.get(opKey)!;\n const pathParams = this.getPathParams(operation);\n const queryParams = this.getQueryParams(operation);\n const responseSchema = this.getResponseSchemaName(operation, pathPattern);\n const requestSchema = this.getRequestSchemaName(operation, pathPattern);\n\n const params: string[] = [];\n for (const p of pathParams) {\n params.push(`${p.name}: ${p.type}`);\n }\n\n if (queryParams.length > 0) {\n const { typeName } = getResourcePrefixedParamNames(methodName, resourceClassName);\n const hasRequired = queryParams.some((p) => p.required);\n params.push(`params${hasRequired ? '' : '?'}: ${typeName}`);\n }\n\n const inlineBodySchema = inlineBodySchemas.get(opKey);\n\n if (['post', 'put', 'patch'].includes(httpMethod) && operation.requestBody) {\n if (requestSchema) {\n const schemaConst = `${camelCase(requestSchema)}Schema`;\n const typeName = typeImports.get(schemaConst)!;\n params.push(`body: ${typeName}`);\n } else if (inlineBodySchema) {\n params.push(`body: ${inlineBodySchema.typeName}`);\n } else {\n params.push('body: Record<string, unknown>');\n }\n }\n\n const fullPath = this.stripPathPrefix ? this.stripPathPrefix + pathPattern : pathPattern;\n let pathTemplate = fullPath.replace(/\\{(\\w+)\\}/g, '${$1}');\n pathTemplate = '`' + pathTemplate + '`';\n\n const successResponse = operation.responses?.['200'] || operation.responses?.['201'];\n const responseContent = successResponse?.content?.['application/json'];\n const responseSchemaObj = responseContent?.schema;\n\n let returnType = 'void';\n let parseLogic = '';\n\n if (responseSchemaObj) {\n if (responseSchemaObj.type === 'object' && responseSchemaObj.properties?.pagination) {\n const dataRef = responseSchemaObj.properties.data?.items?.$ref;\n if (dataRef) {\n const rawItemSchema = dataRef.split('/').pop()!;\n const itemSchema = cleanSchemaName(rawItemSchema);\n const itemSchemaConst = `${camelCase(itemSchema)}Schema`;\n const itemTypeName = pascalCase(itemSchema);\n schemaImports.add(itemSchemaConst);\n typeImports.set(itemSchemaConst, itemTypeName);\n returnType = `{ pagination: PaginationResponse; data: ${itemTypeName}[] }`;\n parseLogic = `const schema = z.object({ pagination: paginationResponseSchema, data: z.array(${itemSchemaConst}) }).describe('Paginated${itemTypeName}List');\n return parseSchema(schema, response);`;\n } else {\n if (responseSchema) {\n const itemSchemaConst = `${camelCase(responseSchema)}Schema`;\n const itemTypeName = pascalCase(responseSchema);\n schemaImports.add(itemSchemaConst);\n typeImports.set(itemSchemaConst, itemTypeName);\n returnType = `{ pagination: PaginationResponse; data: ${itemTypeName}[] }`;\n parseLogic = `const schema = z.object({ pagination: paginationResponseSchema, data: z.array(${itemSchemaConst}) }).describe('Paginated${itemTypeName}List');\n return parseSchema(schema, response);`;\n } else {\n returnType = `{ pagination: PaginationResponse; data: unknown[] }`;\n parseLogic = `const schema = z.object({ pagination: paginationResponseSchema, data: z.array(z.unknown()) }).describe('PaginatedList');\n return parseSchema(schema, response);`;\n }\n }\n } else if (responseSchema) {\n const schemaConstName = `${camelCase(responseSchema)}Schema`;\n const typeName = pascalCase(responseSchema);\n returnType = typeName;\n parseLogic = `return parseSchema(${schemaConstName}, response);`;\n schemaImports.add(schemaConstName);\n typeImports.set(schemaConstName, typeName);\n } else if (inlineResponseSchemas.get(opKey)) {\n const inlineSchema = inlineResponseSchemas.get(opKey)!;\n returnType = inlineSchema.typeName;\n parseLogic = `return parseSchema(${inlineSchema.schemaConst}, response);`;\n } else {\n returnType = 'unknown';\n parseLogic = 'return response;';\n }\n }\n\n lines.push('');\n lines.push(` async ${methodName}(${params.join(', ')}): Promise<${returnType}> {`);\n\n if (queryParams.length > 0) {\n const { schemaConstName } = getResourcePrefixedParamNames(methodName, resourceClassName);\n lines.push(` const searchParams = new URLSearchParams();`);\n lines.push(` if (params) {`);\n lines.push(` const validated = parseSchema(${schemaConstName}, params);`);\n lines.push(` Object.entries(validated).forEach(([key, value]) => {`);\n lines.push(` if (value !== undefined) searchParams.set(key, String(value));`);\n lines.push(` });`);\n lines.push(` }`);\n lines.push(` const query = searchParams.toString();`);\n lines.push(` const url = query ? \\`\\${${pathTemplate}}?\\${query}\\` : ${pathTemplate};`);\n }\n\n const urlVar = queryParams.length > 0 ? 'url' : pathTemplate;\n const needsResponse = returnType !== 'void';\n const responsePrefix = needsResponse ? 'const response = ' : '';\n\n const hasBodySchema = requestSchema || inlineBodySchema;\n const hasBodyValidation = ['post', 'put', 'patch'].includes(httpMethod) && hasBodySchema;\n const bodyVar = hasBodyValidation ? 'validatedBody' : 'body';\n\n if (hasBodyValidation) {\n const bodySchemaConst = requestSchema\n ? `${camelCase(requestSchema)}Schema`\n : inlineBodySchema!.schemaConst;\n lines.push(` const validatedBody = parseSchema(${bodySchemaConst}, body);`);\n }\n\n switch (httpMethod) {\n case 'get':\n lines.push(` ${responsePrefix}await this.client.get(${urlVar});`);\n break;\n case 'post':\n lines.push(` ${responsePrefix}await this.client.post(${urlVar}, ${bodyVar});`);\n break;\n case 'put':\n lines.push(` ${responsePrefix}await this.client.put(${urlVar}, ${bodyVar});`);\n break;\n case 'patch':\n lines.push(` ${responsePrefix}await this.client.patch(${urlVar}, ${bodyVar});`);\n break;\n case 'delete':\n lines.push(` ${responsePrefix}await this.client.delete(${urlVar});`);\n break;\n }\n\n if (parseLogic) {\n lines.push(` ${parseLogic}`);\n }\n\n lines.push(' }');\n }\n\n lines.push('}');\n\n const placeholderIndex = lines.findIndex((l) => l === '__SCHEMA_IMPORTS_PLACEHOLDER__');\n if (placeholderIndex >= 0) {\n if (schemaImports.size > 0 || typeImports.size > 0) {\n const allImports = new Set([...schemaImports, ...typeImports.values()]);\n lines[placeholderIndex] = `import { ${Array.from(allImports).join(', ')} } from '${parentImportPath}schemas';`;\n } else {\n lines.splice(placeholderIndex, 1);\n }\n }\n\n return {\n className: resourceClassName,\n code: lines.join('\\n'),\n children: childResources,\n };\n }\n\n private generateFromTree(\n node: PathTreeNode,\n pathSegments: string[] = [],\n depth = 0,\n ): Array<ResourceResult & { pathSegments: string[] }> {\n const resources: Array<ResourceResult & { pathSegments: string[] }> = [];\n\n for (const [childName, childNode] of node.children) {\n const childPath = [...pathSegments, childName];\n const childResources = this.generateFromTree(childNode, childPath, depth + 1);\n resources.push(...childResources);\n }\n\n if (pathSegments.length > 0 && (node.operations.length > 0 || node.children.size > 0)) {\n const resource = this.generateResourceNode(node, pathSegments);\n resources.push({\n pathSegments,\n ...resource,\n });\n }\n\n return resources;\n }\n\n generateAll(): {\n resources: Record<string, string>;\n tree: PathTreeNode;\n inlineSchemas: Map<string, { schema: OpenAPISchema; isInput: boolean; typeName: string }>;\n } {\n this.collectAllInlineSchemas();\n\n const resources = this.generateFromTree(this.pathTree);\n\n const result: Record<string, string> = {};\n for (const resource of resources) {\n result[resource.className] = resource.code;\n }\n\n return {\n resources: result,\n tree: this.pathTree,\n inlineSchemas: this.collectedInlineSchemas,\n };\n }\n}\n","import { EnumRegistry, EnumContext } from './enum-registry';\nimport { camelCase, pascalCase, isBooleanLikeEnum, cleanSchemaName, OpenAPISchema } from './utils';\n\nexport interface UsedDateSchemas {\n stringToDateSchema: boolean;\n stringToDaySchema: boolean;\n dateToStringSchema: boolean;\n dayToStringSchema: boolean;\n}\n\nexport class ZodGenerator {\n private schemas: Record<string, OpenAPISchema>;\n private generatedSchemas = new Map<string, string>();\n private schemaOrder: string[] = [];\n private inlineSchemas = new Map<string, { schema: OpenAPISchema; isInput: boolean; typeName: string }>();\n public enumRegistry: EnumRegistry;\n public usedDateSchemas: UsedDateSchemas = {\n stringToDateSchema: false,\n stringToDaySchema: false,\n dateToStringSchema: false,\n dayToStringSchema: false,\n };\n private currentSchemaName: string | null = null;\n private currentPropertyPath: string | null = null;\n\n constructor(schemas?: Record<string, OpenAPISchema>, enumRegistry?: EnumRegistry) {\n this.schemas = schemas || {};\n this.enumRegistry = enumRegistry || new EnumRegistry();\n }\n\n addInlineSchemas(inlineSchemas: Map<string, { schema: OpenAPISchema; isInput: boolean; typeName: string }>): void {\n this.inlineSchemas = inlineSchemas;\n }\n\n convertSchema(schema: OpenAPISchema | undefined, schemaName: string | null = null, isTopLevel = false): string {\n if (!schema) return 'z.unknown()';\n\n if (schema.$ref) {\n const refName = schema.$ref.split('/').pop()!;\n const cleanedName = cleanSchemaName(refName);\n return `${camelCase(cleanedName)}Schema`;\n }\n\n if (schema.anyOf) {\n const options = schema.anyOf.map((s) => this.convertSchema(s, schemaName));\n if (options.length === 2 && options.includes('z.null()')) {\n const nonNull = options.find((o) => o !== 'z.null()');\n const isInputSchema =\n schemaName &&\n (schemaName.includes('Input') || schemaName.includes('Create') || schemaName.includes('Update'));\n return isInputSchema ? `${nonNull}.nullish()` : `${nonNull}.nullable()`;\n }\n return `z.union([${options.join(', ')}])`;\n }\n\n if (schema.oneOf) {\n if (schema.oneOf.length === 2) {\n const nullIdx = schema.oneOf.findIndex((s) => this.isNullSchema(s));\n if (nullIdx !== -1) {\n const nonNull = this.convertSchema(schema.oneOf[1 - nullIdx], schemaName);\n const isInputSchema =\n schemaName &&\n (schemaName.includes('Input') || schemaName.includes('Create') || schemaName.includes('Update'));\n return isInputSchema ? `${nonNull}.nullish()` : `${nonNull}.nullable()`;\n }\n }\n const options = schema.oneOf.map((s) => this.convertSchema(s, schemaName));\n return `z.union([${options.join(', ')}])`;\n }\n\n if (schema.allOf) {\n const schemas = schema.allOf.map((s) => this.convertSchema(s, schemaName));\n if (schemas.length === 1) return schemas[0];\n return schemas.reduce((acc, s) => `${acc}.merge(${s})`);\n }\n\n if (schema.const !== undefined) {\n if (typeof schema.const === 'string') {\n return `z.literal('${schema.const}')`;\n }\n return `z.literal(${JSON.stringify(schema.const)})`;\n }\n\n const isNullable = schema.nullable === true;\n let zodSchema: string;\n\n switch (schema.type) {\n case 'string':\n zodSchema = this.convertStringSchema(schema, schemaName);\n break;\n case 'number':\n case 'integer':\n zodSchema = this.convertNumberSchema(schema, schemaName);\n break;\n case 'boolean':\n zodSchema = 'z.boolean()';\n break;\n case 'array':\n zodSchema = this.convertArraySchema(schema, schemaName);\n break;\n case 'object':\n zodSchema = this.convertObjectSchema(schema, schemaName);\n break;\n case 'null':\n return 'z.null()';\n default:\n if (schema.enum) {\n zodSchema = this.convertEnumSchema(schema, schemaName);\n } else if (schema.properties) {\n zodSchema = this.convertObjectSchema(schema, schemaName);\n } else {\n zodSchema = 'z.unknown()';\n }\n }\n\n if (isNullable) {\n const isInputSchema =\n schemaName && (schemaName.includes('Input') || schemaName.includes('Create') || schemaName.includes('Update'));\n zodSchema = isInputSchema ? `${zodSchema}.nullish()` : `${zodSchema}.nullable()`;\n }\n\n return zodSchema;\n }\n\n private isNullSchema(schema: OpenAPISchema): boolean {\n if (schema.type === 'null') return true;\n if (schema.enum && schema.enum.length === 1 && schema.enum[0] === null) return true;\n if (schema.$ref) {\n const refName = schema.$ref.split('/').pop()!;\n const resolved = this.schemas[refName];\n if (resolved) return this.isNullSchema(resolved);\n }\n return false;\n }\n\n private convertStringSchema(schema: OpenAPISchema, schemaName: string | null = null): string {\n if (schema.enum) {\n return this.convertEnumSchema(schema, schemaName);\n }\n\n if (schema.format === 'date-time' || schema.format === 'date') {\n const isInputSchema =\n schemaName && (schemaName.includes('Input') || schemaName.includes('Create') || schemaName.includes('Update'));\n const isDateTime = schema.format === 'date-time';\n\n if (isInputSchema) {\n if (isDateTime) {\n this.usedDateSchemas.dateToStringSchema = true;\n return 'dateToStringSchema';\n } else {\n this.usedDateSchemas.dayToStringSchema = true;\n return 'dayToStringSchema';\n }\n }\n if (isDateTime) {\n this.usedDateSchemas.stringToDateSchema = true;\n return 'stringToDateSchema';\n } else {\n this.usedDateSchemas.stringToDaySchema = true;\n return 'stringToDaySchema';\n }\n }\n\n let zod = 'z.string()';\n if (schema.format === 'uuid') {\n zod = 'z.string().uuid()';\n } else if (schema.format === 'email') {\n zod = 'z.string().email()';\n } else if (schema.format === 'uri') {\n zod = 'z.string().url()';\n }\n\n if (schema.minLength !== undefined) {\n zod = `${zod}.min(${schema.minLength})`;\n }\n if (schema.maxLength !== undefined) {\n zod = `${zod}.max(${schema.maxLength})`;\n }\n if (schema.pattern && !schema.format) {\n zod = `${zod}.regex(/${schema.pattern}/)`;\n }\n\n return zod;\n }\n\n private convertNumberSchema(schema: OpenAPISchema, schemaName: string | null = null): string {\n const isInputSchema =\n schemaName &&\n (schemaName.includes('Input') ||\n schemaName.includes('Body') ||\n schemaName.includes('Params') ||\n schemaName === 'InlineInput');\n const baseType = isInputSchema ? 'z.coerce.number()' : 'z.number()';\n let zod = schema.type === 'integer' ? `${baseType}.int()` : baseType;\n\n if (schema.minimum !== undefined) {\n zod = `${zod}.min(${schema.minimum})`;\n }\n if (schema.maximum !== undefined) {\n zod = `${zod}.max(${schema.maximum})`;\n }\n\n return zod;\n }\n\n private convertArraySchema(schema: OpenAPISchema, schemaName: string | null = null): string {\n const itemSchema = schema.items ? this.convertSchema(schema.items, schemaName) : 'z.unknown()';\n let zod = `z.array(${itemSchema})`;\n\n if (schema.minItems !== undefined) {\n zod = `${zod}.min(${schema.minItems})`;\n }\n if (schema.maxItems !== undefined) {\n zod = `${zod}.max(${schema.maxItems})`;\n }\n\n return zod;\n }\n\n private convertObjectSchema(schema: OpenAPISchema, schemaName: string | null = null): string {\n if (!schema.properties || Object.keys(schema.properties).length === 0) {\n if (schema.additionalProperties && typeof schema.additionalProperties === 'object') {\n const valueSchema = this.convertSchema(schema.additionalProperties as OpenAPISchema, schemaName);\n return `z.record(z.string(), ${valueSchema})`;\n }\n return 'z.object({})';\n }\n\n const required = new Set(schema.required || []);\n const properties: string[] = [];\n\n for (const [propName, propSchema] of Object.entries(schema.properties)) {\n const previousPropertyPath = this.currentPropertyPath;\n this.currentPropertyPath = previousPropertyPath ? `${previousPropertyPath}.${propName}` : propName;\n\n const propZod = this.convertSchema(propSchema, schemaName);\n const isRequired = required.has(propName);\n const finalProp = isRequired ? propZod : `${propZod}.optional()`;\n properties.push(` ${propName}: ${finalProp}`);\n\n this.currentPropertyPath = previousPropertyPath;\n }\n\n let zod = `z.object({\\n${properties.join(',\\n')}\\n})`;\n\n if (schema.additionalProperties === false) {\n zod = `${zod}.strict()`;\n }\n\n return zod;\n }\n\n private convertEnumSchema(schema: OpenAPISchema, schemaName: string | null = null): string {\n const rawValues = schema.enum!;\n const hasNull = rawValues.some((v) => v === null);\n const values = rawValues.filter((v): v is string => v !== null && v !== '');\n\n if (values.length === 0) {\n if (hasNull) return 'z.null()';\n // Enum with only empty string(s) — treat as z.literal('')\n return \"z.literal('')\";\n }\n\n if (isBooleanLikeEnum(values)) {\n return hasNull ? 'z.boolean().nullable()' : 'z.boolean()';\n }\n\n const context: EnumContext = {\n source: 'schema',\n schemaName: this.currentSchemaName || schemaName || undefined,\n propertyPath: this.currentPropertyPath || undefined,\n };\n\n const enumInfo = this.enumRegistry.register(values, context);\n return hasNull ? `${enumInfo.schemaConstName}.nullable()` : enumInfo.schemaConstName;\n }\n\n private extractDependencies(schema: OpenAPISchema | undefined): Set<string> {\n const deps = new Set<string>();\n if (!schema) return deps;\n\n if (schema.$ref) {\n const refName = schema.$ref.split('/').pop()!;\n deps.add(refName);\n return deps;\n }\n\n if (schema.anyOf) {\n for (const s of schema.anyOf) {\n for (const dep of this.extractDependencies(s)) {\n deps.add(dep);\n }\n }\n }\n\n if (schema.oneOf) {\n for (const s of schema.oneOf) {\n for (const dep of this.extractDependencies(s)) {\n deps.add(dep);\n }\n }\n }\n\n if (schema.allOf) {\n for (const s of schema.allOf) {\n for (const dep of this.extractDependencies(s)) {\n deps.add(dep);\n }\n }\n }\n\n if (schema.items) {\n for (const dep of this.extractDependencies(schema.items)) {\n deps.add(dep);\n }\n }\n\n if (schema.properties) {\n for (const propSchema of Object.values(schema.properties)) {\n for (const dep of this.extractDependencies(propSchema)) {\n deps.add(dep);\n }\n }\n }\n\n if (schema.additionalProperties && typeof schema.additionalProperties === 'object') {\n for (const dep of this.extractDependencies(schema.additionalProperties as OpenAPISchema)) {\n deps.add(dep);\n }\n }\n\n return deps;\n }\n\n private topologicalSort(schemaNames: string[]): string[] {\n const visited = new Set<string>();\n const result: string[] = [];\n const visiting = new Set<string>();\n\n const visit = (name: string) => {\n if (visited.has(name)) return;\n if (visiting.has(name)) return;\n\n visiting.add(name);\n\n const schema = this.schemas[name];\n if (schema) {\n const deps = this.extractDependencies(schema);\n for (const dep of deps) {\n if (schemaNames.includes(dep)) {\n visit(dep);\n }\n }\n }\n\n visiting.delete(name);\n visited.add(name);\n result.push(name);\n };\n\n for (const name of schemaNames) {\n visit(name);\n }\n\n return result;\n }\n\n generateSchemas(runtimePackage: string): string {\n const schemaOutput: string[] = [];\n\n for (const name of Object.keys(this.schemas)) {\n this.schemaOrder.push(name);\n }\n\n this.schemaOrder = this.topologicalSort(this.schemaOrder);\n\n const usedNames = new Set<string>();\n\n for (const name of this.schemaOrder) {\n const schema = this.schemas[name];\n\n this.currentSchemaName = name;\n this.currentPropertyPath = null;\n\n const zodSchema = this.convertSchema(schema, name, true);\n\n this.currentSchemaName = null;\n\n let cleanName = name;\n if (cleanName.endsWith('SchemaInput')) {\n cleanName = cleanName.replace('SchemaInput', 'Input');\n } else if (cleanName.endsWith('Schema')) {\n cleanName = cleanName.replace('Schema', '');\n }\n\n const schemaConstName = camelCase(cleanName) + 'Schema';\n const typeName = pascalCase(cleanName);\n\n if (usedNames.has(schemaConstName) || usedNames.has(typeName)) {\n continue;\n }\n usedNames.add(schemaConstName);\n usedNames.add(typeName);\n\n schemaOutput.push(`export const ${schemaConstName} = ${zodSchema}.describe('${typeName}');`);\n const isInputType = /(?:Body|Input|Params)$/.test(cleanName);\n const inferType = isInputType ? 'z.input' : 'z.output';\n schemaOutput.push(`export type ${typeName} = ${inferType}<typeof ${schemaConstName}>;`);\n schemaOutput.push('');\n }\n\n this.enumRegistry.register(['desc', 'asc'], {\n source: 'schema',\n schemaName: 'PaginationParams',\n propertyPath: 'ordering',\n });\n const orderingEnumInfo = this.enumRegistry.get(['desc', 'asc'])!;\n\n schemaOutput.push('// Common pagination schemas');\n schemaOutput.push(`export const paginationParamsSchema = z.object({\n page: z.number().optional(),\n limit: z.number().optional(),\n orderBy: z.string().optional(),\n ordering: ${orderingEnumInfo.schemaConstName}.optional(),\n}).describe('PaginationParams');`);\n schemaOutput.push('export type PaginationParams = z.input<typeof paginationParamsSchema>;');\n schemaOutput.push('');\n\n schemaOutput.push(`export const paginationResponseSchema = z.object({\n page: z.number(),\n pages: z.number(),\n limit: z.number(),\n total: z.number(),\n}).describe('PaginationResponse');`);\n schemaOutput.push('export type PaginationResponse = z.output<typeof paginationResponseSchema>;');\n schemaOutput.push('');\n\n if (this.inlineSchemas.size > 0) {\n schemaOutput.push('// Inline request/response schemas');\n for (const [schemaName, schemaInfo] of this.inlineSchemas) {\n const { schema, isInput, typeName } = schemaInfo;\n const contextName = isInput ? 'InlineInput' : 'InlineOutput';\n const zodSchema = this.convertSchema(schema, contextName, true);\n schemaOutput.push(`export const ${schemaName} = ${zodSchema}.describe('${typeName}');`);\n const inferType = isInput ? 'z.input' : 'z.output';\n schemaOutput.push(`export type ${typeName} = ${inferType}<typeof ${schemaName}>;`);\n schemaOutput.push('');\n }\n }\n\n const output: string[] = [];\n output.push(\"import { z } from 'zod';\");\n\n const usedDateSchemasList = Object.entries(this.usedDateSchemas)\n .filter(([_, used]) => used)\n .map(([name]) => name);\n\n if (usedDateSchemasList.length > 0) {\n output.push(`import { ${usedDateSchemasList.join(', ')} } from '${runtimePackage}';`);\n }\n\n output.push('');\n\n const enumExports = this.enumRegistry.generateEnumExports();\n if (enumExports) {\n output.push(enumExports);\n }\n\n output.push(...schemaOutput);\n\n return output.join('\\n');\n }\n}\n","import fs from 'fs';\nimport path from 'path';\nimport prettier from 'prettier';\n\nexport async function formatCode(code: string, filepath: string): Promise<string> {\n try {\n const options = await prettier.resolveConfig(filepath);\n return prettier.format(code, { ...options, parser: 'typescript' });\n } catch (error) {\n console.warn(`Warning: Could not format ${filepath}:`, (error as Error).message);\n return code;\n }\n}\n\nexport async function writeFile(filepath: string, content: string): Promise<void> {\n const dir = path.dirname(filepath);\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true });\n }\n const formatted = await formatCode(content, filepath);\n fs.writeFileSync(filepath, formatted);\n console.log(`Generated: ${filepath}`);\n}\n\nexport interface GeneratedFile {\n path: string;\n content: string;\n}\n\nexport async function writeFiles(files: GeneratedFile[]): Promise<void> {\n for (const file of files) {\n await writeFile(file.path, file.content);\n }\n}\n","import fs from 'fs';\nimport path from 'path';\nimport type { OpenAPISpec } from './utils';\n\nexport async function loadSpec(specPath: string): Promise<OpenAPISpec> {\n // If it's a URL, fetch it\n if (specPath.startsWith('http://') || specPath.startsWith('https://')) {\n console.log(`Fetching OpenAPI spec from ${specPath}...`);\n const response = await fetch(specPath);\n if (!response.ok) {\n throw new Error(`Failed to fetch OpenAPI spec: ${response.statusText}`);\n }\n const spec = (await response.json()) as OpenAPISpec;\n console.log(`OpenAPI spec version: ${spec.openapi}`);\n console.log(`API title: ${spec.info.title}`);\n return spec;\n }\n\n // Otherwise, read from file\n const resolvedPath = path.resolve(specPath);\n console.log(`Reading OpenAPI spec from ${resolvedPath}...`);\n if (!fs.existsSync(resolvedPath)) {\n throw new Error(`OpenAPI spec file not found: ${resolvedPath}`);\n }\n\n const content = fs.readFileSync(resolvedPath, 'utf-8');\n\n let spec: OpenAPISpec;\n if (resolvedPath.endsWith('.yaml') || resolvedPath.endsWith('.yml')) {\n throw new Error('YAML specs are not supported yet. Please use JSON format.');\n } else {\n spec = JSON.parse(content) as OpenAPISpec;\n }\n\n console.log(`OpenAPI spec version: ${spec.openapi}`);\n console.log(`API title: ${spec.info.title}`);\n return spec;\n}\n","import path from 'path';\nimport { generateClient } from '../../generator/client-generator';\nimport type { OrcConfig } from '../../generator/config';\n\nexport async function runGenerate(\n config: OrcConfig,\n options: { client?: string; spec?: string },\n): Promise<void> {\n const runtimePackage = config.runtimePackage || '@moinax/orc';\n\n let clients = config.clients;\n\n if (options.client) {\n clients = clients.filter((c) => c.name.toLowerCase() === options.client!.toLowerCase());\n if (clients.length === 0) {\n console.error(`Error: Client \"${options.client}\" not found in configuration.`);\n console.log('Available clients:', config.clients.map((c) => c.name).join(', '));\n process.exit(1);\n }\n }\n\n if (options.spec && !options.client) {\n console.error('Error: --spec requires --client to be specified');\n process.exit(1);\n }\n\n console.log('ORC - OpenAPI Rest Client Generator');\n console.log('====================================');\n console.log(`Generating ${clients.length} client(s): ${clients.map((c) => c.name).join(', ')}`);\n if (options.spec) {\n console.log(`Using custom spec: ${options.spec}`);\n }\n\n const results = [];\n for (const clientConfig of clients) {\n try {\n const result = await generateClient(clientConfig, {\n specOverride: options.spec,\n runtimePackage,\n });\n results.push(result);\n } catch (error) {\n console.error(`\\nError generating ${clientConfig.name}Client:`, (error as Error).message);\n process.exit(1);\n }\n }\n\n console.log('\\n' + '='.repeat(60));\n console.log('All clients generated successfully!');\n console.log('='.repeat(60));\n\n for (const result of results) {\n console.log(`\\n${result.name}Client resources: ${result.resourceNames.join(', ')}`);\n }\n}\n","import fs from 'fs';\nimport path from 'path';\n\nconst CONFIG_TEMPLATE = `import { defineConfig } from '@moinax/orc/config';\n\nexport default defineConfig({\n clients: [\n {\n name: 'MyApi',\n spec: 'https://api.example.com/openapi.json',\n output: 'src/lib/api/my-api-client',\n },\n ],\n});\n`;\n\nexport async function runInit(): Promise<void> {\n const configPath = path.join(process.cwd(), 'orc.config.ts');\n\n if (fs.existsSync(configPath)) {\n console.error(`Config file already exists: ${configPath}`);\n process.exit(1);\n }\n\n fs.writeFileSync(configPath, CONFIG_TEMPLATE);\n console.log(`Created config file: ${configPath}`);\n console.log('\\nEdit the file to configure your API clients, then run:');\n console.log(' orc generate');\n}\n"],"mappings":";;;AAAA,SAAS,eAAe;AACxB,OAAOA,WAAU;AACjB,OAAOC,SAAQ;AACf,SAAS,kBAAkB;;;ACH3B,OAAOC,SAAQ;AACf,OAAOC,WAAU;;;ACDjB,OAAOC,mBAAk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/D,OAAO,oBAAoB,uCAAuC,EAClE,OAAO,OAAO,YAAY;AACzB,QAAM,SAAS,MAAM,WAAW;AAChC,QAAM,YAAY,QAAQ,OAAO;AACnC,CAAC;AAEH,QACG,QAAQ,MAAM,EACd,YAAY,mCAAmC,EAC/C,OAAO,YAAY;AAClB,QAAM,QAAQ;AAChB,CAAC;AAEH,QAAQ,MAAM;","names":["path","fs","fs","path","pluralizeLib","cleanSchemaName","pluralizeLib","fs","path","spec","path","fs","fs","path","path","fs"]}
1
+ {"version":3,"sources":["../src/cli.ts","../src/generator/client-generator.ts","../src/generator/enum-registry.ts","../src/generator/utils.ts","../src/generator/resource-generator.ts","../src/generator/zod-generator.ts","../src/generator/file-writer.ts","../src/generator/spec-loader.ts","../src/cli/commands/generate.ts","../src/cli/commands/init.ts"],"sourcesContent":["import { Command } from 'commander';\nimport path from 'path';\nimport fs from 'fs';\nimport { createJiti } from 'jiti';\nimport type { OrcConfig } from './generator/config';\nimport { runGenerate } from './cli/commands/generate';\nimport { runInit } from './cli/commands/init';\n\nconst CONFIG_NAMES = ['orc.config.ts', 'orc.config.js', 'orc.config.mjs'];\n\nasync function loadConfig(): Promise<OrcConfig> {\n const cwd = process.cwd();\n\n for (const configName of CONFIG_NAMES) {\n const configPath = path.join(cwd, configName);\n if (fs.existsSync(configPath)) {\n console.log(`Using config: ${configPath}`);\n const jiti = createJiti(cwd, { interopDefault: true });\n const config = await jiti.import(configPath) as OrcConfig;\n return config;\n }\n }\n\n throw new Error(\n `No config file found. Create one with 'orc init' or add one of: ${CONFIG_NAMES.join(', ')}`,\n );\n}\n\nconst program = new Command();\n\nprogram\n .name('orc')\n .description('ORC - OpenAPI Rest Client Generator')\n .version('0.1.0');\n\nprogram\n .command('generate')\n .description('Generate TypeScript API clients from OpenAPI specs')\n .option('-c, --client <name>', 'Generate a specific client only')\n .option('-s, --spec <url>', 'Override spec URL (requires --client)')\n .action(async (options) => {\n const config = await loadConfig();\n await runGenerate(config, options);\n });\n\nprogram\n .command('init')\n .description('Scaffold a new orc.config.ts file')\n .action(async () => {\n await runInit();\n });\n\nprogram.parse();\n","import fs from 'fs';\nimport path from 'path';\nimport { EnumRegistry } from './enum-registry';\nimport { ResourceGenerator } from './resource-generator';\nimport { ZodGenerator } from './zod-generator';\nimport { writeFile, type GeneratedFile } from './file-writer';\nimport { loadSpec } from './spec-loader';\nimport {\n validateFileName,\n validateOutputPath,\n pascalCase,\n singularize,\n camelCase,\n} from './utils';\nimport type { ClientConfig } from './config';\n\nexport interface GenerateResult {\n name: string;\n resourceNames: string[];\n files?: GeneratedFile[];\n}\n\nexport async function generateClient(\n config: ClientConfig,\n options: {\n specOverride?: string;\n write?: boolean;\n runtimePackage?: string;\n } = {},\n): Promise<GenerateResult> {\n const { name, output } = config;\n const specUrl = options.specOverride || config.spec;\n const shouldWrite = options.write !== false;\n const runtimePackage = options.runtimePackage || '@moinax/orc';\n\n validateOutputPath(output);\n\n const outputDir = path.join(output, 'generated');\n const clientClassName = `${name}Client`;\n\n validateFileName(clientClassName, 'client class name');\n\n console.log(`\\n${'='.repeat(60)}`);\n console.log(`Generating ${clientClassName}...`);\n console.log(`${'='.repeat(60)}`);\n\n // Clean up previously generated files\n if (shouldWrite && fs.existsSync(outputDir)) {\n fs.rmSync(outputDir, { recursive: true });\n console.log(`\\nCleaned up ${outputDir}`);\n }\n\n // Fetch/load OpenAPI spec\n const spec = await loadSpec(specUrl);\n\n // Create shared enum registry\n const enumRegistry = new EnumRegistry(config.schemaPrefix);\n\n // Create resource generator\n const resourceGenerator = new ResourceGenerator(spec.paths, spec.components?.schemas, clientClassName, {\n stripPathPrefix: config.stripPathPrefix,\n enumRegistry,\n runtimePackage,\n schemaPrefix: config.schemaPrefix,\n });\n\n // Generate resources FIRST (registers query param enums)\n console.log('\\nGenerating resource classes...');\n const { resources, tree, inlineSchemas } = resourceGenerator.generateAll();\n\n // Generate schemas (including inline schemas from resources)\n console.log('\\nGenerating Zod schemas...');\n const zodGenerator = new ZodGenerator(spec.components?.schemas, enumRegistry, config.schemaPrefix);\n zodGenerator.addInlineSchemas(inlineSchemas);\n const schemasCode = zodGenerator.generateSchemas(runtimePackage);\n\n const generatedFiles: GeneratedFile[] = [];\n\n // schemas.ts\n generatedFiles.push({\n path: path.join(outputDir, 'schemas.ts'),\n content: schemasCode,\n });\n\n // Resource files\n const resourceNames: string[] = [];\n for (const [resourceName, code] of Object.entries(resources)) {\n validateFileName(resourceName, 'resource name');\n generatedFiles.push({\n path: path.join(outputDir, 'resources', `${resourceName}.resource.ts`),\n content: code,\n });\n resourceNames.push(resourceName);\n }\n\n // Resources index\n const resourceIndexCode = resourceNames\n .map((resourceName) => `export { ${resourceName}Resource } from './${resourceName}.resource';`)\n .join('\\n');\n generatedFiles.push({\n path: path.join(outputDir, 'resources', 'index.ts'),\n content: resourceIndexCode,\n });\n\n // Resource base class\n const resourceBaseCode = `import type ${clientClassName} from './${clientClassName}';\nimport { Resource as BaseResource } from '${runtimePackage}';\n\nexport class Resource extends BaseResource {\n protected declare client: ${clientClassName};\n\n constructor(client: ${clientClassName}) {\n super(client);\n }\n}\n`;\n generatedFiles.push({\n path: path.join(outputDir, 'Resource.ts'),\n content: resourceBaseCode,\n });\n\n // Get top-level resources\n const topLevelResources: Array<{ propertyName: string; className: string }> = [];\n for (const [childName] of tree.children) {\n const className = pascalCase(childName);\n topLevelResources.push({\n propertyName: singularize(camelCase(childName)),\n className,\n });\n }\n\n // Client class\n console.log(`\\nGenerating ${clientClassName}...`);\n const resourceImports = topLevelResources.map((r) => `${r.className}Resource`).join(',\\n ');\n const resourceProperties = topLevelResources\n .map((r) => `public ${r.propertyName}: ${r.className}Resource;`)\n .join('\\n ');\n const resourceInstantiations = topLevelResources\n .map((r) => `this.${r.propertyName} = new ${r.className}Resource(this);`)\n .join('\\n ');\n\n const clientCode = `import { Client, ClientOptions } from '${runtimePackage}';\n\nimport {\n ${resourceImports},\n} from './resources';\n\nexport default class ${clientClassName} extends Client {\n ${resourceProperties}\n\n constructor(baseUrl: string, options: ClientOptions = {}) {\n super(baseUrl, options);\n ${resourceInstantiations}\n }\n}\n`;\n generatedFiles.push({\n path: path.join(outputDir, `${clientClassName}.ts`),\n content: clientCode,\n });\n\n // Main index\n const mainIndexCode = `export { default as ${clientClassName} } from './${clientClassName}';\nexport * from './schemas';\nexport * from './resources';\n`;\n generatedFiles.push({\n path: path.join(outputDir, 'index.ts'),\n content: mainIndexCode,\n });\n\n // Write files if not in dry-run mode\n if (shouldWrite) {\n for (const file of generatedFiles) {\n await writeFile(file.path, file.content);\n }\n }\n\n console.log(`\\n${clientClassName} generation complete!`);\n\n return {\n name,\n resourceNames: topLevelResources.map((r) => r.className),\n files: shouldWrite ? undefined : generatedFiles,\n };\n}\n","import pluralizeLib from 'pluralize';\nimport { camelCase, pascalCase, singularize } from './utils';\n\nexport interface EnumContext {\n source: 'schema' | 'queryParam';\n schemaName?: string;\n propertyPath?: string;\n paramName?: string;\n resourceName?: string;\n}\n\nexport interface EnumInfo {\n valuesConstName: string;\n schemaConstName: string;\n typeName: string;\n values: string[];\n}\n\nexport class EnumRegistry {\n private enums = new Map<string, EnumInfo>();\n private enumContexts = new Map<string, EnumContext[]>();\n private usedNames = new Set<string>();\n private schemaPrefix: string;\n\n constructor(schemaPrefix?: string) {\n this.schemaPrefix = schemaPrefix || '';\n }\n\n static fingerprint(values: string[]): string {\n return JSON.stringify([...values].sort());\n }\n\n generateEnumNames(values: string[], context: EnumContext): EnumInfo {\n const { source, schemaName, propertyPath, paramName, resourceName } = context;\n\n let baseName: string;\n if (source === 'schema' && schemaName && propertyPath) {\n const cleanSchemaName = schemaName\n .replace(/Schema$/, '')\n .replace(/SchemaInput$/, '')\n .replace(/Input$/, '');\n\n const pathParts = propertyPath.split('.');\n const contextFromPath = pathParts.map((p) => pascalCase(singularize(p))).join('');\n baseName = camelCase(cleanSchemaName) + contextFromPath;\n } else if (source === 'queryParam' && resourceName && paramName) {\n const singularResource = singularize(resourceName);\n baseName = camelCase(singularResource) + pascalCase(paramName);\n } else {\n baseName = camelCase(values[0].toLowerCase());\n }\n\n if (this.schemaPrefix) {\n baseName = camelCase(this.schemaPrefix) + pascalCase(baseName);\n }\n\n const valuesConstName = pluralizeLib.isPlural(baseName) ? baseName : pluralizeLib.plural(baseName);\n\n return {\n valuesConstName,\n schemaConstName: `${singularize(baseName)}Schema`,\n typeName: pascalCase(singularize(baseName)),\n values,\n };\n }\n\n register(values: string[], context: EnumContext): EnumInfo {\n const fingerprint = EnumRegistry.fingerprint(values);\n\n if (!this.enumContexts.has(fingerprint)) {\n this.enumContexts.set(fingerprint, []);\n }\n this.enumContexts.get(fingerprint)!.push(context);\n\n if (this.enums.has(fingerprint)) {\n return this.enums.get(fingerprint)!;\n }\n\n let enumInfo = this.generateEnumNames(values, context);\n\n let counter = 1;\n const hasCollision = () =>\n this.usedNames.has(enumInfo.valuesConstName) ||\n this.usedNames.has(enumInfo.schemaConstName) ||\n this.usedNames.has(enumInfo.typeName);\n\n while (hasCollision()) {\n const baseInfo = this.generateEnumNames(values, context);\n enumInfo = {\n valuesConstName: `${baseInfo.valuesConstName}${counter}`,\n schemaConstName: `${baseInfo.schemaConstName.replace(/Schema$/, '')}${counter}Schema`,\n typeName: `${baseInfo.typeName}${counter}`,\n values: baseInfo.values,\n };\n counter++;\n }\n\n this.usedNames.add(enumInfo.valuesConstName);\n this.usedNames.add(enumInfo.schemaConstName);\n this.usedNames.add(enumInfo.typeName);\n\n this.enums.set(fingerprint, enumInfo);\n return enumInfo;\n }\n\n has(values: string[]): boolean {\n return this.enums.has(EnumRegistry.fingerprint(values));\n }\n\n get(values: string[]): EnumInfo | undefined {\n return this.enums.get(EnumRegistry.fingerprint(values));\n }\n\n getAll(): EnumInfo[] {\n return Array.from(this.enums.values());\n }\n\n generateEnumExports(): string {\n const lines: string[] = [];\n\n if (this.enums.size === 0) {\n return '';\n }\n\n lines.push('// ============================================================================');\n lines.push('// Extracted Enums');\n lines.push('// ============================================================================');\n lines.push('');\n\n for (const enumInfo of this.enums.values()) {\n const { valuesConstName, schemaConstName, typeName, values } = enumInfo;\n const valuesStr = values.map((v) => `'${v}'`).join(', ');\n\n lines.push(`export const ${valuesConstName} = [${valuesStr}] as const;`);\n lines.push(`export const ${schemaConstName} = z.enum(${valuesConstName});`);\n lines.push(`export type ${typeName} = z.output<typeof ${schemaConstName}>;`);\n lines.push('');\n }\n\n return lines.join('\\n');\n }\n}\n","import pluralizeLib from 'pluralize';\n\nexport function capitalize(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n\nexport function camelCase(str: string): string {\n const result = str\n .replace(/[-_.]+/g, '_')\n .replace(/_([a-zA-Z])/g, (_, char) => char.toUpperCase())\n .replace(/_+/g, '');\n\n return result.charAt(0).toLowerCase() + result.slice(1);\n}\n\nexport function pascalCase(str: string): string {\n return capitalize(camelCase(str));\n}\n\nexport function schemaConstToTypeName(schemaConstName: string): string {\n const withoutSuffix = schemaConstName.replace(/Schema$/, '');\n return pascalCase(withoutSuffix);\n}\n\nexport function singularize(str: string): string {\n const match = str.match(/^(.*)([A-Z][a-z]+s)$/);\n if (match) {\n const prefix = match[1];\n const lastWord = match[2];\n return prefix + pluralizeLib.singular(lastWord);\n }\n return pluralizeLib.singular(str);\n}\n\nexport function isBooleanLikeEnum(values: unknown[]): boolean {\n if (!Array.isArray(values) || values.length !== 2) return false;\n const sorted = [...values].sort();\n return sorted[0] === 'false' && sorted[1] === 'true';\n}\n\nexport function prefixSchemaConst(name: string, schemaPrefix?: string): string {\n if (!schemaPrefix) return `${camelCase(name)}Schema`;\n return `${camelCase(schemaPrefix)}${pascalCase(name)}Schema`;\n}\n\nexport function prefixTypeName(name: string, schemaPrefix?: string): string {\n if (!schemaPrefix) return pascalCase(name);\n return `${pascalCase(schemaPrefix)}${pascalCase(name)}`;\n}\n\nexport function getResourcePrefixedParamNames(\n methodName: string,\n resourceClassName: string,\n schemaPrefix?: string,\n): { schemaConstName: string; typeName: string } {\n const singularResource = singularize(resourceClassName);\n const prefix = schemaPrefix ? pascalCase(schemaPrefix) : '';\n\n if (methodName.startsWith('get')) {\n const rest = methodName.slice(3);\n return {\n schemaConstName: `get${prefix}${singularResource}${rest}ParamsSchema`,\n typeName: `Get${prefix}${singularResource}${rest}Params`,\n };\n }\n\n return {\n schemaConstName: `${camelCase(methodName)}${prefix}${singularResource}ParamsSchema`,\n typeName: `${pascalCase(methodName)}${prefix}${singularResource}Params`,\n };\n}\n\nexport function validateFileName(name: string, context: string): void {\n if (!name || typeof name !== 'string') {\n throw new Error(`Invalid ${context}: must be a non-empty string`);\n }\n if (name.includes('..') || name.includes('/') || name.includes('\\\\')) {\n throw new Error(`Invalid ${context}: contains path traversal characters`);\n }\n if (!/^[a-zA-Z][a-zA-Z0-9]*$/.test(name)) {\n throw new Error(`Invalid ${context}: must be alphanumeric starting with a letter`);\n }\n}\n\nexport function validateOutputPath(outputPath: string): void {\n if (!outputPath || typeof outputPath !== 'string') {\n throw new Error('Invalid output path: must be a non-empty string');\n }\n if (outputPath.includes('..')) {\n throw new Error('Invalid output path: contains path traversal characters');\n }\n}\n\nexport interface OpenAPISchema {\n type?: string;\n format?: string;\n enum?: (string | null)[];\n const?: unknown;\n nullable?: boolean;\n $ref?: string;\n anyOf?: OpenAPISchema[];\n oneOf?: OpenAPISchema[];\n allOf?: OpenAPISchema[];\n items?: OpenAPISchema;\n properties?: Record<string, OpenAPISchema>;\n additionalProperties?: boolean | OpenAPISchema;\n required?: string[];\n minLength?: number;\n maxLength?: number;\n pattern?: string;\n minimum?: number;\n maximum?: number;\n minItems?: number;\n maxItems?: number;\n description?: string;\n}\n\nexport interface OpenAPIParameter {\n name: string;\n in: string;\n required?: boolean;\n schema?: OpenAPISchema;\n}\n\nexport interface OpenAPIOperation {\n operationId?: string;\n summary?: string;\n tags?: string[];\n parameters?: OpenAPIParameter[];\n requestBody?: {\n content?: {\n 'application/json'?: {\n schema?: OpenAPISchema;\n };\n };\n };\n responses?: Record<\n string,\n {\n content?: {\n 'application/json'?: {\n schema?: OpenAPISchema;\n };\n };\n }\n >;\n}\n\nexport interface OpenAPISpec {\n openapi: string;\n info: { title: string; version?: string };\n paths: Record<string, Record<string, OpenAPIOperation | OpenAPIParameter[]>>;\n components?: {\n schemas?: Record<string, OpenAPISchema>;\n };\n}\n\nexport interface PathSegment {\n name: string;\n isParam: boolean;\n raw: string;\n}\n\nexport function isListResponse(responseSchema: OpenAPISchema | undefined): boolean {\n if (!responseSchema) return false;\n\n if (responseSchema.type === 'object' && responseSchema.properties?.pagination) {\n return true;\n }\n if (responseSchema.type === 'array') {\n return true;\n }\n if (responseSchema.type === 'object' && responseSchema.properties) {\n for (const arrayProp of ['data', 'items', 'results']) {\n const prop = responseSchema.properties[arrayProp];\n if (prop?.type === 'array') return true;\n }\n }\n if (responseSchema.$ref) {\n const refName = responseSchema.$ref.split('/').pop()!;\n if (refName.includes('Paginated') || refName.includes('List')) {\n return true;\n }\n }\n return false;\n}\n\nexport function deriveEntityFromPath(pathPattern: string, includeParentContext = false): string | null {\n const segments = pathPattern.split('/').filter((seg) => seg && !seg.startsWith('{'));\n if (segments.length === 0) return null;\n\n if (includeParentContext && segments.length >= 2) {\n const parentSegment = segments[segments.length - 2];\n const lastSegment = segments[segments.length - 1];\n const singularParent = parentSegment.endsWith('s') ? parentSegment.slice(0, -1) : parentSegment;\n return pascalCase(singularParent) + pascalCase(lastSegment);\n }\n\n const lastSegment = segments[segments.length - 1];\n return pascalCase(lastSegment);\n}\n\nexport function isActionWord(word: string): boolean {\n const knownActions = ['status', 'approve', 'cancel', 'current', 'download_link', 'preferences'];\n if (knownActions.includes(word.toLowerCase())) return true;\n if (word.endsWith('s') && !word.endsWith('ss') && !word.endsWith('us')) {\n return false;\n }\n return true;\n}\n\nexport function operationIdToMethodName(\n operationId: string | undefined,\n httpMethod: string,\n pathPattern: string,\n resourceName: string,\n responseSchema: OpenAPISchema | undefined,\n): string {\n const isList = isListResponse(responseSchema);\n\n switch (httpMethod) {\n case 'get':\n return isList ? 'getList' : 'getDetail';\n case 'post':\n return 'create';\n case 'put':\n return 'replace';\n case 'patch':\n return 'update';\n case 'delete':\n return 'delete';\n default:\n return operationId ? camelCase(operationId) : httpMethod;\n }\n}\n\nexport function parsePathSegments(pathPattern: string): PathSegment[] {\n return pathPattern\n .split('/')\n .filter((seg) => seg)\n .map((seg) => ({\n name: seg.startsWith('{') ? seg.slice(1, -1) : seg,\n isParam: seg.startsWith('{'),\n raw: seg,\n }));\n}\n\nexport function getResourcePath(pathPattern: string): string[] {\n const segments = parsePathSegments(pathPattern);\n const resourcePath: string[] = [];\n for (const seg of segments) {\n if (!seg.isParam) {\n resourcePath.push(seg.name);\n }\n }\n return resourcePath;\n}\n\nexport interface PathTreeNode {\n name: string;\n children: Map<string, PathTreeNode>;\n operations: Array<{\n pathPattern: string;\n httpMethod: string;\n operation: OpenAPIOperation;\n }>;\n}\n\nexport function buildPathTree(paths: Record<string, Record<string, OpenAPIOperation | OpenAPIParameter[]>>): PathTreeNode {\n const tree: PathTreeNode = {\n name: 'root',\n children: new Map(),\n operations: [],\n };\n\n for (const [pathPattern, methods] of Object.entries(paths)) {\n for (const [httpMethod, operation] of Object.entries(methods)) {\n if (httpMethod === 'parameters') continue;\n\n const resourcePath = getResourcePath(pathPattern);\n\n let current = tree;\n for (const segment of resourcePath) {\n if (!current.children.has(segment)) {\n current.children.set(segment, {\n name: segment,\n children: new Map(),\n operations: [],\n });\n }\n current = current.children.get(segment)!;\n }\n\n current.operations.push({\n pathPattern,\n httpMethod,\n operation: operation as OpenAPIOperation,\n });\n }\n }\n\n return tree;\n}\n\nexport function cleanSchemaName(name: string): string {\n if (name.endsWith('SchemaInput')) {\n name = name.replace('SchemaInput', 'Input');\n } else if (name.endsWith('Schema')) {\n name = name.replace('Schema', '');\n }\n\n if (name.includes('__')) {\n const parts = name.split('__');\n name = parts[parts.length - 1];\n }\n\n name = name.replace(/_+$/, '');\n name = name.replace(/_([A-Za-z])/g, (_, char) => char.toUpperCase());\n\n return name;\n}\n","import { EnumRegistry } from './enum-registry';\nimport { ZodGenerator } from './zod-generator';\nimport {\n camelCase,\n pascalCase,\n singularize,\n capitalize,\n schemaConstToTypeName,\n isBooleanLikeEnum,\n getResourcePrefixedParamNames,\n prefixSchemaConst,\n prefixTypeName,\n operationIdToMethodName,\n getResourcePath,\n buildPathTree,\n cleanSchemaName,\n OpenAPISchema,\n OpenAPIOperation,\n OpenAPIParameter,\n PathTreeNode,\n} from './utils';\n\ninterface ResourceResult {\n className: string;\n code: string;\n children: Array<{ propertyName: string; className: string; fileName: string }>;\n}\n\nexport class ResourceGenerator {\n private schemas: Record<string, OpenAPISchema>;\n private clientClassName: string;\n private stripPathPrefix: string | null;\n public enumRegistry: EnumRegistry;\n private paths: Record<string, Record<string, OpenAPIOperation | OpenAPIParameter[]>>;\n private pathTree: PathTreeNode;\n private generatedResources = new Map<string, ResourceResult>();\n public collectedInlineSchemas = new Map<\n string,\n { schema: OpenAPISchema; isInput: boolean; typeName: string }\n >();\n private currentResourceName: string | null = null;\n private runtimePackage: string;\n private schemaPrefix: string;\n\n constructor(\n paths: Record<string, Record<string, OpenAPIOperation | OpenAPIParameter[]>> | undefined,\n schemas: Record<string, OpenAPISchema> | undefined,\n clientClassName: string,\n options: {\n stripPathPrefix?: string;\n enumRegistry?: EnumRegistry;\n runtimePackage?: string;\n schemaPrefix?: string;\n } = {},\n ) {\n this.schemas = schemas || {};\n this.clientClassName = clientClassName;\n this.stripPathPrefix = options.stripPathPrefix || null;\n this.enumRegistry = options.enumRegistry || new EnumRegistry();\n this.runtimePackage = options.runtimePackage || '@moinax/orc';\n this.schemaPrefix = options.schemaPrefix || '';\n\n this.paths = this.stripPathPrefix ? this.stripPrefixFromPaths(paths || {}) : paths || {};\n this.pathTree = buildPathTree(this.paths);\n }\n\n collectAllInlineSchemas(): Map<string, { schema: OpenAPISchema; isInput: boolean; typeName: string }> {\n this._collectInlineSchemasFromNode(this.pathTree, []);\n return this.collectedInlineSchemas;\n }\n\n private _collectInlineSchemasFromNode(node: PathTreeNode, parentPath: string[]): void {\n const nodeName = node.name === 'root' ? '' : node.name;\n const currentPath = [...parentPath, nodeName].filter(Boolean);\n\n const operationMethodNames = new Map<string, string>();\n for (const { pathPattern, httpMethod, operation } of node.operations) {\n const responseSchemaObj = (\n operation.responses?.['200'] || operation.responses?.['201']\n )?.content?.['application/json']?.schema;\n const methodName = operationIdToMethodName(\n operation.operationId,\n httpMethod,\n pathPattern,\n node.name,\n responseSchemaObj,\n );\n const opKey = this.getOperationKey(pathPattern, httpMethod);\n operationMethodNames.set(opKey, methodName);\n }\n\n const resourceClassName = this.getResourceClassName(currentPath);\n\n for (const { pathPattern, httpMethod, operation } of node.operations) {\n if (this.hasInlineRequestBody(operation)) {\n const requestSchema = this.getRequestSchemaName(operation, pathPattern);\n if (!requestSchema) {\n const opKey = this.getOperationKey(pathPattern, httpMethod);\n const methodName = operationMethodNames.get(opKey)!;\n const schemaConstName = this.generateInlineSchemaName(resourceClassName, methodName, 'body');\n\n const bodySchema = operation.requestBody!.content!['application/json']!.schema!;\n this.collectedInlineSchemas.set(schemaConstName, {\n schema: bodySchema,\n isInput: true,\n typeName: prefixTypeName(`${resourceClassName}${pascalCase(methodName)}Body`, this.schemaPrefix),\n });\n }\n }\n }\n\n for (const { pathPattern, httpMethod, operation } of node.operations) {\n if (this.hasInlineResponseSchema(operation)) {\n const responseSchema = this.getResponseSchemaName(operation, pathPattern);\n if (!responseSchema) {\n const opKey = this.getOperationKey(pathPattern, httpMethod);\n const methodName = operationMethodNames.get(opKey)!;\n const schemaConstName = this.generateInlineSchemaName(resourceClassName, methodName, 'response');\n\n const successResponse = operation.responses?.['200'] || operation.responses?.['201'];\n const inlineSchema = successResponse!.content!['application/json']!.schema!;\n this.collectedInlineSchemas.set(schemaConstName, {\n schema: inlineSchema,\n isInput: false,\n typeName: prefixTypeName(`${resourceClassName}${pascalCase(methodName)}Response`, this.schemaPrefix),\n });\n }\n }\n }\n\n for (const [, childNode] of node.children) {\n this._collectInlineSchemasFromNode(childNode, currentPath);\n }\n }\n\n private stripPrefixFromPaths(\n paths: Record<string, Record<string, OpenAPIOperation | OpenAPIParameter[]>>,\n ): Record<string, Record<string, OpenAPIOperation | OpenAPIParameter[]>> {\n const result: Record<string, Record<string, OpenAPIOperation | OpenAPIParameter[]>> = {};\n for (const [pathPattern, methods] of Object.entries(paths)) {\n let newPath = pathPattern;\n if (this.stripPathPrefix && pathPattern.startsWith(this.stripPathPrefix)) {\n newPath = pathPattern.slice(this.stripPathPrefix.length) || '/';\n }\n result[newPath] = methods;\n }\n return result;\n }\n\n private getResponseSchemaName(operation: OpenAPIOperation, pathPattern: string | null = null): string | null {\n const successResponse = operation.responses?.['200'] || operation.responses?.['201'];\n if (!successResponse) return null;\n\n const content = successResponse.content?.['application/json'];\n if (!content?.schema) return null;\n\n const schema = content.schema;\n if (schema.$ref) {\n const rawName = schema.$ref.split('/').pop()!;\n return cleanSchemaName(rawName);\n }\n\n if (schema.type === 'object') {\n if (operation.operationId) {\n const opId = operation.operationId;\n const patterns = [\n /^create[_-]?(.+)$/i,\n /^update[_-]?(.+)$/i,\n /^get[_-]?(.+)$/i,\n /^(.+)[_-]?create$/i,\n /^(.+)[_-]?update$/i,\n /^(.+)[_-]?get$/i,\n ];\n\n for (const pattern of patterns) {\n const match = opId.match(pattern);\n if (match) {\n const entityName = pascalCase(match[1].replace(/[_-]/g, ' '));\n const schemaSchemaName = `${entityName}Schema`;\n if (this.schemas[entityName] || this.schemas[schemaSchemaName]) {\n return entityName;\n }\n }\n }\n }\n\n if (pathPattern) {\n const resourcePath = getResourcePath(pathPattern);\n if (resourcePath.length > 0) {\n const lastSegment = resourcePath[resourcePath.length - 1];\n const entityName = pascalCase(singularize(lastSegment));\n const schemaSchemaName = `${entityName}Schema`;\n if (this.schemas[entityName] || this.schemas[schemaSchemaName]) {\n return entityName;\n }\n }\n }\n }\n\n if (schema.type === 'object' && schema.properties) {\n return null;\n }\n\n return null;\n }\n\n private getRequestSchemaName(operation: OpenAPIOperation, pathPattern: string | null = null): string | null {\n const content = operation.requestBody?.content?.['application/json'];\n if (!content?.schema) return null;\n\n const schema = content.schema;\n if (schema.$ref) {\n const rawName = schema.$ref.split('/').pop()!;\n return cleanSchemaName(rawName);\n }\n\n return null;\n }\n\n private hasInlineRequestBody(operation: OpenAPIOperation): boolean {\n const content = operation.requestBody?.content?.['application/json'];\n if (!content?.schema) return false;\n return !content.schema.$ref && content.schema.type === 'object';\n }\n\n private hasInlineResponseSchema(operation: OpenAPIOperation): boolean {\n const successResponse = operation.responses?.['200'] || operation.responses?.['201'];\n if (!successResponse) return false;\n\n const content = successResponse.content?.['application/json'];\n if (!content?.schema) return false;\n\n const schema = content.schema;\n if (schema.$ref) return false;\n if (schema.type === 'object' && schema.properties?.pagination) return false;\n return schema.type === 'object' && !!schema.properties;\n }\n\n private generateInlineSchemaName(resourceName: string, methodName: string, purpose: string): string {\n const prefix = this.schemaPrefix ? camelCase(this.schemaPrefix) : '';\n // When prefixed, resourceName must be PascalCased to avoid merging with the camelCase prefix.\n // Without prefix, resourceName stays camelCase as the leading segment.\n const baseName = `${prefix}${prefix ? pascalCase(resourceName) : camelCase(resourceName)}${capitalize(methodName)}${capitalize(purpose)}Schema`;\n return camelCase(baseName);\n }\n\n private getPathParams(operation: OpenAPIOperation): Array<{ name: string; type: string; required: boolean }> {\n return (operation.parameters || [])\n .filter((p): p is OpenAPIParameter => 'in' in p && p.in === 'path')\n .map((p) => ({\n name: p.name,\n type: this.paramTypeToTs(p.schema),\n required: p.required !== false,\n }));\n }\n\n private getQueryParams(\n operation: OpenAPIOperation,\n ): Array<{ name: string; type: string; required: boolean; schema?: OpenAPISchema }> {\n return (operation.parameters || [])\n .filter((p): p is OpenAPIParameter => 'in' in p && p.in === 'query')\n .map((p) => ({\n name: p.name,\n type: this.paramTypeToTs(p.schema),\n required: p.required === true,\n schema: p.schema,\n }));\n }\n\n private paramTypeToTs(schema?: OpenAPISchema): string {\n if (!schema) return 'string';\n if (schema.enum) return schema.enum.map((v) => `'${v}'`).join(' | ');\n switch (schema.type) {\n case 'integer':\n case 'number':\n return 'number';\n case 'boolean':\n return 'boolean';\n default:\n return 'string';\n }\n }\n\n private paramToZod(\n param: { name: string; required: boolean; schema?: OpenAPISchema },\n resourceName?: string,\n ): string {\n const { schema, name: paramName } = param;\n if (!schema) return 'z.string()';\n\n let zodType: string;\n if (schema.enum) {\n if (isBooleanLikeEnum(schema.enum)) {\n zodType = 'z.boolean()';\n } else {\n const context = {\n source: 'queryParam' as const,\n resourceName: resourceName || this.currentResourceName || undefined,\n paramName: paramName,\n };\n const enumInfo = this.enumRegistry.register(schema.enum, context);\n zodType = enumInfo.schemaConstName;\n }\n } else {\n switch (schema.type) {\n case 'integer':\n zodType = 'z.number().int()';\n break;\n case 'number':\n zodType = 'z.number()';\n break;\n case 'boolean':\n zodType = 'z.boolean()';\n break;\n default:\n zodType = 'z.string()';\n }\n }\n\n if (!param.required) {\n zodType = `${zodType}.optional()`;\n }\n\n return zodType;\n }\n\n private isPaginationParam(paramName: string): boolean {\n return ['page', 'limit', 'orderBy', 'ordering'].includes(paramName);\n }\n\n private getUniqueMethodName(\n operationId: string | undefined,\n httpMethod: string,\n pathPattern: string,\n usedNames: Set<string>,\n responseSchema?: OpenAPISchema,\n ): string {\n let methodName = operationIdToMethodName(operationId, httpMethod, pathPattern, '', responseSchema);\n\n if (usedNames.has(methodName) && operationId) {\n methodName = camelCase(operationId);\n }\n\n let finalName = methodName;\n let counter = 1;\n while (usedNames.has(finalName)) {\n finalName = `${methodName}${counter}`;\n counter++;\n }\n\n usedNames.add(finalName);\n return finalName;\n }\n\n private getOperationKey(pathPattern: string, httpMethod: string): string {\n return `${httpMethod}:${pathPattern}`;\n }\n\n private getResourceClassName(pathSegments: string[]): string {\n return pathSegments.map((seg) => pascalCase(seg)).join('');\n }\n\n private generateResourceNode(node: PathTreeNode, pathSegments: string[]): ResourceResult {\n const parentImportPath = '../';\n const resourceClassName = this.getResourceClassName(pathSegments);\n\n this.currentResourceName = resourceClassName;\n\n const lines: string[] = [];\n const usedMethodNames = new Set<string>();\n const schemaImports = new Set<string>();\n let hasQueryParams = false;\n let hasPaginatedResponse = false;\n\n const childResources: Array<{ propertyName: string; className: string; fileName: string }> = [];\n for (const [childName, childNode] of node.children) {\n const childPath = [...pathSegments, childName];\n const childClassName = this.getResourceClassName(childPath);\n childResources.push({\n propertyName: singularize(camelCase(childName)),\n className: childClassName,\n fileName: `${childClassName}.resource`,\n });\n }\n\n const operationMethodNames = new Map<string, string>();\n let usesInlineZod = false;\n for (const { pathPattern, httpMethod, operation } of node.operations) {\n const successResponse = operation.responses?.['200'] || operation.responses?.['201'];\n const responseContent = successResponse?.content?.['application/json'];\n const responseSchemaObj = responseContent?.schema;\n\n const methodName = this.getUniqueMethodName(\n operation.operationId,\n httpMethod,\n pathPattern,\n usedMethodNames,\n responseSchemaObj,\n );\n const opKey = this.getOperationKey(pathPattern, httpMethod);\n operationMethodNames.set(opKey, methodName);\n\n const queryParams = this.getQueryParams(operation);\n if (queryParams.length > 0) {\n hasQueryParams = true;\n }\n\n if (responseSchemaObj?.type === 'object' && responseSchemaObj?.properties?.pagination) {\n hasPaginatedResponse = true;\n }\n\n if (\n responseSchemaObj?.type === 'object' &&\n responseSchemaObj?.properties?.pagination &&\n !responseSchemaObj?.properties?.data?.items?.$ref\n ) {\n usesInlineZod = true;\n }\n }\n\n const typeImports = new Map<string, string>();\n\n if (hasQueryParams) {\n schemaImports.add('paginationParamsSchema');\n }\n if (hasPaginatedResponse) {\n schemaImports.add('paginationResponseSchema');\n typeImports.set('paginationResponseSchema', 'PaginationResponse');\n }\n\n for (const { pathPattern, operation } of node.operations) {\n const responseSchema = this.getResponseSchemaName(operation, pathPattern);\n if (responseSchema) {\n const schemaConst = prefixSchemaConst(responseSchema, this.schemaPrefix);\n schemaImports.add(schemaConst);\n typeImports.set(schemaConst, prefixTypeName(responseSchema, this.schemaPrefix));\n }\n const requestSchema = this.getRequestSchemaName(operation, pathPattern);\n if (requestSchema) {\n const schemaConst = prefixSchemaConst(requestSchema, this.schemaPrefix);\n schemaImports.add(schemaConst);\n typeImports.set(schemaConst, prefixTypeName(requestSchema, this.schemaPrefix));\n }\n }\n\n const inlineBodySchemas = new Map<string, { schemaConst: string; typeName: string }>();\n for (const { pathPattern, httpMethod, operation } of node.operations) {\n if (this.hasInlineRequestBody(operation)) {\n const requestSchema = this.getRequestSchemaName(operation, pathPattern);\n if (!requestSchema) {\n const opKey = this.getOperationKey(pathPattern, httpMethod);\n const methodName = operationMethodNames.get(opKey)!;\n const schemaConstName = this.generateInlineSchemaName(resourceClassName, methodName, 'body');\n const typeName = schemaConstToTypeName(schemaConstName);\n inlineBodySchemas.set(opKey, { schemaConst: schemaConstName, typeName });\n schemaImports.add(schemaConstName);\n typeImports.set(schemaConstName, typeName);\n }\n }\n }\n\n const inlineResponseSchemas = new Map<string, { schemaConst: string; typeName: string }>();\n for (const { pathPattern, httpMethod, operation } of node.operations) {\n if (this.hasInlineResponseSchema(operation)) {\n const responseSchema = this.getResponseSchemaName(operation, pathPattern);\n if (!responseSchema) {\n const opKey = this.getOperationKey(pathPattern, httpMethod);\n const methodName = operationMethodNames.get(opKey)!;\n const schemaConstName = this.generateInlineSchemaName(resourceClassName, methodName, 'response');\n const typeName = schemaConstToTypeName(schemaConstName);\n inlineResponseSchemas.set(opKey, { schemaConst: schemaConstName, typeName });\n schemaImports.add(schemaConstName);\n typeImports.set(schemaConstName, typeName);\n }\n }\n }\n\n const needsZod = hasQueryParams || usesInlineZod;\n if (needsZod) {\n lines.push(\"import { z } from 'zod';\");\n lines.push('');\n }\n\n const hasParsing = node.operations.some(({ httpMethod, operation }) => {\n const successResponse = operation.responses?.['200'] || operation.responses?.['201'];\n const hasResponseParsing = !!successResponse?.content?.['application/json']?.schema;\n const hasBodyParsing = ['post', 'put', 'patch'].includes(httpMethod) && !!operation.requestBody;\n const hasParamsParsing = this.getQueryParams(operation).length > 0;\n return hasResponseParsing || hasBodyParsing || hasParamsParsing;\n });\n if (hasParsing) {\n lines.push(`import { parseSchema } from '${this.runtimePackage}';`);\n }\n\n lines.push(`import { Resource } from '${parentImportPath}Resource';`);\n\n const schemaImportPlaceholderIndex = lines.length;\n lines.push('__SCHEMA_IMPORTS_PLACEHOLDER__');\n\n for (const child of childResources) {\n lines.push(`import { ${child.className}Resource } from './${child.fileName}';`);\n }\n lines.push('');\n\n const queryParamsSchemas: string[] = [];\n for (const { pathPattern, httpMethod, operation } of node.operations) {\n const queryParams = this.getQueryParams(operation);\n if (queryParams.length > 0) {\n const opKey = this.getOperationKey(pathPattern, httpMethod);\n const methodName = operationMethodNames.get(opKey)!;\n const { schemaConstName, typeName } = getResourcePrefixedParamNames(methodName, resourceClassName, this.schemaPrefix);\n\n const specificParams = queryParams.filter((p) => !this.isPaginationParam(p.name));\n\n if (specificParams.length > 0) {\n const props = specificParams.map((p) => {\n const zodCode = this.paramToZod(p, resourceClassName);\n if (p.schema?.enum) {\n const enumInfo = this.enumRegistry.get(p.schema.enum);\n if (enumInfo) {\n schemaImports.add(enumInfo.schemaConstName);\n }\n }\n return ` ${p.name}: ${zodCode}`;\n });\n queryParamsSchemas.push(\n `export const ${schemaConstName} = paginationParamsSchema.extend({\\n${props.join(',\\n')},\\n});`,\n );\n } else {\n queryParamsSchemas.push(`export const ${schemaConstName} = paginationParamsSchema;`);\n }\n queryParamsSchemas.push(`export type ${typeName} = z.input<typeof ${schemaConstName}>;`);\n queryParamsSchemas.push('');\n }\n }\n\n if (queryParamsSchemas.length > 0) {\n lines.push('// Query parameter schemas');\n lines.push(queryParamsSchemas.join('\\n'));\n }\n\n lines.push(`export class ${resourceClassName}Resource extends Resource {`);\n\n for (const child of childResources) {\n lines.push(` public ${child.propertyName}: ${child.className}Resource;`);\n }\n\n if (childResources.length > 0) {\n lines.push('');\n lines.push(\n ` constructor(client: InstanceType<typeof import('${parentImportPath}${this.clientClassName}').default>) {`,\n );\n lines.push(' super(client);');\n for (const child of childResources) {\n lines.push(` this.${child.propertyName} = new ${child.className}Resource(client);`);\n }\n lines.push(' }');\n }\n\n for (const { pathPattern, httpMethod, operation } of node.operations) {\n const opKey = this.getOperationKey(pathPattern, httpMethod);\n const methodName = operationMethodNames.get(opKey)!;\n const pathParams = this.getPathParams(operation);\n const queryParams = this.getQueryParams(operation);\n const responseSchema = this.getResponseSchemaName(operation, pathPattern);\n const requestSchema = this.getRequestSchemaName(operation, pathPattern);\n\n const params: string[] = [];\n for (const p of pathParams) {\n params.push(`${p.name}: ${p.type}`);\n }\n\n if (queryParams.length > 0) {\n const { typeName } = getResourcePrefixedParamNames(methodName, resourceClassName, this.schemaPrefix);\n const hasRequired = queryParams.some((p) => p.required);\n params.push(`params${hasRequired ? '' : '?'}: ${typeName}`);\n }\n\n const inlineBodySchema = inlineBodySchemas.get(opKey);\n\n if (['post', 'put', 'patch'].includes(httpMethod) && operation.requestBody) {\n if (requestSchema) {\n const schemaConst = prefixSchemaConst(requestSchema, this.schemaPrefix);\n const typeName = typeImports.get(schemaConst)!;\n params.push(`body: ${typeName}`);\n } else if (inlineBodySchema) {\n params.push(`body: ${inlineBodySchema.typeName}`);\n } else {\n params.push('body: Record<string, unknown>');\n }\n }\n\n const fullPath = this.stripPathPrefix ? this.stripPathPrefix + pathPattern : pathPattern;\n let pathTemplate = fullPath.replace(/\\{(\\w+)\\}/g, '${$1}');\n pathTemplate = '`' + pathTemplate + '`';\n\n const successResponse = operation.responses?.['200'] || operation.responses?.['201'];\n const responseContent = successResponse?.content?.['application/json'];\n const responseSchemaObj = responseContent?.schema;\n\n let returnType = 'void';\n let parseLogic = '';\n\n if (responseSchemaObj) {\n if (responseSchemaObj.type === 'object' && responseSchemaObj.properties?.pagination) {\n const dataRef = responseSchemaObj.properties.data?.items?.$ref;\n if (dataRef) {\n const rawItemSchema = dataRef.split('/').pop()!;\n const itemSchema = cleanSchemaName(rawItemSchema);\n const itemSchemaConst = prefixSchemaConst(itemSchema, this.schemaPrefix);\n const itemTypeName = prefixTypeName(itemSchema, this.schemaPrefix);\n schemaImports.add(itemSchemaConst);\n typeImports.set(itemSchemaConst, itemTypeName);\n returnType = `{ pagination: PaginationResponse; data: ${itemTypeName}[] }`;\n parseLogic = `const schema = z.object({ pagination: paginationResponseSchema, data: z.array(${itemSchemaConst}) }).describe('Paginated${itemTypeName}List');\n return parseSchema(schema, response);`;\n } else {\n if (responseSchema) {\n const itemSchemaConst = prefixSchemaConst(responseSchema, this.schemaPrefix);\n const itemTypeName = prefixTypeName(responseSchema, this.schemaPrefix);\n schemaImports.add(itemSchemaConst);\n typeImports.set(itemSchemaConst, itemTypeName);\n returnType = `{ pagination: PaginationResponse; data: ${itemTypeName}[] }`;\n parseLogic = `const schema = z.object({ pagination: paginationResponseSchema, data: z.array(${itemSchemaConst}) }).describe('Paginated${itemTypeName}List');\n return parseSchema(schema, response);`;\n } else {\n returnType = `{ pagination: PaginationResponse; data: unknown[] }`;\n parseLogic = `const schema = z.object({ pagination: paginationResponseSchema, data: z.array(z.unknown()) }).describe('PaginatedList');\n return parseSchema(schema, response);`;\n }\n }\n } else if (responseSchema) {\n const schemaConstName = prefixSchemaConst(responseSchema, this.schemaPrefix);\n const typeName = prefixTypeName(responseSchema, this.schemaPrefix);\n returnType = typeName;\n parseLogic = `return parseSchema(${schemaConstName}, response);`;\n schemaImports.add(schemaConstName);\n typeImports.set(schemaConstName, typeName);\n } else if (inlineResponseSchemas.get(opKey)) {\n const inlineSchema = inlineResponseSchemas.get(opKey)!;\n returnType = inlineSchema.typeName;\n parseLogic = `return parseSchema(${inlineSchema.schemaConst}, response);`;\n } else {\n returnType = 'unknown';\n parseLogic = 'return response;';\n }\n }\n\n lines.push('');\n lines.push(` async ${methodName}(${params.join(', ')}): Promise<${returnType}> {`);\n\n if (queryParams.length > 0) {\n const { schemaConstName } = getResourcePrefixedParamNames(methodName, resourceClassName, this.schemaPrefix);\n lines.push(` const searchParams = new URLSearchParams();`);\n lines.push(` if (params) {`);\n lines.push(` const validated = parseSchema(${schemaConstName}, params);`);\n lines.push(` Object.entries(validated).forEach(([key, value]) => {`);\n lines.push(` if (value !== undefined) searchParams.set(key, String(value));`);\n lines.push(` });`);\n lines.push(` }`);\n lines.push(` const query = searchParams.toString();`);\n lines.push(` const url = query ? \\`\\${${pathTemplate}}?\\${query}\\` : ${pathTemplate};`);\n }\n\n const urlVar = queryParams.length > 0 ? 'url' : pathTemplate;\n const needsResponse = returnType !== 'void';\n const responsePrefix = needsResponse ? 'const response = ' : '';\n\n const hasBodySchema = requestSchema || inlineBodySchema;\n const hasBodyValidation = ['post', 'put', 'patch'].includes(httpMethod) && hasBodySchema;\n const bodyVar = hasBodyValidation ? 'validatedBody' : 'body';\n\n if (hasBodyValidation) {\n const bodySchemaConst = requestSchema\n ? prefixSchemaConst(requestSchema, this.schemaPrefix)\n : inlineBodySchema!.schemaConst;\n lines.push(` const validatedBody = parseSchema(${bodySchemaConst}, body);`);\n }\n\n switch (httpMethod) {\n case 'get':\n lines.push(` ${responsePrefix}await this.client.get(${urlVar});`);\n break;\n case 'post':\n lines.push(` ${responsePrefix}await this.client.post(${urlVar}, ${bodyVar});`);\n break;\n case 'put':\n lines.push(` ${responsePrefix}await this.client.put(${urlVar}, ${bodyVar});`);\n break;\n case 'patch':\n lines.push(` ${responsePrefix}await this.client.patch(${urlVar}, ${bodyVar});`);\n break;\n case 'delete':\n lines.push(` ${responsePrefix}await this.client.delete(${urlVar});`);\n break;\n }\n\n if (parseLogic) {\n lines.push(` ${parseLogic}`);\n }\n\n lines.push(' }');\n }\n\n lines.push('}');\n\n const placeholderIndex = lines.findIndex((l) => l === '__SCHEMA_IMPORTS_PLACEHOLDER__');\n if (placeholderIndex >= 0) {\n if (schemaImports.size > 0 || typeImports.size > 0) {\n const allImports = new Set([...schemaImports, ...typeImports.values()]);\n lines[placeholderIndex] = `import { ${Array.from(allImports).join(', ')} } from '${parentImportPath}schemas';`;\n } else {\n lines.splice(placeholderIndex, 1);\n }\n }\n\n return {\n className: resourceClassName,\n code: lines.join('\\n'),\n children: childResources,\n };\n }\n\n private generateFromTree(\n node: PathTreeNode,\n pathSegments: string[] = [],\n depth = 0,\n ): Array<ResourceResult & { pathSegments: string[] }> {\n const resources: Array<ResourceResult & { pathSegments: string[] }> = [];\n\n for (const [childName, childNode] of node.children) {\n const childPath = [...pathSegments, childName];\n const childResources = this.generateFromTree(childNode, childPath, depth + 1);\n resources.push(...childResources);\n }\n\n if (pathSegments.length > 0 && (node.operations.length > 0 || node.children.size > 0)) {\n const resource = this.generateResourceNode(node, pathSegments);\n resources.push({\n pathSegments,\n ...resource,\n });\n }\n\n return resources;\n }\n\n generateAll(): {\n resources: Record<string, string>;\n tree: PathTreeNode;\n inlineSchemas: Map<string, { schema: OpenAPISchema; isInput: boolean; typeName: string }>;\n } {\n this.collectAllInlineSchemas();\n\n const resources = this.generateFromTree(this.pathTree);\n\n const result: Record<string, string> = {};\n for (const resource of resources) {\n result[resource.className] = resource.code;\n }\n\n return {\n resources: result,\n tree: this.pathTree,\n inlineSchemas: this.collectedInlineSchemas,\n };\n }\n}\n","import { EnumRegistry, EnumContext } from './enum-registry';\nimport { camelCase, pascalCase, isBooleanLikeEnum, cleanSchemaName, prefixSchemaConst, prefixTypeName, OpenAPISchema } from './utils';\n\nexport interface UsedDateSchemas {\n stringToDateSchema: boolean;\n stringToDaySchema: boolean;\n dateToStringSchema: boolean;\n dayToStringSchema: boolean;\n}\n\nexport class ZodGenerator {\n private schemas: Record<string, OpenAPISchema>;\n private generatedSchemas = new Map<string, string>();\n private schemaOrder: string[] = [];\n private inlineSchemas = new Map<string, { schema: OpenAPISchema; isInput: boolean; typeName: string }>();\n public enumRegistry: EnumRegistry;\n public usedDateSchemas: UsedDateSchemas = {\n stringToDateSchema: false,\n stringToDaySchema: false,\n dateToStringSchema: false,\n dayToStringSchema: false,\n };\n private currentSchemaName: string | null = null;\n private currentPropertyPath: string | null = null;\n\n private schemaPrefix: string;\n\n constructor(schemas?: Record<string, OpenAPISchema>, enumRegistry?: EnumRegistry, schemaPrefix?: string) {\n this.schemas = schemas || {};\n this.enumRegistry = enumRegistry || new EnumRegistry();\n this.schemaPrefix = schemaPrefix || '';\n }\n\n addInlineSchemas(inlineSchemas: Map<string, { schema: OpenAPISchema; isInput: boolean; typeName: string }>): void {\n this.inlineSchemas = inlineSchemas;\n }\n\n convertSchema(schema: OpenAPISchema | undefined, schemaName: string | null = null, isTopLevel = false): string {\n if (!schema) return 'z.unknown()';\n\n if (schema.$ref) {\n const refName = schema.$ref.split('/').pop()!;\n const cleanedName = cleanSchemaName(refName);\n return prefixSchemaConst(cleanedName, this.schemaPrefix);\n }\n\n if (schema.anyOf) {\n const options = schema.anyOf.map((s) => this.convertSchema(s, schemaName));\n if (options.length === 2 && options.includes('z.null()')) {\n const nonNull = options.find((o) => o !== 'z.null()');\n const isInputSchema =\n schemaName &&\n (schemaName.includes('Input') || schemaName.includes('Create') || schemaName.includes('Update'));\n return isInputSchema ? `${nonNull}.nullish()` : `${nonNull}.nullable()`;\n }\n return `z.union([${options.join(', ')}])`;\n }\n\n if (schema.oneOf) {\n if (schema.oneOf.length === 2) {\n const nullIdx = schema.oneOf.findIndex((s) => this.isNullSchema(s));\n if (nullIdx !== -1) {\n const nonNull = this.convertSchema(schema.oneOf[1 - nullIdx], schemaName);\n const isInputSchema =\n schemaName &&\n (schemaName.includes('Input') || schemaName.includes('Create') || schemaName.includes('Update'));\n return isInputSchema ? `${nonNull}.nullish()` : `${nonNull}.nullable()`;\n }\n }\n const options = schema.oneOf.map((s) => this.convertSchema(s, schemaName));\n return `z.union([${options.join(', ')}])`;\n }\n\n if (schema.allOf) {\n const schemas = schema.allOf.map((s) => this.convertSchema(s, schemaName));\n if (schemas.length === 1) return schemas[0];\n return schemas.reduce((acc, s) => `${acc}.merge(${s})`);\n }\n\n if (schema.const !== undefined) {\n if (typeof schema.const === 'string') {\n return `z.literal('${schema.const}')`;\n }\n return `z.literal(${JSON.stringify(schema.const)})`;\n }\n\n const isNullable = schema.nullable === true;\n let zodSchema: string;\n\n switch (schema.type) {\n case 'string':\n zodSchema = this.convertStringSchema(schema, schemaName);\n break;\n case 'number':\n case 'integer':\n zodSchema = this.convertNumberSchema(schema, schemaName);\n break;\n case 'boolean':\n zodSchema = 'z.boolean()';\n break;\n case 'array':\n zodSchema = this.convertArraySchema(schema, schemaName);\n break;\n case 'object':\n zodSchema = this.convertObjectSchema(schema, schemaName);\n break;\n case 'null':\n return 'z.null()';\n default:\n if (schema.enum) {\n zodSchema = this.convertEnumSchema(schema, schemaName);\n } else if (schema.properties) {\n zodSchema = this.convertObjectSchema(schema, schemaName);\n } else {\n zodSchema = 'z.unknown()';\n }\n }\n\n if (isNullable) {\n const isInputSchema =\n schemaName && (schemaName.includes('Input') || schemaName.includes('Create') || schemaName.includes('Update'));\n zodSchema = isInputSchema ? `${zodSchema}.nullish()` : `${zodSchema}.nullable()`;\n }\n\n return zodSchema;\n }\n\n private isNullSchema(schema: OpenAPISchema): boolean {\n if (schema.type === 'null') return true;\n if (schema.enum && schema.enum.length === 1 && schema.enum[0] === null) return true;\n if (schema.$ref) {\n const refName = schema.$ref.split('/').pop()!;\n const resolved = this.schemas[refName];\n if (resolved) return this.isNullSchema(resolved);\n }\n return false;\n }\n\n private convertStringSchema(schema: OpenAPISchema, schemaName: string | null = null): string {\n if (schema.enum) {\n return this.convertEnumSchema(schema, schemaName);\n }\n\n if (schema.format === 'date-time' || schema.format === 'date') {\n const isInputSchema =\n schemaName && (schemaName.includes('Input') || schemaName.includes('Create') || schemaName.includes('Update'));\n const isDateTime = schema.format === 'date-time';\n\n if (isInputSchema) {\n if (isDateTime) {\n this.usedDateSchemas.dateToStringSchema = true;\n return 'dateToStringSchema';\n } else {\n this.usedDateSchemas.dayToStringSchema = true;\n return 'dayToStringSchema';\n }\n }\n if (isDateTime) {\n this.usedDateSchemas.stringToDateSchema = true;\n return 'stringToDateSchema';\n } else {\n this.usedDateSchemas.stringToDaySchema = true;\n return 'stringToDaySchema';\n }\n }\n\n let zod = 'z.string()';\n if (schema.format === 'uuid') {\n zod = 'z.string().uuid()';\n } else if (schema.format === 'email') {\n zod = 'z.string().email()';\n } else if (schema.format === 'uri') {\n zod = 'z.string().url()';\n }\n\n if (schema.minLength !== undefined) {\n zod = `${zod}.min(${schema.minLength})`;\n }\n if (schema.maxLength !== undefined) {\n zod = `${zod}.max(${schema.maxLength})`;\n }\n if (schema.pattern && !schema.format) {\n zod = `${zod}.regex(/${schema.pattern}/)`;\n }\n\n return zod;\n }\n\n private convertNumberSchema(schema: OpenAPISchema, schemaName: string | null = null): string {\n const isInputSchema =\n schemaName &&\n (schemaName.includes('Input') ||\n schemaName.includes('Body') ||\n schemaName.includes('Params') ||\n schemaName === 'InlineInput');\n const baseType = isInputSchema ? 'z.coerce.number()' : 'z.number()';\n let zod = schema.type === 'integer' ? `${baseType}.int()` : baseType;\n\n if (schema.minimum !== undefined) {\n zod = `${zod}.min(${schema.minimum})`;\n }\n if (schema.maximum !== undefined) {\n zod = `${zod}.max(${schema.maximum})`;\n }\n\n return zod;\n }\n\n private convertArraySchema(schema: OpenAPISchema, schemaName: string | null = null): string {\n const itemSchema = schema.items ? this.convertSchema(schema.items, schemaName) : 'z.unknown()';\n let zod = `z.array(${itemSchema})`;\n\n if (schema.minItems !== undefined) {\n zod = `${zod}.min(${schema.minItems})`;\n }\n if (schema.maxItems !== undefined) {\n zod = `${zod}.max(${schema.maxItems})`;\n }\n\n return zod;\n }\n\n private convertObjectSchema(schema: OpenAPISchema, schemaName: string | null = null): string {\n if (!schema.properties || Object.keys(schema.properties).length === 0) {\n if (schema.additionalProperties && typeof schema.additionalProperties === 'object') {\n const valueSchema = this.convertSchema(schema.additionalProperties as OpenAPISchema, schemaName);\n return `z.record(z.string(), ${valueSchema})`;\n }\n return 'z.object({})';\n }\n\n const required = new Set(schema.required || []);\n const properties: string[] = [];\n\n for (const [propName, propSchema] of Object.entries(schema.properties)) {\n const previousPropertyPath = this.currentPropertyPath;\n this.currentPropertyPath = previousPropertyPath ? `${previousPropertyPath}.${propName}` : propName;\n\n const propZod = this.convertSchema(propSchema, schemaName);\n const isRequired = required.has(propName);\n const finalProp = isRequired ? propZod : `${propZod}.optional()`;\n properties.push(` ${propName}: ${finalProp}`);\n\n this.currentPropertyPath = previousPropertyPath;\n }\n\n let zod = `z.object({\\n${properties.join(',\\n')}\\n})`;\n\n if (schema.additionalProperties === false) {\n zod = `${zod}.strict()`;\n }\n\n return zod;\n }\n\n private convertEnumSchema(schema: OpenAPISchema, schemaName: string | null = null): string {\n const rawValues = schema.enum!;\n const hasNull = rawValues.some((v) => v === null);\n const values = rawValues.filter((v): v is string => v !== null && v !== '');\n\n if (values.length === 0) {\n if (hasNull) return 'z.null()';\n // Enum with only empty string(s) — treat as z.literal('')\n return \"z.literal('')\";\n }\n\n if (isBooleanLikeEnum(values)) {\n return hasNull ? 'z.boolean().nullable()' : 'z.boolean()';\n }\n\n const context: EnumContext = {\n source: 'schema',\n schemaName: this.currentSchemaName || schemaName || undefined,\n propertyPath: this.currentPropertyPath || undefined,\n };\n\n const enumInfo = this.enumRegistry.register(values, context);\n return hasNull ? `${enumInfo.schemaConstName}.nullable()` : enumInfo.schemaConstName;\n }\n\n private extractDependencies(schema: OpenAPISchema | undefined): Set<string> {\n const deps = new Set<string>();\n if (!schema) return deps;\n\n if (schema.$ref) {\n const refName = schema.$ref.split('/').pop()!;\n deps.add(refName);\n return deps;\n }\n\n if (schema.anyOf) {\n for (const s of schema.anyOf) {\n for (const dep of this.extractDependencies(s)) {\n deps.add(dep);\n }\n }\n }\n\n if (schema.oneOf) {\n for (const s of schema.oneOf) {\n for (const dep of this.extractDependencies(s)) {\n deps.add(dep);\n }\n }\n }\n\n if (schema.allOf) {\n for (const s of schema.allOf) {\n for (const dep of this.extractDependencies(s)) {\n deps.add(dep);\n }\n }\n }\n\n if (schema.items) {\n for (const dep of this.extractDependencies(schema.items)) {\n deps.add(dep);\n }\n }\n\n if (schema.properties) {\n for (const propSchema of Object.values(schema.properties)) {\n for (const dep of this.extractDependencies(propSchema)) {\n deps.add(dep);\n }\n }\n }\n\n if (schema.additionalProperties && typeof schema.additionalProperties === 'object') {\n for (const dep of this.extractDependencies(schema.additionalProperties as OpenAPISchema)) {\n deps.add(dep);\n }\n }\n\n return deps;\n }\n\n private topologicalSort(schemaNames: string[]): string[] {\n const visited = new Set<string>();\n const result: string[] = [];\n const visiting = new Set<string>();\n\n const visit = (name: string) => {\n if (visited.has(name)) return;\n if (visiting.has(name)) return;\n\n visiting.add(name);\n\n const schema = this.schemas[name];\n if (schema) {\n const deps = this.extractDependencies(schema);\n for (const dep of deps) {\n if (schemaNames.includes(dep)) {\n visit(dep);\n }\n }\n }\n\n visiting.delete(name);\n visited.add(name);\n result.push(name);\n };\n\n for (const name of schemaNames) {\n visit(name);\n }\n\n return result;\n }\n\n generateSchemas(runtimePackage: string): string {\n const schemaOutput: string[] = [];\n\n for (const name of Object.keys(this.schemas)) {\n this.schemaOrder.push(name);\n }\n\n this.schemaOrder = this.topologicalSort(this.schemaOrder);\n\n const usedNames = new Set<string>();\n\n for (const name of this.schemaOrder) {\n const schema = this.schemas[name];\n\n this.currentSchemaName = name;\n this.currentPropertyPath = null;\n\n const zodSchema = this.convertSchema(schema, name, true);\n\n this.currentSchemaName = null;\n\n let cleanName = name;\n if (cleanName.endsWith('SchemaInput')) {\n cleanName = cleanName.replace('SchemaInput', 'Input');\n } else if (cleanName.endsWith('Schema')) {\n cleanName = cleanName.replace('Schema', '');\n }\n\n const schemaConstName = prefixSchemaConst(cleanName, this.schemaPrefix);\n const typeName = prefixTypeName(cleanName, this.schemaPrefix);\n\n if (usedNames.has(schemaConstName) || usedNames.has(typeName)) {\n continue;\n }\n usedNames.add(schemaConstName);\n usedNames.add(typeName);\n\n schemaOutput.push(`export const ${schemaConstName} = ${zodSchema}.describe('${typeName}');`);\n const isInputType = /(?:Body|Input|Params)$/.test(cleanName);\n const inferType = isInputType ? 'z.input' : 'z.output';\n schemaOutput.push(`export type ${typeName} = ${inferType}<typeof ${schemaConstName}>;`);\n schemaOutput.push('');\n }\n\n this.enumRegistry.register(['desc', 'asc'], {\n source: 'schema',\n schemaName: 'PaginationParams',\n propertyPath: 'ordering',\n });\n const orderingEnumInfo = this.enumRegistry.get(['desc', 'asc'])!;\n\n schemaOutput.push('// Common pagination schemas');\n schemaOutput.push(`export const paginationParamsSchema = z.object({\n page: z.number().optional(),\n limit: z.number().optional(),\n orderBy: z.string().optional(),\n ordering: ${orderingEnumInfo.schemaConstName}.optional(),\n}).describe('PaginationParams');`);\n schemaOutput.push('export type PaginationParams = z.input<typeof paginationParamsSchema>;');\n schemaOutput.push('');\n\n schemaOutput.push(`export const paginationResponseSchema = z.object({\n page: z.number(),\n pages: z.number(),\n limit: z.number(),\n total: z.number(),\n}).describe('PaginationResponse');`);\n schemaOutput.push('export type PaginationResponse = z.output<typeof paginationResponseSchema>;');\n schemaOutput.push('');\n\n if (this.inlineSchemas.size > 0) {\n schemaOutput.push('// Inline request/response schemas');\n for (const [schemaName, schemaInfo] of this.inlineSchemas) {\n const { schema, isInput, typeName } = schemaInfo;\n const contextName = isInput ? 'InlineInput' : 'InlineOutput';\n const zodSchema = this.convertSchema(schema, contextName, true);\n schemaOutput.push(`export const ${schemaName} = ${zodSchema}.describe('${typeName}');`);\n const inferType = isInput ? 'z.input' : 'z.output';\n schemaOutput.push(`export type ${typeName} = ${inferType}<typeof ${schemaName}>;`);\n schemaOutput.push('');\n }\n }\n\n const output: string[] = [];\n output.push(\"import { z } from 'zod';\");\n\n const usedDateSchemasList = Object.entries(this.usedDateSchemas)\n .filter(([_, used]) => used)\n .map(([name]) => name);\n\n if (usedDateSchemasList.length > 0) {\n output.push(`import { ${usedDateSchemasList.join(', ')} } from '${runtimePackage}';`);\n }\n\n output.push('');\n\n const enumExports = this.enumRegistry.generateEnumExports();\n if (enumExports) {\n output.push(enumExports);\n }\n\n output.push(...schemaOutput);\n\n return output.join('\\n');\n }\n}\n","import fs from 'fs';\nimport path from 'path';\n\nexport async function writeFile(filepath: string, content: string): Promise<void> {\n const dir = path.dirname(filepath);\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true });\n }\n fs.writeFileSync(filepath, content);\n console.log(`Generated: ${filepath}`);\n}\n\nexport interface GeneratedFile {\n path: string;\n content: string;\n}\n\nexport async function writeFiles(files: GeneratedFile[]): Promise<void> {\n for (const file of files) {\n await writeFile(file.path, file.content);\n }\n}\n","import fs from 'fs';\nimport path from 'path';\nimport type { OpenAPISpec } from './utils';\n\nexport async function loadSpec(specPath: string): Promise<OpenAPISpec> {\n // If it's a URL, fetch it\n if (specPath.startsWith('http://') || specPath.startsWith('https://')) {\n console.log(`Fetching OpenAPI spec from ${specPath}...`);\n const response = await fetch(specPath);\n if (!response.ok) {\n throw new Error(`Failed to fetch OpenAPI spec: ${response.statusText}`);\n }\n const spec = (await response.json()) as OpenAPISpec;\n console.log(`OpenAPI spec version: ${spec.openapi}`);\n console.log(`API title: ${spec.info.title}`);\n return spec;\n }\n\n // Otherwise, read from file\n const resolvedPath = path.resolve(specPath);\n console.log(`Reading OpenAPI spec from ${resolvedPath}...`);\n if (!fs.existsSync(resolvedPath)) {\n throw new Error(`OpenAPI spec file not found: ${resolvedPath}`);\n }\n\n const content = fs.readFileSync(resolvedPath, 'utf-8');\n\n let spec: OpenAPISpec;\n if (resolvedPath.endsWith('.yaml') || resolvedPath.endsWith('.yml')) {\n throw new Error('YAML specs are not supported yet. Please use JSON format.');\n } else {\n spec = JSON.parse(content) as OpenAPISpec;\n }\n\n console.log(`OpenAPI spec version: ${spec.openapi}`);\n console.log(`API title: ${spec.info.title}`);\n return spec;\n}\n","import path from 'path';\nimport { generateClient } from '../../generator/client-generator';\nimport type { OrcConfig } from '../../generator/config';\n\nexport async function runGenerate(\n config: OrcConfig,\n options: { client?: string; spec?: string },\n): Promise<void> {\n const runtimePackage = config.runtimePackage || '@moinax/orc';\n\n let clients = config.clients;\n\n if (options.client) {\n clients = clients.filter((c) => c.name.toLowerCase() === options.client!.toLowerCase());\n if (clients.length === 0) {\n console.error(`Error: Client \"${options.client}\" not found in configuration.`);\n console.log('Available clients:', config.clients.map((c) => c.name).join(', '));\n process.exit(1);\n }\n }\n\n if (options.spec && !options.client) {\n console.error('Error: --spec requires --client to be specified');\n process.exit(1);\n }\n\n console.log('ORC - OpenAPI Rest Client Generator');\n console.log('====================================');\n console.log(`Generating ${clients.length} client(s): ${clients.map((c) => c.name).join(', ')}`);\n if (options.spec) {\n console.log(`Using custom spec: ${options.spec}`);\n }\n\n const results = [];\n for (const clientConfig of clients) {\n try {\n const result = await generateClient(clientConfig, {\n specOverride: options.spec,\n runtimePackage,\n });\n results.push(result);\n } catch (error) {\n console.error(`\\nError generating ${clientConfig.name}Client:`, (error as Error).message);\n process.exit(1);\n }\n }\n\n console.log('\\n' + '='.repeat(60));\n console.log('All clients generated successfully!');\n console.log('='.repeat(60));\n\n for (const result of results) {\n console.log(`\\n${result.name}Client resources: ${result.resourceNames.join(', ')}`);\n }\n}\n","import fs from 'fs';\nimport path from 'path';\n\nconst CONFIG_TEMPLATE = `import { defineConfig } from '@moinax/orc/config';\n\nexport default defineConfig({\n clients: [\n {\n name: 'MyApi',\n spec: 'https://api.example.com/openapi.json',\n output: 'src/lib/api/my-api-client',\n },\n ],\n});\n`;\n\nexport async function runInit(): Promise<void> {\n const configPath = path.join(process.cwd(), 'orc.config.ts');\n\n if (fs.existsSync(configPath)) {\n console.error(`Config file already exists: ${configPath}`);\n process.exit(1);\n }\n\n fs.writeFileSync(configPath, CONFIG_TEMPLATE);\n console.log(`Created config file: ${configPath}`);\n console.log('\\nEdit the file to configure your API clients, then run:');\n console.log(' orc generate');\n}\n"],"mappings":";;;AAAA,SAAS,eAAe;AACxB,OAAOA,WAAU;AACjB,OAAOC,SAAQ;AACf,SAAS,kBAAkB;;;ACH3B,OAAOC,SAAQ;AACf,OAAOC,WAAU;;;ACDjB,OAAOC,mBAAkB;;;ACAzB,OAAO,kBAA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iBAAiB,iBAAiB,gBAAgB;AAExE,eAAe,aAAiC;AAC9C,QAAM,MAAM,QAAQ,IAAI;AAExB,aAAW,cAAc,cAAc;AACrC,UAAM,aAAaE,MAAK,KAAK,KAAK,UAAU;AAC5C,QAAIC,IAAG,WAAW,UAAU,GAAG;AAC7B,cAAQ,IAAI,iBAAiB,UAAU,EAAE;AACzC,YAAM,OAAO,WAAW,KAAK,EAAE,gBAAgB,KAAK,CAAC;AACrD,YAAM,SAAS,MAAM,KAAK,OAAO,UAAU;AAC3C,aAAO;AAAA,IACT;AAAA,EACF;AAEA,QAAM,IAAI;AAAA,IACR,mEAAmE,aAAa,KAAK,IAAI,CAAC;AAAA,EAC5F;AACF;AAEA,IAAM,UAAU,IAAI,QAAQ;AAE5B,QACG,KAAK,KAAK,EACV,YAAY,qCAAqC,EACjD,QAAQ,OAAO;AAElB,QACG,QAAQ,UAAU,EAClB,YAAY,oDAAoD,EAChE,OAAO,uBAAuB,iCAAiC,EAC/D,OAAO,oBAAoB,uCAAuC,EAClE,OAAO,OAAO,YAAY;AACzB,QAAM,SAAS,MAAM,WAAW;AAChC,QAAM,YAAY,QAAQ,OAAO;AACnC,CAAC;AAEH,QACG,QAAQ,MAAM,EACd,YAAY,mCAAmC,EAC/C,OAAO,YAAY;AAClB,QAAM,QAAQ;AAChB,CAAC;AAEH,QAAQ,MAAM;","names":["path","fs","fs","path","pluralizeLib","cleanSchemaName","pluralizeLib","fs","path","spec","path","fs","fs","path","path","fs"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/generator/config.ts"],"sourcesContent":["export interface ClientConfig {\n name: string;\n spec: string;\n output: string;\n stripPathPrefix?: string;\n}\n\nexport interface OrcConfig {\n clients: ClientConfig[];\n runtimePackage?: string;\n}\n\nexport function defineConfig(config: OrcConfig): OrcConfig {\n return config;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAYO,SAAS,aAAa,QAA8B;AACzD,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/generator/config.ts"],"sourcesContent":["export interface ClientConfig {\n name: string;\n spec: string;\n output: string;\n stripPathPrefix?: string;\n schemaPrefix?: string;\n}\n\nexport interface OrcConfig {\n clients: ClientConfig[];\n runtimePackage?: string;\n}\n\nexport function defineConfig(config: OrcConfig): OrcConfig {\n return config;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaO,SAAS,aAAa,QAA8B;AACzD,SAAO;AACT;","names":[]}
@@ -3,6 +3,7 @@ interface ClientConfig {
3
3
  spec: string;
4
4
  output: string;
5
5
  stripPathPrefix?: string;
6
+ schemaPrefix?: string;
6
7
  }
7
8
  interface OrcConfig {
8
9
  clients: ClientConfig[];
@@ -3,6 +3,7 @@ interface ClientConfig {
3
3
  spec: string;
4
4
  output: string;
5
5
  stripPathPrefix?: string;
6
+ schemaPrefix?: string;
6
7
  }
7
8
  interface OrcConfig {
8
9
  clients: ClientConfig[];
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/generator/config.ts"],"sourcesContent":["export interface ClientConfig {\n name: string;\n spec: string;\n output: string;\n stripPathPrefix?: string;\n}\n\nexport interface OrcConfig {\n clients: ClientConfig[];\n runtimePackage?: string;\n}\n\nexport function defineConfig(config: OrcConfig): OrcConfig {\n return config;\n}\n"],"mappings":";AAYO,SAAS,aAAa,QAA8B;AACzD,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/generator/config.ts"],"sourcesContent":["export interface ClientConfig {\n name: string;\n spec: string;\n output: string;\n stripPathPrefix?: string;\n schemaPrefix?: string;\n}\n\nexport interface OrcConfig {\n clients: ClientConfig[];\n runtimePackage?: string;\n}\n\nexport function defineConfig(config: OrcConfig): OrcConfig {\n return config;\n}\n"],"mappings":";AAaO,SAAS,aAAa,QAA8B;AACzD,SAAO;AACT;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moinax/orc",
3
- "version": "0.1.3",
3
+ "version": "0.2.0",
4
4
  "description": "OpenAPI Rest Client generator - generates typed TypeScript API clients with Zod validation from OpenAPI specs",
5
5
  "type": "module",
6
6
  "exports": {
@@ -33,8 +33,7 @@
33
33
  "commander": "^13.1.0",
34
34
  "date-fns": "^4.1.0",
35
35
  "jiti": "^2.4.2",
36
- "pluralize": "^8.0.0",
37
- "prettier": "^3.5.3"
36
+ "pluralize": "^8.0.0"
38
37
  },
39
38
  "peerDependencies": {
40
39
  "zod": "^3.23.0"
@@ -42,6 +41,7 @@
42
41
  "devDependencies": {
43
42
  "@types/node": "^22.13.0",
44
43
  "@types/pluralize": "^0.0.33",
44
+ "prettier": "^3.5.3",
45
45
  "tsup": "^8.4.0",
46
46
  "typescript": "^5.7.3",
47
47
  "vitest": "^3.0.0",