swagger-typescript-api 13.1.0 → 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/dist/lib.d.cts CHANGED
@@ -1,3 +1,1638 @@
1
- export { generateApi } from './_tsup-dts-rollup.cjs';
2
- export { constants } from './_tsup-dts-rollup.cjs';
3
- export { generateTemplates } from './_tsup-dts-rollup.cjs';
1
+ import { OpenAPI } from "openapi-types";
2
+ import * as typescript$1 from "typescript";
3
+ import * as typescript from "typescript";
4
+ import * as lodash19 from "lodash";
5
+ import * as lodash14 from "lodash";
6
+ import lodash from "lodash";
7
+ import * as swagger_schema_official18 from "swagger-schema-official";
8
+ import * as eta20 from "eta";
9
+
10
+ //#region rolldown:runtime
11
+ //#endregion
12
+ //#region src/schema-components-map.d.ts
13
+ declare class SchemaComponentsMap {
14
+ _data: SchemaComponent[];
15
+ config: CodeGenConfig;
16
+ constructor(config: CodeGenConfig);
17
+ clear(): void;
18
+ createRef: (paths: string[]) => string;
19
+ parseRef: (ref: string) => string[];
20
+ createComponent($ref: string, rawTypeData: SchemaComponent["rawTypeData"]): SchemaComponent;
21
+ getComponents(): SchemaComponent[];
22
+ filter(...componentNames: (string[] | string)[]): SchemaComponent[];
23
+ get($ref: string): SchemaComponent | null;
24
+ enumsFirst(): void;
25
+ }
26
+
27
+ //#endregion
28
+ //#region src/util/file-system.d.ts
29
+ declare class FileSystem {
30
+ getFileContent: (path: string) => string;
31
+ readDir: (path: string) => string[];
32
+ pathIsDir: (path: string) => boolean;
33
+ cropExtension: (fileName: string) => string;
34
+ removeDir: (path: string) => void;
35
+ createDir: (path: string) => void;
36
+ cleanDir: (path: string) => void;
37
+ pathIsExist: (path: string) => boolean;
38
+ createFile: ({
39
+ path: path_,
40
+ fileName,
41
+ content,
42
+ withPrefix
43
+ }: {
44
+ path: any;
45
+ fileName: any;
46
+ content: any;
47
+ withPrefix: any;
48
+ }) => void;
49
+ }
50
+
51
+ //#endregion
52
+ //#region src/util/request.d.ts
53
+ declare class Request {
54
+ config: CodeGenConfig;
55
+ constructor(config: CodeGenConfig);
56
+ download({
57
+ url,
58
+ authToken,
59
+ ...options
60
+ }: {
61
+ url: string;
62
+ authToken?: string;
63
+ options?: Partial<RequestInit>;
64
+ }): Promise<string>;
65
+ }
66
+
67
+ //#endregion
68
+ //#region src/swagger-schema-resolver.d.ts
69
+ declare class SwaggerSchemaResolver {
70
+ config: CodeGenConfig;
71
+ fileSystem: FileSystem;
72
+ request: Request;
73
+ constructor(config: CodeGenConfig, fileSystem: FileSystem);
74
+ create(): Promise<{
75
+ usageSchema: OpenAPI.Document;
76
+ originalSchema: OpenAPI.Document;
77
+ }>;
78
+ convertSwaggerObject(swaggerSchema: OpenAPI.Document, converterOptions: {
79
+ patch?: boolean;
80
+ }): Promise<{
81
+ usageSchema: OpenAPI.Document;
82
+ originalSchema: OpenAPI.Document;
83
+ }>;
84
+ getSwaggerSchemaByPath: (pathToSwagger: string) => string;
85
+ fetchSwaggerSchemaFile(pathToSwagger: string, urlToSwagger: string, authToken?: string): Promise<string>;
86
+ processSwaggerSchemaFile(file: string): any;
87
+ fixSwaggerSchema({
88
+ usageSchema,
89
+ originalSchema
90
+ }: {
91
+ usageSchema: any;
92
+ originalSchema: any;
93
+ }): void;
94
+ }
95
+
96
+ //#endregion
97
+ //#region src/schema-walker.d.ts
98
+ declare class SchemaWalker {
99
+ config: CodeGenConfig;
100
+ swaggerSchemaResolver: SwaggerSchemaResolver;
101
+ schemas: Map<string, OpenAPI.Document<{}>>;
102
+ caches: Map<string, OpenAPI.Document<{}>>;
103
+ constructor(config: CodeGenConfig, swaggerSchemaResolver: SwaggerSchemaResolver);
104
+ addSchema: (name: string, schema: OpenAPI.Document) => void;
105
+ _isLocalRef: (ref: string) => boolean;
106
+ _isRemoteRef: (ref: string) => boolean;
107
+ _getRefDataFromSchema: (schema: Record<string, unknown>, ref: string) => any;
108
+ }
109
+
110
+ //#endregion
111
+ //#region src/type-name-formatter.d.ts
112
+ type FormattingSchemaType = "enum-key" | "type-name";
113
+ declare class TypeNameFormatter {
114
+ formattedModelNamesMap: Map<string, string>;
115
+ config: CodeGenConfig;
116
+ constructor(config: CodeGenConfig);
117
+ format: (name: string, options?: {
118
+ type?: FormattingSchemaType;
119
+ }) => string | undefined;
120
+ isValidName: (name: string) => boolean;
121
+ fixModelName: (name: string, options: {
122
+ type?: FormattingSchemaType;
123
+ }) => string;
124
+ }
125
+
126
+ //#endregion
127
+ //#region src/schema-parser/schema-utils.d.ts
128
+ declare class SchemaUtils {
129
+ config: CodeGenConfig;
130
+ schemaComponentsMap: SchemaComponentsMap;
131
+ typeNameFormatter: TypeNameFormatter;
132
+ schemaWalker: SchemaWalker;
133
+ constructor({
134
+ config,
135
+ schemaComponentsMap,
136
+ typeNameFormatter,
137
+ schemaWalker
138
+ }: {
139
+ config: any;
140
+ schemaComponentsMap: any;
141
+ typeNameFormatter: any;
142
+ schemaWalker: any;
143
+ });
144
+ getRequiredProperties: (schema: any) => unknown[];
145
+ isRefSchema: (schema: any) => boolean;
146
+ getEnumNames: (schema: any) => any;
147
+ getSchemaRefType: (schema: any) => SchemaComponent | null;
148
+ isPropertyRequired: (name: any, propertySchema: any, rootSchema: any) => any;
149
+ isNullMissingInType: (schema: any, type: any) => any;
150
+ safeAddNullToType: (schema: any, type: any) => any;
151
+ getSchemaPrimitiveType: (rawSchema: any) => string | null | undefined;
152
+ checkAndAddRequiredKeys: (schema: any, resultType: any) => any;
153
+ makeAddRequiredToChildSchema: (parentSchema: any, childSchema: any) => any;
154
+ filterSchemaContents: (contents: any, filterFn: any) => unknown[];
155
+ resolveTypeName: (typeName: any, {
156
+ suffixes,
157
+ resolver,
158
+ prefixes,
159
+ shouldReserve
160
+ }: {
161
+ suffixes: any;
162
+ resolver: any;
163
+ prefixes: any;
164
+ shouldReserve?: boolean | undefined;
165
+ }) => string | null;
166
+ getComplexType: (schema: any) => "oneOf" | "anyOf" | "allOf" | "not" | "__unknown";
167
+ getInternalSchemaType: (schema: any) => "object" | "array" | "enum" | "primitive" | "complex" | "discriminator";
168
+ getSchemaType: (schema: any) => any;
169
+ buildTypeNameFromPath: (schemaPath: any) => Capitalize<string> | null;
170
+ isConstantSchema(schema: any): boolean;
171
+ formatJsValue: (value: any) => string;
172
+ }
173
+
174
+ //#endregion
175
+ //#region src/schema-parser/schema-formatters.d.ts
176
+ declare class SchemaFormatters {
177
+ config: CodeGenConfig;
178
+ templatesWorker: TemplatesWorker;
179
+ schemaUtils: SchemaUtils;
180
+ constructor(schemaParser: SchemaParser | SchemaParserFabric);
181
+ base: {
182
+ enum: (parsedSchema: any) => any;
183
+ object: (parsedSchema: any) => any;
184
+ primitive: (parsedSchema: any) => any;
185
+ };
186
+ inline: {
187
+ enum: (parsedSchema: any) => any;
188
+ object: (parsedSchema: any) => any;
189
+ };
190
+ formatSchema: (parsedSchema: Record<string, any>, formatType?: "base" | "inline") => any;
191
+ formatDescription: (description: any, inline: any) => any;
192
+ formatObjectContent: (content: any) => string;
193
+ }
194
+
195
+ //#endregion
196
+ //#region src/schema-parser/schema-parser-fabric.d.ts
197
+ declare class SchemaParserFabric {
198
+ config: CodeGenConfig;
199
+ schemaComponentsMap: SchemaComponentsMap;
200
+ typeNameFormatter: TypeNameFormatter;
201
+ schemaFormatters: SchemaFormatters;
202
+ templatesWorker: TemplatesWorker;
203
+ schemaUtils: SchemaUtils;
204
+ schemaWalker: SchemaWalker;
205
+ constructor(config: CodeGenConfig, templatesWorker: TemplatesWorker, schemaComponentsMap: SchemaComponentsMap, typeNameFormatter: TypeNameFormatter, schemaWalker: SchemaWalker);
206
+ createSchemaParser: ({
207
+ schema,
208
+ typeName,
209
+ schemaPath
210
+ }: {
211
+ schema: any;
212
+ typeName: any;
213
+ schemaPath: any;
214
+ }) => SchemaParser;
215
+ createSchema: ({
216
+ content,
217
+ linkedSchema,
218
+ linkedComponent,
219
+ schemaPath,
220
+ ...otherSchemaProps
221
+ }: {
222
+ [x: string]: any;
223
+ content: any;
224
+ linkedSchema?: {} | undefined;
225
+ linkedComponent: any;
226
+ schemaPath: any;
227
+ }) => any;
228
+ createParsedComponent: ({
229
+ typeName,
230
+ schema,
231
+ schemaPath
232
+ }: {
233
+ typeName: any;
234
+ schema: any;
235
+ schemaPath: any;
236
+ }) => SchemaComponent;
237
+ parseSchema: (schema: string, typeName?: string | null, schemaPath?: string[]) => ParsedSchema<SchemaTypeObjectContent | SchemaTypeEnumContent | SchemaTypePrimitiveContent>;
238
+ getInlineParseContent: (schema: string, typeName: string | null, schemaPath: string[]) => Record<string, any>;
239
+ getParseContent: (schema: string, typeName: string | null, schemaPath: string[]) => Record<string, any>;
240
+ }
241
+
242
+ //#endregion
243
+ //#region src/schema-routes/schema-routes.d.ts
244
+ declare class SchemaRoutes {
245
+ config: CodeGenConfig;
246
+ schemaParserFabric: SchemaParserFabric;
247
+ schemaUtils: SchemaUtils;
248
+ typeNameFormatter: TypeNameFormatter;
249
+ schemaComponentsMap: SchemaComponentsMap;
250
+ templatesWorker: TemplatesWorker;
251
+ FORM_DATA_TYPES: string[];
252
+ routes: ParsedRoute[];
253
+ hasSecurityRoutes: boolean;
254
+ hasQueryRoutes: boolean;
255
+ hasFormDataRoutes: boolean;
256
+ constructor(config: CodeGenConfig, schemaParserFabric: SchemaParserFabric, schemaComponentsMap: SchemaComponentsMap, templatesWorker: TemplatesWorker, typeNameFormatter: TypeNameFormatter);
257
+ createRequestsMap: (routeInfoByMethodsMap: any) => {};
258
+ parseRouteName: (originalRouteName: any) => {
259
+ originalRoute: string;
260
+ route: string;
261
+ pathParams: {
262
+ $match: string;
263
+ name: string;
264
+ required: boolean;
265
+ type: "string";
266
+ description: string;
267
+ schema: {
268
+ type: string;
269
+ };
270
+ in: "path" | "query";
271
+ }[];
272
+ queryParams: {
273
+ $match: string;
274
+ name: string;
275
+ required: boolean;
276
+ type: "string";
277
+ description: string;
278
+ schema: {
279
+ type: string;
280
+ };
281
+ in: "path" | "query";
282
+ }[];
283
+ } | {
284
+ originalRoute: any;
285
+ route: any;
286
+ pathParams: never[];
287
+ queryParams: {
288
+ $match: unknown;
289
+ name: string;
290
+ required: boolean;
291
+ type: string;
292
+ description: string;
293
+ schema: {
294
+ type: string;
295
+ };
296
+ in: string;
297
+ }[];
298
+ };
299
+ getRouteParams: (routeInfo: any, pathParamsFromRouteName: any, queryParamsFromRouteName: any) => {
300
+ path: never[];
301
+ header: never[];
302
+ body: never[];
303
+ query: never[];
304
+ formData: never[];
305
+ cookie: never[];
306
+ };
307
+ getContentTypes: (requestInfo: any, extraContentTypes: any) => any[];
308
+ getContentKind: (contentTypes: any) => string;
309
+ isSuccessStatus: (status: any) => boolean;
310
+ getSchemaFromRequestType: (requestInfo: any) => any;
311
+ getTypeFromRequestInfo: ({
312
+ requestInfo,
313
+ parsedSchemas,
314
+ operationId,
315
+ defaultType,
316
+ typeName
317
+ }: {
318
+ requestInfo: any;
319
+ parsedSchemas: any;
320
+ operationId: any;
321
+ defaultType: any;
322
+ typeName: any;
323
+ }) => any;
324
+ getRequestInfoTypes: ({
325
+ requestInfos,
326
+ parsedSchemas,
327
+ operationId,
328
+ defaultType
329
+ }: {
330
+ requestInfos: any;
331
+ parsedSchemas: any;
332
+ operationId: any;
333
+ defaultType: any;
334
+ }) => never[];
335
+ getResponseBodyInfo: (routeInfo: any, parsedSchemas: any) => {
336
+ contentTypes: any[];
337
+ responses: never[];
338
+ success: {
339
+ schema: undefined;
340
+ type: any;
341
+ };
342
+ error: {
343
+ schemas: never[];
344
+ type: string;
345
+ };
346
+ full: {
347
+ types: string;
348
+ };
349
+ };
350
+ convertRouteParamsIntoObject: (params: any) => any;
351
+ getRequestBodyInfo: (routeInfo: any, routeParams: any, parsedSchemas: any, routeName: any) => {
352
+ paramName: any;
353
+ contentTypes: any[];
354
+ contentKind: string;
355
+ schema: any;
356
+ type: any;
357
+ required: any;
358
+ };
359
+ createRequestParamsSchema: ({
360
+ queryParams,
361
+ queryObjectSchema,
362
+ pathArgsSchemas,
363
+ extractRequestParams,
364
+ routeName
365
+ }: {
366
+ queryParams: any;
367
+ queryObjectSchema: any;
368
+ pathArgsSchemas: any;
369
+ extractRequestParams: any;
370
+ routeName: any;
371
+ }) => any;
372
+ extractResponseBodyIfItNeeded: (routeInfo: any, responseBodyInfo: any, routeName: any) => void;
373
+ extractResponseErrorIfItNeeded: (routeInfo: any, responseBodyInfo: any, routeName: any) => void;
374
+ getRouteName: (rawRouteInfo: any) => RouteNameInfo;
375
+ parseRouteInfo: (rawRouteName: any, routeInfo: any, method: any, usageSchema: any, parsedSchemas: any) => ParsedRoute;
376
+ attachSchema: ({
377
+ usageSchema,
378
+ parsedSchemas
379
+ }: {
380
+ usageSchema: any;
381
+ parsedSchemas: any;
382
+ }) => void;
383
+ getGroupedRoutes: () => {
384
+ outOfModule: ParsedRoute[];
385
+ combined?: {
386
+ moduleName: string;
387
+ routes: ParsedRoute[];
388
+ }[];
389
+ };
390
+ sortRoutes: (routes: ParsedRoute[]) => ParsedRoute[];
391
+ }
392
+
393
+ //#endregion
394
+ //#region src/translators/javascript.d.ts
395
+ declare class JavascriptTranslator extends Translator {
396
+ compileTSCode: (input: TranslatorIO) => Record<string, string>;
397
+ translate: (input: any) => Promise<{
398
+ fileName: any;
399
+ fileExtension: typescript$1.Extension;
400
+ fileContent: string;
401
+ }[]>;
402
+ }
403
+
404
+ //#endregion
405
+ //#region src/util/internal-case.d.ts
406
+ declare function internalCase(value: string): string;
407
+
408
+ //#endregion
409
+ //#region src/util/name-resolver.d.ts
410
+ type Resolver = (reserved: string[], extras?: string[]) => string;
411
+ declare class NameResolver {
412
+ reservedNames: string[];
413
+ getFallbackName: Resolver;
414
+ config: CodeGenConfig;
415
+ constructor(config: CodeGenConfig, reservedNames: string[], getFallbackName: Resolver);
416
+ reserve(names: string[]): void;
417
+ unreserve(names: string[]): void;
418
+ isReserved(name: string): boolean;
419
+ resolve(variants: string[], resolver?: Resolver, extras?: string[], shouldReserve?: boolean): string | null;
420
+ }
421
+
422
+ //#endregion
423
+ //#region src/util/pascal-case.d.ts
424
+ declare function pascalCase(value: string): Capitalize<string>;
425
+
426
+ //#endregion
427
+ //#region src/code-gen-process.d.ts
428
+ declare class CodeGenProcess {
429
+ config: CodeGenConfig;
430
+ swaggerSchemaResolver: SwaggerSchemaResolver;
431
+ schemaComponentsMap: SchemaComponentsMap;
432
+ typeNameFormatter: TypeNameFormatter;
433
+ schemaParserFabric: SchemaParserFabric;
434
+ schemaRoutes: SchemaRoutes;
435
+ fileSystem: FileSystem;
436
+ codeFormatter: CodeFormatter;
437
+ templatesWorker: TemplatesWorker;
438
+ schemaWalker: SchemaWalker;
439
+ javascriptTranslator: JavascriptTranslator;
440
+ constructor(config: Partial<GenerateApiConfiguration["config"]>);
441
+ start(): Promise<{
442
+ files: TranslatorIO[];
443
+ configuration: GenerateApiConfiguration | {
444
+ apiConfig: {
445
+ info: any;
446
+ servers: any;
447
+ basePath: any;
448
+ host: any;
449
+ externalDocs: any;
450
+ tags: unknown[];
451
+ baseUrl: any;
452
+ title: any;
453
+ version: any;
454
+ };
455
+ config: CodeGenConfig;
456
+ modelTypes: any[];
457
+ hasSecurityRoutes: boolean;
458
+ hasQueryRoutes: boolean;
459
+ hasFormDataRoutes: boolean;
460
+ generateResponses: boolean;
461
+ routes: {
462
+ outOfModule: ParsedRoute[];
463
+ combined?: {
464
+ moduleName: string;
465
+ routes: ParsedRoute[];
466
+ }[];
467
+ };
468
+ extraTemplates: never[];
469
+ fileName: string;
470
+ translateToJavaScript: boolean;
471
+ customTranslator: Translator | null;
472
+ utils: {
473
+ Ts: {
474
+ Keyword: {
475
+ Number: string;
476
+ String: string;
477
+ Boolean: string;
478
+ Any: string;
479
+ Void: string;
480
+ Unknown: string;
481
+ Null: string;
482
+ Undefined: string;
483
+ Object: string;
484
+ File: string;
485
+ Date: string;
486
+ Type: string;
487
+ Enum: string;
488
+ Interface: string;
489
+ Array: string;
490
+ Record: string;
491
+ Intersection: string;
492
+ Union: string;
493
+ };
494
+ CodeGenKeyword: {
495
+ UtilRequiredKeys: string;
496
+ };
497
+ ArrayType: (content: unknown) => string;
498
+ StringValue: (content: unknown) => string;
499
+ BooleanValue: (content: unknown) => string;
500
+ NumberValue: (content: unknown) => string;
501
+ NullValue: () => string;
502
+ UnionType: (contents: unknown[]) => string;
503
+ ExpressionGroup: (content: unknown) => string;
504
+ IntersectionType: (contents: unknown[]) => string;
505
+ RecordType: (key: unknown, value: unknown) => string;
506
+ TypeField: ({
507
+ readonly,
508
+ key,
509
+ optional,
510
+ value
511
+ }: Record<string, unknown>) => string;
512
+ InterfaceDynamicField: (key: unknown, value: unknown) => string;
513
+ EnumUsageKey: (enumStruct: unknown, key: unknown) => string;
514
+ EnumField: (key: unknown, value: unknown) => string;
515
+ EnumFieldsWrapper: (contents: Record<string, unknown>[]) => string;
516
+ ObjectWrapper: (content: unknown) => string;
517
+ MultilineComment: (contents: unknown[], formatFn: (arg: unknown) => unknown) => string[];
518
+ TypeWithGeneric: (typeName: unknown, genericArgs: unknown[]) => string;
519
+ Tuple: (values: unknown[]) => string;
520
+ };
521
+ formatDescription: (description: any, inline: any) => any;
522
+ internalCase: typeof internalCase;
523
+ classNameCase: typeof pascalCase;
524
+ pascalCase: typeof pascalCase;
525
+ getInlineParseContent: (schema: string, typeName: string | null, schemaPath: string[]) => Record<string, any>;
526
+ getParseContent: (schema: string, typeName: string | null, schemaPath: string[]) => Record<string, any>;
527
+ getComponentByRef: ($ref: string) => SchemaComponent | null;
528
+ parseSchema: (schema: string, typeName?: string | null, schemaPath?: string[]) => ParsedSchema<SchemaTypeObjectContent | SchemaTypeEnumContent | SchemaTypePrimitiveContent>;
529
+ checkAndAddNull: (schema: any, type: any) => any;
530
+ safeAddNullToType: (schema: any, type: any) => any;
531
+ isNeedToAddNull: (schema: any, type: any) => any;
532
+ inlineExtraFormatters: {
533
+ enum: (parsedSchema: any) => any;
534
+ object: (parsedSchema: any) => any;
535
+ };
536
+ formatters: {
537
+ enum: (parsedSchema: any) => any;
538
+ object: (parsedSchema: any) => any;
539
+ primitive: (parsedSchema: any) => any;
540
+ };
541
+ formatModelName: (name: string, options?: {
542
+ type?: "enum-key" | "type-name";
543
+ }) => string | undefined;
544
+ fmtToJSDocLine: (line: string, {
545
+ eol
546
+ }: {
547
+ eol?: boolean | undefined;
548
+ }) => string;
549
+ NameResolver: typeof NameResolver;
550
+ _: lodash.LoDashStatic;
551
+ require: (packageOrPath: string) => Promise<any>;
552
+ };
553
+ };
554
+ getTemplate: (name: string, fileName: string, path?: string) => string | undefined;
555
+ renderTemplate: (template: string, configuration: object, options?: object) => string;
556
+ createFile: ({
557
+ path: path_,
558
+ fileName,
559
+ content,
560
+ withPrefix
561
+ }: {
562
+ path: any;
563
+ fileName: any;
564
+ content: any;
565
+ withPrefix: any;
566
+ }) => void;
567
+ formatTSContent: (code: string, {
568
+ removeUnusedImports,
569
+ format
570
+ }?: {
571
+ removeUnusedImports?: boolean | undefined;
572
+ format?: boolean | undefined;
573
+ }) => Promise<string>;
574
+ }>;
575
+ getRenderTemplateData: () => {
576
+ utils: {
577
+ Ts: {
578
+ Keyword: {
579
+ Number: string;
580
+ String: string;
581
+ Boolean: string;
582
+ Any: string;
583
+ Void: string;
584
+ Unknown: string;
585
+ Null: string;
586
+ Undefined: string;
587
+ Object: string;
588
+ File: string;
589
+ Date: string;
590
+ Type: string;
591
+ Enum: string;
592
+ Interface: string;
593
+ Array: string;
594
+ Record: string;
595
+ Intersection: string;
596
+ Union: string;
597
+ };
598
+ CodeGenKeyword: {
599
+ UtilRequiredKeys: string;
600
+ };
601
+ ArrayType: (content: unknown) => string;
602
+ StringValue: (content: unknown) => string;
603
+ BooleanValue: (content: unknown) => string;
604
+ NumberValue: (content: unknown) => string;
605
+ NullValue: () => string;
606
+ UnionType: (contents: unknown[]) => string;
607
+ ExpressionGroup: (content: unknown) => string;
608
+ IntersectionType: (contents: unknown[]) => string;
609
+ RecordType: (key: unknown, value: unknown) => string;
610
+ TypeField: ({
611
+ readonly,
612
+ key,
613
+ optional,
614
+ value
615
+ }: Record<string, unknown>) => string;
616
+ InterfaceDynamicField: (key: unknown, value: unknown) => string;
617
+ EnumUsageKey: (enumStruct: unknown, key: unknown) => string;
618
+ EnumField: (key: unknown, value: unknown) => string;
619
+ EnumFieldsWrapper: (contents: Record<string, unknown>[]) => string;
620
+ ObjectWrapper: (content: unknown) => string;
621
+ MultilineComment: (contents: unknown[], formatFn: (arg: unknown) => unknown) => string[];
622
+ TypeWithGeneric: (typeName: unknown, genericArgs: unknown[]) => string;
623
+ Tuple: (values: unknown[]) => string;
624
+ };
625
+ formatDescription: (description: any, inline: any) => any;
626
+ internalCase: typeof internalCase;
627
+ classNameCase: typeof pascalCase;
628
+ pascalCase: typeof pascalCase;
629
+ getInlineParseContent: (schema: string, typeName: string | null, schemaPath: string[]) => Record<string, any>;
630
+ getParseContent: (schema: string, typeName: string | null, schemaPath: string[]) => Record<string, any>;
631
+ getComponentByRef: ($ref: string) => SchemaComponent | null;
632
+ parseSchema: (schema: string, typeName?: string | null, schemaPath?: string[]) => ParsedSchema<SchemaTypeObjectContent | SchemaTypeEnumContent | SchemaTypePrimitiveContent>;
633
+ checkAndAddNull: (schema: any, type: any) => any;
634
+ safeAddNullToType: (schema: any, type: any) => any;
635
+ isNeedToAddNull: (schema: any, type: any) => any;
636
+ inlineExtraFormatters: {
637
+ enum: (parsedSchema: any) => any;
638
+ object: (parsedSchema: any) => any;
639
+ };
640
+ formatters: {
641
+ enum: (parsedSchema: any) => any;
642
+ object: (parsedSchema: any) => any;
643
+ primitive: (parsedSchema: any) => any;
644
+ };
645
+ formatModelName: (name: string, options?: {
646
+ type?: "enum-key" | "type-name";
647
+ }) => string | undefined;
648
+ fmtToJSDocLine: (line: string, {
649
+ eol
650
+ }: {
651
+ eol?: boolean | undefined;
652
+ }) => string;
653
+ NameResolver: typeof NameResolver;
654
+ _: lodash.LoDashStatic;
655
+ require: (packageOrPath: string) => Promise<any>;
656
+ };
657
+ config: CodeGenConfig;
658
+ };
659
+ collectModelTypes: () => any[];
660
+ prepareModelType: (typeInfo: any) => any;
661
+ generateOutputFiles: ({
662
+ configuration
663
+ }: {
664
+ configuration: any;
665
+ }) => Promise<TranslatorIO[]>;
666
+ createMultipleFileInfos: (templatesToRender: any, configuration: any) => Promise<TranslatorIO[]>;
667
+ createSingleFileInfo: (templatesToRender: any, configuration: any) => Promise<TranslatorIO[]>;
668
+ createOutputFileInfo: (configuration: any, fileNameFull: any, content: any) => Promise<TranslatorIO[]>;
669
+ createApiConfig: (swaggerSchema: any) => {
670
+ info: any;
671
+ servers: any;
672
+ basePath: any;
673
+ host: any;
674
+ externalDocs: any;
675
+ tags: unknown[];
676
+ baseUrl: any;
677
+ title: any;
678
+ version: any;
679
+ };
680
+ injectClassInstance: (key: any, value: any) => void;
681
+ }
682
+
683
+ //#endregion
684
+ //#region src/templates-worker.d.ts
685
+ declare class TemplatesWorker {
686
+ config: CodeGenConfig;
687
+ fileSystem: FileSystem;
688
+ getRenderTemplateData: CodeGenProcess["getRenderTemplateData"];
689
+ constructor(config: CodeGenConfig, fileSystem: FileSystem, getRenderTemplateData: CodeGenProcess["getRenderTemplateData"]);
690
+ getTemplatePaths: (config: CodeGenConfig) => CodeGenConfig["templatePaths"];
691
+ cropExtension: (path: string) => string;
692
+ getTemplateFullPath: (path_: string, fileName: string) => string | undefined;
693
+ requireFnFromTemplate: (packageOrPath: string) => Promise<any>;
694
+ getTemplate: (name: string, fileName: string, path?: string) => string | undefined;
695
+ getTemplates: ({
696
+ templatePaths
697
+ }: CodeGenConfig) => {};
698
+ findTemplateWithExt: (path: string) => string | undefined;
699
+ getTemplateContent: (path_: string) => string;
700
+ renderTemplate: (template: string, configuration: object, options?: object) => string;
701
+ }
702
+
703
+ //#endregion
704
+ //#region src/schema-parser/schema-parser.d.ts
705
+ declare class SchemaParser {
706
+ schemaParserFabric: SchemaParserFabric;
707
+ config: CodeGenConfig;
708
+ schemaComponentsMap: SchemaComponentsMap;
709
+ typeNameFormatter: TypeNameFormatter;
710
+ schemaFormatters: SchemaFormatters;
711
+ schemaUtils: SchemaUtils;
712
+ templatesWorker: TemplatesWorker;
713
+ schemaWalker: SchemaWalker;
714
+ typeName: any;
715
+ schema: any;
716
+ schemaPath: never[];
717
+ constructor(schemaParserFabric: any, {
718
+ typeName,
719
+ schema,
720
+ schemaPath
721
+ }?: {});
722
+ _complexSchemaParsers: {
723
+ oneOf: (schema: any) => any;
724
+ allOf: (schema: any) => any;
725
+ anyOf: (schema: any) => any;
726
+ not: (schema: any) => any;
727
+ };
728
+ _baseSchemaParsers: {
729
+ enum: (schema: any, typeName: any) => any;
730
+ object: (schema: any, typeName: any) => any;
731
+ complex: (schema: any, typeName: any) => any;
732
+ primitive: (schema: any, typeName: any) => any;
733
+ discriminator: (schema: any, typeName: any) => any;
734
+ array: (schema: any, typeName: any) => any;
735
+ };
736
+ parseSchema: () => any;
737
+ getInlineParseContent: () => any;
738
+ getParseContent: () => any;
739
+ extractSchemaFromResponseStruct: (responseStruct: any) => any;
740
+ }
741
+
742
+ //#endregion
743
+ //#region src/component-type-name-resolver.d.ts
744
+ declare class ComponentTypeNameResolver extends NameResolver {
745
+ counter: number;
746
+ fallbackNameCounter: number;
747
+ countersByVariant: Map<string, number>;
748
+ constructor(config: CodeGenConfig, reservedNames: string[]);
749
+ }
750
+
751
+ //#endregion
752
+ //#region src/constants.d.ts
753
+ declare namespace constants_d_exports {
754
+ export { DEFAULT_BODY_ARG_NAME, FILE_PREFIX, HTTP_CLIENT, PROJECT_VERSION, RESERVED_BODY_ARG_NAMES, RESERVED_HEADER_ARG_NAMES, RESERVED_PATH_ARG_NAMES, RESERVED_QUERY_ARG_NAMES, RESERVED_REQ_PARAMS_ARG_NAMES, SCHEMA_TYPES$1 as SCHEMA_TYPES };
755
+ }
756
+ declare const DEFAULT_BODY_ARG_NAME = "data";
757
+ declare const FILE_PREFIX = "/* eslint-disable */\n/* tslint:disable */\n// @ts-nocheck\n/*\n * ---------------------------------------------------------------\n * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##\n * ## ##\n * ## AUTHOR: acacode ##\n * ## SOURCE: https://github.com/acacode/swagger-typescript-api ##\n * ---------------------------------------------------------------\n */\n\n";
758
+ declare const HTTP_CLIENT: {
759
+ readonly FETCH: "fetch";
760
+ readonly AXIOS: "axios";
761
+ };
762
+ declare const PROJECT_VERSION: string;
763
+ declare const RESERVED_BODY_ARG_NAMES: string[];
764
+ declare const RESERVED_HEADER_ARG_NAMES: string[];
765
+ declare const RESERVED_PATH_ARG_NAMES: string[];
766
+ declare const RESERVED_QUERY_ARG_NAMES: string[];
767
+ declare const RESERVED_REQ_PARAMS_ARG_NAMES: string[];
768
+ declare const SCHEMA_TYPES$1: {
769
+ readonly ARRAY: "array";
770
+ readonly OBJECT: "object";
771
+ readonly ENUM: "enum";
772
+ readonly REF: "$ref";
773
+ readonly PRIMITIVE: "primitive";
774
+ readonly COMPLEX: "complex";
775
+ readonly DISCRIMINATOR: "discriminator";
776
+ readonly COMPLEX_ONE_OF: "oneOf";
777
+ readonly COMPLEX_ANY_OF: "anyOf";
778
+ readonly COMPLEX_ALL_OF: "allOf";
779
+ readonly COMPLEX_NOT: "not";
780
+ readonly COMPLEX_UNKNOWN: "__unknown";
781
+ };
782
+
783
+ //#endregion
784
+ //#region src/schema-parser/mono-schema-parser.d.ts
785
+ declare class MonoSchemaParser {
786
+ schema: any;
787
+ typeName: any;
788
+ schemaPath: never[];
789
+ schemaParser: SchemaParser;
790
+ schemaParserFabric: SchemaParserFabric;
791
+ typeNameFormatter: TypeNameFormatter;
792
+ schemaComponentsMap: SchemaComponentsMap;
793
+ schemaUtils: SchemaUtils;
794
+ config: CodeGenConfig;
795
+ schemaFormatters: SchemaFormatters;
796
+ constructor(schemaParser: SchemaParser, schema: any, typeName?: null, schemaPath?: never[]);
797
+ parse(): void;
798
+ buildTypeNameFromPath: () => Capitalize<string> | null;
799
+ }
800
+
801
+ //#endregion
802
+ //#region types/index.d.ts
803
+ type HttpClientType = (typeof HTTP_CLIENT)[keyof typeof HTTP_CLIENT];
804
+ type BuildRouteParam = {
805
+ /** {bar} */
806
+ $match: string;
807
+ name: string;
808
+ required: boolean;
809
+ type: "string";
810
+ description: string;
811
+ schema: {
812
+ type: string;
813
+ };
814
+ in: "path" | "query";
815
+ };
816
+ type BuildRoutePath = {
817
+ /** /foo/{bar}/baz */
818
+ originalRoute: string;
819
+ /** /foo/${bar}/baz */
820
+ route: string;
821
+ pathParams: BuildRouteParam[];
822
+ queryParams: BuildRouteParam[];
823
+ };
824
+ interface Hooks {
825
+ /** calls before parse\process route path */
826
+ onPreBuildRoutePath: (routePath: string) => string | undefined;
827
+ /** calls after parse\process route path */
828
+ onBuildRoutePath: (data: BuildRoutePath) => BuildRoutePath | undefined;
829
+ /** calls before insert path param name into string path interpolation */
830
+ onInsertPathParam: (paramName: string, index: number, arr: BuildRouteParam[], resultRoute: string) => string | undefined;
831
+ /** calls after parse schema component */
832
+ onCreateComponent: (component: SchemaComponent) => SchemaComponent | undefined;
833
+ /** calls before parse any kind of schema */
834
+ onPreParseSchema: (originalSchema: unknown, typeName: string, schemaType: string) => undefined;
835
+ /** calls after parse any kind of schema */
836
+ onParseSchema: (originalSchema: unknown, parsedSchema: unknown) => unknown | undefined;
837
+ /** calls after parse route (return type: customized route (ParsedRoute), nothing change (void), false (ignore this route)) */
838
+ onCreateRoute: (routeData: ParsedRoute) => ParsedRoute | false | undefined;
839
+ /** Start point of work this tool (after fetching schema) */
840
+ onInit?: <C extends GenerateApiConfiguration["config"]>(configuration: C, codeGenProcess: CodeGenProcess) => C | undefined;
841
+ /** customize configuration object before sending it to ETA templates */
842
+ onPrepareConfig?: <C extends GenerateApiConfiguration>(currentConfiguration: C) => C | undefined;
843
+ /** customize route name as you need */
844
+ onCreateRouteName?: (routeNameInfo: RouteNameInfo, rawRouteInfo: RawRouteInfo) => RouteNameInfo | undefined;
845
+ /** customize request params (path params, query params) */
846
+ onCreateRequestParams?: (rawType: SchemaComponent["rawTypeData"]) => SchemaComponent["rawTypeData"] | undefined;
847
+ /** customize name of model type */
848
+ onFormatTypeName?: (typeName: string, rawTypeName?: string, schemaType?: "type-name" | "enum-key") => string | undefined;
849
+ /** customize name of route (operationId), you can do it with using onCreateRouteName too */
850
+ onFormatRouteName?: (routeInfo: RawRouteInfo, templateRouteName: string) => string | undefined;
851
+ }
852
+ type RouteNameInfo = {
853
+ usage: string;
854
+ original: string;
855
+ duplicate: boolean;
856
+ };
857
+ type SchemaTypePrimitiveContent = {
858
+ $parsedSchema: boolean;
859
+ schemaType: string;
860
+ type: string;
861
+ typeIdentifier: string;
862
+ name?: unknown;
863
+ description: string;
864
+ content: string;
865
+ };
866
+ type SchemaTypeObjectContent = {
867
+ $$raw: {
868
+ type: string;
869
+ required: boolean;
870
+ $parsed: SchemaTypePrimitiveContent;
871
+ };
872
+ isRequired: boolean;
873
+ field: string;
874
+ }[];
875
+ type SchemaTypeEnumContent = {
876
+ key: string;
877
+ type: string;
878
+ value: string;
879
+ };
880
+ interface ParsedSchema<C> {
881
+ $parsedSchema: boolean;
882
+ schemaType: string;
883
+ type: string;
884
+ typeIdentifier: string;
885
+ name: string;
886
+ description?: string;
887
+ allFieldsAreOptional?: boolean;
888
+ content: C;
889
+ isExtractedRequestParams?: boolean;
890
+ isExtractedRequestBody?: boolean;
891
+ isExtractedResponseBody?: boolean;
892
+ isExtractedResponseError?: boolean;
893
+ }
894
+ interface SchemaComponent {
895
+ $ref: string;
896
+ typeName: string;
897
+ rawTypeData?: {
898
+ type: string;
899
+ required?: string[];
900
+ properties?: Record<string, {
901
+ name?: string;
902
+ type: string;
903
+ required: boolean;
904
+ $parsed?: SchemaTypePrimitiveContent;
905
+ }>;
906
+ discriminator?: {
907
+ propertyName?: string;
908
+ };
909
+ $parsed: ParsedSchema<SchemaTypeObjectContent | SchemaTypeEnumContent | SchemaTypePrimitiveContent>;
910
+ };
911
+ componentName: "schemas" | "paths";
912
+ typeData: ParsedSchema<SchemaTypeObjectContent | SchemaTypeEnumContent | SchemaTypePrimitiveContent> | null;
913
+ }
914
+ declare enum RequestContentKind {
915
+ JSON = "JSON",
916
+ URL_ENCODED = "URL_ENCODED",
917
+ FORM_DATA = "FORM_DATA",
918
+ IMAGE = "IMAGE",
919
+ OTHER = "OTHER",
920
+ TEXT = "TEXT",
921
+ }
922
+ interface RequestResponseInfo {
923
+ contentTypes: string[];
924
+ contentKind: RequestContentKind;
925
+ type: string;
926
+ description: string;
927
+ status: string | number;
928
+ isSuccess: boolean;
929
+ }
930
+ type RawRouteInfo = {
931
+ operationId: string;
932
+ method: string;
933
+ route: string;
934
+ moduleName: string;
935
+ responsesTypes: RequestResponseInfo[];
936
+ description?: string;
937
+ tags?: string[];
938
+ summary?: string;
939
+ responses?: swagger_schema_official18.Spec["responses"];
940
+ produces?: string[];
941
+ requestBody?: object;
942
+ consumes?: string[];
943
+ };
944
+ interface ParsedRouteRequest {
945
+ contentTypes?: string[];
946
+ formData?: boolean;
947
+ headers?: {
948
+ name: string | null;
949
+ optional: boolean | undefined;
950
+ type: Record<string, any>;
951
+ };
952
+ isQueryBody?: boolean;
953
+ method?: string;
954
+ parameters?: Record<string, unknown>[];
955
+ path?: string;
956
+ pathParams?: Record<string, unknown>;
957
+ payload?: {
958
+ name: string | null;
959
+ optional?: boolean;
960
+ type: string;
961
+ };
962
+ query?: Record<string, unknown>;
963
+ requestParams?: Record<string, unknown> | null;
964
+ security?: boolean;
965
+ }
966
+ interface ParsedRouteResponse {
967
+ contentTypes?: string[];
968
+ errorType?: string;
969
+ fullTypes?: string;
970
+ type?: string;
971
+ }
972
+ interface ParsedRoute {
973
+ id: string;
974
+ namespace: string;
975
+ routeParams?: Record<string, any>;
976
+ requestBodyInfo?: {
977
+ paramName: any;
978
+ contentTypes: any[];
979
+ contentKind: string;
980
+ schema: any;
981
+ type: any;
982
+ required: any;
983
+ };
984
+ responseBodyInfo?: {
985
+ contentTypes: any[];
986
+ responses: any[];
987
+ success?: Record<string, any>;
988
+ error?: Record<string, any>;
989
+ full?: Record<string, any>;
990
+ };
991
+ specificArgs?: Record<string, any>;
992
+ queryObjectSchema?: Record<string, any>;
993
+ pathObjectSchema?: Record<string, any>;
994
+ headersObjectSchema?: Record<string, any>;
995
+ responseBodySchema?: Record<string, any>;
996
+ requestBodySchema?: Record<string, any>;
997
+ specificArgNameResolver?: Record<string, any>;
998
+ request: ParsedRouteRequest;
999
+ response: ParsedRouteResponse;
1000
+ routeName: RouteNameInfo;
1001
+ raw: RawRouteInfo;
1002
+ }
1003
+ type ModelType = {
1004
+ typeIdentifier: string;
1005
+ name: string;
1006
+ rawContent: string;
1007
+ description: string;
1008
+ content: string;
1009
+ };
1010
+ declare enum SCHEMA_TYPES {
1011
+ ARRAY = "array",
1012
+ OBJECT = "object",
1013
+ ENUM = "enum",
1014
+ REF = "$ref",
1015
+ PRIMITIVE = "primitive",
1016
+ COMPLEX = "complex",
1017
+ COMPLEX_ONE_OF = "oneOf",
1018
+ COMPLEX_ANY_OF = "anyOf",
1019
+ COMPLEX_ALL_OF = "allOf",
1020
+ COMPLEX_NOT = "not",
1021
+ COMPLEX_UNKNOWN = "__unknown",
1022
+ }
1023
+ type MAIN_SCHEMA_TYPES = SCHEMA_TYPES.PRIMITIVE | SCHEMA_TYPES.OBJECT | SCHEMA_TYPES.ENUM;
1024
+ type ExtractingOptions = {
1025
+ requestBodySuffix: string[];
1026
+ responseBodySuffix: string[];
1027
+ responseErrorSuffix: string[];
1028
+ requestParamsSuffix: string[];
1029
+ enumSuffix: string[];
1030
+ discriminatorMappingSuffix: string[];
1031
+ discriminatorAbstractPrefix: string[];
1032
+ requestBodyNameResolver: (name: string, reservedNames: string) => string | undefined;
1033
+ responseBodyNameResolver: (name: string, reservedNames: string) => string | undefined;
1034
+ responseErrorNameResolver: (name: string, reservedNames: string) => string | undefined;
1035
+ requestParamsNameResolver: (name: string, reservedNames: string) => string | undefined;
1036
+ enumNameResolver: (name: string, reservedNames: string) => string | undefined;
1037
+ discriminatorMappingNameResolver: (name: string, reservedNames: string) => string | undefined;
1038
+ discriminatorAbstractResolver: (name: string, reservedNames: string) => string | undefined;
1039
+ };
1040
+ interface GenerateApiConfiguration {
1041
+ apiConfig: {
1042
+ baseUrl: string;
1043
+ title: string;
1044
+ version: string;
1045
+ description: string[];
1046
+ hasDescription: boolean;
1047
+ };
1048
+ config: {
1049
+ input: string;
1050
+ output: string | false;
1051
+ url: string;
1052
+ spec: unknown;
1053
+ fileName: string;
1054
+ templatePaths: {
1055
+ /** `templates/base` */
1056
+ base: string;
1057
+ /** `templates/default` */
1058
+ default: string;
1059
+ /** `templates/modular` */
1060
+ modular: string;
1061
+ /** usage path if `--templates` option is not set */
1062
+ original: string;
1063
+ /** custom path to templates (`--templates`) */
1064
+ custom: string | null;
1065
+ };
1066
+ authorizationToken?: string;
1067
+ generateResponses: boolean;
1068
+ defaultResponseAsSuccess: boolean;
1069
+ generateRouteTypes: boolean;
1070
+ generateClient: boolean;
1071
+ generateUnionEnums: boolean;
1072
+ swaggerSchema: object;
1073
+ originalSchema: object;
1074
+ componentsMap: Record<string, SchemaComponent>;
1075
+ convertedFromSwagger2: boolean;
1076
+ moduleNameIndex: number;
1077
+ moduleNameFirstTag: boolean;
1078
+ extraTemplates: {
1079
+ name: string;
1080
+ path: string;
1081
+ }[];
1082
+ extractRequestParams: boolean;
1083
+ unwrapResponseData: boolean;
1084
+ sortTypes: boolean;
1085
+ sortRoutes: boolean;
1086
+ singleHttpClient: boolean;
1087
+ typePrefix: string;
1088
+ typeSuffix: string;
1089
+ enumKeyPrefix: string;
1090
+ enumKeySuffix: string;
1091
+ patch: boolean;
1092
+ cleanOutput: boolean;
1093
+ debug: boolean;
1094
+ anotherArrayType: boolean;
1095
+ extractRequestBody: boolean;
1096
+ httpClientType: "axios" | "fetch";
1097
+ addReadonly: boolean;
1098
+ extractResponseBody: boolean;
1099
+ extractResponseError: boolean;
1100
+ extractEnums: boolean;
1101
+ extractResponses: boolean;
1102
+ fixInvalidTypeNamePrefix: string;
1103
+ fixInvalidEnumKeyPrefix: string;
1104
+ defaultResponseType: string;
1105
+ toJS: boolean;
1106
+ disableThrowOnError: boolean;
1107
+ silent: boolean;
1108
+ hooks: Partial<Hooks>;
1109
+ enumNamesAsValues: boolean;
1110
+ version: string;
1111
+ compilerTsConfig: Record<string, unknown>;
1112
+ enumKeyResolverName: string;
1113
+ typeNameResolverName: string;
1114
+ specificArgNameResolverName: string;
1115
+ customTranslator?: new () => Translator;
1116
+ internalTemplateOptions: {
1117
+ addUtilRequiredKeysType: boolean;
1118
+ };
1119
+ componentTypeNameResolver: ComponentTypeNameResolver;
1120
+ fileNames: {
1121
+ dataContracts: string;
1122
+ routeTypes: string;
1123
+ httpClient: string;
1124
+ outOfModuleApi: string;
1125
+ };
1126
+ templatesToRender: {
1127
+ api: string;
1128
+ dataContracts: string;
1129
+ httpClient: string;
1130
+ routeTypes: string;
1131
+ routeName: string;
1132
+ dataContractJsDoc: string;
1133
+ interfaceDataContract: string;
1134
+ typeDataContract: string;
1135
+ enumDataContract: string;
1136
+ objectFieldJsDoc: string;
1137
+ };
1138
+ routeNameDuplicatesMap: Map<string, string>;
1139
+ apiClassName: string;
1140
+ requestOptions?: RequestInit;
1141
+ extractingOptions: ExtractingOptions;
1142
+ };
1143
+ modelTypes: ModelType[];
1144
+ hasFormDataRoutes: boolean;
1145
+ hasSecurityRoutes: boolean;
1146
+ hasQueryRoutes: boolean;
1147
+ generateResponses: boolean;
1148
+ routes: {
1149
+ outOfModule: ParsedRoute[];
1150
+ combined?: {
1151
+ moduleName: string;
1152
+ routes: ParsedRoute[];
1153
+ }[];
1154
+ };
1155
+ requestOptions?: Partial<RequestInit>;
1156
+ utils: {
1157
+ formatDescription: (description: string, inline?: boolean) => string;
1158
+ internalCase: (value: string) => string;
1159
+ /** @deprecated */
1160
+ classNameCase: (value: string) => string;
1161
+ pascalCase: (value: string) => string;
1162
+ getInlineParseContent: (rawTypeData: SchemaComponent["rawTypeData"], typeName?: string) => string;
1163
+ getParseContent: (rawTypeData: SchemaComponent["rawTypeData"], typeName?: string) => ModelType;
1164
+ getComponentByRef: (ref: string) => SchemaComponent;
1165
+ parseSchema: (rawSchema: string | SchemaComponent["rawTypeData"], typeName?: string, formattersMap?: Record<MAIN_SCHEMA_TYPES, (content: ModelType) => string>) => ModelType;
1166
+ formatters: Record<MAIN_SCHEMA_TYPES, (content: string | object | string[] | object[]) => string>;
1167
+ inlineExtraFormatters: Record<Exclude<MAIN_SCHEMA_TYPES, SCHEMA_TYPES.PRIMITIVE>, (schema: ModelType) => string>;
1168
+ formatModelName: (name: string) => string;
1169
+ fmtToJSDocLine: (line: string, params?: {
1170
+ eol?: boolean;
1171
+ }) => string;
1172
+ _: lodash19.LoDashStatic;
1173
+ require: (path: string) => unknown;
1174
+ };
1175
+ }
1176
+ type FileInfo = {
1177
+ /** @example myFilename */
1178
+ fileName: string;
1179
+ /** @example .d.ts */
1180
+ fileExtension: string;
1181
+ /** content of the file */
1182
+ fileContent: string;
1183
+ };
1184
+ interface GenerateApiOutput {
1185
+ configuration: GenerateApiConfiguration;
1186
+ files: FileInfo[];
1187
+ createFile: (params: {
1188
+ path: string;
1189
+ fileName: string;
1190
+ content: string;
1191
+ withPrefix: boolean;
1192
+ }) => void;
1193
+ renderTemplate: (templateContent: string, data: Record<string, unknown>, etaOptions?: Partial<eta20.EtaConfig>) => Promise<string> | string;
1194
+ getTemplate: (params: {
1195
+ fileName?: string;
1196
+ name?: string;
1197
+ path?: string;
1198
+ }) => string;
1199
+ formatTSContent: (content: string) => Promise<string>;
1200
+ }
1201
+ interface GenerateTemplatesParams {
1202
+ cleanOutput?: boolean;
1203
+ output?: string;
1204
+ httpClientType?: HttpClientType;
1205
+ modular?: boolean;
1206
+ rewrite?: boolean;
1207
+ silent?: boolean;
1208
+ debug?: boolean;
1209
+ }
1210
+ interface GenerateTemplatesOutput extends Pick<GenerateApiOutput, "files" | "createFile"> {} //#endregion
1211
+ //#region src/configuration.d.ts
1212
+ declare class CodeGenConfig {
1213
+ version: string;
1214
+ /** CLI flag */
1215
+ templates: string;
1216
+ /** CLI flag */
1217
+ generateResponses: boolean;
1218
+ /** CLI flag */
1219
+ defaultResponseAsSuccess: boolean;
1220
+ /** CLI flag */
1221
+ generateRouteTypes: boolean;
1222
+ /** CLI flag */
1223
+ generateClient: boolean;
1224
+ /** CLI flag */
1225
+ generateUnionEnums: boolean;
1226
+ /** CLI flag */
1227
+ addReadonly: boolean;
1228
+ enumNamesAsValues: boolean;
1229
+ /** parsed swagger schema from getSwaggerObject() */
1230
+ /** parsed swagger schema ref */
1231
+ swaggerSchema: null;
1232
+ /** original (converted to json) swagger schema ref */
1233
+ originalSchema: null;
1234
+ /** { "#/components/schemas/Foo": @TypeInfo, ... } */
1235
+ componentsMap: {};
1236
+ /** flag for catching conversion from swagger 2.0 */
1237
+ convertedFromSwagger2: boolean;
1238
+ /** url index from paths used for merging into modules */
1239
+ moduleNameIndex: number;
1240
+ /** use the first tag for the module name */
1241
+ moduleNameFirstTag: boolean;
1242
+ extractRequestParams: boolean;
1243
+ extractRequestBody: boolean;
1244
+ extractResponseBody: boolean;
1245
+ extractResponseError: boolean;
1246
+ extractResponses: boolean;
1247
+ extractEnums: boolean;
1248
+ fileNames: {
1249
+ dataContracts: string;
1250
+ routeTypes: string;
1251
+ httpClient: string;
1252
+ outOfModuleApi: string;
1253
+ };
1254
+ routeNameDuplicatesMap: Map<any, any>;
1255
+ hooks: Hooks;
1256
+ defaultResponseType: string;
1257
+ singleHttpClient: boolean;
1258
+ httpClientType: "fetch";
1259
+ unwrapResponseData: boolean;
1260
+ disableThrowOnError: boolean;
1261
+ sortTypes: boolean;
1262
+ sortRoutes: boolean;
1263
+ templatePaths: {
1264
+ /** `templates/base` */
1265
+ base: string;
1266
+ /** `templates/default` */
1267
+ default: string;
1268
+ /** `templates/modular` */
1269
+ modular: string;
1270
+ /** usage path if `--templates` option is not set */
1271
+ original: string;
1272
+ /** custom path to templates (`--templates`) */
1273
+ custom: string;
1274
+ };
1275
+ /** Record<templateName, templateContent> */
1276
+ templatesToRender: {
1277
+ api: string;
1278
+ dataContracts: string;
1279
+ dataContractJsDoc: string;
1280
+ interfaceDataContract: string;
1281
+ typeDataContract: string;
1282
+ enumDataContract: string;
1283
+ objectFieldJsDoc: string;
1284
+ httpClient: string;
1285
+ routeTypes: string;
1286
+ routeName: string;
1287
+ };
1288
+ schemaParsers: Record<string, (...args: unknown[]) => MonoSchemaParser>;
1289
+ toJS: boolean;
1290
+ silent: boolean;
1291
+ typePrefix: string;
1292
+ typeSuffix: string;
1293
+ enumKeyPrefix: string;
1294
+ enumKeySuffix: string;
1295
+ patch: boolean;
1296
+ componentTypeNameResolver: ComponentTypeNameResolver;
1297
+ /** name of the main exported class */
1298
+ apiClassName: string;
1299
+ debug: boolean;
1300
+ anotherArrayType: boolean;
1301
+ internalTemplateOptions: {
1302
+ addUtilRequiredKeysType: boolean;
1303
+ };
1304
+ extraTemplates: never[];
1305
+ input: string;
1306
+ modular: boolean;
1307
+ output: string;
1308
+ url: string;
1309
+ cleanOutput: boolean;
1310
+ spec: OpenAPI.Document | null;
1311
+ fileName: string;
1312
+ authorizationToken: string | undefined;
1313
+ requestOptions: null;
1314
+ jsPrimitiveTypes: string[];
1315
+ jsEmptyTypes: string[];
1316
+ fixInvalidTypeNamePrefix: string;
1317
+ fixInvalidEnumKeyPrefix: string;
1318
+ enumKeyResolverName: string;
1319
+ typeNameResolverName: string;
1320
+ specificArgNameResolverName: string;
1321
+ successResponseStatusRange: number[];
1322
+ extractingOptions: Partial<ExtractingOptions>;
1323
+ compilerTsConfig: {
1324
+ module: typescript.ModuleKind;
1325
+ noImplicitReturns: boolean;
1326
+ alwaysStrict: boolean;
1327
+ target: typescript.ScriptTarget;
1328
+ declaration: boolean;
1329
+ noImplicitAny: boolean;
1330
+ sourceMap: boolean;
1331
+ removeComments: boolean;
1332
+ disableSizeLimit: boolean;
1333
+ esModuleInterop: boolean;
1334
+ emitDecoratorMetadata: boolean;
1335
+ skipLibCheck: boolean;
1336
+ };
1337
+ customTranslator?: new () => Translator;
1338
+ Ts: {
1339
+ Keyword: {
1340
+ Number: string;
1341
+ String: string;
1342
+ Boolean: string;
1343
+ Any: string;
1344
+ Void: string;
1345
+ Unknown: string;
1346
+ Null: string;
1347
+ Undefined: string;
1348
+ Object: string;
1349
+ File: string;
1350
+ Date: string;
1351
+ Type: string;
1352
+ Enum: string;
1353
+ Interface: string;
1354
+ Array: string;
1355
+ Record: string;
1356
+ Intersection: string;
1357
+ Union: string;
1358
+ };
1359
+ CodeGenKeyword: {
1360
+ UtilRequiredKeys: string;
1361
+ };
1362
+ /**
1363
+ * $A[] or Array<$A>
1364
+ */
1365
+ ArrayType: (content: unknown) => string;
1366
+ /**
1367
+ * "$A"
1368
+ */
1369
+ StringValue: (content: unknown) => string;
1370
+ /**
1371
+ * $A
1372
+ */
1373
+ BooleanValue: (content: unknown) => string;
1374
+ /**
1375
+ * $A
1376
+ */
1377
+ NumberValue: (content: unknown) => string;
1378
+ /**
1379
+ * $A
1380
+ */
1381
+ NullValue: () => string;
1382
+ /**
1383
+ * $A1 | $A2
1384
+ */
1385
+ UnionType: (contents: unknown[]) => string;
1386
+ /**
1387
+ * ($A1)
1388
+ */
1389
+ ExpressionGroup: (content: unknown) => string;
1390
+ /**
1391
+ * $A1 & $A2
1392
+ */
1393
+ IntersectionType: (contents: unknown[]) => string;
1394
+ /**
1395
+ * Record<$A1, $A2>
1396
+ */
1397
+ RecordType: (key: unknown, value: unknown) => string;
1398
+ /**
1399
+ * readonly $key?:$value
1400
+ */
1401
+ TypeField: ({
1402
+ readonly,
1403
+ key,
1404
+ optional,
1405
+ value
1406
+ }: Record<string, unknown>) => string;
1407
+ /**
1408
+ * [key: $A1]: $A2
1409
+ */
1410
+ InterfaceDynamicField: (key: unknown, value: unknown) => string;
1411
+ /**
1412
+ * EnumName.EnumKey
1413
+ */
1414
+ EnumUsageKey: (enumStruct: unknown, key: unknown) => string;
1415
+ /**
1416
+ * $A1 = $A2
1417
+ */
1418
+ EnumField: (key: unknown, value: unknown) => string;
1419
+ /**
1420
+ * $A0.key = $A0.value,
1421
+ * $A1.key = $A1.value,
1422
+ * $AN.key = $AN.value,
1423
+ */
1424
+ EnumFieldsWrapper: (contents: Record<string, unknown>[]) => string;
1425
+ /**
1426
+ * {\n $A \n}
1427
+ */
1428
+ ObjectWrapper: (content: unknown) => string;
1429
+ /**
1430
+ * /** $A *\/
1431
+ */
1432
+ MultilineComment: (contents: unknown[], formatFn: (arg: unknown) => unknown) => string[];
1433
+ /**
1434
+ * $A1<...$A2.join(,)>
1435
+ */
1436
+ TypeWithGeneric: (typeName: unknown, genericArgs: unknown[]) => string;
1437
+ /**
1438
+ * [$A1, $A2, ...$AN]
1439
+ */
1440
+ Tuple: (values: unknown[]) => string;
1441
+ };
1442
+ /**
1443
+ * swagger schema type -> typescript type
1444
+ * https://json-schema.org/understanding-json-schema/reference/string.html#dates-and-times
1445
+ */
1446
+ primitiveTypes: Record<string, string | ((schema: OpenAPI.Document, parser: SchemaParser) => string) | ({
1447
+ $default: string;
1448
+ } & Record<string, string | ((schema: OpenAPI.Document, parser: SchemaParser) => string)>)>;
1449
+ templateInfos: {
1450
+ name: string;
1451
+ fileName: string;
1452
+ }[];
1453
+ templateExtensions: string[];
1454
+ constructor({
1455
+ codeGenConstructs,
1456
+ primitiveTypeConstructs,
1457
+ constants,
1458
+ templateInfos,
1459
+ hooks,
1460
+ ...otherConfig
1461
+ }: Partial<GenerateApiConfiguration["config"]>);
1462
+ update: (update: Partial<GenerateApiConfiguration["config"]>) => void;
1463
+ }
1464
+
1465
+ //#endregion
1466
+ //#region src/code-formatter.d.ts
1467
+ declare class CodeFormatter {
1468
+ config: CodeGenConfig;
1469
+ constructor(config: CodeGenConfig);
1470
+ removeUnusedImports: (content: string) => string;
1471
+ format: (content: string) => Promise<string>;
1472
+ formatCode: (code: string, {
1473
+ removeUnusedImports,
1474
+ format
1475
+ }?: {
1476
+ removeUnusedImports?: boolean | undefined;
1477
+ format?: boolean | undefined;
1478
+ }) => Promise<string>;
1479
+ }
1480
+
1481
+ //#endregion
1482
+ //#region src/translators/translator.d.ts
1483
+ interface TranslatorIO {
1484
+ fileName: string;
1485
+ fileExtension: string;
1486
+ fileContent: string;
1487
+ }
1488
+ declare class Translator {
1489
+ config: CodeGenConfig;
1490
+ codeFormatter: CodeFormatter;
1491
+ constructor(config: CodeGenConfig, codeFormatter: CodeFormatter);
1492
+ translate(_input: TranslatorIO): Promise<TranslatorIO[]>;
1493
+ }
1494
+
1495
+ //#endregion
1496
+ //#region src/commands/generate-templates/index.d.ts
1497
+ declare function generateTemplates(config: GenerateTemplatesParams): Promise<GenerateTemplatesOutput>;
1498
+
1499
+ //#endregion
1500
+ //#region src/index.d.ts
1501
+ declare function generateApi(config: Partial<GenerateApiConfiguration["config"]>): Promise<{
1502
+ files: TranslatorIO[];
1503
+ configuration: GenerateApiConfiguration | {
1504
+ apiConfig: {
1505
+ info: any;
1506
+ servers: any;
1507
+ basePath: any;
1508
+ host: any;
1509
+ externalDocs: any;
1510
+ tags: unknown[];
1511
+ baseUrl: any;
1512
+ title: any;
1513
+ version: any;
1514
+ };
1515
+ config: CodeGenConfig;
1516
+ modelTypes: any[];
1517
+ hasSecurityRoutes: boolean;
1518
+ hasQueryRoutes: boolean;
1519
+ hasFormDataRoutes: boolean;
1520
+ generateResponses: boolean;
1521
+ routes: {
1522
+ outOfModule: ParsedRoute[];
1523
+ combined?: {
1524
+ moduleName: string;
1525
+ routes: ParsedRoute[];
1526
+ }[];
1527
+ };
1528
+ extraTemplates: never[];
1529
+ fileName: string;
1530
+ translateToJavaScript: boolean;
1531
+ customTranslator: Translator | null;
1532
+ utils: {
1533
+ Ts: {
1534
+ Keyword: {
1535
+ Number: string;
1536
+ String: string;
1537
+ Boolean: string;
1538
+ Any: string;
1539
+ Void: string;
1540
+ Unknown: string;
1541
+ Null: string;
1542
+ Undefined: string;
1543
+ Object: string;
1544
+ File: string;
1545
+ Date: string;
1546
+ Type: string;
1547
+ Enum: string;
1548
+ Interface: string;
1549
+ Array: string;
1550
+ Record: string;
1551
+ Intersection: string;
1552
+ Union: string;
1553
+ };
1554
+ CodeGenKeyword: {
1555
+ UtilRequiredKeys: string;
1556
+ };
1557
+ ArrayType: (content: unknown) => string;
1558
+ StringValue: (content: unknown) => string;
1559
+ BooleanValue: (content: unknown) => string;
1560
+ NumberValue: (content: unknown) => string;
1561
+ NullValue: () => string;
1562
+ UnionType: (contents: unknown[]) => string;
1563
+ ExpressionGroup: (content: unknown) => string;
1564
+ IntersectionType: (contents: unknown[]) => string;
1565
+ RecordType: (key: unknown, value: unknown) => string;
1566
+ TypeField: ({
1567
+ readonly,
1568
+ key,
1569
+ optional,
1570
+ value
1571
+ }: Record<string, unknown>) => string;
1572
+ InterfaceDynamicField: (key: unknown, value: unknown) => string;
1573
+ EnumUsageKey: (enumStruct: unknown, key: unknown) => string;
1574
+ EnumField: (key: unknown, value: unknown) => string;
1575
+ EnumFieldsWrapper: (contents: Record<string, unknown>[]) => string;
1576
+ ObjectWrapper: (content: unknown) => string;
1577
+ MultilineComment: (contents: unknown[], formatFn: (arg: unknown) => unknown) => string[];
1578
+ TypeWithGeneric: (typeName: unknown, genericArgs: unknown[]) => string;
1579
+ Tuple: (values: unknown[]) => string;
1580
+ };
1581
+ formatDescription: (description: any, inline: any) => any;
1582
+ internalCase: typeof internalCase;
1583
+ classNameCase: typeof pascalCase;
1584
+ pascalCase: typeof pascalCase;
1585
+ getInlineParseContent: (schema: string, typeName: string | null, schemaPath: string[]) => Record<string, any>;
1586
+ getParseContent: (schema: string, typeName: string | null, schemaPath: string[]) => Record<string, any>;
1587
+ getComponentByRef: ($ref: string) => SchemaComponent | null;
1588
+ parseSchema: (schema: string, typeName?: string | null, schemaPath?: string[]) => ParsedSchema<SchemaTypeObjectContent | SchemaTypeEnumContent | SchemaTypePrimitiveContent>;
1589
+ checkAndAddNull: (schema: any, type: any) => any;
1590
+ safeAddNullToType: (schema: any, type: any) => any;
1591
+ isNeedToAddNull: (schema: any, type: any) => any;
1592
+ inlineExtraFormatters: {
1593
+ enum: (parsedSchema: any) => any;
1594
+ object: (parsedSchema: any) => any;
1595
+ };
1596
+ formatters: {
1597
+ enum: (parsedSchema: any) => any;
1598
+ object: (parsedSchema: any) => any;
1599
+ primitive: (parsedSchema: any) => any;
1600
+ };
1601
+ formatModelName: (name: string, options?: {
1602
+ type?: "enum-key" | "type-name";
1603
+ }) => string | undefined;
1604
+ fmtToJSDocLine: (line: string, {
1605
+ eol
1606
+ }: {
1607
+ eol?: boolean | undefined;
1608
+ }) => string;
1609
+ NameResolver: typeof NameResolver;
1610
+ _: lodash14.LoDashStatic;
1611
+ require: (packageOrPath: string) => Promise<any>;
1612
+ };
1613
+ };
1614
+ getTemplate: (name: string, fileName: string, path?: string) => string | undefined;
1615
+ renderTemplate: (template: string, configuration: object, options?: object) => string;
1616
+ createFile: ({
1617
+ path: path_,
1618
+ fileName,
1619
+ content,
1620
+ withPrefix
1621
+ }: {
1622
+ path: any;
1623
+ fileName: any;
1624
+ content: any;
1625
+ withPrefix: any;
1626
+ }) => void;
1627
+ formatTSContent: (code: string, {
1628
+ removeUnusedImports,
1629
+ format
1630
+ }?: {
1631
+ removeUnusedImports?: boolean | undefined;
1632
+ format?: boolean | undefined;
1633
+ }) => Promise<string>;
1634
+ }>;
1635
+
1636
+ //#endregion
1637
+ export { constants_d_exports as constants, generateApi, generateTemplates };
1638
+ //# sourceMappingURL=lib.d.cts.map