@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,78 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as Fs from "fs";
|
|
4
|
+
import * as Pathe from "pathe";
|
|
5
|
+
import * as Stdlib_JsExn from "@rescript/runtime/lib/es6/Stdlib_JsExn.js";
|
|
6
|
+
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
7
|
+
import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
|
|
8
|
+
|
|
9
|
+
function ensureDir(path) {
|
|
10
|
+
try {
|
|
11
|
+
Fs.mkdirSync(Pathe.dirname(path), {
|
|
12
|
+
recursive: true
|
|
13
|
+
});
|
|
14
|
+
return;
|
|
15
|
+
} catch (exn) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function writeFile(file) {
|
|
21
|
+
try {
|
|
22
|
+
ensureDir(file.path);
|
|
23
|
+
Fs.writeFileSync(file.path, file.content, "utf8");
|
|
24
|
+
return {
|
|
25
|
+
TAG: "Ok",
|
|
26
|
+
_0: undefined
|
|
27
|
+
};
|
|
28
|
+
} catch (raw_exn) {
|
|
29
|
+
let exn = Primitive_exceptions.internalToException(raw_exn);
|
|
30
|
+
if (exn.RE_EXN_ID !== "JsExn") {
|
|
31
|
+
return {
|
|
32
|
+
TAG: "Error",
|
|
33
|
+
_0: `Failed to write file ` + file.path + `: Unknown error`
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
let message = Stdlib_Option.getOr(Stdlib_JsExn.message(exn._1), "Unknown error");
|
|
37
|
+
return {
|
|
38
|
+
TAG: "Error",
|
|
39
|
+
_0: `Failed to write file ` + file.path + `: ` + message
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function writeFiles(files) {
|
|
45
|
+
let successes = [];
|
|
46
|
+
let errors = [];
|
|
47
|
+
files.forEach(file => {
|
|
48
|
+
let err = writeFile(file);
|
|
49
|
+
if (err.TAG === "Ok") {
|
|
50
|
+
successes.push(file.path);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
errors.push(err._0);
|
|
54
|
+
});
|
|
55
|
+
if (errors.length !== 0) {
|
|
56
|
+
return {
|
|
57
|
+
TAG: "Error",
|
|
58
|
+
_0: errors
|
|
59
|
+
};
|
|
60
|
+
} else {
|
|
61
|
+
return {
|
|
62
|
+
TAG: "Ok",
|
|
63
|
+
_0: successes
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function makePath(baseDir, filename) {
|
|
69
|
+
return Pathe.join(baseDir, filename);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export {
|
|
73
|
+
ensureDir,
|
|
74
|
+
writeFile,
|
|
75
|
+
writeFiles,
|
|
76
|
+
makePath,
|
|
77
|
+
}
|
|
78
|
+
/* fs Not a pure module */
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
function string(min, max, pattern, param) {
|
|
5
|
+
return {
|
|
6
|
+
minLength: min,
|
|
7
|
+
maxLength: max,
|
|
8
|
+
pattern: pattern
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function number(min, max, multipleOf, param) {
|
|
13
|
+
return {
|
|
14
|
+
minimum: min,
|
|
15
|
+
maximum: max,
|
|
16
|
+
multipleOf: multipleOf
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function array(min, max, uniqueOpt, param) {
|
|
21
|
+
let unique = uniqueOpt !== undefined ? uniqueOpt : false;
|
|
22
|
+
return {
|
|
23
|
+
minItems: min,
|
|
24
|
+
maxItems: max,
|
|
25
|
+
uniqueItems: unique
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
let Constraints = {
|
|
30
|
+
string: string,
|
|
31
|
+
number: number,
|
|
32
|
+
array: array
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
function string$1(min, max, pattern, param) {
|
|
36
|
+
return {
|
|
37
|
+
TAG: "String",
|
|
38
|
+
constraints: {
|
|
39
|
+
minLength: min,
|
|
40
|
+
maxLength: max,
|
|
41
|
+
pattern: pattern
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function number$1(min, max, multipleOf, param) {
|
|
47
|
+
return {
|
|
48
|
+
TAG: "Number",
|
|
49
|
+
constraints: {
|
|
50
|
+
minimum: min,
|
|
51
|
+
maximum: max,
|
|
52
|
+
multipleOf: multipleOf
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function int(min, max, multipleOf, param) {
|
|
58
|
+
return {
|
|
59
|
+
TAG: "Integer",
|
|
60
|
+
constraints: {
|
|
61
|
+
minimum: min,
|
|
62
|
+
maximum: max,
|
|
63
|
+
multipleOf: multipleOf
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function array$1(items, min, max, uniqueOpt, param) {
|
|
69
|
+
let unique = uniqueOpt !== undefined ? uniqueOpt : false;
|
|
70
|
+
return {
|
|
71
|
+
TAG: "Array",
|
|
72
|
+
items: items,
|
|
73
|
+
constraints: array(min, max, unique, undefined)
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function object_(props, additional, param) {
|
|
78
|
+
return {
|
|
79
|
+
TAG: "Object",
|
|
80
|
+
properties: props,
|
|
81
|
+
additionalProperties: additional
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function union(types) {
|
|
86
|
+
return {
|
|
87
|
+
TAG: "Union",
|
|
88
|
+
_0: types
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function intersection(types) {
|
|
93
|
+
return {
|
|
94
|
+
TAG: "Intersection",
|
|
95
|
+
_0: types
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function ref(refPath) {
|
|
100
|
+
return {
|
|
101
|
+
TAG: "Reference",
|
|
102
|
+
_0: refPath
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function option(type_) {
|
|
107
|
+
return {
|
|
108
|
+
TAG: "Option",
|
|
109
|
+
_0: type_
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function stringLit(s) {
|
|
114
|
+
return {
|
|
115
|
+
TAG: "Literal",
|
|
116
|
+
_0: {
|
|
117
|
+
TAG: "StringLiteral",
|
|
118
|
+
_0: s
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function numberLit(n) {
|
|
124
|
+
return {
|
|
125
|
+
TAG: "Literal",
|
|
126
|
+
_0: {
|
|
127
|
+
TAG: "NumberLiteral",
|
|
128
|
+
_0: n
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function boolLit(b) {
|
|
134
|
+
return {
|
|
135
|
+
TAG: "Literal",
|
|
136
|
+
_0: {
|
|
137
|
+
TAG: "BooleanLiteral",
|
|
138
|
+
_0: b
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function prop(name, type_, requiredOpt, param) {
|
|
144
|
+
let required = requiredOpt !== undefined ? requiredOpt : true;
|
|
145
|
+
return [
|
|
146
|
+
name,
|
|
147
|
+
type_,
|
|
148
|
+
required
|
|
149
|
+
];
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function optProp(name, type_) {
|
|
153
|
+
return [
|
|
154
|
+
name,
|
|
155
|
+
type_,
|
|
156
|
+
false
|
|
157
|
+
];
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function named(name, description, type_) {
|
|
161
|
+
return {
|
|
162
|
+
name: name,
|
|
163
|
+
description: description,
|
|
164
|
+
type_: type_
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
let bool = "Boolean";
|
|
169
|
+
|
|
170
|
+
let $$null = "Null";
|
|
171
|
+
|
|
172
|
+
let unknown = "Unknown";
|
|
173
|
+
|
|
174
|
+
let nullLit = {
|
|
175
|
+
TAG: "Literal",
|
|
176
|
+
_0: "NullLiteral"
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
export {
|
|
180
|
+
Constraints,
|
|
181
|
+
string$1 as string,
|
|
182
|
+
number$1 as number,
|
|
183
|
+
int,
|
|
184
|
+
bool,
|
|
185
|
+
$$null,
|
|
186
|
+
unknown,
|
|
187
|
+
array$1 as array,
|
|
188
|
+
object_,
|
|
189
|
+
union,
|
|
190
|
+
intersection,
|
|
191
|
+
ref,
|
|
192
|
+
option,
|
|
193
|
+
stringLit,
|
|
194
|
+
numberLit,
|
|
195
|
+
boolLit,
|
|
196
|
+
nullLit,
|
|
197
|
+
prop,
|
|
198
|
+
optProp,
|
|
199
|
+
named,
|
|
200
|
+
}
|
|
201
|
+
/* No side effect */
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
|
|
4
|
+
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
5
|
+
|
|
6
|
+
function parseMethod(methodStr) {
|
|
7
|
+
let match = methodStr.toLowerCase();
|
|
8
|
+
switch (match) {
|
|
9
|
+
case "delete" :
|
|
10
|
+
return "DELETE";
|
|
11
|
+
case "get" :
|
|
12
|
+
return "GET";
|
|
13
|
+
case "head" :
|
|
14
|
+
return "HEAD";
|
|
15
|
+
case "options" :
|
|
16
|
+
return "OPTIONS";
|
|
17
|
+
case "patch" :
|
|
18
|
+
return "PATCH";
|
|
19
|
+
case "post" :
|
|
20
|
+
return "POST";
|
|
21
|
+
case "put" :
|
|
22
|
+
return "PUT";
|
|
23
|
+
default:
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function httpMethodToString(method) {
|
|
29
|
+
if (method === "GET") {
|
|
30
|
+
return "get";
|
|
31
|
+
} else if (method === "PUT") {
|
|
32
|
+
return "put";
|
|
33
|
+
} else if (method === "DELETE") {
|
|
34
|
+
return "delete";
|
|
35
|
+
} else if (method === "HEAD") {
|
|
36
|
+
return "head";
|
|
37
|
+
} else if (method === "POST") {
|
|
38
|
+
return "post";
|
|
39
|
+
} else if (method === "PATCH") {
|
|
40
|
+
return "patch";
|
|
41
|
+
} else {
|
|
42
|
+
return "options";
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function tupleToEndpoint(param) {
|
|
47
|
+
let operation = param[2];
|
|
48
|
+
return {
|
|
49
|
+
path: param[0],
|
|
50
|
+
method: httpMethodToString(param[1]),
|
|
51
|
+
operationId: operation.operationId,
|
|
52
|
+
summary: operation.summary,
|
|
53
|
+
description: operation.description,
|
|
54
|
+
tags: operation.tags,
|
|
55
|
+
requestBody: operation.requestBody,
|
|
56
|
+
responses: operation.responses,
|
|
57
|
+
parameters: operation.parameters
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function getOperations(path, param) {
|
|
62
|
+
return Stdlib_Array.filterMap([
|
|
63
|
+
[
|
|
64
|
+
"GET",
|
|
65
|
+
param.get
|
|
66
|
+
],
|
|
67
|
+
[
|
|
68
|
+
"POST",
|
|
69
|
+
param.post
|
|
70
|
+
],
|
|
71
|
+
[
|
|
72
|
+
"PUT",
|
|
73
|
+
param.put
|
|
74
|
+
],
|
|
75
|
+
[
|
|
76
|
+
"PATCH",
|
|
77
|
+
param.patch
|
|
78
|
+
],
|
|
79
|
+
[
|
|
80
|
+
"DELETE",
|
|
81
|
+
param.delete
|
|
82
|
+
],
|
|
83
|
+
[
|
|
84
|
+
"HEAD",
|
|
85
|
+
param.head
|
|
86
|
+
],
|
|
87
|
+
[
|
|
88
|
+
"OPTIONS",
|
|
89
|
+
param.options
|
|
90
|
+
]
|
|
91
|
+
], param => {
|
|
92
|
+
let method = param[0];
|
|
93
|
+
return Stdlib_Option.map(param[1], op => [
|
|
94
|
+
path,
|
|
95
|
+
method,
|
|
96
|
+
op
|
|
97
|
+
]);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function getAllEndpoints(spec) {
|
|
102
|
+
let pathsArray = Object.entries(spec.paths);
|
|
103
|
+
return pathsArray.flatMap(param => getOperations(param[0], param[1])).map(tupleToEndpoint);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function groupByTag(endpoints) {
|
|
107
|
+
let grouped = {};
|
|
108
|
+
endpoints.forEach(endpoint => {
|
|
109
|
+
let tags = Stdlib_Option.getOr(endpoint.tags, ["default"]);
|
|
110
|
+
tags.forEach(tag => {
|
|
111
|
+
let existing = Stdlib_Option.getOr(grouped[tag], []);
|
|
112
|
+
existing.push(endpoint);
|
|
113
|
+
grouped[tag] = existing;
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
return grouped;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function getAllSchemas(spec) {
|
|
120
|
+
return Stdlib_Option.getOr(Stdlib_Option.flatMap(spec.components, c => c.schemas), {});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function getOperationId(path, method, operation) {
|
|
124
|
+
let methodStr = method === "GET" ? "get" : (
|
|
125
|
+
method === "PUT" ? "put" : (
|
|
126
|
+
method === "DELETE" ? "delete" : (
|
|
127
|
+
method === "HEAD" ? "head" : (
|
|
128
|
+
method === "POST" ? "post" : (
|
|
129
|
+
method === "PATCH" ? "patch" : "options"
|
|
130
|
+
)
|
|
131
|
+
)
|
|
132
|
+
)
|
|
133
|
+
)
|
|
134
|
+
);
|
|
135
|
+
let pathParts = path.replaceAll("/", "_").replaceAll("{", "").replaceAll("}", "").replaceAll("-", "_");
|
|
136
|
+
return Stdlib_Option.getOr(operation.operationId, methodStr + pathParts);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function filterByTags(endpoints, includeTags, excludeTags) {
|
|
140
|
+
return endpoints.filter(endpoint => {
|
|
141
|
+
let operationTags = Stdlib_Option.getOr(endpoint.tags, []);
|
|
142
|
+
let included = operationTags.some(tag => includeTags.includes(tag));
|
|
143
|
+
let excluded = operationTags.some(tag => excludeTags.includes(tag));
|
|
144
|
+
if (included) {
|
|
145
|
+
return !excluded;
|
|
146
|
+
} else {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function getAllTags(endpoints) {
|
|
153
|
+
return Array.from(new Set(endpoints.flatMap(endpoint => Stdlib_Option.getOr(endpoint.tags, []))));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export {
|
|
157
|
+
parseMethod,
|
|
158
|
+
httpMethodToString,
|
|
159
|
+
tupleToEndpoint,
|
|
160
|
+
getOperations,
|
|
161
|
+
getAllEndpoints,
|
|
162
|
+
groupByTag,
|
|
163
|
+
getAllSchemas,
|
|
164
|
+
getOperationId,
|
|
165
|
+
filterByTags,
|
|
166
|
+
getAllTags,
|
|
167
|
+
}
|
|
168
|
+
/* No side effect */
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
let empty_files = [];
|
|
5
|
+
|
|
6
|
+
let empty_warnings = [];
|
|
7
|
+
|
|
8
|
+
let empty = {
|
|
9
|
+
files: empty_files,
|
|
10
|
+
warnings: empty_warnings
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
function merge(a, b) {
|
|
14
|
+
return {
|
|
15
|
+
files: a.files.concat(b.files),
|
|
16
|
+
warnings: a.warnings.concat(b.warnings)
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function combine(outputs) {
|
|
21
|
+
return {
|
|
22
|
+
files: outputs.flatMap(p => p.files),
|
|
23
|
+
warnings: outputs.flatMap(p => p.warnings)
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function addFile(file, p) {
|
|
28
|
+
return {
|
|
29
|
+
files: p.files.concat([file]),
|
|
30
|
+
warnings: p.warnings
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function addFiles(files, p) {
|
|
35
|
+
return {
|
|
36
|
+
files: p.files.concat(files),
|
|
37
|
+
warnings: p.warnings
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function addWarning(warning, p) {
|
|
42
|
+
return {
|
|
43
|
+
files: p.files,
|
|
44
|
+
warnings: p.warnings.concat([warning])
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function addWarnings(warnings, p) {
|
|
49
|
+
return {
|
|
50
|
+
files: p.files,
|
|
51
|
+
warnings: p.warnings.concat(warnings)
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function mapFiles(fn, p) {
|
|
56
|
+
return {
|
|
57
|
+
files: p.files.map(fn),
|
|
58
|
+
warnings: p.warnings
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function filterWarnings(pred, p) {
|
|
63
|
+
return {
|
|
64
|
+
files: p.files,
|
|
65
|
+
warnings: p.warnings.filter(pred)
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function make(filesOpt, warningsOpt, param) {
|
|
70
|
+
let files = filesOpt !== undefined ? filesOpt : [];
|
|
71
|
+
let warnings = warningsOpt !== undefined ? warningsOpt : [];
|
|
72
|
+
return {
|
|
73
|
+
files: files,
|
|
74
|
+
warnings: warnings
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function fromFile(file) {
|
|
79
|
+
return make([file], undefined, undefined);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function fromFiles(files) {
|
|
83
|
+
return make(files, undefined, undefined);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function fromWarning(warning) {
|
|
87
|
+
return make(undefined, [warning], undefined);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function fromWarnings(warnings) {
|
|
91
|
+
return make(undefined, warnings, undefined);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function files(p) {
|
|
95
|
+
return p.files;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function warnings(p) {
|
|
99
|
+
return p.warnings;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function fileCount(p) {
|
|
103
|
+
return p.files.length;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function warningCount(p) {
|
|
107
|
+
return p.warnings.length;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function filePaths(p) {
|
|
111
|
+
return p.files.map(f => f.path);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function withWarnings(p, w) {
|
|
115
|
+
return addWarnings(w, p);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function withFiles(p, f) {
|
|
119
|
+
return addFiles(f, p);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function fromFilesAndWarnings(files, warnings) {
|
|
123
|
+
return make(files, warnings, undefined);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export {
|
|
127
|
+
empty,
|
|
128
|
+
merge,
|
|
129
|
+
combine,
|
|
130
|
+
addFile,
|
|
131
|
+
addFiles,
|
|
132
|
+
addWarning,
|
|
133
|
+
addWarnings,
|
|
134
|
+
mapFiles,
|
|
135
|
+
filterWarnings,
|
|
136
|
+
make,
|
|
137
|
+
fromFile,
|
|
138
|
+
fromFiles,
|
|
139
|
+
fromWarning,
|
|
140
|
+
fromWarnings,
|
|
141
|
+
files,
|
|
142
|
+
warnings,
|
|
143
|
+
fileCount,
|
|
144
|
+
warningCount,
|
|
145
|
+
filePaths,
|
|
146
|
+
withWarnings,
|
|
147
|
+
withFiles,
|
|
148
|
+
fromFilesAndWarnings,
|
|
149
|
+
}
|
|
150
|
+
/* No side effect */
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as JsConvertCase from "js-convert-case";
|
|
4
|
+
|
|
5
|
+
function refToTypePath(insideComponentSchemasOpt, modulePrefixOpt, ref) {
|
|
6
|
+
let insideComponentSchemas = insideComponentSchemasOpt !== undefined ? insideComponentSchemasOpt : false;
|
|
7
|
+
let modulePrefix = modulePrefixOpt !== undefined ? modulePrefixOpt : "";
|
|
8
|
+
let parts = ref.split("/");
|
|
9
|
+
let schemaName = parts[parts.length - 1 | 0];
|
|
10
|
+
if (schemaName === undefined) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
let moduleName = JsConvertCase.toPascalCase(schemaName);
|
|
14
|
+
if (insideComponentSchemas) {
|
|
15
|
+
return moduleName + `.t`;
|
|
16
|
+
} else {
|
|
17
|
+
return modulePrefix + `ComponentSchemas.` + moduleName + `.t`;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function refToSchemaPath(insideComponentSchemasOpt, modulePrefixOpt, ref) {
|
|
22
|
+
let insideComponentSchemas = insideComponentSchemasOpt !== undefined ? insideComponentSchemasOpt : false;
|
|
23
|
+
let modulePrefix = modulePrefixOpt !== undefined ? modulePrefixOpt : "";
|
|
24
|
+
let parts = ref.split("/");
|
|
25
|
+
let schemaName = parts[parts.length - 1 | 0];
|
|
26
|
+
if (schemaName === undefined) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
let moduleName = JsConvertCase.toPascalCase(schemaName);
|
|
30
|
+
if (insideComponentSchemas) {
|
|
31
|
+
return moduleName + `.schema`;
|
|
32
|
+
} else {
|
|
33
|
+
return modulePrefix + `ComponentSchemas.` + moduleName + `.schema`;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
refToTypePath,
|
|
39
|
+
refToSchemaPath,
|
|
40
|
+
}
|
|
41
|
+
/* js-convert-case Not a pure module */
|