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