@f3liz/rescript-autogen-openapi 0.3.1
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/LICENSE +373 -0
- package/README.md +111 -0
- package/lib/es6/src/Codegen.d.ts +28 -0
- package/lib/es6/src/Codegen.mjs +423 -0
- package/lib/es6/src/Types.d.ts +286 -0
- package/lib/es6/src/Types.mjs +20 -0
- package/lib/es6/src/bindings/Toposort.mjs +12 -0
- package/lib/es6/src/core/CodegenUtils.mjs +261 -0
- package/lib/es6/src/core/DocOverride.mjs +399 -0
- package/lib/es6/src/core/FileSystem.d.ts +4 -0
- package/lib/es6/src/core/FileSystem.mjs +78 -0
- package/lib/es6/src/core/IRBuilder.mjs +201 -0
- package/lib/es6/src/core/OpenAPIParser.mjs +168 -0
- package/lib/es6/src/core/Pipeline.d.ts +6 -0
- package/lib/es6/src/core/Pipeline.mjs +150 -0
- package/lib/es6/src/core/ReferenceResolver.mjs +41 -0
- package/lib/es6/src/core/Result.mjs +378 -0
- package/lib/es6/src/core/SchemaIR.mjs +425 -0
- package/lib/es6/src/core/SchemaIRParser.mjs +683 -0
- package/lib/es6/src/core/SchemaRefResolver.mjs +146 -0
- package/lib/es6/src/core/SchemaRegistry.mjs +92 -0
- package/lib/es6/src/core/SpecDiffer.mjs +251 -0
- package/lib/es6/src/core/SpecMerger.mjs +237 -0
- package/lib/es6/src/generators/ComponentSchemaGenerator.mjs +207 -0
- package/lib/es6/src/generators/DiffReportGenerator.mjs +155 -0
- package/lib/es6/src/generators/EndpointGenerator.mjs +173 -0
- package/lib/es6/src/generators/IRToSuryGenerator.mjs +543 -0
- package/lib/es6/src/generators/IRToTypeGenerator.mjs +592 -0
- package/lib/es6/src/generators/IRToTypeScriptGenerator.mjs +143 -0
- package/lib/es6/src/generators/ModuleGenerator.mjs +285 -0
- package/lib/es6/src/generators/SchemaCodeGenerator.mjs +77 -0
- package/lib/es6/src/generators/ThinWrapperGenerator.mjs +97 -0
- package/lib/es6/src/generators/TypeScriptDtsGenerator.mjs +172 -0
- package/lib/es6/src/generators/TypeScriptWrapperGenerator.mjs +145 -0
- package/lib/es6/src/types/CodegenError.d.ts +66 -0
- package/lib/es6/src/types/CodegenError.mjs +79 -0
- package/lib/es6/src/types/Config.d.ts +31 -0
- package/lib/es6/src/types/Config.mjs +42 -0
- package/lib/es6/src/types/GenerationContext.mjs +47 -0
- package/package.json +53 -0
- package/rescript.json +26 -0
- package/src/Codegen.res +231 -0
- package/src/Types.res +222 -0
- package/src/bindings/Toposort.res +16 -0
- package/src/core/CodegenUtils.res +180 -0
- package/src/core/DocOverride.res +504 -0
- package/src/core/FileSystem.res +63 -0
- package/src/core/IRBuilder.res +66 -0
- package/src/core/OpenAPIParser.res +144 -0
- package/src/core/Pipeline.res +52 -0
- package/src/core/ReferenceResolver.res +41 -0
- package/src/core/Result.res +187 -0
- package/src/core/SchemaIR.res +291 -0
- package/src/core/SchemaIRParser.res +454 -0
- package/src/core/SchemaRefResolver.res +143 -0
- package/src/core/SchemaRegistry.res +107 -0
- package/src/core/SpecDiffer.res +270 -0
- package/src/core/SpecMerger.res +245 -0
- package/src/generators/ComponentSchemaGenerator.res +210 -0
- package/src/generators/DiffReportGenerator.res +152 -0
- package/src/generators/EndpointGenerator.res +176 -0
- package/src/generators/IRToSuryGenerator.res +386 -0
- package/src/generators/IRToTypeGenerator.res +423 -0
- package/src/generators/IRToTypeScriptGenerator.res +77 -0
- package/src/generators/ModuleGenerator.res +363 -0
- package/src/generators/SchemaCodeGenerator.res +84 -0
- package/src/generators/ThinWrapperGenerator.res +124 -0
- package/src/generators/TypeScriptDtsGenerator.res +193 -0
- package/src/generators/TypeScriptWrapperGenerator.res +166 -0
- package/src/types/CodegenError.res +85 -0
- package/src/types/Config.res +95 -0
- package/src/types/GenerationContext.res +56 -0
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as Stdlib from "@rescript/runtime/lib/es6/Stdlib.js";
|
|
4
|
+
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
5
|
+
import * as Stdlib_Result from "@rescript/runtime/lib/es6/Stdlib_Result.js";
|
|
6
|
+
import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
|
|
7
|
+
|
|
8
|
+
function map2(ra, rb, f) {
|
|
9
|
+
if (ra.TAG === "Ok") {
|
|
10
|
+
if (rb.TAG === "Ok") {
|
|
11
|
+
return {
|
|
12
|
+
TAG: "Ok",
|
|
13
|
+
_0: f(ra._0, rb._0)
|
|
14
|
+
};
|
|
15
|
+
} else {
|
|
16
|
+
return {
|
|
17
|
+
TAG: "Error",
|
|
18
|
+
_0: rb._0
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
} else {
|
|
22
|
+
return {
|
|
23
|
+
TAG: "Error",
|
|
24
|
+
_0: ra._0
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function map3(ra, rb, rc, f) {
|
|
30
|
+
if (ra.TAG === "Ok") {
|
|
31
|
+
if (rb.TAG === "Ok") {
|
|
32
|
+
if (rc.TAG === "Ok") {
|
|
33
|
+
return {
|
|
34
|
+
TAG: "Ok",
|
|
35
|
+
_0: f(ra._0, rb._0, rc._0)
|
|
36
|
+
};
|
|
37
|
+
} else {
|
|
38
|
+
return {
|
|
39
|
+
TAG: "Error",
|
|
40
|
+
_0: rc._0
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
return {
|
|
45
|
+
TAG: "Error",
|
|
46
|
+
_0: rb._0
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
return {
|
|
51
|
+
TAG: "Error",
|
|
52
|
+
_0: ra._0
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function map4(ra, rb, rc, rd, f) {
|
|
58
|
+
if (ra.TAG === "Ok") {
|
|
59
|
+
if (rb.TAG === "Ok") {
|
|
60
|
+
if (rc.TAG === "Ok") {
|
|
61
|
+
if (rd.TAG === "Ok") {
|
|
62
|
+
return {
|
|
63
|
+
TAG: "Ok",
|
|
64
|
+
_0: f(ra._0, rb._0, rc._0, rd._0)
|
|
65
|
+
};
|
|
66
|
+
} else {
|
|
67
|
+
return {
|
|
68
|
+
TAG: "Error",
|
|
69
|
+
_0: rd._0
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
} else {
|
|
73
|
+
return {
|
|
74
|
+
TAG: "Error",
|
|
75
|
+
_0: rc._0
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
} else {
|
|
79
|
+
return {
|
|
80
|
+
TAG: "Error",
|
|
81
|
+
_0: rb._0
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
} else {
|
|
85
|
+
return {
|
|
86
|
+
TAG: "Error",
|
|
87
|
+
_0: ra._0
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function all(results) {
|
|
93
|
+
let acc = [];
|
|
94
|
+
let error = {
|
|
95
|
+
contents: undefined
|
|
96
|
+
};
|
|
97
|
+
let len = results.length;
|
|
98
|
+
let loop = _idx => {
|
|
99
|
+
while (true) {
|
|
100
|
+
let idx = _idx;
|
|
101
|
+
if (!(idx < len && Stdlib_Option.isNone(error.contents))) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
let v = results[idx];
|
|
105
|
+
if (v.TAG !== "Ok") {
|
|
106
|
+
error.contents = Primitive_option.some(v._0);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
acc.push(v._0);
|
|
110
|
+
_idx = idx + 1 | 0;
|
|
111
|
+
continue;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
loop(0);
|
|
115
|
+
let e = error.contents;
|
|
116
|
+
if (e !== undefined) {
|
|
117
|
+
return {
|
|
118
|
+
TAG: "Error",
|
|
119
|
+
_0: Primitive_option.valFromOption(e)
|
|
120
|
+
};
|
|
121
|
+
} else {
|
|
122
|
+
return {
|
|
123
|
+
TAG: "Ok",
|
|
124
|
+
_0: acc
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function allUnit(results) {
|
|
130
|
+
let error = {
|
|
131
|
+
contents: undefined
|
|
132
|
+
};
|
|
133
|
+
let len = results.length;
|
|
134
|
+
let loop = _idx => {
|
|
135
|
+
while (true) {
|
|
136
|
+
let idx = _idx;
|
|
137
|
+
if (!(idx < len && Stdlib_Option.isNone(error.contents))) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
let e = results[idx];
|
|
141
|
+
if (e.TAG !== "Ok") {
|
|
142
|
+
error.contents = Primitive_option.some(e._0);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
_idx = idx + 1 | 0;
|
|
146
|
+
continue;
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
loop(0);
|
|
150
|
+
let e = error.contents;
|
|
151
|
+
if (e !== undefined) {
|
|
152
|
+
return {
|
|
153
|
+
TAG: "Error",
|
|
154
|
+
_0: Primitive_option.valFromOption(e)
|
|
155
|
+
};
|
|
156
|
+
} else {
|
|
157
|
+
return {
|
|
158
|
+
TAG: "Ok",
|
|
159
|
+
_0: undefined
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function partition(results) {
|
|
165
|
+
let successes = [];
|
|
166
|
+
let errors = [];
|
|
167
|
+
results.forEach(r => {
|
|
168
|
+
if (r.TAG === "Ok") {
|
|
169
|
+
successes.push(r._0);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
errors.push(r._0);
|
|
173
|
+
});
|
|
174
|
+
return [
|
|
175
|
+
successes,
|
|
176
|
+
errors
|
|
177
|
+
];
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function firstSuccess(results) {
|
|
181
|
+
let errors = [];
|
|
182
|
+
let success = {
|
|
183
|
+
contents: undefined
|
|
184
|
+
};
|
|
185
|
+
let len = results.length;
|
|
186
|
+
let loop = _idx => {
|
|
187
|
+
while (true) {
|
|
188
|
+
let idx = _idx;
|
|
189
|
+
if (!(idx < len && Stdlib_Option.isNone(success.contents))) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
let v = results[idx];
|
|
193
|
+
if (v.TAG === "Ok") {
|
|
194
|
+
success.contents = Primitive_option.some(v._0);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
errors.push(v._0);
|
|
198
|
+
_idx = idx + 1 | 0;
|
|
199
|
+
continue;
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
loop(0);
|
|
203
|
+
let v = success.contents;
|
|
204
|
+
if (v !== undefined) {
|
|
205
|
+
return {
|
|
206
|
+
TAG: "Ok",
|
|
207
|
+
_0: Primitive_option.valFromOption(v)
|
|
208
|
+
};
|
|
209
|
+
} else {
|
|
210
|
+
return {
|
|
211
|
+
TAG: "Error",
|
|
212
|
+
_0: errors
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function foldM(arr, init, f) {
|
|
218
|
+
let loop = (acc, idx) => {
|
|
219
|
+
if (idx >= arr.length) {
|
|
220
|
+
return {
|
|
221
|
+
TAG: "Ok",
|
|
222
|
+
_0: acc
|
|
223
|
+
};
|
|
224
|
+
} else {
|
|
225
|
+
return Stdlib_Result.flatMap(f(acc, arr[idx]), newAcc => loop(newAcc, idx + 1 | 0));
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
return loop(init, 0);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function tap(result, f) {
|
|
232
|
+
if (result.TAG === "Ok") {
|
|
233
|
+
f(result._0);
|
|
234
|
+
}
|
|
235
|
+
return result;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function tapError(result, f) {
|
|
239
|
+
if (result.TAG !== "Ok") {
|
|
240
|
+
f(result._0);
|
|
241
|
+
}
|
|
242
|
+
return result;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function fromOption(opt, error) {
|
|
246
|
+
if (opt !== undefined) {
|
|
247
|
+
return {
|
|
248
|
+
TAG: "Ok",
|
|
249
|
+
_0: Primitive_option.valFromOption(opt)
|
|
250
|
+
};
|
|
251
|
+
} else {
|
|
252
|
+
return {
|
|
253
|
+
TAG: "Error",
|
|
254
|
+
_0: error
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function toOption(result) {
|
|
260
|
+
if (result.TAG === "Ok") {
|
|
261
|
+
return Primitive_option.some(result._0);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function recover(result, f) {
|
|
266
|
+
if (result.TAG === "Ok") {
|
|
267
|
+
return result;
|
|
268
|
+
} else {
|
|
269
|
+
return f(result._0);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function getOr(result, $$default) {
|
|
274
|
+
if (result.TAG === "Ok") {
|
|
275
|
+
return result._0;
|
|
276
|
+
} else {
|
|
277
|
+
return $$default;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function getExn(result) {
|
|
282
|
+
if (result.TAG === "Ok") {
|
|
283
|
+
return result._0;
|
|
284
|
+
} else {
|
|
285
|
+
return Stdlib.panic("Result.getExn called on Error");
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function getError(result) {
|
|
290
|
+
if (result.TAG === "Ok") {
|
|
291
|
+
return;
|
|
292
|
+
} else {
|
|
293
|
+
return Primitive_option.some(result._0);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
let getOrThrow = Stdlib_Result.getOrThrow;
|
|
298
|
+
|
|
299
|
+
let mapOr = Stdlib_Result.mapOr;
|
|
300
|
+
|
|
301
|
+
let mapWithDefault = Stdlib_Result.mapWithDefault;
|
|
302
|
+
|
|
303
|
+
let map = Stdlib_Result.map;
|
|
304
|
+
|
|
305
|
+
let flatMap = Stdlib_Result.flatMap;
|
|
306
|
+
|
|
307
|
+
let getWithDefault = Stdlib_Result.getWithDefault;
|
|
308
|
+
|
|
309
|
+
let isOk = Stdlib_Result.isOk;
|
|
310
|
+
|
|
311
|
+
let isError = Stdlib_Result.isError;
|
|
312
|
+
|
|
313
|
+
let equal = Stdlib_Result.equal;
|
|
314
|
+
|
|
315
|
+
let compare = Stdlib_Result.compare;
|
|
316
|
+
|
|
317
|
+
let forEach = Stdlib_Result.forEach;
|
|
318
|
+
|
|
319
|
+
let mapError = Stdlib_Result.mapError;
|
|
320
|
+
|
|
321
|
+
let all2 = Stdlib_Result.all2;
|
|
322
|
+
|
|
323
|
+
let all3 = Stdlib_Result.all3;
|
|
324
|
+
|
|
325
|
+
let all4 = Stdlib_Result.all4;
|
|
326
|
+
|
|
327
|
+
let all5 = Stdlib_Result.all5;
|
|
328
|
+
|
|
329
|
+
let all6 = Stdlib_Result.all6;
|
|
330
|
+
|
|
331
|
+
let mapOkAsync = Stdlib_Result.mapOkAsync;
|
|
332
|
+
|
|
333
|
+
let mapErrorAsync = Stdlib_Result.mapErrorAsync;
|
|
334
|
+
|
|
335
|
+
let flatMapOkAsync = Stdlib_Result.flatMapOkAsync;
|
|
336
|
+
|
|
337
|
+
let flatMapErrorAsync = Stdlib_Result.flatMapErrorAsync;
|
|
338
|
+
|
|
339
|
+
export {
|
|
340
|
+
getOrThrow,
|
|
341
|
+
mapOr,
|
|
342
|
+
mapWithDefault,
|
|
343
|
+
map,
|
|
344
|
+
flatMap,
|
|
345
|
+
getWithDefault,
|
|
346
|
+
isOk,
|
|
347
|
+
isError,
|
|
348
|
+
equal,
|
|
349
|
+
compare,
|
|
350
|
+
forEach,
|
|
351
|
+
mapError,
|
|
352
|
+
all2,
|
|
353
|
+
all3,
|
|
354
|
+
all4,
|
|
355
|
+
all5,
|
|
356
|
+
all6,
|
|
357
|
+
mapOkAsync,
|
|
358
|
+
mapErrorAsync,
|
|
359
|
+
flatMapOkAsync,
|
|
360
|
+
flatMapErrorAsync,
|
|
361
|
+
map2,
|
|
362
|
+
map3,
|
|
363
|
+
map4,
|
|
364
|
+
all,
|
|
365
|
+
allUnit,
|
|
366
|
+
partition,
|
|
367
|
+
firstSuccess,
|
|
368
|
+
foldM,
|
|
369
|
+
tap,
|
|
370
|
+
tapError,
|
|
371
|
+
fromOption,
|
|
372
|
+
toOption,
|
|
373
|
+
recover,
|
|
374
|
+
getOr,
|
|
375
|
+
getExn,
|
|
376
|
+
getError,
|
|
377
|
+
}
|
|
378
|
+
/* No side effect */
|