@moccona/apicodegen 0.1.0 → 0.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/README.md +230 -115
- package/bin/cli.cjs +12 -12
- package/npm/index.cjs +1256 -729
- package/npm/index.cjs.map +1 -1
- package/npm/index.d.cts +124 -50
- package/npm/index.d.cts.map +1 -1
- package/npm/index.d.mts +124 -50
- package/npm/index.d.mts.map +1 -1
- package/npm/index.mjs +1254 -729
- package/npm/index.mjs.map +1 -1
- package/npm/vite/index.d.mts +11 -0
- package/npm/vite/index.d.mts.map +1 -1
- package/npm/vite/index.mjs +1074 -535
- package/npm/vite/index.mjs.map +1 -1
- package/package.json +6 -3
package/npm/index.d.cts
CHANGED
|
@@ -74,8 +74,8 @@ interface ArrayTypeSchemaObject {
|
|
|
74
74
|
}
|
|
75
75
|
type SchemaObject = SingleTypeSchemaObject | ArrayTypeSchemaObject;
|
|
76
76
|
type ParameterObject = {
|
|
77
|
-
name: string;
|
|
78
|
-
in
|
|
77
|
+
name: string; /** Where the parameter is sent. A missing `in` is treated as a body parameter. */
|
|
78
|
+
in?: keyof typeof ParameterIn;
|
|
79
79
|
schema?: SchemaObject;
|
|
80
80
|
required?: boolean;
|
|
81
81
|
description?: string;
|
|
@@ -84,14 +84,18 @@ type ParameterObject = {
|
|
|
84
84
|
};
|
|
85
85
|
declare enum MediaTypes {
|
|
86
86
|
JSON = "application/json",
|
|
87
|
-
EVENT_STREAM = "text/event-stream",
|
|
88
87
|
TEXT = "text",
|
|
89
88
|
IMAGE = "image",
|
|
90
89
|
AUDIO = "audio",
|
|
91
90
|
VIDEO = "video"
|
|
92
91
|
}
|
|
93
92
|
type MediaTypeObject = {
|
|
94
|
-
|
|
93
|
+
/**
|
|
94
|
+
* Media type of the payload, e.g. `application/json`,
|
|
95
|
+
* `multipart/form-data`. Known types keep autocomplete, any other media
|
|
96
|
+
* type is accepted.
|
|
97
|
+
*/
|
|
98
|
+
type: MediaTypes | `${MediaTypes}` | (string & {});
|
|
95
99
|
schema?: SchemaObject;
|
|
96
100
|
};
|
|
97
101
|
type ResponsesObject = Record<string, MediaTypeObject[]>;
|
|
@@ -155,6 +159,16 @@ interface ProviderInitResult {
|
|
|
155
159
|
}
|
|
156
160
|
//#endregion
|
|
157
161
|
//#region src/core/base/Adaptor.d.ts
|
|
162
|
+
/**
|
|
163
|
+
* Body shape used to encode the request payload.
|
|
164
|
+
*
|
|
165
|
+
* - `json` — `application/json` (or unknown textual type): serialise via `JSON.stringify`.
|
|
166
|
+
* - `form-data` — `multipart/form-data` (or any request containing files): build `FormData`.
|
|
167
|
+
* - `urlencoded` — `application/x-www-form-urlencoded`: build `URLSearchParams`.
|
|
168
|
+
* - `binary` — single binary/blob parameter: pass the value directly.
|
|
169
|
+
* - `none` — no body.
|
|
170
|
+
*/
|
|
171
|
+
type BodyKind = 'json' | 'form-data' | 'urlencoded' | 'binary' | 'none';
|
|
158
172
|
/**
|
|
159
173
|
* Base adapter for tool
|
|
160
174
|
* This abstract class serves as the foundation for implementing adapters for different code generation tools
|
|
@@ -188,12 +202,12 @@ declare abstract class Adapter {
|
|
|
188
202
|
* @param {MediaTypeObject | undefined} requestBody - The request body payload (if applicable)
|
|
189
203
|
* @param {MediaTypeObject | undefined} response - The expected response format (if applicable)
|
|
190
204
|
* @param {Adapter} adapter - An instance of the adapter being used
|
|
191
|
-
* @param {
|
|
205
|
+
* @param {BodyKind} bodyKind - How the request body should be encoded
|
|
206
|
+
* @param {string | undefined} bodyContentType - The Content-Type header to set (undefined means "let the runtime decide", e.g. for multipart with boundary)
|
|
192
207
|
* @param {boolean} useJSONResponse - Flag indicating whether the response should be parsed as JSON
|
|
193
|
-
* @param {boolean} isEventStream - Flag indicating whether the response is a text/event-stream (SSE) stream; when true, the adapter must return the raw response without parsing
|
|
194
208
|
* @returns {Statement[]} An array of TypeScript AST statements representing the generated code
|
|
195
209
|
*/
|
|
196
|
-
abstract client(uri: string, method: string, parameters: ParameterObject[], requestBody: MediaTypeObject | undefined, response: MediaTypeObject | undefined, adapter: Adapter,
|
|
210
|
+
abstract client(uri: string, method: string, parameters: ParameterObject[], requestBody: MediaTypeObject | undefined, response: MediaTypeObject | undefined, adapter: Adapter, bodyKind: BodyKind, bodyContentType: string | undefined, useJSONResponse: boolean): Statement[];
|
|
197
211
|
}
|
|
198
212
|
//#endregion
|
|
199
213
|
//#region src/core/base/Base.d.ts
|
|
@@ -232,13 +246,27 @@ declare abstract class Base {
|
|
|
232
246
|
* @param [operationId] - Unique identifier for the operation.
|
|
233
247
|
* @returns - The generated function name.
|
|
234
248
|
*/
|
|
235
|
-
static pathToFnName(path: string, method?: string,
|
|
249
|
+
static pathToFnName(path: string, method?: string, operationId?: string): string;
|
|
236
250
|
/**
|
|
237
251
|
* Normalizes a string by replacing special characters and avoiding TypeScript keywords.
|
|
238
252
|
* @param text - Input text to normalize.
|
|
239
253
|
* @returns - The normalized string.
|
|
240
254
|
*/
|
|
241
255
|
static normalize(text: string): string;
|
|
256
|
+
/**
|
|
257
|
+
* Map a request body media type to a stable function-name suffix.
|
|
258
|
+
*
|
|
259
|
+
* Used to disambiguate sibling operations sharing the same path+method
|
|
260
|
+
* but different request body media types. The result is appended (in
|
|
261
|
+
* upperCamelCase) to the operation's base function name.
|
|
262
|
+
*
|
|
263
|
+
* Known types are mapped to short, human-readable names. Unknown types
|
|
264
|
+
* fall back to `camelCase(normalize(<sub-type>))`.
|
|
265
|
+
*
|
|
266
|
+
* @param mediaType - The OpenAPI media type (e.g. `application/json`).
|
|
267
|
+
* @returns - The suffix without leading underscore, or empty string.
|
|
268
|
+
*/
|
|
269
|
+
static mediaTypeToSuffix(mediaType: string): string;
|
|
242
270
|
/**
|
|
243
271
|
* Capitalizes the first character of a string.
|
|
244
272
|
* @param text - Input string.
|
|
@@ -257,10 +285,44 @@ declare abstract class Base {
|
|
|
257
285
|
* @returns - UpperCamelCase string.
|
|
258
286
|
*/
|
|
259
287
|
static upperCamelCase(text: string): string;
|
|
288
|
+
/**
|
|
289
|
+
* Classify a spec location string into a transport + source pair.
|
|
290
|
+
*
|
|
291
|
+
* Returns:
|
|
292
|
+
* - `{ transport: 'file', source }` when `input` looks like a local
|
|
293
|
+
* filesystem path (`file://...`, POSIX absolute, Windows absolute).
|
|
294
|
+
* - `{ transport: 'http', source }` for `http(s)://...` URLs.
|
|
295
|
+
*
|
|
296
|
+
* Relative paths are treated as `http` so that callers (CLI / Vite
|
|
297
|
+
* plugin) must resolve them against cwd first. This makes intent
|
|
298
|
+
* explicit and avoids accidentally reading from process.cwd().
|
|
299
|
+
*/
|
|
300
|
+
static resolveSpecURL(input: string): {
|
|
301
|
+
transport: 'file' | 'http';
|
|
302
|
+
source: string;
|
|
303
|
+
};
|
|
304
|
+
/**
|
|
305
|
+
* Read and parse a local OpenAPI document from the filesystem.
|
|
306
|
+
*
|
|
307
|
+
* @param filePath - Absolute filesystem path to the spec.
|
|
308
|
+
* @returns - A promise resolving to the parsed document.
|
|
309
|
+
*/
|
|
310
|
+
private static readLocalDoc;
|
|
260
311
|
/**
|
|
261
312
|
* Fetches documentation from a given URL.
|
|
262
|
-
*
|
|
263
|
-
*
|
|
313
|
+
*
|
|
314
|
+
* Supports three transport modes:
|
|
315
|
+
* - `file://...` URLs → read from filesystem (parsed as JSON)
|
|
316
|
+
* - absolute filesystem paths → read from filesystem (parsed as JSON)
|
|
317
|
+
* - `http(s)://...` URLs (and unrecognised inputs like relative paths)
|
|
318
|
+
* → fetched via undici (existing behavior)
|
|
319
|
+
*
|
|
320
|
+
* Callers should pass an already-resolved absolute path or URL. Relative
|
|
321
|
+
* paths fall through to undici by design — CLI / Vite plugin should
|
|
322
|
+
* resolve them against cwd first.
|
|
323
|
+
*
|
|
324
|
+
* @param url - The URL or filesystem path to fetch the documentation from.
|
|
325
|
+
* @param requestInit - Additional request parameters (only used for http(s)).
|
|
264
326
|
* @returns - A promise resolving to the fetched documentation data.
|
|
265
327
|
*/
|
|
266
328
|
static fetchDoc<T = unknown>(url: string, requestInit?: FetchDocRequestInit): Promise<T>;
|
|
@@ -386,7 +448,7 @@ declare abstract class Provider implements ProviderInitResult, ProviderInitOptio
|
|
|
386
448
|
//#region src/core/client/axios.d.ts
|
|
387
449
|
/**
|
|
388
450
|
* Adapter class implementing support for generating code that makes use of the Axios HTTP client library.
|
|
389
|
-
* This
|
|
451
|
+
* This adapter defines custom behavior and field mappings specific to the Axios client.
|
|
390
452
|
*/
|
|
391
453
|
declare class AxiosAdapter extends Adapter {
|
|
392
454
|
/**
|
|
@@ -410,19 +472,11 @@ declare class AxiosAdapter extends Adapter {
|
|
|
410
472
|
*/
|
|
411
473
|
readonly name = "axios";
|
|
412
474
|
/**
|
|
413
|
-
*
|
|
414
|
-
*
|
|
415
|
-
* @
|
|
416
|
-
* @param parameters - Array of parameters to include in the request
|
|
417
|
-
* @param requestBody - The request body media type definition
|
|
418
|
-
* @param response - The response media type definition
|
|
419
|
-
* @param adapter - The adapter instance
|
|
420
|
-
* @param shouldUseFormData - Flag to use FormData for the request body
|
|
421
|
-
* @param shouldUseJSONResponse - Unused by AxiosAdapter; present to align with the abstract signature so positional args bind correctly
|
|
422
|
-
* @param isEventStream - Flag indicating a text/event-stream response; when true the raw AxiosResponse is returned without JSON parsing
|
|
423
|
-
* @return - An array of generated TypeScript statements
|
|
475
|
+
* Method that should generate and return the client-specific configuration statements.
|
|
476
|
+
*
|
|
477
|
+
* @returns {Statement[]} An array of TypeScript statements that define the client configuration.
|
|
424
478
|
*/
|
|
425
|
-
client(uri: string, method: string, parameters: ParameterObject[], requestBody: MediaTypeObject | undefined, response: MediaTypeObject | undefined, adapter: Adapter,
|
|
479
|
+
client(uri: string, method: string, parameters: ParameterObject[], requestBody: MediaTypeObject | undefined, response: MediaTypeObject | undefined, adapter: Adapter, bodyKind: BodyKind, bodyContentType: string | undefined, _shouldUseJSONResponse: boolean): Statement[];
|
|
426
480
|
}
|
|
427
481
|
//#endregion
|
|
428
482
|
//#region src/core/client/fetch.d.ts
|
|
@@ -444,12 +498,12 @@ declare class FetchAdapter extends Adapter {
|
|
|
444
498
|
* @param requestBody - The request body media type definition
|
|
445
499
|
* @param response - The response media type definition
|
|
446
500
|
* @param adapter - The adapter instance
|
|
447
|
-
* @param
|
|
501
|
+
* @param bodyKind - How the body should be encoded (json / form-data / urlencoded / binary / none)
|
|
502
|
+
* @param bodyContentType - Content-Type header to inject (undefined means "let runtime decide", e.g. multipart boundary)
|
|
448
503
|
* @param shouldUseJSONResponse - Flag to use JSON parsing for the response
|
|
449
|
-
* @param isEventStream - Flag indicating a text/event-stream response; when true the raw Response is returned unparsed
|
|
450
504
|
* @return - An array of generated TypeScript statements
|
|
451
505
|
*/
|
|
452
|
-
client(uri: string, method: string, parameters: ParameterObject[], requestBody: MediaTypeObject | undefined, response: MediaTypeObject | undefined, adapter: Adapter,
|
|
506
|
+
client(uri: string, method: string, parameters: ParameterObject[], requestBody: MediaTypeObject | undefined, response: MediaTypeObject | undefined, adapter: Adapter, bodyKind: BodyKind, bodyContentType: string | undefined, shouldUseJSONResponse: boolean): Statement[];
|
|
453
507
|
}
|
|
454
508
|
//#endregion
|
|
455
509
|
//#region src/core/config.d.ts
|
|
@@ -502,10 +556,23 @@ interface ResolvedConfig extends ApicodegenConfig {
|
|
|
502
556
|
/** Config name for logging */
|
|
503
557
|
name: string;
|
|
504
558
|
}
|
|
559
|
+
/**
|
|
560
|
+
* Merge multiple config sources with priority
|
|
561
|
+
* Priority: defaults < env vars < config file < CLI args
|
|
562
|
+
*/
|
|
563
|
+
declare function mergeConfigs(base: ApicodegenConfig, ...sources: (Partial<ApicodegenConfig> | undefined)[]): ApicodegenConfig;
|
|
564
|
+
/**
|
|
565
|
+
* Validate config has required fields
|
|
566
|
+
*/
|
|
567
|
+
declare function validateConfig(config: Partial<ApicodegenConfig>): config is ApicodegenConfig;
|
|
505
568
|
/**
|
|
506
569
|
* Load and resolve config from multiple sources
|
|
507
570
|
*/
|
|
508
571
|
declare function loadConfig(options?: LoadConfigOptions): Promise<ResolvedConfig>;
|
|
572
|
+
/**
|
|
573
|
+
* Create CLI options from config for commander
|
|
574
|
+
*/
|
|
575
|
+
declare function configToCLIOptions(config: ApicodegenConfig): Record<string, unknown>;
|
|
509
576
|
/**
|
|
510
577
|
* Convert resolved config to provider options format
|
|
511
578
|
*/
|
|
@@ -674,37 +741,33 @@ declare class Generator {
|
|
|
674
741
|
static generateParamTags(parameters: ParameterObject[], requestBody?: MediaTypeObject): CommentObject[];
|
|
675
742
|
static toRequestBodyTypeNode(schema: SchemaObject): ParameterDeclaration;
|
|
676
743
|
static toTypeNode(schema: SchemaObject): TypeNode;
|
|
744
|
+
static deduplicateTypes(types: TypeNode[]): TypeNode[];
|
|
745
|
+
static getTypeNodeKey(type: TypeNode): string;
|
|
677
746
|
static toDeclarationNodes(parameters: ParameterObject[]): ParameterDeclaration[];
|
|
678
747
|
static toFormDataStatement(parameters: ParameterObject[], requestBody?: SchemaObject): Statement[];
|
|
748
|
+
/**
|
|
749
|
+
* Build statements that construct a `URLSearchParams` from request body
|
|
750
|
+
* fields for an `application/x-www-form-urlencoded` request.
|
|
751
|
+
*
|
|
752
|
+
* Skips `undefined` / `null` values so optional fields don't end up as
|
|
753
|
+
* the literal string `"undefined"` in the URL (fixes #8).
|
|
754
|
+
*
|
|
755
|
+
* The resulting `sp` variable is referenced by the adapter as the
|
|
756
|
+
* `body` payload.
|
|
757
|
+
*/
|
|
758
|
+
static toURLSearchParamsStatement(parameters: ParameterObject[], requestBody?: SchemaObject): Statement[];
|
|
759
|
+
/**
|
|
760
|
+
* Render `expr` as a string suitable for `FormData.append` /
|
|
761
|
+
* `URLSearchParams.append`. Object/array schemas are JSON-stringified,
|
|
762
|
+
* everything else is coerced via `String(...)`.
|
|
763
|
+
*/
|
|
764
|
+
private static toFormDataCompatibleString;
|
|
679
765
|
static bodyBlock(uri: string, method: string, parameters: ParameterObject[], requestBody: MediaTypeObject | undefined, response: MediaTypeObject | undefined, adapter: Adapter): Block;
|
|
680
766
|
static schemaToStatemets(parsedDoc: ProviderInitResult, adaptor: Adapter, options: Omit<ProviderInitOptions, 'docURL' | 'output' | 'requestOptions'>): Statement[];
|
|
681
767
|
static prettier(code: string): Promise<string>;
|
|
682
768
|
static genCode(schema: ProviderInitResult, initOptions: ProviderInitOptions, adaptor: Adapter): Promise<string>;
|
|
683
769
|
}
|
|
684
770
|
//#endregion
|
|
685
|
-
//#region src/core/logger.d.ts
|
|
686
|
-
declare const logger: {
|
|
687
|
-
success(msg: string): void;
|
|
688
|
-
error(err: unknown, verbose?: boolean): void;
|
|
689
|
-
info(msg: string): void;
|
|
690
|
-
warn(msg: string): void;
|
|
691
|
-
loading(msg: string): void;
|
|
692
|
-
watching(msg: string): void;
|
|
693
|
-
fileChange(filePath: string): void;
|
|
694
|
-
fileAdd(filePath: string): void;
|
|
695
|
-
shutdown(): void;
|
|
696
|
-
divider(width?: number): void;
|
|
697
|
-
heading(text: string, mode: string, width?: number): void;
|
|
698
|
-
item(label: string, color?: "green" | "red" | "yellow"): void;
|
|
699
|
-
summary(stats: {
|
|
700
|
-
succeeded: number;
|
|
701
|
-
failed: number;
|
|
702
|
-
endpoints: number;
|
|
703
|
-
schemas: number;
|
|
704
|
-
duration: number;
|
|
705
|
-
}): void;
|
|
706
|
-
};
|
|
707
|
-
//#endregion
|
|
708
771
|
//#region src/openapi/index.d.ts
|
|
709
772
|
declare enum OpenAPIVersion {
|
|
710
773
|
v2 = "v2",
|
|
@@ -735,6 +798,17 @@ type ApiCodeGenPluginOptions = {
|
|
|
735
798
|
importClientSource?: string; /** Enable verbose logging */
|
|
736
799
|
verbose?: boolean; /** Run type check after generation (default: true) */
|
|
737
800
|
typeCheck?: boolean;
|
|
801
|
+
/**
|
|
802
|
+
* Enable on-disk caching of generated code (default: true).
|
|
803
|
+
* Subsequent vite invocations skip codegen when neither the spec file
|
|
804
|
+
* nor the options have changed. Disable to force a fresh generation.
|
|
805
|
+
*/
|
|
806
|
+
cache?: boolean;
|
|
807
|
+
/**
|
|
808
|
+
* Directory to store cache entries (default: `node_modules/.cache/apicodegen`).
|
|
809
|
+
* Ignored when `cache === false`.
|
|
810
|
+
*/
|
|
811
|
+
cacheDir?: string;
|
|
738
812
|
};
|
|
739
813
|
/**
|
|
740
814
|
* Main Vite plugin function
|
|
@@ -760,5 +834,5 @@ type ApiCodeGenPluginOptions = {
|
|
|
760
834
|
*/
|
|
761
835
|
declare function apiCodeGenPlugin(options: ApiCodeGenPluginOptions[]): PluginOption;
|
|
762
836
|
//#endregion
|
|
763
|
-
export { Adapter, Adaptors, ApiCodeGenPluginOptions, ApicodegenConfig, ApicodegenError, ApicodegenErrorContext, ArraySchemaType, ArrayTypeSchemaObject, AxiosAdapter, Base, CodeGenResult, Colors, CommentObject, Comments, ConfigAdaptor, EnumSchemaObject, ErrorCode, ErrorCodes, FetchAdapter, FetchDocRequestInit, Generator, HttpMethods, JSONValue, LoadConfigOptions, MediaTypeObject, MediaTypes, NonArraySchemaType, OpenAPIProvider, OpenAPIVersion, OperationObject, ParameterIn, ParameterObject, PathObject, PathsObject, Provider, ProviderInitOptions, ProviderInitResult, ReferenceObject, RequestBodyObject, ResolvedConfig, ResponsesObject, SchemaFormatType, SchemaObject, SchemaType, SingleTypeSchemaObject, SuccessHttpStatusCode, apiCodeGenPlugin, codeGen, createErrors, formatError, isApicodegenError, loadConfig,
|
|
837
|
+
export { Adapter, Adaptors, ApiCodeGenPluginOptions, ApicodegenConfig, ApicodegenError, ApicodegenErrorContext, ArraySchemaType, ArrayTypeSchemaObject, AxiosAdapter, Base, BodyKind, CodeGenResult, Colors, CommentObject, Comments, ConfigAdaptor, EnumSchemaObject, ErrorCode, ErrorCodes, FetchAdapter, FetchDocRequestInit, Generator, HttpMethods, JSONValue, LoadConfigOptions, MediaTypeObject, MediaTypes, NonArraySchemaType, OpenAPIProvider, OpenAPIVersion, OperationObject, ParameterIn, ParameterObject, PathObject, PathsObject, Provider, ProviderInitOptions, ProviderInitResult, ReferenceObject, RequestBodyObject, ResolvedConfig, ResponsesObject, SchemaFormatType, SchemaObject, SchemaType, SingleTypeSchemaObject, SuccessHttpStatusCode, apiCodeGenPlugin, codeGen, configToCLIOptions, createErrors, formatError, isApicodegenError, loadConfig, mergeConfigs, printError, toProviderOptions, validateConfig, wrapError };
|
|
764
838
|
//# sourceMappingURL=index.d.cts.map
|
package/npm/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/core/interface.ts","../src/core/base/Adaptor.ts","../src/core/base/Base.ts","../src/core/base/Provider.ts","../src/core/client/axios.ts","../src/core/client/fetch.ts","../src/core/config.ts","../src/core/errors.ts","../src/core/generator/index.ts","../src/
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/core/interface.ts","../src/core/base/Adaptor.ts","../src/core/base/Base.ts","../src/core/base/Provider.ts","../src/core/client/axios.ts","../src/core/client/fetch.ts","../src/core/config.ts","../src/core/errors.ts","../src/core/generator/index.ts","../src/openapi/index.ts","../src/vite-plugin/index.ts"],"mappings":";;;;;;;;KAGY,SAAA;EAAA,CACV,CAAA,uCAIE,SAAA,gCAC6B,SAAS;AAAA;AAAA,aAG9B,UAAA;EACX,OAAA;EACA,UAAA;EACA,SAAA;EACA,aAAA;AAAA;AAAA,aAGW,kBAAA;EACX,MAAA;EACA,MAAA;EACA,MAAA;EACA,OAAA;EACA,OAAA;EACA,IAAA;EACA,IAAA;AAAA;AAAA,aAGW,eAAA;EACX,KAAK;AAAA;AAAA,aAGM,gBAAA;EACX,MAAA;EACA,MAAA;EACA,OAAA;EACA,IAAA;EACA,MAAA;EACA,IAAA;AAAA;AAAA,aAGW,WAAA;EACX,MAAA;EACA,IAAA;EACA,KAAA;EACA,MAAA;EACA,IAAA;EACA,QAAA;AAAA;AAAA,UAGgB,eAAA;EAChB,IAAI;AAAA;AAAA,UAGY,gBAAA;EAChB,IAAA;EACA,IAAI;AAAA;AAAA,UAGY,sBAAA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cAyBY,eAAA,SAAwB,QAAA;EAC7B,KAAA,CAAM,GAAA,EAAK,SAAA,CAAU,QAAA,GAAW,kBAAA;AAAA;AAAA,UA2BvB,aAAA;EAChB,IAAA;EACA,KAAA;IACC,SAAA;IACA,OAAA;IACA,QAAA;EAAA;AAAA;AAAA,iBAIoB,OAAA,CACrB,WAAA,EAAa,mBAAA,GACX,OAAA,CAAQ,aAAA;;;KC5EC,uBAAA;2DAEX,IAAA;EAEA,IAAA,WVlBoB;EUoBpB,MAAA,WVdyC;EUgBzC,OAAA,sBVjBG;EUmBH,OAAA,WVlByC;EUoBzC,kBAAA,WVjBW;EUmBX,OAAA;EAEA,SAAA;EVpBA;;;;;EU0BA,KAAA;EVpBW;;;;EUyBX,QAAA;AAAA;;;;;;;AVlBI;AAGL;;;;AACM;AAGN;;;;;;;;;;iBU4OgB,gBAAA,CACf,OAAA,EAAS,uBAAA,KACP,YAAY"}
|
package/npm/index.d.mts
CHANGED
|
@@ -74,8 +74,8 @@ interface ArrayTypeSchemaObject {
|
|
|
74
74
|
}
|
|
75
75
|
type SchemaObject = SingleTypeSchemaObject | ArrayTypeSchemaObject;
|
|
76
76
|
type ParameterObject = {
|
|
77
|
-
name: string;
|
|
78
|
-
in
|
|
77
|
+
name: string; /** Where the parameter is sent. A missing `in` is treated as a body parameter. */
|
|
78
|
+
in?: keyof typeof ParameterIn;
|
|
79
79
|
schema?: SchemaObject;
|
|
80
80
|
required?: boolean;
|
|
81
81
|
description?: string;
|
|
@@ -84,14 +84,18 @@ type ParameterObject = {
|
|
|
84
84
|
};
|
|
85
85
|
declare enum MediaTypes {
|
|
86
86
|
JSON = "application/json",
|
|
87
|
-
EVENT_STREAM = "text/event-stream",
|
|
88
87
|
TEXT = "text",
|
|
89
88
|
IMAGE = "image",
|
|
90
89
|
AUDIO = "audio",
|
|
91
90
|
VIDEO = "video"
|
|
92
91
|
}
|
|
93
92
|
type MediaTypeObject = {
|
|
94
|
-
|
|
93
|
+
/**
|
|
94
|
+
* Media type of the payload, e.g. `application/json`,
|
|
95
|
+
* `multipart/form-data`. Known types keep autocomplete, any other media
|
|
96
|
+
* type is accepted.
|
|
97
|
+
*/
|
|
98
|
+
type: MediaTypes | `${MediaTypes}` | (string & {});
|
|
95
99
|
schema?: SchemaObject;
|
|
96
100
|
};
|
|
97
101
|
type ResponsesObject = Record<string, MediaTypeObject[]>;
|
|
@@ -155,6 +159,16 @@ interface ProviderInitResult {
|
|
|
155
159
|
}
|
|
156
160
|
//#endregion
|
|
157
161
|
//#region src/core/base/Adaptor.d.ts
|
|
162
|
+
/**
|
|
163
|
+
* Body shape used to encode the request payload.
|
|
164
|
+
*
|
|
165
|
+
* - `json` — `application/json` (or unknown textual type): serialise via `JSON.stringify`.
|
|
166
|
+
* - `form-data` — `multipart/form-data` (or any request containing files): build `FormData`.
|
|
167
|
+
* - `urlencoded` — `application/x-www-form-urlencoded`: build `URLSearchParams`.
|
|
168
|
+
* - `binary` — single binary/blob parameter: pass the value directly.
|
|
169
|
+
* - `none` — no body.
|
|
170
|
+
*/
|
|
171
|
+
type BodyKind = 'json' | 'form-data' | 'urlencoded' | 'binary' | 'none';
|
|
158
172
|
/**
|
|
159
173
|
* Base adapter for tool
|
|
160
174
|
* This abstract class serves as the foundation for implementing adapters for different code generation tools
|
|
@@ -188,12 +202,12 @@ declare abstract class Adapter {
|
|
|
188
202
|
* @param {MediaTypeObject | undefined} requestBody - The request body payload (if applicable)
|
|
189
203
|
* @param {MediaTypeObject | undefined} response - The expected response format (if applicable)
|
|
190
204
|
* @param {Adapter} adapter - An instance of the adapter being used
|
|
191
|
-
* @param {
|
|
205
|
+
* @param {BodyKind} bodyKind - How the request body should be encoded
|
|
206
|
+
* @param {string | undefined} bodyContentType - The Content-Type header to set (undefined means "let the runtime decide", e.g. for multipart with boundary)
|
|
192
207
|
* @param {boolean} useJSONResponse - Flag indicating whether the response should be parsed as JSON
|
|
193
|
-
* @param {boolean} isEventStream - Flag indicating whether the response is a text/event-stream (SSE) stream; when true, the adapter must return the raw response without parsing
|
|
194
208
|
* @returns {Statement[]} An array of TypeScript AST statements representing the generated code
|
|
195
209
|
*/
|
|
196
|
-
abstract client(uri: string, method: string, parameters: ParameterObject[], requestBody: MediaTypeObject | undefined, response: MediaTypeObject | undefined, adapter: Adapter,
|
|
210
|
+
abstract client(uri: string, method: string, parameters: ParameterObject[], requestBody: MediaTypeObject | undefined, response: MediaTypeObject | undefined, adapter: Adapter, bodyKind: BodyKind, bodyContentType: string | undefined, useJSONResponse: boolean): Statement[];
|
|
197
211
|
}
|
|
198
212
|
//#endregion
|
|
199
213
|
//#region src/core/base/Base.d.ts
|
|
@@ -232,13 +246,27 @@ declare abstract class Base {
|
|
|
232
246
|
* @param [operationId] - Unique identifier for the operation.
|
|
233
247
|
* @returns - The generated function name.
|
|
234
248
|
*/
|
|
235
|
-
static pathToFnName(path: string, method?: string,
|
|
249
|
+
static pathToFnName(path: string, method?: string, operationId?: string): string;
|
|
236
250
|
/**
|
|
237
251
|
* Normalizes a string by replacing special characters and avoiding TypeScript keywords.
|
|
238
252
|
* @param text - Input text to normalize.
|
|
239
253
|
* @returns - The normalized string.
|
|
240
254
|
*/
|
|
241
255
|
static normalize(text: string): string;
|
|
256
|
+
/**
|
|
257
|
+
* Map a request body media type to a stable function-name suffix.
|
|
258
|
+
*
|
|
259
|
+
* Used to disambiguate sibling operations sharing the same path+method
|
|
260
|
+
* but different request body media types. The result is appended (in
|
|
261
|
+
* upperCamelCase) to the operation's base function name.
|
|
262
|
+
*
|
|
263
|
+
* Known types are mapped to short, human-readable names. Unknown types
|
|
264
|
+
* fall back to `camelCase(normalize(<sub-type>))`.
|
|
265
|
+
*
|
|
266
|
+
* @param mediaType - The OpenAPI media type (e.g. `application/json`).
|
|
267
|
+
* @returns - The suffix without leading underscore, or empty string.
|
|
268
|
+
*/
|
|
269
|
+
static mediaTypeToSuffix(mediaType: string): string;
|
|
242
270
|
/**
|
|
243
271
|
* Capitalizes the first character of a string.
|
|
244
272
|
* @param text - Input string.
|
|
@@ -257,10 +285,44 @@ declare abstract class Base {
|
|
|
257
285
|
* @returns - UpperCamelCase string.
|
|
258
286
|
*/
|
|
259
287
|
static upperCamelCase(text: string): string;
|
|
288
|
+
/**
|
|
289
|
+
* Classify a spec location string into a transport + source pair.
|
|
290
|
+
*
|
|
291
|
+
* Returns:
|
|
292
|
+
* - `{ transport: 'file', source }` when `input` looks like a local
|
|
293
|
+
* filesystem path (`file://...`, POSIX absolute, Windows absolute).
|
|
294
|
+
* - `{ transport: 'http', source }` for `http(s)://...` URLs.
|
|
295
|
+
*
|
|
296
|
+
* Relative paths are treated as `http` so that callers (CLI / Vite
|
|
297
|
+
* plugin) must resolve them against cwd first. This makes intent
|
|
298
|
+
* explicit and avoids accidentally reading from process.cwd().
|
|
299
|
+
*/
|
|
300
|
+
static resolveSpecURL(input: string): {
|
|
301
|
+
transport: 'file' | 'http';
|
|
302
|
+
source: string;
|
|
303
|
+
};
|
|
304
|
+
/**
|
|
305
|
+
* Read and parse a local OpenAPI document from the filesystem.
|
|
306
|
+
*
|
|
307
|
+
* @param filePath - Absolute filesystem path to the spec.
|
|
308
|
+
* @returns - A promise resolving to the parsed document.
|
|
309
|
+
*/
|
|
310
|
+
private static readLocalDoc;
|
|
260
311
|
/**
|
|
261
312
|
* Fetches documentation from a given URL.
|
|
262
|
-
*
|
|
263
|
-
*
|
|
313
|
+
*
|
|
314
|
+
* Supports three transport modes:
|
|
315
|
+
* - `file://...` URLs → read from filesystem (parsed as JSON)
|
|
316
|
+
* - absolute filesystem paths → read from filesystem (parsed as JSON)
|
|
317
|
+
* - `http(s)://...` URLs (and unrecognised inputs like relative paths)
|
|
318
|
+
* → fetched via undici (existing behavior)
|
|
319
|
+
*
|
|
320
|
+
* Callers should pass an already-resolved absolute path or URL. Relative
|
|
321
|
+
* paths fall through to undici by design — CLI / Vite plugin should
|
|
322
|
+
* resolve them against cwd first.
|
|
323
|
+
*
|
|
324
|
+
* @param url - The URL or filesystem path to fetch the documentation from.
|
|
325
|
+
* @param requestInit - Additional request parameters (only used for http(s)).
|
|
264
326
|
* @returns - A promise resolving to the fetched documentation data.
|
|
265
327
|
*/
|
|
266
328
|
static fetchDoc<T = unknown>(url: string, requestInit?: FetchDocRequestInit): Promise<T>;
|
|
@@ -386,7 +448,7 @@ declare abstract class Provider implements ProviderInitResult, ProviderInitOptio
|
|
|
386
448
|
//#region src/core/client/axios.d.ts
|
|
387
449
|
/**
|
|
388
450
|
* Adapter class implementing support for generating code that makes use of the Axios HTTP client library.
|
|
389
|
-
* This
|
|
451
|
+
* This adapter defines custom behavior and field mappings specific to the Axios client.
|
|
390
452
|
*/
|
|
391
453
|
declare class AxiosAdapter extends Adapter {
|
|
392
454
|
/**
|
|
@@ -410,19 +472,11 @@ declare class AxiosAdapter extends Adapter {
|
|
|
410
472
|
*/
|
|
411
473
|
readonly name = "axios";
|
|
412
474
|
/**
|
|
413
|
-
*
|
|
414
|
-
*
|
|
415
|
-
* @
|
|
416
|
-
* @param parameters - Array of parameters to include in the request
|
|
417
|
-
* @param requestBody - The request body media type definition
|
|
418
|
-
* @param response - The response media type definition
|
|
419
|
-
* @param adapter - The adapter instance
|
|
420
|
-
* @param shouldUseFormData - Flag to use FormData for the request body
|
|
421
|
-
* @param shouldUseJSONResponse - Unused by AxiosAdapter; present to align with the abstract signature so positional args bind correctly
|
|
422
|
-
* @param isEventStream - Flag indicating a text/event-stream response; when true the raw AxiosResponse is returned without JSON parsing
|
|
423
|
-
* @return - An array of generated TypeScript statements
|
|
475
|
+
* Method that should generate and return the client-specific configuration statements.
|
|
476
|
+
*
|
|
477
|
+
* @returns {Statement[]} An array of TypeScript statements that define the client configuration.
|
|
424
478
|
*/
|
|
425
|
-
client(uri: string, method: string, parameters: ParameterObject[], requestBody: MediaTypeObject | undefined, response: MediaTypeObject | undefined, adapter: Adapter,
|
|
479
|
+
client(uri: string, method: string, parameters: ParameterObject[], requestBody: MediaTypeObject | undefined, response: MediaTypeObject | undefined, adapter: Adapter, bodyKind: BodyKind, bodyContentType: string | undefined, _shouldUseJSONResponse: boolean): Statement[];
|
|
426
480
|
}
|
|
427
481
|
//#endregion
|
|
428
482
|
//#region src/core/client/fetch.d.ts
|
|
@@ -444,12 +498,12 @@ declare class FetchAdapter extends Adapter {
|
|
|
444
498
|
* @param requestBody - The request body media type definition
|
|
445
499
|
* @param response - The response media type definition
|
|
446
500
|
* @param adapter - The adapter instance
|
|
447
|
-
* @param
|
|
501
|
+
* @param bodyKind - How the body should be encoded (json / form-data / urlencoded / binary / none)
|
|
502
|
+
* @param bodyContentType - Content-Type header to inject (undefined means "let runtime decide", e.g. multipart boundary)
|
|
448
503
|
* @param shouldUseJSONResponse - Flag to use JSON parsing for the response
|
|
449
|
-
* @param isEventStream - Flag indicating a text/event-stream response; when true the raw Response is returned unparsed
|
|
450
504
|
* @return - An array of generated TypeScript statements
|
|
451
505
|
*/
|
|
452
|
-
client(uri: string, method: string, parameters: ParameterObject[], requestBody: MediaTypeObject | undefined, response: MediaTypeObject | undefined, adapter: Adapter,
|
|
506
|
+
client(uri: string, method: string, parameters: ParameterObject[], requestBody: MediaTypeObject | undefined, response: MediaTypeObject | undefined, adapter: Adapter, bodyKind: BodyKind, bodyContentType: string | undefined, shouldUseJSONResponse: boolean): Statement[];
|
|
453
507
|
}
|
|
454
508
|
//#endregion
|
|
455
509
|
//#region src/core/config.d.ts
|
|
@@ -502,10 +556,23 @@ interface ResolvedConfig extends ApicodegenConfig {
|
|
|
502
556
|
/** Config name for logging */
|
|
503
557
|
name: string;
|
|
504
558
|
}
|
|
559
|
+
/**
|
|
560
|
+
* Merge multiple config sources with priority
|
|
561
|
+
* Priority: defaults < env vars < config file < CLI args
|
|
562
|
+
*/
|
|
563
|
+
declare function mergeConfigs(base: ApicodegenConfig, ...sources: (Partial<ApicodegenConfig> | undefined)[]): ApicodegenConfig;
|
|
564
|
+
/**
|
|
565
|
+
* Validate config has required fields
|
|
566
|
+
*/
|
|
567
|
+
declare function validateConfig(config: Partial<ApicodegenConfig>): config is ApicodegenConfig;
|
|
505
568
|
/**
|
|
506
569
|
* Load and resolve config from multiple sources
|
|
507
570
|
*/
|
|
508
571
|
declare function loadConfig(options?: LoadConfigOptions): Promise<ResolvedConfig>;
|
|
572
|
+
/**
|
|
573
|
+
* Create CLI options from config for commander
|
|
574
|
+
*/
|
|
575
|
+
declare function configToCLIOptions(config: ApicodegenConfig): Record<string, unknown>;
|
|
509
576
|
/**
|
|
510
577
|
* Convert resolved config to provider options format
|
|
511
578
|
*/
|
|
@@ -674,37 +741,33 @@ declare class Generator {
|
|
|
674
741
|
static generateParamTags(parameters: ParameterObject[], requestBody?: MediaTypeObject): CommentObject[];
|
|
675
742
|
static toRequestBodyTypeNode(schema: SchemaObject): ParameterDeclaration;
|
|
676
743
|
static toTypeNode(schema: SchemaObject): TypeNode;
|
|
744
|
+
static deduplicateTypes(types: TypeNode[]): TypeNode[];
|
|
745
|
+
static getTypeNodeKey(type: TypeNode): string;
|
|
677
746
|
static toDeclarationNodes(parameters: ParameterObject[]): ParameterDeclaration[];
|
|
678
747
|
static toFormDataStatement(parameters: ParameterObject[], requestBody?: SchemaObject): Statement[];
|
|
748
|
+
/**
|
|
749
|
+
* Build statements that construct a `URLSearchParams` from request body
|
|
750
|
+
* fields for an `application/x-www-form-urlencoded` request.
|
|
751
|
+
*
|
|
752
|
+
* Skips `undefined` / `null` values so optional fields don't end up as
|
|
753
|
+
* the literal string `"undefined"` in the URL (fixes #8).
|
|
754
|
+
*
|
|
755
|
+
* The resulting `sp` variable is referenced by the adapter as the
|
|
756
|
+
* `body` payload.
|
|
757
|
+
*/
|
|
758
|
+
static toURLSearchParamsStatement(parameters: ParameterObject[], requestBody?: SchemaObject): Statement[];
|
|
759
|
+
/**
|
|
760
|
+
* Render `expr` as a string suitable for `FormData.append` /
|
|
761
|
+
* `URLSearchParams.append`. Object/array schemas are JSON-stringified,
|
|
762
|
+
* everything else is coerced via `String(...)`.
|
|
763
|
+
*/
|
|
764
|
+
private static toFormDataCompatibleString;
|
|
679
765
|
static bodyBlock(uri: string, method: string, parameters: ParameterObject[], requestBody: MediaTypeObject | undefined, response: MediaTypeObject | undefined, adapter: Adapter): Block;
|
|
680
766
|
static schemaToStatemets(parsedDoc: ProviderInitResult, adaptor: Adapter, options: Omit<ProviderInitOptions, 'docURL' | 'output' | 'requestOptions'>): Statement[];
|
|
681
767
|
static prettier(code: string): Promise<string>;
|
|
682
768
|
static genCode(schema: ProviderInitResult, initOptions: ProviderInitOptions, adaptor: Adapter): Promise<string>;
|
|
683
769
|
}
|
|
684
770
|
//#endregion
|
|
685
|
-
//#region src/core/logger.d.ts
|
|
686
|
-
declare const logger: {
|
|
687
|
-
success(msg: string): void;
|
|
688
|
-
error(err: unknown, verbose?: boolean): void;
|
|
689
|
-
info(msg: string): void;
|
|
690
|
-
warn(msg: string): void;
|
|
691
|
-
loading(msg: string): void;
|
|
692
|
-
watching(msg: string): void;
|
|
693
|
-
fileChange(filePath: string): void;
|
|
694
|
-
fileAdd(filePath: string): void;
|
|
695
|
-
shutdown(): void;
|
|
696
|
-
divider(width?: number): void;
|
|
697
|
-
heading(text: string, mode: string, width?: number): void;
|
|
698
|
-
item(label: string, color?: "green" | "red" | "yellow"): void;
|
|
699
|
-
summary(stats: {
|
|
700
|
-
succeeded: number;
|
|
701
|
-
failed: number;
|
|
702
|
-
endpoints: number;
|
|
703
|
-
schemas: number;
|
|
704
|
-
duration: number;
|
|
705
|
-
}): void;
|
|
706
|
-
};
|
|
707
|
-
//#endregion
|
|
708
771
|
//#region src/openapi/index.d.ts
|
|
709
772
|
declare enum OpenAPIVersion {
|
|
710
773
|
v2 = "v2",
|
|
@@ -735,6 +798,17 @@ type ApiCodeGenPluginOptions = {
|
|
|
735
798
|
importClientSource?: string; /** Enable verbose logging */
|
|
736
799
|
verbose?: boolean; /** Run type check after generation (default: true) */
|
|
737
800
|
typeCheck?: boolean;
|
|
801
|
+
/**
|
|
802
|
+
* Enable on-disk caching of generated code (default: true).
|
|
803
|
+
* Subsequent vite invocations skip codegen when neither the spec file
|
|
804
|
+
* nor the options have changed. Disable to force a fresh generation.
|
|
805
|
+
*/
|
|
806
|
+
cache?: boolean;
|
|
807
|
+
/**
|
|
808
|
+
* Directory to store cache entries (default: `node_modules/.cache/apicodegen`).
|
|
809
|
+
* Ignored when `cache === false`.
|
|
810
|
+
*/
|
|
811
|
+
cacheDir?: string;
|
|
738
812
|
};
|
|
739
813
|
/**
|
|
740
814
|
* Main Vite plugin function
|
|
@@ -760,5 +834,5 @@ type ApiCodeGenPluginOptions = {
|
|
|
760
834
|
*/
|
|
761
835
|
declare function apiCodeGenPlugin(options: ApiCodeGenPluginOptions[]): PluginOption;
|
|
762
836
|
//#endregion
|
|
763
|
-
export { Adapter, Adaptors, ApiCodeGenPluginOptions, ApicodegenConfig, ApicodegenError, ApicodegenErrorContext, ArraySchemaType, ArrayTypeSchemaObject, AxiosAdapter, Base, CodeGenResult, Colors, CommentObject, Comments, ConfigAdaptor, EnumSchemaObject, ErrorCode, ErrorCodes, FetchAdapter, FetchDocRequestInit, Generator, HttpMethods, JSONValue, LoadConfigOptions, MediaTypeObject, MediaTypes, NonArraySchemaType, OpenAPIProvider, OpenAPIVersion, OperationObject, ParameterIn, ParameterObject, PathObject, PathsObject, Provider, ProviderInitOptions, ProviderInitResult, ReferenceObject, RequestBodyObject, ResolvedConfig, ResponsesObject, SchemaFormatType, SchemaObject, SchemaType, SingleTypeSchemaObject, SuccessHttpStatusCode, apiCodeGenPlugin, codeGen, createErrors, formatError, isApicodegenError, loadConfig,
|
|
837
|
+
export { Adapter, Adaptors, ApiCodeGenPluginOptions, ApicodegenConfig, ApicodegenError, ApicodegenErrorContext, ArraySchemaType, ArrayTypeSchemaObject, AxiosAdapter, Base, BodyKind, CodeGenResult, Colors, CommentObject, Comments, ConfigAdaptor, EnumSchemaObject, ErrorCode, ErrorCodes, FetchAdapter, FetchDocRequestInit, Generator, HttpMethods, JSONValue, LoadConfigOptions, MediaTypeObject, MediaTypes, NonArraySchemaType, OpenAPIProvider, OpenAPIVersion, OperationObject, ParameterIn, ParameterObject, PathObject, PathsObject, Provider, ProviderInitOptions, ProviderInitResult, ReferenceObject, RequestBodyObject, ResolvedConfig, ResponsesObject, SchemaFormatType, SchemaObject, SchemaType, SingleTypeSchemaObject, SuccessHttpStatusCode, apiCodeGenPlugin, codeGen, configToCLIOptions, createErrors, formatError, isApicodegenError, loadConfig, mergeConfigs, printError, toProviderOptions, validateConfig, wrapError };
|
|
764
838
|
//# sourceMappingURL=index.d.mts.map
|