@cushin/api-codegen 2.0.2 → 2.0.4

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/dist/cli.js CHANGED
@@ -952,6 +952,34 @@ ${this.generatePrefetchFunctions()}
952
952
  }
953
953
  };
954
954
 
955
+ // src/generators/generate-index.ts
956
+ import fs9 from "fs/promises";
957
+ import path10 from "path";
958
+ var IndexGenerator = class extends BaseGenerator {
959
+ async generate() {
960
+ const content = this.generateContent();
961
+ const outputPath = path10.join(this.context.config.outputDir, "index.ts");
962
+ await fs9.mkdir(path10.dirname(outputPath), { recursive: true });
963
+ await fs9.writeFile(outputPath, content, "utf-8");
964
+ }
965
+ generateContent() {
966
+ const outputPath = path10.join(this.context.config.outputDir, "types.ts");
967
+ const endpointsPath = path10.join(this.context.config.endpointsPath);
968
+ const relativePath = path10.relative(path10.dirname(outputPath), endpointsPath).replace(/\\/g, "/");
969
+ const content = `// Auto-generated exports
970
+ export * from './types';
971
+ export * from './client';
972
+ export * from './query-keys';
973
+ ${this.hasQueryOptions() ? "export * from './query-options';" : ""}
974
+ export * from './hooks';
975
+ export * from './prefetchs';
976
+ export { z } from 'zod';
977
+ export { apiConfig } from '${relativePath}';
978
+ `;
979
+ return content;
980
+ }
981
+ };
982
+
955
983
  // src/generators/index.ts
