swagger-typescript-api 13.1.1 → 13.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/CHANGELOG.md +6 -0
- package/dist/chunk-Cl8Af3a2.js +11 -0
- package/dist/cli.cjs +326 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +325 -1
- package/dist/cli.js.map +1 -1
- package/dist/lib.cjs +10 -2
- package/dist/lib.d.cts +1638 -3
- package/dist/lib.d.cts.map +1 -0
- package/dist/lib.d.ts +1637 -3
- package/dist/lib.d.ts.map +1 -0
- package/dist/lib.js +3 -2
- package/dist/src-D3nQpZ1i.cjs +3133 -0
- package/dist/src-D3nQpZ1i.cjs.map +1 -0
- package/dist/src-gaIHrOQ9.js +3066 -0
- package/dist/src-gaIHrOQ9.js.map +1 -0
- package/package.json +10 -11
- package/dist/_tsup-dts-rollup.d.cts +0 -1964
- package/dist/_tsup-dts-rollup.d.ts +0 -1964
- package/dist/chunk-E5FI32CM.cjs +0 -42
- package/dist/chunk-E5FI32CM.cjs.map +0 -1
- package/dist/chunk-EBM4FZTJ.js +0 -42
- package/dist/chunk-EBM4FZTJ.js.map +0 -1
- package/dist/lib.cjs.map +0 -1
- package/dist/lib.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -1,3 +1,327 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { CodeGenConfig, HTTP_CLIENT, TemplatesGenConfig, generateApi, generateTemplates, package_default } from "./src-gaIHrOQ9.js";
|
|
3
|
+
import * as path$1 from "node:path";
|
|
4
|
+
import { loadConfig } from "c12";
|
|
5
|
+
import { defineCommand, runMain } from "citty";
|
|
6
|
+
|
|
7
|
+
//#region index.ts
|
|
8
|
+
const templateGenBaseConfig = new TemplatesGenConfig({});
|
|
9
|
+
const generateTemplatesCommand = defineCommand({
|
|
10
|
+
meta: {
|
|
11
|
+
name: "generate-templates",
|
|
12
|
+
description: "Generate \".ejs\" templates needed for generate api"
|
|
13
|
+
},
|
|
14
|
+
args: {
|
|
15
|
+
"clean-output": {
|
|
16
|
+
type: "boolean",
|
|
17
|
+
description: "clean output folder before generate template. WARNING: May cause data loss",
|
|
18
|
+
default: templateGenBaseConfig.cleanOutput
|
|
19
|
+
},
|
|
20
|
+
debug: {
|
|
21
|
+
type: "boolean",
|
|
22
|
+
description: "additional information about processes inside this tool",
|
|
23
|
+
default: templateGenBaseConfig.debug
|
|
24
|
+
},
|
|
25
|
+
"http-client": {
|
|
26
|
+
type: "string",
|
|
27
|
+
description: `http client type (possible values: ${Object.values(HTTP_CLIENT)})`,
|
|
28
|
+
default: templateGenBaseConfig.httpClientType
|
|
29
|
+
},
|
|
30
|
+
modular: {
|
|
31
|
+
type: "boolean",
|
|
32
|
+
description: "generate templates needed to separate files for http client, data contracts, and routes",
|
|
33
|
+
default: templateGenBaseConfig.modular
|
|
34
|
+
},
|
|
35
|
+
output: {
|
|
36
|
+
type: "string",
|
|
37
|
+
alias: "o",
|
|
38
|
+
description: "output path of generated templates",
|
|
39
|
+
default: templateGenBaseConfig.output,
|
|
40
|
+
required: true
|
|
41
|
+
},
|
|
42
|
+
rewrite: {
|
|
43
|
+
type: "boolean",
|
|
44
|
+
alias: "r",
|
|
45
|
+
description: "rewrite content in existing templates",
|
|
46
|
+
default: templateGenBaseConfig.rewrite
|
|
47
|
+
},
|
|
48
|
+
silent: {
|
|
49
|
+
type: "boolean",
|
|
50
|
+
description: "Output only errors to console",
|
|
51
|
+
default: templateGenBaseConfig.silent
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
run: async ({ args }) => {
|
|
55
|
+
await generateTemplates({
|
|
56
|
+
cleanOutput: args["clean-output"],
|
|
57
|
+
httpClientType: args["http-client"],
|
|
58
|
+
modular: args.modular,
|
|
59
|
+
output: args.output,
|
|
60
|
+
rewrite: args.rewrite,
|
|
61
|
+
silent: args.silent,
|
|
62
|
+
debug: args.debug
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
const codeGenBaseConfig = new CodeGenConfig({});
|
|
67
|
+
const generateCommand = defineCommand({
|
|
68
|
+
meta: {
|
|
69
|
+
name: "generate",
|
|
70
|
+
description: package_default.description
|
|
71
|
+
},
|
|
72
|
+
args: {
|
|
73
|
+
"add-readonly": {
|
|
74
|
+
type: "boolean",
|
|
75
|
+
description: "generate readonly properties",
|
|
76
|
+
default: codeGenBaseConfig.addReadonly
|
|
77
|
+
},
|
|
78
|
+
"another-array-type": {
|
|
79
|
+
type: "boolean",
|
|
80
|
+
description: "generate array types as Array<Type> (by default Type[])",
|
|
81
|
+
default: codeGenBaseConfig.anotherArrayType
|
|
82
|
+
},
|
|
83
|
+
"api-class-name": {
|
|
84
|
+
type: "string",
|
|
85
|
+
description: "name of the api class",
|
|
86
|
+
default: codeGenBaseConfig.apiClassName
|
|
87
|
+
},
|
|
88
|
+
axios: {
|
|
89
|
+
type: "boolean",
|
|
90
|
+
description: "generate axios http client",
|
|
91
|
+
default: false
|
|
92
|
+
},
|
|
93
|
+
"clean-output": {
|
|
94
|
+
type: "boolean",
|
|
95
|
+
description: "clean output folder before generate api. WARNING: May cause data loss",
|
|
96
|
+
default: codeGenBaseConfig.cleanOutput
|
|
97
|
+
},
|
|
98
|
+
client: {
|
|
99
|
+
type: "boolean",
|
|
100
|
+
description: "do not generate an API class",
|
|
101
|
+
default: codeGenBaseConfig.generateClient
|
|
102
|
+
},
|
|
103
|
+
"custom-config": {
|
|
104
|
+
type: "string",
|
|
105
|
+
description: "custom config: primitiveTypeConstructs, hooks, ... "
|
|
106
|
+
},
|
|
107
|
+
debug: {
|
|
108
|
+
type: "boolean",
|
|
109
|
+
description: "additional information about processes inside this tool",
|
|
110
|
+
default: codeGenBaseConfig.debug
|
|
111
|
+
},
|
|
112
|
+
"default-as-success": {
|
|
113
|
+
type: "boolean",
|
|
114
|
+
alias: "d",
|
|
115
|
+
description: "use \"default\" response status code as success response too. some swagger schemas use \"default\" response status code as success response type by default.",
|
|
116
|
+
default: codeGenBaseConfig.defaultResponseAsSuccess
|
|
117
|
+
},
|
|
118
|
+
"default-response": {
|
|
119
|
+
type: "string",
|
|
120
|
+
description: "default type for empty response schema",
|
|
121
|
+
default: codeGenBaseConfig.defaultResponseType
|
|
122
|
+
},
|
|
123
|
+
"disable-throw-on-error": {
|
|
124
|
+
type: "boolean",
|
|
125
|
+
description: "Do not throw an error when response.ok is not true",
|
|
126
|
+
default: codeGenBaseConfig.disableThrowOnError
|
|
127
|
+
},
|
|
128
|
+
"enum-names-as-values": {
|
|
129
|
+
type: "boolean",
|
|
130
|
+
description: "use values in 'x-enumNames' as enum values (not only as keys)",
|
|
131
|
+
default: codeGenBaseConfig.enumNamesAsValues
|
|
132
|
+
},
|
|
133
|
+
"extract-enums": {
|
|
134
|
+
type: "boolean",
|
|
135
|
+
description: "extract all enums from inline interface/type content to typescript enum construction",
|
|
136
|
+
default: codeGenBaseConfig.extractEnums
|
|
137
|
+
},
|
|
138
|
+
"extract-request-body": {
|
|
139
|
+
type: "boolean",
|
|
140
|
+
description: "extract request body type to data contract",
|
|
141
|
+
default: codeGenBaseConfig.extractRequestBody
|
|
142
|
+
},
|
|
143
|
+
"extract-request-params": {
|
|
144
|
+
type: "boolean",
|
|
145
|
+
description: "extract request params to data contract (Also combine path params and query params into one object)",
|
|
146
|
+
default: codeGenBaseConfig.extractRequestParams
|
|
147
|
+
},
|
|
148
|
+
"extract-response-body": {
|
|
149
|
+
type: "boolean",
|
|
150
|
+
description: "extract response body type to data contract",
|
|
151
|
+
default: codeGenBaseConfig.extractResponseBody
|
|
152
|
+
},
|
|
153
|
+
"extract-response-error": {
|
|
154
|
+
type: "boolean",
|
|
155
|
+
description: "extract response error type to data contract",
|
|
156
|
+
default: codeGenBaseConfig.extractResponseError
|
|
157
|
+
},
|
|
158
|
+
"extract-responses": {
|
|
159
|
+
type: "boolean",
|
|
160
|
+
description: "extract all responses described in /components/responses",
|
|
161
|
+
default: codeGenBaseConfig.extractResponses
|
|
162
|
+
},
|
|
163
|
+
"generate-union-enums": {
|
|
164
|
+
type: "boolean",
|
|
165
|
+
description: "generate all \"enum\" types as union types (T1 | T2 | TN)",
|
|
166
|
+
default: codeGenBaseConfig.generateUnionEnums
|
|
167
|
+
},
|
|
168
|
+
"http-client": {
|
|
169
|
+
type: "string",
|
|
170
|
+
description: `http client type (possible values: ${Object.values(HTTP_CLIENT)})`
|
|
171
|
+
},
|
|
172
|
+
js: {
|
|
173
|
+
type: "boolean",
|
|
174
|
+
description: "generate js api module with declaration file",
|
|
175
|
+
default: codeGenBaseConfig.toJS
|
|
176
|
+
},
|
|
177
|
+
modular: {
|
|
178
|
+
type: "boolean",
|
|
179
|
+
description: "generate separated files for http client, data contracts, and routes",
|
|
180
|
+
default: codeGenBaseConfig.modular
|
|
181
|
+
},
|
|
182
|
+
"module-name-first-tag": {
|
|
183
|
+
type: "boolean",
|
|
184
|
+
description: "splits routes based on the first tag",
|
|
185
|
+
default: codeGenBaseConfig.moduleNameFirstTag
|
|
186
|
+
},
|
|
187
|
+
"module-name-index": {
|
|
188
|
+
type: "string",
|
|
189
|
+
description: "determines which path index should be used for routes separation (example: GET:/fruits/getFruit -> index:0 -> moduleName -> fruits)",
|
|
190
|
+
default: codeGenBaseConfig.moduleNameIndex.toString()
|
|
191
|
+
},
|
|
192
|
+
name: {
|
|
193
|
+
type: "string",
|
|
194
|
+
alias: "n",
|
|
195
|
+
description: "name of output typescript api file",
|
|
196
|
+
default: codeGenBaseConfig.fileName
|
|
197
|
+
},
|
|
198
|
+
output: {
|
|
199
|
+
type: "string",
|
|
200
|
+
alias: "o",
|
|
201
|
+
description: "output path of typescript api file",
|
|
202
|
+
default: "./"
|
|
203
|
+
},
|
|
204
|
+
patch: {
|
|
205
|
+
type: "boolean",
|
|
206
|
+
description: "fix up small errors in the swagger source definition",
|
|
207
|
+
default: codeGenBaseConfig.patch
|
|
208
|
+
},
|
|
209
|
+
path: {
|
|
210
|
+
type: "string",
|
|
211
|
+
alias: "p",
|
|
212
|
+
description: "path/url to swagger scheme",
|
|
213
|
+
required: true
|
|
214
|
+
},
|
|
215
|
+
responses: {
|
|
216
|
+
type: "boolean",
|
|
217
|
+
alias: "r",
|
|
218
|
+
description: "generate additional information about request responses also add typings for bad responses",
|
|
219
|
+
default: codeGenBaseConfig.generateResponses
|
|
220
|
+
},
|
|
221
|
+
"route-types": {
|
|
222
|
+
type: "boolean",
|
|
223
|
+
description: "generate type definitions for API routes",
|
|
224
|
+
default: codeGenBaseConfig.generateRouteTypes
|
|
225
|
+
},
|
|
226
|
+
silent: {
|
|
227
|
+
type: "boolean",
|
|
228
|
+
description: "Output only errors to console",
|
|
229
|
+
default: codeGenBaseConfig.silent
|
|
230
|
+
},
|
|
231
|
+
"single-http-client": {
|
|
232
|
+
type: "boolean",
|
|
233
|
+
description: "Ability to send HttpClient instance to Api constructor",
|
|
234
|
+
default: codeGenBaseConfig.singleHttpClient
|
|
235
|
+
},
|
|
236
|
+
"sort-routes": {
|
|
237
|
+
type: "boolean",
|
|
238
|
+
description: "sort routes in alphabetical order",
|
|
239
|
+
default: codeGenBaseConfig.sortRoutes
|
|
240
|
+
},
|
|
241
|
+
"sort-types": {
|
|
242
|
+
type: "boolean",
|
|
243
|
+
description: "sort fields and types",
|
|
244
|
+
default: codeGenBaseConfig.sortTypes
|
|
245
|
+
},
|
|
246
|
+
templates: {
|
|
247
|
+
type: "string",
|
|
248
|
+
alias: "t",
|
|
249
|
+
description: "path to folder containing templates"
|
|
250
|
+
},
|
|
251
|
+
"type-prefix": {
|
|
252
|
+
type: "string",
|
|
253
|
+
description: "data contract name prefix",
|
|
254
|
+
default: codeGenBaseConfig.typePrefix
|
|
255
|
+
},
|
|
256
|
+
"type-suffix": {
|
|
257
|
+
type: "string",
|
|
258
|
+
description: "data contract name suffix",
|
|
259
|
+
default: codeGenBaseConfig.typeSuffix
|
|
260
|
+
},
|
|
261
|
+
"unwrap-response-data": {
|
|
262
|
+
type: "boolean",
|
|
263
|
+
description: "unwrap the data item from the response",
|
|
264
|
+
default: codeGenBaseConfig.unwrapResponseData
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
run: async ({ args }) => {
|
|
268
|
+
const customConfig = await loadConfig({ configFile: args["custom-config"] });
|
|
269
|
+
await generateApi({
|
|
270
|
+
addReadonly: args["add-readonly"],
|
|
271
|
+
anotherArrayType: args["another-array-type"],
|
|
272
|
+
apiClassName: args["api-class-name"],
|
|
273
|
+
cleanOutput: args["clean-output"],
|
|
274
|
+
debug: args.debug,
|
|
275
|
+
defaultResponseAsSuccess: args["default-as-success"],
|
|
276
|
+
defaultResponseType: args["default-response"],
|
|
277
|
+
disableThrowOnError: args["disable-throw-on-error"],
|
|
278
|
+
enumNamesAsValues: args["enum-names-as-values"],
|
|
279
|
+
extractEnums: args["extract-enums"],
|
|
280
|
+
extractRequestBody: args["extract-request-body"],
|
|
281
|
+
extractRequestParams: args["extract-request-params"],
|
|
282
|
+
extractResponseBody: args["extract-response-body"],
|
|
283
|
+
extractResponseError: args["extract-response-error"],
|
|
284
|
+
extractResponses: args["extract-responses"],
|
|
285
|
+
fileName: args.name,
|
|
286
|
+
generateClient: args.client,
|
|
287
|
+
generateResponses: args.responses,
|
|
288
|
+
generateRouteTypes: args["route-types"],
|
|
289
|
+
generateUnionEnums: args["generate-union-enums"],
|
|
290
|
+
httpClientType: args["http-client"] || args.axios ? HTTP_CLIENT.AXIOS : HTTP_CLIENT.FETCH,
|
|
291
|
+
input: path$1.resolve(process.cwd(), args.path),
|
|
292
|
+
modular: args.modular,
|
|
293
|
+
moduleNameFirstTag: args["module-name-first-tag"],
|
|
294
|
+
moduleNameIndex: +args["module-name-index"] || 0,
|
|
295
|
+
output: path$1.resolve(process.cwd(), args.output || "."),
|
|
296
|
+
patch: args.patch,
|
|
297
|
+
silent: args.silent,
|
|
298
|
+
singleHttpClient: args["single-http-client"],
|
|
299
|
+
sortRoutes: args["sort-routes"],
|
|
300
|
+
sortTypes: args["sort-types"],
|
|
301
|
+
templates: args.templates,
|
|
302
|
+
toJS: args.js,
|
|
303
|
+
typePrefix: args["type-prefix"],
|
|
304
|
+
typeSuffix: args["type-suffix"],
|
|
305
|
+
unwrapResponseData: args["unwrap-response-data"],
|
|
306
|
+
url: args.path,
|
|
307
|
+
...customConfig.config
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
const main = defineCommand({
|
|
312
|
+
meta: {
|
|
313
|
+
name: package_default.name,
|
|
314
|
+
description: package_default.description,
|
|
315
|
+
version: package_default.version
|
|
316
|
+
},
|
|
317
|
+
args: generateCommand.args,
|
|
318
|
+
run: generateCommand.run,
|
|
319
|
+
subCommands: {
|
|
320
|
+
generate: generateCommand,
|
|
321
|
+
"generate-templates": generateTemplatesCommand
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
runMain(main);
|
|
325
|
+
|
|
326
|
+
//#endregion
|
|
3
327
|
//# 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","loadConfig","generateApi","main","runMain"],"mappings":";+JAYA,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,EACA,KAAO,CAAA,CACL,KAAM,SACN,CAAA,WAAA,CAAa,0DACb,OAASA,CAAAA,CAAAA,CAAsB,KACjC,CACA,CAAA,aAAA,CAA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CAAQA,EAAK,MACb,CAAA,gBAAA,CAAkBA,EAAK,oBAAoB,CAAA,CAC3C,WAAYA,CAAK,CAAA,aAAa,EAC9B,SAAWA,CAAAA,CAAAA,CAAK,YAAY,CAC5B,CAAA,SAAA,CAAWA,EAAK,SAChB,CAAA,IAAA,CAAMA,EAAK,EACX,CAAA,UAAA,CAAYA,EAAK,aAAa,CAAA,CAC9B,WAAYA,CAAK,CAAA,aAAa,EAC9B,kBAAoBA,CAAAA,CAAAA,CAAK,sBAAsB,CAC/C,CAAA,GAAA,CAAKA,EAAK,IACV,CAAA,GAAGM,EAAa,MAClB,CAAC,EACH,CACF,CAAC,EAEKG,CAAOX,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,CAEDa,CAAAA,OAAAA,CAAQD,CAAI,CAAA","file":"cli.js","sourcesContent":["#!/usr/bin/env node\n\nimport * as path from \"node:path\";\nimport { loadConfig } from \"c12\";\nimport { defineCommand, runMain } from \"citty\";\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 { GenerateApiParams, 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 debug: {\n type: \"boolean\",\n description: \"additional information about processes inside this tool\",\n default: templateGenBaseConfig.debug,\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 required: true,\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 },\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 \"add-readonly\": {\n type: \"boolean\",\n description: \"generate readonly properties\",\n default: codeGenBaseConfig.addReadonly,\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 \"api-class-name\": {\n type: \"string\",\n description: \"name of the api class\",\n default: codeGenBaseConfig.apiClassName,\n },\n axios: {\n type: \"boolean\",\n description: \"generate axios http client\",\n default: false,\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 client: {\n type: \"boolean\",\n description: \"do not generate an API class\",\n default: codeGenBaseConfig.generateClient,\n },\n \"custom-config\": {\n type: \"string\",\n description: \"custom config: primitiveTypeConstructs, hooks, ... \",\n },\n debug: {\n type: \"boolean\",\n description: \"additional information about processes inside this tool\",\n default: codeGenBaseConfig.debug,\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 \"default-response\": {\n type: \"string\",\n description: \"default type for empty response schema\",\n default: codeGenBaseConfig.defaultResponseType,\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 \"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-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 \"extract-request-body\": {\n type: \"boolean\",\n description: \"extract request body type to data contract\",\n default: codeGenBaseConfig.extractRequestBody,\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-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 \"generate-union-enums\": {\n type: \"boolean\",\n description: 'generate all \"enum\" types as union types (T1 | T2 | TN)',\n default: codeGenBaseConfig.generateUnionEnums,\n },\n \"http-client\": {\n type: \"string\",\n description: `http client type (possible values: ${Object.values(\n HTTP_CLIENT,\n )})`,\n },\n js: {\n type: \"boolean\",\n description: \"generate js api module with declaration file\",\n default: codeGenBaseConfig.toJS,\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 \"module-name-first-tag\": {\n type: \"boolean\",\n description: \"splits routes based on the first tag\",\n default: codeGenBaseConfig.moduleNameFirstTag,\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 name: {\n type: \"string\",\n alias: \"n\",\n description: \"name of output typescript api file\",\n default: codeGenBaseConfig.fileName,\n },\n output: {\n type: \"string\",\n alias: \"o\",\n description: \"output path of typescript api file\",\n default: \"./\",\n },\n patch: {\n type: \"boolean\",\n description: \"fix up small errors in the swagger source definition\",\n default: codeGenBaseConfig.patch,\n },\n path: {\n type: \"string\",\n alias: \"p\",\n description: \"path/url to swagger scheme\",\n required: true,\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 \"route-types\": {\n type: \"boolean\",\n description: \"generate type definitions for API routes\",\n default: codeGenBaseConfig.generateRouteTypes,\n },\n silent: {\n type: \"boolean\",\n description: \"Output only errors to console\",\n default: codeGenBaseConfig.silent,\n },\n \"single-http-client\": {\n type: \"boolean\",\n description: \"Ability to send HttpClient instance to Api constructor\",\n default: codeGenBaseConfig.singleHttpClient,\n },\n \"sort-routes\": {\n type: \"boolean\",\n description: \"sort routes in alphabetical order\",\n default: codeGenBaseConfig.sortRoutes,\n },\n \"sort-types\": {\n type: \"boolean\",\n description: \"sort fields and types\",\n default: codeGenBaseConfig.sortTypes,\n },\n templates: {\n type: \"string\",\n alias: \"t\",\n description: \"path to folder containing templates\",\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 \"unwrap-response-data\": {\n type: \"boolean\",\n description: \"unwrap the data item from the response\",\n default: codeGenBaseConfig.unwrapResponseData,\n },\n },\n run: async ({ args }) => {\n const customConfig = await loadConfig<GenerateApiParams>({\n configFile: args[\"custom-config\"],\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.client,\n generateResponses: args.responses,\n generateRouteTypes: args[\"route-types\"],\n generateUnionEnums: args[\"generate-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.config,\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,"file":"cli.js","names":[],"sources":["../index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport * as path from \"node:path\";\nimport { loadConfig } from \"c12\";\nimport { defineCommand, runMain } from \"citty\";\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 { GenerateApiParams, 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 debug: {\n type: \"boolean\",\n description: \"additional information about processes inside this tool\",\n default: templateGenBaseConfig.debug,\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 required: true,\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 },\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 \"add-readonly\": {\n type: \"boolean\",\n description: \"generate readonly properties\",\n default: codeGenBaseConfig.addReadonly,\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 \"api-class-name\": {\n type: \"string\",\n description: \"name of the api class\",\n default: codeGenBaseConfig.apiClassName,\n },\n axios: {\n type: \"boolean\",\n description: \"generate axios http client\",\n default: false,\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 client: {\n type: \"boolean\",\n description: \"do not generate an API class\",\n default: codeGenBaseConfig.generateClient,\n },\n \"custom-config\": {\n type: \"string\",\n description: \"custom config: primitiveTypeConstructs, hooks, ... \",\n },\n debug: {\n type: \"boolean\",\n description: \"additional information about processes inside this tool\",\n default: codeGenBaseConfig.debug,\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 \"default-response\": {\n type: \"string\",\n description: \"default type for empty response schema\",\n default: codeGenBaseConfig.defaultResponseType,\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 \"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-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 \"extract-request-body\": {\n type: \"boolean\",\n description: \"extract request body type to data contract\",\n default: codeGenBaseConfig.extractRequestBody,\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-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 \"generate-union-enums\": {\n type: \"boolean\",\n description: 'generate all \"enum\" types as union types (T1 | T2 | TN)',\n default: codeGenBaseConfig.generateUnionEnums,\n },\n \"http-client\": {\n type: \"string\",\n description: `http client type (possible values: ${Object.values(\n HTTP_CLIENT,\n )})`,\n },\n js: {\n type: \"boolean\",\n description: \"generate js api module with declaration file\",\n default: codeGenBaseConfig.toJS,\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 \"module-name-first-tag\": {\n type: \"boolean\",\n description: \"splits routes based on the first tag\",\n default: codeGenBaseConfig.moduleNameFirstTag,\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 name: {\n type: \"string\",\n alias: \"n\",\n description: \"name of output typescript api file\",\n default: codeGenBaseConfig.fileName,\n },\n output: {\n type: \"string\",\n alias: \"o\",\n description: \"output path of typescript api file\",\n default: \"./\",\n },\n patch: {\n type: \"boolean\",\n description: \"fix up small errors in the swagger source definition\",\n default: codeGenBaseConfig.patch,\n },\n path: {\n type: \"string\",\n alias: \"p\",\n description: \"path/url to swagger scheme\",\n required: true,\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 \"route-types\": {\n type: \"boolean\",\n description: \"generate type definitions for API routes\",\n default: codeGenBaseConfig.generateRouteTypes,\n },\n silent: {\n type: \"boolean\",\n description: \"Output only errors to console\",\n default: codeGenBaseConfig.silent,\n },\n \"single-http-client\": {\n type: \"boolean\",\n description: \"Ability to send HttpClient instance to Api constructor\",\n default: codeGenBaseConfig.singleHttpClient,\n },\n \"sort-routes\": {\n type: \"boolean\",\n description: \"sort routes in alphabetical order\",\n default: codeGenBaseConfig.sortRoutes,\n },\n \"sort-types\": {\n type: \"boolean\",\n description: \"sort fields and types\",\n default: codeGenBaseConfig.sortTypes,\n },\n templates: {\n type: \"string\",\n alias: \"t\",\n description: \"path to folder containing templates\",\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 \"unwrap-response-data\": {\n type: \"boolean\",\n description: \"unwrap the data item from the response\",\n default: codeGenBaseConfig.unwrapResponseData,\n },\n },\n run: async ({ args }) => {\n const customConfig = await loadConfig<GenerateApiParams>({\n configFile: args[\"custom-config\"],\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.client,\n generateResponses: args.responses,\n generateRouteTypes: args[\"route-types\"],\n generateUnionEnums: args[\"generate-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.config,\n });\n },\n});\n\nconst main = defineCommand({\n meta: {\n name: packageJson.name,\n description: packageJson.description,\n version: packageJson.version,\n },\n args: generateCommand.args,\n run: generateCommand.run,\n subCommands: {\n generate: generateCommand,\n \"generate-templates\": generateTemplatesCommand,\n },\n});\n\nrunMain(main);\n"],"mappings":";;;;;;;AAYA,MAAM,wBAAwB,IAAI,mBAAmB,CAAE;AAEvD,MAAM,2BAA2B,cAAc;CAC7C,MAAM;EACJ,MAAM;EACN,aAAa;CACd;CACD,MAAM;EACJ,gBAAgB;GACd,MAAM;GACN,aACE;GACF,SAAS,sBAAsB;EAChC;EACD,OAAO;GACL,MAAM;GACN,aAAa;GACb,SAAS,sBAAsB;EAChC;EACD,eAAe;GACb,MAAM;GACN,cAAc,qCAAqC,OAAO,OACxD,YACD,CAAC;GACF,SAAS,sBAAsB;EAChC;EACD,SAAS;GACP,MAAM;GACN,aACE;GACF,SAAS,sBAAsB;EAChC;EACD,QAAQ;GACN,MAAM;GACN,OAAO;GACP,aAAa;GACb,SAAS,sBAAsB;GAC/B,UAAU;EACX;EACD,SAAS;GACP,MAAM;GACN,OAAO;GACP,aAAa;GACb,SAAS,sBAAsB;EAChC;EACD,QAAQ;GACN,MAA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H;AACF,EAAC;AAEF,MAAM,OAAO,cAAc;CACzB,MAAM;EACJ,MAAM,gBAAY;EAClB,aAAa,gBAAY;EACzB,SAAS,gBAAY;CACtB;CACD,MAAM,gBAAgB;CACtB,KAAK,gBAAgB;CACrB,aAAa;EACX,UAAU;EACV,sBAAsB;CACvB;AACF,EAAC;AAEF,QAAQ,KAAK"}
|
package/dist/lib.cjs
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const require_src = require('./src-D3nQpZ1i.cjs');
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, 'constants', {
|
|
4
|
+
enumerable: true,
|
|
5
|
+
get: function () {
|
|
6
|
+
return require_src.constants_exports;
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
exports.generateApi = require_src.generateApi
|
|
10
|
+
exports.generateTemplates = require_src.generateTemplates
|