@blimu/codegen 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +142 -0
- package/dist/generator/typescript/templates/README.md.hbs +123 -0
- package/dist/generator/typescript/templates/client.ts.hbs +380 -0
- package/dist/generator/typescript/templates/index.ts.hbs +67 -0
- package/dist/generator/typescript/templates/package.json.hbs +48 -0
- package/dist/generator/typescript/templates/schema.ts.hbs +76 -0
- package/dist/generator/typescript/templates/schema.zod.ts.hbs +126 -0
- package/dist/generator/typescript/templates/service.ts.hbs +107 -0
- package/dist/generator/typescript/templates/tsconfig.json.hbs +28 -0
- package/dist/generator/typescript/templates/utils.ts.hbs +168 -0
- package/dist/index.d.mts +309 -0
- package/dist/index.d.ts +309 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +7 -0
- package/dist/index.mjs.map +1 -0
- package/dist/main.js +8 -0
- package/dist/main.js.map +1 -0
- package/package.json +68 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';
|
|
3
|
+
|
|
4
|
+
type OperationIdParser = (operationId: string, method: string, path: string) => string | Promise<string>;
|
|
5
|
+
declare const TypeAugmentationOptionsSchema: z.ZodObject<{
|
|
6
|
+
moduleName: z.ZodOptional<z.ZodString>;
|
|
7
|
+
namespace: z.ZodOptional<z.ZodString>;
|
|
8
|
+
typeNames: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
9
|
+
outputFileName: z.ZodOptional<z.ZodString>;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
declare const TYPESCRIPT_TEMPLATE_NAMES: readonly ["client.ts.hbs", "index.ts.hbs", "package.json.hbs", "README.md.hbs", "schema.ts.hbs", "schema.zod.ts.hbs", "service.ts.hbs", "tsconfig.json.hbs", "utils.ts.hbs"];
|
|
12
|
+
type TypeScriptTemplateName = (typeof TYPESCRIPT_TEMPLATE_NAMES)[number];
|
|
13
|
+
declare const TypeScriptClientSchema: z.ZodObject<{
|
|
14
|
+
outDir: z.ZodString;
|
|
15
|
+
name: z.ZodString;
|
|
16
|
+
includeTags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
17
|
+
excludeTags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
18
|
+
operationIdParser: z.ZodOptional<z.ZodCustom<OperationIdParser, OperationIdParser>>;
|
|
19
|
+
preCommand: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
20
|
+
postCommand: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
21
|
+
defaultBaseURL: z.ZodOptional<z.ZodString>;
|
|
22
|
+
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
23
|
+
typeAugmentation: z.ZodOptional<z.ZodObject<{
|
|
24
|
+
moduleName: z.ZodOptional<z.ZodString>;
|
|
25
|
+
namespace: z.ZodOptional<z.ZodString>;
|
|
26
|
+
typeNames: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
27
|
+
outputFileName: z.ZodOptional<z.ZodString>;
|
|
28
|
+
}, z.core.$strip>>;
|
|
29
|
+
type: z.ZodLiteral<"typescript">;
|
|
30
|
+
packageName: z.ZodString;
|
|
31
|
+
moduleName: z.ZodOptional<z.ZodString>;
|
|
32
|
+
includeQueryKeys: z.ZodOptional<z.ZodBoolean>;
|
|
33
|
+
templates: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
declare const ClientSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
36
|
+
outDir: z.ZodString;
|
|
37
|
+
name: z.ZodString;
|
|
38
|
+
includeTags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
39
|
+
excludeTags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
40
|
+
operationIdParser: z.ZodOptional<z.ZodCustom<OperationIdParser, OperationIdParser>>;
|
|
41
|
+
preCommand: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
42
|
+
postCommand: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
43
|
+
defaultBaseURL: z.ZodOptional<z.ZodString>;
|
|
44
|
+
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
45
|
+
typeAugmentation: z.ZodOptional<z.ZodObject<{
|
|
46
|
+
moduleName: z.ZodOptional<z.ZodString>;
|
|
47
|
+
namespace: z.ZodOptional<z.ZodString>;
|
|
48
|
+
typeNames: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
49
|
+
outputFileName: z.ZodOptional<z.ZodString>;
|
|
50
|
+
}, z.core.$strip>>;
|
|
51
|
+
type: z.ZodLiteral<"typescript">;
|
|
52
|
+
packageName: z.ZodString;
|
|
53
|
+
moduleName: z.ZodOptional<z.ZodString>;
|
|
54
|
+
includeQueryKeys: z.ZodOptional<z.ZodBoolean>;
|
|
55
|
+
templates: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
56
|
+
}, z.core.$strip>], "type">;
|
|
57
|
+
declare const ConfigSchema: z.ZodObject<{
|
|
58
|
+
spec: z.ZodString;
|
|
59
|
+
name: z.ZodOptional<z.ZodString>;
|
|
60
|
+
clients: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
61
|
+
outDir: z.ZodString;
|
|
62
|
+
name: z.ZodString;
|
|
63
|
+
includeTags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
64
|
+
excludeTags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
65
|
+
operationIdParser: z.ZodOptional<z.ZodCustom<OperationIdParser, OperationIdParser>>;
|
|
66
|
+
preCommand: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
67
|
+
postCommand: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
68
|
+
defaultBaseURL: z.ZodOptional<z.ZodString>;
|
|
69
|
+
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
70
|
+
typeAugmentation: z.ZodOptional<z.ZodObject<{
|
|
71
|
+
moduleName: z.ZodOptional<z.ZodString>;
|
|
72
|
+
namespace: z.ZodOptional<z.ZodString>;
|
|
73
|
+
typeNames: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
74
|
+
outputFileName: z.ZodOptional<z.ZodString>;
|
|
75
|
+
}, z.core.$strip>>;
|
|
76
|
+
type: z.ZodLiteral<"typescript">;
|
|
77
|
+
packageName: z.ZodString;
|
|
78
|
+
moduleName: z.ZodOptional<z.ZodString>;
|
|
79
|
+
includeQueryKeys: z.ZodOptional<z.ZodBoolean>;
|
|
80
|
+
templates: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
81
|
+
}, z.core.$strip>], "type">>;
|
|
82
|
+
}, z.core.$strip>;
|
|
83
|
+
type Config = z.infer<typeof ConfigSchema>;
|
|
84
|
+
type Client = z.infer<typeof ClientSchema>;
|
|
85
|
+
type TypeScriptClient = z.infer<typeof TypeScriptClientSchema>;
|
|
86
|
+
type TypeAugmentationOptions = z.infer<typeof TypeAugmentationOptionsSchema>;
|
|
87
|
+
|
|
88
|
+
declare class ConfigService {
|
|
89
|
+
private readonly logger;
|
|
90
|
+
private readonly DEFAULT_CONFIG_FILE;
|
|
91
|
+
findDefaultConfig(): Promise<string | null>;
|
|
92
|
+
load(configPath: string): Promise<Config>;
|
|
93
|
+
private normalizePaths;
|
|
94
|
+
private isUrl;
|
|
95
|
+
getPreCommand(client: Client): string[];
|
|
96
|
+
getPostCommand(client: Client): string[];
|
|
97
|
+
shouldExcludeFile(client: Client, targetPath: string): boolean;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
declare class ConfigModule {
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
declare function defineConfig(config: Config): Config;
|
|
104
|
+
|
|
105
|
+
declare function loadMjsConfig(configPath: string): Promise<Config>;
|
|
106
|
+
|
|
107
|
+
declare enum IRSchemaKind {
|
|
108
|
+
Unknown = "unknown",
|
|
109
|
+
String = "string",
|
|
110
|
+
Number = "number",
|
|
111
|
+
Integer = "integer",
|
|
112
|
+
Boolean = "boolean",
|
|
113
|
+
Null = "null",
|
|
114
|
+
Array = "array",
|
|
115
|
+
Object = "object",
|
|
116
|
+
Enum = "enum",
|
|
117
|
+
Ref = "ref",
|
|
118
|
+
OneOf = "oneOf",
|
|
119
|
+
AnyOf = "anyOf",
|
|
120
|
+
AllOf = "allOf",
|
|
121
|
+
Not = "not"
|
|
122
|
+
}
|
|
123
|
+
interface IROperation {
|
|
124
|
+
operationID: string;
|
|
125
|
+
method: string;
|
|
126
|
+
path: string;
|
|
127
|
+
tag: string;
|
|
128
|
+
originalTags: string[];
|
|
129
|
+
summary: string;
|
|
130
|
+
description: string;
|
|
131
|
+
deprecated: boolean;
|
|
132
|
+
pathParams: IRParam[];
|
|
133
|
+
queryParams: IRParam[];
|
|
134
|
+
requestBody: IRRequestBody | null;
|
|
135
|
+
response: IRResponse;
|
|
136
|
+
}
|
|
137
|
+
interface IRService {
|
|
138
|
+
tag: string;
|
|
139
|
+
operations: IROperation[];
|
|
140
|
+
}
|
|
141
|
+
interface IR {
|
|
142
|
+
services: IRService[];
|
|
143
|
+
models: IRModel[];
|
|
144
|
+
securitySchemes: IRSecurityScheme[];
|
|
145
|
+
modelDefs: IRModelDef[];
|
|
146
|
+
}
|
|
147
|
+
interface IRParam {
|
|
148
|
+
name: string;
|
|
149
|
+
required: boolean;
|
|
150
|
+
schema: IRSchema;
|
|
151
|
+
description: string;
|
|
152
|
+
}
|
|
153
|
+
interface IRRequestBody {
|
|
154
|
+
contentType: string;
|
|
155
|
+
typeTS: string;
|
|
156
|
+
required: boolean;
|
|
157
|
+
schema: IRSchema;
|
|
158
|
+
}
|
|
159
|
+
interface IRResponse {
|
|
160
|
+
typeTS: string;
|
|
161
|
+
schema: IRSchema;
|
|
162
|
+
description: string;
|
|
163
|
+
isStreaming: boolean;
|
|
164
|
+
contentType: string;
|
|
165
|
+
streamingFormat?: "sse" | "ndjson" | "chunked";
|
|
166
|
+
}
|
|
167
|
+
interface IRModel {
|
|
168
|
+
name: string;
|
|
169
|
+
decl: string;
|
|
170
|
+
}
|
|
171
|
+
interface IRModelDef {
|
|
172
|
+
name: string;
|
|
173
|
+
schema: IRSchema;
|
|
174
|
+
annotations: IRAnnotations;
|
|
175
|
+
}
|
|
176
|
+
interface IRAnnotations {
|
|
177
|
+
title?: string;
|
|
178
|
+
description?: string;
|
|
179
|
+
deprecated?: boolean;
|
|
180
|
+
readOnly?: boolean;
|
|
181
|
+
writeOnly?: boolean;
|
|
182
|
+
default?: any;
|
|
183
|
+
examples?: any[];
|
|
184
|
+
}
|
|
185
|
+
interface IRSchema {
|
|
186
|
+
kind: IRSchemaKind;
|
|
187
|
+
nullable: boolean;
|
|
188
|
+
format?: string;
|
|
189
|
+
properties?: IRField[];
|
|
190
|
+
additionalProperties?: IRSchema;
|
|
191
|
+
items?: IRSchema;
|
|
192
|
+
enumValues?: string[];
|
|
193
|
+
enumRaw?: any[];
|
|
194
|
+
enumBase?: IRSchemaKind;
|
|
195
|
+
ref?: string;
|
|
196
|
+
oneOf?: IRSchema[];
|
|
197
|
+
anyOf?: IRSchema[];
|
|
198
|
+
allOf?: IRSchema[];
|
|
199
|
+
not?: IRSchema;
|
|
200
|
+
discriminator?: IRDiscriminator;
|
|
201
|
+
}
|
|
202
|
+
interface IRField {
|
|
203
|
+
name: string;
|
|
204
|
+
type: IRSchema;
|
|
205
|
+
required: boolean;
|
|
206
|
+
annotations: IRAnnotations;
|
|
207
|
+
}
|
|
208
|
+
interface IRDiscriminator {
|
|
209
|
+
propertyName: string;
|
|
210
|
+
mapping?: Record<string, string>;
|
|
211
|
+
}
|
|
212
|
+
interface IRSecurityScheme {
|
|
213
|
+
key: string;
|
|
214
|
+
type: string;
|
|
215
|
+
scheme?: string;
|
|
216
|
+
in?: string;
|
|
217
|
+
name?: string;
|
|
218
|
+
bearerFormat?: string;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
interface Generator<TClient extends Client = Client> {
|
|
222
|
+
getType(): string;
|
|
223
|
+
generate(client: TClient, ir: IR): Promise<void>;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
type OpenAPIDocument = OpenAPIV3.Document | OpenAPIV3_1.Document;
|
|
227
|
+
|
|
228
|
+
declare class SchemaConverterService {
|
|
229
|
+
schemaRefToIR(doc: OpenAPIDocument, schemaRef: OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject | OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.SchemaObject | undefined): IRSchema;
|
|
230
|
+
extractAnnotations(schemaRef: OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject | OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.SchemaObject | undefined): IRAnnotations;
|
|
231
|
+
private inferEnumBaseKind;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
declare class IrBuilderService {
|
|
235
|
+
private readonly schemaConverter;
|
|
236
|
+
constructor(schemaConverter: SchemaConverterService);
|
|
237
|
+
buildIR(doc: OpenAPIDocument): IR;
|
|
238
|
+
filterIR(fullIR: IR, client: Client): IR;
|
|
239
|
+
private detectStreamingContentType;
|
|
240
|
+
private collectTags;
|
|
241
|
+
private compileTagFilters;
|
|
242
|
+
private shouldIncludeOperation;
|
|
243
|
+
private buildIRFromDoc;
|
|
244
|
+
private deriveMethodName;
|
|
245
|
+
private firstAllowedTag;
|
|
246
|
+
private collectSecuritySchemes;
|
|
247
|
+
private collectParams;
|
|
248
|
+
private extractRequestBodyWithTypes;
|
|
249
|
+
private extractRequestBody;
|
|
250
|
+
private extractResponseWithTypes;
|
|
251
|
+
private extractResponse;
|
|
252
|
+
private buildStructuredModels;
|
|
253
|
+
private filterUnusedModelDefs;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
declare class OpenApiService {
|
|
257
|
+
private readonly logger;
|
|
258
|
+
loadDocument(input: string): Promise<OpenAPIDocument>;
|
|
259
|
+
validateDocument(input: string): Promise<void>;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
declare class GeneratorService {
|
|
263
|
+
private readonly irBuilder;
|
|
264
|
+
private readonly openApiService;
|
|
265
|
+
private readonly logger;
|
|
266
|
+
private readonly generators;
|
|
267
|
+
constructor(irBuilder: IrBuilderService, openApiService: OpenApiService);
|
|
268
|
+
register<TClient extends Client>(generator: Generator<TClient>): void;
|
|
269
|
+
getGenerator(type: string): Generator | undefined;
|
|
270
|
+
getAvailableTypes(): string[];
|
|
271
|
+
generate(spec: string, client: Client): Promise<void>;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
declare class TypeScriptGeneratorService implements Generator<TypeScriptClient> {
|
|
275
|
+
private readonly configService;
|
|
276
|
+
private readonly logger;
|
|
277
|
+
constructor(configService: ConfigService);
|
|
278
|
+
getType(): string;
|
|
279
|
+
generate(client: TypeScriptClient, ir: IR): Promise<void>;
|
|
280
|
+
private preprocessIR;
|
|
281
|
+
private registerHandlebarsHelpers;
|
|
282
|
+
private renderTemplate;
|
|
283
|
+
private generateClient;
|
|
284
|
+
private generateIndex;
|
|
285
|
+
private generateUtils;
|
|
286
|
+
private generateServices;
|
|
287
|
+
private generateSchema;
|
|
288
|
+
private generateZodSchema;
|
|
289
|
+
private generatePackageJson;
|
|
290
|
+
private generateTsConfig;
|
|
291
|
+
private generateReadme;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
declare class GeneratorModule {
|
|
295
|
+
private readonly generatorService;
|
|
296
|
+
private readonly typeScriptGenerator;
|
|
297
|
+
constructor(generatorService: GeneratorService, typeScriptGenerator: TypeScriptGeneratorService);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
declare class OpenApiModule {
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
interface GenerateOptions {
|
|
304
|
+
client?: string;
|
|
305
|
+
}
|
|
306
|
+
declare function generate(configOrPath: Config | string, options?: GenerateOptions): Promise<void>;
|
|
307
|
+
declare function loadConfig(configPath: string): Promise<Config>;
|
|
308
|
+
|
|
309
|
+
export { type Client, ClientSchema, type Config, ConfigModule, ConfigSchema, ConfigService, type GenerateOptions, type Generator, GeneratorModule, GeneratorService, type IR, type IRAnnotations, type IRDiscriminator, type IRField, type IRModel, type IRModelDef, type IROperation, type IRParam, type IRRequestBody, type IRResponse, type IRSchema, IRSchemaKind, type IRSecurityScheme, type IRService, OpenApiModule, OpenApiService, type OperationIdParser, TYPESCRIPT_TEMPLATE_NAMES, type TypeAugmentationOptions, TypeAugmentationOptionsSchema, type TypeScriptClient, TypeScriptClientSchema, type TypeScriptTemplateName, defineConfig, generate, loadConfig, loadMjsConfig };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';
|
|
3
|
+
|
|
4
|
+
type OperationIdParser = (operationId: string, method: string, path: string) => string | Promise<string>;
|
|
5
|
+
declare const TypeAugmentationOptionsSchema: z.ZodObject<{
|
|
6
|
+
moduleName: z.ZodOptional<z.ZodString>;
|
|
7
|
+
namespace: z.ZodOptional<z.ZodString>;
|
|
8
|
+
typeNames: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
9
|
+
outputFileName: z.ZodOptional<z.ZodString>;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
declare const TYPESCRIPT_TEMPLATE_NAMES: readonly ["client.ts.hbs", "index.ts.hbs", "package.json.hbs", "README.md.hbs", "schema.ts.hbs", "schema.zod.ts.hbs", "service.ts.hbs", "tsconfig.json.hbs", "utils.ts.hbs"];
|
|
12
|
+
type TypeScriptTemplateName = (typeof TYPESCRIPT_TEMPLATE_NAMES)[number];
|
|
13
|
+
declare const TypeScriptClientSchema: z.ZodObject<{
|
|
14
|
+
outDir: z.ZodString;
|
|
15
|
+
name: z.ZodString;
|
|
16
|
+
includeTags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
17
|
+
excludeTags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
18
|
+
operationIdParser: z.ZodOptional<z.ZodCustom<OperationIdParser, OperationIdParser>>;
|
|
19
|
+
preCommand: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
20
|
+
postCommand: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
21
|
+
defaultBaseURL: z.ZodOptional<z.ZodString>;
|
|
22
|
+
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
23
|
+
typeAugmentation: z.ZodOptional<z.ZodObject<{
|
|
24
|
+
moduleName: z.ZodOptional<z.ZodString>;
|
|
25
|
+
namespace: z.ZodOptional<z.ZodString>;
|
|
26
|
+
typeNames: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
27
|
+
outputFileName: z.ZodOptional<z.ZodString>;
|
|
28
|
+
}, z.core.$strip>>;
|
|
29
|
+
type: z.ZodLiteral<"typescript">;
|
|
30
|
+
packageName: z.ZodString;
|
|
31
|
+
moduleName: z.ZodOptional<z.ZodString>;
|
|
32
|
+
includeQueryKeys: z.ZodOptional<z.ZodBoolean>;
|
|
33
|
+
templates: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
declare const ClientSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
36
|
+
outDir: z.ZodString;
|
|
37
|
+
name: z.ZodString;
|
|
38
|
+
includeTags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
39
|
+
excludeTags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
40
|
+
operationIdParser: z.ZodOptional<z.ZodCustom<OperationIdParser, OperationIdParser>>;
|
|
41
|
+
preCommand: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
42
|
+
postCommand: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
43
|
+
defaultBaseURL: z.ZodOptional<z.ZodString>;
|
|
44
|
+
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
45
|
+
typeAugmentation: z.ZodOptional<z.ZodObject<{
|
|
46
|
+
moduleName: z.ZodOptional<z.ZodString>;
|
|
47
|
+
namespace: z.ZodOptional<z.ZodString>;
|
|
48
|
+
typeNames: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
49
|
+
outputFileName: z.ZodOptional<z.ZodString>;
|
|
50
|
+
}, z.core.$strip>>;
|
|
51
|
+
type: z.ZodLiteral<"typescript">;
|
|
52
|
+
packageName: z.ZodString;
|
|
53
|
+
moduleName: z.ZodOptional<z.ZodString>;
|
|
54
|
+
includeQueryKeys: z.ZodOptional<z.ZodBoolean>;
|
|
55
|
+
templates: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
56
|
+
}, z.core.$strip>], "type">;
|
|
57
|
+
declare const ConfigSchema: z.ZodObject<{
|
|
58
|
+
spec: z.ZodString;
|
|
59
|
+
name: z.ZodOptional<z.ZodString>;
|
|
60
|
+
clients: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
61
|
+
outDir: z.ZodString;
|
|
62
|
+
name: z.ZodString;
|
|
63
|
+
includeTags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
64
|
+
excludeTags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
65
|
+
operationIdParser: z.ZodOptional<z.ZodCustom<OperationIdParser, OperationIdParser>>;
|
|
66
|
+
preCommand: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
67
|
+
postCommand: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
68
|
+
defaultBaseURL: z.ZodOptional<z.ZodString>;
|
|
69
|
+
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
70
|
+
typeAugmentation: z.ZodOptional<z.ZodObject<{
|
|
71
|
+
moduleName: z.ZodOptional<z.ZodString>;
|
|
72
|
+
namespace: z.ZodOptional<z.ZodString>;
|
|
73
|
+
typeNames: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
74
|
+
outputFileName: z.ZodOptional<z.ZodString>;
|
|
75
|
+
}, z.core.$strip>>;
|
|
76
|
+
type: z.ZodLiteral<"typescript">;
|
|
77
|
+
packageName: z.ZodString;
|
|
78
|
+
moduleName: z.ZodOptional<z.ZodString>;
|
|
79
|
+
includeQueryKeys: z.ZodOptional<z.ZodBoolean>;
|
|
80
|
+
templates: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
81
|
+
}, z.core.$strip>], "type">>;
|
|
82
|
+
}, z.core.$strip>;
|
|
83
|
+
type Config = z.infer<typeof ConfigSchema>;
|
|
84
|
+
type Client = z.infer<typeof ClientSchema>;
|
|
85
|
+
type TypeScriptClient = z.infer<typeof TypeScriptClientSchema>;
|
|
86
|
+
type TypeAugmentationOptions = z.infer<typeof TypeAugmentationOptionsSchema>;
|
|
87
|
+
|
|
88
|
+
declare class ConfigService {
|
|
89
|
+
private readonly logger;
|
|
90
|
+
private readonly DEFAULT_CONFIG_FILE;
|
|
91
|
+
findDefaultConfig(): Promise<string | null>;
|
|
92
|
+
load(configPath: string): Promise<Config>;
|
|
93
|
+
private normalizePaths;
|
|
94
|
+
private isUrl;
|
|
95
|
+
getPreCommand(client: Client): string[];
|
|
96
|
+
getPostCommand(client: Client): string[];
|
|
97
|
+
shouldExcludeFile(client: Client, targetPath: string): boolean;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
declare class ConfigModule {
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
declare function defineConfig(config: Config): Config;
|
|
104
|
+
|
|
105
|
+
declare function loadMjsConfig(configPath: string): Promise<Config>;
|
|
106
|
+
|
|
107
|
+
declare enum IRSchemaKind {
|
|
108
|
+
Unknown = "unknown",
|
|
109
|
+
String = "string",
|
|
110
|
+
Number = "number",
|
|
111
|
+
Integer = "integer",
|
|
112
|
+
Boolean = "boolean",
|
|
113
|
+
Null = "null",
|
|
114
|
+
Array = "array",
|
|
115
|
+
Object = "object",
|
|
116
|
+
Enum = "enum",
|
|
117
|
+
Ref = "ref",
|
|
118
|
+
OneOf = "oneOf",
|
|
119
|
+
AnyOf = "anyOf",
|
|
120
|
+
AllOf = "allOf",
|
|
121
|
+
Not = "not"
|
|
122
|
+
}
|
|
123
|
+
interface IROperation {
|
|
124
|
+
operationID: string;
|
|
125
|
+
method: string;
|
|
126
|
+
path: string;
|
|
127
|
+
tag: string;
|
|
128
|
+
originalTags: string[];
|
|
129
|
+
summary: string;
|
|
130
|
+
description: string;
|
|
131
|
+
deprecated: boolean;
|
|
132
|
+
pathParams: IRParam[];
|
|
133
|
+
queryParams: IRParam[];
|
|
134
|
+
requestBody: IRRequestBody | null;
|
|
135
|
+
response: IRResponse;
|
|
136
|
+
}
|
|
137
|
+
interface IRService {
|
|
138
|
+
tag: string;
|
|
139
|
+
operations: IROperation[];
|
|
140
|
+
}
|
|
141
|
+
interface IR {
|
|
142
|
+
services: IRService[];
|
|
143
|
+
models: IRModel[];
|
|
144
|
+
securitySchemes: IRSecurityScheme[];
|
|
145
|
+
modelDefs: IRModelDef[];
|
|
146
|
+
}
|
|
147
|
+
interface IRParam {
|
|
148
|
+
name: string;
|
|
149
|
+
required: boolean;
|
|
150
|
+
schema: IRSchema;
|
|
151
|
+
description: string;
|
|
152
|
+
}
|
|
153
|
+
interface IRRequestBody {
|
|
154
|
+
contentType: string;
|
|
155
|
+
typeTS: string;
|
|
156
|
+
required: boolean;
|
|
157
|
+
schema: IRSchema;
|
|
158
|
+
}
|
|
159
|
+
interface IRResponse {
|
|
160
|
+
typeTS: string;
|
|
161
|
+
schema: IRSchema;
|
|
162
|
+
description: string;
|
|
163
|
+
isStreaming: boolean;
|
|
164
|
+
contentType: string;
|
|
165
|
+
streamingFormat?: "sse" | "ndjson" | "chunked";
|
|
166
|
+
}
|
|
167
|
+
interface IRModel {
|
|
168
|
+
name: string;
|
|
169
|
+
decl: string;
|
|
170
|
+
}
|
|
171
|
+
interface IRModelDef {
|
|
172
|
+
name: string;
|
|
173
|
+
schema: IRSchema;
|
|
174
|
+
annotations: IRAnnotations;
|
|
175
|
+
}
|
|
176
|
+
interface IRAnnotations {
|
|
177
|
+
title?: string;
|
|
178
|
+
description?: string;
|
|
179
|
+
deprecated?: boolean;
|
|
180
|
+
readOnly?: boolean;
|
|
181
|
+
writeOnly?: boolean;
|
|
182
|
+
default?: any;
|
|
183
|
+
examples?: any[];
|
|
184
|
+
}
|
|
185
|
+
interface IRSchema {
|
|
186
|
+
kind: IRSchemaKind;
|
|
187
|
+
nullable: boolean;
|
|
188
|
+
format?: string;
|
|
189
|
+
properties?: IRField[];
|
|
190
|
+
additionalProperties?: IRSchema;
|
|
191
|
+
items?: IRSchema;
|
|
192
|
+
enumValues?: string[];
|
|
193
|
+
enumRaw?: any[];
|
|
194
|
+
enumBase?: IRSchemaKind;
|
|
195
|
+
ref?: string;
|
|
196
|
+
oneOf?: IRSchema[];
|
|
197
|
+
anyOf?: IRSchema[];
|
|
198
|
+
allOf?: IRSchema[];
|
|
199
|
+
not?: IRSchema;
|
|
200
|
+
discriminator?: IRDiscriminator;
|
|
201
|
+
}
|
|
202
|
+
interface IRField {
|
|
203
|
+
name: string;
|
|
204
|
+
type: IRSchema;
|
|
205
|
+
required: boolean;
|
|
206
|
+
annotations: IRAnnotations;
|
|
207
|
+
}
|
|
208
|
+
interface IRDiscriminator {
|
|
209
|
+
propertyName: string;
|
|
210
|
+
mapping?: Record<string, string>;
|
|
211
|
+
}
|
|
212
|
+
interface IRSecurityScheme {
|
|
213
|
+
key: string;
|
|
214
|
+
type: string;
|
|
215
|
+
scheme?: string;
|
|
216
|
+
in?: string;
|
|
217
|
+
name?: string;
|
|
218
|
+
bearerFormat?: string;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
interface Generator<TClient extends Client = Client> {
|
|
222
|
+
getType(): string;
|
|
223
|
+
generate(client: TClient, ir: IR): Promise<void>;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
type OpenAPIDocument = OpenAPIV3.Document | OpenAPIV3_1.Document;
|
|
227
|
+
|
|
228
|
+
declare class SchemaConverterService {
|
|
229
|
+
schemaRefToIR(doc: OpenAPIDocument, schemaRef: OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject | OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.SchemaObject | undefined): IRSchema;
|
|
230
|
+
extractAnnotations(schemaRef: OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject | OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.SchemaObject | undefined): IRAnnotations;
|
|
231
|
+
private inferEnumBaseKind;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
declare class IrBuilderService {
|
|
235
|
+
private readonly schemaConverter;
|
|
236
|
+
constructor(schemaConverter: SchemaConverterService);
|
|
237
|
+
buildIR(doc: OpenAPIDocument): IR;
|
|
238
|
+
filterIR(fullIR: IR, client: Client): IR;
|
|
239
|
+
private detectStreamingContentType;
|
|
240
|
+
private collectTags;
|
|
241
|
+
private compileTagFilters;
|
|
242
|
+
private shouldIncludeOperation;
|
|
243
|
+
private buildIRFromDoc;
|
|
244
|
+
private deriveMethodName;
|
|
245
|
+
private firstAllowedTag;
|
|
246
|
+
private collectSecuritySchemes;
|
|
247
|
+
private collectParams;
|
|
248
|
+
private extractRequestBodyWithTypes;
|
|
249
|
+
private extractRequestBody;
|
|
250
|
+
private extractResponseWithTypes;
|
|
251
|
+
private extractResponse;
|
|
252
|
+
private buildStructuredModels;
|
|
253
|
+
private filterUnusedModelDefs;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
declare class OpenApiService {
|
|
257
|
+
private readonly logger;
|
|
258
|
+
loadDocument(input: string): Promise<OpenAPIDocument>;
|
|
259
|
+
validateDocument(input: string): Promise<void>;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
declare class GeneratorService {
|
|
263
|
+
private readonly irBuilder;
|
|
264
|
+
private readonly openApiService;
|
|
265
|
+
private readonly logger;
|
|
266
|
+
private readonly generators;
|
|
267
|
+
constructor(irBuilder: IrBuilderService, openApiService: OpenApiService);
|
|
268
|
+
register<TClient extends Client>(generator: Generator<TClient>): void;
|
|
269
|
+
getGenerator(type: string): Generator | undefined;
|
|
270
|
+
getAvailableTypes(): string[];
|
|
271
|
+
generate(spec: string, client: Client): Promise<void>;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
declare class TypeScriptGeneratorService implements Generator<TypeScriptClient> {
|
|
275
|
+
private readonly configService;
|
|
276
|
+
private readonly logger;
|
|
277
|
+
constructor(configService: ConfigService);
|
|
278
|
+
getType(): string;
|
|
279
|
+
generate(client: TypeScriptClient, ir: IR): Promise<void>;
|
|
280
|
+
private preprocessIR;
|
|
281
|
+
private registerHandlebarsHelpers;
|
|
282
|
+
private renderTemplate;
|
|
283
|
+
private generateClient;
|
|
284
|
+
private generateIndex;
|
|
285
|
+
private generateUtils;
|
|
286
|
+
private generateServices;
|
|
287
|
+
private generateSchema;
|
|
288
|
+
private generateZodSchema;
|
|
289
|
+
private generatePackageJson;
|
|
290
|
+
private generateTsConfig;
|
|
291
|
+
private generateReadme;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
declare class GeneratorModule {
|
|
295
|
+
private readonly generatorService;
|
|
296
|
+
private readonly typeScriptGenerator;
|
|
297
|
+
constructor(generatorService: GeneratorService, typeScriptGenerator: TypeScriptGeneratorService);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
declare class OpenApiModule {
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
interface GenerateOptions {
|
|
304
|
+
client?: string;
|
|
305
|
+
}
|
|
306
|
+
declare function generate(configOrPath: Config | string, options?: GenerateOptions): Promise<void>;
|
|
307
|
+
declare function loadConfig(configPath: string): Promise<Config>;
|
|
308
|
+
|
|
309
|
+
export { type Client, ClientSchema, type Config, ConfigModule, ConfigSchema, ConfigService, type GenerateOptions, type Generator, GeneratorModule, GeneratorService, type IR, type IRAnnotations, type IRDiscriminator, type IRField, type IRModel, type IRModelDef, type IROperation, type IRParam, type IRRequestBody, type IRResponse, type IRSchema, IRSchemaKind, type IRSecurityScheme, type IRService, OpenApiModule, OpenApiService, type OperationIdParser, TYPESCRIPT_TEMPLATE_NAMES, type TypeAugmentationOptions, TypeAugmentationOptionsSchema, type TypeScriptClient, TypeScriptClientSchema, type TypeScriptTemplateName, defineConfig, generate, loadConfig, loadMjsConfig };
|