@devbie/apits 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +89 -2
- package/bin/apits +4 -0
- package/dist/cjs/core/cli.d.ts +29 -0
- package/dist/cjs/core/cli.js +396 -0
- package/dist/cjs/core/generator.d.ts +44 -0
- package/dist/cjs/core/generator.js +301 -0
- package/dist/cjs/core/writeRequestClient.d.ts +2 -0
- package/dist/cjs/core/writeRequestClient.js +93 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +25 -0
- package/dist/cjs/types.d.ts +330 -0
- package/dist/cjs/types.js +90 -0
- package/dist/cjs/utils/console.d.ts +16 -0
- package/dist/cjs/utils/console.js +79 -0
- package/dist/cjs/utils/getOutputPath.d.ts +5 -0
- package/dist/cjs/utils/getOutputPath.js +43 -0
- package/dist/cjs/utils/helpers.d.ts +65 -0
- package/dist/cjs/utils/helpers.js +166 -0
- package/dist/cjs/utils/openApiToInterfaces.d.ts +14 -0
- package/dist/cjs/utils/openApiToInterfaces.js +229 -0
- package/dist/cjs/utils/spinner.d.ts +15 -0
- package/dist/cjs/utils/spinner.js +69 -0
- package/dist/cjs/utils/utils.d.ts +56 -0
- package/dist/cjs/utils/utils.js +355 -0
- package/dist/cjs/utils/vtilsLite.d.ts +55 -0
- package/dist/cjs/utils/vtilsLite.js +123 -0
- package/dist/esm/core/cli.d.mts +29 -0
- package/dist/esm/core/cli.mjs +713 -0
- package/dist/esm/core/generator.d.mts +44 -0
- package/dist/esm/core/generator.mjs +463 -0
- package/dist/esm/core/writeRequestClient.d.mts +2 -0
- package/dist/esm/core/writeRequestClient.mjs +54 -0
- package/dist/esm/index.d.mts +2 -0
- package/dist/esm/index.mjs +2 -0
- package/dist/esm/types.d.mts +330 -0
- package/dist/esm/types.mjs +94 -0
- package/dist/esm/utils/console.d.mts +16 -0
- package/dist/esm/utils/console.mjs +65 -0
- package/dist/esm/utils/getOutputPath.d.mts +5 -0
- package/dist/esm/utils/getOutputPath.mjs +12 -0
- package/dist/esm/utils/helpers.d.mts +65 -0
- package/dist/esm/utils/helpers.mjs +226 -0
- package/dist/esm/utils/openApiToInterfaces.d.mts +14 -0
- package/dist/esm/utils/openApiToInterfaces.mjs +326 -0
- package/dist/esm/utils/spinner.d.mts +15 -0
- package/dist/esm/utils/spinner.mjs +58 -0
- package/dist/esm/utils/utils.d.mts +56 -0
- package/dist/esm/utils/utils.mjs +545 -0
- package/dist/esm/utils/vtilsLite.d.mts +55 -0
- package/dist/esm/utils/vtilsLite.mjs +142 -0
- package/package.json +68 -4
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
export * from "json-schema";
|
|
3
|
+
import { JSONSchema4 } from "json-schema";
|
|
4
|
+
import { OpenAPIV3 } from "openapi-types";
|
|
5
|
+
import { ParsedPath } from "path";
|
|
6
|
+
/** Returns the client import snippet placed at the top of each generated file. */
|
|
7
|
+
export type ClientImportTemplate = () => string;
|
|
8
|
+
/** Interface definition */
|
|
9
|
+
export interface Interface {
|
|
10
|
+
/** Interface name */
|
|
11
|
+
title: string;
|
|
12
|
+
/** Request path */
|
|
13
|
+
path: string;
|
|
14
|
+
/** Request method, HEAD and OPTIONS are handled like GET, others like POST */
|
|
15
|
+
method: Method;
|
|
16
|
+
/** Path parameters */
|
|
17
|
+
req_params: Array<{
|
|
18
|
+
/** Name */
|
|
19
|
+
name: string;
|
|
20
|
+
/** Description */
|
|
21
|
+
desc: string;
|
|
22
|
+
/** Example */
|
|
23
|
+
example: string;
|
|
24
|
+
/** Type (YApi-X) */
|
|
25
|
+
type?: RequestParamType;
|
|
26
|
+
}>;
|
|
27
|
+
/** GET only: query string */
|
|
28
|
+
req_query: Array<{
|
|
29
|
+
/** Name */
|
|
30
|
+
name: string;
|
|
31
|
+
/** Description */
|
|
32
|
+
desc: string;
|
|
33
|
+
/** Example */
|
|
34
|
+
example: string;
|
|
35
|
+
/** Required */
|
|
36
|
+
required: Required;
|
|
37
|
+
/** Type (YApi-X) */
|
|
38
|
+
type?: RequestQueryType;
|
|
39
|
+
}>;
|
|
40
|
+
/** POST only: request content type. No special handling needed for text, file, raw. */
|
|
41
|
+
req_body_type: RequestBodyType;
|
|
42
|
+
/** Whether it is json schema when `req_body_type = json` */
|
|
43
|
+
req_body_is_json_schema: boolean;
|
|
44
|
+
/** Request content when `req_body_type = form` */
|
|
45
|
+
req_body_form: Array<{
|
|
46
|
+
/** Name */
|
|
47
|
+
name: string;
|
|
48
|
+
/** Type */
|
|
49
|
+
type: RequestFormItemType;
|
|
50
|
+
/** Description */
|
|
51
|
+
desc: string;
|
|
52
|
+
/** Example */
|
|
53
|
+
example: string;
|
|
54
|
+
/** Required */
|
|
55
|
+
required: Required;
|
|
56
|
+
/**
|
|
57
|
+
* Whether the field accepts multiple files (a binary array in the
|
|
58
|
+
* OpenAPI schema, e.g. `files: {type: 'array', items: {format: 'binary'}}`).
|
|
59
|
+
* Only meaningful when `type` is `file`.
|
|
60
|
+
*/
|
|
61
|
+
isArray?: boolean;
|
|
62
|
+
/** Allowed literal values when the form field is an enum */
|
|
63
|
+
enum?: Array<string | number>;
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* Whether the form body is `multipart/form-data` (true) or
|
|
67
|
+
* `application/x-www-form-urlencoded` (false). Only set when
|
|
68
|
+
* `req_body_type = form`.
|
|
69
|
+
*/
|
|
70
|
+
req_body_multipart?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* JSON Schema fragment describing dynamic form fields (the
|
|
73
|
+
* `additionalProperties` of a multipart request schema). Used for
|
|
74
|
+
* runtime-named upload fields such as `evidence_0`, `evidence_1`, ...
|
|
75
|
+
*/
|
|
76
|
+
req_body_additional?: Record<string, any>;
|
|
77
|
+
/** Request content when `req_body_type = json` */
|
|
78
|
+
req_body_other: string;
|
|
79
|
+
/** Response data type */
|
|
80
|
+
res_body_type: ResponseBodyType;
|
|
81
|
+
/** Whether it is json schema when `res_body_type = json` */
|
|
82
|
+
res_body_is_json_schema: boolean;
|
|
83
|
+
/** Response data */
|
|
84
|
+
res_body: string;
|
|
85
|
+
[key: string]: any;
|
|
86
|
+
}
|
|
87
|
+
/** Category information */
|
|
88
|
+
export interface Category {
|
|
89
|
+
/** Category name */
|
|
90
|
+
name: string;
|
|
91
|
+
/** Category description */
|
|
92
|
+
desc: string;
|
|
93
|
+
}
|
|
94
|
+
/** Request method */
|
|
95
|
+
export declare enum Method {
|
|
96
|
+
GET = "GET",
|
|
97
|
+
POST = "POST",
|
|
98
|
+
PUT = "PUT",
|
|
99
|
+
DELETE = "DELETE",
|
|
100
|
+
HEAD = "HEAD",
|
|
101
|
+
OPTIONS = "OPTIONS",
|
|
102
|
+
PATCH = "PATCH"
|
|
103
|
+
}
|
|
104
|
+
/** Required */
|
|
105
|
+
export declare enum Required {
|
|
106
|
+
/** Not required */
|
|
107
|
+
false = "0",
|
|
108
|
+
/** Required */
|
|
109
|
+
true = "1"
|
|
110
|
+
}
|
|
111
|
+
/** Request body type */
|
|
112
|
+
export declare enum RequestBodyType {
|
|
113
|
+
/** Query string */
|
|
114
|
+
query = "query",
|
|
115
|
+
/** Form */
|
|
116
|
+
form = "form",
|
|
117
|
+
/** JSON */
|
|
118
|
+
json = "json",
|
|
119
|
+
/** Plain text */
|
|
120
|
+
text = "text",
|
|
121
|
+
/** File */
|
|
122
|
+
file = "file",
|
|
123
|
+
/** Raw data */
|
|
124
|
+
raw = "raw",
|
|
125
|
+
/** No request data */
|
|
126
|
+
none = "none"
|
|
127
|
+
}
|
|
128
|
+
/** Request path parameter type */
|
|
129
|
+
export declare enum RequestParamType {
|
|
130
|
+
/** String */
|
|
131
|
+
string = "string",
|
|
132
|
+
/** Number */
|
|
133
|
+
number = "number"
|
|
134
|
+
}
|
|
135
|
+
/** Request query parameter type */
|
|
136
|
+
export declare enum RequestQueryType {
|
|
137
|
+
/** String */
|
|
138
|
+
string = "string",
|
|
139
|
+
/** Number */
|
|
140
|
+
number = "number"
|
|
141
|
+
}
|
|
142
|
+
/** Request form item type */
|
|
143
|
+
export declare enum RequestFormItemType {
|
|
144
|
+
/** Plain text */
|
|
145
|
+
text = "text",
|
|
146
|
+
/** File */
|
|
147
|
+
file = "file"
|
|
148
|
+
}
|
|
149
|
+
/** Response body type */
|
|
150
|
+
export declare enum ResponseBodyType {
|
|
151
|
+
/** JSON */
|
|
152
|
+
json = "json",
|
|
153
|
+
/** Plain text */
|
|
154
|
+
text = "text",
|
|
155
|
+
/** XML */
|
|
156
|
+
xml = "xml",
|
|
157
|
+
/** Raw data */
|
|
158
|
+
raw = "raw"
|
|
159
|
+
}
|
|
160
|
+
/** Extended interface definition */
|
|
161
|
+
export interface ExtendedInterface extends Interface {
|
|
162
|
+
parsedPath: ParsedPath;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Generator configuration for one OpenAPI source.
|
|
166
|
+
*/
|
|
167
|
+
export interface ApiConfig {
|
|
168
|
+
/**
|
|
169
|
+
* The OpenAPI document to generate code from. Required.
|
|
170
|
+
*
|
|
171
|
+
* Accepts an http(s) URL or a local file path. Local files may be
|
|
172
|
+
* JSON (.json / .json5) or YAML (.yaml / .yml).
|
|
173
|
+
*
|
|
174
|
+
* @example 'http://localhost:3041/api-json'
|
|
175
|
+
* @example './openapi.json'
|
|
176
|
+
* @example './docs/openapi.yaml'
|
|
177
|
+
*/
|
|
178
|
+
input: string;
|
|
179
|
+
/**
|
|
180
|
+
* Output directory for generated files (relative or absolute path).
|
|
181
|
+
*
|
|
182
|
+
* Two files are written into it: `<name>.ts` (type declarations and
|
|
183
|
+
* request functions) and `request.ts` (the axios client, unless
|
|
184
|
+
* `client` is false or the file already exists).
|
|
185
|
+
*
|
|
186
|
+
* @default 'src/api'
|
|
187
|
+
*/
|
|
188
|
+
output?: string;
|
|
189
|
+
/**
|
|
190
|
+
* Base name of the generated types file: code is written to
|
|
191
|
+
* `<output>/<name>.ts`. Also serves as the source identifier for
|
|
192
|
+
* `apits gen -n <name>` filtering.
|
|
193
|
+
*
|
|
194
|
+
* Defaults to a name derived from `input`: the URL hostname
|
|
195
|
+
* (`http://localhost:3041/api-json` -> `localhost`) or the local file
|
|
196
|
+
* name without extension (`./user.openapi.yaml` -> `userOpenapi`).
|
|
197
|
+
* Duplicated derived names get an index suffix.
|
|
198
|
+
*/
|
|
199
|
+
name?: string;
|
|
200
|
+
/**
|
|
201
|
+
* Runtime `baseURL` baked into every generated request function.
|
|
202
|
+
*
|
|
203
|
+
* Prefix with `[code]:` to emit the value as code instead of a string
|
|
204
|
+
* literal, e.g. to read from an env var at runtime:
|
|
205
|
+
*
|
|
206
|
+
* - `baseURL: '[code]:process.env.BASE_URL'` -> `baseURL: process.env.BASE_URL`
|
|
207
|
+
* - `baseURL: 'http://localhost:3000'` -> `baseURL: "http://localhost:3000"`
|
|
208
|
+
*
|
|
209
|
+
* May also be a function receiving each API path and returning the
|
|
210
|
+
* baseURL to use for that path (or undefined to omit).
|
|
211
|
+
*/
|
|
212
|
+
baseURL?: ((path: string) => string | undefined) | string;
|
|
213
|
+
/**
|
|
214
|
+
* Returns the import snippet placed at the top of every generated file —
|
|
215
|
+
* use it to point at a custom request client instead of the scaffolded
|
|
216
|
+
* `request.ts`.
|
|
217
|
+
*
|
|
218
|
+
* Providing this option also flips the default of `client` to `false`,
|
|
219
|
+
* so no unused `request.ts` is scaffolded; set `client: true` explicitly
|
|
220
|
+
* to keep both.
|
|
221
|
+
*
|
|
222
|
+
* @default () => "import request from './request'"
|
|
223
|
+
*/
|
|
224
|
+
clientImportTemplate?: ClientImportTemplate;
|
|
225
|
+
/**
|
|
226
|
+
* Type used for the `extra` argument of every generated request
|
|
227
|
+
* function — the object spread into the underlying client call as
|
|
228
|
+
* per-request overrides (headers, signal, `responseType`, ...).
|
|
229
|
+
*
|
|
230
|
+
* Defaults to `AxiosRequestConfig`, in which case each generated file
|
|
231
|
+
* also imports that type from `axios`. When using a custom client via
|
|
232
|
+
* `clientImportTemplate`, set this to that client's config type and
|
|
233
|
+
* make sure `clientImportTemplate` imports it, e.g.:
|
|
234
|
+
*
|
|
235
|
+
* ```ts
|
|
236
|
+
* clientImportTemplate: () => "import {request, type RequestConfig} from '../fetch'",
|
|
237
|
+
* clientConfigType: 'RequestConfig',
|
|
238
|
+
* ```
|
|
239
|
+
*
|
|
240
|
+
* @default 'AxiosRequestConfig'
|
|
241
|
+
*/
|
|
242
|
+
clientConfigType?: string;
|
|
243
|
+
/**
|
|
244
|
+
* Whether to scaffold the default axios request client into
|
|
245
|
+
* `<output>/request.ts` (skipped when that file already exists).
|
|
246
|
+
*
|
|
247
|
+
* Defaults to `true`, and to `false` when `clientImportTemplate` is
|
|
248
|
+
* provided without an explicit `client` value.
|
|
249
|
+
*
|
|
250
|
+
* @default true
|
|
251
|
+
*/
|
|
252
|
+
client?: boolean;
|
|
253
|
+
}
|
|
254
|
+
/** Combined configuration. */
|
|
255
|
+
export type SyntheticalConfig = Partial<ApiConfig & {
|
|
256
|
+
components: OpenAPIV3.Document["components"];
|
|
257
|
+
}>;
|
|
258
|
+
/** Configuration. */
|
|
259
|
+
export type Config = ApiConfig;
|
|
260
|
+
/**
|
|
261
|
+
* Request configuration.
|
|
262
|
+
*/
|
|
263
|
+
export interface RequestConfig<Path extends string = string, ParamName extends string = string, QueryName extends string = string, RequestDataOptional extends boolean = boolean> {
|
|
264
|
+
/** Interface path, starting with `/` */
|
|
265
|
+
path: Path;
|
|
266
|
+
/** Request method */
|
|
267
|
+
method: Method;
|
|
268
|
+
/** Request headers, all headers except Content-Type */
|
|
269
|
+
requestHeaders: Record<string, string>;
|
|
270
|
+
/** Request body type */
|
|
271
|
+
requestBodyType: RequestBodyType;
|
|
272
|
+
/** Response body type */
|
|
273
|
+
responseBodyType: ResponseBodyType;
|
|
274
|
+
/** List of path parameter names */
|
|
275
|
+
paramNames: ParamName[];
|
|
276
|
+
/** List of query parameter names */
|
|
277
|
+
queryNames: QueryName[];
|
|
278
|
+
/** Whether request data is optional */
|
|
279
|
+
requestDataOptional: RequestDataOptional;
|
|
280
|
+
/** JSON Schema for request data (only effective when JSON Schema generation is enabled) */
|
|
281
|
+
requestDataJsonSchema: JSONSchema4;
|
|
282
|
+
/** JSON Schema for response data (only effective when JSON Schema generation is enabled) */
|
|
283
|
+
responseDataJsonSchema: JSONSchema4;
|
|
284
|
+
/** Request function name */
|
|
285
|
+
requestFunctionName: string;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Request parameters.
|
|
289
|
+
*/
|
|
290
|
+
export interface RequestFunctionParams extends RequestConfig {
|
|
291
|
+
/** Raw data */
|
|
292
|
+
rawData: Record<string, any>;
|
|
293
|
+
/** Request data, excluding file data */
|
|
294
|
+
data: Record<string, any>;
|
|
295
|
+
/** Whether there is file data */
|
|
296
|
+
hasFileData: boolean;
|
|
297
|
+
/** Request file data */
|
|
298
|
+
fileData: Record<string, any>;
|
|
299
|
+
/** All request data, including data and fileData */
|
|
300
|
+
allData: Record<string, any>;
|
|
301
|
+
/** Get FormData instance for all request data (including files) */
|
|
302
|
+
getFormData: () => FormData;
|
|
303
|
+
}
|
|
304
|
+
/** Additional parameters of the request function */
|
|
305
|
+
export type RequestFunctionRestArgs<T extends Function> = T extends (payload: any, ...args: infer R) => any ? R : never;
|
|
306
|
+
/** Property definition */
|
|
307
|
+
export interface PropDefinition {
|
|
308
|
+
/** Property name */
|
|
309
|
+
name: string;
|
|
310
|
+
/** Required */
|
|
311
|
+
required: boolean;
|
|
312
|
+
/** Type */
|
|
313
|
+
type: JSONSchema4["type"];
|
|
314
|
+
/** Comment */
|
|
315
|
+
comment: string;
|
|
316
|
+
/** Whether the property is an array (used for multi-file upload fields) */
|
|
317
|
+
isArray?: boolean;
|
|
318
|
+
/** Allowed literal values for enum properties */
|
|
319
|
+
enum?: Array<string | number>;
|
|
320
|
+
}
|
|
321
|
+
/** Property definition list */
|
|
322
|
+
export type PropDefinitions = PropDefinition[];
|
|
323
|
+
/** Request function body generation template function */
|
|
324
|
+
export interface RequestFunctionTemplateProps {
|
|
325
|
+
baseURL?: string;
|
|
326
|
+
requestFunctionName: string;
|
|
327
|
+
requestDataTypeName: string;
|
|
328
|
+
extendedInterfaceInfo: ExtendedInterface;
|
|
329
|
+
responseDataTypeName: string;
|
|
330
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/types.ts
|
|
21
|
+
var types_exports = {};
|
|
22
|
+
__export(types_exports, {
|
|
23
|
+
Method: () => Method,
|
|
24
|
+
RequestBodyType: () => RequestBodyType,
|
|
25
|
+
RequestFormItemType: () => RequestFormItemType,
|
|
26
|
+
RequestParamType: () => RequestParamType,
|
|
27
|
+
RequestQueryType: () => RequestQueryType,
|
|
28
|
+
Required: () => Required,
|
|
29
|
+
ResponseBodyType: () => ResponseBodyType
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(types_exports);
|
|
32
|
+
__reExport(types_exports, require("json-schema"), module.exports);
|
|
33
|
+
var Method = /* @__PURE__ */ ((Method2) => {
|
|
34
|
+
Method2["GET"] = "GET";
|
|
35
|
+
Method2["POST"] = "POST";
|
|
36
|
+
Method2["PUT"] = "PUT";
|
|
37
|
+
Method2["DELETE"] = "DELETE";
|
|
38
|
+
Method2["HEAD"] = "HEAD";
|
|
39
|
+
Method2["OPTIONS"] = "OPTIONS";
|
|
40
|
+
Method2["PATCH"] = "PATCH";
|
|
41
|
+
return Method2;
|
|
42
|
+
})(Method || {});
|
|
43
|
+
var Required = /* @__PURE__ */ ((Required2) => {
|
|
44
|
+
Required2["false"] = "0";
|
|
45
|
+
Required2["true"] = "1";
|
|
46
|
+
return Required2;
|
|
47
|
+
})(Required || {});
|
|
48
|
+
var RequestBodyType = /* @__PURE__ */ ((RequestBodyType2) => {
|
|
49
|
+
RequestBodyType2["query"] = "query";
|
|
50
|
+
RequestBodyType2["form"] = "form";
|
|
51
|
+
RequestBodyType2["json"] = "json";
|
|
52
|
+
RequestBodyType2["text"] = "text";
|
|
53
|
+
RequestBodyType2["file"] = "file";
|
|
54
|
+
RequestBodyType2["raw"] = "raw";
|
|
55
|
+
RequestBodyType2["none"] = "none";
|
|
56
|
+
return RequestBodyType2;
|
|
57
|
+
})(RequestBodyType || {});
|
|
58
|
+
var RequestParamType = /* @__PURE__ */ ((RequestParamType2) => {
|
|
59
|
+
RequestParamType2["string"] = "string";
|
|
60
|
+
RequestParamType2["number"] = "number";
|
|
61
|
+
return RequestParamType2;
|
|
62
|
+
})(RequestParamType || {});
|
|
63
|
+
var RequestQueryType = /* @__PURE__ */ ((RequestQueryType2) => {
|
|
64
|
+
RequestQueryType2["string"] = "string";
|
|
65
|
+
RequestQueryType2["number"] = "number";
|
|
66
|
+
return RequestQueryType2;
|
|
67
|
+
})(RequestQueryType || {});
|
|
68
|
+
var RequestFormItemType = /* @__PURE__ */ ((RequestFormItemType2) => {
|
|
69
|
+
RequestFormItemType2["text"] = "text";
|
|
70
|
+
RequestFormItemType2["file"] = "file";
|
|
71
|
+
return RequestFormItemType2;
|
|
72
|
+
})(RequestFormItemType || {});
|
|
73
|
+
var ResponseBodyType = /* @__PURE__ */ ((ResponseBodyType2) => {
|
|
74
|
+
ResponseBodyType2["json"] = "json";
|
|
75
|
+
ResponseBodyType2["text"] = "text";
|
|
76
|
+
ResponseBodyType2["xml"] = "xml";
|
|
77
|
+
ResponseBodyType2["raw"] = "raw";
|
|
78
|
+
return ResponseBodyType2;
|
|
79
|
+
})(ResponseBodyType || {});
|
|
80
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
81
|
+
0 && (module.exports = {
|
|
82
|
+
Method,
|
|
83
|
+
RequestBodyType,
|
|
84
|
+
RequestFormItemType,
|
|
85
|
+
RequestParamType,
|
|
86
|
+
RequestQueryType,
|
|
87
|
+
Required,
|
|
88
|
+
ResponseBodyType,
|
|
89
|
+
...require("json-schema")
|
|
90
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Log a plain message. */
|
|
2
|
+
export declare function log(message?: any, ...args: any[]): void;
|
|
3
|
+
/** Log an error message. */
|
|
4
|
+
export declare function error(message?: any, ...args: any[]): void;
|
|
5
|
+
/** Log an info message. */
|
|
6
|
+
export declare function info(message?: any, ...args: any[]): void;
|
|
7
|
+
/** Log a warning message. */
|
|
8
|
+
export declare function warn(message?: any, ...args: any[]): void;
|
|
9
|
+
/** Log a soft tip message with a prefix icon. */
|
|
10
|
+
export declare function tips(message?: any, ...args: any[]): void;
|
|
11
|
+
/** Log a success message. */
|
|
12
|
+
export declare function success(message?: any, ...args: any[]): void;
|
|
13
|
+
/** Print tabular data as a table. */
|
|
14
|
+
export declare function table(tabularData: any, properties?: ReadonlyArray<string>): void;
|
|
15
|
+
/** Print a separator line (or a blank line). */
|
|
16
|
+
export declare function line(blank?: boolean): void;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/utils/console.ts
|
|
30
|
+
var console_exports = {};
|
|
31
|
+
__export(console_exports, {
|
|
32
|
+
error: () => error,
|
|
33
|
+
info: () => info,
|
|
34
|
+
line: () => line,
|
|
35
|
+
log: () => log,
|
|
36
|
+
success: () => success,
|
|
37
|
+
table: () => table,
|
|
38
|
+
tips: () => tips,
|
|
39
|
+
warn: () => warn
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(console_exports);
|
|
42
|
+
var import_chalk = __toESM(require("chalk"));
|
|
43
|
+
function log(message, ...args) {
|
|
44
|
+
console.log(message, ...args);
|
|
45
|
+
}
|
|
46
|
+
function error(message, ...args) {
|
|
47
|
+
console.error(import_chalk.default.magenta(message), ...args);
|
|
48
|
+
}
|
|
49
|
+
function info(message, ...args) {
|
|
50
|
+
console.info(import_chalk.default.yellowBright(message), ...args);
|
|
51
|
+
}
|
|
52
|
+
function warn(message, ...args) {
|
|
53
|
+
console.warn(import_chalk.default.blue(message), ...args);
|
|
54
|
+
}
|
|
55
|
+
function tips(message, ...args) {
|
|
56
|
+
console.log(import_chalk.default.yellow(`🔈 ${message}
|
|
57
|
+
`), ...args);
|
|
58
|
+
}
|
|
59
|
+
function success(message, ...args) {
|
|
60
|
+
console.log(import_chalk.default.cyan(`✓ ${message}`), ...args);
|
|
61
|
+
}
|
|
62
|
+
function table(tabularData, properties) {
|
|
63
|
+
console.table(tabularData, properties);
|
|
64
|
+
}
|
|
65
|
+
function line(blank) {
|
|
66
|
+
console.log(`
|
|
67
|
+
${!blank ? "-----------------------" : ""}`);
|
|
68
|
+
}
|
|
69
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
70
|
+
0 && (module.exports = {
|
|
71
|
+
error,
|
|
72
|
+
info,
|
|
73
|
+
line,
|
|
74
|
+
log,
|
|
75
|
+
success,
|
|
76
|
+
table,
|
|
77
|
+
tips,
|
|
78
|
+
warn
|
|
79
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/utils/getOutputPath.ts
|
|
30
|
+
var getOutputPath_exports = {};
|
|
31
|
+
__export(getOutputPath_exports, {
|
|
32
|
+
getOutputFilePath: () => getOutputFilePath
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(getOutputPath_exports);
|
|
35
|
+
var import_path = __toESM(require("path"));
|
|
36
|
+
var getOutputFilePath = (config, file) => {
|
|
37
|
+
const { dir, name } = import_path.default.parse(config.output || "");
|
|
38
|
+
return import_path.default.join(dir, name, file);
|
|
39
|
+
};
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
getOutputFilePath
|
|
43
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { AppendOptions } from "form-data";
|
|
2
|
+
import type { Config, RequestConfig, RequestFunctionParams } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Normalize user configuration into a config array and apply built-in
|
|
5
|
+
* defaults.
|
|
6
|
+
*
|
|
7
|
+
* Defaults:
|
|
8
|
+
* - `output` falls back to `src/api`.
|
|
9
|
+
* - `client` falls back to `true`, except when a custom
|
|
10
|
+
* `clientImportTemplate` is provided without an explicit `client` value —
|
|
11
|
+
* in that case the scaffolded client is skipped automatically, otherwise
|
|
12
|
+
* the generated `request.ts` would be dead code (the generated file
|
|
13
|
+
* imports the custom client instead).
|
|
14
|
+
*
|
|
15
|
+
* @param config Configuration
|
|
16
|
+
*/
|
|
17
|
+
export declare function defineConfig(config: Config | Config[]): Config[];
|
|
18
|
+
export declare class FileData<T = any> {
|
|
19
|
+
/**
|
|
20
|
+
* Original file data.
|
|
21
|
+
*/
|
|
22
|
+
private originalFileData;
|
|
23
|
+
/**
|
|
24
|
+
* Options.
|
|
25
|
+
*/
|
|
26
|
+
private options;
|
|
27
|
+
/**
|
|
28
|
+
* File data helper class, unified file upload for web, mini-program and other platforms.
|
|
29
|
+
*
|
|
30
|
+
* @param originalFileData Original file data
|
|
31
|
+
* @param options If using internal getFormData, options will be used by it
|
|
32
|
+
*/
|
|
33
|
+
constructor(originalFileData: T, options?: AppendOptions);
|
|
34
|
+
/**
|
|
35
|
+
* Get original file data.
|
|
36
|
+
*
|
|
37
|
+
* @returns Original file data
|
|
38
|
+
*/
|
|
39
|
+
getOriginalFileData(): T;
|
|
40
|
+
/**
|
|
41
|
+
* Get options.
|
|
42
|
+
*/
|
|
43
|
+
getOptions(): AppendOptions | undefined;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Parse request data, separating normal data and file data from request data.
|
|
47
|
+
*
|
|
48
|
+
* @param [requestData] Request data to parse
|
|
49
|
+
* @returns Object containing normal data (data) and file data (fileData), when data and fileData are empty objects, it means no such data exists
|
|
50
|
+
*/
|
|
51
|
+
export declare function parseRequestData(requestData?: any): {
|
|
52
|
+
data: any;
|
|
53
|
+
fileData: any;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Prepare parameters to be passed to the request function.
|
|
57
|
+
*/
|
|
58
|
+
export declare function prepare(requestConfig: RequestConfig, requestData: any): RequestFunctionParams;
|
|
59
|
+
/**
|
|
60
|
+
* Execute async function queue sequentially
|
|
61
|
+
* @param fns
|
|
62
|
+
* @param results
|
|
63
|
+
* @returns
|
|
64
|
+
*/
|
|
65
|
+
export declare const asyncFnArrayOrderRun: <T = any>(fns: (() => Promise<T>)[], results?: T[]) => Promise<T[]>;
|