@acrool/rtk-query-codegen-openapi 1.1.0 → 1.1.2

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/lib/bin/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
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((a,u)=>{let s=r(u),m=s?X(s):"_common";return a[m]||(a[m]=[]),a[m].push(u),a},{}),c={};for(let[a,u]of Object.entries(i))c[a]={groupKey:a,paths:u,outputPath:`${o}/${a}/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 */
2
+ var G=Object.defineProperty;var Ce=Object.getOwnPropertyDescriptor;var Te=Object.getOwnPropertyNames;var Ae=Object.prototype.hasOwnProperty;var k=(n,e)=>()=>(n&&(e=n(n=0)),e);var $e=(n,e)=>{for(var t in e)G(n,t,{get:e[t],enumerable:!0})},Se=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Te(e))!Ae.call(n,o)&&o!==t&&G(n,o,{get:()=>e[o],enumerable:!(r=Ce(e,o))||r.enumerable});return n};var Re=n=>Se(G({},"__esModule",{value:!0}),n);import{fileURLToPath as Ne}from"node:url";var Ee,l,c=k(()=>{"use strict";Ee=()=>Ne(import.meta.url),l=Ee()});var ie={};$e(ie,{argumentMatches:()=>Be,defaultIsDataResponse:()=>Qe,getOperationName:()=>S,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 S({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=S(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";c()});c();import q from"commander";import{createRequire as tt}from"node:module";c();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 p=U.join(r,i);if(Ge(p).isDirectory())t(p);else if(i==="enhanceEndpoints.ts"){let u=x("node:fs").readFileSync(p);e.set(p,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";c();c();import w from"node:path";import ye from"typescript";c();c();function C(n){return n.replace(n[0],n[0].toUpperCase())}c();import j from"node:fs";import Ke from"node:path";c();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}}c();c();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})):[])}c();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}c();function J(n,e,t,r){return r?r(n,e):t?.type?t.type==="query":n==="get"}var T=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={}}};c();import X from"lodash.camelcase";var A=class{groupPaths(e,t){let{groupKeyMatch:r,outputDir:o}=t,i=e.reduce((a,u)=>{let s=r(u),m=s?X(s):"_common";return a[m]||(a[m]=[]),a[m].push(u),a},{}),p={};for(let[a,u]of Object.entries(i))p[a]={groupKey:a,paths:u,outputPath:`${o}/${a}/query.service.ts`};return p}createGroupFilter(e,t){return(r,o)=>{let i=o.path,p=X(t.groupKeyMatch(i)||"");return p!==e&&(p||"_common")!==e?!1:t.filterEndpoint?t.filterEndpoint(r,i,e):!0}}};c();import re from"node:fs";import h from"node:path";c();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 $=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)}};c();import ze from"oazapfts/generate";var R=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(),Re(ie));return Z(this.v3Doc).filter(t(e))}getApiGenerator(){return this.apiGen}getDocument(){return this.v3Doc}getSchemaTypeNames(){return new Set}};c();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
- `}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 a=Le(i);o[i]=a;let u=He(c,i,a),s=e.printNode(d.EmitHint.Unspecified,u,t);r.push(s)}),`/* eslint-disable */
23
+ `}c();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(p){return d.isIdentifier(p)&&p.text===e?d.factory.createIdentifier(t):d.visitEachChild(p,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,p])=>{let a=Le(i);o[i]=a;let u=He(p,i,a),s=e.printNode(d.EmitHint.Unspecified,u,t);r.push(s)}),`/* eslint-disable */
24
24
  // [Warning] Generated automatically - do not edit manually
25
25
 
26
26
  ${r.join(`
