@effect/openapi-generator 4.0.0-beta.9 → 4.0.0-beta.91
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/HttpApiTransformer.d.ts +41 -0
- package/dist/HttpApiTransformer.d.ts.map +1 -0
- package/dist/HttpApiTransformer.js +393 -0
- package/dist/HttpApiTransformer.js.map +1 -0
- package/dist/JsonSchemaGenerator.d.ts +25 -3
- package/dist/JsonSchemaGenerator.d.ts.map +1 -1
- package/dist/JsonSchemaGenerator.js +178 -47
- package/dist/JsonSchemaGenerator.js.map +1 -1
- package/dist/OpenApiGenerator.d.ts +81 -7
- package/dist/OpenApiGenerator.d.ts.map +1 -1
- package/dist/OpenApiGenerator.js +763 -119
- package/dist/OpenApiGenerator.js.map +1 -1
- package/dist/OpenApiPatch.d.ts +47 -24
- package/dist/OpenApiPatch.d.ts.map +1 -1
- package/dist/OpenApiPatch.js +42 -19
- package/dist/OpenApiPatch.js.map +1 -1
- package/dist/OpenApiTransformer.d.ts +85 -12
- package/dist/OpenApiTransformer.d.ts.map +1 -1
- package/dist/OpenApiTransformer.js +88 -11
- package/dist/OpenApiTransformer.js.map +1 -1
- package/dist/ParsedOperation.d.ts +184 -1
- package/dist/ParsedOperation.d.ts.map +1 -1
- package/dist/ParsedOperation.js +32 -0
- package/dist/ParsedOperation.js.map +1 -1
- package/dist/Utils.d.ts +51 -0
- package/dist/Utils.d.ts.map +1 -1
- package/dist/Utils.js +61 -0
- package/dist/Utils.js.map +1 -1
- package/dist/main.d.ts +12 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +41 -8
- package/dist/main.js.map +1 -1
- package/package.json +10 -8
- package/src/HttpApiTransformer.ts +552 -0
- package/src/JsonSchemaGenerator.ts +272 -47
- package/src/OpenApiGenerator.ts +1057 -165
- package/src/OpenApiPatch.ts +56 -31
- package/src/OpenApiTransformer.ts +92 -15
- package/src/ParsedOperation.ts +235 -1
- package/src/Utils.ts +61 -0
- package/src/main.ts +58 -10
|
@@ -1,8 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalized OpenAPI operation model shared by the generator pipeline.
|
|
3
|
+
*
|
|
4
|
+
* This module records the shape produced after an OpenAPI document is resolved
|
|
5
|
+
* into stable generator inputs: document metadata, tags, security schemes,
|
|
6
|
+
* per-operation parameters, request bodies, response media types, derived
|
|
7
|
+
* schema references, path templates, and streaming capabilities. Renderers
|
|
8
|
+
* consume this representation to emit HttpClient or HttpApi modules without
|
|
9
|
+
* reinterpreting raw OpenAPI path-item structures.
|
|
10
|
+
*
|
|
11
|
+
* @since 4.0.0
|
|
12
|
+
*/
|
|
1
13
|
import type * as Types from "effect/Types";
|
|
2
|
-
import type { OpenAPISpecMethodName } from "effect/unstable/httpapi/OpenApi";
|
|
14
|
+
import type { OpenAPISecurityRequirement, OpenAPISpecExternalDocs, OpenAPISpecLicense, OpenAPISpecMethodName, OpenAPISpecServer } from "effect/unstable/httpapi/OpenApi";
|
|
15
|
+
/**
|
|
16
|
+
* Root OpenAPI metadata preserved for generated client and HttpApi output.
|
|
17
|
+
*
|
|
18
|
+
* @category models
|
|
19
|
+
* @since 4.0.0
|
|
20
|
+
*/
|
|
21
|
+
export interface ParsedOpenApiMetadata {
|
|
22
|
+
readonly title: string;
|
|
23
|
+
readonly version: string;
|
|
24
|
+
readonly summary: string | undefined;
|
|
25
|
+
readonly description: string | undefined;
|
|
26
|
+
readonly license: OpenAPISpecLicense | undefined;
|
|
27
|
+
readonly servers: ReadonlyArray<OpenAPISpecServer> | undefined;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Tag metadata used to group and annotate generated operations.
|
|
31
|
+
*
|
|
32
|
+
* @category models
|
|
33
|
+
* @since 4.0.0
|
|
34
|
+
*/
|
|
35
|
+
export interface ParsedOpenApiTag {
|
|
36
|
+
readonly name: string;
|
|
37
|
+
readonly description: string | undefined;
|
|
38
|
+
readonly externalDocs: OpenAPISpecExternalDocs | undefined;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Supported security scheme extracted from an OpenAPI components section.
|
|
42
|
+
*
|
|
43
|
+
* @category models
|
|
44
|
+
* @since 4.0.0
|
|
45
|
+
*/
|
|
46
|
+
export interface ParsedOpenApiSecurityScheme {
|
|
47
|
+
readonly name: string;
|
|
48
|
+
readonly type: "basic" | "bearer" | "apiKey" | "http";
|
|
49
|
+
readonly description: string | undefined;
|
|
50
|
+
readonly bearerFormat: string | undefined;
|
|
51
|
+
readonly scheme: string | undefined;
|
|
52
|
+
readonly key: string | undefined;
|
|
53
|
+
readonly in: "header" | "query" | "cookie" | undefined;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Normalized OpenAPI document consumed by the generator renderers.
|
|
57
|
+
*
|
|
58
|
+
* @category models
|
|
59
|
+
* @since 4.0.0
|
|
60
|
+
*/
|
|
61
|
+
export interface ParsedOpenApi {
|
|
62
|
+
readonly metadata: ParsedOpenApiMetadata;
|
|
63
|
+
readonly tags: ReadonlyArray<ParsedOpenApiTag>;
|
|
64
|
+
readonly securitySchemes: ReadonlyArray<ParsedOpenApiSecurityScheme>;
|
|
65
|
+
readonly operations: ReadonlyArray<ParsedOperation>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Documentation and lifecycle metadata associated with an operation.
|
|
69
|
+
*
|
|
70
|
+
* @category models
|
|
71
|
+
* @since 4.0.0
|
|
72
|
+
*/
|
|
73
|
+
export interface ParsedOperationMetadata {
|
|
74
|
+
readonly summary: string | undefined;
|
|
75
|
+
readonly description: string | undefined;
|
|
76
|
+
readonly deprecated: boolean;
|
|
77
|
+
readonly externalDocs: OpenAPISpecExternalDocs | undefined;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Resolved OpenAPI parameter grouped by where it appears in the request.
|
|
81
|
+
*
|
|
82
|
+
* @category models
|
|
83
|
+
* @since 4.0.0
|
|
84
|
+
*/
|
|
85
|
+
export interface ParsedOperationParameter {
|
|
86
|
+
readonly name: string;
|
|
87
|
+
readonly in: "path" | "query" | "header" | "cookie";
|
|
88
|
+
readonly required: boolean;
|
|
89
|
+
readonly description: string | undefined;
|
|
90
|
+
readonly schema: {};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Summary of the request body declaration before per-media schemas are rendered.
|
|
94
|
+
*
|
|
95
|
+
* @category models
|
|
96
|
+
* @since 4.0.0
|
|
97
|
+
*/
|
|
98
|
+
export interface ParsedOperationRequestBody {
|
|
99
|
+
readonly required: boolean;
|
|
100
|
+
readonly contentTypes: Array<string>;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Encoding strategy the generator can use for a request or response media type.
|
|
104
|
+
*
|
|
105
|
+
* @category models
|
|
106
|
+
* @since 4.0.0
|
|
107
|
+
*/
|
|
108
|
+
export type ParsedOperationMediaTypeEncoding = "json" | "multipart" | "form-url-encoded" | "text" | "binary";
|
|
109
|
+
/**
|
|
110
|
+
* Media type whose schema can be represented in generated Effect code.
|
|
111
|
+
*
|
|
112
|
+
* @category models
|
|
113
|
+
* @since 4.0.0
|
|
114
|
+
*/
|
|
115
|
+
export type ParsedOperationMediaTypeSchema = {
|
|
116
|
+
readonly contentType: string;
|
|
117
|
+
readonly encoding: ParsedOperationMediaTypeEncoding;
|
|
118
|
+
readonly schema: string;
|
|
119
|
+
readonly effectStream?: undefined;
|
|
120
|
+
} | {
|
|
121
|
+
readonly contentType: string;
|
|
122
|
+
readonly encoding: "text";
|
|
123
|
+
readonly schema: string;
|
|
124
|
+
readonly effectStream: "sse";
|
|
125
|
+
readonly errorSchema: string;
|
|
126
|
+
} | {
|
|
127
|
+
readonly contentType: string;
|
|
128
|
+
readonly encoding: "binary";
|
|
129
|
+
readonly schema?: undefined;
|
|
130
|
+
readonly effectStream: "uint8array";
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Parsed response metadata together with generated schema references.
|
|
134
|
+
*
|
|
135
|
+
* @category models
|
|
136
|
+
* @since 4.0.0
|
|
137
|
+
*/
|
|
138
|
+
export interface ParsedOperationResponse {
|
|
139
|
+
readonly status: string;
|
|
140
|
+
readonly description: string | undefined;
|
|
141
|
+
readonly contentTypes: Array<string>;
|
|
142
|
+
readonly hasHeaders: boolean;
|
|
143
|
+
readonly isEmpty: boolean;
|
|
144
|
+
readonly representable: ReadonlyArray<ParsedOperationMediaTypeSchema>;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Resolved security requirement applied to a parsed operation.
|
|
148
|
+
*
|
|
149
|
+
* @category models
|
|
150
|
+
* @since 4.0.0
|
|
151
|
+
*/
|
|
152
|
+
export type ParsedOperationSecurityRequirement = Readonly<OpenAPISecurityRequirement>;
|
|
153
|
+
/**
|
|
154
|
+
* Normalized operation model shared by all OpenAPI generator backends.
|
|
155
|
+
*
|
|
156
|
+
* @category models
|
|
157
|
+
* @since 4.0.0
|
|
158
|
+
*/
|
|
3
159
|
export interface ParsedOperation {
|
|
4
160
|
readonly id: string;
|
|
161
|
+
readonly operationId: string | undefined;
|
|
162
|
+
readonly path: string;
|
|
5
163
|
readonly method: OpenAPISpecMethodName;
|
|
164
|
+
readonly tags: ReadonlyArray<string>;
|
|
165
|
+
readonly metadata: ParsedOperationMetadata;
|
|
166
|
+
readonly parameters: {
|
|
167
|
+
readonly path: ReadonlyArray<ParsedOperationParameter>;
|
|
168
|
+
readonly query: ReadonlyArray<ParsedOperationParameter>;
|
|
169
|
+
readonly header: ReadonlyArray<ParsedOperationParameter>;
|
|
170
|
+
readonly cookie: ReadonlyArray<ParsedOperationParameter>;
|
|
171
|
+
};
|
|
172
|
+
readonly requestBody: ParsedOperationRequestBody | undefined;
|
|
173
|
+
readonly responses: ReadonlyArray<ParsedOperationResponse>;
|
|
174
|
+
readonly defaultResponse: ParsedOperationResponse | undefined;
|
|
175
|
+
readonly effectiveSecurity: ReadonlyArray<ParsedOperationSecurityRequirement>;
|
|
6
176
|
readonly description: string | undefined;
|
|
7
177
|
readonly params?: string;
|
|
8
178
|
readonly paramsOptional: boolean;
|
|
@@ -11,6 +181,13 @@ export interface ParsedOperation {
|
|
|
11
181
|
readonly cookies: ReadonlyArray<string>;
|
|
12
182
|
readonly payload?: string;
|
|
13
183
|
readonly payloadFormData: boolean;
|
|
184
|
+
readonly payloadFormUrlEncoded: boolean;
|
|
185
|
+
readonly pathSchema: string | undefined;
|
|
186
|
+
readonly querySchema: string | undefined;
|
|
187
|
+
readonly querySchemaOptional: boolean;
|
|
188
|
+
readonly headersSchema: string | undefined;
|
|
189
|
+
readonly headersSchemaOptional: boolean;
|
|
190
|
+
readonly requestBodyRepresentable: ReadonlyArray<ParsedOperationMediaTypeSchema>;
|
|
14
191
|
readonly pathIds: ReadonlyArray<string>;
|
|
15
192
|
readonly pathTemplate: string;
|
|
16
193
|
readonly successSchemas: ReadonlyMap<string, string>;
|
|
@@ -19,6 +196,12 @@ export interface ParsedOperation {
|
|
|
19
196
|
readonly sseSchema?: string;
|
|
20
197
|
readonly binaryResponse: boolean;
|
|
21
198
|
}
|
|
199
|
+
/**
|
|
200
|
+
* Creates a mutable operation accumulator populated with parser defaults.
|
|
201
|
+
*
|
|
202
|
+
* @category constructors
|
|
203
|
+
* @since 4.0.0
|
|
204
|
+
*/
|
|
22
205
|
export declare const makeDeepMutable: (options: {
|
|
23
206
|
readonly id: string;
|
|
24
207
|
readonly method: OpenAPISpecMethodName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParsedOperation.d.ts","sourceRoot":"","sources":["../src/ParsedOperation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"ParsedOperation.d.ts","sourceRoot":"","sources":["../src/ParsedOperation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CA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IACrC,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1C,QAAQ,CAAC,qBAAqB,EAAE,OAAO,CAAA;IACvC,QAAQ,CAAC,wBAAwB,EAAE,aAAa,CAAC,8BAA8B,CAAC,CAAA;IAChF,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IACvC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,cAAc,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACpD,QAAQ,CAAC,YAAY,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAClD,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;IAEzC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAE3B,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAA;CACjC;AAED;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAI,SAAS;IACvC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAA;IACtC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IAC/B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;CACzC,KAAG,KAAK,CAAC,WAAW,CAAC,eAAe,CAqCnC,CAAA"}
|
package/dist/ParsedOperation.js
CHANGED
|
@@ -1,9 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a mutable operation accumulator populated with parser defaults.
|
|
3
|
+
*
|
|
4
|
+
* @category constructors
|
|
5
|
+
* @since 4.0.0
|
|
6
|
+
*/
|
|
1
7
|
export const makeDeepMutable = options => ({
|
|
2
8
|
...options,
|
|
9
|
+
operationId: undefined,
|
|
10
|
+
path: "",
|
|
11
|
+
tags: [],
|
|
12
|
+
metadata: {
|
|
13
|
+
summary: undefined,
|
|
14
|
+
description: options.description,
|
|
15
|
+
deprecated: false,
|
|
16
|
+
externalDocs: undefined
|
|
17
|
+
},
|
|
18
|
+
parameters: {
|
|
19
|
+
path: [],
|
|
20
|
+
query: [],
|
|
21
|
+
header: [],
|
|
22
|
+
cookie: []
|
|
23
|
+
},
|
|
24
|
+
requestBody: undefined,
|
|
25
|
+
responses: [],
|
|
26
|
+
defaultResponse: undefined,
|
|
27
|
+
effectiveSecurity: [],
|
|
3
28
|
urlParams: [],
|
|
4
29
|
headers: [],
|
|
5
30
|
cookies: [],
|
|
6
31
|
payloadFormData: false,
|
|
32
|
+
payloadFormUrlEncoded: false,
|
|
33
|
+
pathSchema: undefined,
|
|
34
|
+
querySchema: undefined,
|
|
35
|
+
querySchemaOptional: true,
|
|
36
|
+
headersSchema: undefined,
|
|
37
|
+
headersSchemaOptional: true,
|
|
38
|
+
requestBodyRepresentable: [],
|
|
7
39
|
successSchemas: new Map(),
|
|
8
40
|
errorSchemas: new Map(),
|
|
9
41
|
voidSchemas: new Set(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParsedOperation.js","names":["makeDeepMutable","options","urlParams","headers","cookies","payloadFormData","successSchemas","Map","errorSchemas","voidSchemas","Set","paramsOptional","binaryResponse"],"sources":["../src/ParsedOperation.ts"],"sourcesContent":[null],"mappings":"
|
|
1
|
+
{"version":3,"file":"ParsedOperation.js","names":["makeDeepMutable","options","operationId","undefined","path","tags","metadata","summary","description","deprecated","externalDocs","parameters","query","header","cookie","requestBody","responses","defaultResponse","effectiveSecurity","urlParams","headers","cookies","payloadFormData","payloadFormUrlEncoded","pathSchema","querySchema","querySchemaOptional","headersSchema","headersSchemaOptional","requestBodyRepresentable","successSchemas","Map","errorSchemas","voidSchemas","Set","paramsOptional","binaryResponse"],"sources":["../src/ParsedOperation.ts"],"sourcesContent":[null],"mappings":"AAmOA;;;;;;AAMA,OAAO,MAAMA,eAAe,GAAIC,OAM/B,KAA0C;EACzC,GAAGA,OAAO;EACVC,WAAW,EAAEC,SAAS;EACtBC,IAAI,EAAE,EAAE;EACRC,IAAI,EAAE,EAAE;EACRC,QAAQ,EAAE;IACRC,OAAO,EAAEJ,SAAS;IAClBK,WAAW,EAAEP,OAAO,CAACO,WAAW;IAChCC,UAAU,EAAE,KAAK;IACjBC,YAAY,EAAEP;GACf;EACDQ,UAAU,EAAE;IACVP,IAAI,EAAE,EAAE;IACRQ,KAAK,EAAE,EAAE;IACTC,MAAM,EAAE,EAAE;IACVC,MAAM,EAAE;GACT;EACDC,WAAW,EAAEZ,SAAS;EACtBa,SAAS,EAAE,EAAE;EACbC,eAAe,EAAEd,SAAS;EAC1Be,iBAAiB,EAAE,EAAE;EACrBC,SAAS,EAAE,EAAE;EACbC,OAAO,EAAE,EAAE;EACXC,OAAO,EAAE,EAAE;EACXC,eAAe,EAAE,KAAK;EACtBC,qBAAqB,EAAE,KAAK;EAC5BC,UAAU,EAAErB,SAAS;EACrBsB,WAAW,EAAEtB,SAAS;EACtBuB,mBAAmB,EAAE,IAAI;EACzBC,aAAa,EAAExB,SAAS;EACxByB,qBAAqB,EAAE,IAAI;EAC3BC,wBAAwB,EAAE,EAAE;EAC5BC,cAAc,EAAE,IAAIC,GAAG,EAAE;EACzBC,YAAY,EAAE,IAAID,GAAG,EAAE;EACvBE,WAAW,EAAE,IAAIC,GAAG,EAAE;EACtBC,cAAc,EAAE,IAAI;EACpBC,cAAc,EAAE;CACjB,CAAC","ignoreList":[]}
|
package/dist/Utils.d.ts
CHANGED
|
@@ -1,6 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts an OpenAPI name into the generator's camel-case form.
|
|
3
|
+
*
|
|
4
|
+
* **Details**
|
|
5
|
+
*
|
|
6
|
+
* Separators are removed, leading digits are ignored, and letters following a
|
|
7
|
+
* separator or digit are upper-cased without otherwise changing letter casing.
|
|
8
|
+
*
|
|
9
|
+
* @category converting
|
|
10
|
+
* @since 4.0.0
|
|
11
|
+
*/
|
|
1
12
|
export declare const camelize: (self: string) => string;
|
|
13
|
+
/**
|
|
14
|
+
* Converts an OpenAPI operation id into the exported operation identifier used
|
|
15
|
+
* by generated TypeScript modules.
|
|
16
|
+
*
|
|
17
|
+
* @category converting
|
|
18
|
+
* @since 4.0.0
|
|
19
|
+
*/
|
|
2
20
|
export declare const identifier: (operationId: string) => Capitalize<string>;
|
|
21
|
+
/**
|
|
22
|
+
* Extracts a trimmed, non-empty string from an unknown value.
|
|
23
|
+
*
|
|
24
|
+
* **Details**
|
|
25
|
+
*
|
|
26
|
+
* Returns `undefined` for non-string values and for strings containing only
|
|
27
|
+
* whitespace.
|
|
28
|
+
*
|
|
29
|
+
* @category filtering
|
|
30
|
+
* @since 4.0.0
|
|
31
|
+
*/
|
|
3
32
|
export declare const nonEmptyString: (a: unknown) => string | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Renders an optional description as a JSDoc block for generated TypeScript.
|
|
35
|
+
*
|
|
36
|
+
* **Details**
|
|
37
|
+
*
|
|
38
|
+
* Returns an empty string when the description is absent and escapes any
|
|
39
|
+
* closing comment marker so generated source remains syntactically valid.
|
|
40
|
+
*
|
|
41
|
+
* @category converting
|
|
42
|
+
* @since 4.0.0
|
|
43
|
+
*/
|
|
4
44
|
export declare const toComment: (self: string | undefined) => string;
|
|
45
|
+
/**
|
|
46
|
+
* Appends every element from `source` into `destination` in order.
|
|
47
|
+
*
|
|
48
|
+
* **Details**
|
|
49
|
+
*
|
|
50
|
+
* This mutates `destination` directly, which avoids allocating an intermediate
|
|
51
|
+
* array when generator code needs to merge collections.
|
|
52
|
+
*
|
|
53
|
+
* @category concatenating
|
|
54
|
+
* @since 4.0.0
|
|
55
|
+
*/
|
|
5
56
|
export declare const spreadElementsInto: <A>(source: Array<A>, destination: Array<A>) => void;
|
|
6
57
|
//# sourceMappingURL=Utils.d.ts.map
|
package/dist/Utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../src/Utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../src/Utils.ts"],"names":[],"mappings":"AAaA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,QAAQ,GAAI,MAAM,MAAM,KAAG,MAqBvC,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,GAAI,aAAa,MAAM,uBAA6C,CAAA;AAE3F;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,GAAI,GAAG,OAAO,KAAG,MAAM,GAAG,SAOpD,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS,sCAMpB,CAAA;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,EAAE,QAAQ,KAAK,CAAC,CAAC,CAAC,EAAE,aAAa,KAAK,CAAC,CAAC,CAAC,KAAG,IAI/E,CAAA"}
|
package/dist/Utils.js
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utility helpers for the OpenAPI generator.
|
|
3
|
+
*
|
|
4
|
+
* This module centralizes the small transformations used while rendering
|
|
5
|
+
* generated TypeScript, including operation-name normalization, optional
|
|
6
|
+
* description handling, safe JSDoc comment emission, and direct array merging
|
|
7
|
+
* for code-generation accumulators.
|
|
8
|
+
*
|
|
9
|
+
* @since 4.0.0
|
|
10
|
+
*/
|
|
1
11
|
import * as String from "effect/String";
|
|
2
12
|
import * as UndefinedOr from "effect/UndefinedOr";
|
|
13
|
+
/**
|
|
14
|
+
* Converts an OpenAPI name into the generator's camel-case form.
|
|
15
|
+
*
|
|
16
|
+
* **Details**
|
|
17
|
+
*
|
|
18
|
+
* Separators are removed, leading digits are ignored, and letters following a
|
|
19
|
+
* separator or digit are upper-cased without otherwise changing letter casing.
|
|
20
|
+
*
|
|
21
|
+
* @category converting
|
|
22
|
+
* @since 4.0.0
|
|
23
|
+
*/
|
|
3
24
|
export const camelize = self => {
|
|
4
25
|
let str = "";
|
|
5
26
|
let hadSymbol = false;
|
|
@@ -19,7 +40,25 @@ export const camelize = self => {
|
|
|
19
40
|
}
|
|
20
41
|
return str;
|
|
21
42
|
};
|
|
43
|
+
/**
|
|
44
|
+
* Converts an OpenAPI operation id into the exported operation identifier used
|
|
45
|
+
* by generated TypeScript modules.
|
|
46
|
+
*
|
|
47
|
+
* @category converting
|
|
48
|
+
* @since 4.0.0
|
|
49
|
+
*/
|
|
22
50
|
export const identifier = operationId => String.capitalize(camelize(operationId));
|
|
51
|
+
/**
|
|
52
|
+
* Extracts a trimmed, non-empty string from an unknown value.
|
|
53
|
+
*
|
|
54
|
+
* **Details**
|
|
55
|
+
*
|
|
56
|
+
* Returns `undefined` for non-string values and for strings containing only
|
|
57
|
+
* whitespace.
|
|
58
|
+
*
|
|
59
|
+
* @category filtering
|
|
60
|
+
* @since 4.0.0
|
|
61
|
+
*/
|
|
23
62
|
export const nonEmptyString = a => {
|
|
24
63
|
if (typeof a === "string") {
|
|
25
64
|
const trimmed = String.trim(a);
|
|
@@ -28,12 +67,34 @@ export const nonEmptyString = a => {
|
|
|
28
67
|
}
|
|
29
68
|
}
|
|
30
69
|
};
|
|
70
|
+
/**
|
|
71
|
+
* Renders an optional description as a JSDoc block for generated TypeScript.
|
|
72
|
+
*
|
|
73
|
+
* **Details**
|
|
74
|
+
*
|
|
75
|
+
* Returns an empty string when the description is absent and escapes any
|
|
76
|
+
* closing comment marker so generated source remains syntactically valid.
|
|
77
|
+
*
|
|
78
|
+
* @category converting
|
|
79
|
+
* @since 4.0.0
|
|
80
|
+
*/
|
|
31
81
|
export const toComment = /*#__PURE__*/UndefinedOr.match({
|
|
32
82
|
onUndefined: () => "",
|
|
33
83
|
onDefined: description => `/**
|
|
34
84
|
* ${description.replace(/\*\//g, " * /").split("\n").join("\n* ")}
|
|
35
85
|
*/\n`
|
|
36
86
|
});
|
|
87
|
+
/**
|
|
88
|
+
* Appends every element from `source` into `destination` in order.
|
|
89
|
+
*
|
|
90
|
+
* **Details**
|
|
91
|
+
*
|
|
92
|
+
* This mutates `destination` directly, which avoids allocating an intermediate
|
|
93
|
+
* array when generator code needs to merge collections.
|
|
94
|
+
*
|
|
95
|
+
* @category concatenating
|
|
96
|
+
* @since 4.0.0
|
|
97
|
+
*/
|
|
37
98
|
export const spreadElementsInto = (source, destination) => {
|
|
38
99
|
for (let i = 0; i < source.length; i++) {
|
|
39
100
|
destination.push(source[i]);
|
package/dist/Utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Utils.js","names":["String","UndefinedOr","camelize","self","str","hadSymbol","i","length","charCode","charCodeAt","toUpperCase","identifier","operationId","capitalize","nonEmptyString","a","trimmed","trim","isNonEmpty","toComment","match","onUndefined","onDefined","description","replace","split","join","spreadElementsInto","source","destination","push"],"sources":["../src/Utils.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,KAAKA,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,WAAW,MAAM,oBAAoB;AAEjD,OAAO,MAAMC,QAAQ,GAAIC,IAAY,IAAY;EAC/C,IAAIC,GAAG,GAAG,EAAE;EACZ,IAAIC,SAAS,GAAG,KAAK;EACrB,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGH,IAAI,CAACI,MAAM,EAAED,CAAC,EAAE,EAAE;IACpC,MAAME,QAAQ,GAAGL,IAAI,CAACM,UAAU,CAACH,CAAC,CAAC;IACnC,IACGE,QAAQ,IAAI,EAAE,IAAIA,QAAQ,IAAI,EAAE,IAChCA,QAAQ,IAAI,EAAE,IAAIA,QAAQ,IAAI,GAAI,EACnC;MACAJ,GAAG,IAAIC,SAAS,GAAGF,IAAI,CAACG,CAAC,CAAC,CAACI,WAAW,EAAE,GAAGP,IAAI,CAACG,CAAC,CAAC;MAClDD,SAAS,GAAG,KAAK;IACnB,CAAC,MAAM,IA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ndefinedOr","camelize","self","str","hadSymbol","i","length","charCode","charCodeAt","toUpperCase","identifier","operationId","capitalize","nonEmptyString","a","trimmed","trim","isNonEmpty","toComment","match","onUndefined","onDefined","description","replace","split","join","spreadElementsInto","source","destination","push"],"sources":["../src/Utils.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;AAUA,OAAO,KAAKA,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,WAAW,MAAM,oBAAoB;AAEjD;;;;;;;;;;;AAWA,OAAO,MAAMC,QAAQ,GAAIC,IAAY,IAAY;EAC/C,IAAIC,GAAG,GAAG,EAAE;EACZ,IAAIC,SAAS,GAAG,KAAK;EACrB,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGH,IAAI,CAACI,MAAM,EAAED,CAAC,EAAE,EAAE;IACpC,MAAME,QAAQ,GAAGL,IAAI,CAACM,UAAU,CAACH,CAAC,CAAC;IACnC,IACGE,QAAQ,IAAI,EAAE,IAAIA,QAAQ,IAAI,EAAE,IAChCA,QAAQ,IAAI,EAAE,IAAIA,QAAQ,IAAI,GAAI,EACnC;MACAJ,GAAG,IAAIC,SAAS,GAAGF,IAAI,CAACG,CAAC,CAAC,CAACI,WAAW,EAAE,GAAGP,IAAI,CAACG,CAAC,CAAC;MAClDD,SAAS,GAAG,KAAK;IACnB,CAAC,MAAM,IAAIG,QAAQ,IAAI,EAAE,IAAIA,QAAQ,IAAI,EAAE,EAAE;MAC3C,IAAIJ,GAAG,CAACG,MAAM,GAAG,CAAC,EAAE;QAClBH,GAAG,IAAID,IAAI,CAACG,CAAC,CAAC;QACdD,SAAS,GAAG,IAAI;MAClB;IACF,CAAC,MAAM,IAAID,GAAG,CAACG,MAAM,GAAG,CAAC,EAAE;MACzBF,SAAS,GAAG,IAAI;IAClB;EACF;EACA,OAAOD,GAAG;AACZ,CAAC;AAED;;;;;;;AAOA,OAAO,MAAMO,UAAU,GAAIC,WAAmB,IAAKZ,MAAM,CAACa,UAAU,CAACX,QAAQ,CAACU,WAAW,CAAC,CAAC;AAE3F;;;;;;;;;;;AAWA,OAAO,MAAME,cAAc,GAAIC,CAAU,IAAwB;EAC/D,IAAI,OAAOA,CAAC,KAAK,QAAQ,EAAE;IACzB,MAAMC,OAAO,GAAGhB,MAAM,CAACiB,IAAI,CAACF,CAAC,CAAC;IAC9B,IAAIf,MAAM,CAACkB,UAAU,CAACF,OAAO,CAAC,EAAE;MAC9B,OAAOA,OAAO;IAChB;EACF;AACF,CAAC;AAED;;;;;;;;;;;AAWA,OAAO,MAAMG,SAAS,gBAAGlB,WAAW,CAACmB,KAAK,CAAC;EACzCC,WAAW,EAAEA,CAAA,KAAM,EAAE;EACrBC,SAAS,EAAGC,WAAmB,IAC7B;IACAA,WAAW,CAACC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAACC,KAAK,CAAC,IAAI,CAAC,CAACC,IAAI,CAAC,MAAM,CAAC;;CAEhE,CAAC;AAEF;;;;;;;;;;;AAWA,OAAO,MAAMC,kBAAkB,GAAGA,CAAIC,MAAgB,EAAEC,WAAqB,KAAU;EACrF,KAAK,IAAIvB,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGsB,MAAM,CAACrB,MAAM,EAAED,CAAC,EAAE,EAAE;IACtCuB,WAAW,CAACC,IAAI,CAACF,MAAM,CAACtB,CAAC,CAAC,CAAC;EAC7B;AACF,CAAC","ignoreList":[]}
|
package/dist/main.d.ts
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
2
|
import * as CliError from "effect/unstable/cli/CliError";
|
|
3
3
|
import * as Command from "effect/unstable/cli/Command";
|
|
4
|
+
/**
|
|
5
|
+
* Runs the OpenAPI generator command-line program.
|
|
6
|
+
*
|
|
7
|
+
* **Details**
|
|
8
|
+
*
|
|
9
|
+
* The command reads an OpenAPI specification, optionally applies JSON patches,
|
|
10
|
+
* generates source code in the selected format, writes any generation warnings
|
|
11
|
+
* to stderr, and prints the generated source to stdout.
|
|
12
|
+
*
|
|
13
|
+
* @category running
|
|
14
|
+
* @since 4.0.0
|
|
15
|
+
*/
|
|
4
16
|
export declare const run: Effect.Effect<void, CliError.CliError, Command.Environment>;
|
|
5
17
|
//# sourceMappingURL=main.d.ts.map
|
package/dist/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,KAAK,QAAQ,MAAM,8BAA8B,CAAA;AACxD,OAAO,KAAK,OAAO,MAAM,6BAA6B,CAAA;AA4EtD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,WAAW,CAE1E,CAAA"}
|
package/dist/main.js
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command-line entry point for generating Effect HTTP clients or HttpApi
|
|
3
|
+
* definitions from an OpenAPI specification.
|
|
4
|
+
*
|
|
5
|
+
* The CLI reads a spec file, optionally applies JSON patches in order, selects
|
|
6
|
+
* the generator layer for the requested output format, reports generation
|
|
7
|
+
* warnings to stderr, and writes the generated source to stdout.
|
|
8
|
+
*
|
|
9
|
+
* @since 4.0.0
|
|
10
|
+
*/
|
|
1
11
|
import * as Console from "effect/Console";
|
|
2
12
|
import * as Effect from "effect/Effect";
|
|
3
13
|
import * as CliError from "effect/unstable/cli/CliError";
|
|
@@ -5,19 +15,19 @@ import * as Command from "effect/unstable/cli/Command";
|
|
|
5
15
|
import * as Flag from "effect/unstable/cli/Flag";
|
|
6
16
|
import * as OpenApiGenerator from "./OpenApiGenerator.js";
|
|
7
17
|
import * as OpenApiPatch from "./OpenApiPatch.js";
|
|
8
|
-
const spec = /*#__PURE__*/Flag.fileParse("spec").pipe(/*#__PURE__*/Flag.withAlias("s"), /*#__PURE__*/Flag.withDescription("The OpenAPI spec file to generate
|
|
9
|
-
const name = /*#__PURE__*/Flag.string("name").pipe(/*#__PURE__*/Flag.withAlias("n"), /*#__PURE__*/Flag.withDescription("The name of the generated
|
|
10
|
-
const
|
|
18
|
+
const spec = /*#__PURE__*/Flag.fileParse("spec").pipe(/*#__PURE__*/Flag.withAlias("s"), /*#__PURE__*/Flag.withDescription("The OpenAPI spec file to generate output from"));
|
|
19
|
+
const name = /*#__PURE__*/Flag.string("name").pipe(/*#__PURE__*/Flag.withAlias("n"), /*#__PURE__*/Flag.withDescription("The name of the generated output"), /*#__PURE__*/Flag.withDefault("Client"));
|
|
20
|
+
const format = /*#__PURE__*/Flag.choice("format", ["httpclient", "httpclient-type-only", "httpapi"]).pipe(/*#__PURE__*/Flag.withAlias("f"), /*#__PURE__*/Flag.withDescription("Output format to generate: httpclient | httpclient-type-only | httpapi (default: httpclient)"), /*#__PURE__*/Flag.withDefault("httpclient"));
|
|
11
21
|
const patch = /*#__PURE__*/Flag.string("patch").pipe(/*#__PURE__*/Flag.withAlias("p"), /*#__PURE__*/Flag.withDescription("JSON patch to apply to OpenAPI spec before generation. " + "Can be a file path (.json, .yaml, .yml) or inline JSON array. " + "Multiple patches are applied in order."), /*#__PURE__*/Flag.between(0, Infinity));
|
|
12
22
|
const root = /*#__PURE__*/Command.make("openapigen", {
|
|
13
23
|
spec,
|
|
14
|
-
|
|
24
|
+
format,
|
|
15
25
|
name,
|
|
16
26
|
patch
|
|
17
27
|
}).pipe(/*#__PURE__*/Command.withHandler(/*#__PURE__*/Effect.fnUntraced(function* ({
|
|
18
28
|
name,
|
|
19
29
|
spec,
|
|
20
|
-
|
|
30
|
+
format,
|
|
21
31
|
patch
|
|
22
32
|
}) {
|
|
23
33
|
let patchedSpec = spec;
|
|
@@ -33,15 +43,38 @@ const root = /*#__PURE__*/Command.make("openapigen", {
|
|
|
33
43
|
})));
|
|
34
44
|
}
|
|
35
45
|
const generator = yield* OpenApiGenerator.OpenApiGenerator;
|
|
46
|
+
const warnings = [];
|
|
36
47
|
const source = yield* generator.generate(patchedSpec, {
|
|
37
48
|
name,
|
|
38
|
-
|
|
49
|
+
format,
|
|
50
|
+
onWarning: warning => {
|
|
51
|
+
warnings.push(warning);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
yield* Effect.forEach(warnings, warning => Console.error(formatWarning(warning)), {
|
|
55
|
+
discard: true
|
|
39
56
|
});
|
|
40
57
|
return yield* Console.log(source);
|
|
41
58
|
})), /*#__PURE__*/Command.provide(({
|
|
42
|
-
|
|
43
|
-
}) =>
|
|
59
|
+
format
|
|
60
|
+
}) => format === "httpclient-type-only" ? OpenApiGenerator.layerTransformerTs : OpenApiGenerator.layerTransformerSchema));
|
|
61
|
+
/**
|
|
62
|
+
* Runs the OpenAPI generator command-line program.
|
|
63
|
+
*
|
|
64
|
+
* **Details**
|
|
65
|
+
*
|
|
66
|
+
* The command reads an OpenAPI specification, optionally applies JSON patches,
|
|
67
|
+
* generates source code in the selected format, writes any generation warnings
|
|
68
|
+
* to stderr, and prints the generated source to stdout.
|
|
69
|
+
*
|
|
70
|
+
* @category running
|
|
71
|
+
* @since 4.0.0
|
|
72
|
+
*/
|
|
44
73
|
export const run = /*#__PURE__*/Command.run(root, {
|
|
45
74
|
version: "0.0.0"
|
|
46
75
|
});
|
|
76
|
+
const formatWarning = warning => {
|
|
77
|
+
const context = [warning.method?.toUpperCase(), warning.path, warning.operationId ? `(${warning.operationId})` : undefined].filter(value => value !== undefined);
|
|
78
|
+
return context.length > 0 ? `WARNING [${warning.code}] ${context.join(" ")}: ${warning.message}` : `WARNING [${warning.code}] ${warning.message}`;
|
|
79
|
+
};
|
|
47
80
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","names":["Console","Effect","CliError","Command","Flag","OpenApiGenerator","OpenApiPatch","spec","fileParse","pipe","withAlias","withDescription","name","string","withDefault","
|
|
1
|
+
{"version":3,"file":"main.js","names":["Console","Effect","CliError","Command","Flag","OpenApiGenerator","OpenApiPatch","spec","fileParse","pipe","withAlias","withDescription","name","string","withDefault","format","choice","patch","between","Infinity","root","make","withHandler","fnUntraced","patchedSpec","length","parsedPatches","forEach","input","parsePatchInput","map","p","source","mapError","error","UserError","cause","applyPatches","generator","warnings","generate","onWarning","warning","push","formatWarning","discard","log","provide","layerTransformerTs","layerTransformerSchema","run","version","context","method","toUpperCase","path","operationId","undefined","filter","value","code","join","message"],"sources":["../src/main.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;AAUA,OAAO,KAAKA,OAAO,MAAM,gBAAgB;AACzC,OAAO,KAAKC,MAAM,MAAM,eAAe;AAEvC,OAAO,KAAKC,QAAQ,MAAM,8BAA8B;AACxD,OAAO,KAAKC,OAAO,MAAM,6BAA6B;AACtD,OAAO,KAAKC,IAAI,MAAM,0BAA0B;AAEhD,OAAO,KAAKC,gBAAgB,MAAM,uBAAuB;AACzD,OAAO,KAAKC,YAAY,MAAM,mBAAmB;AAEjD,MAAMC,IAAI,gBAAGH,IAAI,CAACI,SAAS,CAAC,MAAM,CAAC,CAACC,IAAI,cACtCL,IAAI,CAACM,SAAS,CAAC,GAAG,CAAC,eACnBN,IAAI,CAACO,eAAe,CAAC,+CAA+C,CAAC,CACtE;AAED,MAAMC,IAAI,gBAAGR,IAAI,CAACS,MAAM,CAAC,MAAM,CAAC,CAACJ,IAAI,cACnCL,IAAI,CAACM,SAAS,CAAC,GAAG,CAAC,eACnBN,IAAI,CAACO,eAAe,CAAC,kCAAkC,CAAC,eACxDP,IAAI,CAACU,WAAW,CAAC,QAAQ,CAAC,CAC3B;AAED,MAAMC,MAAM,gBAAGX,IAAI,CAACY,MAAM,CAAC,QAAQ,EAAE,CAAC,YAAY,EAAE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AC7D,CAACC,MAAM,CAAEC,KAAK,IAAsBA,KAAK,KAAKF,SAAS,CAAC;EACzD,OAAOL,OAAO,CAAC3B,MAAM,GAAG,CAAC,GACrB,YAAYiB,OAAO,CAACkB,IAAI,KAAKR,OAAO,CAACS,IAAI,CAAC,GAAG,CAAC,KAAKnB,OAAO,CAACoB,OAAO,EAAE,GACpE,YAAYpB,OAAO,CAACkB,IAAI,KAAKlB,OAAO,CAACoB,OAAO,EAAE;AACpD,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect/openapi-generator",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.0-beta.
|
|
4
|
+
"version": "4.0.0-beta.91",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"description": "Generate Effect Schema types
|
|
6
|
+
"description": "Generate Effect Schema types, HTTP clients, and HttpApi modules from OpenAPI specifications",
|
|
7
7
|
"homepage": "https://effect.website",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
@@ -45,16 +45,18 @@
|
|
|
45
45
|
"provenance": true
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@effect/platform-node": "^4.0.0-beta.
|
|
49
|
-
"effect": "^4.0.0-beta.
|
|
48
|
+
"@effect/platform-node": "^4.0.0-beta.91",
|
|
49
|
+
"effect": "^4.0.0-beta.91"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"swagger2openapi": "^7.0.8"
|
|
50
53
|
},
|
|
51
54
|
"devDependencies": {
|
|
52
55
|
"@types/swagger2openapi": "^7.0.4",
|
|
53
56
|
"json-schema-typed": "^8.0.2",
|
|
54
|
-
"openapi-typescript": "^7.
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"effect": "^4.0.0-beta.9"
|
|
57
|
+
"openapi-typescript": "^7.13.0",
|
|
58
|
+
"yaml": "^2.9.0",
|
|
59
|
+
"effect": "^4.0.0-beta.91"
|
|
58
60
|
},
|
|
59
61
|
"scripts": {
|
|
60
62
|
"build": "tsc -b tsconfig.json && pnpm babel",
|