@acrool/rtk-query-codegen-openapi 1.0.6-alpha.0 → 1.1.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -54,14 +54,6 @@ This is a utility library meant to be used with [RTK Query](https://redux-toolki
54
54
 
55
55
  ### Test
56
56
 
57
- ```bash
58
- yarn build && npx acrool-rtk-query-codegen-openapi ./rtk-query-codegen.config.ts
59
- yarn build && npx acrool-rtk-query-codegen-openapi ./rtk-query-codegen-slice.config.ts
60
- rm -rf test_output3/* && node lib/bin/cli.mjs rtk-query-codegen-slice.config.ts
61
- ```
62
-
63
- new
64
-
65
57
  ```bash
66
58
  yarn cli ./react-rtk-query.config.ts
67
59
  ```
package/lib/bin/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- var D=Object.defineProperty;var Pe=Object.getOwnPropertyDescriptor;var Ce=Object.getOwnPropertyNames;var Ae=Object.prototype.hasOwnProperty;var V=(n,e)=>()=>(n&&(e=n(n=0)),e);var Te=(n,e)=>{for(var t in e)D(n,t,{get:e[t],enumerable:!0})},Se=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ce(e))!Ae.call(n,o)&&o!==t&&D(n,o,{get:()=>e[o],enumerable:!(r=Pe(e,o))||r.enumerable});return n};var Ne=n=>Se(D({},"__esModule",{value:!0}),n);import{fileURLToPath as we}from"node:url";var Re,l,a=V(()=>{"use strict";Re=()=>we(import.meta.url),l=Re()});var ie={};Te(ie,{argumentMatches:()=>_e,defaultIsDataResponse:()=>We,getOperationName:()=>A,getOverrides:()=>j,getTags:()=>Qe,operationMatches:()=>oe});import{getOperationName as Ue}from"oazapfts/generate";function We(n,e){if(e&&n==="default")return!0;let t=Number(n);return!Number.isNaN(t)&&t>=200&&t<300}function A({verb:n,path:e}){return Ue(n,e,void 0)}function Qe({verb:n,pathItem:e}){return n?e[n]?.tags||[]:[]}function ne(n){let e=Array.isArray(n)?n:[n];return function(r){return n?e.some(o=>typeof o=="string"?o===r:o?.test(r)):!0}}function oe(n){let e=typeof n=="function"?n:ne(n);return function(r){if(!n)return!0;let o=A(r);return e(o,r)}}function _e(n){let e=typeof n=="function"?n:ne(n);return function(r){if(!n||r.in==="path")return!0;let o=r.name;return e(o,r)}}function j(n,e){return e?.find(t=>oe(t.pattern)(n))}var M=V(()=>{"use strict";a()});a();import E from"commander";import{createRequire as et}from"node:module";a();import Ee from"commander";import{createRequire as Fe}from"node:module";import{resolve as k}from"node:path";import{existsSync as G,rmSync as $e,readdirSync as Ie,statSync as De,mkdirSync as Ge}from"node:fs";import U from"node:path";var x=Fe(l);function qe(n){let e=new Map;if(!G(n))return e;function t(r){try{let o=Ie(r);for(let i of o){let c=U.join(r,i);if(De(c).isDirectory())t(c);else if(i==="enhanceEndpoints.ts"){let u=x("node:fs").readFileSync(c);e.set(c,u)}}}catch{}}return t(n),e}function je(n){for(let[e,t]of n)try{let r=U.dirname(e);G(r)||Ge(r,{recursive:!0}),x("node:fs").writeFileSync(e,t)}catch(r){console.warn(`Failed to restore ${e}:`,r)}}function W(n){let e=["/","/usr","/etc","/var","/home","/Users",".",".."],t=k(n);if(e.some(r=>t===k(r))&&(console.error(`Dangerous path detected: ${t}. Refusing to delete.`),process.exit(1)),G(n)){console.log(`Cleaning output directory: ${n}`);let r=qe(n);$e(n,{recursive:!0,force:!0}),r.size>0&&(je(r),console.log(`Protected ${r.size} enhanceEndpoints.ts file(s) from deletion`)),console.log(`Directory cleaned: ${n}`)}}function Q(){try{if(x.resolve("esbuild")&&x.resolve("esbuild-runner"))return x("esbuild-runner/register"),!0}catch{}try{if(x.resolve("typescript")&&x.resolve("ts-node"))return x("ts-node").register({transpileOnly:!0,compilerOptions:{target:"es6",module:"commonjs"}}),!0}catch{}return!1}function _(n){(!n||!/\.([mc]?(jsx?|tsx?)|jsonc?)?$/.test(n))&&(console.error("Please provide a valid configuration file."),Ee.help())}function z(n,e){/\.[mc]?tsx?$/.test(n)&&!e&&(console.error("Encountered a TypeScript config file, but neither esbuild-runner nor ts-node are installed."),process.exit(1))}import{dirname as tt,resolve as rt}from"node:path";a();a();import w from"node:path";import de from"typescript";a();a();function v(n){return n.replace(n[0],n[0].toUpperCase())}a();import q from"node:fs";import Me from"node:path";a();function B(n){try{new URL(n)}catch{return!1}return!0}async function L(n,e){if(!B(n))throw new Error(`remoteFile must be a valid URL: ${n}`);try{let t=Me.dirname(e);q.existsSync(t)||await q.promises.mkdir(t,{recursive:!0});let r=await fetch(n);if(!r.ok)throw new Error(`Failed to download schema from ${n}: ${r.statusText}`);let o=await r.text();return await q.promises.writeFile(e,o,"utf-8"),console.log(`Schema downloaded from ${n} to ${e}`),e}catch(t){throw console.error(`Error downloading schema from ${n}:`,t),t}}a();a();var H=["get","put","post","delete","options","head","patch","trace"];function Z(n){return Object.entries(n.paths).flatMap(([e,t])=>t?Object.entries(t).filter(r=>H.includes(r[0])).map(([r,o])=>({path:e,verb:r,pathItem:t,operation:o})):[])}a();import Ke from"@apidevtools/swagger-parser";import Ve from"swagger2openapi";async function Y(n,e){let t=await Ke.bundle(n,{resolve:{http:e}});return"openapi"in t&&t.openapi.startsWith("3")?t:(await Ve.convertObj(t,{})).openapi}a();function J(n,e,t,r){return r?r(n,e):t?.type?t.type==="query":n==="get"}var b=class{docCache={};async getDocument(e,t){if(this.docCache[e])return this.docCache[e];let r=await Y(e,t);return this.docCache[e]=r,r}async downloadSchema(e,t){return L(e,t)}getPaths(e){return Object.keys(e.paths||{})}clearCache(){this.docCache={}}};a();import X from"lodash.camelcase";var P=class{groupPaths(e,t){let{groupKeyMatch:r,outputDir:o}=t,i=e.reduce((s,u)=>{let p=r(u),m=p?X(p):"_common";return s[m]||(s[m]=[]),s[m].push(u),s},{}),c={};for(let[s,u]of Object.entries(i))c[s]={groupKey:s,paths:u,outputPath:`${o}/${s}/query.service.ts`};return c}createGroupFilter(e,t){return(r,o)=>{let i=o.path,c=X(t.groupKeyMatch(i)||"");return c!==e&&(c||"_common")!==e?!1:t.filterEndpoint?t.filterEndpoint(r,i,e):!0}}};a();import re from"node:fs";import h from"node:path";a();import ke from"node:path";import ee from"node:fs";async function te(n){let e=ke.dirname(n);ee.existsSync(e)||await ee.promises.mkdir(e,{recursive:!0})}var C=class{async writeFile(e,t){try{let r=h.resolve(process.cwd(),e);return h.basename(r)==="enhanceEndpoints.ts"&&re.existsSync(r)?{path:r,success:!0}:(await te(r),re.writeFileSync(r,t),{path:r,success:!0})}catch(r){return{path:e,success:!1,error:r}}}async writeFiles(e){let t=[];for(let[r,o]of Object.entries(e)){let i=await this.writeFile(r,o);t.push(i)}return t}async writeGroupFiles(e,t){let r={};return t.types&&(r[h.join(e,"types.ts")]=t.types),t.queryService&&(r[h.join(e,"query.generated.ts")]=t.queryService),t.enhanceEndpoints&&(r[h.join(e,"enhanceEndpoints.ts")]=t.enhanceEndpoints),t.index&&(r[h.join(e,"index.ts")]=t.index),this.writeFiles(r)}async writeSharedFiles(e,t){let r={};return t.commonTypes&&(r[h.join(e,"common-types.ts")]=t.commonTypes),t.doNotModify&&(r[h.join(e,"DO_NOT_MODIFY.md")]=t.doNotModify),t.utils&&(r[h.join(e,"utils.ts")]=t.utils),this.writeFiles(r)}async writeSchemaFile(e,t){let r={};return r[h.join(e,"schema.ts")]=t,this.writeFiles(r)}};a();import ze from"oazapfts/generate";var T=class{constructor(e,t){this.v3Doc=e;this.apiGen=new ze(e,{unionUndefined:t.unionUndefined,mergeReadWriteOnly:t.mergeReadWriteOnly})}apiGen;initialize(){this.apiGen.spec.components?.schemas&&(this.apiGen.preprocessComponents(this.apiGen.spec.components.schemas),Object.keys(this.apiGen.spec.components.schemas).forEach(e=>{try{this.apiGen.getRefAlias({$ref:`#/components/schemas/${e}`})}catch{}}))}getOperationDefinitions(e){let{operationMatches:t}=(M(),Ne(ie));return Z(this.v3Doc).filter(t(e))}getApiGenerator(){return this.apiGen}getDocument(){return this.v3Doc}getSchemaTypeNames(){return new Set}};a();function se(){return`/* eslint-disable */
2
+ var G=Object.defineProperty;var Ce=Object.getOwnPropertyDescriptor;var Ae=Object.getOwnPropertyNames;var Te=Object.prototype.hasOwnProperty;var k=(n,e)=>()=>(n&&(e=n(n=0)),e);var Se=(n,e)=>{for(var t in e)G(n,t,{get:e[t],enumerable:!0})},Ne=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ae(e))!Te.call(n,o)&&o!==t&&G(n,o,{get:()=>e[o],enumerable:!(r=Ce(e,o))||r.enumerable});return n};var $e=n=>Ne(G({},"__esModule",{value:!0}),n);import{fileURLToPath as Re}from"node:url";var Ee,l,p=k(()=>{"use strict";Ee=()=>Re(import.meta.url),l=Ee()});var ie={};Se(ie,{argumentMatches:()=>Be,defaultIsDataResponse:()=>Qe,getOperationName:()=>N,getOverrides:()=>M,getTags:()=>_e,operationMatches:()=>oe});import{getOperationName as We}from"oazapfts/generate";function Qe(n,e){if(e&&n==="default")return!0;let t=Number(n);return!Number.isNaN(t)&&t>=200&&t<300}function N({verb:n,path:e}){return We(n,e,void 0)}function _e({verb:n,pathItem:e}){return n?e[n]?.tags||[]:[]}function ne(n){let e=Array.isArray(n)?n:[n];return function(r){return n?e.some(o=>typeof o=="string"?o===r:o?.test(r)):!0}}function oe(n){let e=typeof n=="function"?n:ne(n);return function(r){if(!n)return!0;let o=N(r);return e(o,r)}}function Be(n){let e=typeof n=="function"?n:ne(n);return function(r){if(!n||r.in==="path")return!0;let o=r.name;return e(o,r)}}function M(n,e){return e?.find(t=>oe(t.pattern)(n))}var K=k(()=>{"use strict";p()});p();import q from"commander";import{createRequire as tt}from"node:module";p();import we from"commander";import{createRequire as Fe}from"node:module";import{resolve as V}from"node:path";import{existsSync as D,rmSync as qe,readdirSync as Ie,statSync as Ge,mkdirSync as De}from"node:fs";import U from"node:path";var x=Fe(l);function je(n){let e=new Map;if(!D(n))return e;function t(r){try{let o=Ie(r);for(let i of o){let c=U.join(r,i);if(Ge(c).isDirectory())t(c);else if(i==="enhanceEndpoints.ts"){let u=x("node:fs").readFileSync(c);e.set(c,u)}}}catch{}}return t(n),e}function Me(n){for(let[e,t]of n)try{let r=U.dirname(e);D(r)||De(r,{recursive:!0}),x("node:fs").writeFileSync(e,t)}catch(r){console.warn(`Failed to restore ${e}:`,r)}}function W(n){let e=["/","/usr","/etc","/var","/home","/Users",".",".."],t=V(n);if(e.some(r=>t===V(r))&&(console.error(`Dangerous path detected: ${t}. Refusing to delete.`),process.exit(1)),D(n)){console.log(`Cleaning output directory: ${n}`);let r=je(n);qe(n,{recursive:!0,force:!0}),r.size>0&&(Me(r),console.log(`Protected ${r.size} enhanceEndpoints.ts file(s) from deletion`)),console.log(`Directory cleaned: ${n}`)}}function Q(){try{if(x.resolve("esbuild")&&x.resolve("esbuild-runner"))return x("esbuild-runner/register"),!0}catch{}try{if(x.resolve("typescript")&&x.resolve("ts-node"))return x("ts-node").register({transpileOnly:!0,compilerOptions:{target:"es6",module:"commonjs"}}),!0}catch{}return!1}function _(n){(!n||!/\.([mc]?(jsx?|tsx?)|jsonc?)?$/.test(n))&&(console.error("Please provide a valid configuration file."),we.help())}function B(n,e){/\.[mc]?tsx?$/.test(n)&&!e&&(console.error("Encountered a TypeScript config file, but neither esbuild-runner nor ts-node are installed."),process.exit(1))}import{dirname as rt,resolve as nt}from"node:path";p();p();import w from"node:path";import ye from"typescript";p();p();function C(n){return n.replace(n[0],n[0].toUpperCase())}p();import j from"node:fs";import Ke from"node:path";p();function z(n){try{new URL(n)}catch{return!1}return!0}async function L(n,e){if(!z(n))throw new Error(`remoteFile must be a valid URL: ${n}`);try{let t=Ke.dirname(e);j.existsSync(t)||await j.promises.mkdir(t,{recursive:!0});let r=await fetch(n);if(!r.ok)throw new Error(`Failed to download schema from ${n}: ${r.statusText}`);let o=await r.text();return await j.promises.writeFile(e,o,"utf-8"),console.log(`Schema downloaded from ${n} to ${e}`),e}catch(t){throw console.error(`Error downloading schema from ${n}:`,t),t}}p();p();var H=["get","put","post","delete","options","head","patch","trace"];function Z(n){return Object.entries(n.paths).flatMap(([e,t])=>t?Object.entries(t).filter(r=>H.includes(r[0])).map(([r,o])=>({path:e,verb:r,pathItem:t,operation:o})):[])}p();import ke from"@apidevtools/swagger-parser";import Ve from"swagger2openapi";async function Y(n,e){let t=await ke.bundle(n,{resolve:{http:e}});return"openapi"in t&&t.openapi.startsWith("3")?t:(await Ve.convertObj(t,{})).openapi}p();function J(n,e,t,r){return r?r(n,e):t?.type?t.type==="query":n==="get"}var A=class{docCache={};async getDocument(e,t){if(this.docCache[e])return this.docCache[e];let r=await Y(e,t);return this.docCache[e]=r,r}async downloadSchema(e,t){return L(e,t)}getPaths(e){return Object.keys(e.paths||{})}clearCache(){this.docCache={}}};p();import X from"lodash.camelcase";var T=class{groupPaths(e,t){let{groupKeyMatch:r,outputDir:o}=t,i=e.reduce((s,u)=>{let a=r(u),m=a?X(a):"_common";return s[m]||(s[m]=[]),s[m].push(u),s},{}),c={};for(let[s,u]of Object.entries(i))c[s]={groupKey:s,paths:u,outputPath:`${o}/${s}/query.service.ts`};return c}createGroupFilter(e,t){return(r,o)=>{let i=o.path,c=X(t.groupKeyMatch(i)||"");return c!==e&&(c||"_common")!==e?!1:t.filterEndpoint?t.filterEndpoint(r,i,e):!0}}};p();import re from"node:fs";import h from"node:path";p();import Ue from"node:path";import ee from"node:fs";async function te(n){let e=Ue.dirname(n);ee.existsSync(e)||await ee.promises.mkdir(e,{recursive:!0})}var S=class{async writeFile(e,t){try{let r=h.resolve(process.cwd(),e);return h.basename(r)==="enhanceEndpoints.ts"&&re.existsSync(r)?{path:r,success:!0}:(await te(r),re.writeFileSync(r,t),{path:r,success:!0})}catch(r){return{path:e,success:!1,error:r}}}async writeFiles(e){let t=[];for(let[r,o]of Object.entries(e)){let i=await this.writeFile(r,o);t.push(i)}return t}async writeGroupFiles(e,t){let r={};return t.types&&(r[h.join(e,"types.ts")]=t.types),t.queryService&&(r[h.join(e,"query.generated.ts")]=t.queryService),t.enhanceEndpoints&&(r[h.join(e,"enhanceEndpoints.ts")]=t.enhanceEndpoints),t.index&&(r[h.join(e,"index.ts")]=t.index),this.writeFiles(r)}async writeSharedFiles(e,t){let r={};return t.commonTypes&&(r[h.join(e,"common-types.ts")]=t.commonTypes),t.doNotModify&&(r[h.join(e,"DO_NOT_MODIFY.md")]=t.doNotModify),t.utils&&(r[h.join(e,"utils.ts")]=t.utils),this.writeFiles(r)}async writeSchemaFile(e,t){let r={};return r[h.join(e,"schema.ts")]=t,this.writeFiles(r)}};p();import ze from"oazapfts/generate";var $=class{constructor(e,t){this.v3Doc=e;this.apiGen=new ze(e,{unionUndefined:t.unionUndefined,mergeReadWriteOnly:t.mergeReadWriteOnly})}apiGen;initialize(){this.apiGen.spec.components?.schemas&&(Object.keys(this.apiGen.spec.components.schemas).forEach(e=>{let t=this.apiGen.spec.components.schemas[e];t&&typeof t=="object"&&"title"in t&&delete t.title}),this.apiGen.preprocessComponents(this.apiGen.spec.components.schemas),Object.keys(this.apiGen.spec.components.schemas).forEach(e=>{try{this.apiGen.getRefAlias({$ref:`#/components/schemas/${e}`})}catch{}}))}getOperationDefinitions(e){let{operationMatches:t}=(K(),$e(ie));return Z(this.v3Doc).filter(t(e))}getApiGenerator(){return this.apiGen}getDocument(){return this.v3Doc}getSchemaTypeNames(){return new Set}};p();function se(){return`/* eslint-disable */
3
3
  // [Warning] Generated automatically - do not edit manually
4
4
 
5
5
  export interface RequestOptions {
@@ -20,12 +20,12 @@ export type IRestFulEndpointsQueryReturn<TVariables> = TVariables extends void ?
20
20
  variables: TVariables;
21
21
  fetchOptions?: IRequestConfig;
22
22
  };
23
- `}a();import d from"typescript";function Be(n){return n.charAt(0).toUpperCase()+n.slice(1)}function Le(n,e,t){return d.transform(n,[r=>o=>d.visitNode(o,function i(c){return d.isIdentifier(c)&&c.text===e?d.factory.createIdentifier(t):d.visitEachChild(c,i,r)})]).transformed[0]}function ae(n){let e=d.createPrinter({newLine:d.NewLineKind.LineFeed}),t=d.createSourceFile("component-schema.ts","",d.ScriptTarget.Latest,!1,d.ScriptKind.TS),r=[],o={};return Object.entries(n).forEach(([i,c])=>{let s=Be(i);o[i]=s;let u=Le(c,i,s),p=e.printNode(d.EmitHint.Unspecified,u,t);r.push(p)}),`/* eslint-disable */
23
+ `}p();import d from"typescript";function Le(n){return n.charAt(0).toUpperCase()+n.slice(1)}function He(n,e,t){return d.transform(n,[r=>o=>d.visitNode(o,function i(c){return d.isIdentifier(c)&&c.text===e?d.factory.createIdentifier(t):d.visitEachChild(c,i,r)})]).transformed[0]}function ae(n){let e=d.createPrinter({newLine:d.NewLineKind.LineFeed}),t=d.createSourceFile("component-schema.ts","",d.ScriptTarget.Latest,!1,d.ScriptKind.TS),r=[],o={};return Object.entries(n).forEach(([i,c])=>{let s=Le(i);o[i]=s;let u=He(c,i,s),a=e.printNode(d.EmitHint.Unspecified,u,t);r.push(a)}),`/* eslint-disable */
24
24
  // [Warning] Generated automatically - do not edit manually
25
25
 
26
26
  ${r.join(`
27
27
  `)}
28
- `}a();function pe(){return`# \u8ACB\u52FF\u4FEE\u6539\u6B64\u8CC7\u6599\u593E
28
+ `}p();function pe(){return`# \u8ACB\u52FF\u4FEE\u6539\u6B64\u8CC7\u6599\u593E
29
29
 
30
30
  \u26A0\uFE0F **\u91CD\u8981\u63D0\u9192\uFF1A\u8ACB\u52FF\u4FEE\u6539\u6B64\u8CC7\u6599\u593E\u4E2D\u7684\u4EFB\u4F55\u6A94\u6848**
31
31
 
@@ -44,32 +44,36 @@ ${r.join(`
44
44
  \u9019\u4E9B\u6A94\u6848\u662F\u7531 @acrool/rtk-query-codegen-openapi \u7522\u751F\u5668\u6240\u5EFA\u7ACB\u3002
45
45
 
46
46
  \u5982\u6709\u7591\u554F\uFF0C\u8ACB\u53C3\u8003\u5C08\u6848\u6587\u4EF6\u6216\u806F\u7E6B\u958B\u767C\u5718\u968A\u3002
47
- `}a();import fe from"typescript";a();M();import{supportDeepObjects as He}from"oazapfts/generate";var S=class{constructor(e){this.options=e}extractEndpointInfos(e){return e.map(t=>this.extractSingleEndpointInfo(t))}extractSingleEndpointInfo(e){let{verb:t,path:r,operation:o}=e,{operationNameSuffix:i="",argSuffix:c="Req",responseSuffix:s="Res",queryMatch:u,endpointOverrides:p}=this.options,m=A({verb:t,path:r}),g=i?v(m+i):m,y=v(m+i+c),F=v(m+i+s),$=J(t,r,j(e,p),u),K=`${m.replace(/([A-Z])/g,"_$1").toUpperCase()}`,I=o.summary||`${t.toUpperCase()} ${r}`,{queryParams:xe,pathParams:Oe,isVoidArg:ve}=this.extractParameters(e),be=this.extractContentType(o);return{operationName:g,argTypeName:y,responseTypeName:F,isQuery:$,verb:t.toUpperCase(),path:r,queryKeyName:K,queryParams:xe,pathParams:Oe,isVoidArg:ve,summary:I,contentType:be}}extractParameters(e){let{operation:t,pathItem:r}=e,o=this.resolveArray(t.parameters),i=this.resolveArray(r.parameters).filter(m=>!o.some(g=>g.name===m.name&&g.in===m.in)),c=He([...i,...o]).filter(m=>m.in!=="header"),s=c.filter(m=>m.in==="query"),u=c.filter(m=>m.in==="path"),p=s.length===0&&u.length===0&&!t.requestBody;return{queryParams:s,pathParams:u,isVoidArg:p}}resolveArray(e){return e?Array.isArray(e)?e:[e]:[]}extractContentType(e){if(!e.requestBody)return"application/json";let t=e.requestBody.content;if(!t||typeof t!="object")return"application/json";let r=Object.keys(t);return r.length===0?"application/json":r[0]}};a();var Ze=n=>n.charAt(0).toUpperCase()+n.slice(1);function ue(n,e,t,r){let o={};t&&Object.keys(t).forEach(p=>{if(o[p]=p,p.endsWith("Vo")){let m=p.slice(0,-2)+"VO";o[m]=p}if(p.endsWith("Dto")){let m=p.slice(0,-3)+"DTO";o[m]=p}});let i=`/* eslint-disable */
47
+ `}p();import fe from"typescript";p();K();import{supportDeepObjects as Ze}from"oazapfts/generate";var R=class{constructor(e){this.options=e}extractEndpointInfos(e){return e.map(t=>this.extractSingleEndpointInfo(t))}extractSingleEndpointInfo(e){let{verb:t,path:r,operation:o}=e,{operationNameSuffix:i="",argSuffix:c="Req",responseSuffix:s="Res",queryMatch:u,endpointOverrides:a}=this.options,m=N({verb:t,path:r}),g=i?C(m+i):m,y=C(m+i+c),v=C(m+i+s),O=J(t,r,M(e,a),u),P=`${m.replace(/([A-Z])/g,"_$1").toUpperCase()}`,I=o.summary||`${t.toUpperCase()} ${r}`,{queryParams:xe,pathParams:Oe,isVoidArg:ve,hasRequestBody:be}=this.extractParameters(e),Pe=this.extractContentType(o);return{operationName:g,argTypeName:y,responseTypeName:v,isQuery:O,verb:t.toUpperCase(),path:r,queryKeyName:P,queryParams:xe,pathParams:Oe,isVoidArg:ve,summary:I,contentType:Pe,hasRequestBody:be}}extractParameters(e){let{operation:t,pathItem:r}=e,o=this.resolveArray(t.parameters),i=this.resolveArray(r.parameters).filter(g=>!o.some(y=>y.name===g.name&&y.in===g.in)),c=Ze([...i,...o]).filter(g=>g.in!=="header"),s=c.filter(g=>g.in==="query"),u=c.filter(g=>g.in==="path"),a=!!t.requestBody,m=s.length===0&&u.length===0&&!t.requestBody;return{queryParams:s,pathParams:u,isVoidArg:m,hasRequestBody:a}}resolveArray(e){return e?Array.isArray(e)?e:[e]:[]}extractContentType(e){if(!e.requestBody)return"application/json";let t=e.requestBody.content;if(!t||typeof t!="object")return"application/json";let r=Object.keys(t);return r.length===0?"application/json":r[0]}};p();var Ye=n=>n.charAt(0).toUpperCase()+n.slice(1);function ue(n,e,t,r){let o={};t&&Object.keys(t).forEach(a=>{if(o[a]=a,a.endsWith("Vo")){let m=a.slice(0,-2)+"VO";o[m]=a}if(a.endsWith("Dto")){let m=a.slice(0,-3)+"DTO";o[m]=a}});let i=`/* eslint-disable */
48
48
  // [Warning] Generated automatically - do not edit manually
49
49
 
50
50
  `;t&&Object.keys(t).length>0&&(i+=`import * as Schema from "../schema";
51
51
  `),i+=`
52
- `;let s=[],u=[];return n.forEach(p=>{let m=p.argTypeName,g=p.responseTypeName;if(m){let y=Ye(p,r,o);y.trim()===""?u.push(`export type ${m} = void;`,""):u.push(`export type ${m} = {`,y,"};","")}if(g){let y=Je(p,r,o);y.trim()===""?u.push(`export type ${g} = void;`,""):u.push(`export type ${g} = {`,y,"};","")}}),u.length>0&&s.push(u.join(`
52
+ `;let s=[],u=[];return n.forEach(a=>{let m=a.argTypeName,g=a.responseTypeName;if(m){let y=Je(a,r,o);y.trim()===""?u.push(`export type ${m} = void;`,""):u.push(`export type ${m} = {`,y,"};","")}if(g){let y=Xe(a,r,o);y.trim()===""?u.push(`export type ${g} = void;`,""):u.push(`export type ${g} = {`,y,"};","")}}),u.length>0&&s.push(u.join(`
53
53
  `)),s.length===0&&s.push("// \u6B64\u6A94\u6848\u7528\u65BC\u5B9A\u7FA9 API \u76F8\u95DC\u7684\u985E\u578B","// \u985E\u578B\u5B9A\u7FA9\u6703\u6839\u64DA OpenAPI Schema \u81EA\u52D5\u751F\u6210",""),i+s.join(`
54
54
 
55
- `)}function Ye(n,e,t={}){let r=[];n.queryParams&&n.queryParams.length>0&&n.queryParams.forEach(i=>{let c=i.required?"":"?",s=ce(i,t);r.push(` ${i.name}${c}: ${s};`)}),n.pathParams&&n.pathParams.length>0&&n.pathParams.forEach(i=>{let c=i.required?"":"?",s=ce(i,t);r.push(` ${i.name}${c}: ${s};`)});let o=e?.find(i=>i.operation?.operationId===n.operationName||i.operation?.operationId===n.operationName.toLowerCase()||i.verb===n.verb.toLowerCase()&&i.path===n.path);if(o?.operation?.requestBody){let c=o.operation.requestBody.content,s=c["application/json"],u=c["multipart/form-data"]||c["application/x-www-form-urlencoded"];if(s?.schema){let p=O(s.schema,t,1);r.push(` body: ${p};`)}else if(u?.schema){let p=O(u.schema,t,1);r.push(` body: ${p};`)}else r.push(" body?: any; // Request body from OpenAPI")}return r.length===0?"":r.join(`
56
- `)}function Je(n,e,t={}){let r=[],o=e?.find(i=>i.operation?.operationId===n.operationName||i.operation?.operationId===n.operationName.toLowerCase()||i.verb===n.verb.toLowerCase()&&i.path===n.path);if(o?.operation?.responses){let i=o.operation.responses[200]||o.operation.responses[201];if(i?.content){let c=i.content["application/json"];if(c?.schema){let s=Xe(c.schema,t);r.push(...s)}else r.push(" // Success response from OpenAPI"),r.push(" data?: any;")}}return r.length===0?"":r.join(`
57
- `)}function Xe(n,e={}){let t=[];if(n.type==="object"&&n.properties){let r=n.required||[];Object.entries(n.properties).forEach(([o,i])=>{let s=r.includes(o)?"":"?",u=O(i,e,1),p=i.description?` // ${i.description}`:"",g=/[^a-zA-Z0-9_$]/.test(o)?`"${o}"`:o;t.push(` ${g}${s}: ${u};${p}`)})}return t}function O(n,e={},t=0){if(!n)return"any";if(n.$ref){let o=n.$ref;if(o.startsWith("#/components/schemas/")){let i=o.replace("#/components/schemas/",""),c=e[i]||i,u=`Schema.${Ze(c)}`;return n.nullable?`${u} | null`:u}}let r;switch(n.type){case"string":n.enum?r=n.enum.map(c=>`"${c}"`).join(" | "):n.format==="binary"?r="Blob":r="string";break;case"number":case"integer":r="number";break;case"boolean":r="boolean";break;case"array":let o=n.items?O(n.items,e,t):"any";r=o.includes("|")?`(${o})[]`:`${o}[]`;break;case"object":if(n.properties){let c=Object.entries(n.properties);if(c.length===0)r="{}";else{let s=" ".repeat(t+1),u=" ".repeat(t);r=`{
58
- ${c.map(([m,g])=>{let F=(n.required||[]).includes(m)?"":"?",$=O(g,e,t+1),I=/[^a-zA-Z0-9_$]/.test(m)?`"${m}"`:m;return`${s}${I}${F}: ${$};`}).join(`
55
+ `)}function Je(n,e,t={}){let r=[];n.queryParams&&n.queryParams.length>0&&n.queryParams.forEach(i=>{let c=i.required?"":"?",s=ce(i,t);r.push(` ${i.name}${c}: ${s};`)}),n.pathParams&&n.pathParams.length>0&&n.pathParams.forEach(i=>{let c=i.required?"":"?",s=ce(i,t);r.push(` ${i.name}${c}: ${s};`)});let o=e?.find(i=>i.operation?.operationId===n.operationName||i.operation?.operationId===n.operationName.toLowerCase()||i.verb===n.verb.toLowerCase()&&i.path===n.path);if(o?.operation?.requestBody){let c=o.operation.requestBody.content,s=c["application/json"],u=c["multipart/form-data"]||c["application/x-www-form-urlencoded"];if(s?.schema){let a=b(s.schema,t,1);r.push(` body: ${a};`)}else if(u?.schema){let a=b(u.schema,t,1);r.push(` body: ${a};`)}else r.push(" body?: any; // Request body from OpenAPI")}return r.length===0?"":r.join(`
56
+ `)}function Xe(n,e,t={}){let r=[],o=e?.find(i=>i.operation?.operationId===n.operationName||i.operation?.operationId===n.operationName.toLowerCase()||i.verb===n.verb.toLowerCase()&&i.path===n.path);if(o?.operation?.responses){let i=o.operation.responses[200]||o.operation.responses[201];if(i?.content){let c=i.content["application/json"];if(c?.schema){let s=et(c.schema,t);r.push(...s)}else r.push(" // Success response from OpenAPI"),r.push(" data?: any;")}}return r.length===0?"":r.join(`
57
+ `)}function et(n,e={}){let t=[];if(n.type==="object"&&n.properties){let r=n.required||[];Object.entries(n.properties).forEach(([o,i])=>{let s=r.includes(o)?"":"?",u=b(i,e,1),a=i.description?` // ${i.description}`:"",g=/[^a-zA-Z0-9_$]/.test(o)?`"${o}"`:o;t.push(` ${g}${s}: ${u};${a}`)})}return t}function b(n,e={},t=0){if(!n)return"any";if(n.$ref){let o=n.$ref;if(o.startsWith("#/components/schemas/")){let i=o.replace("#/components/schemas/",""),c=e[i]||i,u=`Schema.${Ye(c)}`;return n.nullable?`${u} | null`:u}}let r;switch(n.type){case"string":n.enum?r=n.enum.map(c=>`"${c}"`).join(" | "):n.format==="binary"?r="Blob":r="string";break;case"number":case"integer":r="number";break;case"boolean":r="boolean";break;case"array":let o=n.items?b(n.items,e,t):"any";r=o.includes("|")?`(${o})[]`:`${o}[]`;break;case"object":if(n.properties){let c=Object.entries(n.properties);if(c.length===0)r="{}";else{let s=" ".repeat(t+1),u=" ".repeat(t);r=`{
58
+ ${c.map(([m,g])=>{let v=(n.required||[]).includes(m)?"":"?",O=b(g,e,t+1),I=/[^a-zA-Z0-9_$]/.test(m)?`"${m}"`:m;return`${s}${I}${v}: ${O};`}).join(`
59
59
  `)}
60
- ${u}}`}}else r="any";break;default:r="any";break}return n.nullable?`${r} | null`:r}function ce(n,e={}){return n.schema?O(n.schema,e):"any"}a();function me(n,e){let{groupKey:t}=e,r=e.httpClient?.importReturnTypeName||e.httpClient?.importName||"IRestFulEndpointsQueryReturn",o=n.map(p=>{let m=p.isQuery?"query":"mutation",g=p.isVoidArg?"void":`${r}<${p.argTypeName}>`;return` ${p.operationName}: build.${m}<
61
- ${p.responseTypeName},
60
+ ${u}}`}}else r="any";break;default:r="any";break}return n.nullable?`${r} | null`:r}function ce(n,e={}){return n.schema?b(n.schema,e):"any"}p();function me(n,e){let{groupKey:t}=e,r=e.httpClient?.importReturnTypeName||e.httpClient?.importName||"IRestFulEndpointsQueryReturn",o=n.map(a=>{let m=a.isQuery?"query":"mutation",g=a.isVoidArg?"void":`${r}<${a.argTypeName}>`,y=a.path;a.pathParams&&a.pathParams.length>0?(a.pathParams.forEach(O=>{y=y.replace(`{${O.name}}`,`\${queryArg.variables.${O.name}}`)}),y="`"+y+"`"):y=`"${y}"`;let v="";return a.queryParams&&a.queryParams.length>0&&(v=`
61
+ params: {
62
+ ${a.queryParams.map(P=>` ${P.name}: queryArg.variables.${P.name},`).join(`
63
+ `)}
64
+ },`),` ${a.operationName}: build.${m}<
65
+ ${a.responseTypeName},
62
66
  ${g}
63
67
  >({
64
68
  query: (queryArg) => ({
65
- url: "${p.path}",
66
- method: "${p.verb.toUpperCase()}",
67
- contentType: "${p.contentType}",${p.isVoidArg?"":`
68
- body: queryArg.variables.body,`}${p.isVoidArg?"":`
69
+ url: ${y},
70
+ method: "${a.verb.toUpperCase()}",
71
+ contentType: "${a.contentType}",${v}${a.hasRequestBody?`
72
+ body: queryArg.variables.body,`:""}${a.isVoidArg?"":`
69
73
  fetchOptions: queryArg?.fetchOptions,`}
70
74
  }),
71
75
  }),`}).join(`
72
- `),i=[...new Set([...n.map(p=>p.argTypeName),...n.map(p=>p.responseTypeName)])].filter(p=>p!=="VoidApiArg"),c=i.length>0?`import type { ${i.join(", ")} } from "./types";`:"",s=e.apiConfiguration?`import { ${e.apiConfiguration.importName} as api } from "${e.apiConfiguration.file.replace(/\.ts$/,"")}";
76
+ `),i=[...new Set([...n.map(a=>a.argTypeName),...n.map(a=>a.responseTypeName)])].filter(a=>a!=="VoidApiArg"),c=i.length>0?`import type { ${i.join(", ")} } from "./types";`:"",s=e.apiConfiguration?`import { ${e.apiConfiguration.importName} as api } from "${e.apiConfiguration.file.replace(/\.ts$/,"")}";
73
77
  `:`import { baseApi as api } from "../../../library/redux/baseApi";
74
78
  `,u=e.httpClient?`import { ${e.httpClient.importReturnTypeName||e.httpClient.importName} } from "${e.httpClient.file}";
75
79
  `:`import { IRestFulEndpointsQueryReturn } from "@acrool/react-fetcher";
@@ -87,13 +91,13 @@ ${o}
87
91
  });
88
92
 
89
93
  export const {
90
- ${n.map(p=>{let m=p.operationName.charAt(0).toUpperCase()+p.operationName.slice(1);if(p.isQuery){let g=`use${m}Query`;if(e.useLazyQueries){let y=`useLazy${m}Query`;return` ${g},
94
+ ${n.map(a=>{let m=a.operationName.charAt(0).toUpperCase()+a.operationName.slice(1);if(a.isQuery){let g=`use${m}Query`;if(e.useLazyQueries){let y=`useLazy${m}Query`;return` ${g},
91
95
  ${y},`}else return` ${g},`}else return` ${`use${m}Mutation`},`}).join(`
92
96
  `)}
93
97
  } = injectedRtkApi;
94
98
 
95
99
  export default injectedRtkApi;
96
- `}a();function le(n,e){let{groupKey:t}=e;return`/* eslint-disable */
100
+ `}p();function le(n,e){let{groupKey:t}=e;return`/* eslint-disable */
97
101
  // [Warning] Generated automatically - do not edit manually
98
102
 
99
103
  import { ECacheTagTypes } from "@/store/tagTypes";
@@ -111,13 +115,13 @@ ${n.map(o=>o.isQuery?` ${o.operationName}: {
111
115
  });
112
116
 
113
117
  export default enhancedApi;
114
- `}var N=class{constructor(e,t){this.parserService=e;this.options=t;this.infoExtractor=new S(t)}infoExtractor;async generate(){let e=this.parserService.getOperationDefinitions(this.options.filterEndpoints),t=this.infoExtractor.extractEndpointInfos(e);return this.generateRtkQueryCode(t)}generateRtkQueryCode(e){let t=this.generateTypes(e),r=me(e,this.options),o=le(e,this.options),i=this.generateIndex();return{operationNames:e.map(s=>s.operationName),files:{types:t,queryService:r,index:i,enhanceEndpoints:o}}}generateTypes(e){let t={...this.options,apiConfiguration:this.options.apiConfiguration||{file:"@/store/webapi",importName:"WebApiConfiguration"}},o=this.parserService.getApiGenerator().aliases.reduce((c,s)=>{if(fe.isInterfaceDeclaration(s)||fe.isTypeAliasDeclaration(s)){let u=s.name.text;return{...c,[u]:s}}return c},{}),i=this.parserService.getOperationDefinitions(this.options.filterEndpoints);return ue(e,t,o,i)}generateIndex(){let e=this.options.groupKey||"";return`/* eslint-disable */
118
+ `}var E=class{constructor(e,t){this.parserService=e;this.options=t;this.infoExtractor=new R(t)}infoExtractor;async generate(){let e=this.parserService.getOperationDefinitions(this.options.filterEndpoints),t=this.infoExtractor.extractEndpointInfos(e);return this.generateRtkQueryCode(t)}generateRtkQueryCode(e){let t=this.generateTypes(e),r=me(e,this.options),o=le(e,this.options),i=this.generateIndex();return{operationNames:e.map(s=>s.operationName),files:{types:t,queryService:r,index:i,enhanceEndpoints:o}}}generateTypes(e){let t={...this.options,apiConfiguration:this.options.apiConfiguration||{file:"@/store/webapi",importName:"WebApiConfiguration"}},o=this.parserService.getApiGenerator().aliases.reduce((c,s)=>{if(fe.isInterfaceDeclaration(s)||fe.isTypeAliasDeclaration(s)){let u=s.name.text;return{...c,[u]:s}}return c},{}),i=this.parserService.getOperationDefinitions(this.options.filterEndpoints);return ue(e,t,o,i)}generateIndex(){let e=this.options.groupKey||"";return`/* eslint-disable */
115
119
  // [Warning] Generated automatically - do not edit manually
116
120
 
117
121
  export { default as ${e?`${e.charAt(0).toLowerCase()+e.slice(1)}Api`:"api"} } from "./enhanceEndpoints";
118
122
  export * from "./query.generated";
119
123
  export * from "./types";
120
- `}};a();function ge(){return`/* eslint-disable */
124
+ `}};p();function ge(){return`/* eslint-disable */
121
125
  // [Warning] Generated automatically - do not edit manually
122
126
 
123
127
  /**
@@ -130,10 +134,10 @@ export function withoutUndefined(obj?: Record<string, any>) {
130
134
  );
131
135
  }
132
136
 
133
- `}var R=class{_options;openApiService=new b;groupService=new P;fileWriterService=new C;openApiDoc=null;parserService=null;schemaInterfaces={};actualSchemaFile="";generatedContent={groups:[],commonTypes:"",componentSchema:"",doNotModify:"",utils:""};constructor(e){this._options=e}async generateAll(){return await this.prepare(),await this.generateApi(),this.generateCommonTypesContent(),this.generateSchemaContent(),this.generateUtilsContent(),this.generateDoNotModifyContent(),await this.release()}async prepare(){this.actualSchemaFile=this._options.schemaFile,this._options.remoteFile&&(this.actualSchemaFile=await this.openApiService.downloadSchema(this._options.remoteFile,this._options.schemaFile)),this.openApiDoc=await this.openApiService.getDocument(this.actualSchemaFile,this._options.httpResolverOptions),this.parserService=new T(this.openApiDoc,this._options),this.parserService.initialize();let e=this.parserService.getApiGenerator();this.schemaInterfaces=e.aliases.reduce((t,r)=>{if(de.isInterfaceDeclaration(r)||de.isTypeAliasDeclaration(r)){let o=r.name.text;return{...t,[o]:r}}return t},{})}async generateApi(){if(!this.openApiDoc||!this.parserService)throw new Error("\u8ACB\u5148\u8ABF\u7528 prepare() \u65B9\u6CD5");let e=this.openApiService.getPaths(this.openApiDoc),t=this.groupService.groupPaths(e,this._options.outputFiles);for(let r of Object.values(t))try{let o=await this.generateApiGroupContent(this._options,r);o.operationNames.length>0&&this.generatedContent.groups.push({groupKey:r.groupKey,outputPath:r.outputPath,content:o})}catch(o){throw new Error(`\u7FA4\u7D44 ${r.groupKey} \u751F\u6210\u5931\u6557: ${o}`)}}async generateCommonTypesContent(){this.generatedContent.commonTypes=se()}async generateSchemaContent(){this.generatedContent.componentSchema=ae(this.schemaInterfaces)}async generateDoNotModifyContent(){this.generatedContent.doNotModify=pe()}async generateUtilsContent(){this.generatedContent.utils=ge()}async release(){let e=[],t=[],r=[];try{for(let s of this.generatedContent.groups)try{if(s.content?.files){let u=w.dirname(s.outputPath),p=await this.fileWriterService.writeGroupFiles(u,{types:s.content.files.types,queryService:s.content.files.queryService,enhanceEndpoints:s.content.files.enhanceEndpoints,index:s.content.files.index});e.push(...p),r.push(s.groupKey)}}catch(u){t.push(new Error(`\u5BEB\u5165\u7FA4\u7D44 ${s.groupKey} \u5931\u6557: ${u}`))}let o=this.generatedContent.groups[0]?w.dirname(w.dirname(this.generatedContent.groups[0].outputPath)):"./generated";if(this.generatedContent.commonTypes||this.generatedContent.doNotModify||this.generatedContent.utils){let s=await this.fileWriterService.writeSharedFiles(o,{commonTypes:this.generatedContent.commonTypes||void 0,doNotModify:this.generatedContent.doNotModify||void 0,utils:this.generatedContent.utils||void 0});e.push(...s)}if(this.generatedContent.componentSchema){let s=await this.fileWriterService.writeSchemaFile(o,this.generatedContent.componentSchema);e.push(...s)}let i=this.generateMainIndex(r),c=await this.fileWriterService.writeFile(w.join(o,"index.ts"),i);e.push(c)}catch(o){t.push(o)}return{success:t.length===0,writtenFiles:e,errors:t,generatedGroups:r}}async generateApiGroupContent(e,t){let{outputFiles:r,...o}=e,i={...o,schemaFile:this.actualSchemaFile,outputFile:t.outputPath,sharedTypesFile:`${r.outputDir}/common-types.ts`,filterEndpoints:this.groupService.createGroupFilter(t.groupKey,r),queryMatch:r.queryMatch,groupKey:t.groupKey};if(!this.openApiDoc||!this.parserService)throw new Error("OpenAPI \u6587\u6A94\u672A\u521D\u59CB\u5316\uFF0C\u8ACB\u5148\u8ABF\u7528 prepare()");return await new N(this.parserService,i).generate()}generateMainIndex(e){return`/* eslint-disable */
137
+ `}var F=class{_options;openApiService=new A;groupService=new T;fileWriterService=new S;openApiDoc=null;parserService=null;schemaInterfaces={};actualSchemaFile="";generatedContent={groups:[],commonTypes:"",componentSchema:"",doNotModify:"",utils:""};constructor(e){this._options=e}async generateAll(){return await this.prepare(),await this.generateApi(),this.generateCommonTypesContent(),this.generateSchemaContent(),this.generateUtilsContent(),this.generateDoNotModifyContent(),await this.release()}async prepare(){this.actualSchemaFile=this._options.schemaFile,this._options.remoteFile&&(this.actualSchemaFile=await this.openApiService.downloadSchema(this._options.remoteFile,this._options.schemaFile)),this.openApiDoc=await this.openApiService.getDocument(this.actualSchemaFile,this._options.httpResolverOptions),this.parserService=new $(this.openApiDoc,this._options),this.parserService.initialize();let e=this.parserService.getApiGenerator();this.schemaInterfaces=e.aliases.reduce((t,r)=>{if(ye.isInterfaceDeclaration(r)||ye.isTypeAliasDeclaration(r)){let o=r.name.text;return{...t,[o]:r}}return t},{})}async generateApi(){if(!this.openApiDoc||!this.parserService)throw new Error("\u8ACB\u5148\u8ABF\u7528 prepare() \u65B9\u6CD5");let e=this.openApiService.getPaths(this.openApiDoc),t=this.groupService.groupPaths(e,this._options.outputFiles);for(let r of Object.values(t))try{let o=await this.generateApiGroupContent(this._options,r);o.operationNames.length>0&&this.generatedContent.groups.push({groupKey:r.groupKey,outputPath:r.outputPath,content:o})}catch(o){throw new Error(`\u7FA4\u7D44 ${r.groupKey} \u751F\u6210\u5931\u6557: ${o}`)}}async generateCommonTypesContent(){this.generatedContent.commonTypes=se()}async generateSchemaContent(){this.generatedContent.componentSchema=ae(this.schemaInterfaces)}async generateDoNotModifyContent(){this.generatedContent.doNotModify=pe()}async generateUtilsContent(){this.generatedContent.utils=ge()}async release(){let e=[],t=[],r=[];try{for(let s of this.generatedContent.groups)try{if(s.content?.files){let u=w.dirname(s.outputPath),a=await this.fileWriterService.writeGroupFiles(u,{types:s.content.files.types,queryService:s.content.files.queryService,enhanceEndpoints:s.content.files.enhanceEndpoints,index:s.content.files.index});e.push(...a),r.push(s.groupKey)}}catch(u){t.push(new Error(`\u5BEB\u5165\u7FA4\u7D44 ${s.groupKey} \u5931\u6557: ${u}`))}let o=this.generatedContent.groups[0]?w.dirname(w.dirname(this.generatedContent.groups[0].outputPath)):"./generated";if(this.generatedContent.commonTypes||this.generatedContent.doNotModify||this.generatedContent.utils){let s=await this.fileWriterService.writeSharedFiles(o,{commonTypes:this.generatedContent.commonTypes||void 0,doNotModify:this.generatedContent.doNotModify||void 0,utils:this.generatedContent.utils||void 0});e.push(...s)}if(this.generatedContent.componentSchema){let s=await this.fileWriterService.writeSchemaFile(o,this.generatedContent.componentSchema);e.push(...s)}let i=this.generateMainIndex(r),c=await this.fileWriterService.writeFile(w.join(o,"index.ts"),i);e.push(c)}catch(o){t.push(o)}return{success:t.length===0,writtenFiles:e,errors:t,generatedGroups:r}}async generateApiGroupContent(e,t){let{outputFiles:r,...o}=e,i={...o,schemaFile:this.actualSchemaFile,outputFile:t.outputPath,sharedTypesFile:`${r.outputDir}/common-types.ts`,filterEndpoints:this.groupService.createGroupFilter(t.groupKey,r),queryMatch:r.queryMatch,groupKey:t.groupKey};if(!this.openApiDoc||!this.parserService)throw new Error("OpenAPI \u6587\u6A94\u672A\u521D\u59CB\u5316\uFF0C\u8ACB\u5148\u8ABF\u7528 prepare()");return await new E(this.parserService,i).generate()}generateMainIndex(e){return`/* eslint-disable */
134
138
  // [Warning] Generated automatically - do not edit manually
135
139
 
136
140
  ${e.map(r=>`export * from "./${r}";`).join(`
137
141
  `)}
138
- `}};async function ye(n){let t=await new R(n).generateAll();if(!t.success&&t.errors.length>0)throw t.errors[0]}var he=et(l);async function nt(n){let e=rt(process.cwd(),n);process.chdir(tt(e));let t=he(e),r=t.default??t;"outputFiles"in r||(console.error('Configuration must include "outputFiles" property. Single file output is no longer supported.'),process.exit(1)),r.outputFiles&&r.outputFiles.outputDir&&W(r.outputFiles.outputDir);try{console.log("Generating multiple outputs..."),await ye(r),console.log("Done")}catch(o){console.error("Generation failed:",o),process.exit(1)}}async function ot(){let n=he("../../package.json"),e=Q();E.version(n.version).usage("<path/to/config.js>").parse(process.argv);let t=E.args[0];if(E.args.length===0){E.help();return}_(t),z(t,e),await nt(t)}ot().catch(n=>{console.error("CLI execution failed:",n),process.exit(1)});export{nt as runGeneration};
142
+ `}};async function de(n){let t=await new F(n).generateAll();if(!t.success&&t.errors.length>0)throw t.errors[0]}var he=tt(l);async function ot(n){let e=nt(process.cwd(),n);process.chdir(rt(e));let t=he(e),r=t.default??t;"outputFiles"in r||(console.error('Configuration must include "outputFiles" property. Single file output is no longer supported.'),process.exit(1)),r.outputFiles&&r.outputFiles.outputDir&&W(r.outputFiles.outputDir);try{console.log("Generating multiple outputs..."),await de(r),console.log("Done")}catch(o){console.error("Generation failed:",o),process.exit(1)}}async function it(){let n=he("../../package.json"),e=Q();q.version(n.version).usage("<path/to/config.js>").parse(process.argv);let t=q.args[0];if(q.args.length===0){q.help();return}_(t),B(t,e),await ot(t)}it().catch(n=>{console.error("CLI execution failed:",n),process.exit(1)});export{ot as runGeneration};
139
143
  //# sourceMappingURL=cli.mjs.map