27
27
  `)}
28
- `}p();function pe(){return`# \u8ACB\u52FF\u4FEE\u6539\u6B64\u8CC7\u6599\u593E
28
+ `}c();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,7 +44,7 @@ ${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
- `}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:a="Res",queryMatch:u,endpointOverrides:s}=this.options,m=N({verb:t,path:r}),g=i?C(m+i):m,y=C(m+i+c),v=C(m+i+a),O=J(t,r,M(e,s),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"),a=c.filter(g=>g.in==="query"),u=c.filter(g=>g.in==="path"),s=!!t.requestBody,m=a.length===0&&u.length===0&&!t.requestBody;return{queryParams:a,pathParams:u,isVoidArg:m,hasRequestBody:s}}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(s=>{if(o[s]=s,s.endsWith("Vo")){let m=s.slice(0,-2)+"VO";o[m]=s}if(s.endsWith("Dto")){let m=s.slice(0,-3)+"DTO";o[m]=s}});let i=`/* eslint-disable */
47
+ `}c();import fe from"typescript";c();K();import{supportDeepObjects as Ze}from"oazapfts/generate";var N=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:p="Req",responseSuffix:a="Res",queryMatch:u,endpointOverrides:s}=this.options,m=S({verb:t,path:r}),g=i?C(m+i):m,y=C(m+i+p),b=C(m+i+a),v=J(t,r,M(e,s),u),P=`${m.replace(/([A-Z])/g,"_$1").toUpperCase()}`,I=o.summary||`${t.toUpperCase()} ${r}`,{queryParams:Oe,pathParams:xe,isVoidArg:ve,hasRequestBody:be}=this.extractParameters(e),Pe=this.extractContentType(o);return{operationName:g,argTypeName:y,responseTypeName:b,isQuery:v,verb:t.toUpperCase(),path:r,queryKeyName:P,queryParams:Oe,pathParams:xe,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)),p=Ze([...i,...o]).filter(g=>g.in!=="header"),a=p.filter(g=>g.in==="query"),u=p.filter(g=>g.in==="path"),s=!!t.requestBody,m=a.length===0&&u.length===0&&!t.requestBody;return{queryParams:a,pathParams:u,isVoidArg:m,hasRequestBody:s}}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]}};c();var Ye=n=>n.charAt(0).toUpperCase()+n.slice(1);function ue(n,e,t,r){let o={};t&&Object.keys(t).forEach(s=>{if(o[s]=s,s.endsWith("Vo")){let m=s.slice(0,-2)+"VO";o[m]=s}if(s.endsWith("Dto")){let m=s.slice(0,-3)+"DTO";o[m]=s}});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";
@@ -52,12 +52,12 @@ ${r.join(`
52
52
  `;let a=[],u=[];return n.forEach(s=>{let m=s.argTypeName,g=s.responseTypeName;if(m){let y=Je(s,r,o);y.trim()===""?u.push(`export type ${m} = void;`,""):u.push(`export type ${m} = {`,y,"};","")}if(g){let y=Xe(s,r,o);y.trim()===""?u.push(`export type ${g} = void;`,""):u.push(`export type ${g} = {`,y,"};","")}}),u.length>0&&a.push(u.join(`
53
53
  `)),a.length===0&&a.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+a.join(`
54
54
 
55
- `)}function Je(n,e,t={}){let r=[];n.queryParams&&n.queryParams.length>0&&n.queryParams.forEach(i=>{let c=i.required?"":"?",a=ce(i,t);r.push(` ${i.name}${c}: ${a};`)}),n.pathParams&&n.pathParams.length>0&&n.pathParams.forEach(i=>{let c=i.required?"":"?",a=ce(i,t);r.push(` ${i.name}${c}: ${a};`)});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,a=c["application/json"],u=c["multipart/form-data"]||c["application/x-www-form-urlencoded"];if(a?.schema){let s=b(a.schema,t,1);r.push(` body: ${s};`)}else if(u?.schema){let s=b(u.schema,t,1);r.push(` body: ${s};`)}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 a=et(c.schema,t);r.push(...a)}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 a=r.includes(o)?"":"?",u=b(i,e,1),s=i.description?` // ${i.description}`:"",g=/[^a-zA-Z0-9_$]/.test(o)?`"${o}"`:o;t.push(` ${g}${a}: ${u};${s}`)})}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 a=" ".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`${a}${I}${v}: ${O};`}).join(`
55
+ `)}function Je(n,e,t={}){let r=[];n.queryParams&&n.queryParams.length>0&&n.queryParams.forEach(i=>{let p=i.required?"":"?",a=ce(i,t);r.push(` ${i.name}${p}: ${a};`)}),n.pathParams&&n.pathParams.length>0&&n.pathParams.forEach(i=>{let p=i.required?"":"?",a=ce(i,t);r.push(` ${i.name}${p}: ${a};`)});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 p=o.operation.requestBody.content,a=p["application/json"]||p["*/*"],u=p["multipart/form-data"]||p["application/x-www-form-urlencoded"];if(a?.schema){let s=O(a.schema,t,1);r.push(` body: ${s};`)}else if(u?.schema){let s=O(u.schema,t,1);r.push(` body: ${s};`)}else{let s=Object.values(p)[0];if(s?.schema){let m=O(s.schema,t,1);r.push(` body: ${m};`)}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 p=i.content["application/json"]||i.content["*/*"]||Object.values(i.content)[0];if(p?.schema){let a=et(p.schema,t);r.push(...a)}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 a=r.includes(o)?"":"?",u=O(i,e,1),m=/[^a-zA-Z0-9_$]/.test(o)?`"${o}"`:o;i.description&&t.push(` /** ${i.description} */`),t.push(` ${m}${a}: ${u};`)})}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/",""),p=e[i]||i,u=`Schema.${Ye(p)}`;return n.nullable?`${u} | null`:u}}let r;switch(n.type){case"string":n.enum?r=n.enum.map(p=>`"${p}"`).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 p=Object.entries(n.properties);if(p.length===0)n.additionalProperties?r=`Record<string, ${n.additionalProperties===!0?"any":O(n.additionalProperties,e,t)}>`:r="{}";else{let a=" ".repeat(t+1),u=" ".repeat(t),s=[];p.forEach(([m,g])=>{let b=(n.required||[]).includes(m)?"":"?",v=O(g,e,t+1),I=/[^a-zA-Z0-9_$]/.test(m)?`"${m}"`:m;g.description&&s.push(`${a}/** ${g.description} */`),s.push(`${a}${I}${b}: ${v};`)}),r=`{
58
+ ${s.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?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(s=>{let m=s.isQuery?"query":"mutation",g=s.isVoidArg?"void":`${r}<${s.argTypeName}>`,y=s.path;s.pathParams&&s.pathParams.length>0?(s.pathParams.forEach(O=>{y=y.replace(`{${O.name}}`,`\${queryArg.variables.${O.name}}`)}),y="`"+y+"`"):y=`"${y}"`;let v="";return s.queryParams&&s.queryParams.length>0&&(v=`
60
+ ${u}}`}}else n.additionalProperties?r=`Record<string, ${n.additionalProperties===!0?"any":O(n.additionalProperties,e,t)}>`: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"}c();function me(n,e){let{groupKey:t}=e,r=e.httpClient?.importReturnTypeName||e.httpClient?.importName||"IRestFulEndpointsQueryReturn",o=n.map(s=>{let m=s.isQuery?"query":"mutation",g=s.isVoidArg?"void":`${r}<${s.argTypeName}>`,y=s.path;s.pathParams&&s.pathParams.length>0?(s.pathParams.forEach(v=>{y=y.replace(`{${v.name}}`,`\${queryArg.variables.${v.name}}`)}),y="`"+y+"`"):y=`"${y}"`;let b="";return s.queryParams&&s.queryParams.length>0&&(b=`
61
61
  params: {
62
62
  ${s.queryParams.map(P=>` ${P.name}: queryArg.variables.${P.name},`).join(`
63
63
  `)}
@@ -69,20 +69,20 @@ ${s.queryParams.map(P=>` ${P.name}: queryArg.variables.${P.na
69
69
  query: (queryArg) => ({
70
70
  url: ${y},
71
71
  method: "${s.verb.toUpperCase()}",
72
- contentType: "${s.contentType}",${v}${s.hasRequestBody?`
72
+ contentType: "${s.contentType}",${b}${s.hasRequestBody?`
73
73
  body: queryArg.variables.body,`:""}${s.isVoidArg?"":`
74
74
  fetchOptions: queryArg?.fetchOptions,`}
75
75
  }),
76
76
  }),`}).join(`
77
- `),i=[...new Set([...n.map(s=>s.argTypeName),...n.map(s=>s.responseTypeName)])].filter(s=>s!=="VoidApiArg"),c=i.length>0?`import type { ${i.join(", ")} } from "./types";`:"",a=e.apiConfiguration?`import {${e.apiConfiguration.importName} as api } from "${e.apiConfiguration.file.replace(/\.ts$/,"")}";
77
+ `),i=[...new Set([...n.map(s=>s.argTypeName),...n.map(s=>s.responseTypeName)])].filter(s=>s!=="VoidApiArg"),p=i.length>0?`import type { ${i.join(", ")} } from "./types";`:"",a=e.apiConfiguration?`import {${e.apiConfiguration.importName} as api} from "${e.apiConfiguration.file.replace(/\.ts$/,"")}";
78
78
  `:`import {baseApi as api} from "../../../library/redux/baseApi";
79
- `,u=e.httpClient?`import {${e.httpClient.importReturnTypeName||e.httpClient.importName}} from "${e.httpClient.file}";
79
+ `,u=e.httpClient?`import {${e.httpClient.importReturnTypeName}} from "${e.httpClient.file}";
80
80
  `:`import {IRestFulEndpointsQueryReturn} from "@acrool/react-fetcher";
81
81
  `;return`/* eslint-disable */
82
82
  // [Warning] Generated automatically - do not edit manually
83
83
 
84
84
  ${a}${u}
85
- ${c}
85
+ ${p}
86
86
 
87
87
 
88
88
  const injectedRtkApi = api.injectEndpoints({
@@ -98,31 +98,31 @@ ${n.map(s=>{let m=s.operationName.charAt(0).toUpperCase()+s.operationName.slice(
98
98
  } = injectedRtkApi;
99
99
 
100
100
  export default injectedRtkApi;
101
- `}p();function le(n,e){let{groupKey:t}=e;return`/* eslint-disable */
101
+ `}c();function le(n,e){let{groupKey:t,cacheTagTypes:r}=e,o=n.map(p=>p.isQuery?` ${p.operationName}: {
102
+ providesTags: (result, error, arg) => [],
103
+ },`:` ${p.operationName}: {
104
+ invalidatesTags: (result, error, arg) => [],
105
+ },`).join(`
106
+ `),i=`/* eslint-disable */
102
107
  // [Warning] Generated automatically - do not edit manually
103
108
 
104
- import { ECacheTagTypes } from "@/store/tagTypes";
105
- import api from "./query.generated";
106
-
109
+ `;return r&&(i+=`import { ${r.importReturnTypeName} } from "${r.file}";
110
+ `),i+=`import api from "./query.generated";
111
+ `,`${i}
107
112
  const enhancedApi = api.enhanceEndpoints({
108
113
  endpoints: {
109
- ${n.map(o=>o.isQuery?` ${o.operationName}: {
110
- providesTags: (result, error, arg) => [],
111
- },`:` ${o.operationName}: {
112
- invalidatesTags: (result, error, arg) => [],
113
- },`).join(`
114
- `)}
114
+ ${o}
115
115
  },
116
116
  });
117
117
 
118
118
  export default enhancedApi;
119
- `}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(a=>a.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,a)=>{if(fe.isInterfaceDeclaration(a)||fe.isTypeAliasDeclaration(a)){let u=a.name.text;return{...c,[u]:a}}return c},{}),i=this.parserService.getOperationDefinitions(this.options.filterEndpoints);return ue(e,t,o,i)}generateIndex(){let e=this.options.groupKey||"";return`/* eslint-disable */
119
+ `}var E=class{constructor(e,t){this.parserService=e;this.options=t;this.infoExtractor=new N(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(a=>a.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((p,a)=>{if(fe.isInterfaceDeclaration(a)||fe.isTypeAliasDeclaration(a)){let u=a.name.text;return{...p,[u]:a}}return p},{}),i=this.parserService.getOperationDefinitions(this.options.filterEndpoints);return ue(e,t,o,i)}generateIndex(){let e=this.options.groupKey||"";return`/* eslint-disable */
120
120
  // [Warning] Generated automatically - do not edit manually
121
121
 
122
122
  export { default as ${e?`${e.charAt(0).toLowerCase()+e.slice(1)}Api`:"api"} } from "./enhanceEndpoints";
123
123
  export * from "./query.generated";
124
124
  export * from "./types";
125
- `}};p();function ge(){return`/* eslint-disable */
125
+ `}};c();function ge(){return`/* eslint-disable */
126
126
  // [Warning] Generated automatically - do not edit manually
127
127
 
128
128
  /**
@@ -135,7 +135,7 @@ export function withoutUndefined(obj?: Record<string, any>) {
135
135
  );
136
136
  }
137
137
 
138
- `}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 a of this.generatedContent.groups)try{if(a.content?.files){let u=w.dirname(a.outputPath),s=await this.fileWriterService.writeGroupFiles(u,{types:a.content.files.types,queryService:a.content.files.queryService,enhanceEndpoints:a.content.files.enhanceEndpoints,index:a.content.files.index});e.push(...s),r.push(a.groupKey)}}catch(u){t.push(new Error(`\u5BEB\u5165\u7FA4\u7D44 ${a.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 a=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(...a)}if(this.generatedContent.componentSchema){let a=await this.fileWriterService.writeSchemaFile(o,this.generatedContent.componentSchema);e.push(...a)}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 */
138
+ `}var F=class{_options;openApiService=new T;groupService=new A;fileWriterService=new $;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 R(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 a of this.generatedContent.groups)try{if(a.content?.files){let u=w.dirname(a.outputPath),s=await this.fileWriterService.writeGroupFiles(u,{types:a.content.files.types,queryService:a.content.files.queryService,enhanceEndpoints:a.content.files.enhanceEndpoints,index:a.content.files.index});e.push(...s),r.push(a.groupKey)}}catch(u){t.push(new Error(`\u5BEB\u5165\u7FA4\u7D44 ${a.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 a=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(...a)}if(this.generatedContent.componentSchema){let a=await this.fileWriterService.writeSchemaFile(o,this.generatedContent.componentSchema);e.push(...a)}let i=this.generateMainIndex(r),p=await this.fileWriterService.writeFile(w.join(o,"index.ts"),i);e.push(p)}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 */
139
139
  // [Warning] Generated automatically - do not edit manually
140
140
 
141
141
  ${e.map(r=>`export * from "./${r}";`).join(`