956
984
  var CodeGenerator = class {
957
985
  constructor(context2) {
@@ -966,6 +994,7 @@ var CodeGenerator = class {
966
994
  getGenerators() {
967
995
  const generators = [];
968
996
  generators.push(new TypesGenerator(this.context));
997
+ generators.push(new IndexGenerator(this.context));
969
998
  if (this.context.config.generateClient) {
970
999
  generators.push(new ClientGenerator(this.context));
971
1000
  }
@@ -1024,14 +1053,14 @@ var CodegenCore = class {
1024
1053
  };
1025
1054
 
1026
1055
  // src/cli.ts
1027
- import path10 from "path";
1056
+ import path11 from "path";
1028
1057
  var program = new Command();
1029
1058
  setupCLIProgram(program);
1030
1059
  var context = {
1031
1060
  loadConfig,
1032
1061
  validateConfig,
1033
1062
  CodegenCore,
1034
- pathToFileURL: (filePath) => new URL(`file://${path10.resolve(filePath)}`)
1063
+ pathToFileURL: (filePath) => new URL(`file://${path11.resolve(filePath)}`)
1035
1064
  };
1036
1065
  setupGenerateCommand(program, context);
1037
1066
  setupInitCommand(program);
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli.ts","../src/config/index.ts","../src/core/codegen.ts","../src/generators/hooks.ts","../src/generators/base.ts","../src/generators/actions.ts","../src/generators/queries.ts","../src/generators/types.ts","../src/generators/client.ts","../src/generators/query-keys.ts","../src/generators/query-options.ts","../src/generators/prefetch.ts","../src/generators/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { Command } from 'commander';\nimport { setupCLIProgram, setupGenerateCommand, setupInitCommand, setupValidateCommand } from '@cushin/codegen-cli';\nimport { loadConfig, validateConfig } from './config/index.js';\nimport { CodegenCore } from './core/codegen.js';\nimport path from 'path';\n\nconst program = new Command();\n\n// Setup base program\nsetupCLIProgram(program);\n\n// Setup commands with context\nconst context = {\n loadConfig,\n validateConfig,\n CodegenCore,\n pathToFileURL: (filePath: string) => new URL(`file://${path.resolve(filePath)}`),\n};\n\nsetupGenerateCommand(program, context);\nsetupInitCommand(program);\nsetupValidateCommand(program, context);\n\nprogram.parse();\n","import { cosmiconfig } from \"cosmiconfig\";\nimport path from \"path\";\nimport type { APIConfig } from \"@cushin/api-runtime\";\n\nexport interface UserConfig {\n /**\n * Base URL for API requests\n */\n baseUrl?: string;\n\n /**\n * Path to the endpoints configuration file\n */\n endpoints: string;\n\n /**\n * Provider type: 'vite' | 'nextjs'\n */\n provider: \"vite\" | \"nextjs\";\n\n /**\n * Output directory for generated files\n */\n output: string;\n\n /**\n * Whether to generate React Query hooks (for client-side)\n * @default true for vite, nextjs\n */\n generateHooks?: boolean;\n\n /**\n * Whether to generate server actions (Next.js only)\n * @default true for nextjs, false for vite\n */\n generateServerActions?: boolean;\n\n /**\n * Whether to generate server queries (Next.js only)\n * @default true for nextjs, false for vite\n */\n generateServerQueries?: boolean;\n\n /**\n * Whether to generate API client\n * @default true\n */\n generateClient?: boolean;\n\n /**\n * Whether to generate prefetch utilities\n * @default true\n */\n generatePrefetch?: boolean;\n\n /**\n * Custom templates directory\n */\n templatesDir?: string;\n\n /**\n * Additional options\n */\n options?: {\n /**\n * Use 'use client' directive\n */\n useClientDirective?: boolean;\n\n /**\n * Custom imports to add to generated files\n */\n customImports?: Record<string, string[]>;\n\n /**\n * Prefix for generated hook names\n */\n hookPrefix?: string;\n\n /**\n * Suffix for generated action names\n */\n actionSuffix?: string;\n };\n}\n\nexport interface ResolvedConfig extends UserConfig {\n rootDir: string;\n endpointsPath: string;\n outputDir: string;\n apiConfig?: APIConfig;\n}\n\nconst explorer = cosmiconfig(\"api-codegen\", {\n searchPlaces: [\n \"api-codegen.config.js\",\n \"api-codegen.config.mjs\",\n \"api-codegen.config.ts\",\n \"api-codegen.config.json\",\n \".api-codegenrc\",\n \".api-codegenrc.json\",\n \".api-codegenrc.js\",\n ],\n});\n\nexport async function loadConfig(\n configPath?: string,\n): Promise<ResolvedConfig | null> {\n try {\n const result = configPath\n ? await explorer.load(configPath)\n : await explorer.search();\n\n if (!result || !result.config) {\n return null;\n }\n\n const userConfig = result.config as UserConfig;\n const rootDir = path.dirname(result.filepath);\n\n // Resolve paths\n const endpointsPath = path.resolve(rootDir, userConfig.endpoints);\n const outputDir = path.resolve(rootDir, userConfig.output);\n\n // Set defaults based on provider\n const generateHooks = userConfig.generateHooks ?? true;\n const generateServerActions =\n userConfig.generateServerActions ?? userConfig.provider === \"nextjs\";\n const generateServerQueries =\n userConfig.generateServerQueries ?? userConfig.provider === \"nextjs\";\n const generateClient = userConfig.generateClient ?? true;\n const generatePrefetch = userConfig.generatePrefetch ?? true;\n\n return {\n ...userConfig,\n rootDir,\n endpointsPath,\n outputDir,\n generateHooks,\n generateServerActions,\n generateServerQueries,\n generateClient,\n generatePrefetch,\n };\n } catch (error) {\n throw new Error(\n `Failed to load config: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n}\n\n/**\n * Validate user config\n */\nexport function validateConfig(config: UserConfig): void {\n if (!config.endpoints) {\n throw new Error('Config error: \"endpoints\" path is required');\n }\n\n if (!config.provider) {\n throw new Error(\n 'Config error: \"provider\" must be specified (vite or nextjs)',\n );\n }\n\n if (![\"vite\", \"nextjs\"].includes(config.provider)) {\n throw new Error(\n 'Config error: \"provider\" must be either \"vite\" or \"nextjs\"',\n );\n }\n\n if (!config.output) {\n throw new Error('Config error: \"output\" directory is required');\n }\n}\n","import { createJiti } from \"jiti\";\nimport type { APIConfig } from \"@cushin/api-runtime\";\nimport type { ResolvedConfig } from \"../config/index.js\";\nimport { CodeGenerator } from \"../generators/index.js\";\nimport { fileURLToPath } from \"url\";\n\nexport class CodegenCore {\n constructor(private config: ResolvedConfig) {}\n\n async execute(): Promise<void> {\n // Load API configuration\n const apiConfig = await this.loadAPIConfig();\n\n // Store in config for generators\n this.config.apiConfig = apiConfig;\n\n // Generate code\n const generator = new CodeGenerator({\n config: this.config,\n apiConfig,\n });\n\n await generator.generate();\n }\n\n private async loadAPIConfig(): Promise<APIConfig> {\n try {\n // Use jiti to load TypeScript files\n const jiti = createJiti(fileURLToPath(import.meta.url), {\n interopDefault: true,\n });\n\n const module = (await jiti.import(this.config.endpointsPath)) as any;\n\n // Try different export patterns\n const apiConfig =\n module.apiConfig ||\n module.default?.apiConfig ||\n module.default ||\n module;\n\n if (!apiConfig || !apiConfig.endpoints) {\n throw new Error(\n 'Invalid API config: must export an object with \"endpoints\" property',\n );\n }\n\n return apiConfig;\n } catch (error) {\n throw new Error(\n `Failed to load endpoints from \"${this.config.endpointsPath}\": ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n }\n }\n}\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport { BaseGenerator } from \"./base.js\";\nimport type { APIEndpoint } from \"@cushin/api-runtime\";\n\nexport class HooksGenerator extends BaseGenerator {\n async generate(): Promise<void> {\n const content = this.generateContent();\n const outputPath = path.join(this.context.config.outputDir, \"hooks.ts\");\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, \"utf-8\");\n }\n\n private generateContent(): string {\n const useClientDirective =\n this.context.config.options?.useClientDirective ?? true;\n const outputPath = path.join(this.context.config.outputDir, \"types.ts\");\n const endpointsPath = path.join(this.context.config.endpointsPath);\n const relativePath = path\n .relative(path.dirname(outputPath), endpointsPath)\n .replace(/\\\\/g, \"/\");\n\n const content = `${useClientDirective ? \"'use client';\\n\" : \"\"}\nimport { useQuery, useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport { apiClient } from \"./client\";\nimport { queryKeys } from \"./query-keys\";\nimport { apiQueryOptions } from \"./query-options\";\nimport { z } from \"zod\";\nimport { apiConfig } from \"${relativePath}\";\n\n${this.generateQueryHooks()}\n${this.generateMutationHooks()}\n`;\n\n return content;\n }\n\n private generateQueryHooks(): string {\n const hooks: string[] = [];\n Object.entries(this.context.apiConfig.endpoints).forEach(\n ([name, endpoint]) => {\n if (endpoint.method === \"GET\")\n hooks.push(this.generateQueryHook(name, endpoint));\n },\n );\n return hooks.join(\"\\n\\n\");\n }\n\n private generateQueryHook(name: string, endpoint: APIEndpoint): string {\n const hookName = `use${this.capitalize(name)}`;\n const resource = this.getResourceFromEndpoint(name, endpoint);\n const optionName = this.getEndpointKeyName(name);\n const inferParams = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.params`,\n );\n const inferQuery = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.query`,\n );\n const inferResponse = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.response`,\n );\n\n const params: string[] = [];\n const optionParams: string[] = [];\n\n const queryTags = this.getQueryTags(endpoint);\n\n if (endpoint.params) {\n params.push(`params: ${inferParams}`);\n optionParams.push(\"params\");\n }\n if (endpoint.query) {\n params.push(`filters?: ${inferQuery}`);\n optionParams.push(\"filters\");\n }\n\n params.push(`options?: {\n enabled?: boolean;\n select?: <TData = ${inferResponse}>(data: ${inferResponse}) => TData;\n }`);\n\n return `/**\n * ${endpoint.description || `Query hook for ${name}`}\n * @tags ${queryTags.join(\", \") || \"none\"}\n */\nexport function ${hookName}(${params.join(\",\\n \")}) {\n return useQuery({\n ...apiQueryOptions.${resource}.${optionName}(${optionParams.join(\", \")}),\n ...options,\n });\n}`;\n }\n\n private generateMutationHooks(): string {\n const hooks: string[] = [];\n Object.entries(this.context.apiConfig.endpoints).forEach(\n ([name, endpoint]) => {\n if (endpoint.method !== \"GET\")\n hooks.push(this.generateMutationHook(name, endpoint));\n },\n );\n return hooks.join(\"\\n\\n\");\n }\n\n private generateMutationHook(name: string, endpoint: APIEndpoint): string {\n const hookName = `use${this.capitalize(name)}`;\n const resource = this.getResourceFromEndpoint(name, endpoint);\n const inferParams = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.params`,\n );\n const inferBody = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.body`,\n );\n const inferResponse = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.response`,\n );\n\n const resourceHasQueries = this.resourceHasQueryEndpoints(resource);\n\n let inputType: string;\n let fnBody: string;\n\n if (endpoint.params && endpoint.body) {\n inputType = `{ params: ${inferParams}; body: ${inferBody}; }`;\n fnBody = `({ params, body }: ${inputType}) => apiClient.${name}(params, body)`;\n } else if (endpoint.params) {\n inputType = `${inferParams}`;\n fnBody = `(params: ${inputType}) => apiClient.${name}(params)`;\n } else if (endpoint.body) {\n inputType = `${inferBody}`;\n fnBody = `(body: ${inputType}) => apiClient.${name}(body)`;\n } else {\n inputType = \"void\";\n fnBody = `() => apiClient.${name}()`;\n }\n\n const invalidate = resourceHasQueries\n ? `queryClient.invalidateQueries({ queryKey: queryKeys.${resource}.all });`\n : \"\";\n\n return `/**\n * ${endpoint.description || `Mutation hook for ${name}`}\n * @tags ${endpoint.tags?.join(\", \") || \"none\"}\n */\n export function ${hookName}(options?: {\n onSuccess?: (data: ${inferResponse}, variables: ${inputType}, context: unknown) => void;\n onError?: (error: Error, variables: ${inputType}, context: unknown) => void;\n onSettled?: (data: ${inferResponse} | undefined, error: Error | null, variables: ${inputType}, context: unknown) => void;\n onMutate?: (variables: ${inputType}) => Promise<unknown> | unknown;\n }) {\n ${invalidate ? \"const queryClient = useQueryClient();\" : \"\"}\n return useMutation({\n\tmutationFn: ${fnBody},\n\tonSuccess: (data, variables, context) => {\n\t ${invalidate}\n\t options?.onSuccess?.(data, variables, context);\n\t},\n\tonError: options?.onError,\n\tonSettled: options?.onSettled,\n\tonMutate: options?.onMutate,\n });\n }`;\n }\n}\n","import type { APIConfig, APIEndpoint } from \"@cushin/api-runtime\";\nimport type { ResolvedConfig } from \"../config/index.js\";\n\nexport interface GeneratorContext {\n config: ResolvedConfig;\n apiConfig: APIConfig;\n}\n\nexport abstract class BaseGenerator {\n constructor(protected context: GeneratorContext) {}\n\n abstract generate(): Promise<void>;\n\n protected isQueryEndpoint(endpoint: APIEndpoint): boolean {\n return endpoint.method === \"GET\";\n }\n\n protected isMutationEndpoint(endpoint: APIEndpoint): boolean {\n return !this.isQueryEndpoint(endpoint);\n }\n\n protected capitalize(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1);\n }\n\n protected getQueryTags(endpoint: APIEndpoint): string[] {\n return endpoint.tags || [];\n }\n\n protected getInvalidationTags(endpoint: APIEndpoint): string[] {\n const tags = endpoint.tags || [];\n return tags.filter((tag) => tag !== \"query\" && tag !== \"mutation\");\n }\n\n protected hasParams(endpoint: APIEndpoint): boolean {\n return !!endpoint.params;\n }\n\n protected hasQuery(endpoint: APIEndpoint): boolean {\n return !!endpoint.query;\n }\n\n protected hasBody(endpoint: APIEndpoint): boolean {\n return !!endpoint.body;\n }\n\n protected getEndpointSignature(\n name: string,\n endpoint: APIEndpoint,\n ): {\n hasParams: boolean;\n hasQuery: boolean;\n hasBody: boolean;\n paramType: string;\n queryType: string;\n bodyType: string;\n responseType: string;\n } {\n const hasParams = this.hasParams(endpoint);\n const hasQuery = this.hasQuery(endpoint);\n const hasBody = this.hasBody(endpoint);\n\n return {\n hasParams,\n hasQuery,\n hasBody,\n paramType: hasParams ? `ExtractParams<APIEndpoints['${name}']>` : \"never\",\n queryType: hasQuery ? `ExtractQuery<APIEndpoints['${name}']>` : \"never\",\n bodyType: hasBody ? `ExtractBody<APIEndpoints['${name}']>` : \"never\",\n responseType: `ExtractResponse<APIEndpoints['${name}']>`,\n };\n }\n\n protected generateMutationCall(\n name: string,\n hasParams: boolean,\n hasBody: boolean,\n ): string {\n if (hasParams && hasBody) {\n return `return apiClient.${name}(input.params, input.body);`;\n } else if (hasParams) {\n return `return apiClient.${name}(input);`;\n } else if (hasBody) {\n return `return apiClient.${name}(input);`;\n } else {\n return `return apiClient.${name}();`;\n }\n }\n\n protected inferNonNull(expr: string): string {\n return `z.infer<NonNullable<${expr}>>`;\n }\n\n protected toCamelCase(str: string): string {\n return str\n .toLowerCase()\n .replace(/[-_\\s]+(.)?/g, (_, c) => (c ? c.toUpperCase() : \"\"))\n .replace(/^./, (c) => c.toLowerCase());\n }\n\n protected getResourceFromEndpoint(\n _name: string,\n endpoint: APIEndpoint,\n ): string {\n const tag = endpoint.tags?.find((t) => t !== \"query\" && t !== \"mutation\");\n if (tag) return this.toCamelCase(tag);\n const match = endpoint.path.match(/^\\/([^/]+)/);\n return match ? this.toCamelCase(match[1]) : \"general\";\n }\n\n protected groupEndpointsByResource() {\n const groups: Record<\n string,\n Array<{ name: string; endpoint: APIEndpoint }>\n > = {};\n Object.entries(this.context.apiConfig.endpoints).forEach(\n ([name, endpoint]) => {\n const res = this.getResourceFromEndpoint(name, endpoint);\n if (!groups[res]) groups[res] = [];\n groups[res].push({ name, endpoint });\n },\n );\n return groups;\n }\n\n protected resourceHasQueryEndpoints(resource: string): boolean {\n return (\n this.groupEndpointsByResource()[resource]?.some(\n ({ endpoint }) => endpoint.method === \"GET\",\n ) ?? false\n );\n }\n\n protected getEndpointKeyName(name: string): string {\n return name.startsWith(\"get\")\n ? name[3].toLowerCase() + name.slice(4)\n : name;\n }\n\n protected generateQueryKeyCall(\n resource: string,\n name: string,\n endpoint: APIEndpoint,\n ): string {\n const key = this.getEndpointKeyName(name);\n const args: string[] = [];\n if (endpoint.params) args.push(\"params\");\n if (endpoint.query) args.push(\"filters\");\n return args.length\n ? `queryKeys.${resource}.${key}(${args.join(\", \")})`\n : `queryKeys.${resource}.${key}()`;\n }\n\n protected hasQueryOptions() {\n return Object.values(this.context.apiConfig.endpoints).some(\n (e) => e.method === \"GET\",\n );\n }\n}\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport { BaseGenerator } from \"./base.js\";\nimport type { APIEndpoint } from \"@cushin/api-runtime\";\n\nexport class ServerActionsGenerator extends BaseGenerator {\n async generate(): Promise<void> {\n const content = this.generateContent();\n const outputPath = path.join(this.context.config.outputDir, 'actions.ts');\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, 'utf-8');\n }\n\n private generateContent(): string {\n const imports = `'use server';\n\nimport { revalidateTag, revalidatePath } from 'next/cache';\nimport { serverClient } from './server-client';\nimport type { \n APIEndpoints, \n ExtractBody, \n ExtractParams, \n ExtractResponse \n} from './types';\n\nexport type ActionResult<T> = \n | { success: true; data: T }\n | { success: false; error: string };\n`;\n\n const actions: string[] = [];\n\n Object.entries(this.context.apiConfig.endpoints).forEach(([name, endpoint]) => {\n if (this.isMutationEndpoint(endpoint)) {\n actions.push(this.generateServerAction(name, endpoint));\n }\n });\n\n return imports + '\\n' + actions.join('\\n\\n');\n }\n\n private generateServerAction(name: string, endpoint: APIEndpoint): string {\n const actionSuffix = this.context.config.options?.actionSuffix || 'Action';\n const actionName = `${name}${actionSuffix}`;\n const signature = this.getEndpointSignature(name, endpoint);\n const invalidationTags = this.getInvalidationTags(endpoint);\n\n let inputType = '';\n let inputParam = '';\n if (signature.hasParams && signature.hasBody) {\n inputType = `input: { params: ${signature.paramType}; body: ${signature.bodyType} }`;\n inputParam = 'input';\n } else if (signature.hasParams) {\n inputType = `params: ${signature.paramType}`;\n inputParam = 'params';\n } else if (signature.hasBody) {\n inputType = `body: ${signature.bodyType}`;\n inputParam = 'body';\n }\n\n const revalidateStatements = invalidationTags.length > 0\n ? invalidationTags\n .map((tag) => ` revalidateTag('${tag}');`)\n .join('\\n')\n : ' // No automatic revalidations';\n\n return `/**\n * ${endpoint.description || `Server action for ${name}`}\n * @tags ${endpoint.tags?.join(', ') || 'none'}\n */\nexport async function ${actionName}(\n ${inputType}\n): Promise<ActionResult<${signature.responseType}>> {\n try {\n const result = await serverClient.${name}(${inputParam ? inputParam : ''});\n \n // Revalidate related data\n${revalidateStatements}\n \n return { success: true, data: result };\n } catch (error) {\n console.error('[Server Action Error]:', error);\n return { \n success: false, \n error: error instanceof Error ? error.message : 'Unknown error' \n };\n }\n}`;\n }\n}\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport { BaseGenerator } from \"./base.js\";\nimport type { APIEndpoint } from \"@cushin/api-runtime\";\n\nexport class ServerQueriesGenerator extends BaseGenerator {\n async generate(): Promise<void> {\n const content = this.generateContent();\n const outputPath = path.join(this.context.config.outputDir, \"queries.ts\");\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, \"utf-8\");\n }\n\n private generateContent(): string {\n const imports = `import { cache } from 'react';\nimport { unstable_cache } from 'next/cache';\nimport { serverClient } from './server-client';\nimport type { \n APIEndpoints, \n ExtractParams, \n ExtractQuery, \n ExtractResponse \n} from './types';\n`;\n\n const queries: string[] = [];\n\n Object.entries(this.context.apiConfig.endpoints).forEach(\n ([name, endpoint]) => {\n if (this.isQueryEndpoint(endpoint)) {\n queries.push(this.generateServerQuery(name, endpoint));\n }\n },\n );\n\n return imports + \"\\n\" + queries.join(\"\\n\\n\");\n }\n\n private generateServerQuery(name: string, endpoint: APIEndpoint): string {\n const queryName = `${name}Query`;\n const signature = this.getEndpointSignature(name, endpoint);\n const queryTags = this.getQueryTags(endpoint);\n\n const paramDef = signature.hasParams\n ? `params: ${signature.paramType}`\n : \"\";\n const queryDef = signature.hasQuery ? `query?: ${signature.queryType}` : \"\";\n const paramsList = [paramDef, queryDef].filter(Boolean).join(\",\\n \");\n\n const clientCallArgs: string[] = [];\n if (signature.hasParams) clientCallArgs.push(\"params\");\n if (signature.hasQuery) clientCallArgs.push(\"query\");\n\n // Generate cache key based on params\n const cacheKeyParts: string[] = [`'${name}'`];\n if (signature.hasParams) cacheKeyParts.push(\"JSON.stringify(params)\");\n if (signature.hasQuery) cacheKeyParts.push(\"JSON.stringify(query)\");\n\n return `/**\n * ${endpoint.description || `Server query for ${name}`}\n * @tags ${queryTags.join(\", \") || \"none\"}\n */\nexport const ${queryName} = cache(async (\n ${paramsList}\n): Promise<${signature.responseType}> => {\n return unstable_cache(\n async () => serverClient.${name}(${clientCallArgs.join(\", \")}),\n [${cacheKeyParts.join(\", \")}],\n {\n tags: [${queryTags.map((tag) => `'${tag}'`).join(\", \")}],\n revalidate: 3600, // 1 hour default, can be overridden\n }\n )();\n});`;\n }\n}\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport { BaseGenerator } from \"./base.js\";\n\nexport class TypesGenerator extends BaseGenerator {\n async generate(): Promise<void> {\n const content = this.generateContent();\n const outputPath = path.join(this.context.config.outputDir, \"types.ts\");\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, \"utf-8\");\n }\n\n private generateContent(): string {\n const outputPath = path.join(this.context.config.outputDir, \"types.ts\");\n const endpointsPath = path.join(this.context.config.endpointsPath);\n const relativePath = path\n .relative(path.dirname(outputPath), endpointsPath)\n .replace(/\\\\/g, \"/\");\n return `// Auto-generated type definitions\n// Do not edit this file manually\n\nimport type { z } from 'zod';\nimport { apiConfig } from '${relativePath}';\n\n\n// Re-export endpoint configuration types\nexport type { APIConfig, APIEndpoint, HTTPMethod } from '@cushin/api-runtime';\n\n/**\n * Type helper to extract params schema from an endpoint\n */\nexport type ExtractParams<T> = T extends { params: infer P extends z.ZodType }\n ? z.infer<P>\n : never;\n\n/**\n * Type helper to extract query schema from an endpoint\n */\nexport type ExtractQuery<T> = T extends { query: infer Q extends z.ZodType }\n ? z.infer<Q>\n : never;\n\n/**\n * Type helper to extract body schema from an endpoint\n */\nexport type ExtractBody<T> = T extends { body: infer B extends z.ZodType }\n ? z.infer<B>\n : never;\n\n/**\n * Type helper to extract response schema from an endpoint\n */\nexport type ExtractResponse<T> = T extends { response: infer R extends z.ZodType }\n ? z.infer<R>\n : never;\n\n/**\n * Import your API config to get typed endpoints\n * \n */\nexport type APIEndpoints = typeof apiConfig.endpoints;\n\n${this.generateEndpointTypes()}\n`;\n }\n\n private generateEndpointTypes(): string {\n const types: string[] = [];\n\n Object.entries(this.context.apiConfig.endpoints).forEach(\n ([name, endpoint]) => {\n const cap = this.capitalize(name);\n if (endpoint.response)\n types.push(\n `export type ${cap}Response = ${this.inferNonNull(`typeof apiConfig.endpoints.${name}.response`)};`,\n );\n if (endpoint.body)\n types.push(\n `export type ${cap}Input = ${this.inferNonNull(`typeof apiConfig.endpoints.${name}.body`)};`,\n );\n if (endpoint.query)\n types.push(\n `export type ${cap}Query = ${this.inferNonNull(`typeof apiConfig.endpoints.${name}.query`)};`,\n );\n if (endpoint.params)\n types.push(\n `export type ${cap}Params = ${this.inferNonNull(`typeof apiConfig.endpoints.${name}.params`)};`,\n );\n },\n );\n\n return types.join(\"\\n\");\n }\n}\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport { BaseGenerator } from \"./base.js\";\n\nexport class ClientGenerator extends BaseGenerator {\n async generate(): Promise<void> {\n await this.generateClientFile();\n\n if (this.context.config.provider === \"nextjs\") {\n await this.generateServerClientFile();\n }\n }\n\n private async generateClientFile(): Promise<void> {\n const content = this.generateClientContent();\n const outputPath = path.join(this.context.config.outputDir, \"client.ts\");\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, \"utf-8\");\n }\n\n private async generateServerClientFile(): Promise<void> {\n const content = this.generateServerClientContent();\n const outputPath = path.join(\n this.context.config.outputDir,\n \"server-client.ts\",\n );\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, \"utf-8\");\n }\n\n private generateClientContent(): string {\n const useClientDirective =\n this.context.config.options?.useClientDirective ?? true;\n const outputPath = path.join(this.context.config.outputDir, \"types.ts\");\n const endpointsPath = path.join(this.context.config.endpointsPath);\n const relativePath = path\n .relative(path.dirname(outputPath), endpointsPath)\n .replace(/\\\\/g, \"/\");\n\n return `${useClientDirective ? \"'use client';\\n\" : \"\"}\nimport { createAPIClient } from '@cushin/api-runtime';\nimport type { AuthCallbacks } from '@cushin/api-runtime';\nimport { apiConfig } from '${relativePath}';\nimport { z } from 'zod';\n\n// Type the methods based on endpoints\ntype APIClientMethods = {\n [K in keyof typeof apiConfig.endpoints]: (typeof apiConfig.endpoints)[K] extends {\n method: infer M;\n params?: infer P;\n query?: infer Q;\n body?: infer B;\n response: infer R;\n }\n ? M extends \"GET\"\n ? P extends z.ZodJSONSchema\n ? Q extends z.ZodJSONSchema\n ? (params: z.infer<P>, query?: z.infer<Q>) => Promise<z.infer<R>>\n : (params: z.infer<P>) => Promise<z.infer<R>>\n : Q extends z.ZodJSONSchema\n ? (query?: z.infer<Q>) => Promise<z.infer<R>>\n : () => Promise<z.infer<R>>\n : P extends z.ZodJSONSchema\n ? B extends z.ZodJSONSchema\n ? (params: z.infer<P>, body: z.infer<B>) => Promise<z.infer<R>>\n : (params: z.infer<P>) => Promise<z.infer<R>>\n : B extends z.ZodJSONSchema\n ? (body: z.infer<B>) => Promise<z.infer<R>>\n : () => Promise<z.infer<R>>\n : never;\n};\n\n\n// Export singleton instance (will be initialized later)\nexport let baseClient: APIClientMethods & {\n refreshAuth: () => Promise<void>;\n updateAuthCallbacks: (callbacks: AuthCallbacks) => void;\n};\n\nexport const apiClient = {\n${this.generateApiClientMethods()}\n};\n\n/**\n * Initialize API client with auth callbacks\n * Call this function in your auth provider setup\n * \n * @example\n * const authCallbacks = {\n * getTokens: () => getStoredTokens(),\n * onAuthError: () => router.push('/login'),\n * onRefreshToken: async () => {\n * await refreshAccessToken();\n * },\n * };\n * \n * initializeAPIClient(authCallbacks);\n */\nexport const initializeAPIClient = (authCallbacks: AuthCallbacks) => {\n baseClient = createAPIClient(apiConfig, authCallbacks) as any;\n return baseClient;\n};\n\n// Export for custom usage\nexport { createAPIClient };\nexport type { AuthCallbacks };\n`;\n }\n\n private generateServerClientContent(): string {\n return `import { createAPIClient } from './core';\nimport { apiConfig } from '../config/endpoints';\nimport type { APIEndpoints } from './types';\n\n// Type-safe API client methods for server-side\ntype APIClientMethods = {\n [K in keyof APIEndpoints]: APIEndpoints[K] extends {\n method: infer M;\n params?: infer P;\n query?: infer Q;\n body?: infer B;\n response: infer R;\n }\n ? M extends 'GET'\n ? P extends { _type: any }\n ? Q extends { _type: any }\n ? (params: P['_type'], query?: Q['_type']) => Promise<R['_type']>\n : (params: P['_type']) => Promise<R['_type']>\n : Q extends { _type: any }\n ? (query?: Q['_type']) => Promise<R['_type']>\n : () => Promise<R['_type']>\n : P extends { _type: any }\n ? B extends { _type: any }\n ? (params: P['_type'], body: B['_type']) => Promise<R['_type']>\n : (params: P['_type']) => Promise<R['_type']>\n : B extends { _type: any }\n ? (body: B['_type']) => Promise<R['_type']>\n : () => Promise<R['_type']>\n : never;\n};\n\n/**\n * Server-side API client (no auth, direct API calls)\n * Use this in Server Components, Server Actions, and Route Handlers\n */\nexport const serverClient = createAPIClient(apiConfig) as APIClientMethods;\n`;\n }\n\n private generateApiClientMethods(): string {\n const methods: string[] = [];\n\n Object.entries(this.context.apiConfig.endpoints).forEach(\n ([name, endpoint]) => {\n const inferParams = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.params`,\n );\n const inferQuery = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.query`,\n );\n const inferBody = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.body`,\n );\n const inferResponse = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.response`,\n );\n\n if (endpoint.method === \"GET\") {\n if (endpoint.params && endpoint.query) {\n methods.push(` ${name}: (params: ${inferParams}, query?: ${inferQuery}): Promise<${inferResponse}> => \n (baseClient as any).${name}(params, query),`);\n } else if (endpoint.params) {\n methods.push(` ${name}: (params: ${inferParams}): Promise<${inferResponse}> => \n (baseClient as any).${name}(params),`);\n } else if (endpoint.query) {\n methods.push(` ${name}: (query?: ${inferQuery}): Promise<${inferResponse}> => \n (baseClient as any).${name}(query),`);\n } else {\n methods.push(` ${name}: (): Promise<${inferResponse}> => \n (baseClient as any).${name}(),`);\n }\n } else {\n if (endpoint.params && endpoint.body) {\n methods.push(` ${name}: (params: ${inferParams}, body: ${inferBody}): Promise<${inferResponse}> => \n (baseClient as any).${name}(params, body),`);\n } else if (endpoint.params) {\n methods.push(` ${name}: (params: ${inferParams}): Promise<${inferResponse}> => \n (baseClient as any).${name}(params),`);\n } else if (endpoint.body) {\n methods.push(` ${name}: (body: ${inferBody}): Promise<${inferResponse}> => \n (baseClient as any).${name}(body),`);\n } else {\n methods.push(` ${name}: (): Promise<${inferResponse}> => \n (baseClient as any).${name}(),`);\n }\n }\n },\n );\n\n return methods.join(\"\\n\");\n }\n}\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport { BaseGenerator } from \"./base.js\";\n\nexport class QueryKeysGenerator extends BaseGenerator {\n async generate(): Promise<void> {\n const content = this.generateContent();\n const outputPath = path.join(\n this.context.config.outputDir,\n \"query-keys.ts\",\n );\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, \"utf-8\");\n }\n\n private generateContent(): string {\n const outputPath = path.join(this.context.config.outputDir, \"types.ts\");\n const endpointsPath = path.join(this.context.config.endpointsPath);\n const relativePath = path\n .relative(path.dirname(outputPath), endpointsPath)\n .replace(/\\\\/g, \"/\");\n const content = `// Auto-generated query keys\nimport { z } from 'zod';\nimport { apiConfig } from '${relativePath}';\n\nexport const queryKeys = {\n${this.generateQueryKeysContent()}\n} as const;\n`;\n return content;\n }\n\n private generateQueryKeysContent(): string {\n const resourceGroups = this.groupEndpointsByResource();\n const keys: string[] = [];\n\n Object.entries(resourceGroups).forEach(([resource, endpoints]) => {\n const queryEndpoints = endpoints.filter(\n ({ endpoint }) => endpoint.method === \"GET\",\n );\n if (queryEndpoints.length === 0) return;\n\n const resourceKeys: string[] = [` all: ['${resource}'] as const,`];\n const added = new Set<string>();\n\n queryEndpoints.forEach(({ name, endpoint }) => {\n const keyName = this.getEndpointKeyName(name);\n if (added.has(keyName)) return;\n const inferParams = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.params`,\n );\n const inferQuery = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.query`,\n );\n\n if (endpoint.params || endpoint.query) {\n const params: string[] = [];\n if (endpoint.params) params.push(`params?: ${inferParams}`);\n if (endpoint.query) params.push(`query?: ${inferQuery}`);\n\n resourceKeys.push(` ${keyName}: (${params.join(\", \")}) =>\n ['${resource}', '${keyName}', ${endpoint.params ? \"params\" : \"undefined\"}, ${endpoint.query ? \"query\" : \"undefined\"}] as const,`);\n } else {\n resourceKeys.push(\n ` ${keyName}: () => ['${resource}', '${keyName}'] as const,`,\n );\n }\n added.add(keyName);\n });\n\n keys.push(` ${resource}: {\\n${resourceKeys.join(\"\\n\")}\\n },`);\n });\n\n return keys.join(\"\\n\");\n }\n}\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport { BaseGenerator } from \"./base.js\";\n\nexport class QueryOptionsGenerator extends BaseGenerator {\n async generate(): Promise<void> {\n const content = this.generateContent();\n const outputPath = path.join(\n this.context.config.outputDir,\n \"query-options.ts\",\n );\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, \"utf-8\");\n }\n private generateContent(): string {\n const outputPath = path.join(this.context.config.outputDir, \"types.ts\");\n const endpointsPath = path.join(this.context.config.endpointsPath);\n const relativePath = path\n .relative(path.dirname(outputPath), endpointsPath)\n .replace(/\\\\/g, \"/\");\n const content = `// Auto-generated query options\nimport { queryOptions } from '@tanstack/react-query';\nimport { apiClient } from './client';\nimport { queryKeys } from './query-keys';\nimport { z } from 'zod';\nimport { apiConfig } from '${relativePath}';\n\n${this.generateQueryOptionsContent()}\n\nexport const apiQueryOptions = {\n${this.generateQueryOptionsExports()}\n} as const;\n`;\n\n return content;\n }\n\n private generateQueryOptionsContent(): string {\n const groups = this.groupEndpointsByResource();\n const options: string[] = [];\n\n Object.entries(groups).forEach(([resource, endpoints]) => {\n const queries = endpoints.filter(\n ({ endpoint }) => endpoint.method === \"GET\",\n );\n if (queries.length === 0) return;\n\n const resourceOptions: string[] = [];\n queries.forEach(({ name, endpoint }) => {\n const optionName = this.getEndpointKeyName(name);\n const inferParams = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.params`,\n );\n const inferQuery = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.query`,\n );\n const inferResponse = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.response`,\n );\n\n const params: string[] = [];\n let apiCall = \"\";\n\n if (endpoint.params && endpoint.query) {\n params.push(`params: ${inferParams}`, `filters?: ${inferQuery}`);\n apiCall = `apiClient.${name}(params, filters)`;\n } else if (endpoint.params) {\n params.push(`params: ${inferParams}`);\n apiCall = `apiClient.${name}(params)`;\n } else if (endpoint.query) {\n params.push(`filters?: ${inferQuery}`);\n apiCall = `apiClient.${name}(filters)`;\n } else {\n apiCall = `apiClient.${name}()`;\n }\n\n const keyCall = this.generateQueryKeyCall(resource, name, endpoint);\n\n resourceOptions.push(` ${optionName}: (${params.join(\", \")}) =>\n queryOptions({\n queryKey: ${keyCall},\n queryFn: (): Promise<${inferResponse}> => ${apiCall},\n staleTime: 1000 * 60 * 5,\n }),`);\n });\n\n options.push(\n `const ${resource}QueryOptions = {\\n${resourceOptions.join(\"\\n\")}\\n};\\n`,\n );\n });\n\n return options.join(\"\\n\");\n }\n\n private generateQueryOptionsExports(): string {\n const groups = this.groupEndpointsByResource();\n const exports: string[] = [];\n\n Object.keys(groups).forEach((resource) => {\n const hasQueries = groups[resource].some(\n ({ endpoint }) => endpoint.method === \"GET\",\n );\n if (hasQueries) exports.push(` ${resource}: ${resource}QueryOptions,`);\n });\n\n return exports.join(\"\\n\");\n }\n}\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport { BaseGenerator } from \"./base.js\";\nimport type { APIEndpoint } from \"@cushin/api-runtime\";\n\nexport class PrefetchGenerator extends BaseGenerator {\n async generate(): Promise<void> {\n const content = this.generateContent();\n const outputPath = path.join(this.context.config.outputDir, \"prefetchs.ts\");\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, \"utf-8\");\n }\n\n private generateContent(): string {\n const content = `// Auto-generated prefetch utilities\nimport { type QueryClient } from '@tanstack/react-query';\n${this.hasQueryOptions() ? \"import { apiQueryOptions } from './query-options';\" : \"\"}\nimport { z } from 'zod';\nimport { apiConfig } from '../config/endpoints';\n\n${this.generatePrefetchFunctions()}\n`;\n return content;\n }\n\n private generatePrefetchFunctions(): string {\n const funcs: string[] = [];\n Object.entries(this.context.apiConfig.endpoints).forEach(\n ([name, endpoint]) => {\n if (endpoint.method === \"GET\")\n funcs.push(this.generatePrefetchFunction(name, endpoint));\n },\n );\n return funcs.join(\"\\n\\n\");\n }\n\n private generatePrefetchFunction(\n name: string,\n endpoint: APIEndpoint,\n ): string {\n const prefetchName = `prefetch${this.capitalize(name)}`;\n const resource = this.getResourceFromEndpoint(name, endpoint);\n const optionName = this.getEndpointKeyName(name);\n const inferParams = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.params`,\n );\n const inferQuery = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.query`,\n );\n\n const params: string[] = [\"queryClient: QueryClient\"];\n const optionParams: string[] = [];\n\n if (endpoint.params) {\n params.push(`params: ${inferParams}`);\n optionParams.push(\"params\");\n }\n if (endpoint.query) {\n params.push(`filters?: ${inferQuery}`);\n optionParams.push(\"filters\");\n }\n\n return `export const ${prefetchName} = async (${params.join(\",\\n \")}) => {\n return await queryClient.ensureQueryData(apiQueryOptions.${resource}.${optionName}(${optionParams.join(\", \")}));\n};`;\n }\n}\n","import { HooksGenerator } from \"./hooks.js\";\nimport { ServerActionsGenerator } from \"./actions.js\";\nimport { ServerQueriesGenerator } from \"./queries.js\";\nimport { TypesGenerator } from \"./types.js\";\nimport { ClientGenerator } from \"./client.js\";\nimport type { GeneratorContext } from \"./base.js\";\nimport { QueryKeysGenerator } from \"./query-keys.js\";\nimport { QueryOptionsGenerator } from \"./query-options.js\";\nimport { PrefetchGenerator } from \"./prefetch.js\";\n\nexport class CodeGenerator {\n constructor(private context: GeneratorContext) {}\n\n async generate(): Promise<void> {\n const generators = this.getGenerators();\n\n for (const generator of generators) {\n await generator.generate();\n }\n }\n\n private getGenerators() {\n const generators: Array<any> = [];\n\n // Always generate types\n generators.push(new TypesGenerator(this.context));\n\n // Generate client if enabled\n if (this.context.config.generateClient) {\n generators.push(new ClientGenerator(this.context));\n }\n\n // Generate hooks if enabled\n if (this.context.config.generateHooks) {\n generators.push(new QueryKeysGenerator(this.context));\n generators.push(new QueryOptionsGenerator(this.context));\n generators.push(new HooksGenerator(this.context));\n }\n\n if (this.context.config.generatePrefetch) {\n generators.push(new PrefetchGenerator(this.context));\n }\n\n // Generate server actions if enabled (Next.js only)\n if (\n this.context.config.generateServerActions &&\n this.context.config.provider === \"nextjs\"\n ) {\n generators.push(new ServerActionsGenerator(this.context));\n }\n\n // Generate server queries if enabled (Next.js only)\n if (\n this.context.config.generateServerQueries &&\n this.context.config.provider === \"nextjs\"\n ) {\n generators.push(new ServerQueriesGenerator(this.context));\n }\n\n return generators;\n }\n}\n"],"mappings":";;;AAEA,SAAS,eAAe;AACxB,SAAS,iBAAiB,sBAAsB,kBAAkB,4BAA4B;;;ACH9F,SAAS,mBAAmB;AAC5B,OAAO,UAAU;AA4FjB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;AAAA,MAClB,CAAC;AAED,YAAM,SAAU,MAAM,KAAK,OAAO,KAAK,OAAO,aAAa;AAG3D,YAAM,YACJ,OAAO,aACP,OAAO,SAAS,aAChB,OAAO,WACP;AAEF,UAAI,CAAC,aAAa,CAAC,UAAU,WAAW;AACtC,cAAM,IAAI;AAAA,UACR;AAAA,QACF;AAAA,MACF;AAEA,aAAO;AAAA,IACT,SAAS,OAAO;AACd,YAAM,IAAI;AAAA,QACR,kCAAkC,KAAK,OAAO,aAAa,MACzD,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CACvD;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;;;AFlDA,OAAOC,YAAU;AAEjB,IAAM,UAAU,IAAI,QAAQ;AAG5B,gBAAgB,OAAO;AAGvB,IAAM,UAAU;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe,CAAC,aAAqB,IAAI,IAAI,UAAUA,OAAK,QAAQ,QAAQ,CAAC,EAAE;AACjF;AAEA,qBAAqB,SAAS,OAAO;AACrC,iBAAiB,OAAO;AACxB,qBAAqB,SAAS,OAAO;AAErC,QAAQ,MAAM;","names":["path","context","path","fs","path","path","fs","fs","path","path","fs","fs","path","path","fs","fs","path","path","fs","fs","path","path","fs","fs","path","path","fs","fs","path","path","fs","context","path"]}
1
+ {"version":3,"sources":["../src/cli.ts","../src/config/index.ts","../src/core/codegen.ts","../src/generators/hooks.ts","../src/generators/base.ts","../src/generators/actions.ts","../src/generators/queries.ts","../src/generators/types.ts","../src/generators/client.ts","../src/generators/query-keys.ts","../src/generators/query-options.ts","../src/generators/prefetch.ts","../src/generators/generate-index.ts","../src/generators/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { Command } from 'commander';\nimport { setupCLIProgram, setupGenerateCommand, setupInitCommand, setupValidateCommand } from '@cushin/codegen-cli';\nimport { loadConfig, validateConfig } from './config/index.js';\nimport { CodegenCore } from './core/codegen.js';\nimport path from 'path';\n\nconst program = new Command();\n\n// Setup base program\nsetupCLIProgram(program);\n\n// Setup commands with context\nconst context = {\n loadConfig,\n validateConfig,\n CodegenCore,\n pathToFileURL: (filePath: string) => new URL(`file://${path.resolve(filePath)}`),\n};\n\nsetupGenerateCommand(program, context);\nsetupInitCommand(program);\nsetupValidateCommand(program, context);\n\nprogram.parse();\n","import { cosmiconfig } from \"cosmiconfig\";\nimport path from \"path\";\nimport type { APIConfig } from \"@cushin/api-runtime\";\n\nexport interface UserConfig {\n /**\n * Base URL for API requests\n */\n baseUrl?: string;\n\n /**\n * Path to the endpoints configuration file\n */\n endpoints: string;\n\n /**\n * Provider type: 'vite' | 'nextjs'\n */\n provider: \"vite\" | \"nextjs\";\n\n /**\n * Output directory for generated files\n */\n output: string;\n\n /**\n * Whether to generate React Query hooks (for client-side)\n * @default true for vite, nextjs\n */\n generateHooks?: boolean;\n\n /**\n * Whether to generate server actions (Next.js only)\n * @default true for nextjs, false for vite\n */\n generateServerActions?: boolean;\n\n /**\n * Whether to generate server queries (Next.js only)\n * @default true for nextjs, false for vite\n */\n generateServerQueries?: boolean;\n\n /**\n * Whether to generate API client\n * @default true\n */\n generateClient?: boolean;\n\n /**\n * Whether to generate prefetch utilities\n * @default true\n */\n generatePrefetch?: boolean;\n\n /**\n * Custom templates directory\n */\n templatesDir?: string;\n\n /**\n * Additional options\n */\n options?: {\n /**\n * Use 'use client' directive\n */\n useClientDirective?: boolean;\n\n /**\n * Custom imports to add to generated files\n */\n customImports?: Record<string, string[]>;\n\n /**\n * Prefix for generated hook names\n */\n hookPrefix?: string;\n\n /**\n * Suffix for generated action names\n */\n actionSuffix?: string;\n };\n}\n\nexport interface ResolvedConfig extends UserConfig {\n rootDir: string;\n endpointsPath: string;\n outputDir: string;\n apiConfig?: APIConfig;\n}\n\nconst explorer = cosmiconfig(\"api-codegen\", {\n searchPlaces: [\n \"api-codegen.config.js\",\n \"api-codegen.config.mjs\",\n \"api-codegen.config.ts\",\n \"api-codegen.config.json\",\n \".api-codegenrc\",\n \".api-codegenrc.json\",\n \".api-codegenrc.js\",\n ],\n});\n\nexport async function loadConfig(\n configPath?: string,\n): Promise<ResolvedConfig | null> {\n try {\n const result = configPath\n ? await explorer.load(configPath)\n : await explorer.search();\n\n if (!result || !result.config) {\n return null;\n }\n\n const userConfig = result.config as UserConfig;\n const rootDir = path.dirname(result.filepath);\n\n // Resolve paths\n const endpointsPath = path.resolve(rootDir, userConfig.endpoints);\n const outputDir = path.resolve(rootDir, userConfig.output);\n\n // Set defaults based on provider\n const generateHooks = userConfig.generateHooks ?? true;\n const generateServerActions =\n userConfig.generateServerActions ?? userConfig.provider === \"nextjs\";\n const generateServerQueries =\n userConfig.generateServerQueries ?? userConfig.provider === \"nextjs\";\n const generateClient = userConfig.generateClient ?? true;\n const generatePrefetch = userConfig.generatePrefetch ?? true;\n\n return {\n ...userConfig,\n rootDir,\n endpointsPath,\n outputDir,\n generateHooks,\n generateServerActions,\n generateServerQueries,\n generateClient,\n generatePrefetch,\n };\n } catch (error) {\n throw new Error(\n `Failed to load config: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n}\n\n/**\n * Validate user config\n */\nexport function validateConfig(config: UserConfig): void {\n if (!config.endpoints) {\n throw new Error('Config error: \"endpoints\" path is required');\n }\n\n if (!config.provider) {\n throw new Error(\n 'Config error: \"provider\" must be specified (vite or nextjs)',\n );\n }\n\n if (![\"vite\", \"nextjs\"].includes(config.provider)) {\n throw new Error(\n 'Config error: \"provider\" must be either \"vite\" or \"nextjs\"',\n );\n }\n\n if (!config.output) {\n throw new Error('Config error: \"output\" directory is required');\n }\n}\n","import { createJiti } from \"jiti\";\nimport type { APIConfig } from \"@cushin/api-runtime\";\nimport type { ResolvedConfig } from \"../config/index.js\";\nimport { CodeGenerator } from \"../generators/index.js\";\nimport { fileURLToPath } from \"url\";\n\nexport class CodegenCore {\n constructor(private config: ResolvedConfig) {}\n\n async execute(): Promise<void> {\n // Load API configuration\n const apiConfig = await this.loadAPIConfig();\n\n // Store in config for generators\n this.config.apiConfig = apiConfig;\n\n // Generate code\n const generator = new CodeGenerator({\n config: this.config,\n apiConfig,\n });\n\n await generator.generate();\n }\n\n private async loadAPIConfig(): Promise<APIConfig> {\n try {\n // Use jiti to load TypeScript files\n const jiti = createJiti(fileURLToPath(import.meta.url), {\n interopDefault: true,\n });\n\n const module = (await jiti.import(this.config.endpointsPath)) as any;\n\n // Try different export patterns\n const apiConfig =\n module.apiConfig ||\n module.default?.apiConfig ||\n module.default ||\n module;\n\n if (!apiConfig || !apiConfig.endpoints) {\n throw new Error(\n 'Invalid API config: must export an object with \"endpoints\" property',\n );\n }\n\n return apiConfig;\n } catch (error) {\n throw new Error(\n `Failed to load endpoints from \"${this.config.endpointsPath}\": ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n }\n }\n}\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport { BaseGenerator } from \"./base.js\";\nimport type { APIEndpoint } from \"@cushin/api-runtime\";\n\nexport class HooksGenerator extends BaseGenerator {\n async generate(): Promise<void> {\n const content = this.generateContent();\n const outputPath = path.join(this.context.config.outputDir, \"hooks.ts\");\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, \"utf-8\");\n }\n\n private generateContent(): string {\n const useClientDirective =\n this.context.config.options?.useClientDirective ?? true;\n const outputPath = path.join(this.context.config.outputDir, \"types.ts\");\n const endpointsPath = path.join(this.context.config.endpointsPath);\n const relativePath = path\n .relative(path.dirname(outputPath), endpointsPath)\n .replace(/\\\\/g, \"/\");\n\n const content = `${useClientDirective ? \"'use client';\\n\" : \"\"}\nimport { useQuery, useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport { apiClient } from \"./client\";\nimport { queryKeys } from \"./query-keys\";\nimport { apiQueryOptions } from \"./query-options\";\nimport { z } from \"zod\";\nimport { apiConfig } from \"${relativePath}\";\n\n${this.generateQueryHooks()}\n${this.generateMutationHooks()}\n`;\n\n return content;\n }\n\n private generateQueryHooks(): string {\n const hooks: string[] = [];\n Object.entries(this.context.apiConfig.endpoints).forEach(\n ([name, endpoint]) => {\n if (endpoint.method === \"GET\")\n hooks.push(this.generateQueryHook(name, endpoint));\n },\n );\n return hooks.join(\"\\n\\n\");\n }\n\n private generateQueryHook(name: string, endpoint: APIEndpoint): string {\n const hookName = `use${this.capitalize(name)}`;\n const resource = this.getResourceFromEndpoint(name, endpoint);\n const optionName = this.getEndpointKeyName(name);\n const inferParams = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.params`,\n );\n const inferQuery = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.query`,\n );\n const inferResponse = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.response`,\n );\n\n const params: string[] = [];\n const optionParams: string[] = [];\n\n const queryTags = this.getQueryTags(endpoint);\n\n if (endpoint.params) {\n params.push(`params: ${inferParams}`);\n optionParams.push(\"params\");\n }\n if (endpoint.query) {\n params.push(`filters?: ${inferQuery}`);\n optionParams.push(\"filters\");\n }\n\n params.push(`options?: {\n enabled?: boolean;\n select?: <TData = ${inferResponse}>(data: ${inferResponse}) => TData;\n }`);\n\n return `/**\n * ${endpoint.description || `Query hook for ${name}`}\n * @tags ${queryTags.join(\", \") || \"none\"}\n */\nexport function ${hookName}(${params.join(\",\\n \")}) {\n return useQuery({\n ...apiQueryOptions.${resource}.${optionName}(${optionParams.join(\", \")}),\n ...options,\n });\n}`;\n }\n\n private generateMutationHooks(): string {\n const hooks: string[] = [];\n Object.entries(this.context.apiConfig.endpoints).forEach(\n ([name, endpoint]) => {\n if (endpoint.method !== \"GET\")\n hooks.push(this.generateMutationHook(name, endpoint));\n },\n );\n return hooks.join(\"\\n\\n\");\n }\n\n private generateMutationHook(name: string, endpoint: APIEndpoint): string {\n const hookName = `use${this.capitalize(name)}`;\n const resource = this.getResourceFromEndpoint(name, endpoint);\n const inferParams = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.params`,\n );\n const inferBody = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.body`,\n );\n const inferResponse = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.response`,\n );\n\n const resourceHasQueries = this.resourceHasQueryEndpoints(resource);\n\n let inputType: string;\n let fnBody: string;\n\n if (endpoint.params && endpoint.body) {\n inputType = `{ params: ${inferParams}; body: ${inferBody}; }`;\n fnBody = `({ params, body }: ${inputType}) => apiClient.${name}(params, body)`;\n } else if (endpoint.params) {\n inputType = `${inferParams}`;\n fnBody = `(params: ${inputType}) => apiClient.${name}(params)`;\n } else if (endpoint.body) {\n inputType = `${inferBody}`;\n fnBody = `(body: ${inputType}) => apiClient.${name}(body)`;\n } else {\n inputType = \"void\";\n fnBody = `() => apiClient.${name}()`;\n }\n\n const invalidate = resourceHasQueries\n ? `queryClient.invalidateQueries({ queryKey: queryKeys.${resource}.all });`\n : \"\";\n\n return `/**\n * ${endpoint.description || `Mutation hook for ${name}`}\n * @tags ${endpoint.tags?.join(\", \") || \"none\"}\n */\n export function ${hookName}(options?: {\n onSuccess?: (data: ${inferResponse}, variables: ${inputType}, context: unknown) => void;\n onError?: (error: Error, variables: ${inputType}, context: unknown) => void;\n onSettled?: (data: ${inferResponse} | undefined, error: Error | null, variables: ${inputType}, context: unknown) => void;\n onMutate?: (variables: ${inputType}) => Promise<unknown> | unknown;\n }) {\n ${invalidate ? \"const queryClient = useQueryClient();\" : \"\"}\n return useMutation({\n\tmutationFn: ${fnBody},\n\tonSuccess: (data, variables, context) => {\n\t ${invalidate}\n\t options?.onSuccess?.(data, variables, context);\n\t},\n\tonError: options?.onError,\n\tonSettled: options?.onSettled,\n\tonMutate: options?.onMutate,\n });\n }`;\n }\n}\n","import type { APIConfig, APIEndpoint } from \"@cushin/api-runtime\";\nimport type { ResolvedConfig } from \"../config/index.js\";\n\nexport interface GeneratorContext {\n config: ResolvedConfig;\n apiConfig: APIConfig;\n}\n\nexport abstract class BaseGenerator {\n constructor(protected context: GeneratorContext) {}\n\n abstract generate(): Promise<void>;\n\n protected isQueryEndpoint(endpoint: APIEndpoint): boolean {\n return endpoint.method === \"GET\";\n }\n\n protected isMutationEndpoint(endpoint: APIEndpoint): boolean {\n return !this.isQueryEndpoint(endpoint);\n }\n\n protected capitalize(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1);\n }\n\n protected getQueryTags(endpoint: APIEndpoint): string[] {\n return endpoint.tags || [];\n }\n\n protected getInvalidationTags(endpoint: APIEndpoint): string[] {\n const tags = endpoint.tags || [];\n return tags.filter((tag) => tag !== \"query\" && tag !== \"mutation\");\n }\n\n protected hasParams(endpoint: APIEndpoint): boolean {\n return !!endpoint.params;\n }\n\n protected hasQuery(endpoint: APIEndpoint): boolean {\n return !!endpoint.query;\n }\n\n protected hasBody(endpoint: APIEndpoint): boolean {\n return !!endpoint.body;\n }\n\n protected getEndpointSignature(\n name: string,\n endpoint: APIEndpoint,\n ): {\n hasParams: boolean;\n hasQuery: boolean;\n hasBody: boolean;\n paramType: string;\n queryType: string;\n bodyType: string;\n responseType: string;\n } {\n const hasParams = this.hasParams(endpoint);\n const hasQuery = this.hasQuery(endpoint);\n const hasBody = this.hasBody(endpoint);\n\n return {\n hasParams,\n hasQuery,\n hasBody,\n paramType: hasParams ? `ExtractParams<APIEndpoints['${name}']>` : \"never\",\n queryType: hasQuery ? `ExtractQuery<APIEndpoints['${name}']>` : \"never\",\n bodyType: hasBody ? `ExtractBody<APIEndpoints['${name}']>` : \"never\",\n responseType: `ExtractResponse<APIEndpoints['${name}']>`,\n };\n }\n\n protected generateMutationCall(\n name: string,\n hasParams: boolean,\n hasBody: boolean,\n ): string {\n if (hasParams && hasBody) {\n return `return apiClient.${name}(input.params, input.body);`;\n } else if (hasParams) {\n return `return apiClient.${name}(input);`;\n } else if (hasBody) {\n return `return apiClient.${name}(input);`;\n } else {\n return `return apiClient.${name}();`;\n }\n }\n\n protected inferNonNull(expr: string): string {\n return `z.infer<NonNullable<${expr}>>`;\n }\n\n protected toCamelCase(str: string): string {\n return str\n .toLowerCase()\n .replace(/[-_\\s]+(.)?/g, (_, c) => (c ? c.toUpperCase() : \"\"))\n .replace(/^./, (c) => c.toLowerCase());\n }\n\n protected getResourceFromEndpoint(\n _name: string,\n endpoint: APIEndpoint,\n ): string {\n const tag = endpoint.tags?.find((t) => t !== \"query\" && t !== \"mutation\");\n if (tag) return this.toCamelCase(tag);\n const match = endpoint.path.match(/^\\/([^/]+)/);\n return match ? this.toCamelCase(match[1]) : \"general\";\n }\n\n protected groupEndpointsByResource() {\n const groups: Record<\n string,\n Array<{ name: string; endpoint: APIEndpoint }>\n > = {};\n Object.entries(this.context.apiConfig.endpoints).forEach(\n ([name, endpoint]) => {\n const res = this.getResourceFromEndpoint(name, endpoint);\n if (!groups[res]) groups[res] = [];\n groups[res].push({ name, endpoint });\n },\n );\n return groups;\n }\n\n protected resourceHasQueryEndpoints(resource: string): boolean {\n return (\n this.groupEndpointsByResource()[resource]?.some(\n ({ endpoint }) => endpoint.method === \"GET\",\n ) ?? false\n );\n }\n\n protected getEndpointKeyName(name: string): string {\n return name.startsWith(\"get\")\n ? name[3].toLowerCase() + name.slice(4)\n : name;\n }\n\n protected generateQueryKeyCall(\n resource: string,\n name: string,\n endpoint: APIEndpoint,\n ): string {\n const key = this.getEndpointKeyName(name);\n const args: string[] = [];\n if (endpoint.params) args.push(\"params\");\n if (endpoint.query) args.push(\"filters\");\n return args.length\n ? `queryKeys.${resource}.${key}(${args.join(\", \")})`\n : `queryKeys.${resource}.${key}()`;\n }\n\n protected hasQueryOptions() {\n return Object.values(this.context.apiConfig.endpoints).some(\n (e) => e.method === \"GET\",\n );\n }\n}\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport { BaseGenerator } from \"./base.js\";\nimport type { APIEndpoint } from \"@cushin/api-runtime\";\n\nexport class ServerActionsGenerator extends BaseGenerator {\n async generate(): Promise<void> {\n const content = this.generateContent();\n const outputPath = path.join(this.context.config.outputDir, 'actions.ts');\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, 'utf-8');\n }\n\n private generateContent(): string {\n const imports = `'use server';\n\nimport { revalidateTag, revalidatePath } from 'next/cache';\nimport { serverClient } from './server-client';\nimport type { \n APIEndpoints, \n ExtractBody, \n ExtractParams, \n ExtractResponse \n} from './types';\n\nexport type ActionResult<T> = \n | { success: true; data: T }\n | { success: false; error: string };\n`;\n\n const actions: string[] = [];\n\n Object.entries(this.context.apiConfig.endpoints).forEach(([name, endpoint]) => {\n if (this.isMutationEndpoint(endpoint)) {\n actions.push(this.generateServerAction(name, endpoint));\n }\n });\n\n return imports + '\\n' + actions.join('\\n\\n');\n }\n\n private generateServerAction(name: string, endpoint: APIEndpoint): string {\n const actionSuffix = this.context.config.options?.actionSuffix || 'Action';\n const actionName = `${name}${actionSuffix}`;\n const signature = this.getEndpointSignature(name, endpoint);\n const invalidationTags = this.getInvalidationTags(endpoint);\n\n let inputType = '';\n let inputParam = '';\n if (signature.hasParams && signature.hasBody) {\n inputType = `input: { params: ${signature.paramType}; body: ${signature.bodyType} }`;\n inputParam = 'input';\n } else if (signature.hasParams) {\n inputType = `params: ${signature.paramType}`;\n inputParam = 'params';\n } else if (signature.hasBody) {\n inputType = `body: ${signature.bodyType}`;\n inputParam = 'body';\n }\n\n const revalidateStatements = invalidationTags.length > 0\n ? invalidationTags\n .map((tag) => ` revalidateTag('${tag}');`)\n .join('\\n')\n : ' // No automatic revalidations';\n\n return `/**\n * ${endpoint.description || `Server action for ${name}`}\n * @tags ${endpoint.tags?.join(', ') || 'none'}\n */\nexport async function ${actionName}(\n ${inputType}\n): Promise<ActionResult<${signature.responseType}>> {\n try {\n const result = await serverClient.${name}(${inputParam ? inputParam : ''});\n \n // Revalidate related data\n${revalidateStatements}\n \n return { success: true, data: result };\n } catch (error) {\n console.error('[Server Action Error]:', error);\n return { \n success: false, \n error: error instanceof Error ? error.message : 'Unknown error' \n };\n }\n}`;\n }\n}\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport { BaseGenerator } from \"./base.js\";\nimport type { APIEndpoint } from \"@cushin/api-runtime\";\n\nexport class ServerQueriesGenerator extends BaseGenerator {\n async generate(): Promise<void> {\n const content = this.generateContent();\n const outputPath = path.join(this.context.config.outputDir, \"queries.ts\");\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, \"utf-8\");\n }\n\n private generateContent(): string {\n const imports = `import { cache } from 'react';\nimport { unstable_cache } from 'next/cache';\nimport { serverClient } from './server-client';\nimport type { \n APIEndpoints, \n ExtractParams, \n ExtractQuery, \n ExtractResponse \n} from './types';\n`;\n\n const queries: string[] = [];\n\n Object.entries(this.context.apiConfig.endpoints).forEach(\n ([name, endpoint]) => {\n if (this.isQueryEndpoint(endpoint)) {\n queries.push(this.generateServerQuery(name, endpoint));\n }\n },\n );\n\n return imports + \"\\n\" + queries.join(\"\\n\\n\");\n }\n\n private generateServerQuery(name: string, endpoint: APIEndpoint): string {\n const queryName = `${name}Query`;\n const signature = this.getEndpointSignature(name, endpoint);\n const queryTags = this.getQueryTags(endpoint);\n\n const paramDef = signature.hasParams\n ? `params: ${signature.paramType}`\n : \"\";\n const queryDef = signature.hasQuery ? `query?: ${signature.queryType}` : \"\";\n const paramsList = [paramDef, queryDef].filter(Boolean).join(\",\\n \");\n\n const clientCallArgs: string[] = [];\n if (signature.hasParams) clientCallArgs.push(\"params\");\n if (signature.hasQuery) clientCallArgs.push(\"query\");\n\n // Generate cache key based on params\n const cacheKeyParts: string[] = [`'${name}'`];\n if (signature.hasParams) cacheKeyParts.push(\"JSON.stringify(params)\");\n if (signature.hasQuery) cacheKeyParts.push(\"JSON.stringify(query)\");\n\n return `/**\n * ${endpoint.description || `Server query for ${name}`}\n * @tags ${queryTags.join(\", \") || \"none\"}\n */\nexport const ${queryName} = cache(async (\n ${paramsList}\n): Promise<${signature.responseType}> => {\n return unstable_cache(\n async () => serverClient.${name}(${clientCallArgs.join(\", \")}),\n [${cacheKeyParts.join(\", \")}],\n {\n tags: [${queryTags.map((tag) => `'${tag}'`).join(\", \")}],\n revalidate: 3600, // 1 hour default, can be overridden\n }\n )();\n});`;\n }\n}\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport { BaseGenerator } from \"./base.js\";\n\nexport class TypesGenerator extends BaseGenerator {\n async generate(): Promise<void> {\n const content = this.generateContent();\n const outputPath = path.join(this.context.config.outputDir, \"types.ts\");\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, \"utf-8\");\n }\n\n private generateContent(): string {\n const outputPath = path.join(this.context.config.outputDir, \"types.ts\");\n const endpointsPath = path.join(this.context.config.endpointsPath);\n const relativePath = path\n .relative(path.dirname(outputPath), endpointsPath)\n .replace(/\\\\/g, \"/\");\n return `// Auto-generated type definitions\n// Do not edit this file manually\n\nimport type { z } from 'zod';\nimport { apiConfig } from '${relativePath}';\n\n\n// Re-export endpoint configuration types\nexport type { APIConfig, APIEndpoint, HTTPMethod } from '@cushin/api-runtime';\n\n/**\n * Type helper to extract params schema from an endpoint\n */\nexport type ExtractParams<T> = T extends { params: infer P extends z.ZodType }\n ? z.infer<P>\n : never;\n\n/**\n * Type helper to extract query schema from an endpoint\n */\nexport type ExtractQuery<T> = T extends { query: infer Q extends z.ZodType }\n ? z.infer<Q>\n : never;\n\n/**\n * Type helper to extract body schema from an endpoint\n */\nexport type ExtractBody<T> = T extends { body: infer B extends z.ZodType }\n ? z.infer<B>\n : never;\n\n/**\n * Type helper to extract response schema from an endpoint\n */\nexport type ExtractResponse<T> = T extends { response: infer R extends z.ZodType }\n ? z.infer<R>\n : never;\n\n/**\n * Import your API config to get typed endpoints\n * \n */\nexport type APIEndpoints = typeof apiConfig.endpoints;\n\n${this.generateEndpointTypes()}\n`;\n }\n\n private generateEndpointTypes(): string {\n const types: string[] = [];\n\n Object.entries(this.context.apiConfig.endpoints).forEach(\n ([name, endpoint]) => {\n const cap = this.capitalize(name);\n if (endpoint.response)\n types.push(\n `export type ${cap}Response = ${this.inferNonNull(`typeof apiConfig.endpoints.${name}.response`)};`,\n );\n if (endpoint.body)\n types.push(\n `export type ${cap}Input = ${this.inferNonNull(`typeof apiConfig.endpoints.${name}.body`)};`,\n );\n if (endpoint.query)\n types.push(\n `export type ${cap}Query = ${this.inferNonNull(`typeof apiConfig.endpoints.${name}.query`)};`,\n );\n if (endpoint.params)\n types.push(\n `export type ${cap}Params = ${this.inferNonNull(`typeof apiConfig.endpoints.${name}.params`)};`,\n );\n },\n );\n\n return types.join(\"\\n\");\n }\n}\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport { BaseGenerator } from \"./base.js\";\n\nexport class ClientGenerator extends BaseGenerator {\n async generate(): Promise<void> {\n await this.generateClientFile();\n\n if (this.context.config.provider === \"nextjs\") {\n await this.generateServerClientFile();\n }\n }\n\n private async generateClientFile(): Promise<void> {\n const content = this.generateClientContent();\n const outputPath = path.join(this.context.config.outputDir, \"client.ts\");\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, \"utf-8\");\n }\n\n private async generateServerClientFile(): Promise<void> {\n const content = this.generateServerClientContent();\n const outputPath = path.join(\n this.context.config.outputDir,\n \"server-client.ts\",\n );\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, \"utf-8\");\n }\n\n private generateClientContent(): string {\n const useClientDirective =\n this.context.config.options?.useClientDirective ?? true;\n const outputPath = path.join(this.context.config.outputDir, \"types.ts\");\n const endpointsPath = path.join(this.context.config.endpointsPath);\n const relativePath = path\n .relative(path.dirname(outputPath), endpointsPath)\n .replace(/\\\\/g, \"/\");\n\n return `${useClientDirective ? \"'use client';\\n\" : \"\"}\nimport { createAPIClient } from '@cushin/api-runtime';\nimport type { AuthCallbacks } from '@cushin/api-runtime';\nimport { apiConfig } from '${relativePath}';\nimport { z } from 'zod';\n\n// Type the methods based on endpoints\ntype APIClientMethods = {\n [K in keyof typeof apiConfig.endpoints]: (typeof apiConfig.endpoints)[K] extends {\n method: infer M;\n params?: infer P;\n query?: infer Q;\n body?: infer B;\n response: infer R;\n }\n ? M extends \"GET\"\n ? P extends z.ZodJSONSchema\n ? Q extends z.ZodJSONSchema\n ? (params: z.infer<P>, query?: z.infer<Q>) => Promise<z.infer<R>>\n : (params: z.infer<P>) => Promise<z.infer<R>>\n : Q extends z.ZodJSONSchema\n ? (query?: z.infer<Q>) => Promise<z.infer<R>>\n : () => Promise<z.infer<R>>\n : P extends z.ZodJSONSchema\n ? B extends z.ZodJSONSchema\n ? (params: z.infer<P>, body: z.infer<B>) => Promise<z.infer<R>>\n : (params: z.infer<P>) => Promise<z.infer<R>>\n : B extends z.ZodJSONSchema\n ? (body: z.infer<B>) => Promise<z.infer<R>>\n : () => Promise<z.infer<R>>\n : never;\n};\n\n\n// Export singleton instance (will be initialized later)\nexport let baseClient: APIClientMethods & {\n refreshAuth: () => Promise<void>;\n updateAuthCallbacks: (callbacks: AuthCallbacks) => void;\n};\n\nexport const apiClient = {\n${this.generateApiClientMethods()}\n};\n\n/**\n * Initialize API client with auth callbacks\n * Call this function in your auth provider setup\n * \n * @example\n * const authCallbacks = {\n * getTokens: () => getStoredTokens(),\n * onAuthError: () => router.push('/login'),\n * onRefreshToken: async () => {\n * await refreshAccessToken();\n * },\n * };\n * \n * initializeAPIClient(authCallbacks);\n */\nexport const initializeAPIClient = (authCallbacks: AuthCallbacks) => {\n baseClient = createAPIClient(apiConfig, authCallbacks) as any;\n return baseClient;\n};\n\n// Export for custom usage\nexport { createAPIClient };\nexport type { AuthCallbacks };\n`;\n }\n\n private generateServerClientContent(): string {\n return `import { createAPIClient } from './core';\nimport { apiConfig } from '../config/endpoints';\nimport type { APIEndpoints } from './types';\n\n// Type-safe API client methods for server-side\ntype APIClientMethods = {\n [K in keyof APIEndpoints]: APIEndpoints[K] extends {\n method: infer M;\n params?: infer P;\n query?: infer Q;\n body?: infer B;\n response: infer R;\n }\n ? M extends 'GET'\n ? P extends { _type: any }\n ? Q extends { _type: any }\n ? (params: P['_type'], query?: Q['_type']) => Promise<R['_type']>\n : (params: P['_type']) => Promise<R['_type']>\n : Q extends { _type: any }\n ? (query?: Q['_type']) => Promise<R['_type']>\n : () => Promise<R['_type']>\n : P extends { _type: any }\n ? B extends { _type: any }\n ? (params: P['_type'], body: B['_type']) => Promise<R['_type']>\n : (params: P['_type']) => Promise<R['_type']>\n : B extends { _type: any }\n ? (body: B['_type']) => Promise<R['_type']>\n : () => Promise<R['_type']>\n : never;\n};\n\n/**\n * Server-side API client (no auth, direct API calls)\n * Use this in Server Components, Server Actions, and Route Handlers\n */\nexport const serverClient = createAPIClient(apiConfig) as APIClientMethods;\n`;\n }\n\n private generateApiClientMethods(): string {\n const methods: string[] = [];\n\n Object.entries(this.context.apiConfig.endpoints).forEach(\n ([name, endpoint]) => {\n const inferParams = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.params`,\n );\n const inferQuery = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.query`,\n );\n const inferBody = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.body`,\n );\n const inferResponse = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.response`,\n );\n\n if (endpoint.method === \"GET\") {\n if (endpoint.params && endpoint.query) {\n methods.push(` ${name}: (params: ${inferParams}, query?: ${inferQuery}): Promise<${inferResponse}> => \n (baseClient as any).${name}(params, query),`);\n } else if (endpoint.params) {\n methods.push(` ${name}: (params: ${inferParams}): Promise<${inferResponse}> => \n (baseClient as any).${name}(params),`);\n } else if (endpoint.query) {\n methods.push(` ${name}: (query?: ${inferQuery}): Promise<${inferResponse}> => \n (baseClient as any).${name}(query),`);\n } else {\n methods.push(` ${name}: (): Promise<${inferResponse}> => \n (baseClient as any).${name}(),`);\n }\n } else {\n if (endpoint.params && endpoint.body) {\n methods.push(` ${name}: (params: ${inferParams}, body: ${inferBody}): Promise<${inferResponse}> => \n (baseClient as any).${name}(params, body),`);\n } else if (endpoint.params) {\n methods.push(` ${name}: (params: ${inferParams}): Promise<${inferResponse}> => \n (baseClient as any).${name}(params),`);\n } else if (endpoint.body) {\n methods.push(` ${name}: (body: ${inferBody}): Promise<${inferResponse}> => \n (baseClient as any).${name}(body),`);\n } else {\n methods.push(` ${name}: (): Promise<${inferResponse}> => \n (baseClient as any).${name}(),`);\n }\n }\n },\n );\n\n return methods.join(\"\\n\");\n }\n}\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport { BaseGenerator } from \"./base.js\";\n\nexport class QueryKeysGenerator extends BaseGenerator {\n async generate(): Promise<void> {\n const content = this.generateContent();\n const outputPath = path.join(\n this.context.config.outputDir,\n \"query-keys.ts\",\n );\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, \"utf-8\");\n }\n\n private generateContent(): string {\n const outputPath = path.join(this.context.config.outputDir, \"types.ts\");\n const endpointsPath = path.join(this.context.config.endpointsPath);\n const relativePath = path\n .relative(path.dirname(outputPath), endpointsPath)\n .replace(/\\\\/g, \"/\");\n const content = `// Auto-generated query keys\nimport { z } from 'zod';\nimport { apiConfig } from '${relativePath}';\n\nexport const queryKeys = {\n${this.generateQueryKeysContent()}\n} as const;\n`;\n return content;\n }\n\n private generateQueryKeysContent(): string {\n const resourceGroups = this.groupEndpointsByResource();\n const keys: string[] = [];\n\n Object.entries(resourceGroups).forEach(([resource, endpoints]) => {\n const queryEndpoints = endpoints.filter(\n ({ endpoint }) => endpoint.method === \"GET\",\n );\n if (queryEndpoints.length === 0) return;\n\n const resourceKeys: string[] = [` all: ['${resource}'] as const,`];\n const added = new Set<string>();\n\n queryEndpoints.forEach(({ name, endpoint }) => {\n const keyName = this.getEndpointKeyName(name);\n if (added.has(keyName)) return;\n const inferParams = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.params`,\n );\n const inferQuery = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.query`,\n );\n\n if (endpoint.params || endpoint.query) {\n const params: string[] = [];\n if (endpoint.params) params.push(`params?: ${inferParams}`);\n if (endpoint.query) params.push(`query?: ${inferQuery}`);\n\n resourceKeys.push(` ${keyName}: (${params.join(\", \")}) =>\n ['${resource}', '${keyName}', ${endpoint.params ? \"params\" : \"undefined\"}, ${endpoint.query ? \"query\" : \"undefined\"}] as const,`);\n } else {\n resourceKeys.push(\n ` ${keyName}: () => ['${resource}', '${keyName}'] as const,`,\n );\n }\n added.add(keyName);\n });\n\n keys.push(` ${resource}: {\\n${resourceKeys.join(\"\\n\")}\\n },`);\n });\n\n return keys.join(\"\\n\");\n }\n}\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport { BaseGenerator } from \"./base.js\";\n\nexport class QueryOptionsGenerator extends BaseGenerator {\n async generate(): Promise<void> {\n const content = this.generateContent();\n const outputPath = path.join(\n this.context.config.outputDir,\n \"query-options.ts\",\n );\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, \"utf-8\");\n }\n private generateContent(): string {\n const outputPath = path.join(this.context.config.outputDir, \"types.ts\");\n const endpointsPath = path.join(this.context.config.endpointsPath);\n const relativePath = path\n .relative(path.dirname(outputPath), endpointsPath)\n .replace(/\\\\/g, \"/\");\n const content = `// Auto-generated query options\nimport { queryOptions } from '@tanstack/react-query';\nimport { apiClient } from './client';\nimport { queryKeys } from './query-keys';\nimport { z } from 'zod';\nimport { apiConfig } from '${relativePath}';\n\n${this.generateQueryOptionsContent()}\n\nexport const apiQueryOptions = {\n${this.generateQueryOptionsExports()}\n} as const;\n`;\n\n return content;\n }\n\n private generateQueryOptionsContent(): string {\n const groups = this.groupEndpointsByResource();\n const options: string[] = [];\n\n Object.entries(groups).forEach(([resource, endpoints]) => {\n const queries = endpoints.filter(\n ({ endpoint }) => endpoint.method === \"GET\",\n );\n if (queries.length === 0) return;\n\n const resourceOptions: string[] = [];\n queries.forEach(({ name, endpoint }) => {\n const optionName = this.getEndpointKeyName(name);\n const inferParams = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.params`,\n );\n const inferQuery = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.query`,\n );\n const inferResponse = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.response`,\n );\n\n const params: string[] = [];\n let apiCall = \"\";\n\n if (endpoint.params && endpoint.query) {\n params.push(`params: ${inferParams}`, `filters?: ${inferQuery}`);\n apiCall = `apiClient.${name}(params, filters)`;\n } else if (endpoint.params) {\n params.push(`params: ${inferParams}`);\n apiCall = `apiClient.${name}(params)`;\n } else if (endpoint.query) {\n params.push(`filters?: ${inferQuery}`);\n apiCall = `apiClient.${name}(filters)`;\n } else {\n apiCall = `apiClient.${name}()`;\n }\n\n const keyCall = this.generateQueryKeyCall(resource, name, endpoint);\n\n resourceOptions.push(` ${optionName}: (${params.join(\", \")}) =>\n queryOptions({\n queryKey: ${keyCall},\n queryFn: (): Promise<${inferResponse}> => ${apiCall},\n staleTime: 1000 * 60 * 5,\n }),`);\n });\n\n options.push(\n `const ${resource}QueryOptions = {\\n${resourceOptions.join(\"\\n\")}\\n};\\n`,\n );\n });\n\n return options.join(\"\\n\");\n }\n\n private generateQueryOptionsExports(): string {\n const groups = this.groupEndpointsByResource();\n const exports: string[] = [];\n\n Object.keys(groups).forEach((resource) => {\n const hasQueries = groups[resource].some(\n ({ endpoint }) => endpoint.method === \"GET\",\n );\n if (hasQueries) exports.push(` ${resource}: ${resource}QueryOptions,`);\n });\n\n return exports.join(\"\\n\");\n }\n}\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport { BaseGenerator } from \"./base.js\";\nimport type { APIEndpoint } from \"@cushin/api-runtime\";\n\nexport class PrefetchGenerator extends BaseGenerator {\n async generate(): Promise<void> {\n const content = this.generateContent();\n const outputPath = path.join(this.context.config.outputDir, \"prefetchs.ts\");\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, \"utf-8\");\n }\n\n private generateContent(): string {\n const content = `// Auto-generated prefetch utilities\nimport { type QueryClient } from '@tanstack/react-query';\n${this.hasQueryOptions() ? \"import { apiQueryOptions } from './query-options';\" : \"\"}\nimport { z } from 'zod';\nimport { apiConfig } from '../config/endpoints';\n\n${this.generatePrefetchFunctions()}\n`;\n return content;\n }\n\n private generatePrefetchFunctions(): string {\n const funcs: string[] = [];\n Object.entries(this.context.apiConfig.endpoints).forEach(\n ([name, endpoint]) => {\n if (endpoint.method === \"GET\")\n funcs.push(this.generatePrefetchFunction(name, endpoint));\n },\n );\n return funcs.join(\"\\n\\n\");\n }\n\n private generatePrefetchFunction(\n name: string,\n endpoint: APIEndpoint,\n ): string {\n const prefetchName = `prefetch${this.capitalize(name)}`;\n const resource = this.getResourceFromEndpoint(name, endpoint);\n const optionName = this.getEndpointKeyName(name);\n const inferParams = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.params`,\n );\n const inferQuery = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.query`,\n );\n\n const params: string[] = [\"queryClient: QueryClient\"];\n const optionParams: string[] = [];\n\n if (endpoint.params) {\n params.push(`params: ${inferParams}`);\n optionParams.push(\"params\");\n }\n if (endpoint.query) {\n params.push(`filters?: ${inferQuery}`);\n optionParams.push(\"filters\");\n }\n\n return `export const ${prefetchName} = async (${params.join(\",\\n \")}) => {\n return await queryClient.ensureQueryData(apiQueryOptions.${resource}.${optionName}(${optionParams.join(\", \")}));\n};`;\n }\n}\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport { BaseGenerator } from \"./base.js\";\n\nexport class IndexGenerator extends BaseGenerator {\n async generate(): Promise<void> {\n const content = this.generateContent();\n const outputPath = path.join(this.context.config.outputDir, \"index.ts\");\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, \"utf-8\");\n }\n\n private generateContent(): string {\n const outputPath = path.join(this.context.config.outputDir, \"types.ts\");\n const endpointsPath = path.join(this.context.config.endpointsPath);\n const relativePath = path\n .relative(path.dirname(outputPath), endpointsPath)\n .replace(/\\\\/g, \"/\");\n\n const content = `// Auto-generated exports\nexport * from './types';\nexport * from './client';\nexport * from './query-keys';\n${this.hasQueryOptions() ? \"export * from './query-options';\" : \"\"}\nexport * from './hooks';\nexport * from './prefetchs';\nexport { z } from 'zod';\nexport { apiConfig } from '${relativePath}';\n`;\n return content;\n }\n}\n","import { HooksGenerator } from \"./hooks.js\";\nimport { ServerActionsGenerator } from \"./actions.js\";\nimport { ServerQueriesGenerator } from \"./queries.js\";\nimport { TypesGenerator } from \"./types.js\";\nimport { ClientGenerator } from \"./client.js\";\nimport type { GeneratorContext } from \"./base.js\";\nimport { QueryKeysGenerator } from \"./query-keys.js\";\nimport { QueryOptionsGenerator } from \"./query-options.js\";\nimport { PrefetchGenerator } from \"./prefetch.js\";\nimport { IndexGenerator } from \"./generate-index.js\";\n\nexport class CodeGenerator {\n constructor(private context: GeneratorContext) {}\n\n async generate(): Promise<void> {\n const generators = this.getGenerators();\n\n for (const generator of generators) {\n await generator.generate();\n }\n }\n\n private getGenerators() {\n const generators: Array<any> = [];\n\n // Always generate types\n generators.push(new TypesGenerator(this.context));\n generators.push(new IndexGenerator(this.context));\n\n // Generate client if enabled\n if (this.context.config.generateClient) {\n generators.push(new ClientGenerator(this.context));\n }\n\n // Generate hooks if enabled\n if (this.context.config.generateHooks) {\n generators.push(new QueryKeysGenerator(this.context));\n generators.push(new QueryOptionsGenerator(this.context));\n generators.push(new HooksGenerator(this.context));\n }\n\n if (this.context.config.generatePrefetch) {\n generators.push(new PrefetchGenerator(this.context));\n }\n\n // Generate server actions if enabled (Next.js only)\n if (\n this.context.config.generateServerActions &&\n this.context.config.provider === \"nextjs\"\n ) {\n generators.push(new ServerActionsGenerator(this.context));\n }\n\n // Generate server queries if enabled (Next.js only)\n if (\n this.context.config.generateServerQueries &&\n this.context.config.provider === \"nextjs\"\n ) {\n generators.push(new ServerQueriesGenerator(this.context));\n }\n\n return generators;\n }\n}\n"],"mappings":";;;AAEA,SAAS,eAAe;AACxB,SAAS,iBAAiB,sBAAsB,kBAAkB,4BAA4B;;;ACH9F,SAAS,mBAAmB;AAC5B,OAAO,UAAU;AA4FjB,IAA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,OAAO;AAGvB,IAAM,UAAU;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe,CAAC,aAAqB,IAAI,IAAI,UAAUA,OAAK,QAAQ,QAAQ,CAAC,EAAE;AACjF;AAEA,qBAAqB,SAAS,OAAO;AACrC,iBAAiB,OAAO;AACxB,qBAAqB,SAAS,OAAO;AAErC,QAAQ,MAAM;","names":["path","context","path","fs","path","path","fs","fs","path","path","fs","fs","path","path","fs","fs","path","path","fs","fs","path","path","fs","fs","path","path","fs","fs","path","path","fs","fs","path","path","fs","context","path"]}
package/dist/index.js CHANGED
@@ -949,6 +949,34 @@ ${this.generatePrefetchFunctions()}
949
949
  }
950
950
  };
951
951
 
952
+ // src/generators/generate-index.ts
953
+ import fs9 from "fs/promises";
954
+ import path10 from "path";
955
+ var IndexGenerator = class extends BaseGenerator {
956
+ async generate() {
957
+ const content = this.generateContent();
958
+ const outputPath = path10.join(this.context.config.outputDir, "index.ts");
959
+ await fs9.mkdir(path10.dirname(outputPath), { recursive: true });
960
+ await fs9.writeFile(outputPath, content, "utf-8");
961
+ }
962
+ generateContent() {
963
+ const outputPath = path10.join(this.context.config.outputDir, "types.ts");
964
+ const endpointsPath = path10.join(this.context.config.endpointsPath);
965
+ const relativePath = path10.relative(path10.dirname(outputPath), endpointsPath).replace(/\\/g, "/");
966
+ const content = `// Auto-generated exports
967
+ export * from './types';
968
+ export * from './client';
969
+ export * from './query-keys';
970
+ ${this.hasQueryOptions() ? "export * from './query-options';" : ""}
971
+ export * from './hooks';
972
+ export * from './prefetchs';
973
+ export { z } from 'zod';
974
+ export { apiConfig } from '${relativePath}';
975
+ `;
976
+ return content;
977
+ }
978
+ };
979
+
952
980
  // src/generators/index.ts
953
981
  var CodeGenerator = class {
954
982
  constructor(context) {
@@ -963,6 +991,7 @@ var CodeGenerator = class {
963
991
  getGenerators() {
964
992
  const generators = [];
965
993
  generators.push(new TypesGenerator(this.context));
994
+ generators.push(new IndexGenerator(this.context));
966
995
  if (this.context.config.generateClient) {
967
996
  generators.push(new ClientGenerator(this.context));
968
997
  }
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/config/index.ts","../src/core/codegen.ts","../src/generators/hooks.ts","../src/generators/base.ts","../src/generators/actions.ts","../src/generators/queries.ts","../src/generators/types.ts","../src/generators/client.ts","../src/generators/query-keys.ts","../src/generators/query-options.ts","../src/generators/prefetch.ts","../src/generators/index.ts"],"sourcesContent":["// Re-export runtime types from @cushin/api-runtime\nexport * from \"@cushin/api-runtime\";\n\n// Export config types and utilities\nexport * from \"./config/index.js\";\n\n// Export codegen utilities\nexport { CodegenCore } from \"./core/codegen.js\";\nexport { CodeGenerator } from \"./generators/index.js\";\n","import { cosmiconfig } from \"cosmiconfig\";\nimport path from \"path\";\nimport type { APIConfig } from \"@cushin/api-runtime\";\n\nexport interface UserConfig {\n /**\n * Base URL for API requests\n */\n baseUrl?: string;\n\n /**\n * Path to the endpoints configuration file\n */\n endpoints: string;\n\n /**\n * Provider type: 'vite' | 'nextjs'\n */\n provider: \"vite\" | \"nextjs\";\n\n /**\n * Output directory for generated files\n */\n output: string;\n\n /**\n * Whether to generate React Query hooks (for client-side)\n * @default true for vite, nextjs\n */\n generateHooks?: boolean;\n\n /**\n * Whether to generate server actions (Next.js only)\n * @default true for nextjs, false for vite\n */\n generateServerActions?: boolean;\n\n /**\n * Whether to generate server queries (Next.js only)\n * @default true for nextjs, false for vite\n */\n generateServerQueries?: boolean;\n\n /**\n * Whether to generate API client\n * @default true\n */\n generateClient?: boolean;\n\n /**\n * Whether to generate prefetch utilities\n * @default true\n */\n generatePrefetch?: boolean;\n\n /**\n * Custom templates directory\n */\n templatesDir?: string;\n\n /**\n * Additional options\n */\n options?: {\n /**\n * Use 'use client' directive\n */\n useClientDirective?: boolean;\n\n /**\n * Custom imports to add to generated files\n */\n customImports?: Record<string, string[]>;\n\n /**\n * Prefix for generated hook names\n */\n hookPrefix?: string;\n\n /**\n * Suffix for generated action names\n */\n actionSuffix?: string;\n };\n}\n\nexport interface ResolvedConfig extends UserConfig {\n rootDir: string;\n endpointsPath: string;\n outputDir: string;\n apiConfig?: APIConfig;\n}\n\nconst explorer = cosmiconfig(\"api-codegen\", {\n searchPlaces: [\n \"api-codegen.config.js\",\n \"api-codegen.config.mjs\",\n \"api-codegen.config.ts\",\n \"api-codegen.config.json\",\n \".api-codegenrc\",\n \".api-codegenrc.json\",\n \".api-codegenrc.js\",\n ],\n});\n\nexport async function loadConfig(\n configPath?: string,\n): Promise<ResolvedConfig | null> {\n try {\n const result = configPath\n ? await explorer.load(configPath)\n : await explorer.search();\n\n if (!result || !result.config) {\n return null;\n }\n\n const userConfig = result.config as UserConfig;\n const rootDir = path.dirname(result.filepath);\n\n // Resolve paths\n const endpointsPath = path.resolve(rootDir, userConfig.endpoints);\n const outputDir = path.resolve(rootDir, userConfig.output);\n\n // Set defaults based on provider\n const generateHooks = userConfig.generateHooks ?? true;\n const generateServerActions =\n userConfig.generateServerActions ?? userConfig.provider === \"nextjs\";\n const generateServerQueries =\n userConfig.generateServerQueries ?? userConfig.provider === \"nextjs\";\n const generateClient = userConfig.generateClient ?? true;\n const generatePrefetch = userConfig.generatePrefetch ?? true;\n\n return {\n ...userConfig,\n rootDir,\n endpointsPath,\n outputDir,\n generateHooks,\n generateServerActions,\n generateServerQueries,\n generateClient,\n generatePrefetch,\n };\n } catch (error) {\n throw new Error(\n `Failed to load config: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n}\n\n/**\n * Validate user config\n */\nexport function validateConfig(config: UserConfig): void {\n if (!config.endpoints) {\n throw new Error('Config error: \"endpoints\" path is required');\n }\n\n if (!config.provider) {\n throw new Error(\n 'Config error: \"provider\" must be specified (vite or nextjs)',\n );\n }\n\n if (![\"vite\", \"nextjs\"].includes(config.provider)) {\n throw new Error(\n 'Config error: \"provider\" must be either \"vite\" or \"nextjs\"',\n );\n }\n\n if (!config.output) {\n throw new Error('Config error: \"output\" directory is required');\n }\n}\n","import { createJiti } from \"jiti\";\nimport type { APIConfig } from \"@cushin/api-runtime\";\nimport type { ResolvedConfig } from \"../config/index.js\";\nimport { CodeGenerator } from \"../generators/index.js\";\nimport { fileURLToPath } from \"url\";\n\nexport class CodegenCore {\n constructor(private config: ResolvedConfig) {}\n\n async execute(): Promise<void> {\n // Load API configuration\n const apiConfig = await this.loadAPIConfig();\n\n // Store in config for generators\n this.config.apiConfig = apiConfig;\n\n // Generate code\n const generator = new CodeGenerator({\n config: this.config,\n apiConfig,\n });\n\n await generator.generate();\n }\n\n private async loadAPIConfig(): Promise<APIConfig> {\n try {\n // Use jiti to load TypeScript files\n const jiti = createJiti(fileURLToPath(import.meta.url), {\n interopDefault: true,\n });\n\n const module = (await jiti.import(this.config.endpointsPath)) as any;\n\n // Try different export patterns\n const apiConfig =\n module.apiConfig ||\n module.default?.apiConfig ||\n module.default ||\n module;\n\n if (!apiConfig || !apiConfig.endpoints) {\n throw new Error(\n 'Invalid API config: must export an object with \"endpoints\" property',\n );\n }\n\n return apiConfig;\n } catch (error) {\n throw new Error(\n `Failed to load endpoints from \"${this.config.endpointsPath}\": ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n }\n }\n}\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport { BaseGenerator } from \"./base.js\";\nimport type { APIEndpoint } from \"@cushin/api-runtime\";\n\nexport class HooksGenerator extends BaseGenerator {\n async generate(): Promise<void> {\n const content = this.generateContent();\n const outputPath = path.join(this.context.config.outputDir, \"hooks.ts\");\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, \"utf-8\");\n }\n\n private generateContent(): string {\n const useClientDirective =\n this.context.config.options?.useClientDirective ?? true;\n const outputPath = path.join(this.context.config.outputDir, \"types.ts\");\n const endpointsPath = path.join(this.context.config.endpointsPath);\n const relativePath = path\n .relative(path.dirname(outputPath), endpointsPath)\n .replace(/\\\\/g, \"/\");\n\n const content = `${useClientDirective ? \"'use client';\\n\" : \"\"}\nimport { useQuery, useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport { apiClient } from \"./client\";\nimport { queryKeys } from \"./query-keys\";\nimport { apiQueryOptions } from \"./query-options\";\nimport { z } from \"zod\";\nimport { apiConfig } from \"${relativePath}\";\n\n${this.generateQueryHooks()}\n${this.generateMutationHooks()}\n`;\n\n return content;\n }\n\n private generateQueryHooks(): string {\n const hooks: string[] = [];\n Object.entries(this.context.apiConfig.endpoints).forEach(\n ([name, endpoint]) => {\n if (endpoint.method === \"GET\")\n hooks.push(this.generateQueryHook(name, endpoint));\n },\n );\n return hooks.join(\"\\n\\n\");\n }\n\n private generateQueryHook(name: string, endpoint: APIEndpoint): string {\n const hookName = `use${this.capitalize(name)}`;\n const resource = this.getResourceFromEndpoint(name, endpoint);\n const optionName = this.getEndpointKeyName(name);\n const inferParams = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.params`,\n );\n const inferQuery = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.query`,\n );\n const inferResponse = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.response`,\n );\n\n const params: string[] = [];\n const optionParams: string[] = [];\n\n const queryTags = this.getQueryTags(endpoint);\n\n if (endpoint.params) {\n params.push(`params: ${inferParams}`);\n optionParams.push(\"params\");\n }\n if (endpoint.query) {\n params.push(`filters?: ${inferQuery}`);\n optionParams.push(\"filters\");\n }\n\n params.push(`options?: {\n enabled?: boolean;\n select?: <TData = ${inferResponse}>(data: ${inferResponse}) => TData;\n }`);\n\n return `/**\n * ${endpoint.description || `Query hook for ${name}`}\n * @tags ${queryTags.join(\", \") || \"none\"}\n */\nexport function ${hookName}(${params.join(\",\\n \")}) {\n return useQuery({\n ...apiQueryOptions.${resource}.${optionName}(${optionParams.join(\", \")}),\n ...options,\n });\n}`;\n }\n\n private generateMutationHooks(): string {\n const hooks: string[] = [];\n Object.entries(this.context.apiConfig.endpoints).forEach(\n ([name, endpoint]) => {\n if (endpoint.method !== \"GET\")\n hooks.push(this.generateMutationHook(name, endpoint));\n },\n );\n return hooks.join(\"\\n\\n\");\n }\n\n private generateMutationHook(name: string, endpoint: APIEndpoint): string {\n const hookName = `use${this.capitalize(name)}`;\n const resource = this.getResourceFromEndpoint(name, endpoint);\n const inferParams = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.params`,\n );\n const inferBody = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.body`,\n );\n const inferResponse = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.response`,\n );\n\n const resourceHasQueries = this.resourceHasQueryEndpoints(resource);\n\n let inputType: string;\n let fnBody: string;\n\n if (endpoint.params && endpoint.body) {\n inputType = `{ params: ${inferParams}; body: ${inferBody}; }`;\n fnBody = `({ params, body }: ${inputType}) => apiClient.${name}(params, body)`;\n } else if (endpoint.params) {\n inputType = `${inferParams}`;\n fnBody = `(params: ${inputType}) => apiClient.${name}(params)`;\n } else if (endpoint.body) {\n inputType = `${inferBody}`;\n fnBody = `(body: ${inputType}) => apiClient.${name}(body)`;\n } else {\n inputType = \"void\";\n fnBody = `() => apiClient.${name}()`;\n }\n\n const invalidate = resourceHasQueries\n ? `queryClient.invalidateQueries({ queryKey: queryKeys.${resource}.all });`\n : \"\";\n\n return `/**\n * ${endpoint.description || `Mutation hook for ${name}`}\n * @tags ${endpoint.tags?.join(\", \") || \"none\"}\n */\n export function ${hookName}(options?: {\n onSuccess?: (data: ${inferResponse}, variables: ${inputType}, context: unknown) => void;\n onError?: (error: Error, variables: ${inputType}, context: unknown) => void;\n onSettled?: (data: ${inferResponse} | undefined, error: Error | null, variables: ${inputType}, context: unknown) => void;\n onMutate?: (variables: ${inputType}) => Promise<unknown> | unknown;\n }) {\n ${invalidate ? \"const queryClient = useQueryClient();\" : \"\"}\n return useMutation({\n\tmutationFn: ${fnBody},\n\tonSuccess: (data, variables, context) => {\n\t ${invalidate}\n\t options?.onSuccess?.(data, variables, context);\n\t},\n\tonError: options?.onError,\n\tonSettled: options?.onSettled,\n\tonMutate: options?.onMutate,\n });\n }`;\n }\n}\n","import type { APIConfig, APIEndpoint } from \"@cushin/api-runtime\";\nimport type { ResolvedConfig } from \"../config/index.js\";\n\nexport interface GeneratorContext {\n config: ResolvedConfig;\n apiConfig: APIConfig;\n}\n\nexport abstract class BaseGenerator {\n constructor(protected context: GeneratorContext) {}\n\n abstract generate(): Promise<void>;\n\n protected isQueryEndpoint(endpoint: APIEndpoint): boolean {\n return endpoint.method === \"GET\";\n }\n\n protected isMutationEndpoint(endpoint: APIEndpoint): boolean {\n return !this.isQueryEndpoint(endpoint);\n }\n\n protected capitalize(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1);\n }\n\n protected getQueryTags(endpoint: APIEndpoint): string[] {\n return endpoint.tags || [];\n }\n\n protected getInvalidationTags(endpoint: APIEndpoint): string[] {\n const tags = endpoint.tags || [];\n return tags.filter((tag) => tag !== \"query\" && tag !== \"mutation\");\n }\n\n protected hasParams(endpoint: APIEndpoint): boolean {\n return !!endpoint.params;\n }\n\n protected hasQuery(endpoint: APIEndpoint): boolean {\n return !!endpoint.query;\n }\n\n protected hasBody(endpoint: APIEndpoint): boolean {\n return !!endpoint.body;\n }\n\n protected getEndpointSignature(\n name: string,\n endpoint: APIEndpoint,\n ): {\n hasParams: boolean;\n hasQuery: boolean;\n hasBody: boolean;\n paramType: string;\n queryType: string;\n bodyType: string;\n responseType: string;\n } {\n const hasParams = this.hasParams(endpoint);\n const hasQuery = this.hasQuery(endpoint);\n const hasBody = this.hasBody(endpoint);\n\n return {\n hasParams,\n hasQuery,\n hasBody,\n paramType: hasParams ? `ExtractParams<APIEndpoints['${name}']>` : \"never\",\n queryType: hasQuery ? `ExtractQuery<APIEndpoints['${name}']>` : \"never\",\n bodyType: hasBody ? `ExtractBody<APIEndpoints['${name}']>` : \"never\",\n responseType: `ExtractResponse<APIEndpoints['${name}']>`,\n };\n }\n\n protected generateMutationCall(\n name: string,\n hasParams: boolean,\n hasBody: boolean,\n ): string {\n if (hasParams && hasBody) {\n return `return apiClient.${name}(input.params, input.body);`;\n } else if (hasParams) {\n return `return apiClient.${name}(input);`;\n } else if (hasBody) {\n return `return apiClient.${name}(input);`;\n } else {\n return `return apiClient.${name}();`;\n }\n }\n\n protected inferNonNull(expr: string): string {\n return `z.infer<NonNullable<${expr}>>`;\n }\n\n protected toCamelCase(str: string): string {\n return str\n .toLowerCase()\n .replace(/[-_\\s]+(.)?/g, (_, c) => (c ? c.toUpperCase() : \"\"))\n .replace(/^./, (c) => c.toLowerCase());\n }\n\n protected getResourceFromEndpoint(\n _name: string,\n endpoint: APIEndpoint,\n ): string {\n const tag = endpoint.tags?.find((t) => t !== \"query\" && t !== \"mutation\");\n if (tag) return this.toCamelCase(tag);\n const match = endpoint.path.match(/^\\/([^/]+)/);\n return match ? this.toCamelCase(match[1]) : \"general\";\n }\n\n protected groupEndpointsByResource() {\n const groups: Record<\n string,\n Array<{ name: string; endpoint: APIEndpoint }>\n > = {};\n Object.entries(this.context.apiConfig.endpoints).forEach(\n ([name, endpoint]) => {\n const res = this.getResourceFromEndpoint(name, endpoint);\n if (!groups[res]) groups[res] = [];\n groups[res].push({ name, endpoint });\n },\n );\n return groups;\n }\n\n protected resourceHasQueryEndpoints(resource: string): boolean {\n return (\n this.groupEndpointsByResource()[resource]?.some(\n ({ endpoint }) => endpoint.method === \"GET\",\n ) ?? false\n );\n }\n\n protected getEndpointKeyName(name: string): string {\n return name.startsWith(\"get\")\n ? name[3].toLowerCase() + name.slice(4)\n : name;\n }\n\n protected generateQueryKeyCall(\n resource: string,\n name: string,\n endpoint: APIEndpoint,\n ): string {\n const key = this.getEndpointKeyName(name);\n const args: string[] = [];\n if (endpoint.params) args.push(\"params\");\n if (endpoint.query) args.push(\"filters\");\n return args.length\n ? `queryKeys.${resource}.${key}(${args.join(\", \")})`\n : `queryKeys.${resource}.${key}()`;\n }\n\n protected hasQueryOptions() {\n return Object.values(this.context.apiConfig.endpoints).some(\n (e) => e.method === \"GET\",\n );\n }\n}\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport { BaseGenerator } from \"./base.js\";\nimport type { APIEndpoint } from \"@cushin/api-runtime\";\n\nexport class ServerActionsGenerator extends BaseGenerator {\n async generate(): Promise<void> {\n const content = this.generateContent();\n const outputPath = path.join(this.context.config.outputDir, 'actions.ts');\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, 'utf-8');\n }\n\n private generateContent(): string {\n const imports = `'use server';\n\nimport { revalidateTag, revalidatePath } from 'next/cache';\nimport { serverClient } from './server-client';\nimport type { \n APIEndpoints, \n ExtractBody, \n ExtractParams, \n ExtractResponse \n} from './types';\n\nexport type ActionResult<T> = \n | { success: true; data: T }\n | { success: false; error: string };\n`;\n\n const actions: string[] = [];\n\n Object.entries(this.context.apiConfig.endpoints).forEach(([name, endpoint]) => {\n if (this.isMutationEndpoint(endpoint)) {\n actions.push(this.generateServerAction(name, endpoint));\n }\n });\n\n return imports + '\\n' + actions.join('\\n\\n');\n }\n\n private generateServerAction(name: string, endpoint: APIEndpoint): string {\n const actionSuffix = this.context.config.options?.actionSuffix || 'Action';\n const actionName = `${name}${actionSuffix}`;\n const signature = this.getEndpointSignature(name, endpoint);\n const invalidationTags = this.getInvalidationTags(endpoint);\n\n let inputType = '';\n let inputParam = '';\n if (signature.hasParams && signature.hasBody) {\n inputType = `input: { params: ${signature.paramType}; body: ${signature.bodyType} }`;\n inputParam = 'input';\n } else if (signature.hasParams) {\n inputType = `params: ${signature.paramType}`;\n inputParam = 'params';\n } else if (signature.hasBody) {\n inputType = `body: ${signature.bodyType}`;\n inputParam = 'body';\n }\n\n const revalidateStatements = invalidationTags.length > 0\n ? invalidationTags\n .map((tag) => ` revalidateTag('${tag}');`)\n .join('\\n')\n : ' // No automatic revalidations';\n\n return `/**\n * ${endpoint.description || `Server action for ${name}`}\n * @tags ${endpoint.tags?.join(', ') || 'none'}\n */\nexport async function ${actionName}(\n ${inputType}\n): Promise<ActionResult<${signature.responseType}>> {\n try {\n const result = await serverClient.${name}(${inputParam ? inputParam : ''});\n \n // Revalidate related data\n${revalidateStatements}\n \n return { success: true, data: result };\n } catch (error) {\n console.error('[Server Action Error]:', error);\n return { \n success: false, \n error: error instanceof Error ? error.message : 'Unknown error' \n };\n }\n}`;\n }\n}\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport { BaseGenerator } from \"./base.js\";\nimport type { APIEndpoint } from \"@cushin/api-runtime\";\n\nexport class ServerQueriesGenerator extends BaseGenerator {\n async generate(): Promise<void> {\n const content = this.generateContent();\n const outputPath = path.join(this.context.config.outputDir, \"queries.ts\");\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, \"utf-8\");\n }\n\n private generateContent(): string {\n const imports = `import { cache } from 'react';\nimport { unstable_cache } from 'next/cache';\nimport { serverClient } from './server-client';\nimport type { \n APIEndpoints, \n ExtractParams, \n ExtractQuery, \n ExtractResponse \n} from './types';\n`;\n\n const queries: string[] = [];\n\n Object.entries(this.context.apiConfig.endpoints).forEach(\n ([name, endpoint]) => {\n if (this.isQueryEndpoint(endpoint)) {\n queries.push(this.generateServerQuery(name, endpoint));\n }\n },\n );\n\n return imports + \"\\n\" + queries.join(\"\\n\\n\");\n }\n\n private generateServerQuery(name: string, endpoint: APIEndpoint): string {\n const queryName = `${name}Query`;\n const signature = this.getEndpointSignature(name, endpoint);\n const queryTags = this.getQueryTags(endpoint);\n\n const paramDef = signature.hasParams\n ? `params: ${signature.paramType}`\n : \"\";\n const queryDef = signature.hasQuery ? `query?: ${signature.queryType}` : \"\";\n const paramsList = [paramDef, queryDef].filter(Boolean).join(\",\\n \");\n\n const clientCallArgs: string[] = [];\n if (signature.hasParams) clientCallArgs.push(\"params\");\n if (signature.hasQuery) clientCallArgs.push(\"query\");\n\n // Generate cache key based on params\n const cacheKeyParts: string[] = [`'${name}'`];\n if (signature.hasParams) cacheKeyParts.push(\"JSON.stringify(params)\");\n if (signature.hasQuery) cacheKeyParts.push(\"JSON.stringify(query)\");\n\n return `/**\n * ${endpoint.description || `Server query for ${name}`}\n * @tags ${queryTags.join(\", \") || \"none\"}\n */\nexport const ${queryName} = cache(async (\n ${paramsList}\n): Promise<${signature.responseType}> => {\n return unstable_cache(\n async () => serverClient.${name}(${clientCallArgs.join(\", \")}),\n [${cacheKeyParts.join(\", \")}],\n {\n tags: [${queryTags.map((tag) => `'${tag}'`).join(\", \")}],\n revalidate: 3600, // 1 hour default, can be overridden\n }\n )();\n});`;\n }\n}\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport { BaseGenerator } from \"./base.js\";\n\nexport class TypesGenerator extends BaseGenerator {\n async generate(): Promise<void> {\n const content = this.generateContent();\n const outputPath = path.join(this.context.config.outputDir, \"types.ts\");\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, \"utf-8\");\n }\n\n private generateContent(): string {\n const outputPath = path.join(this.context.config.outputDir, \"types.ts\");\n const endpointsPath = path.join(this.context.config.endpointsPath);\n const relativePath = path\n .relative(path.dirname(outputPath), endpointsPath)\n .replace(/\\\\/g, \"/\");\n return `// Auto-generated type definitions\n// Do not edit this file manually\n\nimport type { z } from 'zod';\nimport { apiConfig } from '${relativePath}';\n\n\n// Re-export endpoint configuration types\nexport type { APIConfig, APIEndpoint, HTTPMethod } from '@cushin/api-runtime';\n\n/**\n * Type helper to extract params schema from an endpoint\n */\nexport type ExtractParams<T> = T extends { params: infer P extends z.ZodType }\n ? z.infer<P>\n : never;\n\n/**\n * Type helper to extract query schema from an endpoint\n */\nexport type ExtractQuery<T> = T extends { query: infer Q extends z.ZodType }\n ? z.infer<Q>\n : never;\n\n/**\n * Type helper to extract body schema from an endpoint\n */\nexport type ExtractBody<T> = T extends { body: infer B extends z.ZodType }\n ? z.infer<B>\n : never;\n\n/**\n * Type helper to extract response schema from an endpoint\n */\nexport type ExtractResponse<T> = T extends { response: infer R extends z.ZodType }\n ? z.infer<R>\n : never;\n\n/**\n * Import your API config to get typed endpoints\n * \n */\nexport type APIEndpoints = typeof apiConfig.endpoints;\n\n${this.generateEndpointTypes()}\n`;\n }\n\n private generateEndpointTypes(): string {\n const types: string[] = [];\n\n Object.entries(this.context.apiConfig.endpoints).forEach(\n ([name, endpoint]) => {\n const cap = this.capitalize(name);\n if (endpoint.response)\n types.push(\n `export type ${cap}Response = ${this.inferNonNull(`typeof apiConfig.endpoints.${name}.response`)};`,\n );\n if (endpoint.body)\n types.push(\n `export type ${cap}Input = ${this.inferNonNull(`typeof apiConfig.endpoints.${name}.body`)};`,\n );\n if (endpoint.query)\n types.push(\n `export type ${cap}Query = ${this.inferNonNull(`typeof apiConfig.endpoints.${name}.query`)};`,\n );\n if (endpoint.params)\n types.push(\n `export type ${cap}Params = ${this.inferNonNull(`typeof apiConfig.endpoints.${name}.params`)};`,\n );\n },\n );\n\n return types.join(\"\\n\");\n }\n}\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport { BaseGenerator } from \"./base.js\";\n\nexport class ClientGenerator extends BaseGenerator {\n async generate(): Promise<void> {\n await this.generateClientFile();\n\n if (this.context.config.provider === \"nextjs\") {\n await this.generateServerClientFile();\n }\n }\n\n private async generateClientFile(): Promise<void> {\n const content = this.generateClientContent();\n const outputPath = path.join(this.context.config.outputDir, \"client.ts\");\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, \"utf-8\");\n }\n\n private async generateServerClientFile(): Promise<void> {\n const content = this.generateServerClientContent();\n const outputPath = path.join(\n this.context.config.outputDir,\n \"server-client.ts\",\n );\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, \"utf-8\");\n }\n\n private generateClientContent(): string {\n const useClientDirective =\n this.context.config.options?.useClientDirective ?? true;\n const outputPath = path.join(this.context.config.outputDir, \"types.ts\");\n const endpointsPath = path.join(this.context.config.endpointsPath);\n const relativePath = path\n .relative(path.dirname(outputPath), endpointsPath)\n .replace(/\\\\/g, \"/\");\n\n return `${useClientDirective ? \"'use client';\\n\" : \"\"}\nimport { createAPIClient } from '@cushin/api-runtime';\nimport type { AuthCallbacks } from '@cushin/api-runtime';\nimport { apiConfig } from '${relativePath}';\nimport { z } from 'zod';\n\n// Type the methods based on endpoints\ntype APIClientMethods = {\n [K in keyof typeof apiConfig.endpoints]: (typeof apiConfig.endpoints)[K] extends {\n method: infer M;\n params?: infer P;\n query?: infer Q;\n body?: infer B;\n response: infer R;\n }\n ? M extends \"GET\"\n ? P extends z.ZodJSONSchema\n ? Q extends z.ZodJSONSchema\n ? (params: z.infer<P>, query?: z.infer<Q>) => Promise<z.infer<R>>\n : (params: z.infer<P>) => Promise<z.infer<R>>\n : Q extends z.ZodJSONSchema\n ? (query?: z.infer<Q>) => Promise<z.infer<R>>\n : () => Promise<z.infer<R>>\n : P extends z.ZodJSONSchema\n ? B extends z.ZodJSONSchema\n ? (params: z.infer<P>, body: z.infer<B>) => Promise<z.infer<R>>\n : (params: z.infer<P>) => Promise<z.infer<R>>\n : B extends z.ZodJSONSchema\n ? (body: z.infer<B>) => Promise<z.infer<R>>\n : () => Promise<z.infer<R>>\n : never;\n};\n\n\n// Export singleton instance (will be initialized later)\nexport let baseClient: APIClientMethods & {\n refreshAuth: () => Promise<void>;\n updateAuthCallbacks: (callbacks: AuthCallbacks) => void;\n};\n\nexport const apiClient = {\n${this.generateApiClientMethods()}\n};\n\n/**\n * Initialize API client with auth callbacks\n * Call this function in your auth provider setup\n * \n * @example\n * const authCallbacks = {\n * getTokens: () => getStoredTokens(),\n * onAuthError: () => router.push('/login'),\n * onRefreshToken: async () => {\n * await refreshAccessToken();\n * },\n * };\n * \n * initializeAPIClient(authCallbacks);\n */\nexport const initializeAPIClient = (authCallbacks: AuthCallbacks) => {\n baseClient = createAPIClient(apiConfig, authCallbacks) as any;\n return baseClient;\n};\n\n// Export for custom usage\nexport { createAPIClient };\nexport type { AuthCallbacks };\n`;\n }\n\n private generateServerClientContent(): string {\n return `import { createAPIClient } from './core';\nimport { apiConfig } from '../config/endpoints';\nimport type { APIEndpoints } from './types';\n\n// Type-safe API client methods for server-side\ntype APIClientMethods = {\n [K in keyof APIEndpoints]: APIEndpoints[K] extends {\n method: infer M;\n params?: infer P;\n query?: infer Q;\n body?: infer B;\n response: infer R;\n }\n ? M extends 'GET'\n ? P extends { _type: any }\n ? Q extends { _type: any }\n ? (params: P['_type'], query?: Q['_type']) => Promise<R['_type']>\n : (params: P['_type']) => Promise<R['_type']>\n : Q extends { _type: any }\n ? (query?: Q['_type']) => Promise<R['_type']>\n : () => Promise<R['_type']>\n : P extends { _type: any }\n ? B extends { _type: any }\n ? (params: P['_type'], body: B['_type']) => Promise<R['_type']>\n : (params: P['_type']) => Promise<R['_type']>\n : B extends { _type: any }\n ? (body: B['_type']) => Promise<R['_type']>\n : () => Promise<R['_type']>\n : never;\n};\n\n/**\n * Server-side API client (no auth, direct API calls)\n * Use this in Server Components, Server Actions, and Route Handlers\n */\nexport const serverClient = createAPIClient(apiConfig) as APIClientMethods;\n`;\n }\n\n private generateApiClientMethods(): string {\n const methods: string[] = [];\n\n Object.entries(this.context.apiConfig.endpoints).forEach(\n ([name, endpoint]) => {\n const inferParams = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.params`,\n );\n const inferQuery = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.query`,\n );\n const inferBody = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.body`,\n );\n const inferResponse = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.response`,\n );\n\n if (endpoint.method === \"GET\") {\n if (endpoint.params && endpoint.query) {\n methods.push(` ${name}: (params: ${inferParams}, query?: ${inferQuery}): Promise<${inferResponse}> => \n (baseClient as any).${name}(params, query),`);\n } else if (endpoint.params) {\n methods.push(` ${name}: (params: ${inferParams}): Promise<${inferResponse}> => \n (baseClient as any).${name}(params),`);\n } else if (endpoint.query) {\n methods.push(` ${name}: (query?: ${inferQuery}): Promise<${inferResponse}> => \n (baseClient as any).${name}(query),`);\n } else {\n methods.push(` ${name}: (): Promise<${inferResponse}> => \n (baseClient as any).${name}(),`);\n }\n } else {\n if (endpoint.params && endpoint.body) {\n methods.push(` ${name}: (params: ${inferParams}, body: ${inferBody}): Promise<${inferResponse}> => \n (baseClient as any).${name}(params, body),`);\n } else if (endpoint.params) {\n methods.push(` ${name}: (params: ${inferParams}): Promise<${inferResponse}> => \n (baseClient as any).${name}(params),`);\n } else if (endpoint.body) {\n methods.push(` ${name}: (body: ${inferBody}): Promise<${inferResponse}> => \n (baseClient as any).${name}(body),`);\n } else {\n methods.push(` ${name}: (): Promise<${inferResponse}> => \n (baseClient as any).${name}(),`);\n }\n }\n },\n );\n\n return methods.join(\"\\n\");\n }\n}\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport { BaseGenerator } from \"./base.js\";\n\nexport class QueryKeysGenerator extends BaseGenerator {\n async generate(): Promise<void> {\n const content = this.generateContent();\n const outputPath = path.join(\n this.context.config.outputDir,\n \"query-keys.ts\",\n );\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, \"utf-8\");\n }\n\n private generateContent(): string {\n const outputPath = path.join(this.context.config.outputDir, \"types.ts\");\n const endpointsPath = path.join(this.context.config.endpointsPath);\n const relativePath = path\n .relative(path.dirname(outputPath), endpointsPath)\n .replace(/\\\\/g, \"/\");\n const content = `// Auto-generated query keys\nimport { z } from 'zod';\nimport { apiConfig } from '${relativePath}';\n\nexport const queryKeys = {\n${this.generateQueryKeysContent()}\n} as const;\n`;\n return content;\n }\n\n private generateQueryKeysContent(): string {\n const resourceGroups = this.groupEndpointsByResource();\n const keys: string[] = [];\n\n Object.entries(resourceGroups).forEach(([resource, endpoints]) => {\n const queryEndpoints = endpoints.filter(\n ({ endpoint }) => endpoint.method === \"GET\",\n );\n if (queryEndpoints.length === 0) return;\n\n const resourceKeys: string[] = [` all: ['${resource}'] as const,`];\n const added = new Set<string>();\n\n queryEndpoints.forEach(({ name, endpoint }) => {\n const keyName = this.getEndpointKeyName(name);\n if (added.has(keyName)) return;\n const inferParams = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.params`,\n );\n const inferQuery = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.query`,\n );\n\n if (endpoint.params || endpoint.query) {\n const params: string[] = [];\n if (endpoint.params) params.push(`params?: ${inferParams}`);\n if (endpoint.query) params.push(`query?: ${inferQuery}`);\n\n resourceKeys.push(` ${keyName}: (${params.join(\", \")}) =>\n ['${resource}', '${keyName}', ${endpoint.params ? \"params\" : \"undefined\"}, ${endpoint.query ? \"query\" : \"undefined\"}] as const,`);\n } else {\n resourceKeys.push(\n ` ${keyName}: () => ['${resource}', '${keyName}'] as const,`,\n );\n }\n added.add(keyName);\n });\n\n keys.push(` ${resource}: {\\n${resourceKeys.join(\"\\n\")}\\n },`);\n });\n\n return keys.join(\"\\n\");\n }\n}\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport { BaseGenerator } from \"./base.js\";\n\nexport class QueryOptionsGenerator extends BaseGenerator {\n async generate(): Promise<void> {\n const content = this.generateContent();\n const outputPath = path.join(\n this.context.config.outputDir,\n \"query-options.ts\",\n );\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, \"utf-8\");\n }\n private generateContent(): string {\n const outputPath = path.join(this.context.config.outputDir, \"types.ts\");\n const endpointsPath = path.join(this.context.config.endpointsPath);\n const relativePath = path\n .relative(path.dirname(outputPath), endpointsPath)\n .replace(/\\\\/g, \"/\");\n const content = `// Auto-generated query options\nimport { queryOptions } from '@tanstack/react-query';\nimport { apiClient } from './client';\nimport { queryKeys } from './query-keys';\nimport { z } from 'zod';\nimport { apiConfig } from '${relativePath}';\n\n${this.generateQueryOptionsContent()}\n\nexport const apiQueryOptions = {\n${this.generateQueryOptionsExports()}\n} as const;\n`;\n\n return content;\n }\n\n private generateQueryOptionsContent(): string {\n const groups = this.groupEndpointsByResource();\n const options: string[] = [];\n\n Object.entries(groups).forEach(([resource, endpoints]) => {\n const queries = endpoints.filter(\n ({ endpoint }) => endpoint.method === \"GET\",\n );\n if (queries.length === 0) return;\n\n const resourceOptions: string[] = [];\n queries.forEach(({ name, endpoint }) => {\n const optionName = this.getEndpointKeyName(name);\n const inferParams = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.params`,\n );\n const inferQuery = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.query`,\n );\n const inferResponse = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.response`,\n );\n\n const params: string[] = [];\n let apiCall = \"\";\n\n if (endpoint.params && endpoint.query) {\n params.push(`params: ${inferParams}`, `filters?: ${inferQuery}`);\n apiCall = `apiClient.${name}(params, filters)`;\n } else if (endpoint.params) {\n params.push(`params: ${inferParams}`);\n apiCall = `apiClient.${name}(params)`;\n } else if (endpoint.query) {\n params.push(`filters?: ${inferQuery}`);\n apiCall = `apiClient.${name}(filters)`;\n } else {\n apiCall = `apiClient.${name}()`;\n }\n\n const keyCall = this.generateQueryKeyCall(resource, name, endpoint);\n\n resourceOptions.push(` ${optionName}: (${params.join(\", \")}) =>\n queryOptions({\n queryKey: ${keyCall},\n queryFn: (): Promise<${inferResponse}> => ${apiCall},\n staleTime: 1000 * 60 * 5,\n }),`);\n });\n\n options.push(\n `const ${resource}QueryOptions = {\\n${resourceOptions.join(\"\\n\")}\\n};\\n`,\n );\n });\n\n return options.join(\"\\n\");\n }\n\n private generateQueryOptionsExports(): string {\n const groups = this.groupEndpointsByResource();\n const exports: string[] = [];\n\n Object.keys(groups).forEach((resource) => {\n const hasQueries = groups[resource].some(\n ({ endpoint }) => endpoint.method === \"GET\",\n );\n if (hasQueries) exports.push(` ${resource}: ${resource}QueryOptions,`);\n });\n\n return exports.join(\"\\n\");\n }\n}\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport { BaseGenerator } from \"./base.js\";\nimport type { APIEndpoint } from \"@cushin/api-runtime\";\n\nexport class PrefetchGenerator extends BaseGenerator {\n async generate(): Promise<void> {\n const content = this.generateContent();\n const outputPath = path.join(this.context.config.outputDir, \"prefetchs.ts\");\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, \"utf-8\");\n }\n\n private generateContent(): string {\n const content = `// Auto-generated prefetch utilities\nimport { type QueryClient } from '@tanstack/react-query';\n${this.hasQueryOptions() ? \"import { apiQueryOptions } from './query-options';\" : \"\"}\nimport { z } from 'zod';\nimport { apiConfig } from '../config/endpoints';\n\n${this.generatePrefetchFunctions()}\n`;\n return content;\n }\n\n private generatePrefetchFunctions(): string {\n const funcs: string[] = [];\n Object.entries(this.context.apiConfig.endpoints).forEach(\n ([name, endpoint]) => {\n if (endpoint.method === \"GET\")\n funcs.push(this.generatePrefetchFunction(name, endpoint));\n },\n );\n return funcs.join(\"\\n\\n\");\n }\n\n private generatePrefetchFunction(\n name: string,\n endpoint: APIEndpoint,\n ): string {\n const prefetchName = `prefetch${this.capitalize(name)}`;\n const resource = this.getResourceFromEndpoint(name, endpoint);\n const optionName = this.getEndpointKeyName(name);\n const inferParams = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.params`,\n );\n const inferQuery = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.query`,\n );\n\n const params: string[] = [\"queryClient: QueryClient\"];\n const optionParams: string[] = [];\n\n if (endpoint.params) {\n params.push(`params: ${inferParams}`);\n optionParams.push(\"params\");\n }\n if (endpoint.query) {\n params.push(`filters?: ${inferQuery}`);\n optionParams.push(\"filters\");\n }\n\n return `export const ${prefetchName} = async (${params.join(\",\\n \")}) => {\n return await queryClient.ensureQueryData(apiQueryOptions.${resource}.${optionName}(${optionParams.join(\", \")}));\n};`;\n }\n}\n","import { HooksGenerator } from \"./hooks.js\";\nimport { ServerActionsGenerator } from \"./actions.js\";\nimport { ServerQueriesGenerator } from \"./queries.js\";\nimport { TypesGenerator } from \"./types.js\";\nimport { ClientGenerator } from \"./client.js\";\nimport type { GeneratorContext } from \"./base.js\";\nimport { QueryKeysGenerator } from \"./query-keys.js\";\nimport { QueryOptionsGenerator } from \"./query-options.js\";\nimport { PrefetchGenerator } from \"./prefetch.js\";\n\nexport class CodeGenerator {\n constructor(private context: GeneratorContext) {}\n\n async generate(): Promise<void> {\n const generators = this.getGenerators();\n\n for (const generator of generators) {\n await generator.generate();\n }\n }\n\n private getGenerators() {\n const generators: Array<any> = [];\n\n // Always generate types\n generators.push(new TypesGenerator(this.context));\n\n // Generate client if enabled\n if (this.context.config.generateClient) {\n generators.push(new ClientGenerator(this.context));\n }\n\n // Generate hooks if enabled\n if (this.context.config.generateHooks) {\n generators.push(new QueryKeysGenerator(this.context));\n generators.push(new QueryOptionsGenerator(this.context));\n generators.push(new HooksGenerator(this.context));\n }\n\n if (this.context.config.generatePrefetch) {\n generators.push(new PrefetchGenerator(this.context));\n }\n\n // Generate server actions if enabled (Next.js only)\n if (\n this.context.config.generateServerActions &&\n this.context.config.provider === \"nextjs\"\n ) {\n generators.push(new ServerActionsGenerator(this.context));\n }\n\n // Generate server queries if enabled (Next.js only)\n if (\n this.context.config.generateServerQueries &&\n this.context.config.provider === \"nextjs\"\n ) {\n generators.push(new ServerQueriesGenerator(this.context));\n }\n\n return generators;\n }\n}\n"],"mappings":";AACA,cAAc;;;ACDd,SAAS,mBAAmB;AAC5B,OAAO,UAAU;AA4FjB,IAAM,WAAW,YAAY,eAAe;AAAA,EAC1C,cAAc;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF,CAAC;AAED,eAAsB,WACpB,YACgC;AAChC,MAAI;AACF,UAAM,SAAS,aACX,MAAM,SAAS,KAAK,UAAU,IAC9B,MAAM,SAAS,OAAO;AAE1B,QAAI,CAAC,UAAU,CAAC,OAAO,QAAQ;AAC7B,aAAO;AAAA,IACT;AAEA,UAAM,aAAa,OAAO;AAC1B,UAAM,UAAU,KAAK,QAAQ,OAAO,QAAQ;AAG5C,UAAM,gBAAgB,KAAK,QA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","path","path","fs","fs","path","path","fs","fs","path","path","fs","fs","path","path","fs","fs","path","path","fs"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/config/index.ts","../src/core/codegen.ts","../src/generators/hooks.ts","../src/generators/base.ts","../src/generators/actions.ts","../src/generators/queries.ts","../src/generators/types.ts","../src/generators/client.ts","../src/generators/query-keys.ts","../src/generators/query-options.ts","../src/generators/prefetch.ts","../src/generators/generate-index.ts","../src/generators/index.ts"],"sourcesContent":["// Re-export runtime types from @cushin/api-runtime\nexport * from \"@cushin/api-runtime\";\n\n// Export config types and utilities\nexport * from \"./config/index.js\";\n\n// Export codegen utilities\nexport { CodegenCore } from \"./core/codegen.js\";\nexport { CodeGenerator } from \"./generators/index.js\";\n","import { cosmiconfig } from \"cosmiconfig\";\nimport path from \"path\";\nimport type { APIConfig } from \"@cushin/api-runtime\";\n\nexport interface UserConfig {\n /**\n * Base URL for API requests\n */\n baseUrl?: string;\n\n /**\n * Path to the endpoints configuration file\n */\n endpoints: string;\n\n /**\n * Provider type: 'vite' | 'nextjs'\n */\n provider: \"vite\" | \"nextjs\";\n\n /**\n * Output directory for generated files\n */\n output: string;\n\n /**\n * Whether to generate React Query hooks (for client-side)\n * @default true for vite, nextjs\n */\n generateHooks?: boolean;\n\n /**\n * Whether to generate server actions (Next.js only)\n * @default true for nextjs, false for vite\n */\n generateServerActions?: boolean;\n\n /**\n * Whether to generate server queries (Next.js only)\n * @default true for nextjs, false for vite\n */\n generateServerQueries?: boolean;\n\n /**\n * Whether to generate API client\n * @default true\n */\n generateClient?: boolean;\n\n /**\n * Whether to generate prefetch utilities\n * @default true\n */\n generatePrefetch?: boolean;\n\n /**\n * Custom templates directory\n */\n templatesDir?: string;\n\n /**\n * Additional options\n */\n options?: {\n /**\n * Use 'use client' directive\n */\n useClientDirective?: boolean;\n\n /**\n * Custom imports to add to generated files\n */\n customImports?: Record<string, string[]>;\n\n /**\n * Prefix for generated hook names\n */\n hookPrefix?: string;\n\n /**\n * Suffix for generated action names\n */\n actionSuffix?: string;\n };\n}\n\nexport interface ResolvedConfig extends UserConfig {\n rootDir: string;\n endpointsPath: string;\n outputDir: string;\n apiConfig?: APIConfig;\n}\n\nconst explorer = cosmiconfig(\"api-codegen\", {\n searchPlaces: [\n \"api-codegen.config.js\",\n \"api-codegen.config.mjs\",\n \"api-codegen.config.ts\",\n \"api-codegen.config.json\",\n \".api-codegenrc\",\n \".api-codegenrc.json\",\n \".api-codegenrc.js\",\n ],\n});\n\nexport async function loadConfig(\n configPath?: string,\n): Promise<ResolvedConfig | null> {\n try {\n const result = configPath\n ? await explorer.load(configPath)\n : await explorer.search();\n\n if (!result || !result.config) {\n return null;\n }\n\n const userConfig = result.config as UserConfig;\n const rootDir = path.dirname(result.filepath);\n\n // Resolve paths\n const endpointsPath = path.resolve(rootDir, userConfig.endpoints);\n const outputDir = path.resolve(rootDir, userConfig.output);\n\n // Set defaults based on provider\n const generateHooks = userConfig.generateHooks ?? true;\n const generateServerActions =\n userConfig.generateServerActions ?? userConfig.provider === \"nextjs\";\n const generateServerQueries =\n userConfig.generateServerQueries ?? userConfig.provider === \"nextjs\";\n const generateClient = userConfig.generateClient ?? true;\n const generatePrefetch = userConfig.generatePrefetch ?? true;\n\n return {\n ...userConfig,\n rootDir,\n endpointsPath,\n outputDir,\n generateHooks,\n generateServerActions,\n generateServerQueries,\n generateClient,\n generatePrefetch,\n };\n } catch (error) {\n throw new Error(\n `Failed to load config: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n}\n\n/**\n * Validate user config\n */\nexport function validateConfig(config: UserConfig): void {\n if (!config.endpoints) {\n throw new Error('Config error: \"endpoints\" path is required');\n }\n\n if (!config.provider) {\n throw new Error(\n 'Config error: \"provider\" must be specified (vite or nextjs)',\n );\n }\n\n if (![\"vite\", \"nextjs\"].includes(config.provider)) {\n throw new Error(\n 'Config error: \"provider\" must be either \"vite\" or \"nextjs\"',\n );\n }\n\n if (!config.output) {\n throw new Error('Config error: \"output\" directory is required');\n }\n}\n","import { createJiti } from \"jiti\";\nimport type { APIConfig } from \"@cushin/api-runtime\";\nimport type { ResolvedConfig } from \"../config/index.js\";\nimport { CodeGenerator } from \"../generators/index.js\";\nimport { fileURLToPath } from \"url\";\n\nexport class CodegenCore {\n constructor(private config: ResolvedConfig) {}\n\n async execute(): Promise<void> {\n // Load API configuration\n const apiConfig = await this.loadAPIConfig();\n\n // Store in config for generators\n this.config.apiConfig = apiConfig;\n\n // Generate code\n const generator = new CodeGenerator({\n config: this.config,\n apiConfig,\n });\n\n await generator.generate();\n }\n\n private async loadAPIConfig(): Promise<APIConfig> {\n try {\n // Use jiti to load TypeScript files\n const jiti = createJiti(fileURLToPath(import.meta.url), {\n interopDefault: true,\n });\n\n const module = (await jiti.import(this.config.endpointsPath)) as any;\n\n // Try different export patterns\n const apiConfig =\n module.apiConfig ||\n module.default?.apiConfig ||\n module.default ||\n module;\n\n if (!apiConfig || !apiConfig.endpoints) {\n throw new Error(\n 'Invalid API config: must export an object with \"endpoints\" property',\n );\n }\n\n return apiConfig;\n } catch (error) {\n throw new Error(\n `Failed to load endpoints from \"${this.config.endpointsPath}\": ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n }\n }\n}\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport { BaseGenerator } from \"./base.js\";\nimport type { APIEndpoint } from \"@cushin/api-runtime\";\n\nexport class HooksGenerator extends BaseGenerator {\n async generate(): Promise<void> {\n const content = this.generateContent();\n const outputPath = path.join(this.context.config.outputDir, \"hooks.ts\");\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, \"utf-8\");\n }\n\n private generateContent(): string {\n const useClientDirective =\n this.context.config.options?.useClientDirective ?? true;\n const outputPath = path.join(this.context.config.outputDir, \"types.ts\");\n const endpointsPath = path.join(this.context.config.endpointsPath);\n const relativePath = path\n .relative(path.dirname(outputPath), endpointsPath)\n .replace(/\\\\/g, \"/\");\n\n const content = `${useClientDirective ? \"'use client';\\n\" : \"\"}\nimport { useQuery, useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport { apiClient } from \"./client\";\nimport { queryKeys } from \"./query-keys\";\nimport { apiQueryOptions } from \"./query-options\";\nimport { z } from \"zod\";\nimport { apiConfig } from \"${relativePath}\";\n\n${this.generateQueryHooks()}\n${this.generateMutationHooks()}\n`;\n\n return content;\n }\n\n private generateQueryHooks(): string {\n const hooks: string[] = [];\n Object.entries(this.context.apiConfig.endpoints).forEach(\n ([name, endpoint]) => {\n if (endpoint.method === \"GET\")\n hooks.push(this.generateQueryHook(name, endpoint));\n },\n );\n return hooks.join(\"\\n\\n\");\n }\n\n private generateQueryHook(name: string, endpoint: APIEndpoint): string {\n const hookName = `use${this.capitalize(name)}`;\n const resource = this.getResourceFromEndpoint(name, endpoint);\n const optionName = this.getEndpointKeyName(name);\n const inferParams = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.params`,\n );\n const inferQuery = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.query`,\n );\n const inferResponse = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.response`,\n );\n\n const params: string[] = [];\n const optionParams: string[] = [];\n\n const queryTags = this.getQueryTags(endpoint);\n\n if (endpoint.params) {\n params.push(`params: ${inferParams}`);\n optionParams.push(\"params\");\n }\n if (endpoint.query) {\n params.push(`filters?: ${inferQuery}`);\n optionParams.push(\"filters\");\n }\n\n params.push(`options?: {\n enabled?: boolean;\n select?: <TData = ${inferResponse}>(data: ${inferResponse}) => TData;\n }`);\n\n return `/**\n * ${endpoint.description || `Query hook for ${name}`}\n * @tags ${queryTags.join(\", \") || \"none\"}\n */\nexport function ${hookName}(${params.join(\",\\n \")}) {\n return useQuery({\n ...apiQueryOptions.${resource}.${optionName}(${optionParams.join(\", \")}),\n ...options,\n });\n}`;\n }\n\n private generateMutationHooks(): string {\n const hooks: string[] = [];\n Object.entries(this.context.apiConfig.endpoints).forEach(\n ([name, endpoint]) => {\n if (endpoint.method !== \"GET\")\n hooks.push(this.generateMutationHook(name, endpoint));\n },\n );\n return hooks.join(\"\\n\\n\");\n }\n\n private generateMutationHook(name: string, endpoint: APIEndpoint): string {\n const hookName = `use${this.capitalize(name)}`;\n const resource = this.getResourceFromEndpoint(name, endpoint);\n const inferParams = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.params`,\n );\n const inferBody = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.body`,\n );\n const inferResponse = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.response`,\n );\n\n const resourceHasQueries = this.resourceHasQueryEndpoints(resource);\n\n let inputType: string;\n let fnBody: string;\n\n if (endpoint.params && endpoint.body) {\n inputType = `{ params: ${inferParams}; body: ${inferBody}; }`;\n fnBody = `({ params, body }: ${inputType}) => apiClient.${name}(params, body)`;\n } else if (endpoint.params) {\n inputType = `${inferParams}`;\n fnBody = `(params: ${inputType}) => apiClient.${name}(params)`;\n } else if (endpoint.body) {\n inputType = `${inferBody}`;\n fnBody = `(body: ${inputType}) => apiClient.${name}(body)`;\n } else {\n inputType = \"void\";\n fnBody = `() => apiClient.${name}()`;\n }\n\n const invalidate = resourceHasQueries\n ? `queryClient.invalidateQueries({ queryKey: queryKeys.${resource}.all });`\n : \"\";\n\n return `/**\n * ${endpoint.description || `Mutation hook for ${name}`}\n * @tags ${endpoint.tags?.join(\", \") || \"none\"}\n */\n export function ${hookName}(options?: {\n onSuccess?: (data: ${inferResponse}, variables: ${inputType}, context: unknown) => void;\n onError?: (error: Error, variables: ${inputType}, context: unknown) => void;\n onSettled?: (data: ${inferResponse} | undefined, error: Error | null, variables: ${inputType}, context: unknown) => void;\n onMutate?: (variables: ${inputType}) => Promise<unknown> | unknown;\n }) {\n ${invalidate ? \"const queryClient = useQueryClient();\" : \"\"}\n return useMutation({\n\tmutationFn: ${fnBody},\n\tonSuccess: (data, variables, context) => {\n\t ${invalidate}\n\t options?.onSuccess?.(data, variables, context);\n\t},\n\tonError: options?.onError,\n\tonSettled: options?.onSettled,\n\tonMutate: options?.onMutate,\n });\n }`;\n }\n}\n","import type { APIConfig, APIEndpoint } from \"@cushin/api-runtime\";\nimport type { ResolvedConfig } from \"../config/index.js\";\n\nexport interface GeneratorContext {\n config: ResolvedConfig;\n apiConfig: APIConfig;\n}\n\nexport abstract class BaseGenerator {\n constructor(protected context: GeneratorContext) {}\n\n abstract generate(): Promise<void>;\n\n protected isQueryEndpoint(endpoint: APIEndpoint): boolean {\n return endpoint.method === \"GET\";\n }\n\n protected isMutationEndpoint(endpoint: APIEndpoint): boolean {\n return !this.isQueryEndpoint(endpoint);\n }\n\n protected capitalize(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1);\n }\n\n protected getQueryTags(endpoint: APIEndpoint): string[] {\n return endpoint.tags || [];\n }\n\n protected getInvalidationTags(endpoint: APIEndpoint): string[] {\n const tags = endpoint.tags || [];\n return tags.filter((tag) => tag !== \"query\" && tag !== \"mutation\");\n }\n\n protected hasParams(endpoint: APIEndpoint): boolean {\n return !!endpoint.params;\n }\n\n protected hasQuery(endpoint: APIEndpoint): boolean {\n return !!endpoint.query;\n }\n\n protected hasBody(endpoint: APIEndpoint): boolean {\n return !!endpoint.body;\n }\n\n protected getEndpointSignature(\n name: string,\n endpoint: APIEndpoint,\n ): {\n hasParams: boolean;\n hasQuery: boolean;\n hasBody: boolean;\n paramType: string;\n queryType: string;\n bodyType: string;\n responseType: string;\n } {\n const hasParams = this.hasParams(endpoint);\n const hasQuery = this.hasQuery(endpoint);\n const hasBody = this.hasBody(endpoint);\n\n return {\n hasParams,\n hasQuery,\n hasBody,\n paramType: hasParams ? `ExtractParams<APIEndpoints['${name}']>` : \"never\",\n queryType: hasQuery ? `ExtractQuery<APIEndpoints['${name}']>` : \"never\",\n bodyType: hasBody ? `ExtractBody<APIEndpoints['${name}']>` : \"never\",\n responseType: `ExtractResponse<APIEndpoints['${name}']>`,\n };\n }\n\n protected generateMutationCall(\n name: string,\n hasParams: boolean,\n hasBody: boolean,\n ): string {\n if (hasParams && hasBody) {\n return `return apiClient.${name}(input.params, input.body);`;\n } else if (hasParams) {\n return `return apiClient.${name}(input);`;\n } else if (hasBody) {\n return `return apiClient.${name}(input);`;\n } else {\n return `return apiClient.${name}();`;\n }\n }\n\n protected inferNonNull(expr: string): string {\n return `z.infer<NonNullable<${expr}>>`;\n }\n\n protected toCamelCase(str: string): string {\n return str\n .toLowerCase()\n .replace(/[-_\\s]+(.)?/g, (_, c) => (c ? c.toUpperCase() : \"\"))\n .replace(/^./, (c) => c.toLowerCase());\n }\n\n protected getResourceFromEndpoint(\n _name: string,\n endpoint: APIEndpoint,\n ): string {\n const tag = endpoint.tags?.find((t) => t !== \"query\" && t !== \"mutation\");\n if (tag) return this.toCamelCase(tag);\n const match = endpoint.path.match(/^\\/([^/]+)/);\n return match ? this.toCamelCase(match[1]) : \"general\";\n }\n\n protected groupEndpointsByResource() {\n const groups: Record<\n string,\n Array<{ name: string; endpoint: APIEndpoint }>\n > = {};\n Object.entries(this.context.apiConfig.endpoints).forEach(\n ([name, endpoint]) => {\n const res = this.getResourceFromEndpoint(name, endpoint);\n if (!groups[res]) groups[res] = [];\n groups[res].push({ name, endpoint });\n },\n );\n return groups;\n }\n\n protected resourceHasQueryEndpoints(resource: string): boolean {\n return (\n this.groupEndpointsByResource()[resource]?.some(\n ({ endpoint }) => endpoint.method === \"GET\",\n ) ?? false\n );\n }\n\n protected getEndpointKeyName(name: string): string {\n return name.startsWith(\"get\")\n ? name[3].toLowerCase() + name.slice(4)\n : name;\n }\n\n protected generateQueryKeyCall(\n resource: string,\n name: string,\n endpoint: APIEndpoint,\n ): string {\n const key = this.getEndpointKeyName(name);\n const args: string[] = [];\n if (endpoint.params) args.push(\"params\");\n if (endpoint.query) args.push(\"filters\");\n return args.length\n ? `queryKeys.${resource}.${key}(${args.join(\", \")})`\n : `queryKeys.${resource}.${key}()`;\n }\n\n protected hasQueryOptions() {\n return Object.values(this.context.apiConfig.endpoints).some(\n (e) => e.method === \"GET\",\n );\n }\n}\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport { BaseGenerator } from \"./base.js\";\nimport type { APIEndpoint } from \"@cushin/api-runtime\";\n\nexport class ServerActionsGenerator extends BaseGenerator {\n async generate(): Promise<void> {\n const content = this.generateContent();\n const outputPath = path.join(this.context.config.outputDir, 'actions.ts');\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, 'utf-8');\n }\n\n private generateContent(): string {\n const imports = `'use server';\n\nimport { revalidateTag, revalidatePath } from 'next/cache';\nimport { serverClient } from './server-client';\nimport type { \n APIEndpoints, \n ExtractBody, \n ExtractParams, \n ExtractResponse \n} from './types';\n\nexport type ActionResult<T> = \n | { success: true; data: T }\n | { success: false; error: string };\n`;\n\n const actions: string[] = [];\n\n Object.entries(this.context.apiConfig.endpoints).forEach(([name, endpoint]) => {\n if (this.isMutationEndpoint(endpoint)) {\n actions.push(this.generateServerAction(name, endpoint));\n }\n });\n\n return imports + '\\n' + actions.join('\\n\\n');\n }\n\n private generateServerAction(name: string, endpoint: APIEndpoint): string {\n const actionSuffix = this.context.config.options?.actionSuffix || 'Action';\n const actionName = `${name}${actionSuffix}`;\n const signature = this.getEndpointSignature(name, endpoint);\n const invalidationTags = this.getInvalidationTags(endpoint);\n\n let inputType = '';\n let inputParam = '';\n if (signature.hasParams && signature.hasBody) {\n inputType = `input: { params: ${signature.paramType}; body: ${signature.bodyType} }`;\n inputParam = 'input';\n } else if (signature.hasParams) {\n inputType = `params: ${signature.paramType}`;\n inputParam = 'params';\n } else if (signature.hasBody) {\n inputType = `body: ${signature.bodyType}`;\n inputParam = 'body';\n }\n\n const revalidateStatements = invalidationTags.length > 0\n ? invalidationTags\n .map((tag) => ` revalidateTag('${tag}');`)\n .join('\\n')\n : ' // No automatic revalidations';\n\n return `/**\n * ${endpoint.description || `Server action for ${name}`}\n * @tags ${endpoint.tags?.join(', ') || 'none'}\n */\nexport async function ${actionName}(\n ${inputType}\n): Promise<ActionResult<${signature.responseType}>> {\n try {\n const result = await serverClient.${name}(${inputParam ? inputParam : ''});\n \n // Revalidate related data\n${revalidateStatements}\n \n return { success: true, data: result };\n } catch (error) {\n console.error('[Server Action Error]:', error);\n return { \n success: false, \n error: error instanceof Error ? error.message : 'Unknown error' \n };\n }\n}`;\n }\n}\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport { BaseGenerator } from \"./base.js\";\nimport type { APIEndpoint } from \"@cushin/api-runtime\";\n\nexport class ServerQueriesGenerator extends BaseGenerator {\n async generate(): Promise<void> {\n const content = this.generateContent();\n const outputPath = path.join(this.context.config.outputDir, \"queries.ts\");\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, \"utf-8\");\n }\n\n private generateContent(): string {\n const imports = `import { cache } from 'react';\nimport { unstable_cache } from 'next/cache';\nimport { serverClient } from './server-client';\nimport type { \n APIEndpoints, \n ExtractParams, \n ExtractQuery, \n ExtractResponse \n} from './types';\n`;\n\n const queries: string[] = [];\n\n Object.entries(this.context.apiConfig.endpoints).forEach(\n ([name, endpoint]) => {\n if (this.isQueryEndpoint(endpoint)) {\n queries.push(this.generateServerQuery(name, endpoint));\n }\n },\n );\n\n return imports + \"\\n\" + queries.join(\"\\n\\n\");\n }\n\n private generateServerQuery(name: string, endpoint: APIEndpoint): string {\n const queryName = `${name}Query`;\n const signature = this.getEndpointSignature(name, endpoint);\n const queryTags = this.getQueryTags(endpoint);\n\n const paramDef = signature.hasParams\n ? `params: ${signature.paramType}`\n : \"\";\n const queryDef = signature.hasQuery ? `query?: ${signature.queryType}` : \"\";\n const paramsList = [paramDef, queryDef].filter(Boolean).join(\",\\n \");\n\n const clientCallArgs: string[] = [];\n if (signature.hasParams) clientCallArgs.push(\"params\");\n if (signature.hasQuery) clientCallArgs.push(\"query\");\n\n // Generate cache key based on params\n const cacheKeyParts: string[] = [`'${name}'`];\n if (signature.hasParams) cacheKeyParts.push(\"JSON.stringify(params)\");\n if (signature.hasQuery) cacheKeyParts.push(\"JSON.stringify(query)\");\n\n return `/**\n * ${endpoint.description || `Server query for ${name}`}\n * @tags ${queryTags.join(\", \") || \"none\"}\n */\nexport const ${queryName} = cache(async (\n ${paramsList}\n): Promise<${signature.responseType}> => {\n return unstable_cache(\n async () => serverClient.${name}(${clientCallArgs.join(\", \")}),\n [${cacheKeyParts.join(\", \")}],\n {\n tags: [${queryTags.map((tag) => `'${tag}'`).join(\", \")}],\n revalidate: 3600, // 1 hour default, can be overridden\n }\n )();\n});`;\n }\n}\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport { BaseGenerator } from \"./base.js\";\n\nexport class TypesGenerator extends BaseGenerator {\n async generate(): Promise<void> {\n const content = this.generateContent();\n const outputPath = path.join(this.context.config.outputDir, \"types.ts\");\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, \"utf-8\");\n }\n\n private generateContent(): string {\n const outputPath = path.join(this.context.config.outputDir, \"types.ts\");\n const endpointsPath = path.join(this.context.config.endpointsPath);\n const relativePath = path\n .relative(path.dirname(outputPath), endpointsPath)\n .replace(/\\\\/g, \"/\");\n return `// Auto-generated type definitions\n// Do not edit this file manually\n\nimport type { z } from 'zod';\nimport { apiConfig } from '${relativePath}';\n\n\n// Re-export endpoint configuration types\nexport type { APIConfig, APIEndpoint, HTTPMethod } from '@cushin/api-runtime';\n\n/**\n * Type helper to extract params schema from an endpoint\n */\nexport type ExtractParams<T> = T extends { params: infer P extends z.ZodType }\n ? z.infer<P>\n : never;\n\n/**\n * Type helper to extract query schema from an endpoint\n */\nexport type ExtractQuery<T> = T extends { query: infer Q extends z.ZodType }\n ? z.infer<Q>\n : never;\n\n/**\n * Type helper to extract body schema from an endpoint\n */\nexport type ExtractBody<T> = T extends { body: infer B extends z.ZodType }\n ? z.infer<B>\n : never;\n\n/**\n * Type helper to extract response schema from an endpoint\n */\nexport type ExtractResponse<T> = T extends { response: infer R extends z.ZodType }\n ? z.infer<R>\n : never;\n\n/**\n * Import your API config to get typed endpoints\n * \n */\nexport type APIEndpoints = typeof apiConfig.endpoints;\n\n${this.generateEndpointTypes()}\n`;\n }\n\n private generateEndpointTypes(): string {\n const types: string[] = [];\n\n Object.entries(this.context.apiConfig.endpoints).forEach(\n ([name, endpoint]) => {\n const cap = this.capitalize(name);\n if (endpoint.response)\n types.push(\n `export type ${cap}Response = ${this.inferNonNull(`typeof apiConfig.endpoints.${name}.response`)};`,\n );\n if (endpoint.body)\n types.push(\n `export type ${cap}Input = ${this.inferNonNull(`typeof apiConfig.endpoints.${name}.body`)};`,\n );\n if (endpoint.query)\n types.push(\n `export type ${cap}Query = ${this.inferNonNull(`typeof apiConfig.endpoints.${name}.query`)};`,\n );\n if (endpoint.params)\n types.push(\n `export type ${cap}Params = ${this.inferNonNull(`typeof apiConfig.endpoints.${name}.params`)};`,\n );\n },\n );\n\n return types.join(\"\\n\");\n }\n}\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport { BaseGenerator } from \"./base.js\";\n\nexport class ClientGenerator extends BaseGenerator {\n async generate(): Promise<void> {\n await this.generateClientFile();\n\n if (this.context.config.provider === \"nextjs\") {\n await this.generateServerClientFile();\n }\n }\n\n private async generateClientFile(): Promise<void> {\n const content = this.generateClientContent();\n const outputPath = path.join(this.context.config.outputDir, \"client.ts\");\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, \"utf-8\");\n }\n\n private async generateServerClientFile(): Promise<void> {\n const content = this.generateServerClientContent();\n const outputPath = path.join(\n this.context.config.outputDir,\n \"server-client.ts\",\n );\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, \"utf-8\");\n }\n\n private generateClientContent(): string {\n const useClientDirective =\n this.context.config.options?.useClientDirective ?? true;\n const outputPath = path.join(this.context.config.outputDir, \"types.ts\");\n const endpointsPath = path.join(this.context.config.endpointsPath);\n const relativePath = path\n .relative(path.dirname(outputPath), endpointsPath)\n .replace(/\\\\/g, \"/\");\n\n return `${useClientDirective ? \"'use client';\\n\" : \"\"}\nimport { createAPIClient } from '@cushin/api-runtime';\nimport type { AuthCallbacks } from '@cushin/api-runtime';\nimport { apiConfig } from '${relativePath}';\nimport { z } from 'zod';\n\n// Type the methods based on endpoints\ntype APIClientMethods = {\n [K in keyof typeof apiConfig.endpoints]: (typeof apiConfig.endpoints)[K] extends {\n method: infer M;\n params?: infer P;\n query?: infer Q;\n body?: infer B;\n response: infer R;\n }\n ? M extends \"GET\"\n ? P extends z.ZodJSONSchema\n ? Q extends z.ZodJSONSchema\n ? (params: z.infer<P>, query?: z.infer<Q>) => Promise<z.infer<R>>\n : (params: z.infer<P>) => Promise<z.infer<R>>\n : Q extends z.ZodJSONSchema\n ? (query?: z.infer<Q>) => Promise<z.infer<R>>\n : () => Promise<z.infer<R>>\n : P extends z.ZodJSONSchema\n ? B extends z.ZodJSONSchema\n ? (params: z.infer<P>, body: z.infer<B>) => Promise<z.infer<R>>\n : (params: z.infer<P>) => Promise<z.infer<R>>\n : B extends z.ZodJSONSchema\n ? (body: z.infer<B>) => Promise<z.infer<R>>\n : () => Promise<z.infer<R>>\n : never;\n};\n\n\n// Export singleton instance (will be initialized later)\nexport let baseClient: APIClientMethods & {\n refreshAuth: () => Promise<void>;\n updateAuthCallbacks: (callbacks: AuthCallbacks) => void;\n};\n\nexport const apiClient = {\n${this.generateApiClientMethods()}\n};\n\n/**\n * Initialize API client with auth callbacks\n * Call this function in your auth provider setup\n * \n * @example\n * const authCallbacks = {\n * getTokens: () => getStoredTokens(),\n * onAuthError: () => router.push('/login'),\n * onRefreshToken: async () => {\n * await refreshAccessToken();\n * },\n * };\n * \n * initializeAPIClient(authCallbacks);\n */\nexport const initializeAPIClient = (authCallbacks: AuthCallbacks) => {\n baseClient = createAPIClient(apiConfig, authCallbacks) as any;\n return baseClient;\n};\n\n// Export for custom usage\nexport { createAPIClient };\nexport type { AuthCallbacks };\n`;\n }\n\n private generateServerClientContent(): string {\n return `import { createAPIClient } from './core';\nimport { apiConfig } from '../config/endpoints';\nimport type { APIEndpoints } from './types';\n\n// Type-safe API client methods for server-side\ntype APIClientMethods = {\n [K in keyof APIEndpoints]: APIEndpoints[K] extends {\n method: infer M;\n params?: infer P;\n query?: infer Q;\n body?: infer B;\n response: infer R;\n }\n ? M extends 'GET'\n ? P extends { _type: any }\n ? Q extends { _type: any }\n ? (params: P['_type'], query?: Q['_type']) => Promise<R['_type']>\n : (params: P['_type']) => Promise<R['_type']>\n : Q extends { _type: any }\n ? (query?: Q['_type']) => Promise<R['_type']>\n : () => Promise<R['_type']>\n : P extends { _type: any }\n ? B extends { _type: any }\n ? (params: P['_type'], body: B['_type']) => Promise<R['_type']>\n : (params: P['_type']) => Promise<R['_type']>\n : B extends { _type: any }\n ? (body: B['_type']) => Promise<R['_type']>\n : () => Promise<R['_type']>\n : never;\n};\n\n/**\n * Server-side API client (no auth, direct API calls)\n * Use this in Server Components, Server Actions, and Route Handlers\n */\nexport const serverClient = createAPIClient(apiConfig) as APIClientMethods;\n`;\n }\n\n private generateApiClientMethods(): string {\n const methods: string[] = [];\n\n Object.entries(this.context.apiConfig.endpoints).forEach(\n ([name, endpoint]) => {\n const inferParams = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.params`,\n );\n const inferQuery = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.query`,\n );\n const inferBody = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.body`,\n );\n const inferResponse = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.response`,\n );\n\n if (endpoint.method === \"GET\") {\n if (endpoint.params && endpoint.query) {\n methods.push(` ${name}: (params: ${inferParams}, query?: ${inferQuery}): Promise<${inferResponse}> => \n (baseClient as any).${name}(params, query),`);\n } else if (endpoint.params) {\n methods.push(` ${name}: (params: ${inferParams}): Promise<${inferResponse}> => \n (baseClient as any).${name}(params),`);\n } else if (endpoint.query) {\n methods.push(` ${name}: (query?: ${inferQuery}): Promise<${inferResponse}> => \n (baseClient as any).${name}(query),`);\n } else {\n methods.push(` ${name}: (): Promise<${inferResponse}> => \n (baseClient as any).${name}(),`);\n }\n } else {\n if (endpoint.params && endpoint.body) {\n methods.push(` ${name}: (params: ${inferParams}, body: ${inferBody}): Promise<${inferResponse}> => \n (baseClient as any).${name}(params, body),`);\n } else if (endpoint.params) {\n methods.push(` ${name}: (params: ${inferParams}): Promise<${inferResponse}> => \n (baseClient as any).${name}(params),`);\n } else if (endpoint.body) {\n methods.push(` ${name}: (body: ${inferBody}): Promise<${inferResponse}> => \n (baseClient as any).${name}(body),`);\n } else {\n methods.push(` ${name}: (): Promise<${inferResponse}> => \n (baseClient as any).${name}(),`);\n }\n }\n },\n );\n\n return methods.join(\"\\n\");\n }\n}\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport { BaseGenerator } from \"./base.js\";\n\nexport class QueryKeysGenerator extends BaseGenerator {\n async generate(): Promise<void> {\n const content = this.generateContent();\n const outputPath = path.join(\n this.context.config.outputDir,\n \"query-keys.ts\",\n );\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, \"utf-8\");\n }\n\n private generateContent(): string {\n const outputPath = path.join(this.context.config.outputDir, \"types.ts\");\n const endpointsPath = path.join(this.context.config.endpointsPath);\n const relativePath = path\n .relative(path.dirname(outputPath), endpointsPath)\n .replace(/\\\\/g, \"/\");\n const content = `// Auto-generated query keys\nimport { z } from 'zod';\nimport { apiConfig } from '${relativePath}';\n\nexport const queryKeys = {\n${this.generateQueryKeysContent()}\n} as const;\n`;\n return content;\n }\n\n private generateQueryKeysContent(): string {\n const resourceGroups = this.groupEndpointsByResource();\n const keys: string[] = [];\n\n Object.entries(resourceGroups).forEach(([resource, endpoints]) => {\n const queryEndpoints = endpoints.filter(\n ({ endpoint }) => endpoint.method === \"GET\",\n );\n if (queryEndpoints.length === 0) return;\n\n const resourceKeys: string[] = [` all: ['${resource}'] as const,`];\n const added = new Set<string>();\n\n queryEndpoints.forEach(({ name, endpoint }) => {\n const keyName = this.getEndpointKeyName(name);\n if (added.has(keyName)) return;\n const inferParams = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.params`,\n );\n const inferQuery = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.query`,\n );\n\n if (endpoint.params || endpoint.query) {\n const params: string[] = [];\n if (endpoint.params) params.push(`params?: ${inferParams}`);\n if (endpoint.query) params.push(`query?: ${inferQuery}`);\n\n resourceKeys.push(` ${keyName}: (${params.join(\", \")}) =>\n ['${resource}', '${keyName}', ${endpoint.params ? \"params\" : \"undefined\"}, ${endpoint.query ? \"query\" : \"undefined\"}] as const,`);\n } else {\n resourceKeys.push(\n ` ${keyName}: () => ['${resource}', '${keyName}'] as const,`,\n );\n }\n added.add(keyName);\n });\n\n keys.push(` ${resource}: {\\n${resourceKeys.join(\"\\n\")}\\n },`);\n });\n\n return keys.join(\"\\n\");\n }\n}\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport { BaseGenerator } from \"./base.js\";\n\nexport class QueryOptionsGenerator extends BaseGenerator {\n async generate(): Promise<void> {\n const content = this.generateContent();\n const outputPath = path.join(\n this.context.config.outputDir,\n \"query-options.ts\",\n );\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, \"utf-8\");\n }\n private generateContent(): string {\n const outputPath = path.join(this.context.config.outputDir, \"types.ts\");\n const endpointsPath = path.join(this.context.config.endpointsPath);\n const relativePath = path\n .relative(path.dirname(outputPath), endpointsPath)\n .replace(/\\\\/g, \"/\");\n const content = `// Auto-generated query options\nimport { queryOptions } from '@tanstack/react-query';\nimport { apiClient } from './client';\nimport { queryKeys } from './query-keys';\nimport { z } from 'zod';\nimport { apiConfig } from '${relativePath}';\n\n${this.generateQueryOptionsContent()}\n\nexport const apiQueryOptions = {\n${this.generateQueryOptionsExports()}\n} as const;\n`;\n\n return content;\n }\n\n private generateQueryOptionsContent(): string {\n const groups = this.groupEndpointsByResource();\n const options: string[] = [];\n\n Object.entries(groups).forEach(([resource, endpoints]) => {\n const queries = endpoints.filter(\n ({ endpoint }) => endpoint.method === \"GET\",\n );\n if (queries.length === 0) return;\n\n const resourceOptions: string[] = [];\n queries.forEach(({ name, endpoint }) => {\n const optionName = this.getEndpointKeyName(name);\n const inferParams = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.params`,\n );\n const inferQuery = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.query`,\n );\n const inferResponse = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.response`,\n );\n\n const params: string[] = [];\n let apiCall = \"\";\n\n if (endpoint.params && endpoint.query) {\n params.push(`params: ${inferParams}`, `filters?: ${inferQuery}`);\n apiCall = `apiClient.${name}(params, filters)`;\n } else if (endpoint.params) {\n params.push(`params: ${inferParams}`);\n apiCall = `apiClient.${name}(params)`;\n } else if (endpoint.query) {\n params.push(`filters?: ${inferQuery}`);\n apiCall = `apiClient.${name}(filters)`;\n } else {\n apiCall = `apiClient.${name}()`;\n }\n\n const keyCall = this.generateQueryKeyCall(resource, name, endpoint);\n\n resourceOptions.push(` ${optionName}: (${params.join(\", \")}) =>\n queryOptions({\n queryKey: ${keyCall},\n queryFn: (): Promise<${inferResponse}> => ${apiCall},\n staleTime: 1000 * 60 * 5,\n }),`);\n });\n\n options.push(\n `const ${resource}QueryOptions = {\\n${resourceOptions.join(\"\\n\")}\\n};\\n`,\n );\n });\n\n return options.join(\"\\n\");\n }\n\n private generateQueryOptionsExports(): string {\n const groups = this.groupEndpointsByResource();\n const exports: string[] = [];\n\n Object.keys(groups).forEach((resource) => {\n const hasQueries = groups[resource].some(\n ({ endpoint }) => endpoint.method === \"GET\",\n );\n if (hasQueries) exports.push(` ${resource}: ${resource}QueryOptions,`);\n });\n\n return exports.join(\"\\n\");\n }\n}\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport { BaseGenerator } from \"./base.js\";\nimport type { APIEndpoint } from \"@cushin/api-runtime\";\n\nexport class PrefetchGenerator extends BaseGenerator {\n async generate(): Promise<void> {\n const content = this.generateContent();\n const outputPath = path.join(this.context.config.outputDir, \"prefetchs.ts\");\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, \"utf-8\");\n }\n\n private generateContent(): string {\n const content = `// Auto-generated prefetch utilities\nimport { type QueryClient } from '@tanstack/react-query';\n${this.hasQueryOptions() ? \"import { apiQueryOptions } from './query-options';\" : \"\"}\nimport { z } from 'zod';\nimport { apiConfig } from '../config/endpoints';\n\n${this.generatePrefetchFunctions()}\n`;\n return content;\n }\n\n private generatePrefetchFunctions(): string {\n const funcs: string[] = [];\n Object.entries(this.context.apiConfig.endpoints).forEach(\n ([name, endpoint]) => {\n if (endpoint.method === \"GET\")\n funcs.push(this.generatePrefetchFunction(name, endpoint));\n },\n );\n return funcs.join(\"\\n\\n\");\n }\n\n private generatePrefetchFunction(\n name: string,\n endpoint: APIEndpoint,\n ): string {\n const prefetchName = `prefetch${this.capitalize(name)}`;\n const resource = this.getResourceFromEndpoint(name, endpoint);\n const optionName = this.getEndpointKeyName(name);\n const inferParams = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.params`,\n );\n const inferQuery = this.inferNonNull(\n `typeof apiConfig.endpoints.${name}.query`,\n );\n\n const params: string[] = [\"queryClient: QueryClient\"];\n const optionParams: string[] = [];\n\n if (endpoint.params) {\n params.push(`params: ${inferParams}`);\n optionParams.push(\"params\");\n }\n if (endpoint.query) {\n params.push(`filters?: ${inferQuery}`);\n optionParams.push(\"filters\");\n }\n\n return `export const ${prefetchName} = async (${params.join(\",\\n \")}) => {\n return await queryClient.ensureQueryData(apiQueryOptions.${resource}.${optionName}(${optionParams.join(\", \")}));\n};`;\n }\n}\n","import fs from \"fs/promises\";\nimport path from \"path\";\nimport { BaseGenerator } from \"./base.js\";\n\nexport class IndexGenerator extends BaseGenerator {\n async generate(): Promise<void> {\n const content = this.generateContent();\n const outputPath = path.join(this.context.config.outputDir, \"index.ts\");\n\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, content, \"utf-8\");\n }\n\n private generateContent(): string {\n const outputPath = path.join(this.context.config.outputDir, \"types.ts\");\n const endpointsPath = path.join(this.context.config.endpointsPath);\n const relativePath = path\n .relative(path.dirname(outputPath), endpointsPath)\n .replace(/\\\\/g, \"/\");\n\n const content = `// Auto-generated exports\nexport * from './types';\nexport * from './client';\nexport * from './query-keys';\n${this.hasQueryOptions() ? \"export * from './query-options';\" : \"\"}\nexport * from './hooks';\nexport * from './prefetchs';\nexport { z } from 'zod';\nexport { apiConfig } from '${relativePath}';\n`;\n return content;\n }\n}\n","import { HooksGenerator } from \"./hooks.js\";\nimport { ServerActionsGenerator } from \"./actions.js\";\nimport { ServerQueriesGenerator } from \"./queries.js\";\nimport { TypesGenerator } from \"./types.js\";\nimport { ClientGenerator } from \"./client.js\";\nimport type { GeneratorContext } from \"./base.js\";\nimport { QueryKeysGenerator } from \"./query-keys.js\";\nimport { QueryOptionsGenerator } from \"./query-options.js\";\nimport { PrefetchGenerator } from \"./prefetch.js\";\nimport { IndexGenerator } from \"./generate-index.js\";\n\nexport class CodeGenerator {\n constructor(private context: GeneratorContext) {}\n\n async generate(): Promise<void> {\n const generators = this.getGenerators();\n\n for (const generator of generators) {\n await generator.generate();\n }\n }\n\n private getGenerators() {\n const generators: Array<any> = [];\n\n // Always generate types\n generators.push(new TypesGenerator(this.context));\n generators.push(new IndexGenerator(this.context));\n\n // Generate client if enabled\n if (this.context.config.generateClient) {\n generators.push(new ClientGenerator(this.context));\n }\n\n // Generate hooks if enabled\n if (this.context.config.generateHooks) {\n generators.push(new QueryKeysGenerator(this.context));\n generators.push(new QueryOptionsGenerator(this.context));\n generators.push(new HooksGenerator(this.context));\n }\n\n if (this.context.config.generatePrefetch) {\n generators.push(new PrefetchGenerator(this.context));\n }\n\n // Generate server actions if enabled (Next.js only)\n if (\n this.context.config.generateServerActions &&\n this.context.config.provider === \"nextjs\"\n ) {\n generators.push(new ServerActionsGenerator(this.context));\n }\n\n // Generate server queries if enabled (Next.js only)\n if (\n this.context.config.generateServerQueries &&\n this.context.config.provider === \"nextjs\"\n ) {\n generators.push(new ServerQueriesGenerator(this.context));\n }\n\n return generators;\n }\n}\n"],"mappings":";AACA,cAAc;;;ACDd,SAAS,mBAAmB;AAC5B,OAAO,UAAU;AA4FjB,IAAM,WAAW,YAAY,eAAe;AAAA,EAC1C,cAAc;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF,CAAC;AAED,eAAsB,WACpB,YACgC;AAChC,MAAI;AACF,UAAM,SAAS,aACX,MAAM,SAAS,KAAK,UAAU,IAC9B,MAAM,SAAS,OAAO;AAE1B,QAAI,CAAC,UAAU,CAAC,OAAO,QAAQ;AAC7B,aAAO;AAAA,IACT;AAEA,UAAM,aAAa,OAAO;AAC1B,UAAM,UAAU,KAAK,QAAQ,OAAO,QAAQ;AAG5C,UAAM,gBAAgB,KAAK,QAAQ,SAAS,WAAW,SAAS;AAChE,UAAM,YAAY,KAAK,QAAQ,SAAS,WAAW,MAAM;AAGzD,UAAM,gBAAgB,WAAW,iBAAiB;AAClD,UAAM,wBACJ,WAAW,yBAAyB,WAAW,aAAa;AAC9D,UAAM,wBACJ,WAAW,yBAAyB,WAAW,aAAa;AAC9D,UAAM,iBAAiB,WAAW,kBAAkB;AACpD,UAAM,mBAAmB,WAAW,oBAAoB;AAExD,WAAO;AAAA,MACL,GAAG;AAAA,MACH;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF,SAAS,OAAO;AACd,UAAM,IAAI;AAAA,MACR,0BAA0B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,IAClF;AAAA,EACF;AACF;AAKO,SAAS,eAAe,QAA0B;AACvD,MAAI,CAAC,OAAO,WAAW;AACrB,UAAM,IAAI,MAAM,4CAA4C;AAAA,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AK,OAAO,aAAa,MACzD,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CACvD;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":["path","path","fs","path","path","fs","fs","path","path","fs","fs","path","path","fs","fs","path","path","fs","fs","path","path","fs","fs","path","path","fs","fs","path","path","fs","fs","path","path","fs"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cushin/api-codegen",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "Type-safe API client generator for React/Next.js with automatic hooks and server actions generation",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -60,8 +60,8 @@
60
60
  "fast-glob": "^3.3.2",
61
61
  "jiti": "^2.6.1",
62
62
  "ora": "^8.0.0",
63
- "@cushin/api-runtime": "2.0.2",
64
- "@cushin/codegen-cli": "2.0.2"
63
+ "@cushin/api-runtime": "2.0.3",
64
+ "@cushin/codegen-cli": "2.0.3"
65
65
  },
66
66
  "devDependencies": {
67
67
  "@tanstack/react-query": "^5.0.0",