@cushin/api-codegen 4.0.3 → 4.1.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
@@ -188,7 +188,7 @@ var HooksGenerator = class extends BaseGenerator {
188
188
  const useClientDirective = this.context.config.options?.useClientDirective ?? true;
189
189
  const outputPath = path2.join(this.context.config.outputDir, "types.ts");
190
190
  const endpointsPath = path2.join(this.context.config.endpointsPath);
191
- const relativePath = path2.relative(path2.dirname(outputPath), endpointsPath).replace(/\\/g, "/");
191
+ const relativePath = path2.relative(path2.dirname(outputPath), endpointsPath).replace(/\\/g, "/").replace(/\.ts$/, "");
192
192
  const content = `${useClientDirective ? "'use client';\n" : ""}
193
193
  import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
194
194
  import { apiClient } from "./client";
@@ -328,7 +328,7 @@ var ServerActionsGenerator = class extends BaseGenerator {
328
328
  generateContent() {
329
329
  const outputPath = path3.join(this.context.config.outputDir, "types.ts");
330
330
  const endpointsPath = path3.join(this.context.config.endpointsPath);
331
- const relativePath = path3.relative(path3.dirname(outputPath), endpointsPath).replace(/\\/g, "/");
331
+ const relativePath = path3.relative(path3.dirname(outputPath), endpointsPath).replace(/\\/g, "/").replace(/\.ts$/, "");
332
332
  const imports = `'use server';
333
333
 
334
334
  import { revalidateTag, revalidatePath } from 'next/cache';
@@ -406,7 +406,7 @@ var ServerQueriesGenerator = class extends BaseGenerator {
406
406
  generateContent() {
407
407
  const outputPath = path4.join(this.context.config.outputDir, "types.ts");
408
408
  const endpointsPath = path4.join(this.context.config.endpointsPath);
409
- const relativePath = path4.relative(path4.dirname(outputPath), endpointsPath).replace(/\\/g, "/");
409
+ const relativePath = path4.relative(path4.dirname(outputPath), endpointsPath).replace(/\\/g, "/").replace(/\.ts$/, "");
410
410
  const imports = `import { cache } from 'react';
411
411
  import { unstable_cache } from 'next/cache';
412
412
  import { serverClient } from './server-client';
@@ -476,7 +476,7 @@ var TypesGenerator = class extends BaseGenerator {
476
476
  generateContent() {
477
477
  const outputPath = path5.join(this.context.config.outputDir, "types.ts");
478
478
  const endpointsPath = path5.join(this.context.config.endpointsPath);
479
- const relativePath = path5.relative(path5.dirname(outputPath), endpointsPath).replace(/\\/g, "/");
479
+ const relativePath = path5.relative(path5.dirname(outputPath), endpointsPath).replace(/\\/g, "/").replace(/\.ts$/, "");
480
480
  return `// Auto-generated type definitions
481
481
  // Do not edit this file manually
482
482
 
@@ -546,7 +546,7 @@ var ClientGenerator = class extends BaseGenerator {
546
546
  const useClientDirective = this.context.config.options?.useClientDirective ?? true;
547
547
  const outputPath = path6.join(this.context.config.outputDir, "types.ts");
548
548
  const endpointsPath = path6.join(this.context.config.endpointsPath);
549
- const relativePath = path6.relative(path6.dirname(outputPath), endpointsPath).replace(/\\/g, "/");
549
+ const relativePath = path6.relative(path6.dirname(outputPath), endpointsPath).replace(/\\/g, "/").replace(/\.ts$/, "");
550
550
  return `${useClientDirective ? "'use client';\n" : ""}
551
551
  import { createAPIClient } from '@cushin/api-runtime';
552
552
  import type { AuthCallbacks } from '@cushin/api-runtime';
@@ -615,7 +615,7 @@ export type { AuthCallbacks };
615
615
  generateServerClientContent() {
616
616
  const outputPath = path6.join(this.context.config.outputDir, "types.ts");
617
617
  const endpointsPath = path6.join(this.context.config.endpointsPath);
618
- const relativePath = path6.relative(path6.dirname(outputPath), endpointsPath).replace(/\\/g, "/");
618
+ const relativePath = path6.relative(path6.dirname(outputPath), endpointsPath).replace(/\\/g, "/").replace(/\.ts$/, "");
619
619
  return `import { createAPIClient } from '@cushin/api-runtime';
620
620
  import { apiConfig } from '${relativePath}';
621
621
  import { z } from 'zod';
@@ -717,7 +717,7 @@ var QueryKeysGenerator = class extends BaseGenerator {
717
717
  generateContent() {
718
718
  const outputPath = path7.join(this.context.config.outputDir, "types.ts");
719
719
  const endpointsPath = path7.join(this.context.config.endpointsPath);
720
- const relativePath = path7.relative(path7.dirname(outputPath), endpointsPath).replace(/\\/g, "/");
720
+ const relativePath = path7.relative(path7.dirname(outputPath), endpointsPath).replace(/\\/g, "/").replace(/\.ts$/, "");
721
721
  const content = `// Auto-generated query keys
722
722
  import { z } from 'zod';
723
723
  import { apiConfig } from '${relativePath}';
@@ -784,7 +784,7 @@ var QueryOptionsGenerator = class extends BaseGenerator {
784
784
  generateContent() {
785
785
  const outputPath = path8.join(this.context.config.outputDir, "types.ts");
786
786
  const endpointsPath = path8.join(this.context.config.endpointsPath);
787
- const relativePath = path8.relative(path8.dirname(outputPath), endpointsPath).replace(/\\/g, "/");
787
+ const relativePath = path8.relative(path8.dirname(outputPath), endpointsPath).replace(/\\/g, "/").replace(/\.ts$/, "");
788
788
  const content = `// Auto-generated query options
789
789
  import { queryOptions } from '@tanstack/react-query';
790
790
  import { apiClient } from './client';
@@ -934,7 +934,7 @@ var IndexGenerator = class extends BaseGenerator {
934
934
  generateContent() {
935
935
  const outputPath = path10.join(this.context.config.outputDir, "types.ts");
936
936
  const endpointsPath = path10.join(this.context.config.endpointsPath);
937
- const relativePath = path10.relative(path10.dirname(outputPath), endpointsPath).replace(/\\/g, "/");
937
+ const relativePath = path10.relative(path10.dirname(outputPath), endpointsPath).replace(/\\/g, "/").replace(/\.ts$/, "");
938
938
  const content = `// Auto-generated exports
939
939
  export * from './types';
940
940
  export * from './client';
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/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 ? this.inferNonNull(`typeof apiConfig.endpoints.${name}.params`) : \"never\",\n queryType: hasQuery ? this.inferNonNull(`typeof apiConfig.endpoints.${name}.query`) : \"never\",\n bodyType: hasBody ? this.inferNonNull(`typeof apiConfig.endpoints.${name}.body`) : \"never\",\n responseType: this.inferNonNull(`typeof apiConfig.endpoints.${name}.response`),\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 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 imports = `'use server';\n\nimport { revalidateTag, revalidatePath } from 'next/cache';\nimport { serverClient } from './server-client';\nimport { z } from 'zod';\nimport { apiConfig } from '${relativePath}';\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(\n ([name, endpoint]) => {\n if (this.isMutationEndpoint(endpoint)) {\n actions.push(this.generateServerAction(name, endpoint));\n }\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 callArgs = \"\";\n if (signature.hasParams && signature.hasBody) {\n inputType = `input: { params: ${signature.paramType}; body: ${signature.bodyType} }`;\n callArgs = \"input.params, input.body\";\n } else if (signature.hasParams) {\n inputType = `params: ${signature.paramType}`;\n callArgs = \"params\";\n } else if (signature.hasBody) {\n inputType = `body: ${signature.bodyType}`;\n callArgs = \"body\";\n }\n\n const revalidateStatements =\n 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 as any).${name}(${callArgs});\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 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 imports = `import { cache } from 'react';\nimport { unstable_cache } from 'next/cache';\nimport { serverClient } from './server-client';\nimport { z } from 'zod';\nimport { apiConfig } from '${relativePath}';\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 // Build client call with proper argument handling\n let clientCall = \"\";\n if (signature.hasParams && signature.hasQuery) {\n clientCall = `(serverClient as any).${name}(params, query)`;\n } else if (signature.hasParams) {\n clientCall = `(serverClient as any).${name}(params)`;\n } else if (signature.hasQuery) {\n clientCall = `(serverClient as any).${name}(query)`;\n } else {\n clientCall = `(serverClient as any).${name}()`;\n }\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)\n cacheKeyParts.push(\"query ? JSON.stringify(query) : 'no-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 () => ${clientCall},\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${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 infer E\n ? E extends { method: \"GET\"; params: infer P; query: infer Q; response: infer R }\n ? (params: P extends z.ZodType ? z.infer<P> : never, query?: Q extends z.ZodType ? z.infer<Q> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: \"GET\"; params: infer P; response: infer R }\n ? (params: P extends z.ZodType ? z.infer<P> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: \"GET\"; query: infer Q; response: infer R }\n ? (query?: Q extends z.ZodType ? z.infer<Q> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: \"GET\"; response: infer R }\n ? () => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: string; params: infer P; body: infer B; response: infer R }\n ? (params: P extends z.ZodType ? z.infer<P> : never, body: B extends z.ZodType ? z.infer<B> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: string; params: infer P; response: infer R }\n ? (params: P extends z.ZodType ? z.infer<P> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: string; body: infer B; response: infer R }\n ? (body: B extends z.ZodType ? z.infer<B> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: string; response: infer R }\n ? () => Promise<R extends z.ZodType ? z.infer<R> : never>\n : never\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 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 `import { createAPIClient } 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 infer E\n ? E extends { method: \"GET\"; params: infer P; query: infer Q; response: infer R }\n ? (params: P extends z.ZodType ? z.infer<P> : never, query?: Q extends z.ZodType ? z.infer<Q> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: \"GET\"; params: infer P; response: infer R }\n ? (params: P extends z.ZodType ? z.infer<P> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: \"GET\"; query: infer Q; response: infer R }\n ? (query?: Q extends z.ZodType ? z.infer<Q> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: \"GET\"; response: infer R }\n ? () => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: string; params: infer P; body: infer B; response: infer R }\n ? (params: P extends z.ZodType ? z.infer<P> : never, body: B extends z.ZodType ? z.infer<B> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: string; params: infer P; response: infer R }\n ? (params: P extends z.ZodType ? z.infer<P> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: string; body: infer B; response: infer R }\n ? (body: B extends z.ZodType ? z.infer<B> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: string; response: infer R }\n ? () => Promise<R extends z.ZodType ? z.infer<R> : never>\n : never\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,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,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AAI;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","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 .replace(/\\.ts$/, \"\");\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 ? this.inferNonNull(`typeof apiConfig.endpoints.${name}.params`) : \"never\",\n queryType: hasQuery ? this.inferNonNull(`typeof apiConfig.endpoints.${name}.query`) : \"never\",\n bodyType: hasBody ? this.inferNonNull(`typeof apiConfig.endpoints.${name}.body`) : \"never\",\n responseType: this.inferNonNull(`typeof apiConfig.endpoints.${name}.response`),\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 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 .replace(/\\.ts$/, \"\");\n\n const imports = `'use server';\n\nimport { revalidateTag, revalidatePath } from 'next/cache';\nimport { serverClient } from './server-client';\nimport { z } from 'zod';\nimport { apiConfig } from '${relativePath}';\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(\n ([name, endpoint]) => {\n if (this.isMutationEndpoint(endpoint)) {\n actions.push(this.generateServerAction(name, endpoint));\n }\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 callArgs = \"\";\n if (signature.hasParams && signature.hasBody) {\n inputType = `input: { params: ${signature.paramType}; body: ${signature.bodyType} }`;\n callArgs = \"input.params, input.body\";\n } else if (signature.hasParams) {\n inputType = `params: ${signature.paramType}`;\n callArgs = \"params\";\n } else if (signature.hasBody) {\n inputType = `body: ${signature.bodyType}`;\n callArgs = \"body\";\n }\n\n const revalidateStatements =\n 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 as any).${name}(${callArgs});\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 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 .replace(/\\.ts$/, \"\");\n\n const imports = `import { cache } from 'react';\nimport { unstable_cache } from 'next/cache';\nimport { serverClient } from './server-client';\nimport { z } from 'zod';\nimport { apiConfig } from '${relativePath}';\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 // Build client call with proper argument handling\n let clientCall = \"\";\n if (signature.hasParams && signature.hasQuery) {\n clientCall = `(serverClient as any).${name}(params, query)`;\n } else if (signature.hasParams) {\n clientCall = `(serverClient as any).${name}(params)`;\n } else if (signature.hasQuery) {\n clientCall = `(serverClient as any).${name}(query)`;\n } else {\n clientCall = `(serverClient as any).${name}()`;\n }\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)\n cacheKeyParts.push(\"query ? JSON.stringify(query) : 'no-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 () => ${clientCall},\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 .replace(/\\.ts$/, \"\");\n\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${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 .replace(/\\.ts$/, \"\");\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 infer E\n ? E extends { method: \"GET\"; params: infer P; query: infer Q; response: infer R }\n ? (params: P extends z.ZodType ? z.infer<P> : never, query?: Q extends z.ZodType ? z.infer<Q> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: \"GET\"; params: infer P; response: infer R }\n ? (params: P extends z.ZodType ? z.infer<P> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: \"GET\"; query: infer Q; response: infer R }\n ? (query?: Q extends z.ZodType ? z.infer<Q> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: \"GET\"; response: infer R }\n ? () => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: string; params: infer P; body: infer B; response: infer R }\n ? (params: P extends z.ZodType ? z.infer<P> : never, body: B extends z.ZodType ? z.infer<B> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: string; params: infer P; response: infer R }\n ? (params: P extends z.ZodType ? z.infer<P> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: string; body: infer B; response: infer R }\n ? (body: B extends z.ZodType ? z.infer<B> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: string; response: infer R }\n ? () => Promise<R extends z.ZodType ? z.infer<R> : never>\n : never\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 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 .replace(/\\.ts$/, \"\");\n\n return `import { createAPIClient } 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 infer E\n ? E extends { method: \"GET\"; params: infer P; query: infer Q; response: infer R }\n ? (params: P extends z.ZodType ? z.infer<P> : never, query?: Q extends z.ZodType ? z.infer<Q> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: \"GET\"; params: infer P; response: infer R }\n ? (params: P extends z.ZodType ? z.infer<P> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: \"GET\"; query: infer Q; response: infer R }\n ? (query?: Q extends z.ZodType ? z.infer<Q> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: \"GET\"; response: infer R }\n ? () => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: string; params: infer P; body: infer B; response: infer R }\n ? (params: P extends z.ZodType ? z.infer<P> : never, body: B extends z.ZodType ? z.infer<B> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: string; params: infer P; response: infer R }\n ? (params: P extends z.ZodType ? z.infer<P> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: string; body: infer B; response: infer R }\n ? (body: B extends z.ZodType ? z.infer<B> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: string; response: infer R }\n ? () => Promise<R extends z.ZodType ? z.infer<R> : never>\n : never\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 .replace(/\\.ts$/, \"\");\n\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 .replace(/\\.ts$/, \"\");\n\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 .replace(/\\.ts$/, \"\");\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,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;A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AAO,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","fs","path","path","fs","context","path"]}
package/dist/index.js CHANGED
@@ -185,7 +185,7 @@ var HooksGenerator = class extends BaseGenerator {
185
185
  const useClientDirective = this.context.config.options?.useClientDirective ?? true;
186
186
  const outputPath = path2.join(this.context.config.outputDir, "types.ts");
187
187
  const endpointsPath = path2.join(this.context.config.endpointsPath);
188
- const relativePath = path2.relative(path2.dirname(outputPath), endpointsPath).replace(/\\/g, "/");
188
+ const relativePath = path2.relative(path2.dirname(outputPath), endpointsPath).replace(/\\/g, "/").replace(/\.ts$/, "");
189
189
  const content = `${useClientDirective ? "'use client';\n" : ""}
190
190
  import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
191
191
  import { apiClient } from "./client";
@@ -325,7 +325,7 @@ var ServerActionsGenerator = class extends BaseGenerator {
325
325
  generateContent() {
326
326
  const outputPath = path3.join(this.context.config.outputDir, "types.ts");
327
327
  const endpointsPath = path3.join(this.context.config.endpointsPath);
328
- const relativePath = path3.relative(path3.dirname(outputPath), endpointsPath).replace(/\\/g, "/");
328
+ const relativePath = path3.relative(path3.dirname(outputPath), endpointsPath).replace(/\\/g, "/").replace(/\.ts$/, "");
329
329
  const imports = `'use server';
330
330
 
331
331
  import { revalidateTag, revalidatePath } from 'next/cache';
@@ -403,7 +403,7 @@ var ServerQueriesGenerator = class extends BaseGenerator {
403
403
  generateContent() {
404
404
  const outputPath = path4.join(this.context.config.outputDir, "types.ts");
405
405
  const endpointsPath = path4.join(this.context.config.endpointsPath);
406
- const relativePath = path4.relative(path4.dirname(outputPath), endpointsPath).replace(/\\/g, "/");
406
+ const relativePath = path4.relative(path4.dirname(outputPath), endpointsPath).replace(/\\/g, "/").replace(/\.ts$/, "");
407
407
  const imports = `import { cache } from 'react';
408
408
  import { unstable_cache } from 'next/cache';
409
409
  import { serverClient } from './server-client';
@@ -473,7 +473,7 @@ var TypesGenerator = class extends BaseGenerator {
473
473
  generateContent() {
474
474
  const outputPath = path5.join(this.context.config.outputDir, "types.ts");
475
475
  const endpointsPath = path5.join(this.context.config.endpointsPath);
476
- const relativePath = path5.relative(path5.dirname(outputPath), endpointsPath).replace(/\\/g, "/");
476
+ const relativePath = path5.relative(path5.dirname(outputPath), endpointsPath).replace(/\\/g, "/").replace(/\.ts$/, "");
477
477
  return `// Auto-generated type definitions
478
478
  // Do not edit this file manually
479
479
 
@@ -543,7 +543,7 @@ var ClientGenerator = class extends BaseGenerator {
543
543
  const useClientDirective = this.context.config.options?.useClientDirective ?? true;
544
544
  const outputPath = path6.join(this.context.config.outputDir, "types.ts");
545
545
  const endpointsPath = path6.join(this.context.config.endpointsPath);
546
- const relativePath = path6.relative(path6.dirname(outputPath), endpointsPath).replace(/\\/g, "/");
546
+ const relativePath = path6.relative(path6.dirname(outputPath), endpointsPath).replace(/\\/g, "/").replace(/\.ts$/, "");
547
547
  return `${useClientDirective ? "'use client';\n" : ""}
548
548
  import { createAPIClient } from '@cushin/api-runtime';
549
549
  import type { AuthCallbacks } from '@cushin/api-runtime';
@@ -612,7 +612,7 @@ export type { AuthCallbacks };
612
612
  generateServerClientContent() {
613
613
  const outputPath = path6.join(this.context.config.outputDir, "types.ts");
614
614
  const endpointsPath = path6.join(this.context.config.endpointsPath);
615
- const relativePath = path6.relative(path6.dirname(outputPath), endpointsPath).replace(/\\/g, "/");
615
+ const relativePath = path6.relative(path6.dirname(outputPath), endpointsPath).replace(/\\/g, "/").replace(/\.ts$/, "");
616
616
  return `import { createAPIClient } from '@cushin/api-runtime';
617
617
  import { apiConfig } from '${relativePath}';
618
618
  import { z } from 'zod';
@@ -714,7 +714,7 @@ var QueryKeysGenerator = class extends BaseGenerator {
714
714
  generateContent() {
715
715
  const outputPath = path7.join(this.context.config.outputDir, "types.ts");
716
716
  const endpointsPath = path7.join(this.context.config.endpointsPath);
717
- const relativePath = path7.relative(path7.dirname(outputPath), endpointsPath).replace(/\\/g, "/");
717
+ const relativePath = path7.relative(path7.dirname(outputPath), endpointsPath).replace(/\\/g, "/").replace(/\.ts$/, "");
718
718
  const content = `// Auto-generated query keys
719
719
  import { z } from 'zod';
720
720
  import { apiConfig } from '${relativePath}';
@@ -781,7 +781,7 @@ var QueryOptionsGenerator = class extends BaseGenerator {
781
781
  generateContent() {
782
782
  const outputPath = path8.join(this.context.config.outputDir, "types.ts");
783
783
  const endpointsPath = path8.join(this.context.config.endpointsPath);
784
- const relativePath = path8.relative(path8.dirname(outputPath), endpointsPath).replace(/\\/g, "/");
784
+ const relativePath = path8.relative(path8.dirname(outputPath), endpointsPath).replace(/\\/g, "/").replace(/\.ts$/, "");
785
785
  const content = `// Auto-generated query options
786
786
  import { queryOptions } from '@tanstack/react-query';
787
787
  import { apiClient } from './client';
@@ -931,7 +931,7 @@ var IndexGenerator = class extends BaseGenerator {
931
931
  generateContent() {
932
932
  const outputPath = path10.join(this.context.config.outputDir, "types.ts");
933
933
  const endpointsPath = path10.join(this.context.config.endpointsPath);
934
- const relativePath = path10.relative(path10.dirname(outputPath), endpointsPath).replace(/\\/g, "/");
934
+ const relativePath = path10.relative(path10.dirname(outputPath), endpointsPath).replace(/\\/g, "/").replace(/\.ts$/, "");
935
935
  const content = `// Auto-generated exports
936
936
  export * from './types';
937
937
  export * from './client';
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/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 ? this.inferNonNull(`typeof apiConfig.endpoints.${name}.params`) : \"never\",\n queryType: hasQuery ? this.inferNonNull(`typeof apiConfig.endpoints.${name}.query`) : \"never\",\n bodyType: hasBody ? this.inferNonNull(`typeof apiConfig.endpoints.${name}.body`) : \"never\",\n responseType: this.inferNonNull(`typeof apiConfig.endpoints.${name}.response`),\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 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 imports = `'use server';\n\nimport { revalidateTag, revalidatePath } from 'next/cache';\nimport { serverClient } from './server-client';\nimport { z } from 'zod';\nimport { apiConfig } from '${relativePath}';\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(\n ([name, endpoint]) => {\n if (this.isMutationEndpoint(endpoint)) {\n actions.push(this.generateServerAction(name, endpoint));\n }\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 callArgs = \"\";\n if (signature.hasParams && signature.hasBody) {\n inputType = `input: { params: ${signature.paramType}; body: ${signature.bodyType} }`;\n callArgs = \"input.params, input.body\";\n } else if (signature.hasParams) {\n inputType = `params: ${signature.paramType}`;\n callArgs = \"params\";\n } else if (signature.hasBody) {\n inputType = `body: ${signature.bodyType}`;\n callArgs = \"body\";\n }\n\n const revalidateStatements =\n 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 as any).${name}(${callArgs});\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 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 imports = `import { cache } from 'react';\nimport { unstable_cache } from 'next/cache';\nimport { serverClient } from './server-client';\nimport { z } from 'zod';\nimport { apiConfig } from '${relativePath}';\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 // Build client call with proper argument handling\n let clientCall = \"\";\n if (signature.hasParams && signature.hasQuery) {\n clientCall = `(serverClient as any).${name}(params, query)`;\n } else if (signature.hasParams) {\n clientCall = `(serverClient as any).${name}(params)`;\n } else if (signature.hasQuery) {\n clientCall = `(serverClient as any).${name}(query)`;\n } else {\n clientCall = `(serverClient as any).${name}()`;\n }\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)\n cacheKeyParts.push(\"query ? JSON.stringify(query) : 'no-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 () => ${clientCall},\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${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 infer E\n ? E extends { method: \"GET\"; params: infer P; query: infer Q; response: infer R }\n ? (params: P extends z.ZodType ? z.infer<P> : never, query?: Q extends z.ZodType ? z.infer<Q> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: \"GET\"; params: infer P; response: infer R }\n ? (params: P extends z.ZodType ? z.infer<P> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: \"GET\"; query: infer Q; response: infer R }\n ? (query?: Q extends z.ZodType ? z.infer<Q> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: \"GET\"; response: infer R }\n ? () => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: string; params: infer P; body: infer B; response: infer R }\n ? (params: P extends z.ZodType ? z.infer<P> : never, body: B extends z.ZodType ? z.infer<B> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: string; params: infer P; response: infer R }\n ? (params: P extends z.ZodType ? z.infer<P> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: string; body: infer B; response: infer R }\n ? (body: B extends z.ZodType ? z.infer<B> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: string; response: infer R }\n ? () => Promise<R extends z.ZodType ? z.infer<R> : never>\n : never\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 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 `import { createAPIClient } 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 infer E\n ? E extends { method: \"GET\"; params: infer P; query: infer Q; response: infer R }\n ? (params: P extends z.ZodType ? z.infer<P> : never, query?: Q extends z.ZodType ? z.infer<Q> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: \"GET\"; params: infer P; response: infer R }\n ? (params: P extends z.ZodType ? z.infer<P> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: \"GET\"; query: infer Q; response: infer R }\n ? (query?: Q extends z.ZodType ? z.infer<Q> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: \"GET\"; response: infer R }\n ? () => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: string; params: infer P; body: infer B; response: infer R }\n ? (params: P extends z.ZodType ? z.infer<P> : never, body: B extends z.ZodType ? z.infer<B> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: string; params: infer P; response: infer R }\n ? (params: P extends z.ZodType ? z.infer<P> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: string; body: infer B; response: infer R }\n ? (body: B extends z.ZodType ? z.infer<B> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: string; response: infer R }\n ? () => Promise<R extends z.ZodType ? z.infer<R> : never>\n : never\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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AA,QACtD,gBAAgB;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;","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"]}
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 .replace(/\\.ts$/, \"\");\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 ? this.inferNonNull(`typeof apiConfig.endpoints.${name}.params`) : \"never\",\n queryType: hasQuery ? this.inferNonNull(`typeof apiConfig.endpoints.${name}.query`) : \"never\",\n bodyType: hasBody ? this.inferNonNull(`typeof apiConfig.endpoints.${name}.body`) : \"never\",\n responseType: this.inferNonNull(`typeof apiConfig.endpoints.${name}.response`),\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 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 .replace(/\\.ts$/, \"\");\n\n const imports = `'use server';\n\nimport { revalidateTag, revalidatePath } from 'next/cache';\nimport { serverClient } from './server-client';\nimport { z } from 'zod';\nimport { apiConfig } from '${relativePath}';\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(\n ([name, endpoint]) => {\n if (this.isMutationEndpoint(endpoint)) {\n actions.push(this.generateServerAction(name, endpoint));\n }\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 callArgs = \"\";\n if (signature.hasParams && signature.hasBody) {\n inputType = `input: { params: ${signature.paramType}; body: ${signature.bodyType} }`;\n callArgs = \"input.params, input.body\";\n } else if (signature.hasParams) {\n inputType = `params: ${signature.paramType}`;\n callArgs = \"params\";\n } else if (signature.hasBody) {\n inputType = `body: ${signature.bodyType}`;\n callArgs = \"body\";\n }\n\n const revalidateStatements =\n 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 as any).${name}(${callArgs});\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 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 .replace(/\\.ts$/, \"\");\n\n const imports = `import { cache } from 'react';\nimport { unstable_cache } from 'next/cache';\nimport { serverClient } from './server-client';\nimport { z } from 'zod';\nimport { apiConfig } from '${relativePath}';\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 // Build client call with proper argument handling\n let clientCall = \"\";\n if (signature.hasParams && signature.hasQuery) {\n clientCall = `(serverClient as any).${name}(params, query)`;\n } else if (signature.hasParams) {\n clientCall = `(serverClient as any).${name}(params)`;\n } else if (signature.hasQuery) {\n clientCall = `(serverClient as any).${name}(query)`;\n } else {\n clientCall = `(serverClient as any).${name}()`;\n }\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)\n cacheKeyParts.push(\"query ? JSON.stringify(query) : 'no-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 () => ${clientCall},\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 .replace(/\\.ts$/, \"\");\n\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${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 .replace(/\\.ts$/, \"\");\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 infer E\n ? E extends { method: \"GET\"; params: infer P; query: infer Q; response: infer R }\n ? (params: P extends z.ZodType ? z.infer<P> : never, query?: Q extends z.ZodType ? z.infer<Q> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: \"GET\"; params: infer P; response: infer R }\n ? (params: P extends z.ZodType ? z.infer<P> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: \"GET\"; query: infer Q; response: infer R }\n ? (query?: Q extends z.ZodType ? z.infer<Q> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: \"GET\"; response: infer R }\n ? () => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: string; params: infer P; body: infer B; response: infer R }\n ? (params: P extends z.ZodType ? z.infer<P> : never, body: B extends z.ZodType ? z.infer<B> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: string; params: infer P; response: infer R }\n ? (params: P extends z.ZodType ? z.infer<P> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: string; body: infer B; response: infer R }\n ? (body: B extends z.ZodType ? z.infer<B> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: string; response: infer R }\n ? () => Promise<R extends z.ZodType ? z.infer<R> : never>\n : never\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 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 .replace(/\\.ts$/, \"\");\n\n return `import { createAPIClient } 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 infer E\n ? E extends { method: \"GET\"; params: infer P; query: infer Q; response: infer R }\n ? (params: P extends z.ZodType ? z.infer<P> : never, query?: Q extends z.ZodType ? z.infer<Q> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: \"GET\"; params: infer P; response: infer R }\n ? (params: P extends z.ZodType ? z.infer<P> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: \"GET\"; query: infer Q; response: infer R }\n ? (query?: Q extends z.ZodType ? z.infer<Q> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: \"GET\"; response: infer R }\n ? () => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: string; params: infer P; body: infer B; response: infer R }\n ? (params: P extends z.ZodType ? z.infer<P> : never, body: B extends z.ZodType ? z.infer<B> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: string; params: infer P; response: infer R }\n ? (params: P extends z.ZodType ? z.infer<P> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: string; body: infer B; response: infer R }\n ? (body: B extends z.ZodType ? z.infer<B> : never) => Promise<R extends z.ZodType ? z.infer<R> : never>\n : E extends { method: string; response: infer R }\n ? () => Promise<R extends z.ZodType ? z.infer<R> : never>\n : never\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 .replace(/\\.ts$/, \"\");\n\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 .replace(/\\.ts$/, \"\");\n\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 .replace(/\\.ts$/, \"\");\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;AAA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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": "4.0.3",
3
+ "version": "4.1.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,7 +60,7 @@
60
60
  "fast-glob": "^3.3.2",
61
61
  "jiti": "^2.6.1",
62
62
  "ora": "^8.0.0",
63
- "@cushin/api-runtime": "4.0.3",
63
+ "@cushin/api-runtime": "4.1.3",
64
64
  "@cushin/codegen-cli": "4.0.3"
65
65
  },
66
66
  "devDependencies": {