swagger-typescript-api 13.0.25 → 13.0.26
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/CHANGELOG.md +12 -0
- package/dist/{chunk-NLO3XRFX.cjs → chunk-LI5RQUAL.cjs} +5 -5
- package/dist/{chunk-NLO3XRFX.cjs.map → chunk-LI5RQUAL.cjs.map} +1 -1
- package/dist/{chunk-TXFFSIK5.js → chunk-U2TAGTOU.js} +3 -3
- package/dist/{chunk-TXFFSIK5.js.map → chunk-U2TAGTOU.js.map} +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/lib.cjs +1 -1
- package/dist/lib.js +1 -1
- package/package.json +2 -2
package/dist/cli.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
'use strict';var
|
|
2
|
+
'use strict';var chunkLI5RQUAL_cjs=require('./chunk-LI5RQUAL.cjs'),i=require('path'),f=require('url'),citty=require('citty'),consola=require('consola');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var i__namespace=/*#__PURE__*/_interopNamespace(i);var f__namespace=/*#__PURE__*/_interopNamespace(f);var o=new chunkLI5RQUAL_cjs.e({}),b=citty.defineCommand({meta:{name:"generate-templates",description:'Generate ".ejs" templates needed for generate api'},args:{"clean-output":{type:"boolean",description:"clean output folder before generate template. WARNING: May cause data loss",default:o.cleanOutput},"http-client":{type:"string",description:`http client type (possible values: ${Object.values(chunkLI5RQUAL_cjs.b)})`,default:o.httpClientType},modular:{type:"boolean",description:"generate templates needed to separate files for http client, data contracts, and routes",default:o.modular},output:{type:"string",alias:"o",description:"output path of generated templates",default:o.output},rewrite:{type:"boolean",alias:"r",description:"rewrite content in existing templates",default:o.rewrite},silent:{type:"boolean",description:"Output only errors to console",default:o.silent},debug:{type:"boolean",description:"additional information about processes inside this tool",default:o.debug}},run:async({args:e})=>{await chunkLI5RQUAL_cjs.f({cleanOutput:e["clean-output"],httpClientType:e["http-client"],modular:e.modular,output:e.output,rewrite:e.rewrite,silent:e.silent,debug:e.debug});}}),t=new chunkLI5RQUAL_cjs.d({}),h=citty.defineCommand({meta:{name:"generate",description:chunkLI5RQUAL_cjs.a.description},args:{path:{type:"string",alias:"p",description:"path/url to swagger scheme",required:true},output:{type:"string",alias:"o",description:"output path of typescript api file",default:"./"},name:{type:"string",alias:"n",description:"name of output typescript api file",default:t.fileName},templates:{type:"string",alias:"t",description:"path to folder containing templates"},"default-as-success":{type:"boolean",alias:"d",description:'use "default" response status code as success response too. some swagger schemas use "default" response status code as success response type by default.',default:t.defaultResponseAsSuccess},responses:{type:"boolean",alias:"r",description:"generate additional information about request responses also add typings for bad responses",default:t.generateResponses},"union-enums":{type:"boolean",description:'generate all "enum" types as union types (T1 | T2 | TN)',default:t.generateUnionEnums},"add-readonly":{type:"boolean",description:"generate readonly properties",default:t.addReadonly},"route-types":{type:"boolean",description:"generate type definitions for API routes",default:t.generateRouteTypes},"no-client":{type:"boolean",description:"do not generate an API class",default:!t.generateClient},"enum-names-as-values":{type:"boolean",description:"use values in 'x-enumNames' as enum values (not only as keys)",default:t.enumNamesAsValues},"extract-request-params":{type:"boolean",description:"extract request params to data contract (Also combine path params and query params into one object)",default:t.extractRequestParams},"extract-request-body":{type:"boolean",description:"extract request body type to data contract",default:t.extractRequestBody},"extract-response-body":{type:"boolean",description:"extract response body type to data contract",default:t.extractResponseBody},"extract-response-error":{type:"boolean",description:"extract response error type to data contract",default:t.extractResponseError},"extract-responses":{type:"boolean",description:"extract all responses described in /components/responses",default:t.extractResponses},modular:{type:"boolean",description:"generate separated files for http client, data contracts, and routes",default:t.modular},js:{type:"boolean",description:"generate js api module with declaration file",default:t.toJS},"module-name-index":{type:"string",description:"determines which path index should be used for routes separation (example: GET:/fruits/getFruit -> index:0 -> moduleName -> fruits)",default:t.moduleNameIndex.toString()},"module-name-first-tag":{type:"boolean",description:"splits routes based on the first tag",default:t.moduleNameFirstTag},axios:{type:"boolean",description:"generate axios http client",default:false},"unwrap-response-data":{type:"boolean",description:"unwrap the data item from the response",default:t.unwrapResponseData},"disable-throw-on-error":{type:"boolean",description:"Do not throw an error when response.ok is not true",default:t.disableThrowOnError},"single-http-client":{type:"boolean",description:"Ability to send HttpClient instance to Api constructor",default:t.singleHttpClient},silent:{type:"boolean",description:"Output only errors to console",default:t.silent},"default-response":{type:"string",description:"default type for empty response schema",default:t.defaultResponseType},"type-prefix":{type:"string",description:"data contract name prefix",default:t.typePrefix},"type-suffix":{type:"string",description:"data contract name suffix",default:t.typeSuffix},"clean-output":{type:"boolean",description:"clean output folder before generate api. WARNING: May cause data loss",default:t.cleanOutput},"api-class-name":{type:"string",description:"name of the api class",default:t.apiClassName},patch:{type:"boolean",description:"fix up small errors in the swagger source definition",default:t.patch},debug:{type:"boolean",description:"additional information about processes inside this tool",default:t.debug},"another-array-type":{type:"boolean",description:"generate array types as Array<Type> (by default Type[])",default:t.anotherArrayType},"sort-types":{type:"boolean",description:"sort fields and types",default:t.sortTypes},"extract-enums":{type:"boolean",description:"extract all enums from inline interface/type content to typescript enum construction",default:t.extractEnums},"sort-routes":{type:"boolean",description:"sort routes in alphabetical order",default:t.sortRoutes},"custom-config":{type:"string",description:"custom config: primitiveTypeConstructs, hooks, ... "}},run:async({args:e})=>{let a;if(e["custom-config"])try{let s=f__namespace.pathToFileURL(i__namespace.resolve(process.cwd(),e["custom-config"])).toString();a=await import(s),a=a.default||a,a&&consola.consola.info(`Found custom config at: ${s}`);}catch(s){consola.consola.error("Error loading custom config:",s);}await chunkLI5RQUAL_cjs.g({addReadonly:e["add-readonly"],anotherArrayType:e["another-array-type"],apiClassName:e["api-class-name"],cleanOutput:e["clean-output"],debug:e.debug,defaultResponseAsSuccess:e["default-as-success"],defaultResponseType:e["default-response"],disableThrowOnError:e["disable-throw-on-error"],enumNamesAsValues:e["enum-names-as-values"],extractEnums:e["extract-enums"],extractRequestBody:e["extract-request-body"],extractRequestParams:e["extract-request-params"],extractResponseBody:e["extract-response-body"],extractResponseError:e["extract-response-error"],extractResponses:e["extract-responses"],fileName:e.name,generateClient:!e["no-client"],generateResponses:e.responses,generateRouteTypes:e["route-types"],generateUnionEnums:e["union-enums"],httpClientType:e["http-client"]||e.axios?chunkLI5RQUAL_cjs.b.AXIOS:chunkLI5RQUAL_cjs.b.FETCH,input:i__namespace.resolve(process.cwd(),e.path),modular:e.modular,moduleNameFirstTag:e["module-name-first-tag"],moduleNameIndex:+e["module-name-index"]||0,output:i__namespace.resolve(process.cwd(),e.output||"."),patch:e.patch,silent:e.silent,singleHttpClient:e["single-http-client"],sortRoutes:e["sort-routes"],sortTypes:e["sort-types"],templates:e.templates,toJS:e.js,typePrefix:e["type-prefix"],typeSuffix:e["type-suffix"],unwrapResponseData:e["unwrap-response-data"],url:e.path,...a});}}),x=citty.defineCommand({meta:{name:chunkLI5RQUAL_cjs.a.name,description:chunkLI5RQUAL_cjs.a.description,version:chunkLI5RQUAL_cjs.a.version},subCommands:{generate:h,"generate-templates":b}});citty.runMain(x);//# sourceMappingURL=cli.cjs.map
|
|
3
3
|
//# sourceMappingURL=cli.cjs.map
|
package/dist/cli.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../index.ts"],"names":["templateGenBaseConfig","TemplatesGenConfig","generateTemplatesCommand","defineCommand","HTTP_CLIENT","args","generateTemplates","codeGenBaseConfig","CodeGenConfig","generateCommand","package_default","customConfig","customConfigPath","f","i","consola","error","generateApi","main","runMain"],"mappings":";ijBAaA,IAAMA,EAAwB,IAAIC,mBAAAA,CAAmB,EAAE,CAAA,CAEjDC,EAA2BC,mBAAc,CAAA,CAC7C,KA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WAAa,CAAA,CACX,SAAUD,CACV,CAAA,oBAAA,CAAsBP,CACxB,CACF,CAAC,CAEDiB,CAAAA,aAAAA,CAAQD,CAAI,CAAA","file":"cli.cjs","sourcesContent":["#!/usr/bin/env node\n\nimport * as path from \"node:path\";\nimport * as url from \"node:url\";\nimport { defineCommand, runMain } from \"citty\";\nimport { consola } from \"consola\";\nimport packageJson from \"./package.json\" with { type: \"json\" };\nimport { TemplatesGenConfig } from \"./src/commands/generate-templates/configuration.js\";\nimport { CodeGenConfig } from \"./src/configuration.js\";\nimport { HTTP_CLIENT } from \"./src/constants.js\";\nimport { generateApi, generateTemplates } from \"./src/index.js\";\nimport type { HttpClientType } from \"./types/index.js\";\n\nconst templateGenBaseConfig = new TemplatesGenConfig({});\n\nconst generateTemplatesCommand = defineCommand({\n meta: {\n name: \"generate-templates\",\n description: 'Generate \".ejs\" templates needed for generate api',\n },\n args: {\n \"clean-output\": {\n type: \"boolean\",\n description:\n \"clean output folder before generate template. WARNING: May cause data loss\",\n default: templateGenBaseConfig.cleanOutput,\n },\n \"http-client\": {\n type: \"string\",\n description: `http client type (possible values: ${Object.values(\n HTTP_CLIENT,\n )})`,\n default: templateGenBaseConfig.httpClientType,\n },\n modular: {\n type: \"boolean\",\n description:\n \"generate templates needed to separate files for http client, data contracts, and routes\",\n default: templateGenBaseConfig.modular,\n },\n output: {\n type: \"string\",\n alias: \"o\",\n description: \"output path of generated templates\",\n default: templateGenBaseConfig.output,\n },\n rewrite: {\n type: \"boolean\",\n alias: \"r\",\n description: \"rewrite content in existing templates\",\n default: templateGenBaseConfig.rewrite,\n },\n silent: {\n type: \"boolean\",\n description: \"Output only errors to console\",\n default: templateGenBaseConfig.silent,\n },\n debug: {\n type: \"boolean\",\n description: \"additional information about processes inside this tool\",\n default: templateGenBaseConfig.debug,\n },\n },\n run: async ({ args }) => {\n await generateTemplates({\n cleanOutput: args[\"clean-output\"],\n httpClientType: args[\"http-client\"] as HttpClientType,\n modular: args.modular,\n output: args.output,\n rewrite: args.rewrite,\n silent: args.silent,\n debug: args.debug,\n });\n },\n});\n\nconst codeGenBaseConfig = new CodeGenConfig({});\n\nconst generateCommand = defineCommand({\n meta: {\n name: \"generate\",\n description: packageJson.description,\n },\n args: {\n path: {\n type: \"string\",\n alias: \"p\",\n description: \"path/url to swagger scheme\",\n required: true,\n },\n output: {\n type: \"string\",\n alias: \"o\",\n description: \"output path of typescript api file\",\n default: \"./\",\n },\n name: {\n type: \"string\",\n alias: \"n\",\n description: \"name of output typescript api file\",\n default: codeGenBaseConfig.fileName,\n },\n templates: {\n type: \"string\",\n alias: \"t\",\n description: \"path to folder containing templates\",\n },\n \"default-as-success\": {\n type: \"boolean\",\n alias: \"d\",\n description:\n 'use \"default\" response status code as success response too. some swagger schemas use \"default\" response status code as success response type by default.',\n default: codeGenBaseConfig.defaultResponseAsSuccess,\n },\n responses: {\n type: \"boolean\",\n alias: \"r\",\n description:\n \"generate additional information about request responses also add typings for bad responses\",\n default: codeGenBaseConfig.generateResponses,\n },\n \"union-enums\": {\n type: \"boolean\",\n description: 'generate all \"enum\" types as union types (T1 | T2 | TN)',\n default: codeGenBaseConfig.generateUnionEnums,\n },\n \"add-readonly\": {\n type: \"boolean\",\n description: \"generate readonly properties\",\n default: codeGenBaseConfig.addReadonly,\n },\n \"route-types\": {\n type: \"boolean\",\n description: \"generate type definitions for API routes\",\n default: codeGenBaseConfig.generateRouteTypes,\n },\n \"no-client\": {\n type: \"boolean\",\n description: \"do not generate an API class\",\n default: codeGenBaseConfig.generateClient,\n },\n \"enum-names-as-values\": {\n type: \"boolean\",\n description:\n \"use values in 'x-enumNames' as enum values (not only as keys)\",\n default: codeGenBaseConfig.enumNamesAsValues,\n },\n \"extract-request-params\": {\n description:\n \"extract request params to data contract (Also combine path params and query params into one object)\",\n default: codeGenBaseConfig.extractRequestParams,\n },\n \"extract-request-body\": {\n type: \"boolean\",\n description: \"extract request body type to data contract\",\n default: codeGenBaseConfig.extractRequestBody,\n },\n \"extract-response-body\": {\n type: \"boolean\",\n description: \"extract response body type to data contract\",\n default: codeGenBaseConfig.extractResponseBody,\n },\n \"extract-response-error\": {\n type: \"boolean\",\n description: \"extract response error type to data contract\",\n default: codeGenBaseConfig.extractResponseError,\n },\n \"extract-responses\": {\n type: \"boolean\",\n description: \"extract all responses described in /components/responses\",\n default: codeGenBaseConfig.extractResponses,\n },\n modular: {\n type: \"boolean\",\n description:\n \"generate separated files for http client, data contracts, and routes\",\n default: codeGenBaseConfig.modular,\n },\n js: {\n type: \"boolean\",\n description: \"generate js api module with declaration file\",\n default: codeGenBaseConfig.toJS,\n },\n \"module-name-index\": {\n type: \"string\",\n description:\n \"determines which path index should be used for routes separation (example: GET:/fruits/getFruit -> index:0 -> moduleName -> fruits)\",\n default: codeGenBaseConfig.moduleNameIndex.toString(),\n },\n \"module-name-first-tag\": {\n type: \"boolean\",\n description: \"splits routes based on the first tag\",\n default: codeGenBaseConfig.moduleNameFirstTag,\n },\n axios: {\n type: \"boolean\",\n description: \"generate axios http client\",\n default: false,\n },\n \"unwrap-response-data\": {\n type: \"boolean\",\n description: \"unwrap the data item from the response\",\n default: codeGenBaseConfig.unwrapResponseData,\n },\n \"disable-throw-on-error\": {\n type: \"boolean\",\n description: \"Do not throw an error when response.ok is not true\",\n default: codeGenBaseConfig.disableThrowOnError,\n },\n \"single-http-client\": {\n type: \"boolean\",\n description: \"Ability to send HttpClient instance to Api constructor\",\n default: codeGenBaseConfig.singleHttpClient,\n },\n silent: {\n type: \"boolean\",\n description: \"Output only errors to console\",\n default: codeGenBaseConfig.silent,\n },\n \"default-response\": {\n type: \"string\",\n description: \"default type for empty response schema\",\n default: codeGenBaseConfig.defaultResponseType,\n },\n \"type-prefix\": {\n type: \"string\",\n description: \"data contract name prefix\",\n default: codeGenBaseConfig.typePrefix,\n },\n \"type-suffix\": {\n type: \"string\",\n description: \"data contract name suffix\",\n default: codeGenBaseConfig.typeSuffix,\n },\n \"clean-output\": {\n type: \"boolean\",\n description:\n \"clean output folder before generate api. WARNING: May cause data loss\",\n default: codeGenBaseConfig.cleanOutput,\n },\n \"api-class-name\": {\n type: \"string\",\n description: \"name of the api class\",\n default: codeGenBaseConfig.apiClassName,\n },\n patch: {\n type: \"boolean\",\n description: \"fix up small errors in the swagger source definition\",\n default: codeGenBaseConfig.patch,\n },\n debug: {\n type: \"boolean\",\n description: \"additional information about processes inside this tool\",\n default: codeGenBaseConfig.debug,\n },\n \"another-array-type\": {\n type: \"boolean\",\n description: \"generate array types as Array<Type> (by default Type[])\",\n default: codeGenBaseConfig.anotherArrayType,\n },\n \"sort-types\": {\n type: \"boolean\",\n description: \"sort fields and types\",\n default: codeGenBaseConfig.sortTypes,\n },\n \"extract-enums\": {\n type: \"boolean\",\n description:\n \"extract all enums from inline interface/type content to typescript enum construction\",\n default: codeGenBaseConfig.extractEnums,\n },\n \"sort-routes\": {\n type: \"boolean\",\n description: \"sort routes in alphabetical order\",\n default: codeGenBaseConfig.sortRoutes,\n },\n \"custom-config\": {\n type: \"string\",\n description: \"custom config: primitiveTypeConstructs, hooks, ... \",\n },\n },\n run: async ({ args }) => {\n let customConfig;\n\n if (args[\"custom-config\"]) {\n try {\n const customConfigPath = url\n .pathToFileURL(path.resolve(process.cwd(), args[\"custom-config\"]))\n .toString();\n customConfig = await import(customConfigPath);\n customConfig = customConfig.default || customConfig;\n if (customConfig) {\n consola.info(`Found custom config at: ${customConfigPath}`);\n }\n } catch (error) {\n consola.error(\"Error loading custom config:\", error);\n }\n }\n\n await generateApi({\n addReadonly: args[\"add-readonly\"],\n anotherArrayType: args[\"another-array-type\"],\n apiClassName: args[\"api-class-name\"],\n cleanOutput: args[\"clean-output\"],\n debug: args.debug,\n defaultResponseAsSuccess: args[\"default-as-success\"],\n defaultResponseType: args[\"default-response\"],\n disableThrowOnError: args[\"disable-throw-on-error\"],\n enumNamesAsValues: args[\"enum-names-as-values\"],\n extractEnums: args[\"extract-enums\"],\n extractRequestBody: args[\"extract-request-body\"],\n extractRequestParams: args[\"extract-request-params\"],\n extractResponseBody: args[\"extract-response-body\"],\n extractResponseError: args[\"extract-response-error\"],\n extractResponses: args[\"extract-responses\"],\n fileName: args.name,\n generateClient: !(args.axios || args[\"no-client\"]),\n generateResponses: args.responses,\n generateRouteTypes: args[\"route-types\"],\n generateUnionEnums: args[\"union-enums\"],\n httpClientType:\n args[\"http-client\"] || args.axios\n ? HTTP_CLIENT.AXIOS\n : HTTP_CLIENT.FETCH,\n input: path.resolve(process.cwd(), args.path as string),\n modular: args.modular,\n moduleNameFirstTag: args[\"module-name-first-tag\"],\n moduleNameIndex: +args[\"module-name-index\"] || 0,\n output: path.resolve(process.cwd(), (args.output as string) || \".\"),\n patch: args.patch,\n silent: args.silent,\n singleHttpClient: args[\"single-http-client\"],\n sortRoutes: args[\"sort-routes\"],\n sortTypes: args[\"sort-types\"],\n templates: args.templates,\n toJS: args.js,\n typePrefix: args[\"type-prefix\"],\n typeSuffix: args[\"type-suffix\"],\n unwrapResponseData: args[\"unwrap-response-data\"],\n url: args.path,\n ...customConfig,\n });\n },\n});\n\nconst main = defineCommand({\n meta: {\n name: packageJson.name,\n description: packageJson.description,\n version: packageJson.version,\n },\n subCommands: {\n generate: generateCommand,\n \"generate-templates\": generateTemplatesCommand,\n },\n});\n\nrunMain(main);\n"]}
|
|
1
|
+
{"version":3,"sources":["../index.ts"],"names":["templateGenBaseConfig","TemplatesGenConfig","generateTemplatesCommand","defineCommand","HTTP_CLIENT","args","generateTemplates","codeGenBaseConfig","CodeGenConfig","generateCommand","package_default","customConfig","customConfigPath","f","i","consola","error","generateApi","main","runMain"],"mappings":";ijBAaA,IAAMA,EAAwB,IAAIC,mBAAAA,CAAmB,EAAE,CAAA,CAEjDC,EAA2BC,mBAAc,CAAA,CAC7C,KAAM,CACJ,IAAA,CAAM,qBACN,WAAa,CAAA,mDACf,EACA,IAAM,CAAA,CACJ,eAAgB,CACd,IAAA,CAAM,UACN,WACE,CAAA,4EAAA,CACF,QAASH,CAAsB,CAAA,WACj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path from \"node:path\";\nimport * as url from \"node:url\";\nimport { defineCommand, runMain } from \"citty\";\nimport { consola } from \"consola\";\nimport packageJson from \"./package.json\" with { type: \"json\" };\nimport { TemplatesGenConfig } from \"./src/commands/generate-templates/configuration.js\";\nimport { CodeGenConfig } from \"./src/configuration.js\";\nimport { HTTP_CLIENT } from \"./src/constants.js\";\nimport { generateApi, generateTemplates } from \"./src/index.js\";\nimport type { HttpClientType } from \"./types/index.js\";\n\nconst templateGenBaseConfig = new TemplatesGenConfig({});\n\nconst generateTemplatesCommand = defineCommand({\n meta: {\n name: \"generate-templates\",\n description: 'Generate \".ejs\" templates needed for generate api',\n },\n args: {\n \"clean-output\": {\n type: \"boolean\",\n description:\n \"clean output folder before generate template. WARNING: May cause data loss\",\n default: templateGenBaseConfig.cleanOutput,\n },\n \"http-client\": {\n type: \"string\",\n description: `http client type (possible values: ${Object.values(\n HTTP_CLIENT,\n )})`,\n default: templateGenBaseConfig.httpClientType,\n },\n modular: {\n type: \"boolean\",\n description:\n \"generate templates needed to separate files for http client, data contracts, and routes\",\n default: templateGenBaseConfig.modular,\n },\n output: {\n type: \"string\",\n alias: \"o\",\n description: \"output path of generated templates\",\n default: templateGenBaseConfig.output,\n },\n rewrite: {\n type: \"boolean\",\n alias: \"r\",\n description: \"rewrite content in existing templates\",\n default: templateGenBaseConfig.rewrite,\n },\n silent: {\n type: \"boolean\",\n description: \"Output only errors to console\",\n default: templateGenBaseConfig.silent,\n },\n debug: {\n type: \"boolean\",\n description: \"additional information about processes inside this tool\",\n default: templateGenBaseConfig.debug,\n },\n },\n run: async ({ args }) => {\n await generateTemplates({\n cleanOutput: args[\"clean-output\"],\n httpClientType: args[\"http-client\"] as HttpClientType,\n modular: args.modular,\n output: args.output,\n rewrite: args.rewrite,\n silent: args.silent,\n debug: args.debug,\n });\n },\n});\n\nconst codeGenBaseConfig = new CodeGenConfig({});\n\nconst generateCommand = defineCommand({\n meta: {\n name: \"generate\",\n description: packageJson.description,\n },\n args: {\n path: {\n type: \"string\",\n alias: \"p\",\n description: \"path/url to swagger scheme\",\n required: true,\n },\n output: {\n type: \"string\",\n alias: \"o\",\n description: \"output path of typescript api file\",\n default: \"./\",\n },\n name: {\n type: \"string\",\n alias: \"n\",\n description: \"name of output typescript api file\",\n default: codeGenBaseConfig.fileName,\n },\n templates: {\n type: \"string\",\n alias: \"t\",\n description: \"path to folder containing templates\",\n },\n \"default-as-success\": {\n type: \"boolean\",\n alias: \"d\",\n description:\n 'use \"default\" response status code as success response too. some swagger schemas use \"default\" response status code as success response type by default.',\n default: codeGenBaseConfig.defaultResponseAsSuccess,\n },\n responses: {\n type: \"boolean\",\n alias: \"r\",\n description:\n \"generate additional information about request responses also add typings for bad responses\",\n default: codeGenBaseConfig.generateResponses,\n },\n \"union-enums\": {\n type: \"boolean\",\n description: 'generate all \"enum\" types as union types (T1 | T2 | TN)',\n default: codeGenBaseConfig.generateUnionEnums,\n },\n \"add-readonly\": {\n type: \"boolean\",\n description: \"generate readonly properties\",\n default: codeGenBaseConfig.addReadonly,\n },\n \"route-types\": {\n type: \"boolean\",\n description: \"generate type definitions for API routes\",\n default: codeGenBaseConfig.generateRouteTypes,\n },\n \"no-client\": {\n type: \"boolean\",\n description: \"do not generate an API class\",\n default: !codeGenBaseConfig.generateClient,\n },\n \"enum-names-as-values\": {\n type: \"boolean\",\n description:\n \"use values in 'x-enumNames' as enum values (not only as keys)\",\n default: codeGenBaseConfig.enumNamesAsValues,\n },\n \"extract-request-params\": {\n type: \"boolean\",\n description:\n \"extract request params to data contract (Also combine path params and query params into one object)\",\n default: codeGenBaseConfig.extractRequestParams,\n },\n \"extract-request-body\": {\n type: \"boolean\",\n description: \"extract request body type to data contract\",\n default: codeGenBaseConfig.extractRequestBody,\n },\n \"extract-response-body\": {\n type: \"boolean\",\n description: \"extract response body type to data contract\",\n default: codeGenBaseConfig.extractResponseBody,\n },\n \"extract-response-error\": {\n type: \"boolean\",\n description: \"extract response error type to data contract\",\n default: codeGenBaseConfig.extractResponseError,\n },\n \"extract-responses\": {\n type: \"boolean\",\n description: \"extract all responses described in /components/responses\",\n default: codeGenBaseConfig.extractResponses,\n },\n modular: {\n type: \"boolean\",\n description:\n \"generate separated files for http client, data contracts, and routes\",\n default: codeGenBaseConfig.modular,\n },\n js: {\n type: \"boolean\",\n description: \"generate js api module with declaration file\",\n default: codeGenBaseConfig.toJS,\n },\n \"module-name-index\": {\n type: \"string\",\n description:\n \"determines which path index should be used for routes separation (example: GET:/fruits/getFruit -> index:0 -> moduleName -> fruits)\",\n default: codeGenBaseConfig.moduleNameIndex.toString(),\n },\n \"module-name-first-tag\": {\n type: \"boolean\",\n description: \"splits routes based on the first tag\",\n default: codeGenBaseConfig.moduleNameFirstTag,\n },\n axios: {\n type: \"boolean\",\n description: \"generate axios http client\",\n default: false,\n },\n \"unwrap-response-data\": {\n type: \"boolean\",\n description: \"unwrap the data item from the response\",\n default: codeGenBaseConfig.unwrapResponseData,\n },\n \"disable-throw-on-error\": {\n type: \"boolean\",\n description: \"Do not throw an error when response.ok is not true\",\n default: codeGenBaseConfig.disableThrowOnError,\n },\n \"single-http-client\": {\n type: \"boolean\",\n description: \"Ability to send HttpClient instance to Api constructor\",\n default: codeGenBaseConfig.singleHttpClient,\n },\n silent: {\n type: \"boolean\",\n description: \"Output only errors to console\",\n default: codeGenBaseConfig.silent,\n },\n \"default-response\": {\n type: \"string\",\n description: \"default type for empty response schema\",\n default: codeGenBaseConfig.defaultResponseType,\n },\n \"type-prefix\": {\n type: \"string\",\n description: \"data contract name prefix\",\n default: codeGenBaseConfig.typePrefix,\n },\n \"type-suffix\": {\n type: \"string\",\n description: \"data contract name suffix\",\n default: codeGenBaseConfig.typeSuffix,\n },\n \"clean-output\": {\n type: \"boolean\",\n description:\n \"clean output folder before generate api. WARNING: May cause data loss\",\n default: codeGenBaseConfig.cleanOutput,\n },\n \"api-class-name\": {\n type: \"string\",\n description: \"name of the api class\",\n default: codeGenBaseConfig.apiClassName,\n },\n patch: {\n type: \"boolean\",\n description: \"fix up small errors in the swagger source definition\",\n default: codeGenBaseConfig.patch,\n },\n debug: {\n type: \"boolean\",\n description: \"additional information about processes inside this tool\",\n default: codeGenBaseConfig.debug,\n },\n \"another-array-type\": {\n type: \"boolean\",\n description: \"generate array types as Array<Type> (by default Type[])\",\n default: codeGenBaseConfig.anotherArrayType,\n },\n \"sort-types\": {\n type: \"boolean\",\n description: \"sort fields and types\",\n default: codeGenBaseConfig.sortTypes,\n },\n \"extract-enums\": {\n type: \"boolean\",\n description:\n \"extract all enums from inline interface/type content to typescript enum construction\",\n default: codeGenBaseConfig.extractEnums,\n },\n \"sort-routes\": {\n type: \"boolean\",\n description: \"sort routes in alphabetical order\",\n default: codeGenBaseConfig.sortRoutes,\n },\n \"custom-config\": {\n type: \"string\",\n description: \"custom config: primitiveTypeConstructs, hooks, ... \",\n },\n },\n run: async ({ args }) => {\n let customConfig = undefined;\n\n if (args[\"custom-config\"]) {\n try {\n const customConfigPath = url\n .pathToFileURL(path.resolve(process.cwd(), args[\"custom-config\"]))\n .toString();\n customConfig = await import(customConfigPath);\n customConfig = customConfig.default || customConfig;\n if (customConfig) {\n consola.info(`Found custom config at: ${customConfigPath}`);\n }\n } catch (error) {\n consola.error(\"Error loading custom config:\", error);\n }\n }\n\n await generateApi({\n addReadonly: args[\"add-readonly\"],\n anotherArrayType: args[\"another-array-type\"],\n apiClassName: args[\"api-class-name\"],\n cleanOutput: args[\"clean-output\"],\n debug: args.debug,\n defaultResponseAsSuccess: args[\"default-as-success\"],\n defaultResponseType: args[\"default-response\"],\n disableThrowOnError: args[\"disable-throw-on-error\"],\n enumNamesAsValues: args[\"enum-names-as-values\"],\n extractEnums: args[\"extract-enums\"],\n extractRequestBody: args[\"extract-request-body\"],\n extractRequestParams: args[\"extract-request-params\"],\n extractResponseBody: args[\"extract-response-body\"],\n extractResponseError: args[\"extract-response-error\"],\n extractResponses: args[\"extract-responses\"],\n fileName: args.name,\n generateClient: !args[\"no-client\"],\n generateResponses: args.responses,\n generateRouteTypes: args[\"route-types\"],\n generateUnionEnums: args[\"union-enums\"],\n httpClientType:\n args[\"http-client\"] || args.axios\n ? HTTP_CLIENT.AXIOS\n : HTTP_CLIENT.FETCH,\n input: path.resolve(process.cwd(), args.path as string),\n modular: args.modular,\n moduleNameFirstTag: args[\"module-name-first-tag\"],\n moduleNameIndex: +args[\"module-name-index\"] || 0,\n output: path.resolve(process.cwd(), (args.output as string) || \".\"),\n patch: args.patch,\n silent: args.silent,\n singleHttpClient: args[\"single-http-client\"],\n sortRoutes: args[\"sort-routes\"],\n sortTypes: args[\"sort-types\"],\n templates: args.templates,\n toJS: args.js,\n typePrefix: args[\"type-prefix\"],\n typeSuffix: args[\"type-suffix\"],\n unwrapResponseData: args[\"unwrap-response-data\"],\n url: args.path,\n ...customConfig,\n });\n },\n});\n\nconst main = defineCommand({\n meta: {\n name: packageJson.name,\n description: packageJson.description,\n version: packageJson.version,\n },\n subCommands: {\n generate: generateCommand,\n \"generate-templates\": generateTemplatesCommand,\n },\n});\n\nrunMain(main);\n"]}
|
package/dist/cli.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {e,f as f$1,b as b$1,d,a,g}from'./chunk-
|
|
2
|
+
import {e,f as f$1,b as b$1,d,a,g}from'./chunk-U2TAGTOU.js';import*as i from'node:path';import*as f from'node:url';import {defineCommand,runMain}from'citty';import {consola}from'consola';var o=new e({}),b=defineCommand({meta:{name:"generate-templates",description:'Generate ".ejs" templates needed for generate api'},args:{"clean-output":{type:"boolean",description:"clean output folder before generate template. WARNING: May cause data loss",default:o.cleanOutput},"http-client":{type:"string",description:`http client type (possible values: ${Object.values(b$1)})`,default:o.httpClientType},modular:{type:"boolean",description:"generate templates needed to separate files for http client, data contracts, and routes",default:o.modular},output:{type:"string",alias:"o",description:"output path of generated templates",default:o.output},rewrite:{type:"boolean",alias:"r",description:"rewrite content in existing templates",default:o.rewrite},silent:{type:"boolean",description:"Output only errors to console",default:o.silent},debug:{type:"boolean",description:"additional information about processes inside this tool",default:o.debug}},run:async({args:e})=>{await f$1({cleanOutput:e["clean-output"],httpClientType:e["http-client"],modular:e.modular,output:e.output,rewrite:e.rewrite,silent:e.silent,debug:e.debug});}}),t=new d({}),h=defineCommand({meta:{name:"generate",description:a.description},args:{path:{type:"string",alias:"p",description:"path/url to swagger scheme",required:true},output:{type:"string",alias:"o",description:"output path of typescript api file",default:"./"},name:{type:"string",alias:"n",description:"name of output typescript api file",default:t.fileName},templates:{type:"string",alias:"t",description:"path to folder containing templates"},"default-as-success":{type:"boolean",alias:"d",description:'use "default" response status code as success response too. some swagger schemas use "default" response status code as success response type by default.',default:t.defaultResponseAsSuccess},responses:{type:"boolean",alias:"r",description:"generate additional information about request responses also add typings for bad responses",default:t.generateResponses},"union-enums":{type:"boolean",description:'generate all "enum" types as union types (T1 | T2 | TN)',default:t.generateUnionEnums},"add-readonly":{type:"boolean",description:"generate readonly properties",default:t.addReadonly},"route-types":{type:"boolean",description:"generate type definitions for API routes",default:t.generateRouteTypes},"no-client":{type:"boolean",description:"do not generate an API class",default:!t.generateClient},"enum-names-as-values":{type:"boolean",description:"use values in 'x-enumNames' as enum values (not only as keys)",default:t.enumNamesAsValues},"extract-request-params":{type:"boolean",description:"extract request params to data contract (Also combine path params and query params into one object)",default:t.extractRequestParams},"extract-request-body":{type:"boolean",description:"extract request body type to data contract",default:t.extractRequestBody},"extract-response-body":{type:"boolean",description:"extract response body type to data contract",default:t.extractResponseBody},"extract-response-error":{type:"boolean",description:"extract response error type to data contract",default:t.extractResponseError},"extract-responses":{type:"boolean",description:"extract all responses described in /components/responses",default:t.extractResponses},modular:{type:"boolean",description:"generate separated files for http client, data contracts, and routes",default:t.modular},js:{type:"boolean",description:"generate js api module with declaration file",default:t.toJS},"module-name-index":{type:"string",description:"determines which path index should be used for routes separation (example: GET:/fruits/getFruit -> index:0 -> moduleName -> fruits)",default:t.moduleNameIndex.toString()},"module-name-first-tag":{type:"boolean",description:"splits routes based on the first tag",default:t.moduleNameFirstTag},axios:{type:"boolean",description:"generate axios http client",default:false},"unwrap-response-data":{type:"boolean",description:"unwrap the data item from the response",default:t.unwrapResponseData},"disable-throw-on-error":{type:"boolean",description:"Do not throw an error when response.ok is not true",default:t.disableThrowOnError},"single-http-client":{type:"boolean",description:"Ability to send HttpClient instance to Api constructor",default:t.singleHttpClient},silent:{type:"boolean",description:"Output only errors to console",default:t.silent},"default-response":{type:"string",description:"default type for empty response schema",default:t.defaultResponseType},"type-prefix":{type:"string",description:"data contract name prefix",default:t.typePrefix},"type-suffix":{type:"string",description:"data contract name suffix",default:t.typeSuffix},"clean-output":{type:"boolean",description:"clean output folder before generate api. WARNING: May cause data loss",default:t.cleanOutput},"api-class-name":{type:"string",description:"name of the api class",default:t.apiClassName},patch:{type:"boolean",description:"fix up small errors in the swagger source definition",default:t.patch},debug:{type:"boolean",description:"additional information about processes inside this tool",default:t.debug},"another-array-type":{type:"boolean",description:"generate array types as Array<Type> (by default Type[])",default:t.anotherArrayType},"sort-types":{type:"boolean",description:"sort fields and types",default:t.sortTypes},"extract-enums":{type:"boolean",description:"extract all enums from inline interface/type content to typescript enum construction",default:t.extractEnums},"sort-routes":{type:"boolean",description:"sort routes in alphabetical order",default:t.sortRoutes},"custom-config":{type:"string",description:"custom config: primitiveTypeConstructs, hooks, ... "}},run:async({args:e})=>{let a;if(e["custom-config"])try{let s=f.pathToFileURL(i.resolve(process.cwd(),e["custom-config"])).toString();a=await import(s),a=a.default||a,a&&consola.info(`Found custom config at: ${s}`);}catch(s){consola.error("Error loading custom config:",s);}await g({addReadonly:e["add-readonly"],anotherArrayType:e["another-array-type"],apiClassName:e["api-class-name"],cleanOutput:e["clean-output"],debug:e.debug,defaultResponseAsSuccess:e["default-as-success"],defaultResponseType:e["default-response"],disableThrowOnError:e["disable-throw-on-error"],enumNamesAsValues:e["enum-names-as-values"],extractEnums:e["extract-enums"],extractRequestBody:e["extract-request-body"],extractRequestParams:e["extract-request-params"],extractResponseBody:e["extract-response-body"],extractResponseError:e["extract-response-error"],extractResponses:e["extract-responses"],fileName:e.name,generateClient:!e["no-client"],generateResponses:e.responses,generateRouteTypes:e["route-types"],generateUnionEnums:e["union-enums"],httpClientType:e["http-client"]||e.axios?b$1.AXIOS:b$1.FETCH,input:i.resolve(process.cwd(),e.path),modular:e.modular,moduleNameFirstTag:e["module-name-first-tag"],moduleNameIndex:+e["module-name-index"]||0,output:i.resolve(process.cwd(),e.output||"."),patch:e.patch,silent:e.silent,singleHttpClient:e["single-http-client"],sortRoutes:e["sort-routes"],sortTypes:e["sort-types"],templates:e.templates,toJS:e.js,typePrefix:e["type-prefix"],typeSuffix:e["type-suffix"],unwrapResponseData:e["unwrap-response-data"],url:e.path,...a});}}),x=defineCommand({meta:{name:a.name,description:a.description,version:a.version},subCommands:{generate:h,"generate-templates":b}});runMain(x);//# sourceMappingURL=cli.js.map
|
|
3
3
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../index.ts"],"names":["templateGenBaseConfig","TemplatesGenConfig","generateTemplatesCommand","defineCommand","HTTP_CLIENT","args","generateTemplates","codeGenBaseConfig","CodeGenConfig","generateCommand","package_default","customConfig","customConfigPath","consola","error","generateApi","main","runMain"],"mappings":";2LAaA,IAAMA,EAAwB,IAAIC,CAAAA,CAAmB,EAAE,CAAA,CAEjDC,EAA2BC,aAAc,CAAA,CAC7C,KAAM,CACJ,IAAA,CAAM,qBACN,WAAa,CAAA,mDACf,EACA,IAAM,CAAA,CACJ,eAAgB,CACd,IAAA,CAAM,UACN,WACE,CAAA,4EAAA,CACF,QAASH,CAAsB,CAAA,WACjC,CACA,CAAA,aAAA,CAAe,CACb,IAAA,CAAM,SACN,WAAa,CAAA,CAAA,mCAAA,EAAsC,OAAO,MACxDI,CAAAA,GACF,CAAC,CACD,CAAA,CAAA,CAAA,OAAA,CAASJ,EAAsB,cACjC,C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A,CAAA,OAAA,CAAQ,KAAOC,CAAAA,CAAAA,CAAK,IAAc,CACtD,CAAA,OAAA,CAASA,EAAK,OACd,CAAA,kBAAA,CAAoBA,EAAK,uBAAuB,CAAA,CAChD,gBAAiB,CAACA,CAAAA,CAAK,mBAAmB,CAAK,EAAA,CAAA,CAC/C,OAAa,CAAQ,CAAA,OAAA,CAAA,OAAA,CAAQ,GAAI,EAAA,CAAIA,CAAK,CAAA,MAAA,EAAqB,GAAG,CAClE,CAAA,KAAA,CAAOA,EAAK,KACZ,CAAA,MAAA,CAAQA,EAAK,MACb,CAAA,gBAAA,CAAkBA,EAAK,oBAAoB,CAAA,CAC3C,WAAYA,CAAK,CAAA,aAAa,EAC9B,SAAWA,CAAAA,CAAAA,CAAK,YAAY,CAC5B,CAAA,SAAA,CAAWA,CAAK,CAAA,SAAA,CAChB,IAAMA,CAAAA,CAAAA,CAAK,GACX,UAAYA,CAAAA,CAAAA,CAAK,aAAa,CAC9B,CAAA,UAAA,CAAYA,EAAK,aAAa,CAAA,CAC9B,mBAAoBA,CAAK,CAAA,sBAAsB,EAC/C,GAAKA,CAAAA,CAAAA,CAAK,KACV,GAAGM,CACL,CAAC,EACH,CACF,CAAC,CAAA,CAEKK,CAAOb,CAAAA,aAAAA,CAAc,CACzB,IAAM,CAAA,CACJ,KAAMO,CAAY,CAAA,IAAA,CAClB,YAAaA,CAAY,CAAA,WAAA,CACzB,QAASA,CAAY,CAAA,OACvB,EACA,WAAa,CAAA,CACX,SAAUD,CACV,CAAA,oBAAA,CAAsBP,CACxB,CACF,CAAC,CAEDe,CAAAA,OAAAA,CAAQD,CAAI,CAAA","file":"cli.js","sourcesContent":["#!/usr/bin/env node\n\nimport * as path from \"node:path\";\nimport * as url from \"node:url\";\nimport { defineCommand, runMain } from \"citty\";\nimport { consola } from \"consola\";\nimport packageJson from \"./package.json\" with { type: \"json\" };\nimport { TemplatesGenConfig } from \"./src/commands/generate-templates/configuration.js\";\nimport { CodeGenConfig } from \"./src/configuration.js\";\nimport { HTTP_CLIENT } from \"./src/constants.js\";\nimport { generateApi, generateTemplates } from \"./src/index.js\";\nimport type { HttpClientType } from \"./types/index.js\";\n\nconst templateGenBaseConfig = new TemplatesGenConfig({});\n\nconst generateTemplatesCommand = defineCommand({\n meta: {\n name: \"generate-templates\",\n description: 'Generate \".ejs\" templates needed for generate api',\n },\n args: {\n \"clean-output\": {\n type: \"boolean\",\n description:\n \"clean output folder before generate template. WARNING: May cause data loss\",\n default: templateGenBaseConfig.cleanOutput,\n },\n \"http-client\": {\n type: \"string\",\n description: `http client type (possible values: ${Object.values(\n HTTP_CLIENT,\n )})`,\n default: templateGenBaseConfig.httpClientType,\n },\n modular: {\n type: \"boolean\",\n description:\n \"generate templates needed to separate files for http client, data contracts, and routes\",\n default: templateGenBaseConfig.modular,\n },\n output: {\n type: \"string\",\n alias: \"o\",\n description: \"output path of generated templates\",\n default: templateGenBaseConfig.output,\n },\n rewrite: {\n type: \"boolean\",\n alias: \"r\",\n description: \"rewrite content in existing templates\",\n default: templateGenBaseConfig.rewrite,\n },\n silent: {\n type: \"boolean\",\n description: \"Output only errors to console\",\n default: templateGenBaseConfig.silent,\n },\n debug: {\n type: \"boolean\",\n description: \"additional information about processes inside this tool\",\n default: templateGenBaseConfig.debug,\n },\n },\n run: async ({ args }) => {\n await generateTemplates({\n cleanOutput: args[\"clean-output\"],\n httpClientType: args[\"http-client\"] as HttpClientType,\n modular: args.modular,\n output: args.output,\n rewrite: args.rewrite,\n silent: args.silent,\n debug: args.debug,\n });\n },\n});\n\nconst codeGenBaseConfig = new CodeGenConfig({});\n\nconst generateCommand = defineCommand({\n meta: {\n name: \"generate\",\n description: packageJson.description,\n },\n args: {\n path: {\n type: \"string\",\n alias: \"p\",\n description: \"path/url to swagger scheme\",\n required: true,\n },\n output: {\n type: \"string\",\n alias: \"o\",\n description: \"output path of typescript api file\",\n default: \"./\",\n },\n name: {\n type: \"string\",\n alias: \"n\",\n description: \"name of output typescript api file\",\n default: codeGenBaseConfig.fileName,\n },\n templates: {\n type: \"string\",\n alias: \"t\",\n description: \"path to folder containing templates\",\n },\n \"default-as-success\": {\n type: \"boolean\",\n alias: \"d\",\n description:\n 'use \"default\" response status code as success response too. some swagger schemas use \"default\" response status code as success response type by default.',\n default: codeGenBaseConfig.defaultResponseAsSuccess,\n },\n responses: {\n type: \"boolean\",\n alias: \"r\",\n description:\n \"generate additional information about request responses also add typings for bad responses\",\n default: codeGenBaseConfig.generateResponses,\n },\n \"union-enums\": {\n type: \"boolean\",\n description: 'generate all \"enum\" types as union types (T1 | T2 | TN)',\n default: codeGenBaseConfig.generateUnionEnums,\n },\n \"add-readonly\": {\n type: \"boolean\",\n description: \"generate readonly properties\",\n default: codeGenBaseConfig.addReadonly,\n },\n \"route-types\": {\n type: \"boolean\",\n description: \"generate type definitions for API routes\",\n default: codeGenBaseConfig.generateRouteTypes,\n },\n \"no-client\": {\n type: \"boolean\",\n description: \"do not generate an API class\",\n default: codeGenBaseConfig.generateClient,\n },\n \"enum-names-as-values\": {\n type: \"boolean\",\n description:\n \"use values in 'x-enumNames' as enum values (not only as keys)\",\n default: codeGenBaseConfig.enumNamesAsValues,\n },\n \"extract-request-params\": {\n description:\n \"extract request params to data contract (Also combine path params and query params into one object)\",\n default: codeGenBaseConfig.extractRequestParams,\n },\n \"extract-request-body\": {\n type: \"boolean\",\n description: \"extract request body type to data contract\",\n default: codeGenBaseConfig.extractRequestBody,\n },\n \"extract-response-body\": {\n type: \"boolean\",\n description: \"extract response body type to data contract\",\n default: codeGenBaseConfig.extractResponseBody,\n },\n \"extract-response-error\": {\n type: \"boolean\",\n description: \"extract response error type to data contract\",\n default: codeGenBaseConfig.extractResponseError,\n },\n \"extract-responses\": {\n type: \"boolean\",\n description: \"extract all responses described in /components/responses\",\n default: codeGenBaseConfig.extractResponses,\n },\n modular: {\n type: \"boolean\",\n description:\n \"generate separated files for http client, data contracts, and routes\",\n default: codeGenBaseConfig.modular,\n },\n js: {\n type: \"boolean\",\n description: \"generate js api module with declaration file\",\n default: codeGenBaseConfig.toJS,\n },\n \"module-name-index\": {\n type: \"string\",\n description:\n \"determines which path index should be used for routes separation (example: GET:/fruits/getFruit -> index:0 -> moduleName -> fruits)\",\n default: codeGenBaseConfig.moduleNameIndex.toString(),\n },\n \"module-name-first-tag\": {\n type: \"boolean\",\n description: \"splits routes based on the first tag\",\n default: codeGenBaseConfig.moduleNameFirstTag,\n },\n axios: {\n type: \"boolean\",\n description: \"generate axios http client\",\n default: false,\n },\n \"unwrap-response-data\": {\n type: \"boolean\",\n description: \"unwrap the data item from the response\",\n default: codeGenBaseConfig.unwrapResponseData,\n },\n \"disable-throw-on-error\": {\n type: \"boolean\",\n description: \"Do not throw an error when response.ok is not true\",\n default: codeGenBaseConfig.disableThrowOnError,\n },\n \"single-http-client\": {\n type: \"boolean\",\n description: \"Ability to send HttpClient instance to Api constructor\",\n default: codeGenBaseConfig.singleHttpClient,\n },\n silent: {\n type: \"boolean\",\n description: \"Output only errors to console\",\n default: codeGenBaseConfig.silent,\n },\n \"default-response\": {\n type: \"string\",\n description: \"default type for empty response schema\",\n default: codeGenBaseConfig.defaultResponseType,\n },\n \"type-prefix\": {\n type: \"string\",\n description: \"data contract name prefix\",\n default: codeGenBaseConfig.typePrefix,\n },\n \"type-suffix\": {\n type: \"string\",\n description: \"data contract name suffix\",\n default: codeGenBaseConfig.typeSuffix,\n },\n \"clean-output\": {\n type: \"boolean\",\n description:\n \"clean output folder before generate api. WARNING: May cause data loss\",\n default: codeGenBaseConfig.cleanOutput,\n },\n \"api-class-name\": {\n type: \"string\",\n description: \"name of the api class\",\n default: codeGenBaseConfig.apiClassName,\n },\n patch: {\n type: \"boolean\",\n description: \"fix up small errors in the swagger source definition\",\n default: codeGenBaseConfig.patch,\n },\n debug: {\n type: \"boolean\",\n description: \"additional information about processes inside this tool\",\n default: codeGenBaseConfig.debug,\n },\n \"another-array-type\": {\n type: \"boolean\",\n description: \"generate array types as Array<Type> (by default Type[])\",\n default: codeGenBaseConfig.anotherArrayType,\n },\n \"sort-types\": {\n type: \"boolean\",\n description: \"sort fields and types\",\n default: codeGenBaseConfig.sortTypes,\n },\n \"extract-enums\": {\n type: \"boolean\",\n description:\n \"extract all enums from inline interface/type content to typescript enum construction\",\n default: codeGenBaseConfig.extractEnums,\n },\n \"sort-routes\": {\n type: \"boolean\",\n description: \"sort routes in alphabetical order\",\n default: codeGenBaseConfig.sortRoutes,\n },\n \"custom-config\": {\n type: \"string\",\n description: \"custom config: primitiveTypeConstructs, hooks, ... \",\n },\n },\n run: async ({ args }) => {\n let customConfig;\n\n if (args[\"custom-config\"]) {\n try {\n const customConfigPath = url\n .pathToFileURL(path.resolve(process.cwd(), args[\"custom-config\"]))\n .toString();\n customConfig = await import(customConfigPath);\n customConfig = customConfig.default || customConfig;\n if (customConfig) {\n consola.info(`Found custom config at: ${customConfigPath}`);\n }\n } catch (error) {\n consola.error(\"Error loading custom config:\", error);\n }\n }\n\n await generateApi({\n addReadonly: args[\"add-readonly\"],\n anotherArrayType: args[\"another-array-type\"],\n apiClassName: args[\"api-class-name\"],\n cleanOutput: args[\"clean-output\"],\n debug: args.debug,\n defaultResponseAsSuccess: args[\"default-as-success\"],\n defaultResponseType: args[\"default-response\"],\n disableThrowOnError: args[\"disable-throw-on-error\"],\n enumNamesAsValues: args[\"enum-names-as-values\"],\n extractEnums: args[\"extract-enums\"],\n extractRequestBody: args[\"extract-request-body\"],\n extractRequestParams: args[\"extract-request-params\"],\n extractResponseBody: args[\"extract-response-body\"],\n extractResponseError: args[\"extract-response-error\"],\n extractResponses: args[\"extract-responses\"],\n fileName: args.name,\n generateClient: !(args.axios || args[\"no-client\"]),\n generateResponses: args.responses,\n generateRouteTypes: args[\"route-types\"],\n generateUnionEnums: args[\"union-enums\"],\n httpClientType:\n args[\"http-client\"] || args.axios\n ? HTTP_CLIENT.AXIOS\n : HTTP_CLIENT.FETCH,\n input: path.resolve(process.cwd(), args.path as string),\n modular: args.modular,\n moduleNameFirstTag: args[\"module-name-first-tag\"],\n moduleNameIndex: +args[\"module-name-index\"] || 0,\n output: path.resolve(process.cwd(), (args.output as string) || \".\"),\n patch: args.patch,\n silent: args.silent,\n singleHttpClient: args[\"single-http-client\"],\n sortRoutes: args[\"sort-routes\"],\n sortTypes: args[\"sort-types\"],\n templates: args.templates,\n toJS: args.js,\n typePrefix: args[\"type-prefix\"],\n typeSuffix: args[\"type-suffix\"],\n unwrapResponseData: args[\"unwrap-response-data\"],\n url: args.path,\n ...customConfig,\n });\n },\n});\n\nconst main = defineCommand({\n meta: {\n name: packageJson.name,\n description: packageJson.description,\n version: packageJson.version,\n },\n subCommands: {\n generate: generateCommand,\n \"generate-templates\": generateTemplatesCommand,\n },\n});\n\nrunMain(main);\n"]}
|
|
1
|
+
{"version":3,"sources":["../index.ts"],"names":["templateGenBaseConfig","TemplatesGenConfig","generateTemplatesCommand","defineCommand","HTTP_CLIENT","args","generateTemplates","codeGenBaseConfig","CodeGenConfig","generateCommand","package_default","customConfig","customConfigPath","consola","error","generateApi","main","runMain"],"mappings":";2LAaA,IAAMA,EAAwB,IAAIC,CAAAA,CAAmB,EAAE,CAAA,CAEjDC,EAA2BC,aAAc,CAAA,CAC7C,KAAM,CACJ,IAAA,CAAM,qBACN,WAAa,CAAA,mDACf,EACA,IAAM,CAAA,CACJ,eAAgB,CACd,IAAA,CAAM,UACN,WACE,CAAA,4EAAA,CACF,QAASH,CAAsB,CAAA,WACjC,CACA,CAAA,aAAA,CAAe,CACb,IAAA,CAAM,SACN,WAAa,CAAA,CAAA,mCAAA,EAAsC,OAAO,MACxDI,CAAAA,GACF,CAAC,CACD,CAAA,CAAA,CAAA,OAAA,CAASJ,EAAsB,cACjC,CAAA,CACA,QAAS,CACP,IAAA,CAAM,UACN,WACE,CAAA,yFAAA,CACF,QAASA,CAAsB,CAAA,OACjC,CACA,CAAA,MAAA,CAAQ,CACN,IAAA,CAAM,SACN,KAAO,CAAA,GAAA,CACP,YAAa,oCACb,CAAA,OAAA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AAA,CAC/C,OAAa,CAAQ,CAAA,OAAA,CAAA,OAAA,CAAQ,GAAI,EAAA,CAAIA,CAAK,CAAA,MAAA,EAAqB,GAAG,CAClE,CAAA,KAAA,CAAOA,EAAK,KACZ,CAAA,MAAA,CAAQA,EAAK,MACb,CAAA,gBAAA,CAAkBA,EAAK,oBAAoB,CAAA,CAC3C,WAAYA,CAAK,CAAA,aAAa,EAC9B,SAAWA,CAAAA,CAAAA,CAAK,YAAY,CAC5B,CAAA,SAAA,CAAWA,CAAK,CAAA,SAAA,CAChB,IAAMA,CAAAA,CAAAA,CAAK,GACX,UAAYA,CAAAA,CAAAA,CAAK,aAAa,CAC9B,CAAA,UAAA,CAAYA,EAAK,aAAa,CAAA,CAC9B,mBAAoBA,CAAK,CAAA,sBAAsB,EAC/C,GAAKA,CAAAA,CAAAA,CAAK,KACV,GAAGM,CACL,CAAC,EACH,CACF,CAAC,CAAA,CAEKK,CAAOb,CAAAA,aAAAA,CAAc,CACzB,IAAM,CAAA,CACJ,KAAMO,CAAY,CAAA,IAAA,CAClB,YAAaA,CAAY,CAAA,WAAA,CACzB,QAASA,CAAY,CAAA,OACvB,EACA,WAAa,CAAA,CACX,SAAUD,CACV,CAAA,oBAAA,CAAsBP,CACxB,CACF,CAAC,CAEDe,CAAAA,OAAAA,CAAQD,CAAI,CAAA","file":"cli.js","sourcesContent":["#!/usr/bin/env node\n\nimport * as path from \"node:path\";\nimport * as url from \"node:url\";\nimport { defineCommand, runMain } from \"citty\";\nimport { consola } from \"consola\";\nimport packageJson from \"./package.json\" with { type: \"json\" };\nimport { TemplatesGenConfig } from \"./src/commands/generate-templates/configuration.js\";\nimport { CodeGenConfig } from \"./src/configuration.js\";\nimport { HTTP_CLIENT } from \"./src/constants.js\";\nimport { generateApi, generateTemplates } from \"./src/index.js\";\nimport type { HttpClientType } from \"./types/index.js\";\n\nconst templateGenBaseConfig = new TemplatesGenConfig({});\n\nconst generateTemplatesCommand = defineCommand({\n meta: {\n name: \"generate-templates\",\n description: 'Generate \".ejs\" templates needed for generate api',\n },\n args: {\n \"clean-output\": {\n type: \"boolean\",\n description:\n \"clean output folder before generate template. WARNING: May cause data loss\",\n default: templateGenBaseConfig.cleanOutput,\n },\n \"http-client\": {\n type: \"string\",\n description: `http client type (possible values: ${Object.values(\n HTTP_CLIENT,\n )})`,\n default: templateGenBaseConfig.httpClientType,\n },\n modular: {\n type: \"boolean\",\n description:\n \"generate templates needed to separate files for http client, data contracts, and routes\",\n default: templateGenBaseConfig.modular,\n },\n output: {\n type: \"string\",\n alias: \"o\",\n description: \"output path of generated templates\",\n default: templateGenBaseConfig.output,\n },\n rewrite: {\n type: \"boolean\",\n alias: \"r\",\n description: \"rewrite content in existing templates\",\n default: templateGenBaseConfig.rewrite,\n },\n silent: {\n type: \"boolean\",\n description: \"Output only errors to console\",\n default: templateGenBaseConfig.silent,\n },\n debug: {\n type: \"boolean\",\n description: \"additional information about processes inside this tool\",\n default: templateGenBaseConfig.debug,\n },\n },\n run: async ({ args }) => {\n await generateTemplates({\n cleanOutput: args[\"clean-output\"],\n httpClientType: args[\"http-client\"] as HttpClientType,\n modular: args.modular,\n output: args.output,\n rewrite: args.rewrite,\n silent: args.silent,\n debug: args.debug,\n });\n },\n});\n\nconst codeGenBaseConfig = new CodeGenConfig({});\n\nconst generateCommand = defineCommand({\n meta: {\n name: \"generate\",\n description: packageJson.description,\n },\n args: {\n path: {\n type: \"string\",\n alias: \"p\",\n description: \"path/url to swagger scheme\",\n required: true,\n },\n output: {\n type: \"string\",\n alias: \"o\",\n description: \"output path of typescript api file\",\n default: \"./\",\n },\n name: {\n type: \"string\",\n alias: \"n\",\n description: \"name of output typescript api file\",\n default: codeGenBaseConfig.fileName,\n },\n templates: {\n type: \"string\",\n alias: \"t\",\n description: \"path to folder containing templates\",\n },\n \"default-as-success\": {\n type: \"boolean\",\n alias: \"d\",\n description:\n 'use \"default\" response status code as success response too. some swagger schemas use \"default\" response status code as success response type by default.',\n default: codeGenBaseConfig.defaultResponseAsSuccess,\n },\n responses: {\n type: \"boolean\",\n alias: \"r\",\n description:\n \"generate additional information about request responses also add typings for bad responses\",\n default: codeGenBaseConfig.generateResponses,\n },\n \"union-enums\": {\n type: \"boolean\",\n description: 'generate all \"enum\" types as union types (T1 | T2 | TN)',\n default: codeGenBaseConfig.generateUnionEnums,\n },\n \"add-readonly\": {\n type: \"boolean\",\n description: \"generate readonly properties\",\n default: codeGenBaseConfig.addReadonly,\n },\n \"route-types\": {\n type: \"boolean\",\n description: \"generate type definitions for API routes\",\n default: codeGenBaseConfig.generateRouteTypes,\n },\n \"no-client\": {\n type: \"boolean\",\n description: \"do not generate an API class\",\n default: !codeGenBaseConfig.generateClient,\n },\n \"enum-names-as-values\": {\n type: \"boolean\",\n description:\n \"use values in 'x-enumNames' as enum values (not only as keys)\",\n default: codeGenBaseConfig.enumNamesAsValues,\n },\n \"extract-request-params\": {\n type: \"boolean\",\n description:\n \"extract request params to data contract (Also combine path params and query params into one object)\",\n default: codeGenBaseConfig.extractRequestParams,\n },\n \"extract-request-body\": {\n type: \"boolean\",\n description: \"extract request body type to data contract\",\n default: codeGenBaseConfig.extractRequestBody,\n },\n \"extract-response-body\": {\n type: \"boolean\",\n description: \"extract response body type to data contract\",\n default: codeGenBaseConfig.extractResponseBody,\n },\n \"extract-response-error\": {\n type: \"boolean\",\n description: \"extract response error type to data contract\",\n default: codeGenBaseConfig.extractResponseError,\n },\n \"extract-responses\": {\n type: \"boolean\",\n description: \"extract all responses described in /components/responses\",\n default: codeGenBaseConfig.extractResponses,\n },\n modular: {\n type: \"boolean\",\n description:\n \"generate separated files for http client, data contracts, and routes\",\n default: codeGenBaseConfig.modular,\n },\n js: {\n type: \"boolean\",\n description: \"generate js api module with declaration file\",\n default: codeGenBaseConfig.toJS,\n },\n \"module-name-index\": {\n type: \"string\",\n description:\n \"determines which path index should be used for routes separation (example: GET:/fruits/getFruit -> index:0 -> moduleName -> fruits)\",\n default: codeGenBaseConfig.moduleNameIndex.toString(),\n },\n \"module-name-first-tag\": {\n type: \"boolean\",\n description: \"splits routes based on the first tag\",\n default: codeGenBaseConfig.moduleNameFirstTag,\n },\n axios: {\n type: \"boolean\",\n description: \"generate axios http client\",\n default: false,\n },\n \"unwrap-response-data\": {\n type: \"boolean\",\n description: \"unwrap the data item from the response\",\n default: codeGenBaseConfig.unwrapResponseData,\n },\n \"disable-throw-on-error\": {\n type: \"boolean\",\n description: \"Do not throw an error when response.ok is not true\",\n default: codeGenBaseConfig.disableThrowOnError,\n },\n \"single-http-client\": {\n type: \"boolean\",\n description: \"Ability to send HttpClient instance to Api constructor\",\n default: codeGenBaseConfig.singleHttpClient,\n },\n silent: {\n type: \"boolean\",\n description: \"Output only errors to console\",\n default: codeGenBaseConfig.silent,\n },\n \"default-response\": {\n type: \"string\",\n description: \"default type for empty response schema\",\n default: codeGenBaseConfig.defaultResponseType,\n },\n \"type-prefix\": {\n type: \"string\",\n description: \"data contract name prefix\",\n default: codeGenBaseConfig.typePrefix,\n },\n \"type-suffix\": {\n type: \"string\",\n description: \"data contract name suffix\",\n default: codeGenBaseConfig.typeSuffix,\n },\n \"clean-output\": {\n type: \"boolean\",\n description:\n \"clean output folder before generate api. WARNING: May cause data loss\",\n default: codeGenBaseConfig.cleanOutput,\n },\n \"api-class-name\": {\n type: \"string\",\n description: \"name of the api class\",\n default: codeGenBaseConfig.apiClassName,\n },\n patch: {\n type: \"boolean\",\n description: \"fix up small errors in the swagger source definition\",\n default: codeGenBaseConfig.patch,\n },\n debug: {\n type: \"boolean\",\n description: \"additional information about processes inside this tool\",\n default: codeGenBaseConfig.debug,\n },\n \"another-array-type\": {\n type: \"boolean\",\n description: \"generate array types as Array<Type> (by default Type[])\",\n default: codeGenBaseConfig.anotherArrayType,\n },\n \"sort-types\": {\n type: \"boolean\",\n description: \"sort fields and types\",\n default: codeGenBaseConfig.sortTypes,\n },\n \"extract-enums\": {\n type: \"boolean\",\n description:\n \"extract all enums from inline interface/type content to typescript enum construction\",\n default: codeGenBaseConfig.extractEnums,\n },\n \"sort-routes\": {\n type: \"boolean\",\n description: \"sort routes in alphabetical order\",\n default: codeGenBaseConfig.sortRoutes,\n },\n \"custom-config\": {\n type: \"string\",\n description: \"custom config: primitiveTypeConstructs, hooks, ... \",\n },\n },\n run: async ({ args }) => {\n let customConfig = undefined;\n\n if (args[\"custom-config\"]) {\n try {\n const customConfigPath = url\n .pathToFileURL(path.resolve(process.cwd(), args[\"custom-config\"]))\n .toString();\n customConfig = await import(customConfigPath);\n customConfig = customConfig.default || customConfig;\n if (customConfig) {\n consola.info(`Found custom config at: ${customConfigPath}`);\n }\n } catch (error) {\n consola.error(\"Error loading custom config:\", error);\n }\n }\n\n await generateApi({\n addReadonly: args[\"add-readonly\"],\n anotherArrayType: args[\"another-array-type\"],\n apiClassName: args[\"api-class-name\"],\n cleanOutput: args[\"clean-output\"],\n debug: args.debug,\n defaultResponseAsSuccess: args[\"default-as-success\"],\n defaultResponseType: args[\"default-response\"],\n disableThrowOnError: args[\"disable-throw-on-error\"],\n enumNamesAsValues: args[\"enum-names-as-values\"],\n extractEnums: args[\"extract-enums\"],\n extractRequestBody: args[\"extract-request-body\"],\n extractRequestParams: args[\"extract-request-params\"],\n extractResponseBody: args[\"extract-response-body\"],\n extractResponseError: args[\"extract-response-error\"],\n extractResponses: args[\"extract-responses\"],\n fileName: args.name,\n generateClient: !args[\"no-client\"],\n generateResponses: args.responses,\n generateRouteTypes: args[\"route-types\"],\n generateUnionEnums: args[\"union-enums\"],\n httpClientType:\n args[\"http-client\"] || args.axios\n ? HTTP_CLIENT.AXIOS\n : HTTP_CLIENT.FETCH,\n input: path.resolve(process.cwd(), args.path as string),\n modular: args.modular,\n moduleNameFirstTag: args[\"module-name-first-tag\"],\n moduleNameIndex: +args[\"module-name-index\"] || 0,\n output: path.resolve(process.cwd(), (args.output as string) || \".\"),\n patch: args.patch,\n silent: args.silent,\n singleHttpClient: args[\"single-http-client\"],\n sortRoutes: args[\"sort-routes\"],\n sortTypes: args[\"sort-types\"],\n templates: args.templates,\n toJS: args.js,\n typePrefix: args[\"type-prefix\"],\n typeSuffix: args[\"type-suffix\"],\n unwrapResponseData: args[\"unwrap-response-data\"],\n url: args.path,\n ...customConfig,\n });\n },\n});\n\nconst main = defineCommand({\n meta: {\n name: packageJson.name,\n description: packageJson.description,\n version: packageJson.version,\n },\n subCommands: {\n generate: generateCommand,\n \"generate-templates\": generateTemplatesCommand,\n },\n});\n\nrunMain(main);\n"]}
|
package/dist/lib.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkLI5RQUAL_cjs=require('./chunk-LI5RQUAL.cjs');Object.defineProperty(exports,"constants",{enumerable:true,get:function(){return chunkLI5RQUAL_cjs.c}});Object.defineProperty(exports,"generateApi",{enumerable:true,get:function(){return chunkLI5RQUAL_cjs.g}});Object.defineProperty(exports,"generateTemplates",{enumerable:true,get:function(){return chunkLI5RQUAL_cjs.f}});//# sourceMappingURL=lib.cjs.map
|
|
2
2
|
//# sourceMappingURL=lib.cjs.map
|
package/dist/lib.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{c as constants,g as generateApi,f as generateTemplates}from'./chunk-
|
|
1
|
+
export{c as constants,g as generateApi,f as generateTemplates}from'./chunk-U2TAGTOU.js';//# sourceMappingURL=lib.js.map
|
|
2
2
|
//# sourceMappingURL=lib.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swagger-typescript-api",
|
|
3
|
-
"version": "13.0.
|
|
3
|
+
"version": "13.0.26",
|
|
4
4
|
"description": "Generate the API client for Fetch or Axios from an OpenAPI Specification",
|
|
5
5
|
"homepage": "https://github.com/acacode/swagger-typescript-api",
|
|
6
6
|
"bugs": "https://github.com/acacode/swagger-typescript-api/issues",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"@tsconfig/strictest": "2.0.5",
|
|
65
65
|
"@types/js-yaml": "4.0.9",
|
|
66
66
|
"@types/lodash": "4.17.16",
|
|
67
|
-
"@types/node": "22.13.
|
|
67
|
+
"@types/node": "22.13.12",
|
|
68
68
|
"@types/swagger2openapi": "7.0.4",
|
|
69
69
|
"axios": "1.8.4",
|
|
70
70
|
"openapi-types": "12.1.3",
|