@sdk-it/dart 0.19.0 → 0.20.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/dist/index.js +101 -234
- package/dist/index.js.map +4 -4
- package/dist/lib/generate.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -2,142 +2,19 @@
|
|
|
2
2
|
import { parse as partContentType } from "fast-content-type-parse";
|
|
3
3
|
import { merge as merge2 } from "lodash-es";
|
|
4
4
|
import assert2 from "node:assert";
|
|
5
|
-
import { writeFile
|
|
6
|
-
import { join
|
|
5
|
+
import { writeFile } from "node:fs/promises";
|
|
6
|
+
import { join } from "node:path";
|
|
7
7
|
import { camelcase as camelcase3 } from "stringcase";
|
|
8
8
|
import yaml from "yaml";
|
|
9
|
-
|
|
10
|
-
// packages/core/dist/index.js
|
|
11
9
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
import
|
|
20
|
-
import ts2 from "typescript";
|
|
21
|
-
import { get } from "lodash-es";
|
|
22
|
-
var deriveSymbol = Symbol.for("serialize");
|
|
23
|
-
var $types = Symbol.for("types");
|
|
24
|
-
async function exist(file) {
|
|
25
|
-
return stat(file).then(() => true).catch(() => false);
|
|
26
|
-
}
|
|
27
|
-
async function writeFiles(dir, contents) {
|
|
28
|
-
await Promise.all(
|
|
29
|
-
Object.entries(contents).map(async ([file, content]) => {
|
|
30
|
-
if (content === null) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
const filePath = isAbsolute(file) ? file : join(dir, file);
|
|
34
|
-
await mkdir(dirname(filePath), { recursive: true });
|
|
35
|
-
if (typeof content === "string") {
|
|
36
|
-
await writeFile(filePath, content, "utf-8");
|
|
37
|
-
} else {
|
|
38
|
-
if (content.ignoreIfExists) {
|
|
39
|
-
if (!await exist(filePath)) {
|
|
40
|
-
await writeFile(filePath, content.content, "utf-8");
|
|
41
|
-
}
|
|
42
|
-
} else {
|
|
43
|
-
await writeFile(filePath, content.content, "utf-8");
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
})
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
async function getFolderExportsV2(folder, options = {
|
|
50
|
-
extensions: "ts",
|
|
51
|
-
ignore: () => false,
|
|
52
|
-
includeExtension: true,
|
|
53
|
-
exportSyntax: "export * from "
|
|
54
|
-
}) {
|
|
55
|
-
options.includeExtension ??= true;
|
|
56
|
-
if (!await exist(folder)) {
|
|
57
|
-
return "";
|
|
58
|
-
}
|
|
59
|
-
const files = await readdir(folder, { withFileTypes: true });
|
|
60
|
-
const exports = [];
|
|
61
|
-
for (const file of files) {
|
|
62
|
-
if (options.ignore?.(file)) {
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
if (file.isDirectory()) {
|
|
66
|
-
if (await exist(
|
|
67
|
-
`${file.parentPath}/${file.name}/index.${options.extensions}`
|
|
68
|
-
)) {
|
|
69
|
-
exports.push(
|
|
70
|
-
`${options.exportSyntax} './${file.name}/index${options.includeExtension ? `.${options.extensions}` : ""}';`
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
} else if (file.name !== `index.${options.extensions}` && options.extensions.includes(getExt(file.name))) {
|
|
74
|
-
exports.push(
|
|
75
|
-
`${options.exportSyntax} './${options.includeExtension ? file.name : file.name.replace(extname(file.name), "")}';`
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return exports.join("\n");
|
|
80
|
-
}
|
|
81
|
-
var getExt = (fileName) => {
|
|
82
|
-
if (!fileName) {
|
|
83
|
-
return "";
|
|
84
|
-
}
|
|
85
|
-
const lastDot = fileName.lastIndexOf(".");
|
|
86
|
-
if (lastDot === -1) {
|
|
87
|
-
return "";
|
|
88
|
-
}
|
|
89
|
-
const ext = fileName.slice(lastDot + 1).split("/").filter(Boolean).join("");
|
|
90
|
-
if (ext === fileName) {
|
|
91
|
-
return "";
|
|
92
|
-
}
|
|
93
|
-
return ext || "txt";
|
|
94
|
-
};
|
|
95
|
-
var logger = debug("january:client");
|
|
96
|
-
function isRef(obj) {
|
|
97
|
-
return obj && "$ref" in obj;
|
|
98
|
-
}
|
|
99
|
-
function notRef(obj) {
|
|
100
|
-
return !isRef(obj);
|
|
101
|
-
}
|
|
102
|
-
function cleanRef(ref) {
|
|
103
|
-
return ref.replace(/^#\//, "");
|
|
104
|
-
}
|
|
105
|
-
function parseRef(ref) {
|
|
106
|
-
const parts = ref.split("/");
|
|
107
|
-
const [model] = parts.splice(-1);
|
|
108
|
-
const [namespace] = parts.splice(-1);
|
|
109
|
-
return {
|
|
110
|
-
model,
|
|
111
|
-
namespace,
|
|
112
|
-
path: cleanRef(parts.join("/"))
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
function followRef(spec, ref) {
|
|
116
|
-
const pathParts = cleanRef(ref).split("/");
|
|
117
|
-
const entry = get(spec, pathParts);
|
|
118
|
-
if (entry && "$ref" in entry) {
|
|
119
|
-
return followRef(spec, entry.$ref);
|
|
120
|
-
}
|
|
121
|
-
return entry;
|
|
122
|
-
}
|
|
123
|
-
function isEmpty(value) {
|
|
124
|
-
if (value === null || value === void 0 || value === "") {
|
|
125
|
-
return true;
|
|
126
|
-
}
|
|
127
|
-
if (Array.isArray(value) && value.length === 0) {
|
|
128
|
-
return true;
|
|
129
|
-
}
|
|
130
|
-
if (typeof value === "object" && Object.keys(value).length === 0) {
|
|
131
|
-
return true;
|
|
132
|
-
}
|
|
133
|
-
return false;
|
|
134
|
-
}
|
|
135
|
-
function pascalcase(value) {
|
|
136
|
-
return _pascalcase(value.split("/").join(" "));
|
|
137
|
-
}
|
|
138
|
-
function snakecase(value) {
|
|
139
|
-
return _snakecase(value.split("/").join(" "));
|
|
140
|
-
}
|
|
10
|
+
followRef as followRef3,
|
|
11
|
+
isEmpty as isEmpty2,
|
|
12
|
+
isRef as isRef3,
|
|
13
|
+
notRef as notRef2,
|
|
14
|
+
pascalcase as pascalcase2,
|
|
15
|
+
snakecase as snakecase2
|
|
16
|
+
} from "@sdk-it/core";
|
|
17
|
+
import { getFolderExportsV2, writeFiles } from "@sdk-it/core/file-system.js";
|
|
141
18
|
|
|
142
19
|
// packages/spec/dist/lib/loaders/local-loader.js
|
|
143
20
|
import { parse } from "yaml";
|
|
@@ -147,6 +24,7 @@ import { parse as parse2 } from "yaml";
|
|
|
147
24
|
|
|
148
25
|
// packages/spec/dist/lib/operation.js
|
|
149
26
|
import { camelcase } from "stringcase";
|
|
27
|
+
import { followRef, isRef } from "@sdk-it/core";
|
|
150
28
|
var defaults = {
|
|
151
29
|
operationId: (operation, path, method) => {
|
|
152
30
|
if (operation.operationId) {
|
|
@@ -161,9 +39,18 @@ var defaults = {
|
|
|
161
39
|
);
|
|
162
40
|
},
|
|
163
41
|
tag: (operation, path) => {
|
|
164
|
-
return operation.tags?.[0]
|
|
42
|
+
return operation.tags?.[0] ? sanitizeTag(operation.tags?.[0]) : determineGenericTag(path, operation);
|
|
165
43
|
}
|
|
166
44
|
};
|
|
45
|
+
function resolveResponses(spec, operation) {
|
|
46
|
+
const responses = operation.responses ?? {};
|
|
47
|
+
const resolved = {};
|
|
48
|
+
for (const status in responses) {
|
|
49
|
+
const response = isRef(responses[status]) ? followRef(spec, responses[status].$ref) : responses[status];
|
|
50
|
+
resolved[status] = response;
|
|
51
|
+
}
|
|
52
|
+
return resolved;
|
|
53
|
+
}
|
|
167
54
|
function forEachOperation(config, callback) {
|
|
168
55
|
const result = [];
|
|
169
56
|
for (const [path, pathItem] of Object.entries(config.spec.paths ?? {})) {
|
|
@@ -187,7 +74,8 @@ function forEachOperation(config, callback) {
|
|
|
187
74
|
{
|
|
188
75
|
...operation,
|
|
189
76
|
parameters: [...parameters, ...operation.parameters ?? []],
|
|
190
|
-
operationId: operationName
|
|
77
|
+
operationId: operationName,
|
|
78
|
+
responses: resolveResponses(config.spec, operation)
|
|
191
79
|
}
|
|
192
80
|
)
|
|
193
81
|
);
|
|
@@ -196,15 +84,11 @@ function forEachOperation(config, callback) {
|
|
|
196
84
|
return result;
|
|
197
85
|
}
|
|
198
86
|
var reservedKeywords = /* @__PURE__ */ new Set([
|
|
199
|
-
"abstract",
|
|
200
|
-
"arguments",
|
|
201
87
|
"await",
|
|
202
|
-
|
|
88
|
+
// Reserved in async functions
|
|
203
89
|
"break",
|
|
204
|
-
"byte",
|
|
205
90
|
"case",
|
|
206
91
|
"catch",
|
|
207
|
-
"char",
|
|
208
92
|
"class",
|
|
209
93
|
"const",
|
|
210
94
|
"continue",
|
|
@@ -212,85 +96,59 @@ var reservedKeywords = /* @__PURE__ */ new Set([
|
|
|
212
96
|
"default",
|
|
213
97
|
"delete",
|
|
214
98
|
"do",
|
|
215
|
-
"double",
|
|
216
99
|
"else",
|
|
217
100
|
"enum",
|
|
218
|
-
"eval",
|
|
219
101
|
"export",
|
|
220
102
|
"extends",
|
|
221
103
|
"false",
|
|
222
|
-
"final",
|
|
223
104
|
"finally",
|
|
224
|
-
"float",
|
|
225
105
|
"for",
|
|
226
106
|
"function",
|
|
227
|
-
"goto",
|
|
228
107
|
"if",
|
|
229
108
|
"implements",
|
|
109
|
+
// Strict mode
|
|
230
110
|
"import",
|
|
231
111
|
"in",
|
|
232
112
|
"instanceof",
|
|
233
|
-
"int",
|
|
234
113
|
"interface",
|
|
114
|
+
// Strict mode
|
|
235
115
|
"let",
|
|
236
|
-
|
|
237
|
-
"native",
|
|
116
|
+
// Strict mode
|
|
238
117
|
"new",
|
|
239
118
|
"null",
|
|
240
119
|
"package",
|
|
120
|
+
// Strict mode
|
|
241
121
|
"private",
|
|
122
|
+
// Strict mode
|
|
242
123
|
"protected",
|
|
124
|
+
// Strict mode
|
|
243
125
|
"public",
|
|
126
|
+
// Strict mode
|
|
244
127
|
"return",
|
|
245
|
-
"short",
|
|
246
128
|
"static",
|
|
129
|
+
// Strict mode
|
|
247
130
|
"super",
|
|
248
131
|
"switch",
|
|
249
|
-
"synchronized",
|
|
250
132
|
"this",
|
|
251
133
|
"throw",
|
|
252
|
-
"throws",
|
|
253
|
-
"transient",
|
|
254
134
|
"true",
|
|
255
135
|
"try",
|
|
256
136
|
"typeof",
|
|
257
137
|
"var",
|
|
258
138
|
"void",
|
|
259
|
-
"volatile",
|
|
260
139
|
"while",
|
|
261
140
|
"with",
|
|
262
141
|
"yield",
|
|
263
|
-
//
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
"
|
|
267
|
-
"any",
|
|
268
|
-
"unknown",
|
|
269
|
-
"never",
|
|
270
|
-
"get",
|
|
271
|
-
"list",
|
|
272
|
-
"create",
|
|
273
|
-
"update",
|
|
274
|
-
"delete",
|
|
275
|
-
"post",
|
|
276
|
-
"put",
|
|
277
|
-
"patch",
|
|
278
|
-
"do",
|
|
279
|
-
"send",
|
|
280
|
-
"add",
|
|
281
|
-
"remove",
|
|
282
|
-
"set",
|
|
283
|
-
"find",
|
|
284
|
-
"search",
|
|
285
|
-
"check",
|
|
286
|
-
"make"
|
|
287
|
-
// Added make, check
|
|
142
|
+
// Strict mode / Generator functions
|
|
143
|
+
// 'arguments' is not technically a reserved word, but it's a special identifier within functions
|
|
144
|
+
// and assigning to it or declaring it can cause issues or unexpected behavior.
|
|
145
|
+
"arguments"
|
|
288
146
|
]);
|
|
289
147
|
function sanitizeTag(camelCasedTag) {
|
|
290
148
|
if (/^\d/.test(camelCasedTag)) {
|
|
291
149
|
return `_${camelCasedTag}`;
|
|
292
150
|
}
|
|
293
|
-
return reservedKeywords.has(camelCasedTag) ? `${camelCasedTag}_` : camelCasedTag;
|
|
151
|
+
return reservedKeywords.has(camelcase(camelCasedTag)) ? `${camelCasedTag}_` : camelCasedTag;
|
|
294
152
|
}
|
|
295
153
|
function determineGenericTag(pathString, operation) {
|
|
296
154
|
const operationId = operation.operationId || "";
|
|
@@ -314,7 +172,6 @@ function determineGenericTag(pathString, operation) {
|
|
|
314
172
|
"search",
|
|
315
173
|
"check",
|
|
316
174
|
"make"
|
|
317
|
-
// Added make
|
|
318
175
|
]);
|
|
319
176
|
const segments = pathString.split("/").filter(Boolean);
|
|
320
177
|
const potentialCandidates = segments.filter(
|
|
@@ -434,7 +291,16 @@ function isSuccessStatusCode(statusCode) {
|
|
|
434
291
|
// packages/dart/src/lib/dart-emitter.ts
|
|
435
292
|
import { merge } from "lodash-es";
|
|
436
293
|
import assert from "node:assert";
|
|
437
|
-
import { camelcase as camelcase2, snakecase
|
|
294
|
+
import { camelcase as camelcase2, snakecase } from "stringcase";
|
|
295
|
+
import {
|
|
296
|
+
cleanRef,
|
|
297
|
+
followRef as followRef2,
|
|
298
|
+
isEmpty,
|
|
299
|
+
isRef as isRef2,
|
|
300
|
+
notRef,
|
|
301
|
+
parseRef,
|
|
302
|
+
pascalcase
|
|
303
|
+
} from "@sdk-it/core";
|
|
438
304
|
var formatName = (it) => {
|
|
439
305
|
const startsWithDigitPattern = /^-?\d/;
|
|
440
306
|
if (typeof it === "number") {
|
|
@@ -462,9 +328,9 @@ var formatName = (it) => {
|
|
|
462
328
|
if (nameToFormat.endsWith("]")) {
|
|
463
329
|
nameToFormat = nameToFormat.slice(0, -1);
|
|
464
330
|
}
|
|
465
|
-
return
|
|
331
|
+
return snakecase(nameToFormat);
|
|
466
332
|
}
|
|
467
|
-
return
|
|
333
|
+
return snakecase(String(it));
|
|
468
334
|
};
|
|
469
335
|
var DartSerializer = class {
|
|
470
336
|
#spec;
|
|
@@ -478,7 +344,7 @@ var DartSerializer = class {
|
|
|
478
344
|
this.#spec.components.schemas ??= {};
|
|
479
345
|
this.#spec.components.responses ??= {};
|
|
480
346
|
const checkSchema = (schema) => {
|
|
481
|
-
if (
|
|
347
|
+
if (isRef2(schema)) {
|
|
482
348
|
const { model } = parseRef(schema.$ref);
|
|
483
349
|
return model === schemaName;
|
|
484
350
|
}
|
|
@@ -684,7 +550,7 @@ return ${matches.join(" && ")};
|
|
|
684
550
|
const schemaName = cleanRef($ref).split("/").pop();
|
|
685
551
|
const serialized = this.handle(
|
|
686
552
|
schemaName,
|
|
687
|
-
|
|
553
|
+
followRef2(this.#spec, $ref),
|
|
688
554
|
required,
|
|
689
555
|
{
|
|
690
556
|
...context,
|
|
@@ -697,7 +563,7 @@ return ${matches.join(" && ")};
|
|
|
697
563
|
// fixme: this method should no longer be needed because the logic in it is being preprocessed before emitting begins
|
|
698
564
|
#allOf(className, schemas, context) {
|
|
699
565
|
const name = pascalcase(context.propName || className);
|
|
700
|
-
const refs = schemas.filter(
|
|
566
|
+
const refs = schemas.filter(isRef2);
|
|
701
567
|
const nonRefs = schemas.filter(notRef);
|
|
702
568
|
if (nonRefs.some((it) => it.type && it.type !== "object")) {
|
|
703
569
|
assert(false, `allOf ${name} must be an object`);
|
|
@@ -705,7 +571,7 @@ return ${matches.join(" && ")};
|
|
|
705
571
|
const objectSchema = merge(
|
|
706
572
|
{},
|
|
707
573
|
...nonRefs,
|
|
708
|
-
...refs.map((ref) =>
|
|
574
|
+
...refs.map((ref) => followRef2(this.#spec, ref.$ref))
|
|
709
575
|
);
|
|
710
576
|
delete objectSchema.allOf;
|
|
711
577
|
return this.handle(name, objectSchema, true, context);
|
|
@@ -721,8 +587,8 @@ return ${matches.join(" && ")};
|
|
|
721
587
|
};
|
|
722
588
|
}
|
|
723
589
|
const nullSchemaIndex = schemas.findIndex((schema) => {
|
|
724
|
-
if (
|
|
725
|
-
const refSchema =
|
|
590
|
+
if (isRef2(schema)) {
|
|
591
|
+
const refSchema = followRef2(this.#spec, schema.$ref);
|
|
726
592
|
return refSchema.type === "null";
|
|
727
593
|
}
|
|
728
594
|
return schema.type === "null";
|
|
@@ -762,7 +628,7 @@ return ${matches.join(" && ")};
|
|
|
762
628
|
const patterns = [];
|
|
763
629
|
const objects = schemas.filter(notRef).filter((it) => it.type === "object");
|
|
764
630
|
for (const schema of schemas) {
|
|
765
|
-
if (
|
|
631
|
+
if (isRef2(schema)) {
|
|
766
632
|
const refType = this.#ref(className, schema.$ref, true, context);
|
|
767
633
|
patterns.push({
|
|
768
634
|
pattern: `case ${refType.type || "Map<String, dynamic>"} map when ${refType.use}.matches(map): return ${refType.use}.fromJson(map);`,
|
|
@@ -1013,7 +879,7 @@ return false;
|
|
|
1013
879
|
};
|
|
1014
880
|
}
|
|
1015
881
|
#serialize(className, schema, required = true, context = {}) {
|
|
1016
|
-
if (
|
|
882
|
+
if (isRef2(schema)) {
|
|
1017
883
|
return this.#ref(className, schema.$ref, required, context);
|
|
1018
884
|
}
|
|
1019
885
|
if (schema.allOf && Array.isArray(schema.allOf)) {
|
|
@@ -1077,7 +943,7 @@ return false;
|
|
|
1077
943
|
}
|
|
1078
944
|
};
|
|
1079
945
|
function isObjectSchema(schema) {
|
|
1080
|
-
return !
|
|
946
|
+
return !isRef2(schema) && (schema.type === "object" || !!schema.properties);
|
|
1081
947
|
}
|
|
1082
948
|
|
|
1083
949
|
// packages/dart/src/lib/http/dispatcher.txt
|
|
@@ -1092,34 +958,34 @@ var responses_default = "sealed class ApiError {\n final String message;\n fin
|
|
|
1092
958
|
// packages/dart/src/lib/generate.ts
|
|
1093
959
|
function tuneSpec(spec, schemas, refs) {
|
|
1094
960
|
for (const [name, schema] of Object.entries(schemas)) {
|
|
1095
|
-
if (
|
|
961
|
+
if (isRef3(schema))
|
|
1096
962
|
continue;
|
|
1097
|
-
if (!
|
|
963
|
+
if (!isEmpty2(schema.anyOf) && !isEmpty2(schema.oneOf)) {
|
|
1098
964
|
delete schema.anyOf;
|
|
1099
965
|
}
|
|
1100
|
-
if (!
|
|
966
|
+
if (!isEmpty2(schema.allOf)) {
|
|
1101
967
|
const schemas2 = schema.allOf;
|
|
1102
|
-
const refs2 = schemas2.filter(
|
|
1103
|
-
const nonRefs = schemas2.filter(
|
|
968
|
+
const refs2 = schemas2.filter(isRef3);
|
|
969
|
+
const nonRefs = schemas2.filter(notRef2);
|
|
1104
970
|
if (nonRefs.some((it) => it.type && it.type !== "object")) {
|
|
1105
971
|
assert2(false, `allOf ${name} must be an object`);
|
|
1106
972
|
}
|
|
1107
973
|
const objectSchema = merge2(
|
|
1108
974
|
{},
|
|
1109
975
|
...nonRefs,
|
|
1110
|
-
...refs2.map((ref) =>
|
|
976
|
+
...refs2.map((ref) => followRef3(spec, ref.$ref))
|
|
1111
977
|
);
|
|
1112
978
|
delete objectSchema.allOf;
|
|
1113
979
|
delete schema.allOf;
|
|
1114
980
|
Object.assign(schema, objectSchema);
|
|
1115
981
|
}
|
|
1116
982
|
if (schema.type === "object") {
|
|
1117
|
-
if (!
|
|
983
|
+
if (!isEmpty2(schema.oneOf)) {
|
|
1118
984
|
for (const oneOfIdx in schema.oneOf) {
|
|
1119
985
|
const oneOf = schema.oneOf[oneOfIdx];
|
|
1120
|
-
if (
|
|
986
|
+
if (isRef3(oneOf))
|
|
1121
987
|
continue;
|
|
1122
|
-
if (!
|
|
988
|
+
if (!isEmpty2(oneOf.required) && schema.properties) {
|
|
1123
989
|
schema.oneOf[oneOfIdx] = schema.properties[oneOf.required[0]];
|
|
1124
990
|
}
|
|
1125
991
|
}
|
|
@@ -1129,22 +995,22 @@ function tuneSpec(spec, schemas, refs) {
|
|
|
1129
995
|
}
|
|
1130
996
|
schema.properties ??= {};
|
|
1131
997
|
for (const [propName, value] of Object.entries(schema.properties)) {
|
|
1132
|
-
if (
|
|
998
|
+
if (isRef3(value))
|
|
1133
999
|
continue;
|
|
1134
|
-
const refName =
|
|
1000
|
+
const refName = pascalcase2(`${name} ${propName.replace("[]", "")}`);
|
|
1135
1001
|
refs.push({ name: refName, value });
|
|
1136
1002
|
schema.properties[propName] = {
|
|
1137
1003
|
$ref: `#/components/schemas/${refName}`
|
|
1138
1004
|
};
|
|
1139
1005
|
const props = Object.fromEntries(
|
|
1140
1006
|
Object.entries(value.properties ?? {}).map(([key, value2]) => {
|
|
1141
|
-
return [
|
|
1007
|
+
return [pascalcase2(`${refName} ${key}`), value2];
|
|
1142
1008
|
})
|
|
1143
1009
|
);
|
|
1144
1010
|
tuneSpec(spec, props, refs);
|
|
1145
1011
|
}
|
|
1146
1012
|
} else if (schema.type === "array") {
|
|
1147
|
-
if (
|
|
1013
|
+
if (isRef3(schema.items))
|
|
1148
1014
|
continue;
|
|
1149
1015
|
const refName = name;
|
|
1150
1016
|
refs.push({ name: refName, value: schema.items ?? {} });
|
|
@@ -1156,7 +1022,7 @@ function tuneSpec(spec, schemas, refs) {
|
|
|
1156
1022
|
}
|
|
1157
1023
|
async function generate(spec, settings) {
|
|
1158
1024
|
const clientName = settings.name || "Client";
|
|
1159
|
-
const output =
|
|
1025
|
+
const output = join(settings.output, "lib");
|
|
1160
1026
|
const groups = {};
|
|
1161
1027
|
spec.components ??= {};
|
|
1162
1028
|
spec.components.schemas ??= {};
|
|
@@ -1169,15 +1035,16 @@ async function generate(spec, settings) {
|
|
|
1169
1035
|
for (const status in operation.responses) {
|
|
1170
1036
|
if (!isSuccessStatusCode(status))
|
|
1171
1037
|
continue;
|
|
1172
|
-
const response2 =
|
|
1173
|
-
if (!
|
|
1038
|
+
const response2 = operation.responses[status];
|
|
1039
|
+
if (!isEmpty2(response2.content)) {
|
|
1174
1040
|
for (const [contentType, mediaType] of Object.entries(
|
|
1175
1041
|
response2.content
|
|
1176
1042
|
)) {
|
|
1177
1043
|
if (parseJsonContentType(contentType)) {
|
|
1178
|
-
if (mediaType.schema && !
|
|
1179
|
-
const outputName =
|
|
1044
|
+
if (mediaType.schema && !isRef3(mediaType.schema)) {
|
|
1045
|
+
const outputName = pascalcase2(`${operation.operationId} output`);
|
|
1180
1046
|
spec.components.schemas[outputName] = mediaType.schema;
|
|
1047
|
+
operation.responses[status].content ??= {};
|
|
1181
1048
|
operation.responses[status].content[contentType].schema = {
|
|
1182
1049
|
$ref: `#/components/schemas/${outputName}`
|
|
1183
1050
|
};
|
|
@@ -1189,7 +1056,7 @@ async function generate(spec, settings) {
|
|
|
1189
1056
|
console.log(`Processing ${entry.method} ${entry.path}`);
|
|
1190
1057
|
const group = groups[entry.groupName] ?? (groups[entry.groupName] = {
|
|
1191
1058
|
methods: [],
|
|
1192
|
-
use: `final ${entry.groupName} = new ${
|
|
1059
|
+
use: `final ${entry.groupName} = new ${pascalcase2(entry.groupName)}();`
|
|
1193
1060
|
});
|
|
1194
1061
|
const input = toInputs(spec, { entry, operation });
|
|
1195
1062
|
Object.assign(inputs, input.inputs);
|
|
@@ -1199,7 +1066,7 @@ async function generate(spec, settings) {
|
|
|
1199
1066
|
}
|
|
1200
1067
|
group.methods.push(`
|
|
1201
1068
|
Future<${response ? response.returnType : "http.StreamedResponse"}> ${camelcase3(operation.operationId)}(
|
|
1202
|
-
${
|
|
1069
|
+
${isEmpty2(operation.requestBody) ? "" : `${input.inputName} input`}
|
|
1203
1070
|
) async {
|
|
1204
1071
|
final stream = await this.dispatcher.${input.contentType}(RequestConfig(
|
|
1205
1072
|
method: '${entry.method}',
|
|
@@ -1215,24 +1082,24 @@ async function generate(spec, settings) {
|
|
|
1215
1082
|
for (const ref of newRefs) {
|
|
1216
1083
|
spec.components.schemas[ref.name] = ref.value;
|
|
1217
1084
|
}
|
|
1218
|
-
await
|
|
1219
|
-
|
|
1085
|
+
await writeFile(
|
|
1086
|
+
join(process.cwd(), "openai.json"),
|
|
1220
1087
|
JSON.stringify(spec, null, 2)
|
|
1221
1088
|
);
|
|
1222
1089
|
const models = Object.entries(spec.components.schemas).reduce((acc, [name, schema]) => {
|
|
1223
1090
|
const serializer = new DartSerializer(spec, (name2, content) => {
|
|
1224
|
-
acc[`models/${
|
|
1091
|
+
acc[`models/${snakecase2(name2)}.dart`] = `import 'dart:io';import 'dart:typed_data'; import './index.dart';
|
|
1225
1092
|
|
|
1226
1093
|
${content}`;
|
|
1227
1094
|
});
|
|
1228
|
-
serializer.handle(
|
|
1095
|
+
serializer.handle(pascalcase2(name), schema);
|
|
1229
1096
|
return acc;
|
|
1230
1097
|
}, {});
|
|
1231
1098
|
const clazzez = Object.entries(groups).reduce(
|
|
1232
1099
|
(acc, [name, { methods }]) => {
|
|
1233
1100
|
return {
|
|
1234
1101
|
...acc,
|
|
1235
|
-
[`api/${
|
|
1102
|
+
[`api/${snakecase2(name)}.dart`]: `
|
|
1236
1103
|
import 'dart:convert';
|
|
1237
1104
|
|
|
1238
1105
|
import 'package:http/http.dart' as http;
|
|
@@ -1243,10 +1110,10 @@ import '../outputs/index.dart';
|
|
|
1243
1110
|
import '../models/index.dart';
|
|
1244
1111
|
import '../http.dart';
|
|
1245
1112
|
|
|
1246
|
-
class ${
|
|
1113
|
+
class ${pascalcase2(name)}Client {
|
|
1247
1114
|
final Dispatcher dispatcher;
|
|
1248
1115
|
final Receiver receiver;
|
|
1249
|
-
${
|
|
1116
|
+
${pascalcase2(name)}Client(this.dispatcher, this.receiver);
|
|
1250
1117
|
${methods.join("\n")}
|
|
1251
1118
|
}
|
|
1252
1119
|
`
|
|
@@ -1255,20 +1122,20 @@ import '../http.dart';
|
|
|
1255
1122
|
{}
|
|
1256
1123
|
);
|
|
1257
1124
|
const client = `
|
|
1258
|
-
${Object.keys(groups).map((name) => `import './api/${
|
|
1125
|
+
${Object.keys(groups).map((name) => `import './api/${snakecase2(name)}.dart';`).join("\n")}
|
|
1259
1126
|
import './interceptors.dart';
|
|
1260
1127
|
import './http.dart';
|
|
1261
1128
|
|
|
1262
1129
|
class ${clientName} {
|
|
1263
1130
|
final Options options;
|
|
1264
|
-
${Object.keys(groups).map((name) => `late final ${
|
|
1131
|
+
${Object.keys(groups).map((name) => `late final ${pascalcase2(name)}Client ${camelcase3(name)};`).join("\n")}
|
|
1265
1132
|
|
|
1266
1133
|
${clientName}(this.options) {
|
|
1267
1134
|
final interceptors = [BaseUrlInterceptor(() => this.options.baseUrl)];
|
|
1268
1135
|
final dispatcher = Dispatcher(interceptors);
|
|
1269
1136
|
final receiver = Receiver(interceptors);
|
|
1270
1137
|
${Object.keys(groups).map(
|
|
1271
|
-
(name) => `this.${camelcase3(name)} = ${
|
|
1138
|
+
(name) => `this.${camelcase3(name)} = ${pascalcase2(name)}Client(dispatcher, receiver);`
|
|
1272
1139
|
).join("\n")}
|
|
1273
1140
|
|
|
1274
1141
|
}
|
|
@@ -1293,15 +1160,15 @@ class Options {
|
|
|
1293
1160
|
...outputs
|
|
1294
1161
|
});
|
|
1295
1162
|
await writeFiles(output, {
|
|
1296
|
-
"models/index.dart": await getFolderExportsV2(
|
|
1163
|
+
"models/index.dart": await getFolderExportsV2(join(output, "models"), {
|
|
1297
1164
|
exportSyntax: "export",
|
|
1298
1165
|
extensions: "dart"
|
|
1299
1166
|
}),
|
|
1300
|
-
"inputs/index.dart": await getFolderExportsV2(
|
|
1167
|
+
"inputs/index.dart": await getFolderExportsV2(join(output, "inputs"), {
|
|
1301
1168
|
exportSyntax: "export",
|
|
1302
1169
|
extensions: "dart"
|
|
1303
1170
|
}),
|
|
1304
|
-
"outputs/index.dart": await getFolderExportsV2(
|
|
1171
|
+
"outputs/index.dart": await getFolderExportsV2(join(output, "outputs"), {
|
|
1305
1172
|
exportSyntax: "export",
|
|
1306
1173
|
extensions: "dart"
|
|
1307
1174
|
}),
|
|
@@ -1311,7 +1178,7 @@ class Options {
|
|
|
1311
1178
|
...clazzez
|
|
1312
1179
|
});
|
|
1313
1180
|
await writeFiles(output, {
|
|
1314
|
-
"package.dart": `${await getFolderExportsV2(
|
|
1181
|
+
"package.dart": `${await getFolderExportsV2(join(output), {
|
|
1315
1182
|
exportSyntax: "export",
|
|
1316
1183
|
extensions: "dart",
|
|
1317
1184
|
ignore(dirent) {
|
|
@@ -1323,7 +1190,7 @@ class Options {
|
|
|
1323
1190
|
"pubspec.yaml": {
|
|
1324
1191
|
ignoreIfExists: true,
|
|
1325
1192
|
content: yaml.stringify({
|
|
1326
|
-
name: settings.name ? `${
|
|
1193
|
+
name: settings.name ? `${snakecase2(clientName.toLowerCase())}_sdk` : "sdk",
|
|
1327
1194
|
version: "0.0.1",
|
|
1328
1195
|
environment: {
|
|
1329
1196
|
sdk: "^3.7.2"
|
|
@@ -1341,13 +1208,13 @@ class Options {
|
|
|
1341
1208
|
}
|
|
1342
1209
|
function toInputs(spec, { entry, operation }) {
|
|
1343
1210
|
const inputs = {};
|
|
1344
|
-
const inputName =
|
|
1211
|
+
const inputName = pascalcase2(`${operation.operationId} input`);
|
|
1345
1212
|
let contentType = "empty";
|
|
1346
1213
|
let encode = "";
|
|
1347
|
-
if (!
|
|
1348
|
-
const requestBody =
|
|
1214
|
+
if (!isEmpty2(operation.requestBody)) {
|
|
1215
|
+
const requestBody = isRef3(operation.requestBody) ? followRef3(spec, operation.requestBody.$ref) : operation.requestBody;
|
|
1349
1216
|
for (const type in requestBody.content) {
|
|
1350
|
-
const ctSchema =
|
|
1217
|
+
const ctSchema = isRef3(requestBody.content[type].schema) ? followRef3(spec, requestBody.content[type].schema.$ref) : requestBody.content[type].schema;
|
|
1351
1218
|
if (!ctSchema) {
|
|
1352
1219
|
console.warn(
|
|
1353
1220
|
`Schema not found for ${type} in ${entry.method} ${entry.path}`
|
|
@@ -1355,7 +1222,7 @@ function toInputs(spec, { entry, operation }) {
|
|
|
1355
1222
|
continue;
|
|
1356
1223
|
}
|
|
1357
1224
|
const serializer = new DartSerializer(spec, (name, content) => {
|
|
1358
|
-
inputs[
|
|
1225
|
+
inputs[join(`inputs/${name}.dart`)] = `import 'dart:io';import 'dart:typed_data';import '../models/index.dart'; import './index.dart';
|
|
1359
1226
|
|
|
1360
1227
|
${content}`;
|
|
1361
1228
|
});
|
|
@@ -1374,11 +1241,11 @@ ${content}`;
|
|
|
1374
1241
|
return { inputs, inputName, contentType, encode };
|
|
1375
1242
|
}
|
|
1376
1243
|
function toOutput(spec, operation) {
|
|
1377
|
-
const outputName =
|
|
1244
|
+
const outputName = pascalcase2(`${operation.operationId} output`);
|
|
1378
1245
|
operation.responses ??= {};
|
|
1379
1246
|
const outputs = {};
|
|
1380
1247
|
for (const status in operation.responses) {
|
|
1381
|
-
const response =
|
|
1248
|
+
const response = isRef3(operation.responses[status]) ? followRef3(spec, operation.responses[status].$ref) : operation.responses[status];
|
|
1382
1249
|
for (const type in response.content) {
|
|
1383
1250
|
const { schema } = response.content[type];
|
|
1384
1251
|
if (!schema) {
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/lib/generate.ts", "../../
|
|
4
|
-
"sourcesContent": ["import { parse as partContentType } from 'fast-content-type-parse';\nimport { merge } from 'lodash-es';\nimport assert from 'node:assert';\nimport { writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport type {\n OpenAPIObject,\n OperationObject,\n ReferenceObject,\n RequestBodyObject,\n ResponseObject,\n SchemaObject,\n} from 'openapi3-ts/oas31';\nimport { camelcase } from 'stringcase';\nimport yaml from 'yaml';\n\nimport {\n followRef,\n getFolderExportsV2,\n isEmpty,\n isRef,\n notRef,\n pascalcase,\n snakecase,\n writeFiles,\n} from '@sdk-it/core';\nimport {\n type Operation,\n forEachOperation,\n isStreamingContentType,\n isSuccessStatusCode,\n parseJsonContentType,\n} from '@sdk-it/spec';\n\nimport { DartSerializer, isObjectSchema } from './dart-emitter.ts';\nimport dispatcherTxt from './http/dispatcher.txt';\nimport interceptorsTxt from './http/interceptors.txt';\nimport responsesTxt from './http/responses.txt';\n\nfunction tuneSpec(\n spec: OpenAPIObject,\n schemas: Record<string, SchemaObject | ReferenceObject>,\n refs: { name: string; value: SchemaObject }[],\n) {\n for (const [name, schema] of Object.entries(schemas)) {\n if (isRef(schema)) continue;\n\n if (!isEmpty(schema.anyOf) && !isEmpty(schema.oneOf)) {\n delete schema.anyOf;\n }\n if (!isEmpty(schema.allOf)) {\n const schemas = schema.allOf;\n const refs = schemas.filter(isRef);\n const nonRefs = schemas.filter(notRef);\n if (nonRefs.some((it) => it.type && it.type !== 'object')) {\n assert(false, `allOf ${name} must be an object`);\n }\n const objectSchema = merge(\n {},\n ...nonRefs,\n ...refs.map((ref) => followRef(spec, ref.$ref)),\n );\n delete objectSchema.allOf;\n delete schema.allOf;\n Object.assign(schema, objectSchema);\n }\n\n if (schema.type === 'object') {\n if (!isEmpty(schema.oneOf)) {\n for (const oneOfIdx in schema.oneOf) {\n const oneOf = schema.oneOf[oneOfIdx];\n if (isRef(oneOf)) continue;\n if (!isEmpty(oneOf.required) && schema.properties) {\n schema.oneOf[oneOfIdx] = schema.properties[oneOf.required[0]];\n }\n }\n\n delete schema.type;\n tuneSpec(spec, schemas, refs);\n continue;\n }\n\n schema.properties ??= {};\n\n for (const [propName, value] of Object.entries(schema.properties)) {\n if (isRef(value)) continue;\n const refName = pascalcase(`${name} ${propName.replace('[]', '')}`);\n refs.push({ name: refName, value });\n schema.properties[propName] = {\n $ref: `#/components/schemas/${refName}`,\n };\n const props = Object.fromEntries(\n Object.entries(value.properties ?? {}).map(([key, value]) => {\n return [pascalcase(`${refName} ${key}`), value];\n }),\n );\n tuneSpec(spec, props, refs);\n // if (value.oneOf && Array.isArray(value.oneOf) && value.oneOf.length) {\n // for (const oneOfIdx in value.oneOf) {\n // const oneOf = value.oneOf[oneOfIdx];\n // if (isRef(oneOf)) continue;\n // if (oneOf.type === 'string') {\n // console.log(refName);\n // // const refName= pascalcase(`${name} ${key} ${oneOfIdx}`);\n // // schema.oneOf[oneOfIdx] = {\n // // $ref: `#/components/schemas/${refName}`,\n // // };\n // }\n // }\n // }\n }\n } else if (schema.type === 'array') {\n if (isRef(schema.items)) continue;\n const refName = name;\n refs.push({ name: refName, value: schema.items ?? {} });\n schema.items = {\n $ref: `#/components/schemas/${refName}`,\n };\n }\n }\n}\nexport async function generate(\n spec: OpenAPIObject,\n settings: {\n output: string;\n name?: string;\n /**\n * full: generate a full project including package.json and tsconfig.json. useful for monorepo/workspaces\n * minimal: generate only the client sdk\n */\n mode?: 'full' | 'minimal';\n formatCode?: (options: { output: string }) => void | Promise<void>;\n },\n) {\n const clientName = settings.name || 'Client';\n const output = join(settings.output, 'lib');\n const groups: Record<\n string,\n {\n use: string;\n methods: string[];\n }\n > = {};\n spec.components ??= {};\n spec.components.schemas ??= {};\n const inputs: Record<string, string> = {};\n const outputs: Record<string, string> = {};\n forEachOperation({ spec }, (entry, operation) => {\n // if (entry.path !== '/v6/prepareUpload') {\n // return;\n // }\n operation.responses ??= {};\n spec.components ??= {};\n spec.components.schemas ??= {};\n for (const status in operation.responses) {\n if (!isSuccessStatusCode(status)) continue;\n const response = isRef(operation.responses[status] as ReferenceObject)\n ? followRef<ResponseObject>(spec, operation.responses[status].$ref)\n : (operation.responses[status] as ResponseObject);\n if (!isEmpty(response.content)) {\n for (const [contentType, mediaType] of Object.entries(\n response.content,\n )) {\n if (parseJsonContentType(contentType)) {\n if (mediaType.schema && !isRef(mediaType.schema)) {\n const outputName = pascalcase(`${operation.operationId} output`);\n spec.components.schemas[outputName] = mediaType.schema;\n operation.responses[status].content[contentType].schema = {\n $ref: `#/components/schemas/${outputName}`,\n };\n }\n }\n // handle chunked response\n }\n }\n }\n console.log(`Processing ${entry.method} ${entry.path}`);\n const group =\n groups[entry.groupName] ??\n (groups[entry.groupName] = {\n methods: [],\n use: `final ${entry.groupName} = new ${pascalcase(entry.groupName)}();`,\n });\n\n const input = toInputs(spec, { entry, operation });\n Object.assign(inputs, input.inputs);\n\n const response = toOutput(spec, operation);\n if (response) {\n Object.assign(outputs, response.outputs);\n }\n group.methods.push(`\n Future<${response ? response.returnType : 'http.StreamedResponse'}> ${camelcase(operation.operationId)}(\n ${isEmpty(operation.requestBody) ? '' : `${input.inputName} input`}\n ) async {\n final stream = await this.dispatcher.${input.contentType}(RequestConfig(\n method: '${entry.method}',\n url: Uri.parse('${entry.path}'),\n headers: {},\n ), ${['json', 'multipart'].includes(input.contentType) ? input.encode : ``});\n ${response ? `${response.decode};` : 'return stream;'}\n }\n `);\n });\n\n const newRefs: { name: string; value: SchemaObject }[] = [];\n tuneSpec(spec, spec.components.schemas, newRefs);\n for (const ref of newRefs) {\n spec.components.schemas[ref.name] = ref.value;\n }\n await writeFile(\n join(process.cwd(), 'openai.json'),\n JSON.stringify(spec, null, 2),\n );\n\n const models = Object.entries(spec.components.schemas).reduce<\n Record<string, string>\n >((acc, [name, schema]) => {\n const serializer = new DartSerializer(spec, (name, content) => {\n acc[`models/${snakecase(name)}.dart`] =\n `import 'dart:io';import 'dart:typed_data'; import './index.dart';\\n\\n${content}`;\n });\n serializer.handle(pascalcase(name), schema);\n return acc;\n }, {});\n\n const clazzez = Object.entries(groups).reduce<Record<string, string>>(\n (acc, [name, { methods }]) => {\n return {\n ...acc,\n [`api/${snakecase(name)}.dart`]: `\nimport 'dart:convert';\n\nimport 'package:http/http.dart' as http;\n\nimport '../interceptors.dart';\nimport '../inputs/index.dart';\nimport '../outputs/index.dart';\nimport '../models/index.dart';\nimport '../http.dart';\n\n class ${pascalcase(name)}Client {\n final Dispatcher dispatcher;\n final Receiver receiver;\n ${pascalcase(name)}Client(this.dispatcher, this.receiver);\n ${methods.join('\\n')}\n }\n `,\n };\n },\n {},\n );\n\n const client = `\n ${Object.keys(groups)\n .map((name) => `import './api/${snakecase(name)}.dart';`)\n .join('\\n')}\nimport './interceptors.dart';\nimport './http.dart';\n\n class ${clientName} {\n final Options options;\n${Object.keys(groups)\n .map((name) => `late final ${pascalcase(name)}Client ${camelcase(name)};`)\n .join('\\n')}\n\n ${clientName}(this.options) {\n final interceptors = [BaseUrlInterceptor(() => this.options.baseUrl)];\n final dispatcher = Dispatcher(interceptors);\n final receiver = Receiver(interceptors);\n ${Object.keys(groups)\n .map(\n (name) =>\n `this.${camelcase(name)} = ${pascalcase(name)}Client(dispatcher, receiver);`,\n )\n .join('\\n')}\n\n }\n\n void setOptions({String? baseUrl}) {\n if (baseUrl != null) {\n options.baseUrl = baseUrl;\n }\n }\n }\n\n\nclass Options {\n String baseUrl;\n Options({required this.baseUrl});\n}\n\n `;\n await writeFiles(output, {\n ...models,\n ...inputs,\n ...outputs,\n });\n\n await writeFiles(output, {\n 'models/index.dart': await getFolderExportsV2(join(output, 'models'), {\n exportSyntax: 'export',\n extensions: 'dart',\n }),\n 'inputs/index.dart': await getFolderExportsV2(join(output, 'inputs'), {\n exportSyntax: 'export',\n extensions: 'dart',\n }),\n 'outputs/index.dart': await getFolderExportsV2(join(output, 'outputs'), {\n exportSyntax: 'export',\n extensions: 'dart',\n }),\n 'interceptors.dart': interceptorsTxt,\n 'http.dart': dispatcherTxt,\n 'responses.dart': responsesTxt,\n ...clazzez,\n });\n await writeFiles(output, {\n 'package.dart': `${await getFolderExportsV2(join(output), {\n exportSyntax: 'export',\n extensions: 'dart',\n ignore(dirent) {\n return dirent.isFile() && dirent.name === 'package.dart';\n },\n })}${client}`,\n });\n\n await writeFiles(settings.output, {\n 'pubspec.yaml': {\n ignoreIfExists: true,\n content: yaml.stringify({\n name: settings.name\n ? `${snakecase(clientName.toLowerCase())}_sdk`\n : 'sdk',\n version: '0.0.1',\n environment: {\n sdk: '^3.7.2',\n },\n dependencies: {\n http: '^1.3.0',\n mime: '^2.0.0',\n },\n }),\n },\n });\n\n await settings.formatCode?.({\n output: output,\n });\n}\n\nfunction toInputs(spec: OpenAPIObject, { entry, operation }: Operation) {\n const inputs: Record<string, unknown> = {};\n const inputName = pascalcase(`${operation.operationId} input`);\n let contentType = 'empty';\n let encode = '';\n if (!isEmpty(operation.requestBody)) {\n const requestBody = isRef(operation.requestBody)\n ? followRef<RequestBodyObject>(spec, operation.requestBody.$ref)\n : operation.requestBody;\n\n for (const type in requestBody.content) {\n const ctSchema = isRef(requestBody.content[type].schema)\n ? followRef(spec, requestBody.content[type].schema.$ref)\n : requestBody.content[type].schema;\n if (!ctSchema) {\n console.warn(\n `Schema not found for ${type} in ${entry.method} ${entry.path}`,\n );\n continue;\n }\n\n const serializer = new DartSerializer(spec, (name, content) => {\n inputs[join(`inputs/${name}.dart`)] =\n `import 'dart:io';import 'dart:typed_data';import '../models/index.dart'; import './index.dart';\\n\\n${content}`;\n });\n const serialized = serializer.handle(inputName, ctSchema, true, {\n alias: isObjectSchema(ctSchema) ? undefined : inputName,\n });\n encode = serialized.encode as string;\n const [mediaType, mediaSubType] = partContentType(type).type.split('/');\n if (mediaType === 'application') {\n contentType = parseJsonContentType(type) as string;\n } else {\n contentType = mediaType;\n }\n\n // const schema = merge({}, objectSchema, {\n // required: additionalProperties\n // .filter((p) => p.required)\n // .map((p) => p.name),\n // properties: additionalProperties.reduce<Record<string, unknown>>(\n // (acc, p) => ({\n // ...acc,\n // [p.name]: p.schema,\n // }),\n // {},\n // ),\n // });\n\n // Object.assign(inputs, bodyInputs(config, objectSchema));\n // schemas[shortContenTypeMap[type]] = zodDeserialzer.handle(schema, true);\n }\n }\n\n return { inputs, inputName, contentType, encode };\n}\n\nfunction toOutput(spec: OpenAPIObject, operation: OperationObject) {\n const outputName = pascalcase(`${operation.operationId} output`);\n operation.responses ??= {};\n const outputs: Record<string, string> = {};\n for (const status in operation.responses) {\n const response = isRef(operation.responses[status] as ReferenceObject)\n ? followRef<ResponseObject>(spec, operation.responses[status].$ref)\n : (operation.responses[status] as ResponseObject);\n for (const type in response.content) {\n const { schema } = response.content[type];\n if (!schema) {\n console.warn(\n `Schema not found for ${type} in ${operation.operationId}`,\n );\n continue;\n }\n const serializer = new DartSerializer(spec, (name, content) => {\n // outputs[join(`outputs/${name}.dart`)] =\n // `import 'dart:typed_data'; import '../models/index.dart'; \\n\\n${content}`;\n });\n if (isStreamingContentType(type)) {\n return {\n type: 'stream',\n outputName,\n outputs,\n decode: `return stream`,\n returnType: `http.StreamedResponse`,\n };\n }\n if (parseJsonContentType(type)) {\n const serialized = serializer.handle(outputName, schema, true, {\n // alias: outputName,\n noEmit: true,\n });\n return {\n type: 'json',\n outputName,\n outputs,\n decode: `final json = await this.receiver.json(stream); return ${serialized.fromJson}`,\n returnType: serialized.use,\n };\n }\n }\n }\n return null;\n}\n", "import {\n pascalcase as _pascalcase,\n snakecase as _snakecase,\n spinalcase as _spinalcase,\n} from 'stringcase';\nimport type ts from 'typescript';\n\nimport type { TypeDeriver } from './lib/deriver.ts';\nimport type { ResponseItem } from './lib/paths.ts';\n\nexport * from './lib/deriver.ts';\nexport * from './lib/file-system.ts';\nexport * from './lib/paths.ts';\nexport * from './lib/program.ts';\nexport * from './lib/ref.ts';\n\nexport function removeDuplicates<T>(\n data: T[],\n accessor: (item: T) => T[keyof T] | T = (item) => item,\n): T[] {\n return [...new Map(data.map((x) => [accessor(x), x])).values()];\n}\n\nexport type InferRecordValue<T> = T extends Record<string, infer U> ? U : any;\n\nexport function toLitObject<T extends Record<string, any>>(\n obj: T,\n accessor: (value: InferRecordValue<T>) => string = (value) => value,\n) {\n return `{${Object.keys(obj)\n .map((key) => `${key}: ${accessor(obj[key])}`)\n .join(', ')}}`;\n}\n\nexport type NaunceResponseAnalyzerFn = (\n handler: ts.ArrowFunction,\n deriver: TypeDeriver,\n node: ts.Node,\n) => ResponseItem[];\nexport type NaunceResponseAnalyzer = Record<string, NaunceResponseAnalyzerFn>;\n\nexport type ResponseAnalyzerFn = (\n handler: ts.ArrowFunction,\n deriver: TypeDeriver,\n) => ResponseItem[];\n\nexport function isEmpty(value: unknown): value is null | undefined | '' {\n if (value === null || value === undefined || value === '') {\n return true;\n }\n if (Array.isArray(value) && value.length === 0) {\n return true;\n }\n if (typeof value === 'object' && Object.keys(value).length === 0) {\n return true;\n }\n return false;\n}\n\nexport function pascalcase(value: string) {\n return _pascalcase(value.split('/').join(' '));\n}\nexport function spinalcase(value: string) {\n return _spinalcase(value.split('/').join(' '));\n}\nexport function snakecase(value: string) {\n return _snakecase(value.split('/').join(' '));\n}\n", "import ts, { TypeFlags, symbolName } from 'typescript';\n\ntype Collector = Record<string, any>;\nexport const deriveSymbol = Symbol.for('serialize');\nexport const $types = Symbol.for('types');\nconst defaults: Record<string, string> = {\n Readable: 'any',\n ReadableStream: 'any',\n DateConstructor: 'string',\n ArrayBufferConstructor: 'any',\n SharedArrayBufferConstructor: 'any',\n Int8ArrayConstructor: 'any',\n Uint8Array: 'any',\n};\nexport class TypeDeriver {\n public readonly collector: Collector = {};\n public readonly checker: ts.TypeChecker;\n constructor(checker: ts.TypeChecker) {\n this.checker = checker;\n }\n\n serializeType(type: ts.Type): any {\n const indexType = type.getStringIndexType();\n if (indexType) {\n return {\n [deriveSymbol]: true,\n kind: 'record',\n optional: false,\n [$types]: [this.serializeType(indexType)],\n };\n }\n if (type.flags & TypeFlags.Any) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [],\n };\n }\n if (type.flags & TypeFlags.Unknown) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [],\n };\n }\n if (type.isStringLiteral()) {\n return {\n [deriveSymbol]: true,\n optional: false,\n kind: 'literal',\n value: type.value,\n [$types]: ['string'],\n };\n }\n if (type.isNumberLiteral()) {\n return {\n [deriveSymbol]: true,\n optional: false,\n kind: 'literal',\n value: type.value,\n [$types]: ['number'],\n };\n }\n if (type.flags & TypeFlags.BooleanLiteral) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: ['boolean'],\n };\n }\n\n if (type.flags & TypeFlags.TemplateLiteral) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: ['string'],\n };\n }\n if (type.flags & TypeFlags.String) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: ['string'],\n };\n }\n if (type.flags & TypeFlags.Number) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: ['number'],\n };\n }\n if (type.flags & ts.TypeFlags.Boolean) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: ['boolean'],\n };\n }\n if (type.flags & TypeFlags.Null) {\n return {\n [deriveSymbol]: true,\n optional: true,\n [$types]: ['null'],\n };\n }\n if (type.isIntersection()) {\n let optional: boolean | undefined;\n const types: any[] = [];\n for (const unionType of type.types) {\n if (optional === undefined) {\n optional = (unionType.flags & ts.TypeFlags.Undefined) !== 0;\n if (optional) {\n continue;\n }\n }\n\n types.push(this.serializeType(unionType));\n }\n return {\n [deriveSymbol]: true,\n kind: 'intersection',\n optional,\n [$types]: types,\n };\n }\n if (type.isUnion()) {\n let optional: boolean | undefined;\n const types: any[] = [];\n for (const unionType of type.types) {\n if (optional === undefined) {\n // ignore undefined\n optional = (unionType.flags & ts.TypeFlags.Undefined) !== 0;\n if (optional) {\n continue;\n }\n }\n\n types.push(this.serializeType(unionType));\n }\n return {\n [deriveSymbol]: true,\n kind: 'union',\n optional,\n [$types]: types,\n };\n }\n if (this.checker.isArrayLikeType(type)) {\n const [argType] = this.checker.getTypeArguments(type as ts.TypeReference);\n if (!argType) {\n const typeName = type.symbol?.getName() || '<unknown>';\n console.warn(\n `Could not find generic type argument for array type ${typeName}`,\n );\n return {\n [deriveSymbol]: true,\n optional: false,\n kind: 'array',\n [$types]: ['any'],\n };\n }\n const typeSymbol = argType.getSymbol();\n if (!typeSymbol) {\n return {\n [deriveSymbol]: true,\n optional: false,\n kind: 'array',\n [$types]: [this.serializeType(argType)],\n };\n }\n\n if (typeSymbol.valueDeclaration) {\n return {\n kind: 'array',\n [deriveSymbol]: true,\n [$types]: [this.serializeNode(typeSymbol.valueDeclaration)],\n };\n }\n const maybeDeclaration = typeSymbol.declarations?.[0];\n if (maybeDeclaration) {\n if (ts.isMappedTypeNode(maybeDeclaration)) {\n const resolvedType = this.checker\n .getPropertiesOfType(argType)\n .reduce<Record<string, unknown>>((acc, prop) => {\n const propType = this.checker.getTypeOfSymbol(prop);\n acc[prop.name] = this.serializeType(propType);\n return acc;\n }, {});\n return {\n kind: 'array',\n optional: false,\n [deriveSymbol]: true,\n [$types]: [resolvedType],\n };\n } else {\n return {\n kind: 'array',\n ...this.serializeNode(maybeDeclaration),\n };\n }\n }\n\n return {\n kind: 'array',\n optional: false,\n [deriveSymbol]: true,\n [$types]: ['any'],\n };\n }\n if (type.isClass()) {\n const declaration = type.symbol?.valueDeclaration;\n if (!declaration) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [type.symbol.getName()],\n };\n }\n return this.serializeNode(declaration);\n }\n if (isInterfaceType(type)) {\n const valueDeclaration =\n type.symbol.valueDeclaration ?? type.symbol.declarations?.[0];\n if (!valueDeclaration) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [type.symbol.getName()],\n };\n }\n return this.serializeNode(valueDeclaration);\n }\n if (type.flags & TypeFlags.Object) {\n if (defaults[symbolName(type.symbol)]) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [defaults[type.symbol.name]],\n };\n }\n const properties = this.checker.getPropertiesOfType(type);\n if (properties.length > 0) {\n const serializedProps: Record<string, any> = {};\n for (const prop of properties) {\n const propAssingment = (prop.getDeclarations() ?? []).find((it) =>\n ts.isPropertyAssignment(it),\n );\n // get literal properties values if any\n if (propAssingment) {\n const type = this.checker.getTypeAtLocation(\n propAssingment.initializer,\n );\n serializedProps[prop.name] = this.serializeType(type);\n }\n if (\n (prop.getDeclarations() ?? []).find((it) =>\n ts.isPropertySignature(it),\n )\n ) {\n const propType = this.checker.getTypeOfSymbol(prop);\n serializedProps[prop.name] = this.serializeType(propType);\n }\n }\n return {\n [deriveSymbol]: true,\n kind: 'object',\n optional: false,\n [$types]: [serializedProps],\n };\n }\n const declaration =\n type.symbol.valueDeclaration ?? type.symbol.declarations?.[0];\n if (!declaration) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [type.symbol.getName()],\n };\n }\n return this.serializeNode(declaration);\n }\n console.warn(`Unhandled type: ${type.flags} ${ts.TypeFlags[type.flags]}`);\n\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [\n this.checker.typeToString(\n type,\n undefined,\n ts.TypeFormatFlags.NoTruncation,\n ),\n ],\n };\n }\n\n serializeNode(node: ts.Node): any {\n if (ts.isObjectLiteralExpression(node)) {\n const symbolType = this.checker.getTypeAtLocation(node);\n const props: Record<string, any> = {};\n for (const symbol of symbolType.getProperties()) {\n const type = this.checker.getTypeOfSymbol(symbol);\n props[symbol.name] = this.serializeType(type);\n }\n\n // get literal properties values if any\n for (const prop of node.properties) {\n if (ts.isPropertyAssignment(prop)) {\n const type = this.checker.getTypeAtLocation(prop.initializer);\n props[prop.name.getText()] = this.serializeType(type);\n }\n }\n\n return props;\n }\n if (ts.isPropertyAccessExpression(node)) {\n const symbol = this.checker.getSymbolAtLocation(node.name);\n if (!symbol) {\n console.warn(`No symbol found for ${node.name.getText()}`);\n return null;\n }\n const type = this.checker.getTypeOfSymbol(symbol);\n return this.serializeType(type);\n }\n if (ts.isPropertySignature(node)) {\n const symbol = this.checker.getSymbolAtLocation(node.name);\n if (!symbol) {\n console.warn(`No symbol found for ${node.name.getText()}`);\n return null;\n }\n const type = this.checker.getTypeOfSymbol(symbol);\n return this.serializeType(type);\n }\n if (ts.isPropertyDeclaration(node)) {\n const symbol = this.checker.getSymbolAtLocation(node.name);\n if (!symbol) {\n console.warn(`No symbol found for ${node.name.getText()}`);\n return null;\n }\n const type = this.checker.getTypeOfSymbol(symbol);\n return this.serializeType(type);\n }\n if (ts.isInterfaceDeclaration(node)) {\n if (!node.name?.text) {\n throw new Error('Interface has no name');\n }\n if (defaults[node.name.text]) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [defaults[node.name.text]],\n };\n }\n if (!this.collector[node.name.text]) {\n this.collector[node.name.text] = {};\n const members: Record<string, any> = {};\n for (const member of node.members.filter(ts.isPropertySignature)) {\n members[member.name.getText()] = this.serializeNode(member);\n }\n this.collector[node.name.text] = members;\n }\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [`#/components/schemas/${node.name.text}`],\n };\n }\n if (ts.isClassDeclaration(node)) {\n if (!node.name?.text) {\n throw new Error('Class has no name');\n }\n if (defaults[node.name.text]) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [defaults[node.name.text]],\n };\n }\n\n if (!this.collector[node.name.text]) {\n this.collector[node.name.text] = {};\n const members: Record<string, unknown> = {};\n for (const member of node.members.filter(ts.isPropertyDeclaration)) {\n members[member.name!.getText()] = this.serializeNode(member);\n }\n this.collector[node.name.text] = members;\n }\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [`#/components/schemas/${node.name.text}`],\n $ref: `#/components/schemas/${node.name.text}`,\n };\n }\n if (ts.isVariableDeclaration(node)) {\n const symbol = this.checker.getSymbolAtLocation(node.name);\n if (!symbol) {\n console.warn(`No symbol found for ${node.name.getText()}`);\n return null;\n }\n if (!node.type) {\n console.warn(`No type found for ${node.name.getText()}`);\n return 'any';\n }\n const type = this.checker.getTypeFromTypeNode(node.type);\n return this.serializeType(type);\n }\n if (ts.isIdentifier(node)) {\n const symbol = this.checker.getSymbolAtLocation(node);\n if (!symbol) {\n console.warn(`Identifer: No symbol found for ${node.getText()}`);\n return null;\n }\n const type = this.checker.getTypeAtLocation(node);\n return this.serializeType(type);\n }\n if (ts.isAwaitExpression(node)) {\n const type = this.checker.getTypeAtLocation(node);\n return this.serializeType(type);\n }\n if (ts.isCallExpression(node)) {\n const type = this.checker.getTypeAtLocation(node);\n return this.serializeType(type);\n }\n if (ts.isAsExpression(node)) {\n const type = this.checker.getTypeAtLocation(node);\n return this.serializeType(type);\n }\n if (ts.isTypeLiteralNode(node)) {\n const symbolType = this.checker.getTypeAtLocation(node);\n const props: Record<string, unknown> = {};\n for (const symbol of symbolType.getProperties()) {\n const type = this.checker.getTypeOfSymbol(symbol);\n props[symbol.name] = this.serializeType(type);\n }\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [props],\n };\n }\n if (node.kind === ts.SyntaxKind.NullKeyword) {\n return {\n [deriveSymbol]: true,\n optional: true,\n [$types]: ['null'],\n };\n }\n if (node.kind === ts.SyntaxKind.BooleanKeyword) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: ['boolean'],\n };\n }\n if (node.kind === ts.SyntaxKind.TrueKeyword) {\n return {\n [deriveSymbol]: true,\n optional: false,\n kind: 'literal',\n value: true,\n [$types]: ['boolean'],\n };\n }\n if (node.kind === ts.SyntaxKind.FalseKeyword) {\n return {\n [deriveSymbol]: true,\n optional: false,\n kind: 'literal',\n value: false,\n [$types]: ['boolean'],\n };\n }\n if (ts.isArrayLiteralExpression(node)) {\n const type = this.checker.getTypeAtLocation(node);\n return this.serializeType(type);\n }\n\n console.warn(`Unhandled node: ${ts.SyntaxKind[node.kind]} ${node.flags}`);\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: ['any'],\n };\n }\n}\n\nfunction isInterfaceType(type: ts.Type): boolean {\n if (type.isClassOrInterface()) {\n // Check if it's an interface\n return !!(type.symbol.flags & ts.SymbolFlags.Interface);\n }\n return false;\n}\n", "import type { Dirent } from 'node:fs';\nimport { mkdir, readFile, readdir, stat, writeFile } from 'node:fs/promises';\nimport { dirname, extname, isAbsolute, join } from 'node:path';\n\nexport async function getFile(filePath: string) {\n if (await exist(filePath)) {\n return readFile(filePath, 'utf-8');\n }\n return null;\n}\n\nexport async function exist(file: string): Promise<boolean> {\n return stat(file)\n .then(() => true)\n .catch(() => false);\n}\n\nexport async function readFolder(path: string) {\n if (await exist(path)) {\n return readdir(path);\n }\n return [] as string[];\n}\n\nexport async function writeFiles(\n dir: string,\n contents: Record<\n string,\n null | string | { content: string; ignoreIfExists?: boolean }\n >,\n) {\n await Promise.all(\n Object.entries(contents).map(async ([file, content]) => {\n if (content === null) {\n return;\n }\n const filePath = isAbsolute(file) ? file : join(dir, file);\n await mkdir(dirname(filePath), { recursive: true });\n if (typeof content === 'string') {\n await writeFile(filePath, content, 'utf-8');\n } else {\n if (content.ignoreIfExists) {\n if (!(await exist(filePath))) {\n await writeFile(filePath, content.content, 'utf-8');\n }\n } else {\n await writeFile(filePath, content.content, 'utf-8');\n }\n }\n }),\n );\n}\n\nexport async function getFolderExports(\n folder: string,\n includeExtension = true,\n extensions = ['ts'],\n ignore: (dirent: Dirent) => boolean = () => false,\n) {\n const files = await readdir(folder, { withFileTypes: true });\n const exports: string[] = [];\n for (const file of files) {\n if (ignore(file)) {\n continue;\n }\n if (file.isDirectory()) {\n if (await exist(`${file.parentPath}/${file.name}/index.ts`)) {\n exports.push(\n `export * from './${file.name}/index${includeExtension ? '.ts' : ''}';`,\n );\n }\n } else if (\n file.name !== 'index.ts' &&\n extensions.includes(getExt(file.name))\n ) {\n exports.push(\n `export * from './${includeExtension ? file.name : file.name.replace(extname(file.name), '')}';`,\n );\n }\n }\n return exports.join('\\n');\n}\n\nexport async function getFolderExportsV2(\n folder: string,\n options: {\n includeExtension?: boolean;\n extensions: string;\n ignore?: (dirent: Dirent) => boolean;\n exportSyntax: string;\n } = {\n extensions: 'ts',\n ignore: () => false,\n includeExtension: true,\n exportSyntax: 'export * from ',\n },\n) {\n options.includeExtension ??= true;\n if (!(await exist(folder))) {\n return '';\n }\n const files = await readdir(folder, { withFileTypes: true });\n const exports: string[] = [];\n for (const file of files) {\n if (options.ignore?.(file)) {\n continue;\n }\n if (file.isDirectory()) {\n if (\n await exist(\n `${file.parentPath}/${file.name}/index.${options.extensions}`,\n )\n ) {\n exports.push(\n `${options.exportSyntax} './${file.name}/index${options.includeExtension ? `.${options.extensions}` : ''}';`,\n );\n }\n } else if (\n file.name !== `index.${options.extensions}` &&\n options.extensions.includes(getExt(file.name))\n ) {\n exports.push(\n `${options.exportSyntax} './${options.includeExtension ? file.name : file.name.replace(extname(file.name), '')}';`,\n );\n }\n }\n return exports.join('\\n');\n}\n\nexport const getExt = (fileName?: string) => {\n if (!fileName) {\n return ''; // shouldn't happen as there will always be a file name\n }\n const lastDot = fileName.lastIndexOf('.');\n if (lastDot === -1) {\n return '';\n }\n const ext = fileName\n .slice(lastDot + 1)\n .split('/')\n .filter(Boolean)\n .join('');\n if (ext === fileName) {\n // files that have no extension\n return '';\n }\n return ext || 'txt';\n};\n", "import type {\n HeadersObject,\n OperationObject,\n ParameterObject,\n PathsObject,\n ResponseObject,\n ResponsesObject,\n SchemaObject,\n} from 'openapi3-ts/oas31';\n\nimport { $types } from './deriver.ts';\n\nexport type Method =\n | 'get'\n | 'post'\n | 'put'\n | 'patch'\n | 'delete'\n | 'trace'\n | 'head';\nexport const methods = [\n 'get',\n 'post',\n 'put',\n 'patch',\n 'delete',\n 'trace',\n 'head',\n] as const;\nexport type SemanticSource =\n | 'query'\n | 'queries'\n | 'body'\n | 'params'\n | 'headers';\n\nconst semanticSourceToOpenAPI = {\n queries: 'query',\n query: 'query',\n headers: 'header',\n params: 'path',\n} as const;\nexport interface Selector {\n name: string;\n select: string;\n against: string;\n source: SemanticSource;\n nullable: boolean;\n required: boolean;\n}\n\nexport interface ResponseItem {\n statusCode: string;\n response?: DateType;\n contentType: string;\n headers: (string | Record<string, string[]>)[];\n}\n\nexport type OnOperation = (\n sourceFile: string,\n method: Method,\n path: string,\n operation: OperationObject,\n) => PathsObject;\nexport class Paths {\n #commonZodImport?: string;\n #onOperation?: OnOperation;\n #operations: Array<{\n sourceFile: string;\n name: string;\n path: string;\n method: Method;\n selectors: Selector[];\n responses: ResponsesObject;\n contentType?: string;\n tags?: string[];\n description?: string;\n }> = [];\n\n constructor(config: { commonZodImport?: string; onOperation?: OnOperation }) {\n this.#commonZodImport = config.commonZodImport;\n this.#onOperation = config.onOperation;\n }\n\n addPath(\n name: string,\n path: string,\n method: Method,\n contentType: string | undefined,\n selectors: Selector[],\n responses: ResponseItem[],\n sourceFile: string,\n tags?: string[],\n description?: string,\n ) {\n const responsesObject = this.#responseItemToResponses(responses);\n\n this.#operations.push({\n name,\n path: this.#tunePath(path),\n sourceFile,\n contentType: contentType,\n method,\n selectors,\n responses: responsesObject,\n tags,\n description,\n });\n return this;\n }\n\n #responseItemToResponses(responses: ResponseItem[]): ResponsesObject {\n const responsesObject: ResponsesObject = {};\n for (const item of responses) {\n const ct = item.contentType;\n const schema = item.response ? toSchema(item.response) : {};\n if (!responsesObject[item.statusCode]) {\n responsesObject[item.statusCode] = {\n description: `Response for ${item.statusCode}`,\n content:\n ct !== 'empty'\n ? {\n [ct]:\n ct === 'application/octet-stream'\n ? { schema: { type: 'string', format: 'binary' } }\n : { schema },\n }\n : undefined,\n headers: item.headers.length\n ? item.headers.reduce<HeadersObject>((acc, current) => {\n const headers =\n typeof current === 'string' ? { [current]: [] } : current;\n return Object.entries(headers).reduce<HeadersObject>(\n (subAcc, [key, value]) => {\n const header: HeadersObject = {\n [key]: {\n schema: {\n type: 'string',\n enum: value.length ? value : undefined,\n },\n },\n };\n return { ...subAcc, ...header };\n },\n acc,\n );\n }, {})\n : undefined,\n } satisfies ResponseObject;\n } else {\n if (!responsesObject[item.statusCode].content[ct]) {\n responsesObject[item.statusCode].content[ct] = { schema };\n } else {\n const existing = responsesObject[item.statusCode].content[ct]\n .schema as SchemaObject;\n if (existing.oneOf) {\n if (\n !existing.oneOf.find(\n (it) => JSON.stringify(it) === JSON.stringify(schema),\n )\n ) {\n existing.oneOf.push(schema);\n }\n } else if (JSON.stringify(existing) !== JSON.stringify(schema)) {\n responsesObject[item.statusCode].content[ct].schema = {\n oneOf: [existing, schema],\n };\n }\n }\n }\n }\n return responsesObject;\n }\n\n async #selectosToParameters(selectors: Selector[]) {\n const parameters: ParameterObject[] = [];\n const bodySchemaProps: Record<\n string,\n { required: boolean; schema: SchemaObject }\n > = {};\n for (const selector of selectors) {\n if (selector.source === 'body') {\n bodySchemaProps[selector.name] = {\n required: selector.required,\n schema: await evalZod(selector.against, this.#commonZodImport),\n };\n continue;\n }\n\n const parameter: ParameterObject = {\n in: semanticSourceToOpenAPI[selector.source],\n name: selector.name,\n required: selector.required,\n schema: await evalZod(selector.against, this.#commonZodImport),\n };\n parameters.push(parameter);\n }\n return { parameters, bodySchemaProps };\n }\n\n async getPaths() {\n const operations: PathsObject = {};\n for (const operation of this.#operations) {\n const { path, method, selectors } = operation;\n const { parameters, bodySchemaProps } =\n await this.#selectosToParameters(selectors);\n const bodySchema: Record<string, SchemaObject> = {};\n const required: string[] = [];\n for (const [key, value] of Object.entries(bodySchemaProps)) {\n if (value.required) {\n required.push(key);\n }\n bodySchema[key] = value.schema;\n }\n const operationObject: OperationObject = {\n operationId: operation.name,\n parameters,\n tags: operation.tags,\n description: operation.description,\n requestBody: Object.keys(bodySchema).length\n ? {\n required: required.length ? true : false,\n content: {\n [operation.contentType || 'application/json']: {\n schema: {\n required: required.length ? required : undefined,\n type: 'object',\n properties: bodySchema,\n },\n },\n },\n }\n : undefined,\n responses:\n Object.keys(operation.responses).length === 0\n ? undefined\n : operation.responses,\n };\n if (!operations[path]) {\n operations[path] = {};\n }\n operations[path][method] = operationObject;\n if (this.#onOperation) {\n const paths = this.#onOperation?.(\n operation.sourceFile,\n method,\n path,\n operationObject,\n );\n Object.assign(operations, paths ?? {});\n }\n }\n return operations;\n }\n\n /**\n * Converts Express/Node.js style path parameters (/path/:param) to OpenAPI style (/path/{param})\n */\n #tunePath(path: string): string {\n return path.replace(/:([^/]+)/g, '{$1}');\n }\n}\n\nasync function evalZod(schema: string, commonZodImport?: string) {\n // https://github.com/nodejs/node/issues/51956\n const lines = [\n `import { createRequire } from \"node:module\";`,\n `const filename = \"${import.meta.url}\";`,\n `const require = createRequire(filename);`,\n `const z = require(\"zod\");`,\n commonZodImport ? `const commonZod = require('${commonZodImport}');` : '',\n `const {zodToJsonSchema} = require('zod-to-json-schema');`,\n `const schema = ${schema.replace('.optional()', '').replaceAll('instanceof(File)', 'string().base64()')};`,\n `const jsonSchema = zodToJsonSchema(schema, {\n $refStrategy: 'root',\n basePath: ['#', 'components', 'schemas'],\n target: 'jsonSchema7',\n base64Strategy: 'format:binary',\n });`,\n `export default jsonSchema;`,\n ];\n\n const base64 = Buffer.from(lines.join('\\n')).toString('base64');\n return import(`data:text/javascript;base64,${base64}`)\n .then((mod) => mod.default)\n .then(({ $schema, ...result }) => result);\n}\n\ninterface DateType {\n [$types]: any[];\n kind: string;\n optional: boolean;\n value?: string;\n}\n\nexport function toSchema(data: DateType | string | null | undefined): any {\n if (data === null || data === undefined) {\n return { type: 'any' };\n } else if (typeof data === 'string') {\n const isRef = data.startsWith('#');\n if (isRef) {\n return { $ref: data };\n }\n return { type: data };\n } else if (data.kind === 'literal') {\n return { enum: [data.value], type: data[$types][0] };\n } else if (data.kind === 'record') {\n return {\n type: 'object',\n additionalProperties: toSchema(data[$types][0]),\n };\n } else if (data.kind === 'array') {\n const items = data[$types].map(toSchema);\n return { type: 'array', items: data[$types].length ? items[0] : {} };\n } else if (data.kind === 'union') {\n return { anyOf: data[$types].map(toSchema) };\n } else if (data.kind === 'intersection') {\n return { allOf: data[$types].map(toSchema) };\n } else if ($types in data) {\n return data[$types].map(toSchema)[0] ?? {};\n } else {\n const props: Record<string, unknown> = {};\n const required: string[] = [];\n for (const [key, value] of Object.entries(data)) {\n props[key] = toSchema(value as any);\n if (!(value as any).optional) {\n required.push(key);\n }\n }\n return {\n type: 'object',\n properties: props,\n required,\n additionalProperties: false,\n };\n }\n}\n\nexport function isHttpMethod(name: string): name is Method {\n return ['get', 'post', 'put', 'delete', 'patch'].includes(name);\n}\n", "import debug from 'debug';\nimport { dirname, join } from 'node:path';\nimport ts from 'typescript';\n\nconst logger = debug('january:client');\n\nexport function parseTsConfig(tsconfigPath: string) {\n logger(`Using TypeScript version: ${ts.version}`);\n const configContent = ts.readConfigFile(tsconfigPath, ts.sys.readFile);\n\n if (configContent.error) {\n console.error(\n `Failed to read tsconfig file:`,\n ts.formatDiagnosticsWithColorAndContext([configContent.error], {\n getCanonicalFileName: (path) => path,\n getCurrentDirectory: ts.sys.getCurrentDirectory,\n getNewLine: () => ts.sys.newLine,\n }),\n );\n throw new Error('Failed to parse tsconfig.json');\n }\n\n const parsed = ts.parseJsonConfigFileContent(\n configContent.config,\n ts.sys,\n dirname(tsconfigPath),\n );\n\n if (parsed.errors.length > 0) {\n console.error(\n `Errors found in tsconfig.json:`,\n ts.formatDiagnosticsWithColorAndContext(parsed.errors, {\n getCanonicalFileName: (path) => path,\n getCurrentDirectory: ts.sys.getCurrentDirectory,\n getNewLine: () => ts.sys.newLine,\n }),\n );\n throw new Error('Failed to parse tsconfig.json');\n }\n return parsed;\n}\nexport function getProgram(tsconfigPath: string) {\n const tsConfigParseResult = parseTsConfig(tsconfigPath);\n logger(`Parsing tsconfig`);\n return ts.createProgram({\n options: {\n ...tsConfigParseResult.options,\n noEmit: true,\n incremental: true,\n tsBuildInfoFile: join(dirname(tsconfigPath), './.tsbuildinfo'), // not working atm\n },\n rootNames: tsConfigParseResult.fileNames,\n projectReferences: tsConfigParseResult.projectReferences,\n configFileParsingDiagnostics: tsConfigParseResult.errors,\n });\n}\nexport function getPropertyAssignment(node: ts.Node, name: string) {\n if (ts.isObjectLiteralExpression(node)) {\n return node.properties\n .filter((prop) => ts.isPropertyAssignment(prop))\n .find((prop) => prop.name!.getText() === name);\n }\n return undefined;\n}\nexport function isCallExpression(\n node: ts.Node,\n name: string,\n): node is ts.CallExpression {\n return (\n ts.isCallExpression(node) &&\n node.expression &&\n ts.isIdentifier(node.expression) &&\n node.expression.text === name\n );\n}\n\nexport function isInterfaceType(type: ts.Type): boolean {\n if (type.isClassOrInterface()) {\n // Check if it's an interface\n return !!(type.symbol.flags & ts.SymbolFlags.Interface);\n }\n return false;\n}\n", "import { get } from 'lodash-es';\nimport type {\n OpenAPIObject,\n ParameterObject,\n ReferenceObject,\n RequestBodyObject,\n SchemaObject,\n} from 'openapi3-ts/oas31';\n\nexport function isRef(obj: any): obj is ReferenceObject {\n return obj && '$ref' in obj;\n}\nexport function notRef(obj: any): obj is SchemaObject {\n return !isRef(obj);\n}\n\nexport function cleanRef(ref: string) {\n return ref.replace(/^#\\//, '');\n}\n\nexport function parseRef(ref: string) {\n const parts = ref.split('/');\n const [model] = parts.splice(-1);\n const [namespace] = parts.splice(-1);\n return {\n model,\n namespace,\n path: cleanRef(parts.join('/')),\n };\n}\nexport function followRef<\n T extends SchemaObject | ParameterObject | RequestBodyObject = SchemaObject,\n>(spec: OpenAPIObject, ref: string): T {\n const pathParts = cleanRef(ref).split('/');\n const entry = get(spec, pathParts) as T | ReferenceObject;\n if (entry && '$ref' in entry) {\n return followRef<T>(spec, entry.$ref);\n }\n return entry;\n}\n", "import { readFile } from 'node:fs/promises';\nimport { extname } from 'node:path';\nimport { parse } from 'yaml';\n\nexport async function loadLocal(location: string) {\n const extName = extname(location);\n const text = await readFile(location, 'utf-8');\n switch (extName) {\n case '.json':\n return JSON.parse(text);\n case '.yaml':\n case '.yml':\n return parse(text);\n default:\n throw new Error(`Unsupported file extension: ${extName}`);\n }\n}\n", "import { extname } from 'node:path';\nimport { parse } from 'yaml';\n\nexport async function loadRemote<T>(location: string): Promise<T> {\n const extName = extname(location);\n const response = await fetch(location);\n switch (extName) {\n case '.json':\n return response.json() as Promise<T>;\n case '.yaml':\n case '.yml': {\n const text = await response.text();\n return parse(text);\n }\n default:\n try {\n // try to parse it as json first\n return response.json() as Promise<T>;\n } catch {\n // parse as yaml\n const text = await response.text();\n return parse(text) as Promise<T>;\n }\n }\n}\n", "import type {\n OpenAPIObject,\n OperationObject,\n ParameterObject,\n ReferenceObject,\n} from 'openapi3-ts/oas31';\nimport { camelcase } from 'stringcase';\n\nexport const defaults: Partial<GenerateSdkConfig> &\n Required<Pick<GenerateSdkConfig, 'operationId' | 'tag'>> = {\n operationId: (operation, path, method) => {\n if (operation.operationId) {\n return camelcase(operation.operationId);\n }\n const metadata = operation['x-oaiMeta'];\n if (metadata && metadata.name) {\n return camelcase(metadata.name);\n }\n return camelcase(\n [method, ...path.replace(/[\\\\/\\\\{\\\\}]/g, ' ').split(' ')]\n .filter(Boolean)\n .join(' ')\n .trim(),\n );\n },\n tag: (operation, path) => {\n return operation.tags?.[0] || determineGenericTag(path, operation);\n },\n};\n\nexport type TunedOperationObject = OperationObject & {\n operationId: string;\n parameters: (ParameterObject | ReferenceObject)[];\n};\n\nexport interface OperationEntry {\n name?: string;\n method: string;\n path: string;\n groupName: string;\n tag: string;\n}\nexport type Operation = {\n entry: OperationEntry;\n operation: TunedOperationObject;\n};\n\nexport function forEachOperation<T>(\n config: GenerateSdkConfig,\n callback: (entry: OperationEntry, operation: TunedOperationObject) => T,\n) {\n const result: T[] = [];\n for (const [path, pathItem] of Object.entries(config.spec.paths ?? {})) {\n const { parameters = [], ...methods } = pathItem;\n\n // Convert Express-style routes (:param) to OpenAPI-style routes ({param})\n const fixedPath = path.replace(/:([^/]+)/g, '{$1}');\n\n for (const [method, operation] of Object.entries(methods) as [\n string,\n OperationObject,\n ][]) {\n const formatOperationId = config.operationId ?? defaults.operationId;\n const formatTag = config.tag ?? defaults.tag;\n const operationName = formatOperationId(operation, fixedPath, method);\n const operationTag = formatTag(operation, fixedPath);\n const metadata = operation['x-oaiMeta'] ?? {};\n result.push(\n callback(\n {\n name: metadata.name,\n method,\n path: fixedPath,\n groupName: operationTag,\n tag: operationTag,\n },\n {\n ...operation,\n parameters: [...parameters, ...(operation.parameters ?? [])],\n operationId: operationName,\n },\n ),\n );\n }\n }\n return result;\n}\n\nexport interface GenerateSdkConfig {\n spec: OpenAPIObject;\n operationId?: (\n operation: OperationObject,\n path: string,\n method: string,\n ) => string;\n tag?: (operation: OperationObject, path: string) => string;\n}\n\n// --- Function Definition (determineGenericTag, sanitizeTag, reservedKeywords, commonVerbs) ---\n/**\n * Set of reserved TypeScript keywords and common verbs potentially used as tags.\n */\nconst reservedKeywords = new Set([\n 'abstract',\n 'arguments',\n 'await',\n 'boolean',\n 'break',\n 'byte',\n 'case',\n 'catch',\n 'char',\n 'class',\n 'const',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'double',\n 'else',\n 'enum',\n 'eval',\n 'export',\n 'extends',\n 'false',\n 'final',\n 'finally',\n 'float',\n 'for',\n 'function',\n 'goto',\n 'if',\n 'implements',\n 'import',\n 'in',\n 'instanceof',\n 'int',\n 'interface',\n 'let',\n 'long',\n 'native',\n 'new',\n 'null',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'return',\n 'short',\n 'static',\n 'super',\n 'switch',\n 'synchronized',\n 'this',\n 'throw',\n 'throws',\n 'transient',\n 'true',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'volatile',\n 'while',\n 'with',\n 'yield',\n // Potentially problematic identifiers / Common Verbs used as tags\n 'object',\n 'string',\n 'number',\n 'any',\n 'unknown',\n 'never',\n 'get',\n 'list',\n 'create',\n 'update',\n 'delete',\n 'post',\n 'put',\n 'patch',\n 'do',\n 'send',\n 'add',\n 'remove',\n 'set',\n 'find',\n 'search',\n 'check',\n 'make', // Added make, check\n]);\n\n/**\n * Sanitizes a potential tag name (assumed to be already camelCased)\n * to avoid conflicts with reserved keywords or invalid starting characters (numbers).\n * Appends an underscore if the tag matches a reserved keyword.\n * Prepends an underscore if the tag starts with a number.\n * @param camelCasedTag The potential tag name, already camelCased.\n * @returns The sanitized tag name.\n */\nfunction sanitizeTag(camelCasedTag: string): string {\n // Prepend underscore if starts with a number\n if (/^\\d/.test(camelCasedTag)) {\n return `_${camelCasedTag}`;\n }\n // Append underscore if it's a reserved keyword\n return reservedKeywords.has(camelCasedTag)\n ? `${camelCasedTag}_`\n : camelCasedTag;\n}\n\n/**\n * Attempts to determine a generic tag for an OpenAPI operation based on path and operationId.\n * Rules and fallbacks are documented within the code.\n * @param pathString The path string.\n * @param operation The OpenAPI Operation Object.\n * @returns A sanitized, camelCased tag name string.\n */\nexport function determineGenericTag(\n pathString: string,\n operation: OperationObject,\n): string {\n const operationId = operation.operationId || '';\n const VERSION_REGEX = /^[vV]\\d+$/;\n const commonVerbs = new Set([\n // Verbs to potentially strip from operationId prefix\n 'get',\n 'list',\n 'create',\n 'update',\n 'delete',\n 'post',\n 'put',\n 'patch',\n 'do',\n 'send',\n 'add',\n 'remove',\n 'set',\n 'find',\n 'search',\n 'check',\n 'make', // Added make\n ]);\n\n const segments = pathString.split('/').filter(Boolean);\n\n const potentialCandidates = segments.filter(\n (segment) =>\n segment &&\n !segment.startsWith('{') &&\n !segment.endsWith('}') &&\n !VERSION_REGEX.test(segment),\n );\n\n // --- Heuristic 1: Last non-'@' path segment ---\n for (let i = potentialCandidates.length - 1; i >= 0; i--) {\n const segment = potentialCandidates[i];\n if (!segment.startsWith('@')) {\n // Sanitize just before returning\n return sanitizeTag(camelcase(segment));\n }\n }\n\n const canFallbackToPathSegment = potentialCandidates.length > 0;\n\n // --- Heuristic 2: OperationId parsing ---\n if (operationId) {\n const lowerOpId = operationId.toLowerCase();\n const parts = operationId\n .replace(/([a-z])([A-Z])/g, '$1_$2')\n .replace(/([A-Z])([A-Z][a-z])/g, '$1_$2')\n .replace(/([a-zA-Z])(\\d)/g, '$1_$2')\n .replace(/(\\d)([a-zA-Z])/g, '$1_$2')\n .toLowerCase()\n .split(/[_-\\s]+/);\n\n const validParts = parts.filter(Boolean);\n\n // Quick skip: If opId is just a verb and we can use Heuristic 3, prefer that.\n if (\n commonVerbs.has(lowerOpId) &&\n validParts.length === 1 &&\n canFallbackToPathSegment\n ) {\n // Proceed directly to Heuristic 3\n }\n // Only process if there are valid parts and the quick skip didn't happen\n else if (validParts.length > 0) {\n const firstPart = validParts[0];\n const isFirstPartVerb = commonVerbs.has(firstPart);\n\n // Case 2a: Starts with verb, has following parts\n if (isFirstPartVerb && validParts.length > 1) {\n const verbPrefixLength = firstPart.length;\n let nextPartStartIndex = -1;\n if (operationId.length > verbPrefixLength) {\n // Simplified check for next part start\n const charAfterPrefix = operationId[verbPrefixLength];\n if (charAfterPrefix >= 'A' && charAfterPrefix <= 'Z') {\n nextPartStartIndex = verbPrefixLength;\n } else if (charAfterPrefix >= '0' && charAfterPrefix <= '9') {\n nextPartStartIndex = verbPrefixLength;\n } else if (['_', '-'].includes(charAfterPrefix)) {\n nextPartStartIndex = verbPrefixLength + 1;\n } else {\n const match = operationId\n .substring(verbPrefixLength)\n .match(/[A-Z0-9]/);\n if (match && match.index !== undefined) {\n nextPartStartIndex = verbPrefixLength + match.index;\n }\n if (\n nextPartStartIndex === -1 &&\n operationId.length > verbPrefixLength\n ) {\n nextPartStartIndex = verbPrefixLength; // Default guess\n }\n }\n }\n\n if (\n nextPartStartIndex !== -1 &&\n nextPartStartIndex < operationId.length\n ) {\n const remainingOriginalSubstring =\n operationId.substring(nextPartStartIndex);\n const potentialTag = camelcase(remainingOriginalSubstring);\n if (potentialTag) {\n // Sanitize just before returning\n return sanitizeTag(potentialTag);\n }\n }\n\n // Fallback: join remaining lowercased parts\n const potentialTagJoined = camelcase(validParts.slice(1).join('_'));\n if (potentialTagJoined) {\n // Sanitize just before returning\n return sanitizeTag(potentialTagJoined);\n }\n }\n\n // Case 2b: Doesn't start with verb, or only one part (might be verb)\n const potentialTagFull = camelcase(operationId);\n if (potentialTagFull) {\n const isResultSingleVerb = validParts.length === 1 && isFirstPartVerb;\n\n // Avoid returning only a verb if Heuristic 3 is possible\n if (!(isResultSingleVerb && canFallbackToPathSegment)) {\n if (potentialTagFull.length > 0) {\n // Sanitize just before returning\n return sanitizeTag(potentialTagFull);\n }\n }\n }\n\n // Case 2c: Further fallbacks within OpId if above failed/skipped\n const firstPartCamel = camelcase(firstPart);\n if (firstPartCamel) {\n const isFirstPartCamelVerb = commonVerbs.has(firstPartCamel);\n if (\n !isFirstPartCamelVerb ||\n validParts.length === 1 ||\n !canFallbackToPathSegment\n ) {\n // Sanitize just before returning\n return sanitizeTag(firstPartCamel);\n }\n }\n if (\n isFirstPartVerb &&\n validParts.length > 1 &&\n validParts[1] &&\n canFallbackToPathSegment\n ) {\n const secondPartCamel = camelcase(validParts[1]);\n if (secondPartCamel) {\n // Sanitize just before returning\n return sanitizeTag(secondPartCamel);\n }\n }\n } // End if(validParts.length > 0) after quick skip check\n } // End if(operationId)\n\n // --- Heuristic 3: First path segment (stripping '@') ---\n if (potentialCandidates.length > 0) {\n let firstCandidate = potentialCandidates[0];\n if (firstCandidate.startsWith('@')) {\n firstCandidate = firstCandidate.substring(1);\n }\n if (firstCandidate) {\n // Sanitize just before returning\n return sanitizeTag(camelcase(firstCandidate));\n }\n }\n\n // --- Heuristic 4: Default ---\n console.warn(\n `Could not determine a suitable tag for path: ${pathString}, operationId: ${operationId}. Using 'unknown'.`,\n );\n return 'unknown'; // 'unknown' is safe\n}\n\nexport function parseJsonContentType(contentType: string | null | undefined) {\n if (!contentType) {\n return null;\n }\n\n // 1. Trim whitespace\n let mainType = contentType.trim();\n\n // 2. Remove parameters (anything after the first ';')\n const semicolonIndex = mainType.indexOf(';');\n if (semicolonIndex !== -1) {\n mainType = mainType.substring(0, semicolonIndex).trim(); // Trim potential space before ';'\n }\n\n // 3. Convert to lowercase for case-insensitive comparison\n mainType = mainType.toLowerCase();\n\n if (mainType.endsWith('/json')) {\n return mainType.split('/')[1];\n } else if (mainType.endsWith('+json')) {\n return mainType.split('+')[1];\n }\n return null;\n}\n\n/**\n * Checks if a given content type string represents Server-Sent Events (SSE).\n * Handles case-insensitivity, parameters (like charset), and leading/trailing whitespace.\n *\n * @param contentType The content type string to check (e.g., from a Content-Type header).\n * @returns True if the content type is 'text/event-stream', false otherwise.\n */\nexport function isSseContentType(\n contentType: string | null | undefined,\n): boolean {\n if (!contentType) {\n return false; // Handle null, undefined, or empty string\n }\n\n // 1. Trim whitespace from the input string\n let mainType = contentType.trim();\n\n // 2. Find the position of the first semicolon (if any) to remove parameters\n const semicolonIndex = mainType.indexOf(';');\n if (semicolonIndex !== -1) {\n // Extract the part before the semicolon and trim potential space\n mainType = mainType.substring(0, semicolonIndex).trim();\n }\n\n // 3. Convert the main type part to lowercase for case-insensitive comparison\n mainType = mainType.toLowerCase();\n\n // 4. Compare against the standard SSE MIME type\n return mainType === 'text/event-stream';\n}\n\nexport function isStreamingContentType(\n contentType: string | null | undefined,\n): boolean {\n return contentType === 'application/octet-stream';\n}\n\nexport function isSuccessStatusCode(statusCode: number | string): boolean {\n statusCode = Number(statusCode);\n return statusCode >= 200 && statusCode < 300;\n}\n", "import { merge } from 'lodash-es';\nimport assert from 'node:assert';\nimport type {\n OpenAPIObject,\n ReferenceObject,\n SchemaObject,\n} from 'openapi3-ts/oas31';\nimport { camelcase, snakecase } from 'stringcase';\n\nimport {\n cleanRef,\n followRef,\n isEmpty,\n isRef,\n notRef,\n parseRef,\n pascalcase,\n} from '@sdk-it/core';\n\nconst formatName = (it: any): string => {\n const startsWithDigitPattern = /^-?\\d/;\n // 1. Handle numbers\n if (typeof it === 'number') {\n if (Math.sign(it) === -1) {\n return `$_${Math.abs(it)}`;\n }\n return `$${it}`;\n }\n\n // 2. Handle the specific string 'default'\n if (it === 'default') {\n return '$default';\n }\n\n // 3. Handle other strings\n if (typeof it === 'string') {\n // 3a. Check if the string starts with a digit FIRST\n if (startsWithDigitPattern.test(it)) {\n if (typeof it === 'number') {\n if (Math.sign(it) === -1) {\n return `$_${Math.abs(it)}`;\n }\n return `$${it}`;\n }\n }\n\n // 3b. If not starting with a digit, handle brackets and snake_case\n let nameToFormat = it;\n\n // Remove a single leading '[' if present\n if (nameToFormat.startsWith('[')) {\n nameToFormat = nameToFormat.slice(1);\n }\n\n // Remove a single trailing ']' if present\n if (nameToFormat.endsWith(']')) {\n nameToFormat = nameToFormat.slice(0, -1);\n }\n\n // Apply snakecase to the (potentially modified) string\n return snakecase(nameToFormat);\n }\n\n // 4. Fallback for any other types (e.g., null, undefined, objects)\n // Convert to string first, then apply snakecase\n return snakecase(String(it));\n};\n\ntype Context = Record<string, any>;\ntype Serialized = {\n nullable?: boolean;\n encode?: string;\n use: string;\n toJson: string;\n matches?: string;\n fromJson: string;\n type?: string;\n content: string;\n simple?: boolean;\n};\ntype Emit = (name: string, content: string) => void;\n/**\n * Convert an OpenAPI (JSON Schema style) object into Dart classes\n */\nexport class DartSerializer {\n #spec: OpenAPIObject;\n #emit: Emit;\n\n constructor(spec: OpenAPIObject, emit: Emit) {\n this.#spec = spec;\n this.#emit = emit;\n }\n\n #getRefUsage(schemaName: string, list: string[] = []): string[] {\n this.#spec.components ??= {};\n this.#spec.components.schemas ??= {};\n this.#spec.components.responses ??= {};\n\n const checkSchema = (schema: SchemaObject | ReferenceObject): boolean => {\n if (isRef(schema)) {\n const { model } = parseRef(schema.$ref);\n return model === schemaName;\n }\n if (schema.oneOf && Array.isArray(schema.oneOf)) {\n return (schema.oneOf as Array<SchemaObject | ReferenceObject>).some(\n (subSchema) => checkSchema(subSchema),\n );\n }\n if (\n schema.type === 'array' &&\n schema.items &&\n notRef(schema.items) &&\n schema.items.oneOf\n ) {\n return checkSchema(schema.items);\n }\n return false;\n };\n\n for (const [key, value] of Object.entries(this.#spec.components.schemas)) {\n if (checkSchema(value)) {\n list.push(key);\n }\n }\n\n return list;\n }\n\n #object(\n className: string,\n schema: SchemaObject,\n context: Context,\n ): Serialized {\n if (schema.additionalProperties) {\n this.#emit(className, `typedef ${className} = Map<String, dynamic>;`);\n return {\n content: '',\n use: 'Map<String, dynamic>',\n encode: 'input',\n toJson: `this.${camelcase(context.name)}`,\n fromJson: `json['${camelcase(context.name)}']`,\n matches: `json['${camelcase(context.name)}'] is Map<String, dynamic>`,\n };\n }\n if (isEmpty(schema.properties)) {\n if (context.noEmit !== true) {\n this.#emit(\n className,\n `class ${className} {\n const ${className}(); // Add const constructor\n\n factory ${className}.fromJson(Map<String, dynamic> json) {\n return const ${className}();\n }\n\n Map<String, dynamic> toJson() => {};\n\n /// Determines if a given map can be parsed into an instance of this class.\n /// Returns true for any map since this class has no properties.\n static bool matches(Map<String, dynamic> json) {\n return true; // Any map is fine for an empty object\n }\n}`,\n );\n }\n return {\n content: '',\n encode: 'input.toJson()',\n use: className,\n toJson: `${this.#safe(context.name as string, context.required)}`,\n fromJson: `${className}.fromJson(json['${context.name}'])`,\n matches: `${className}.matches(json['${context.name}'])`,\n };\n }\n\n const props: string[] = [];\n const toJsonProperties: string[] = [];\n const constructorParams: string[] = [];\n const fromJsonParams: string[] = [];\n const matches: string[] = [];\n\n for (const [key, propSchema] of Object.entries(schema.properties)) {\n const propName = key.replace('[]', '');\n const required = (schema.required ?? []).includes(key);\n const typeStr = this.handle(className, propSchema, required, {\n name: propName,\n required,\n propName: [className, propName].filter(Boolean).join('_'),\n });\n const nullable = typeStr.nullable || !required;\n const nullableSuffix = nullable ? '?' : '';\n props.push(\n `final ${typeStr.use}${nullableSuffix} ${camelcase(propName)};`,\n );\n fromJsonParams.push(`${camelcase(propName)}: ${typeStr.fromJson}`);\n toJsonProperties.push(`'${propName}': ${typeStr.toJson}`);\n constructorParams.push(\n `${required ? 'required ' : ''}this.${camelcase(propName)},`,\n );\n if (required) {\n matches.push(`(\n json.containsKey('${camelcase(propName)}')\n ? ${nullable ? `json['${propName}'] == null` : `json['${propName}'] != null`} ${typeStr.matches ? `&& ${typeStr.matches}` : ''}\n : false)`);\n } else {\n matches.push(`(\n json.containsKey('${camelcase(propName)}')\n ? ${nullable ? `json['${propName}'] == null` : `json['${propName}'] != null`} ${typeStr.matches ? `|| ${typeStr.matches}` : ''}\n : true)`);\n }\n }\n\n const { mixins, withMixins } = this.#mixinise(className, context);\n const content = `class ${className} ${withMixins} {\n ${props.join('\\n')}\n ${!mixins.length ? 'const' : ''} ${className}({\n ${constructorParams.join('\\n')}})${mixins.length > 1 ? '' : `:super()`};\n factory ${className}.fromJson(Map<String, dynamic> json) {\nreturn ${className}(\\n${fromJsonParams.join(',\\n')});\n }\n Map<String, dynamic> toJson() => {\n${toJsonProperties.join(',\\n')}\n };\n static bool matches(Map<String, dynamic> json) {\nreturn ${matches.join(' && ')};\n }\n }`;\n if (context.noEmit !== true) {\n this.#emit(className, content);\n }\n const nullable = !context.required || context.nullable === true;\n return {\n use: className,\n content,\n encode: 'input.toJson()',\n toJson: `${this.#safe(context.name, context.required)}`,\n fromJson: context.name\n ? `${context.forJson || className}.fromJson(json['${context.name}'])`\n : `${context.forJson || className}.fromJson(json)`,\n matches: `${className}.matches(json['${context.name}'])`,\n };\n }\n\n #safe(accces: string, required: boolean) {\n return required\n ? `this.${camelcase(accces)}.toJson()`\n : `this.${camelcase(accces)} != null ? this.${camelcase(accces)}!.toJson() : null`;\n }\n\n #array(\n className: string,\n schema: SchemaObject,\n required = false,\n context: Context,\n ): Serialized {\n if (!schema.items) {\n return {\n content: '',\n use: 'List<dynamic>',\n toJson: '',\n fromJson: `List<dynamic>.from(${context.name ? `json['${context.name}']` : `json`})})`,\n matches: '',\n };\n }\n const itemsType = this.handle(className, schema.items, true, context);\n const fromJson = required\n ? context.name\n ? `(json['${context.name}'] as List<${itemsType.simple ? itemsType.use : 'dynamic'}>)\n .map((it) => ${itemsType.simple ? 'it' : `${itemsType.use}.fromJson(it)`})\n .toList()`\n : `(json as List<${itemsType.simple ? itemsType.use : 'dynamic'}>)\n .map((it) => ${itemsType.simple ? 'it' : `${itemsType.use}.fromJson(it)`})\n .toList()`\n : context.name\n ? `json['${context.name}'] != null\n ? (json['${context.name}'] as List<${itemsType.simple ? itemsType.use : 'dynamic'}>)\n .map((it) => ${itemsType.simple ? 'it' : `${itemsType.use}.fromJson(it)`})\n .toList()\n : null`\n : `json != null\n ? (json as List<${itemsType.simple ? itemsType.use : 'dynamic'}>)\n .map((it) => ${itemsType.simple ? 'it' : `${itemsType.use}.fromJson(it)`})\n .toList()\n : null`;\n\n return {\n encode: `input.map((it) => ${itemsType.simple ? 'it' : `it.toJson()`}).toList()`,\n content: '',\n use: `List<${itemsType.use}>`,\n fromJson,\n toJson: `${context.required ? `this.${camelcase(context.name)}${itemsType.simple ? '' : '.map((it) => it.toJson()).toList()'}` : `this.${camelcase(context.name)}!= null? this.${camelcase(context.name)}${itemsType.simple ? '' : '!.map((it) => it.toJson()).toList()'} : null`}`,\n matches: `json['${camelcase(context.name)}'].every((it) => ${itemsType.matches})`,\n };\n }\n\n /**\n * Convert a basic type to Dart\n */\n #primitive(\n className: string,\n type: string,\n schema: SchemaObject,\n context: Record<string, unknown>,\n required = false,\n ): Serialized {\n switch (type) {\n case 'string':\n return this.#string(schema, context);\n case 'number':\n case 'integer':\n return this.number(schema, context);\n case 'boolean':\n return {\n content: '',\n use: 'bool',\n toJson: `${camelcase(context.name as string)}`,\n fromJson: `json['${context.name}']`,\n matches: `json['${context.name}'] is bool`,\n };\n case 'object':\n return this.#object(className, schema, context);\n case 'array':\n return this.#array(className, schema, required, context);\n case 'null':\n return {\n content: '',\n use: 'Null',\n toJson: `${camelcase(context.name as string)}`,\n fromJson: `json['${context.name}']`,\n };\n default:\n // Unknown type -> fallback\n return {\n content: '',\n use: 'dynamic',\n nullable: false,\n toJson: `${camelcase(context.name as string)}`,\n fromJson: `json['${context.name}']`,\n };\n }\n }\n\n #ref(\n className: string,\n $ref: string,\n required: boolean,\n context: Context,\n ): Serialized {\n const schemaName = cleanRef($ref).split('/').pop()!;\n\n const serialized = this.handle(\n schemaName,\n followRef<SchemaObject>(this.#spec, $ref),\n required,\n {\n ...context,\n propName: schemaName,\n noEmit: !!context.alias || !!className || !context.forceEmit,\n },\n );\n return serialized;\n }\n\n // fixme: this method should no longer be needed because the logic in it is being preprocessed before emitting begins\n #allOf(\n className: string,\n schemas: (SchemaObject | ReferenceObject)[],\n context: Context,\n ): Serialized {\n const name = pascalcase(context.propName || className); // className in case is top level\n\n const refs = schemas.filter(isRef);\n const nonRefs = schemas.filter(notRef);\n if (nonRefs.some((it) => it.type && it.type !== 'object')) {\n assert(false, `allOf ${name} must be an object`);\n }\n const objectSchema = merge(\n {},\n ...nonRefs,\n ...refs.map((ref) => followRef(this.#spec, ref.$ref)),\n );\n delete objectSchema.allOf;\n return this.handle(name, objectSchema, true, context);\n }\n\n #anyOf(\n className: string,\n schemas: (SchemaObject | ReferenceObject)[],\n context: Record<string, unknown>,\n ): Serialized {\n // fixme: handle\n if (schemas.length === 0) {\n return {\n content: '',\n nullable: false,\n use: 'dynamic',\n toJson: `${camelcase(context.name as string)}`,\n fromJson: `json['${context.name}']`,\n };\n }\n const nullSchemaIndex = schemas.findIndex((schema) => {\n if (isRef(schema)) {\n const refSchema = followRef(this.#spec, schema.$ref);\n return refSchema.type === 'null';\n }\n return schema.type === 'null';\n });\n const anyOfSchemas = schemas.slice(0);\n if (nullSchemaIndex >= 0) {\n anyOfSchemas.splice(nullSchemaIndex, 1); // remove null schema\n }\n\n return this.handle(className, anyOfSchemas[0], true, {\n ...context,\n nullable: nullSchemaIndex >= 0,\n });\n }\n\n #mixinise(name: string, context: Context) {\n const mixins = this.#getRefUsage(name);\n if (context.mixin) {\n mixins.unshift(context.mixin);\n }\n const withMixins =\n mixins.length > 1\n ? ` with ${mixins.join(', ')}`\n : mixins.length === 1\n ? `extends ${mixins[0]}`\n : '';\n return {\n withMixins,\n mixins,\n };\n }\n\n #oneOf(\n className: string,\n schemas: (SchemaObject | ReferenceObject)[],\n context: Context,\n ): Serialized {\n const name = pascalcase(context.propName || className); // className in case is top level\n\n if (schemas.length === 0) {\n return {\n content: '',\n nullable: false,\n use: 'dynamic',\n toJson: `${camelcase(context.name as string)}`,\n fromJson: `json['${context.name}']`,\n };\n }\n const content: string[] = [];\n const patterns: { pattern: string; name: string }[] = [];\n // FIXME: if there is just one type then no need to add the discriminator\n const objects = schemas.filter(notRef).filter((it) => it.type === 'object');\n for (const schema of schemas) {\n if (isRef(schema)) {\n const refType = this.#ref(className, schema.$ref, true, context);\n patterns.push({\n pattern: `case ${refType.type || 'Map<String, dynamic>'} map when ${refType.use}.matches(map): return ${refType.use}.fromJson(map);`,\n name: refType.use,\n });\n } else if (schema.type === 'string') {\n // todo: make this into a schema with ref (preproccesing)\n content.push(`class ${name}Text with ${name} {\n final String value;\n ${name}Text(this.value);\n @override\n dynamic toJson() => value;\n static bool matches(dynamic value) {\n return value is String;\n }}\n `);\n patterns.push({\n pattern: `case String(): return ${name}Text(json);`,\n name: `${name}Text`,\n });\n } else if (schema.type === 'array') {\n // todo: make this into a schema with ref (preproccesing) with all varients types (integer, string)\n // todo: this can be abstracted so the varients somehow dynamic without having to replicate the same classes all the time\n const itemsType = this.handle(name, schema.items!, true, {\n ...context,\n noEmit: true,\n });\n content.push(`class ${name}List with ${name} {\n final List<${itemsType.use}> value;\n ${name}List(this.value);\n @override\n dynamic toJson() => value;\n static bool matches(dynamic value) {\n return value is List;\n }}`);\n patterns.push({\n pattern: `case List(): return ${name}List(List<${itemsType.use}>.from(json));`,\n name: `${name}List`,\n });\n }\n }\n if (objects.length) {\n // todo: take a look at CompoundFilterFilters at the end\n const candidates: Record<string, Set<string>> = {};\n for (const schema of objects) {\n if (schema.additionalProperties === true) {\n continue;\n }\n assert(\n schema.properties,\n `Schema ${name} has no properties which are required in oneOf in order to determine the discriminator.`,\n );\n for (const [propName, propSchema] of Object.entries(\n schema.properties,\n )) {\n if (\n notRef(propSchema) &&\n propSchema.enum &&\n // fixme: the enum can have more than one value as long as it is not duplicated else where on the other schemas\n propSchema.enum.length === 1\n ) {\n candidates[propName] ??= new Set();\n candidates[propName].add(String(propSchema.enum[0]));\n }\n }\n }\n\n let discriminatorProp: string | undefined;\n\n for (const [name, values] of Object.entries(candidates)) {\n if (\n // make sure we pick the prop that exists on all objects\n values.size === objects.filter((it) => it.properties?.[name]).length\n ) {\n discriminatorProp = name;\n break;\n }\n }\n\n // if (objects.filter((it) => it.additionalProperties !== true).length) {\n // }\n // assert(discriminatorProp, `No discriminator property found in ${name}`);\n\n if (discriminatorProp) {\n for (const schema of objects) {\n const discriminatorValue: string = (\n (schema as SchemaObject).properties![\n discriminatorProp!\n ] as SchemaObject\n ).enum?.[0];\n\n const varientName = `${name}${pascalcase(discriminatorValue)}`;\n patterns.push({\n pattern: `case Map<String, dynamic> map when ${varientName}.matches(json): return ${varientName}.fromJson(map);`,\n name: varientName,\n });\n\n const objResult = this.#object(varientName, schema, {\n ...context,\n noEmit: true,\n mixin: name,\n });\n content.push(objResult.content);\n }\n }\n }\n\n const { mixins, withMixins } = this.#mixinise(name, context);\n content.unshift(`abstract ${mixins.length ? '' : 'mixin'} class ${name} ${withMixins} {\n dynamic toJson();\n ${\n patterns.length\n ? `static ${name} fromJson(dynamic json) {\n switch (json){\n ${patterns.map((it) => it.pattern).join('\\n')}\n default:\n throw ArgumentError(\"Invalid type for query property: \\${json}\");\n }\n }\n\n\n ${\n patterns.length\n ? ` static bool matches(dynamic value) {\n return ${patterns.map((it) => `value is ${it.name}`).join(' || ')};\n }`\n : ''\n }\n\n `\n : ''\n }\n }`);\n this.#emit(name, content.join('\\n'));\n\n return {\n content: content.join('\\n'),\n use: name,\n toJson: `${this.#safe(context.name as string, context.required)}`,\n fromJson: `${name}.fromJson(json['${context.name}'])`,\n matches: `${name}.matches(json['${context.name}'])`,\n };\n }\n\n #simple(type: string) {\n switch (type) {\n case 'string':\n return 'String';\n case 'number':\n return 'double';\n case 'integer':\n return 'int';\n case 'boolean':\n return 'bool';\n default:\n return 'dynamic';\n }\n }\n\n #enum(className: string, schema: SchemaObject, context: Context): Serialized {\n const name = context.propName || className; // className in case enum is top level\n const values = schema.enum as string[];\n const valType = this.#simple((schema.type as string) || 'string');\n // fixme: if enum have one value and cannot be null then use it as default value\n\n const { mixins, withMixins } = this.#mixinise(className, context);\n\n const content = `\n class _EnumValue implements ${pascalcase(name)} {\n final ${valType} value;\n const _EnumValue(this.value);\n @override\n toJson() {return this.value;}\n}\n abstract ${mixins.length ? '' : 'mixin'} class ${pascalcase(name)} ${withMixins} {\n ${values.map((it) => `static const _EnumValue ${formatName(it)} = _EnumValue(${typeof it === 'number' ? it : `'${it}'`});`).join('\\n')}\n dynamic toJson();\n\n ${valType} get value;\n\n static _EnumValue fromJson(${valType} value) {\n switch (value) {\n${values\n .map(\n (it) =>\n `case ${typeof it === 'number' ? it : `'${it}'`}: return ${formatName(it)};`,\n )\n .join('\\n')}\ndefault:\n throw ArgumentError.value(value, \"value\", \"No enum value with that name\");\n }\n }\n\n static bool matches(${valType} value) {\n try {\nfromJson(value);\nreturn true;\n } catch (error) {\nreturn false;\n }\n }\n\n }`;\n if (context.noEmit !== true) {\n this.#emit(name, content);\n }\n return {\n type: Array.isArray(schema.type)\n ? this.#simple(schema.type[0])\n : schema.type\n ? this.#simple(schema.type)\n : undefined,\n content: content,\n use: pascalcase(name),\n toJson: `${context.required ? `this.${camelcase(context.name)}.toJson()` : `this.${camelcase(context.name)} != null ? this.${camelcase(context.name)}!.toJson() : null`}`,\n fromJson: `${pascalcase(name)}.fromJson(json['${context.name}'])`,\n matches: `${pascalcase(name)}.matches(json['${context.name}'])`,\n };\n }\n\n /**\n * Handle string type with formats\n */\n #string(schema: SchemaObject, context: Context): Serialized {\n switch (schema.format) {\n case 'date-time':\n case 'datetime':\n case 'date':\n return {\n content: '',\n use: 'DateTime',\n simple: true,\n toJson: context.required\n ? `this.${camelcase(context.name)}.toIso8601String()`\n : `this.${camelcase(context.name)} != null ? this.${camelcase(\n context.name,\n )}!.toIso8601String() : null`,\n fromJson: context.name\n ? `json['${context.name}'] != null ? DateTime.parse(json['${context.name}']) : null`\n : 'json',\n matches: `json['${context.name}'] is String`,\n };\n case 'binary':\n case 'byte':\n return {\n content: '',\n use: 'File',\n toJson: `this.${camelcase(context.name)}`,\n simple: true,\n fromJson: context.name ? `json['${context.name}']` : 'json',\n matches: `json['${context.name}'] is Uint8List`,\n };\n default:\n return {\n encode: 'input',\n use: `String`,\n content: '',\n simple: true,\n toJson: `this.${camelcase(context.name)}`,\n fromJson: context.name ? `json['${context.name}'] as String` : 'json',\n matches: `json['${context.name}'] is String`,\n };\n }\n }\n\n /**\n * Handle number/integer types with formats\n */\n number(schema: SchemaObject, context: Context): Serialized {\n if (schema.type === 'integer') {\n return {\n content: '',\n use: 'int',\n simple: true,\n toJson: `this.${camelcase(context.name)}`,\n fromJson: `json['${context.name}']`,\n matches: `json['${context.name}'] is int`,\n };\n }\n if (['float', 'double'].includes(schema.format as string)) {\n return {\n content: '',\n use: 'double',\n simple: true,\n toJson: `this.${camelcase(context.name)}`,\n fromJson: `json['${context.name}']`,\n matches: `json['${context.name}'] is double`,\n };\n }\n return {\n content: '',\n use: 'num',\n simple: true,\n toJson: `this.${camelcase(context.name)}`,\n fromJson: `json['${context.name}']`,\n matches: `json['${context.name}'] is double`,\n };\n }\n\n #serialize(\n className: string,\n schema: SchemaObject | ReferenceObject,\n required = true,\n context: Context = {},\n ): Serialized {\n if (isRef(schema)) {\n return this.#ref(className, schema.$ref, required, context);\n }\n // some schemas have decalres allof, oneof, anyOf at once or combinations of them\n // so we need to process them in order\n if (schema.allOf && Array.isArray(schema.allOf)) {\n return this.#allOf(className, schema.allOf, context);\n }\n if (schema.oneOf && Array.isArray(schema.oneOf)) {\n return this.#oneOf(className, schema.oneOf, context);\n }\n if (schema.anyOf && Array.isArray(schema.anyOf)) {\n return this.#anyOf(className, schema.anyOf, context);\n }\n if (schema.enum && Array.isArray(schema.enum)) {\n return this.#enum(className, schema, context);\n }\n // Handle types\n const types = Array.isArray(schema.type)\n ? schema.type\n : schema.type\n ? [schema.type]\n : [];\n\n let nullable = false;\n if ('nullable' in schema && schema.nullable) {\n nullable = true;\n } else if (schema.default === null) {\n nullable = true;\n } else if (types.includes('null')) {\n nullable = true;\n }\n\n // If no explicit \"type\", fallback to dynamic\n if (!types.length) {\n // unless properties are defined then assume object\n if ('properties' in schema) {\n return this.#object(className, schema, context);\n }\n if ('items' in schema) {\n return this.#array(className, schema, true, context);\n }\n return {\n content: '',\n use: 'dynamic',\n toJson: `${camelcase(context.name as string)}`,\n fromJson: `json['${context.name}']`,\n nullable: false,\n matches: '', // keep it empty as 'type is dynamic' is always true\n };\n }\n return this.#primitive(\n className,\n types[0],\n schema,\n { ...context, nullable },\n required,\n );\n }\n\n handle(\n className: string,\n schema: SchemaObject | ReferenceObject,\n required = true,\n context: Context = {},\n ): Serialized {\n const alias = context.alias;\n context.alias = undefined;\n const serialized = this.#serialize(className, schema, required, {\n ...context,\n forJson: alias,\n });\n\n if (alias) {\n this.#emit(className, `typedef ${alias} = ${serialized.use};`);\n return serialized;\n }\n return serialized;\n }\n}\n\nexport function isObjectSchema(\n schema: SchemaObject | ReferenceObject,\n): schema is SchemaObject {\n return !isRef(schema) && (schema.type === 'object' || !!schema.properties);\n}\n", "import 'dart:convert';\nimport 'dart:io';\n\nimport 'package:http/http.dart' as http;\nimport 'package:http_parser/http_parser.dart';\nimport 'package:mime/mime.dart' as mime;\n\nimport './interceptors.dart';\nimport './responses.dart';\n\nclass Dispatcher {\n final List<Interceptor> interceptors;\n\n Dispatcher(this.interceptors);\n\n Future<http.StreamedResponse> multipart(\n RequestConfig config,\n Map<String, dynamic> body,\n ) async {\n final modifiedConfig = interceptors.fold(\n config,\n (acc, interceptor) => interceptor.before(acc),\n );\n final request = http.MultipartRequest(\n modifiedConfig.method,\n modifiedConfig.url,\n );\n request.headers.addAll(modifiedConfig.headers);\n for (var entry in body.entries) {\n final key = entry.key;\n final value = entry.value;\n if (value is File) {\n final mimeType = mime.lookupMimeType(value.path);\n request.files.add(\n http.MultipartFile(\n key,\n value.openRead(),\n await value.length(),\n filename: value.uri.pathSegments.last,\n contentType: mimeType != null ? MediaType.parse(mimeType) : null,\n ),\n );\n } else {\n request.fields[key] = value.toString();\n }\n }\n\n return request.send();\n }\n\n Future<http.StreamedResponse> empty(RequestConfig config) {\n final modifiedConfig = interceptors.fold(\n config,\n (acc, interceptor) => interceptor.before(acc),\n );\n final request = http.Request(modifiedConfig.method, modifiedConfig.url);\n request.headers.addAll(modifiedConfig.headers);\n return request.send();\n }\n\n Future<http.StreamedResponse> json(RequestConfig config, dynamic body) {\n final modifiedConfig = interceptors.fold(\n config,\n (acc, interceptor) => interceptor.before(acc),\n );\n final request = http.Request(modifiedConfig.method, modifiedConfig.url);\n request.headers.addAll(modifiedConfig.headers);\n\n request.headers['Content-Type'] = 'application/json';\n if ((body is Map || body is List)) {\n request.body = jsonEncode(body);\n } else if (body is String) {\n request.body = body;\n } else {\n throw ArgumentError('Unsupported body type: ${body.runtimeType}');\n }\n\n return request.send();\n }\n}\n\nclass Receiver {\n final List<Interceptor> interceptors;\n Receiver(this.interceptors);\n\n dynamic _parse(http.Response response) {\n final contentTypeHeader = response.headers['content-type'];\n final parsed = parseContentType(contentTypeHeader);\n if (parsed.type == 'application/json') {\n return jsonDecode(response.body);\n } else if (parsed.type == 'text/plain') {\n return response.body;\n } else if (parsed.type == 'application/octet-stream') {\n return response.bodyBytes;\n } else {\n throw UnsupportedError('Unsupported content type: ${parsed.type}');\n }\n }\n\n dynamic json(http.StreamedResponse stream) async {\n if (stream.statusCode >= 200 && stream.statusCode < 300) {\n final response = await http.Response.fromStream(stream);\n return _parse(response);\n }\n switch (stream.statusCode) {\n case 400:\n throw BadRequestError('');\n case 401:\n throw UnauthorizedError('');\n case 403:\n throw ForbiddenError('');\n case 404:\n throw NotFoundError('');\n case 500:\n throw InternalServerError('');\n case 402:\n throw PaymentRequiredError('');\n case 405:\n throw MethodNotAllowedError('');\n case 406:\n throw NotAcceptableError('');\n case 409:\n throw ConflictError('');\n case 410:\n throw GoneError('');\n case 422:\n throw UnprocessableEntityError('');\n case 429:\n throw TooManyRequestsError('');\n case 413:\n throw PayloadTooLargeError('');\n case 415:\n throw UnsupportedMediaTypeError('');\n case 501:\n throw NotImplementedError('');\n case 502:\n throw BadGatewayError('');\n case 503:\n throw ServiceUnavailableError('');\n case 504:\n throw GatewayTimeoutError('');\n default:\n throw UnknownApiError('', stream.statusCode);\n }\n }\n}\n\n({String type, Map<String, String> parameters}) parseContentType(\n String? contentTypeHeader,\n) {\n if (contentTypeHeader == null || contentTypeHeader.isEmpty) {\n return (type: '', parameters: {});\n }\n final parts = contentTypeHeader.split(';');\n final type = parts[0].trim();\n final parameters = <String, String>{};\n for (var i = 1; i < parts.length; i++) {\n final param = parts[i].split('=');\n if (param.length == 2) {\n parameters[param[0].trim()] = param[1].trim();\n }\n }\n\n return (type: type, parameters: parameters);\n}\n", "abstract class Interceptor {\n RequestConfig before(RequestConfig config);\n void after();\n}\n\nclass BaseUrlInterceptor extends Interceptor {\n final String Function() getBaseUrl;\n BaseUrlInterceptor(this.getBaseUrl);\n\n @override\n RequestConfig before(RequestConfig config) {\n final baseUrl = getBaseUrl();\n if (config.url.scheme.isEmpty) {\n config.url = Uri.parse(baseUrl + config.url.toString());\n }\n return config;\n }\n\n @override\n void after() {\n //\n }\n}\n\nclass RequestConfig {\n final String method;\n Uri url;\n final Map<String, String> headers;\n RequestConfig({required this.method, required this.url, required this.headers});\n}\n", "sealed class ApiError {\n final String message;\n final int? statusCode;\n final String status;\n const ApiError(this.message, {this.statusCode, this.status = ''});\n\n @override\n String toString() =>\n 'ApiError(status: $status, statusCode: $statusCode, message: $message)';\n}\n\nbase class BadRequestError extends ApiError {\n const BadRequestError(String message)\n : super(message, statusCode: 400, status: 'BadRequest');\n}\n\nbase class UnauthorizedError extends ApiError {\n const UnauthorizedError(String message)\n : super(message, statusCode: 401, status: 'Unauthorized');\n}\n\nbase class ForbiddenError extends ApiError {\n const ForbiddenError(String message)\n : super(message, statusCode: 403, status: 'Forbidden');\n}\n\nbase class NotFoundError extends ApiError {\n const NotFoundError(String message)\n : super(message, statusCode: 404, status: 'NotFound');\n}\n\nbase class InternalServerError extends ApiError {\n const InternalServerError(String message)\n : super(message, statusCode: 500, status: 'InternalServerError');\n}\n\nbase class UnknownApiError extends ApiError {\n const UnknownApiError(String message, int statusCode)\n : super(message, statusCode: statusCode, status: 'UnknownApiError');\n}\n\nbase class PaymentRequiredError extends ApiError {\n const PaymentRequiredError(String message)\n : super(message, statusCode: 402, status: 'PaymentRequired');\n}\n\nbase class MethodNotAllowedError extends ApiError {\n const MethodNotAllowedError(String message)\n : super(message, statusCode: 405, status: 'MethodNotAllowed');\n}\n\nbase class NotAcceptableError extends ApiError {\n const NotAcceptableError(String message)\n : super(message, statusCode: 406, status: 'NotAcceptable');\n}\n\nbase class ConflictError extends ApiError {\n const ConflictError(String message)\n : super(message, statusCode: 409, status: 'Conflict');\n}\n\nbase class GoneError extends ApiError {\n const GoneError(String message)\n : super(message, statusCode: 410, status: 'Gone');\n}\n\nbase class UnprocessableEntityError extends ApiError {\n const UnprocessableEntityError(String message)\n : super(message, statusCode: 422, status: 'UnprocessableEntity');\n}\n\nbase class TooManyRequestsError extends ApiError {\n const TooManyRequestsError(String message)\n : super(message, statusCode: 429, status: 'TooManyRequests');\n}\n\nbase class PayloadTooLargeError extends ApiError {\n const PayloadTooLargeError(String message)\n : super(message, statusCode: 413, status: 'PayloadTooLarge');\n}\n\nbase class UnsupportedMediaTypeError extends ApiError {\n const UnsupportedMediaTypeError(String message)\n : super(message, statusCode: 415, status: 'UnsupportedMediaType');\n}\n\nbase class NotImplementedError extends ApiError {\n const NotImplementedError(String message)\n : super(message, statusCode: 501, status: 'NotImplemented');\n}\n\nbase class BadGatewayError extends ApiError {\n const BadGatewayError(String message)\n : super(message, statusCode: 502, status: 'BadGateway');\n}\n\nbase class ServiceUnavailableError extends ApiError {\n const ServiceUnavailableError(String message)\n : super(message, statusCode: 503, status: 'ServiceUnavailable');\n}\n\nbase class GatewayTimeoutError extends ApiError {\n const GatewayTimeoutError(String message)\n : super(message, statusCode: 504, status: 'GatewayTimeout');\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,SAAS,uBAAuB;AACzC,SAAS,SAAAA,cAAa;AACtB,OAAOC,aAAY;AACnB,SAAS,aAAAC,kBAAiB;AAC1B,SAAS,QAAAC,aAAY;AASrB,SAAS,aAAAC,kBAAiB;AAC1B,OAAO,UAAU;;;ACdjB;EACE,cAAc;EACd,aAAa;EACb,cAAc;OACT;ACJP,OAAO,MAAM,WAAW,kBAAkB;ACC1C,SAAS,OAAO,UAAU,SAAS,MAAM,iBAAiB;AAC1D,SAAS,SAAS,SAAS,YAAY,YAAY;AEFnD,OAAO,WAAW;AAElB,OAAOC,SAAQ;ACFf,SAAS,WAAW;AJGb,IAAM,eAAe,OAAO,IAAI,WAAW;AAC3C,IAAM,SAAS,OAAO,IAAI,OAAO;ACOxC,eAAsB,MAAM,MAAgC;AAC1D,SAAO,KAAK,IAAI,EACb,KAAK,MAAM,IAAI,EACf,MAAM,MAAM,KAAK;AACtB;AASA,eAAsB,WACpB,KACA,UAIA;AACA,QAAM,QAAQ;IACZ,OAAO,QAAQ,QAAQ,EAAE,IAAI,OAAO,CAAC,MAAM,OAAO,MAAM;AACtD,UAAI,YAAY,MAAM;AACpB;MACF;AACA,YAAM,WAAW,WAAW,IAAI,IAAI,OAAO,KAAK,KAAK,IAAI;AACzD,YAAM,MAAM,QAAQ,QAAQ,GAAG,EAAE,WAAW,KAAK,CAAC;AAClD,UAAI,OAAO,YAAY,UAAU;AAC/B,cAAM,UAAU,UAAU,SAAS,OAAO;MAC5C,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IACF;EACF;AACA,SAAO;AACT;AAgBA,IAAM,mBAAmB,oBAAI,IAAI;EAC/B;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AACF,CAAC;AAUD,SAAS,YAAY,eAA+B;AAElD,MAAI,MAAM,KAAK,aAAa,GAAG;AAC7B,WAAO,IAAI,aAAa;EAC1B;AAEA,SAAO,iBAAiB,IAAI,aAAa,IACrC,GAAG,aAAa,MAChB;AACN;AASO,SAAS,oBACd,YACA,WACQ;AACR,QAAM,cAAc,UAAU,eAAe;AAC7C,QAAM,gBAAgB;AACtB,QAAM,cAAc,oBAAI,IAAI;;IAE1B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;EACF,CAAC;AAED,QAAM,WAAW,WAAW,MAAM,GAAG,EAAE,OAAO,OAAO;AAErD,QAAM,sBAAsB,SAAS;IACnC,CAAC,YACC,WACA,CAAC,QAAQ,WAAW,GAAG,KACvB,CAAC,QAAQ,SAAS,GAAG,KACrB,CAAC,cAAc,KAAK,OAAO;EAC/B;AAGA,WAAS,IAAI,oBAAoB,SAAS,GAAG,KAAK,GAAG,KAAK;AACxD,UAAM,UAAU,oBAAoB,CAAC;AACrC,QAAI,CAAC,QAAQ,WAAW,GAAG,GAAG;AAE5B,aAAO,YAAY,UAAU,OAAO,CAAC;IACvC;EACF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;AAAA,QAC1D;AACA;AAAA,MACF;AACA,YAAM,aAAa,IAAI,eAAe,MAAM,CAAC,MAAM,YAAY;AAAA,MAG/D,CAAC;AACD,UAAI,uBAAuB,IAAI,GAAG;AAChC,eAAO;AAAA,UACL,MAAM;AAAA,UACN;AAAA,UACA;AAAA,UACA,QAAQ;AAAA,UACR,YAAY;AAAA,QACd;AAAA,MACF;AACA,UAAI,qBAAqB,IAAI,GAAG;AAC9B,cAAM,aAAa,WAAW,OAAO,YAAY,QAAQ,MAAM;AAAA;AAAA,UAE7D,QAAQ;AAAA,QACV,CAAC;AACD,eAAO;AAAA,UACL,MAAM;AAAA,UACN;AAAA,UACA;AAAA,UACA,QAAQ,yDAAyD,WAAW,QAAQ;AAAA,UACpF,YAAY,WAAW;AAAA,QACzB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;",
|
|
6
|
-
"names": ["merge", "assert", "
|
|
3
|
+
"sources": ["../src/lib/generate.ts", "../../spec/src/lib/loaders/local-loader.ts", "../../spec/src/lib/loaders/remote-loader.ts", "../../spec/src/lib/operation.ts", "../src/lib/dart-emitter.ts", "../src/lib/http/dispatcher.txt", "../src/lib/http/interceptors.txt", "../src/lib/http/responses.txt"],
|
|
4
|
+
"sourcesContent": ["import { parse as partContentType } from 'fast-content-type-parse';\nimport { merge } from 'lodash-es';\nimport assert from 'node:assert';\nimport { writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport type {\n OpenAPIObject,\n OperationObject,\n ReferenceObject,\n RequestBodyObject,\n ResponseObject,\n SchemaObject,\n} from 'openapi3-ts/oas31';\nimport { camelcase } from 'stringcase';\nimport yaml from 'yaml';\n\nimport {\n followRef,\n isEmpty,\n isRef,\n notRef,\n pascalcase,\n snakecase,\n} from '@sdk-it/core';\nimport { getFolderExportsV2, writeFiles } from '@sdk-it/core/file-system.js';\nimport {\n type Operation,\n forEachOperation,\n isStreamingContentType,\n isSuccessStatusCode,\n parseJsonContentType,\n} from '@sdk-it/spec';\n\nimport { DartSerializer, isObjectSchema } from './dart-emitter.ts';\nimport dispatcherTxt from './http/dispatcher.txt';\nimport interceptorsTxt from './http/interceptors.txt';\nimport responsesTxt from './http/responses.txt';\n\nfunction tuneSpec(\n spec: OpenAPIObject,\n schemas: Record<string, SchemaObject | ReferenceObject>,\n refs: { name: string; value: SchemaObject }[],\n) {\n for (const [name, schema] of Object.entries(schemas)) {\n if (isRef(schema)) continue;\n\n if (!isEmpty(schema.anyOf) && !isEmpty(schema.oneOf)) {\n delete schema.anyOf;\n }\n if (!isEmpty(schema.allOf)) {\n const schemas = schema.allOf;\n const refs = schemas.filter(isRef);\n const nonRefs = schemas.filter(notRef);\n if (nonRefs.some((it) => it.type && it.type !== 'object')) {\n assert(false, `allOf ${name} must be an object`);\n }\n const objectSchema = merge(\n {},\n ...nonRefs,\n ...refs.map((ref) => followRef(spec, ref.$ref)),\n );\n delete objectSchema.allOf;\n delete schema.allOf;\n Object.assign(schema, objectSchema);\n }\n\n if (schema.type === 'object') {\n if (!isEmpty(schema.oneOf)) {\n for (const oneOfIdx in schema.oneOf) {\n const oneOf = schema.oneOf[oneOfIdx];\n if (isRef(oneOf)) continue;\n if (!isEmpty(oneOf.required) && schema.properties) {\n schema.oneOf[oneOfIdx] = schema.properties[oneOf.required[0]];\n }\n }\n\n delete schema.type;\n tuneSpec(spec, schemas, refs);\n continue;\n }\n\n schema.properties ??= {};\n\n for (const [propName, value] of Object.entries(schema.properties)) {\n if (isRef(value)) continue;\n const refName = pascalcase(`${name} ${propName.replace('[]', '')}`);\n refs.push({ name: refName, value });\n schema.properties[propName] = {\n $ref: `#/components/schemas/${refName}`,\n };\n const props = Object.fromEntries(\n Object.entries(value.properties ?? {}).map(([key, value]) => {\n return [pascalcase(`${refName} ${key}`), value];\n }),\n );\n tuneSpec(spec, props, refs);\n // if (value.oneOf && Array.isArray(value.oneOf) && value.oneOf.length) {\n // for (const oneOfIdx in value.oneOf) {\n // const oneOf = value.oneOf[oneOfIdx];\n // if (isRef(oneOf)) continue;\n // if (oneOf.type === 'string') {\n // console.log(refName);\n // // const refName= pascalcase(`${name} ${key} ${oneOfIdx}`);\n // // schema.oneOf[oneOfIdx] = {\n // // $ref: `#/components/schemas/${refName}`,\n // // };\n // }\n // }\n // }\n }\n } else if (schema.type === 'array') {\n if (isRef(schema.items)) continue;\n const refName = name;\n refs.push({ name: refName, value: schema.items ?? {} });\n schema.items = {\n $ref: `#/components/schemas/${refName}`,\n };\n }\n }\n}\nexport async function generate(\n spec: OpenAPIObject,\n settings: {\n output: string;\n name?: string;\n /**\n * full: generate a full project including package.json and tsconfig.json. useful for monorepo/workspaces\n * minimal: generate only the client sdk\n */\n mode?: 'full' | 'minimal';\n formatCode?: (options: { output: string }) => void | Promise<void>;\n },\n) {\n const clientName = settings.name || 'Client';\n const output = join(settings.output, 'lib');\n const groups: Record<\n string,\n {\n use: string;\n methods: string[];\n }\n > = {};\n spec.components ??= {};\n spec.components.schemas ??= {};\n const inputs: Record<string, string> = {};\n const outputs: Record<string, string> = {};\n forEachOperation({ spec }, (entry, operation) => {\n // if (entry.path !== '/v6/prepareUpload') {\n // return;\n // }\n operation.responses ??= {};\n spec.components ??= {};\n spec.components.schemas ??= {};\n for (const status in operation.responses) {\n if (!isSuccessStatusCode(status)) continue;\n const response = operation.responses[status];\n if (!isEmpty(response.content)) {\n for (const [contentType, mediaType] of Object.entries(\n response.content,\n )) {\n if (parseJsonContentType(contentType)) {\n if (mediaType.schema && !isRef(mediaType.schema)) {\n const outputName = pascalcase(`${operation.operationId} output`);\n spec.components.schemas[outputName] = mediaType.schema;\n operation.responses[status].content ??= {};\n operation.responses[status].content[contentType].schema = {\n $ref: `#/components/schemas/${outputName}`,\n };\n }\n }\n // handle chunked response\n }\n }\n }\n console.log(`Processing ${entry.method} ${entry.path}`);\n const group =\n groups[entry.groupName] ??\n (groups[entry.groupName] = {\n methods: [],\n use: `final ${entry.groupName} = new ${pascalcase(entry.groupName)}();`,\n });\n\n const input = toInputs(spec, { entry, operation });\n Object.assign(inputs, input.inputs);\n\n const response = toOutput(spec, operation);\n if (response) {\n Object.assign(outputs, response.outputs);\n }\n group.methods.push(`\n Future<${response ? response.returnType : 'http.StreamedResponse'}> ${camelcase(operation.operationId)}(\n ${isEmpty(operation.requestBody) ? '' : `${input.inputName} input`}\n ) async {\n final stream = await this.dispatcher.${input.contentType}(RequestConfig(\n method: '${entry.method}',\n url: Uri.parse('${entry.path}'),\n headers: {},\n ), ${['json', 'multipart'].includes(input.contentType) ? input.encode : ``});\n ${response ? `${response.decode};` : 'return stream;'}\n }\n `);\n });\n\n const newRefs: { name: string; value: SchemaObject }[] = [];\n tuneSpec(spec, spec.components.schemas, newRefs);\n for (const ref of newRefs) {\n spec.components.schemas[ref.name] = ref.value;\n }\n await writeFile(\n join(process.cwd(), 'openai.json'),\n JSON.stringify(spec, null, 2),\n );\n\n const models = Object.entries(spec.components.schemas).reduce<\n Record<string, string>\n >((acc, [name, schema]) => {\n const serializer = new DartSerializer(spec, (name, content) => {\n acc[`models/${snakecase(name)}.dart`] =\n `import 'dart:io';import 'dart:typed_data'; import './index.dart';\\n\\n${content}`;\n });\n serializer.handle(pascalcase(name), schema);\n return acc;\n }, {});\n\n const clazzez = Object.entries(groups).reduce<Record<string, string>>(\n (acc, [name, { methods }]) => {\n return {\n ...acc,\n [`api/${snakecase(name)}.dart`]: `\nimport 'dart:convert';\n\nimport 'package:http/http.dart' as http;\n\nimport '../interceptors.dart';\nimport '../inputs/index.dart';\nimport '../outputs/index.dart';\nimport '../models/index.dart';\nimport '../http.dart';\n\n class ${pascalcase(name)}Client {\n final Dispatcher dispatcher;\n final Receiver receiver;\n ${pascalcase(name)}Client(this.dispatcher, this.receiver);\n ${methods.join('\\n')}\n }\n `,\n };\n },\n {},\n );\n\n const client = `\n ${Object.keys(groups)\n .map((name) => `import './api/${snakecase(name)}.dart';`)\n .join('\\n')}\nimport './interceptors.dart';\nimport './http.dart';\n\n class ${clientName} {\n final Options options;\n${Object.keys(groups)\n .map((name) => `late final ${pascalcase(name)}Client ${camelcase(name)};`)\n .join('\\n')}\n\n ${clientName}(this.options) {\n final interceptors = [BaseUrlInterceptor(() => this.options.baseUrl)];\n final dispatcher = Dispatcher(interceptors);\n final receiver = Receiver(interceptors);\n ${Object.keys(groups)\n .map(\n (name) =>\n `this.${camelcase(name)} = ${pascalcase(name)}Client(dispatcher, receiver);`,\n )\n .join('\\n')}\n\n }\n\n void setOptions({String? baseUrl}) {\n if (baseUrl != null) {\n options.baseUrl = baseUrl;\n }\n }\n }\n\n\nclass Options {\n String baseUrl;\n Options({required this.baseUrl});\n}\n\n `;\n await writeFiles(output, {\n ...models,\n ...inputs,\n ...outputs,\n });\n\n await writeFiles(output, {\n 'models/index.dart': await getFolderExportsV2(join(output, 'models'), {\n exportSyntax: 'export',\n extensions: 'dart',\n }),\n 'inputs/index.dart': await getFolderExportsV2(join(output, 'inputs'), {\n exportSyntax: 'export',\n extensions: 'dart',\n }),\n 'outputs/index.dart': await getFolderExportsV2(join(output, 'outputs'), {\n exportSyntax: 'export',\n extensions: 'dart',\n }),\n 'interceptors.dart': interceptorsTxt,\n 'http.dart': dispatcherTxt,\n 'responses.dart': responsesTxt,\n ...clazzez,\n });\n await writeFiles(output, {\n 'package.dart': `${await getFolderExportsV2(join(output), {\n exportSyntax: 'export',\n extensions: 'dart',\n ignore(dirent) {\n return dirent.isFile() && dirent.name === 'package.dart';\n },\n })}${client}`,\n });\n\n await writeFiles(settings.output, {\n 'pubspec.yaml': {\n ignoreIfExists: true,\n content: yaml.stringify({\n name: settings.name\n ? `${snakecase(clientName.toLowerCase())}_sdk`\n : 'sdk',\n version: '0.0.1',\n environment: {\n sdk: '^3.7.2',\n },\n dependencies: {\n http: '^1.3.0',\n mime: '^2.0.0',\n },\n }),\n },\n });\n\n await settings.formatCode?.({\n output: output,\n });\n}\n\n// function makeRequestBody(spec: OpenAPIObject, operation: OperationObject) {\n// const requestBody = operation.requestBody;\n// const params = (operation.parameters ?? []).map((it) =>\n// isRef(it) ? followRef<ParameterObject>(spec, it.$ref) : it,\n// );\n// if (!requestBody) return {\n\n// }\n// if (isRef(requestBody)) {\n// return followRef<RequestBodyObject>(operation, requestBody.$ref);\n// }\n// return requestBody;\n// }\n\nfunction toInputs(spec: OpenAPIObject, { entry, operation }: Operation) {\n const inputs: Record<string, unknown> = {};\n const inputName = pascalcase(`${operation.operationId} input`);\n let contentType = 'empty';\n let encode = '';\n\n if (!isEmpty(operation.requestBody)) {\n const requestBody = isRef(operation.requestBody)\n ? followRef<RequestBodyObject>(spec, operation.requestBody.$ref)\n : operation.requestBody;\n\n for (const type in requestBody.content) {\n const ctSchema = isRef(requestBody.content[type].schema)\n ? followRef(spec, requestBody.content[type].schema.$ref)\n : requestBody.content[type].schema;\n if (!ctSchema) {\n console.warn(\n `Schema not found for ${type} in ${entry.method} ${entry.path}`,\n );\n continue;\n }\n\n const serializer = new DartSerializer(spec, (name, content) => {\n inputs[join(`inputs/${name}.dart`)] =\n `import 'dart:io';import 'dart:typed_data';import '../models/index.dart'; import './index.dart';\\n\\n${content}`;\n });\n const serialized = serializer.handle(inputName, ctSchema, true, {\n alias: isObjectSchema(ctSchema) ? undefined : inputName,\n });\n encode = serialized.encode as string;\n const [mediaType, mediaSubType] = partContentType(type).type.split('/');\n if (mediaType === 'application') {\n contentType = parseJsonContentType(type) as string;\n } else {\n contentType = mediaType;\n }\n\n // const schema = merge({}, objectSchema, {\n // required: additionalProperties\n // .filter((p) => p.required)\n // .map((p) => p.name),\n // properties: additionalProperties.reduce<Record<string, unknown>>(\n // (acc, p) => ({\n // ...acc,\n // [p.name]: p.schema,\n // }),\n // {},\n // ),\n // });\n\n // Object.assign(inputs, bodyInputs(config, objectSchema));\n // schemas[shortContenTypeMap[type]] = zodDeserialzer.handle(schema, true);\n }\n }\n\n return { inputs, inputName, contentType, encode };\n}\n\nfunction toOutput(spec: OpenAPIObject, operation: OperationObject) {\n const outputName = pascalcase(`${operation.operationId} output`);\n operation.responses ??= {};\n const outputs: Record<string, string> = {};\n for (const status in operation.responses) {\n const response = isRef(operation.responses[status] as ReferenceObject)\n ? followRef<ResponseObject>(spec, operation.responses[status].$ref)\n : (operation.responses[status] as ResponseObject);\n for (const type in response.content) {\n const { schema } = response.content[type];\n if (!schema) {\n console.warn(\n `Schema not found for ${type} in ${operation.operationId}`,\n );\n continue;\n }\n const serializer = new DartSerializer(spec, (name, content) => {\n // outputs[join(`outputs/${name}.dart`)] =\n // `import 'dart:typed_data'; import '../models/index.dart'; \\n\\n${content}`;\n });\n if (isStreamingContentType(type)) {\n return {\n type: 'stream',\n outputName,\n outputs,\n decode: `return stream`,\n returnType: `http.StreamedResponse`,\n };\n }\n if (parseJsonContentType(type)) {\n const serialized = serializer.handle(outputName, schema, true, {\n // alias: outputName,\n noEmit: true,\n });\n return {\n type: 'json',\n outputName,\n outputs,\n decode: `final json = await this.receiver.json(stream); return ${serialized.fromJson}`,\n returnType: serialized.use,\n };\n }\n }\n }\n return null;\n}\n", "import { readFile } from 'node:fs/promises';\nimport { extname } from 'node:path';\nimport { parse } from 'yaml';\n\nexport async function loadLocal(location: string) {\n const extName = extname(location);\n const text = await readFile(location, 'utf-8');\n switch (extName) {\n case '.json':\n return JSON.parse(text);\n case '.yaml':\n case '.yml':\n return parse(text);\n default:\n throw new Error(`Unsupported file extension: ${extName}`);\n }\n}\n", "import { extname } from 'node:path';\nimport { parse } from 'yaml';\n\nexport async function loadRemote<T>(location: string): Promise<T> {\n const extName = extname(location);\n const response = await fetch(location);\n switch (extName) {\n case '.json':\n return response.json() as Promise<T>;\n case '.yaml':\n case '.yml': {\n const text = await response.text();\n return parse(text);\n }\n default:\n try {\n // try to parse it as json first\n return response.json() as Promise<T>;\n } catch {\n // parse as yaml\n const text = await response.text();\n return parse(text) as Promise<T>;\n }\n }\n}\n", "import type {\n OpenAPIObject,\n OperationObject,\n ParameterObject,\n ReferenceObject,\n ResponseObject,\n} from 'openapi3-ts/oas31';\nimport { camelcase } from 'stringcase';\n\nimport { followRef, isRef } from '@sdk-it/core';\n\nexport const defaults: Partial<GenerateSdkConfig> &\n Required<Pick<GenerateSdkConfig, 'operationId' | 'tag'>> = {\n operationId: (operation, path, method) => {\n if (operation.operationId) {\n return camelcase(operation.operationId);\n }\n const metadata = operation['x-oaiMeta'];\n if (metadata && metadata.name) {\n return camelcase(metadata.name);\n }\n return camelcase(\n [method, ...path.replace(/[\\\\/\\\\{\\\\}]/g, ' ').split(' ')]\n .filter(Boolean)\n .join(' ')\n .trim(),\n );\n },\n tag: (operation, path) => {\n return operation.tags?.[0]\n ? sanitizeTag(operation.tags?.[0])\n : determineGenericTag(path, operation);\n },\n};\n\nexport type TunedOperationObject = Omit<\n OperationObject,\n 'operationId' | 'parameters' | 'responses'\n> & {\n operationId: string;\n parameters: (ParameterObject | ReferenceObject)[];\n responses: Record<string, ResponseObject>;\n};\n\nexport interface OperationEntry {\n name?: string;\n method: string;\n path: string;\n groupName: string;\n tag: string;\n}\nexport type Operation = {\n entry: OperationEntry;\n operation: TunedOperationObject;\n};\n\nfunction resolveResponses(spec: OpenAPIObject, operation: OperationObject) {\n const responses = operation.responses ?? {};\n const resolved: Record<string, ResponseObject> = {};\n for (const status in responses) {\n const response = isRef(responses[status] as ReferenceObject)\n ? followRef<ResponseObject>(spec, responses[status].$ref)\n : (responses[status] as ResponseObject);\n resolved[status] = response;\n }\n return resolved;\n}\n\nexport function forEachOperation<T>(\n config: GenerateSdkConfig,\n callback: (entry: OperationEntry, operation: TunedOperationObject) => T,\n) {\n const result: T[] = [];\n for (const [path, pathItem] of Object.entries(config.spec.paths ?? {})) {\n const { parameters = [], ...methods } = pathItem;\n\n // Convert Express-style routes (:param) to OpenAPI-style routes ({param})\n const fixedPath = path.replace(/:([^/]+)/g, '{$1}');\n\n for (const [method, operation] of Object.entries(methods) as [\n string,\n OperationObject,\n ][]) {\n const formatOperationId = config.operationId ?? defaults.operationId;\n const formatTag = config.tag ?? defaults.tag;\n const operationName = formatOperationId(operation, fixedPath, method);\n const operationTag = formatTag(operation, fixedPath);\n const metadata = operation['x-oaiMeta'] ?? {};\n\n result.push(\n callback(\n {\n name: metadata.name,\n method,\n path: fixedPath,\n groupName: operationTag,\n tag: operationTag,\n },\n {\n ...operation,\n parameters: [...parameters, ...(operation.parameters ?? [])],\n operationId: operationName,\n responses: resolveResponses(config.spec, operation),\n },\n ),\n );\n }\n }\n return result;\n}\n\nexport interface GenerateSdkConfig {\n spec: OpenAPIObject;\n operationId?: (\n operation: OperationObject,\n path: string,\n method: string,\n ) => string;\n tag?: (operation: OperationObject, path: string) => string;\n}\n\n/**\n * Set of reserved TypeScript keywords and common verbs potentially used as tags.\n */\n\nconst reservedKeywords = new Set([\n 'await', // Reserved in async functions\n 'break',\n 'case',\n 'catch',\n 'class',\n 'const',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'else',\n 'enum',\n 'export',\n 'extends',\n 'false',\n 'finally',\n 'for',\n 'function',\n 'if',\n 'implements', // Strict mode\n 'import',\n 'in',\n 'instanceof',\n 'interface', // Strict mode\n 'let', // Strict mode\n 'new',\n 'null',\n 'package', // Strict mode\n 'private', // Strict mode\n 'protected', // Strict mode\n 'public', // Strict mode\n 'return',\n 'static', // Strict mode\n 'super',\n 'switch',\n 'this',\n 'throw',\n 'true',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'while',\n 'with',\n 'yield', // Strict mode / Generator functions\n // 'arguments' is not technically a reserved word, but it's a special identifier within functions\n // and assigning to it or declaring it can cause issues or unexpected behavior.\n 'arguments',\n]);\n\n/**\n * Sanitizes a potential tag name (assumed to be already camelCased)\n * to avoid conflicts with reserved keywords or invalid starting characters (numbers).\n * Appends an underscore if the tag matches a reserved keyword.\n * Prepends an underscore if the tag starts with a number.\n * @param camelCasedTag The potential tag name, already camelCased.\n * @returns The sanitized tag name.\n */\nfunction sanitizeTag(camelCasedTag: string): string {\n // Prepend underscore if starts with a number\n if (/^\\d/.test(camelCasedTag)) {\n return `_${camelCasedTag}`;\n }\n // Append underscore if it's a reserved keyword\n return reservedKeywords.has(camelcase(camelCasedTag))\n ? `${camelCasedTag}_`\n : camelCasedTag;\n}\n\n/**\n * Attempts to determine a generic tag for an OpenAPI operation based on path and operationId.\n * Rules and fallbacks are documented within the code.\n * @param pathString The path string.\n * @param operation The OpenAPI Operation Object.\n * @returns A sanitized, camelCased tag name string.\n */\nexport function determineGenericTag(\n pathString: string,\n operation: OperationObject,\n): string {\n const operationId = operation.operationId || '';\n const VERSION_REGEX = /^[vV]\\d+$/;\n const commonVerbs = new Set([\n // Verbs to potentially strip from operationId prefix\n 'get',\n 'list',\n 'create',\n 'update',\n 'delete',\n 'post',\n 'put',\n 'patch',\n 'do',\n 'send',\n 'add',\n 'remove',\n 'set',\n 'find',\n 'search',\n 'check',\n 'make',\n ]);\n\n const segments = pathString.split('/').filter(Boolean);\n\n const potentialCandidates = segments.filter(\n (segment) =>\n segment &&\n !segment.startsWith('{') &&\n !segment.endsWith('}') &&\n !VERSION_REGEX.test(segment),\n );\n\n // --- Heuristic 1: Last non-'@' path segment ---\n for (let i = potentialCandidates.length - 1; i >= 0; i--) {\n const segment = potentialCandidates[i];\n if (!segment.startsWith('@')) {\n // Sanitize just before returning\n return sanitizeTag(camelcase(segment));\n }\n }\n\n const canFallbackToPathSegment = potentialCandidates.length > 0;\n\n // --- Heuristic 2: OperationId parsing ---\n if (operationId) {\n const lowerOpId = operationId.toLowerCase();\n const parts = operationId\n .replace(/([a-z])([A-Z])/g, '$1_$2')\n .replace(/([A-Z])([A-Z][a-z])/g, '$1_$2')\n .replace(/([a-zA-Z])(\\d)/g, '$1_$2')\n .replace(/(\\d)([a-zA-Z])/g, '$1_$2')\n .toLowerCase()\n .split(/[_-\\s]+/);\n\n const validParts = parts.filter(Boolean);\n\n // Quick skip: If opId is just a verb and we can use Heuristic 3, prefer that.\n if (\n commonVerbs.has(lowerOpId) &&\n validParts.length === 1 &&\n canFallbackToPathSegment\n ) {\n // Proceed directly to Heuristic 3\n }\n // Only process if there are valid parts and the quick skip didn't happen\n else if (validParts.length > 0) {\n const firstPart = validParts[0];\n const isFirstPartVerb = commonVerbs.has(firstPart);\n\n // Case 2a: Starts with verb, has following parts\n if (isFirstPartVerb && validParts.length > 1) {\n const verbPrefixLength = firstPart.length;\n let nextPartStartIndex = -1;\n if (operationId.length > verbPrefixLength) {\n // Simplified check for next part start\n const charAfterPrefix = operationId[verbPrefixLength];\n if (charAfterPrefix >= 'A' && charAfterPrefix <= 'Z') {\n nextPartStartIndex = verbPrefixLength;\n } else if (charAfterPrefix >= '0' && charAfterPrefix <= '9') {\n nextPartStartIndex = verbPrefixLength;\n } else if (['_', '-'].includes(charAfterPrefix)) {\n nextPartStartIndex = verbPrefixLength + 1;\n } else {\n const match = operationId\n .substring(verbPrefixLength)\n .match(/[A-Z0-9]/);\n if (match && match.index !== undefined) {\n nextPartStartIndex = verbPrefixLength + match.index;\n }\n if (\n nextPartStartIndex === -1 &&\n operationId.length > verbPrefixLength\n ) {\n nextPartStartIndex = verbPrefixLength; // Default guess\n }\n }\n }\n\n if (\n nextPartStartIndex !== -1 &&\n nextPartStartIndex < operationId.length\n ) {\n const remainingOriginalSubstring =\n operationId.substring(nextPartStartIndex);\n const potentialTag = camelcase(remainingOriginalSubstring);\n if (potentialTag) {\n // Sanitize just before returning\n return sanitizeTag(potentialTag);\n }\n }\n\n // Fallback: join remaining lowercased parts\n const potentialTagJoined = camelcase(validParts.slice(1).join('_'));\n if (potentialTagJoined) {\n // Sanitize just before returning\n return sanitizeTag(potentialTagJoined);\n }\n }\n\n // Case 2b: Doesn't start with verb, or only one part (might be verb)\n const potentialTagFull = camelcase(operationId);\n if (potentialTagFull) {\n const isResultSingleVerb = validParts.length === 1 && isFirstPartVerb;\n\n // Avoid returning only a verb if Heuristic 3 is possible\n if (!(isResultSingleVerb && canFallbackToPathSegment)) {\n if (potentialTagFull.length > 0) {\n // Sanitize just before returning\n return sanitizeTag(potentialTagFull);\n }\n }\n }\n\n // Case 2c: Further fallbacks within OpId if above failed/skipped\n const firstPartCamel = camelcase(firstPart);\n if (firstPartCamel) {\n const isFirstPartCamelVerb = commonVerbs.has(firstPartCamel);\n if (\n !isFirstPartCamelVerb ||\n validParts.length === 1 ||\n !canFallbackToPathSegment\n ) {\n // Sanitize just before returning\n return sanitizeTag(firstPartCamel);\n }\n }\n if (\n isFirstPartVerb &&\n validParts.length > 1 &&\n validParts[1] &&\n canFallbackToPathSegment\n ) {\n const secondPartCamel = camelcase(validParts[1]);\n if (secondPartCamel) {\n // Sanitize just before returning\n return sanitizeTag(secondPartCamel);\n }\n }\n } // End if(validParts.length > 0) after quick skip check\n } // End if(operationId)\n\n // --- Heuristic 3: First path segment (stripping '@') ---\n if (potentialCandidates.length > 0) {\n let firstCandidate = potentialCandidates[0];\n if (firstCandidate.startsWith('@')) {\n firstCandidate = firstCandidate.substring(1);\n }\n if (firstCandidate) {\n // Sanitize just before returning\n return sanitizeTag(camelcase(firstCandidate));\n }\n }\n\n // --- Heuristic 4: Default ---\n console.warn(\n `Could not determine a suitable tag for path: ${pathString}, operationId: ${operationId}. Using 'unknown'.`,\n );\n return 'unknown'; // 'unknown' is safe\n}\n\nexport function parseJsonContentType(contentType: string | null | undefined) {\n if (!contentType) {\n return null;\n }\n\n // 1. Trim whitespace\n let mainType = contentType.trim();\n\n // 2. Remove parameters (anything after the first ';')\n const semicolonIndex = mainType.indexOf(';');\n if (semicolonIndex !== -1) {\n mainType = mainType.substring(0, semicolonIndex).trim(); // Trim potential space before ';'\n }\n\n // 3. Convert to lowercase for case-insensitive comparison\n mainType = mainType.toLowerCase();\n\n if (mainType.endsWith('/json')) {\n return mainType.split('/')[1];\n } else if (mainType.endsWith('+json')) {\n return mainType.split('+')[1];\n }\n return null;\n}\n\n/**\n * Checks if a given content type string represents Server-Sent Events (SSE).\n * Handles case-insensitivity, parameters (like charset), and leading/trailing whitespace.\n *\n * @param contentType The content type string to check (e.g., from a Content-Type header).\n * @returns True if the content type is 'text/event-stream', false otherwise.\n */\nexport function isSseContentType(\n contentType: string | null | undefined,\n): boolean {\n if (!contentType) {\n return false; // Handle null, undefined, or empty string\n }\n\n // 1. Trim whitespace from the input string\n let mainType = contentType.trim();\n\n // 2. Find the position of the first semicolon (if any) to remove parameters\n const semicolonIndex = mainType.indexOf(';');\n if (semicolonIndex !== -1) {\n // Extract the part before the semicolon and trim potential space\n mainType = mainType.substring(0, semicolonIndex).trim();\n }\n\n // 3. Convert the main type part to lowercase for case-insensitive comparison\n mainType = mainType.toLowerCase();\n\n // 4. Compare against the standard SSE MIME type\n return mainType === 'text/event-stream';\n}\n\nexport function isStreamingContentType(\n contentType: string | null | undefined,\n): boolean {\n return contentType === 'application/octet-stream';\n}\n\nexport function isSuccessStatusCode(statusCode: number | string): boolean {\n statusCode = Number(statusCode);\n return statusCode >= 200 && statusCode < 300;\n}\n", "import { merge } from 'lodash-es';\nimport assert from 'node:assert';\nimport type {\n OpenAPIObject,\n ReferenceObject,\n SchemaObject,\n} from 'openapi3-ts/oas31';\nimport { camelcase, snakecase } from 'stringcase';\n\nimport {\n cleanRef,\n followRef,\n isEmpty,\n isRef,\n notRef,\n parseRef,\n pascalcase,\n} from '@sdk-it/core';\n\nconst formatName = (it: any): string => {\n const startsWithDigitPattern = /^-?\\d/;\n // 1. Handle numbers\n if (typeof it === 'number') {\n if (Math.sign(it) === -1) {\n return `$_${Math.abs(it)}`;\n }\n return `$${it}`;\n }\n\n // 2. Handle the specific string 'default'\n if (it === 'default') {\n return '$default';\n }\n\n // 3. Handle other strings\n if (typeof it === 'string') {\n // 3a. Check if the string starts with a digit FIRST\n if (startsWithDigitPattern.test(it)) {\n if (typeof it === 'number') {\n if (Math.sign(it) === -1) {\n return `$_${Math.abs(it)}`;\n }\n return `$${it}`;\n }\n }\n\n // 3b. If not starting with a digit, handle brackets and snake_case\n let nameToFormat = it;\n\n // Remove a single leading '[' if present\n if (nameToFormat.startsWith('[')) {\n nameToFormat = nameToFormat.slice(1);\n }\n\n // Remove a single trailing ']' if present\n if (nameToFormat.endsWith(']')) {\n nameToFormat = nameToFormat.slice(0, -1);\n }\n\n // Apply snakecase to the (potentially modified) string\n return snakecase(nameToFormat);\n }\n\n // 4. Fallback for any other types (e.g., null, undefined, objects)\n // Convert to string first, then apply snakecase\n return snakecase(String(it));\n};\n\ntype Context = Record<string, any>;\ntype Serialized = {\n nullable?: boolean;\n encode?: string;\n use: string;\n toJson: string;\n matches?: string;\n fromJson: string;\n type?: string;\n content: string;\n simple?: boolean;\n};\ntype Emit = (name: string, content: string) => void;\n/**\n * Convert an OpenAPI (JSON Schema style) object into Dart classes\n */\nexport class DartSerializer {\n #spec: OpenAPIObject;\n #emit: Emit;\n\n constructor(spec: OpenAPIObject, emit: Emit) {\n this.#spec = spec;\n this.#emit = emit;\n }\n\n #getRefUsage(schemaName: string, list: string[] = []): string[] {\n this.#spec.components ??= {};\n this.#spec.components.schemas ??= {};\n this.#spec.components.responses ??= {};\n\n const checkSchema = (schema: SchemaObject | ReferenceObject): boolean => {\n if (isRef(schema)) {\n const { model } = parseRef(schema.$ref);\n return model === schemaName;\n }\n if (schema.oneOf && Array.isArray(schema.oneOf)) {\n return (schema.oneOf as Array<SchemaObject | ReferenceObject>).some(\n (subSchema) => checkSchema(subSchema),\n );\n }\n if (\n schema.type === 'array' &&\n schema.items &&\n notRef(schema.items) &&\n schema.items.oneOf\n ) {\n return checkSchema(schema.items);\n }\n return false;\n };\n\n for (const [key, value] of Object.entries(this.#spec.components.schemas)) {\n if (checkSchema(value)) {\n list.push(key);\n }\n }\n\n return list;\n }\n\n #object(\n className: string,\n schema: SchemaObject,\n context: Context,\n ): Serialized {\n if (schema.additionalProperties) {\n this.#emit(className, `typedef ${className} = Map<String, dynamic>;`);\n return {\n content: '',\n use: 'Map<String, dynamic>',\n encode: 'input',\n toJson: `this.${camelcase(context.name)}`,\n fromJson: `json['${camelcase(context.name)}']`,\n matches: `json['${camelcase(context.name)}'] is Map<String, dynamic>`,\n };\n }\n if (isEmpty(schema.properties)) {\n if (context.noEmit !== true) {\n this.#emit(\n className,\n `class ${className} {\n const ${className}(); // Add const constructor\n\n factory ${className}.fromJson(Map<String, dynamic> json) {\n return const ${className}();\n }\n\n Map<String, dynamic> toJson() => {};\n\n /// Determines if a given map can be parsed into an instance of this class.\n /// Returns true for any map since this class has no properties.\n static bool matches(Map<String, dynamic> json) {\n return true; // Any map is fine for an empty object\n }\n}`,\n );\n }\n return {\n content: '',\n encode: 'input.toJson()',\n use: className,\n toJson: `${this.#safe(context.name as string, context.required)}`,\n fromJson: `${className}.fromJson(json['${context.name}'])`,\n matches: `${className}.matches(json['${context.name}'])`,\n };\n }\n\n const props: string[] = [];\n const toJsonProperties: string[] = [];\n const constructorParams: string[] = [];\n const fromJsonParams: string[] = [];\n const matches: string[] = [];\n\n for (const [key, propSchema] of Object.entries(schema.properties)) {\n const propName = key.replace('[]', '');\n const required = (schema.required ?? []).includes(key);\n const typeStr = this.handle(className, propSchema, required, {\n name: propName,\n required,\n propName: [className, propName].filter(Boolean).join('_'),\n });\n const nullable = typeStr.nullable || !required;\n const nullableSuffix = nullable ? '?' : '';\n props.push(\n `final ${typeStr.use}${nullableSuffix} ${camelcase(propName)};`,\n );\n fromJsonParams.push(`${camelcase(propName)}: ${typeStr.fromJson}`);\n toJsonProperties.push(`'${propName}': ${typeStr.toJson}`);\n constructorParams.push(\n `${required ? 'required ' : ''}this.${camelcase(propName)},`,\n );\n if (required) {\n matches.push(`(\n json.containsKey('${camelcase(propName)}')\n ? ${nullable ? `json['${propName}'] == null` : `json['${propName}'] != null`} ${typeStr.matches ? `&& ${typeStr.matches}` : ''}\n : false)`);\n } else {\n matches.push(`(\n json.containsKey('${camelcase(propName)}')\n ? ${nullable ? `json['${propName}'] == null` : `json['${propName}'] != null`} ${typeStr.matches ? `|| ${typeStr.matches}` : ''}\n : true)`);\n }\n }\n\n const { mixins, withMixins } = this.#mixinise(className, context);\n const content = `class ${className} ${withMixins} {\n ${props.join('\\n')}\n ${!mixins.length ? 'const' : ''} ${className}({\n ${constructorParams.join('\\n')}})${mixins.length > 1 ? '' : `:super()`};\n factory ${className}.fromJson(Map<String, dynamic> json) {\nreturn ${className}(\\n${fromJsonParams.join(',\\n')});\n }\n Map<String, dynamic> toJson() => {\n${toJsonProperties.join(',\\n')}\n };\n static bool matches(Map<String, dynamic> json) {\nreturn ${matches.join(' && ')};\n }\n }`;\n if (context.noEmit !== true) {\n this.#emit(className, content);\n }\n const nullable = !context.required || context.nullable === true;\n return {\n use: className,\n content,\n encode: 'input.toJson()',\n toJson: `${this.#safe(context.name, context.required)}`,\n fromJson: context.name\n ? `${context.forJson || className}.fromJson(json['${context.name}'])`\n : `${context.forJson || className}.fromJson(json)`,\n matches: `${className}.matches(json['${context.name}'])`,\n };\n }\n\n #safe(accces: string, required: boolean) {\n return required\n ? `this.${camelcase(accces)}.toJson()`\n : `this.${camelcase(accces)} != null ? this.${camelcase(accces)}!.toJson() : null`;\n }\n\n #array(\n className: string,\n schema: SchemaObject,\n required = false,\n context: Context,\n ): Serialized {\n if (!schema.items) {\n return {\n content: '',\n use: 'List<dynamic>',\n toJson: '',\n fromJson: `List<dynamic>.from(${context.name ? `json['${context.name}']` : `json`})})`,\n matches: '',\n };\n }\n const itemsType = this.handle(className, schema.items, true, context);\n const fromJson = required\n ? context.name\n ? `(json['${context.name}'] as List<${itemsType.simple ? itemsType.use : 'dynamic'}>)\n .map((it) => ${itemsType.simple ? 'it' : `${itemsType.use}.fromJson(it)`})\n .toList()`\n : `(json as List<${itemsType.simple ? itemsType.use : 'dynamic'}>)\n .map((it) => ${itemsType.simple ? 'it' : `${itemsType.use}.fromJson(it)`})\n .toList()`\n : context.name\n ? `json['${context.name}'] != null\n ? (json['${context.name}'] as List<${itemsType.simple ? itemsType.use : 'dynamic'}>)\n .map((it) => ${itemsType.simple ? 'it' : `${itemsType.use}.fromJson(it)`})\n .toList()\n : null`\n : `json != null\n ? (json as List<${itemsType.simple ? itemsType.use : 'dynamic'}>)\n .map((it) => ${itemsType.simple ? 'it' : `${itemsType.use}.fromJson(it)`})\n .toList()\n : null`;\n\n return {\n encode: `input.map((it) => ${itemsType.simple ? 'it' : `it.toJson()`}).toList()`,\n content: '',\n use: `List<${itemsType.use}>`,\n fromJson,\n toJson: `${context.required ? `this.${camelcase(context.name)}${itemsType.simple ? '' : '.map((it) => it.toJson()).toList()'}` : `this.${camelcase(context.name)}!= null? this.${camelcase(context.name)}${itemsType.simple ? '' : '!.map((it) => it.toJson()).toList()'} : null`}`,\n matches: `json['${camelcase(context.name)}'].every((it) => ${itemsType.matches})`,\n };\n }\n\n /**\n * Convert a basic type to Dart\n */\n #primitive(\n className: string,\n type: string,\n schema: SchemaObject,\n context: Record<string, unknown>,\n required = false,\n ): Serialized {\n switch (type) {\n case 'string':\n return this.#string(schema, context);\n case 'number':\n case 'integer':\n return this.number(schema, context);\n case 'boolean':\n return {\n content: '',\n use: 'bool',\n toJson: `${camelcase(context.name as string)}`,\n fromJson: `json['${context.name}']`,\n matches: `json['${context.name}'] is bool`,\n };\n case 'object':\n return this.#object(className, schema, context);\n case 'array':\n return this.#array(className, schema, required, context);\n case 'null':\n return {\n content: '',\n use: 'Null',\n toJson: `${camelcase(context.name as string)}`,\n fromJson: `json['${context.name}']`,\n };\n default:\n // Unknown type -> fallback\n return {\n content: '',\n use: 'dynamic',\n nullable: false,\n toJson: `${camelcase(context.name as string)}`,\n fromJson: `json['${context.name}']`,\n };\n }\n }\n\n #ref(\n className: string,\n $ref: string,\n required: boolean,\n context: Context,\n ): Serialized {\n const schemaName = cleanRef($ref).split('/').pop()!;\n\n const serialized = this.handle(\n schemaName,\n followRef<SchemaObject>(this.#spec, $ref),\n required,\n {\n ...context,\n propName: schemaName,\n noEmit: !!context.alias || !!className || !context.forceEmit,\n },\n );\n return serialized;\n }\n\n // fixme: this method should no longer be needed because the logic in it is being preprocessed before emitting begins\n #allOf(\n className: string,\n schemas: (SchemaObject | ReferenceObject)[],\n context: Context,\n ): Serialized {\n const name = pascalcase(context.propName || className); // className in case is top level\n\n const refs = schemas.filter(isRef);\n const nonRefs = schemas.filter(notRef);\n if (nonRefs.some((it) => it.type && it.type !== 'object')) {\n assert(false, `allOf ${name} must be an object`);\n }\n const objectSchema = merge(\n {},\n ...nonRefs,\n ...refs.map((ref) => followRef(this.#spec, ref.$ref)),\n );\n delete objectSchema.allOf;\n return this.handle(name, objectSchema, true, context);\n }\n\n #anyOf(\n className: string,\n schemas: (SchemaObject | ReferenceObject)[],\n context: Record<string, unknown>,\n ): Serialized {\n // fixme: handle\n if (schemas.length === 0) {\n return {\n content: '',\n nullable: false,\n use: 'dynamic',\n toJson: `${camelcase(context.name as string)}`,\n fromJson: `json['${context.name}']`,\n };\n }\n const nullSchemaIndex = schemas.findIndex((schema) => {\n if (isRef(schema)) {\n const refSchema = followRef(this.#spec, schema.$ref);\n return refSchema.type === 'null';\n }\n return schema.type === 'null';\n });\n const anyOfSchemas = schemas.slice(0);\n if (nullSchemaIndex >= 0) {\n anyOfSchemas.splice(nullSchemaIndex, 1); // remove null schema\n }\n\n return this.handle(className, anyOfSchemas[0], true, {\n ...context,\n nullable: nullSchemaIndex >= 0,\n });\n }\n\n #mixinise(name: string, context: Context) {\n const mixins = this.#getRefUsage(name);\n if (context.mixin) {\n mixins.unshift(context.mixin);\n }\n const withMixins =\n mixins.length > 1\n ? ` with ${mixins.join(', ')}`\n : mixins.length === 1\n ? `extends ${mixins[0]}`\n : '';\n return {\n withMixins,\n mixins,\n };\n }\n\n #oneOf(\n className: string,\n schemas: (SchemaObject | ReferenceObject)[],\n context: Context,\n ): Serialized {\n const name = pascalcase(context.propName || className); // className in case is top level\n\n if (schemas.length === 0) {\n return {\n content: '',\n nullable: false,\n use: 'dynamic',\n toJson: `${camelcase(context.name as string)}`,\n fromJson: `json['${context.name}']`,\n };\n }\n const content: string[] = [];\n const patterns: { pattern: string; name: string }[] = [];\n // FIXME: if there is just one type then no need to add the discriminator\n const objects = schemas.filter(notRef).filter((it) => it.type === 'object');\n for (const schema of schemas) {\n if (isRef(schema)) {\n const refType = this.#ref(className, schema.$ref, true, context);\n patterns.push({\n pattern: `case ${refType.type || 'Map<String, dynamic>'} map when ${refType.use}.matches(map): return ${refType.use}.fromJson(map);`,\n name: refType.use,\n });\n } else if (schema.type === 'string') {\n // todo: make this into a schema with ref (preproccesing)\n content.push(`class ${name}Text with ${name} {\n final String value;\n ${name}Text(this.value);\n @override\n dynamic toJson() => value;\n static bool matches(dynamic value) {\n return value is String;\n }}\n `);\n patterns.push({\n pattern: `case String(): return ${name}Text(json);`,\n name: `${name}Text`,\n });\n } else if (schema.type === 'array') {\n // todo: make this into a schema with ref (preproccesing) with all varients types (integer, string)\n // todo: this can be abstracted so the varients somehow dynamic without having to replicate the same classes all the time\n const itemsType = this.handle(name, schema.items!, true, {\n ...context,\n noEmit: true,\n });\n content.push(`class ${name}List with ${name} {\n final List<${itemsType.use}> value;\n ${name}List(this.value);\n @override\n dynamic toJson() => value;\n static bool matches(dynamic value) {\n return value is List;\n }}`);\n patterns.push({\n pattern: `case List(): return ${name}List(List<${itemsType.use}>.from(json));`,\n name: `${name}List`,\n });\n }\n }\n if (objects.length) {\n // todo: take a look at CompoundFilterFilters at the end\n const candidates: Record<string, Set<string>> = {};\n for (const schema of objects) {\n if (schema.additionalProperties === true) {\n continue;\n }\n assert(\n schema.properties,\n `Schema ${name} has no properties which are required in oneOf in order to determine the discriminator.`,\n );\n for (const [propName, propSchema] of Object.entries(\n schema.properties,\n )) {\n if (\n notRef(propSchema) &&\n propSchema.enum &&\n // fixme: the enum can have more than one value as long as it is not duplicated else where on the other schemas\n propSchema.enum.length === 1\n ) {\n candidates[propName] ??= new Set();\n candidates[propName].add(String(propSchema.enum[0]));\n }\n }\n }\n\n let discriminatorProp: string | undefined;\n\n for (const [name, values] of Object.entries(candidates)) {\n if (\n // make sure we pick the prop that exists on all objects\n values.size === objects.filter((it) => it.properties?.[name]).length\n ) {\n discriminatorProp = name;\n break;\n }\n }\n\n // if (objects.filter((it) => it.additionalProperties !== true).length) {\n // }\n // assert(discriminatorProp, `No discriminator property found in ${name}`);\n\n if (discriminatorProp) {\n for (const schema of objects) {\n const discriminatorValue: string = (\n (schema as SchemaObject).properties![\n discriminatorProp!\n ] as SchemaObject\n ).enum?.[0];\n\n const varientName = `${name}${pascalcase(discriminatorValue)}`;\n patterns.push({\n pattern: `case Map<String, dynamic> map when ${varientName}.matches(json): return ${varientName}.fromJson(map);`,\n name: varientName,\n });\n\n const objResult = this.#object(varientName, schema, {\n ...context,\n noEmit: true,\n mixin: name,\n });\n content.push(objResult.content);\n }\n }\n }\n\n const { mixins, withMixins } = this.#mixinise(name, context);\n content.unshift(`abstract ${mixins.length ? '' : 'mixin'} class ${name} ${withMixins} {\n dynamic toJson();\n ${\n patterns.length\n ? `static ${name} fromJson(dynamic json) {\n switch (json){\n ${patterns.map((it) => it.pattern).join('\\n')}\n default:\n throw ArgumentError(\"Invalid type for query property: \\${json}\");\n }\n }\n\n\n ${\n patterns.length\n ? ` static bool matches(dynamic value) {\n return ${patterns.map((it) => `value is ${it.name}`).join(' || ')};\n }`\n : ''\n }\n\n `\n : ''\n }\n }`);\n this.#emit(name, content.join('\\n'));\n\n return {\n content: content.join('\\n'),\n use: name,\n toJson: `${this.#safe(context.name as string, context.required)}`,\n fromJson: `${name}.fromJson(json['${context.name}'])`,\n matches: `${name}.matches(json['${context.name}'])`,\n };\n }\n\n #simple(type: string) {\n switch (type) {\n case 'string':\n return 'String';\n case 'number':\n return 'double';\n case 'integer':\n return 'int';\n case 'boolean':\n return 'bool';\n default:\n return 'dynamic';\n }\n }\n\n #enum(className: string, schema: SchemaObject, context: Context): Serialized {\n const name = context.propName || className; // className in case enum is top level\n const values = schema.enum as string[];\n const valType = this.#simple((schema.type as string) || 'string');\n // fixme: if enum have one value and cannot be null then use it as default value\n\n const { mixins, withMixins } = this.#mixinise(className, context);\n\n const content = `\n class _EnumValue implements ${pascalcase(name)} {\n final ${valType} value;\n const _EnumValue(this.value);\n @override\n toJson() {return this.value;}\n}\n abstract ${mixins.length ? '' : 'mixin'} class ${pascalcase(name)} ${withMixins} {\n ${values.map((it) => `static const _EnumValue ${formatName(it)} = _EnumValue(${typeof it === 'number' ? it : `'${it}'`});`).join('\\n')}\n dynamic toJson();\n\n ${valType} get value;\n\n static _EnumValue fromJson(${valType} value) {\n switch (value) {\n${values\n .map(\n (it) =>\n `case ${typeof it === 'number' ? it : `'${it}'`}: return ${formatName(it)};`,\n )\n .join('\\n')}\ndefault:\n throw ArgumentError.value(value, \"value\", \"No enum value with that name\");\n }\n }\n\n static bool matches(${valType} value) {\n try {\nfromJson(value);\nreturn true;\n } catch (error) {\nreturn false;\n }\n }\n\n }`;\n if (context.noEmit !== true) {\n this.#emit(name, content);\n }\n return {\n type: Array.isArray(schema.type)\n ? this.#simple(schema.type[0])\n : schema.type\n ? this.#simple(schema.type)\n : undefined,\n content: content,\n use: pascalcase(name),\n toJson: `${context.required ? `this.${camelcase(context.name)}.toJson()` : `this.${camelcase(context.name)} != null ? this.${camelcase(context.name)}!.toJson() : null`}`,\n fromJson: `${pascalcase(name)}.fromJson(json['${context.name}'])`,\n matches: `${pascalcase(name)}.matches(json['${context.name}'])`,\n };\n }\n\n /**\n * Handle string type with formats\n */\n #string(schema: SchemaObject, context: Context): Serialized {\n switch (schema.format) {\n case 'date-time':\n case 'datetime':\n case 'date':\n return {\n content: '',\n use: 'DateTime',\n simple: true,\n toJson: context.required\n ? `this.${camelcase(context.name)}.toIso8601String()`\n : `this.${camelcase(context.name)} != null ? this.${camelcase(\n context.name,\n )}!.toIso8601String() : null`,\n fromJson: context.name\n ? `json['${context.name}'] != null ? DateTime.parse(json['${context.name}']) : null`\n : 'json',\n matches: `json['${context.name}'] is String`,\n };\n case 'binary':\n case 'byte':\n return {\n content: '',\n use: 'File',\n toJson: `this.${camelcase(context.name)}`,\n simple: true,\n fromJson: context.name ? `json['${context.name}']` : 'json',\n matches: `json['${context.name}'] is Uint8List`,\n };\n default:\n return {\n encode: 'input',\n use: `String`,\n content: '',\n simple: true,\n toJson: `this.${camelcase(context.name)}`,\n fromJson: context.name ? `json['${context.name}'] as String` : 'json',\n matches: `json['${context.name}'] is String`,\n };\n }\n }\n\n /**\n * Handle number/integer types with formats\n */\n number(schema: SchemaObject, context: Context): Serialized {\n if (schema.type === 'integer') {\n return {\n content: '',\n use: 'int',\n simple: true,\n toJson: `this.${camelcase(context.name)}`,\n fromJson: `json['${context.name}']`,\n matches: `json['${context.name}'] is int`,\n };\n }\n if (['float', 'double'].includes(schema.format as string)) {\n return {\n content: '',\n use: 'double',\n simple: true,\n toJson: `this.${camelcase(context.name)}`,\n fromJson: `json['${context.name}']`,\n matches: `json['${context.name}'] is double`,\n };\n }\n return {\n content: '',\n use: 'num',\n simple: true,\n toJson: `this.${camelcase(context.name)}`,\n fromJson: `json['${context.name}']`,\n matches: `json['${context.name}'] is double`,\n };\n }\n\n #serialize(\n className: string,\n schema: SchemaObject | ReferenceObject,\n required = true,\n context: Context = {},\n ): Serialized {\n if (isRef(schema)) {\n return this.#ref(className, schema.$ref, required, context);\n }\n // some schemas have decalres allof, oneof, anyOf at once or combinations of them\n // so we need to process them in order\n if (schema.allOf && Array.isArray(schema.allOf)) {\n return this.#allOf(className, schema.allOf, context);\n }\n if (schema.oneOf && Array.isArray(schema.oneOf)) {\n return this.#oneOf(className, schema.oneOf, context);\n }\n if (schema.anyOf && Array.isArray(schema.anyOf)) {\n return this.#anyOf(className, schema.anyOf, context);\n }\n if (schema.enum && Array.isArray(schema.enum)) {\n return this.#enum(className, schema, context);\n }\n // Handle types\n const types = Array.isArray(schema.type)\n ? schema.type\n : schema.type\n ? [schema.type]\n : [];\n\n let nullable = false;\n if ('nullable' in schema && schema.nullable) {\n nullable = true;\n } else if (schema.default === null) {\n nullable = true;\n } else if (types.includes('null')) {\n nullable = true;\n }\n\n // If no explicit \"type\", fallback to dynamic\n if (!types.length) {\n // unless properties are defined then assume object\n if ('properties' in schema) {\n return this.#object(className, schema, context);\n }\n if ('items' in schema) {\n return this.#array(className, schema, true, context);\n }\n return {\n content: '',\n use: 'dynamic',\n toJson: `${camelcase(context.name as string)}`,\n fromJson: `json['${context.name}']`,\n nullable: false,\n matches: '', // keep it empty as 'type is dynamic' is always true\n };\n }\n return this.#primitive(\n className,\n types[0],\n schema,\n { ...context, nullable },\n required,\n );\n }\n\n handle(\n className: string,\n schema: SchemaObject | ReferenceObject,\n required = true,\n context: Context = {},\n ): Serialized {\n const alias = context.alias;\n context.alias = undefined;\n const serialized = this.#serialize(className, schema, required, {\n ...context,\n forJson: alias,\n });\n\n if (alias) {\n this.#emit(className, `typedef ${alias} = ${serialized.use};`);\n return serialized;\n }\n return serialized;\n }\n}\n\nexport function isObjectSchema(\n schema: SchemaObject | ReferenceObject,\n): schema is SchemaObject {\n return !isRef(schema) && (schema.type === 'object' || !!schema.properties);\n}\n", "import 'dart:convert';\nimport 'dart:io';\n\nimport 'package:http/http.dart' as http;\nimport 'package:http_parser/http_parser.dart';\nimport 'package:mime/mime.dart' as mime;\n\nimport './interceptors.dart';\nimport './responses.dart';\n\nclass Dispatcher {\n final List<Interceptor> interceptors;\n\n Dispatcher(this.interceptors);\n\n Future<http.StreamedResponse> multipart(\n RequestConfig config,\n Map<String, dynamic> body,\n ) async {\n final modifiedConfig = interceptors.fold(\n config,\n (acc, interceptor) => interceptor.before(acc),\n );\n final request = http.MultipartRequest(\n modifiedConfig.method,\n modifiedConfig.url,\n );\n request.headers.addAll(modifiedConfig.headers);\n for (var entry in body.entries) {\n final key = entry.key;\n final value = entry.value;\n if (value is File) {\n final mimeType = mime.lookupMimeType(value.path);\n request.files.add(\n http.MultipartFile(\n key,\n value.openRead(),\n await value.length(),\n filename: value.uri.pathSegments.last,\n contentType: mimeType != null ? MediaType.parse(mimeType) : null,\n ),\n );\n } else {\n request.fields[key] = value.toString();\n }\n }\n\n return request.send();\n }\n\n Future<http.StreamedResponse> empty(RequestConfig config) {\n final modifiedConfig = interceptors.fold(\n config,\n (acc, interceptor) => interceptor.before(acc),\n );\n final request = http.Request(modifiedConfig.method, modifiedConfig.url);\n request.headers.addAll(modifiedConfig.headers);\n return request.send();\n }\n\n Future<http.StreamedResponse> json(RequestConfig config, dynamic body) {\n final modifiedConfig = interceptors.fold(\n config,\n (acc, interceptor) => interceptor.before(acc),\n );\n final request = http.Request(modifiedConfig.method, modifiedConfig.url);\n request.headers.addAll(modifiedConfig.headers);\n\n request.headers['Content-Type'] = 'application/json';\n if ((body is Map || body is List)) {\n request.body = jsonEncode(body);\n } else if (body is String) {\n request.body = body;\n } else {\n throw ArgumentError('Unsupported body type: ${body.runtimeType}');\n }\n\n return request.send();\n }\n}\n\nclass Receiver {\n final List<Interceptor> interceptors;\n Receiver(this.interceptors);\n\n dynamic _parse(http.Response response) {\n final contentTypeHeader = response.headers['content-type'];\n final parsed = parseContentType(contentTypeHeader);\n if (parsed.type == 'application/json') {\n return jsonDecode(response.body);\n } else if (parsed.type == 'text/plain') {\n return response.body;\n } else if (parsed.type == 'application/octet-stream') {\n return response.bodyBytes;\n } else {\n throw UnsupportedError('Unsupported content type: ${parsed.type}');\n }\n }\n\n dynamic json(http.StreamedResponse stream) async {\n if (stream.statusCode >= 200 && stream.statusCode < 300) {\n final response = await http.Response.fromStream(stream);\n return _parse(response);\n }\n switch (stream.statusCode) {\n case 400:\n throw BadRequestError('');\n case 401:\n throw UnauthorizedError('');\n case 403:\n throw ForbiddenError('');\n case 404:\n throw NotFoundError('');\n case 500:\n throw InternalServerError('');\n case 402:\n throw PaymentRequiredError('');\n case 405:\n throw MethodNotAllowedError('');\n case 406:\n throw NotAcceptableError('');\n case 409:\n throw ConflictError('');\n case 410:\n throw GoneError('');\n case 422:\n throw UnprocessableEntityError('');\n case 429:\n throw TooManyRequestsError('');\n case 413:\n throw PayloadTooLargeError('');\n case 415:\n throw UnsupportedMediaTypeError('');\n case 501:\n throw NotImplementedError('');\n case 502:\n throw BadGatewayError('');\n case 503:\n throw ServiceUnavailableError('');\n case 504:\n throw GatewayTimeoutError('');\n default:\n throw UnknownApiError('', stream.statusCode);\n }\n }\n}\n\n({String type, Map<String, String> parameters}) parseContentType(\n String? contentTypeHeader,\n) {\n if (contentTypeHeader == null || contentTypeHeader.isEmpty) {\n return (type: '', parameters: {});\n }\n final parts = contentTypeHeader.split(';');\n final type = parts[0].trim();\n final parameters = <String, String>{};\n for (var i = 1; i < parts.length; i++) {\n final param = parts[i].split('=');\n if (param.length == 2) {\n parameters[param[0].trim()] = param[1].trim();\n }\n }\n\n return (type: type, parameters: parameters);\n}\n", "abstract class Interceptor {\n RequestConfig before(RequestConfig config);\n void after();\n}\n\nclass BaseUrlInterceptor extends Interceptor {\n final String Function() getBaseUrl;\n BaseUrlInterceptor(this.getBaseUrl);\n\n @override\n RequestConfig before(RequestConfig config) {\n final baseUrl = getBaseUrl();\n if (config.url.scheme.isEmpty) {\n config.url = Uri.parse(baseUrl + config.url.toString());\n }\n return config;\n }\n\n @override\n void after() {\n //\n }\n}\n\nclass RequestConfig {\n final String method;\n Uri url;\n final Map<String, String> headers;\n RequestConfig({required this.method, required this.url, required this.headers});\n}\n", "sealed class ApiError {\n final String message;\n final int? statusCode;\n final String status;\n const ApiError(this.message, {this.statusCode, this.status = ''});\n\n @override\n String toString() =>\n 'ApiError(status: $status, statusCode: $statusCode, message: $message)';\n}\n\nbase class BadRequestError extends ApiError {\n const BadRequestError(String message)\n : super(message, statusCode: 400, status: 'BadRequest');\n}\n\nbase class UnauthorizedError extends ApiError {\n const UnauthorizedError(String message)\n : super(message, statusCode: 401, status: 'Unauthorized');\n}\n\nbase class ForbiddenError extends ApiError {\n const ForbiddenError(String message)\n : super(message, statusCode: 403, status: 'Forbidden');\n}\n\nbase class NotFoundError extends ApiError {\n const NotFoundError(String message)\n : super(message, statusCode: 404, status: 'NotFound');\n}\n\nbase class InternalServerError extends ApiError {\n const InternalServerError(String message)\n : super(message, statusCode: 500, status: 'InternalServerError');\n}\n\nbase class UnknownApiError extends ApiError {\n const UnknownApiError(String message, int statusCode)\n : super(message, statusCode: statusCode, status: 'UnknownApiError');\n}\n\nbase class PaymentRequiredError extends ApiError {\n const PaymentRequiredError(String message)\n : super(message, statusCode: 402, status: 'PaymentRequired');\n}\n\nbase class MethodNotAllowedError extends ApiError {\n const MethodNotAllowedError(String message)\n : super(message, statusCode: 405, status: 'MethodNotAllowed');\n}\n\nbase class NotAcceptableError extends ApiError {\n const NotAcceptableError(String message)\n : super(message, statusCode: 406, status: 'NotAcceptable');\n}\n\nbase class ConflictError extends ApiError {\n const ConflictError(String message)\n : super(message, statusCode: 409, status: 'Conflict');\n}\n\nbase class GoneError extends ApiError {\n const GoneError(String message)\n : super(message, statusCode: 410, status: 'Gone');\n}\n\nbase class UnprocessableEntityError extends ApiError {\n const UnprocessableEntityError(String message)\n : super(message, statusCode: 422, status: 'UnprocessableEntity');\n}\n\nbase class TooManyRequestsError extends ApiError {\n const TooManyRequestsError(String message)\n : super(message, statusCode: 429, status: 'TooManyRequests');\n}\n\nbase class PayloadTooLargeError extends ApiError {\n const PayloadTooLargeError(String message)\n : super(message, statusCode: 413, status: 'PayloadTooLarge');\n}\n\nbase class UnsupportedMediaTypeError extends ApiError {\n const UnsupportedMediaTypeError(String message)\n : super(message, statusCode: 415, status: 'UnsupportedMediaType');\n}\n\nbase class NotImplementedError extends ApiError {\n const NotImplementedError(String message)\n : super(message, statusCode: 501, status: 'NotImplemented');\n}\n\nbase class BadGatewayError extends ApiError {\n const BadGatewayError(String message)\n : super(message, statusCode: 502, status: 'BadGateway');\n}\n\nbase class ServiceUnavailableError extends ApiError {\n const ServiceUnavailableError(String message)\n : super(message, statusCode: 503, status: 'ServiceUnavailable');\n}\n\nbase class GatewayTimeoutError extends ApiError {\n const GatewayTimeoutError(String message)\n : super(message, statusCode: 504, status: 'GatewayTimeout');\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,SAAS,uBAAuB;AACzC,SAAS,SAAAA,cAAa;AACtB,OAAOC,aAAY;AACnB,SAAS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ACF;AAEA,SAAO,EAAE,QAAQ,WAAW,aAAa,OAAO;AAClD;AAEA,SAAS,SAAS,MAAqB,WAA4B;AACjE,QAAM,aAAaC,YAAW,GAAG,UAAU,WAAW,SAAS;AAC/D,YAAU,cAAc,CAAC;AACzB,QAAM,UAAkC,CAAC;AACzC,aAAW,UAAU,UAAU,WAAW;AACxC,UAAM,WAAWR,OAAM,UAAU,UAAU,MAAM,CAAoB,IACjEO,WAA0B,MAAM,UAAU,UAAU,MAAM,EAAE,IAAI,IAC/D,UAAU,UAAU,MAAM;AAC/B,eAAW,QAAQ,SAAS,SAAS;AACnC,YAAM,EAAE,OAAO,IAAI,SAAS,QAAQ,IAAI;AACxC,UAAI,CAAC,QAAQ;AACX,gBAAQ;AAAA,UACN,wBAAwB,IAAI,OAAO,UAAU,WAAW;AAAA,QAC1D;AACA;AAAA,MACF;AACA,YAAM,aAAa,IAAI,eAAe,MAAM,CAAC,MAAM,YAAY;AAAA,MAG/D,CAAC;AACD,UAAI,uBAAuB,IAAI,GAAG;AAChC,eAAO;AAAA,UACL,MAAM;AAAA,UACN;AAAA,UACA;AAAA,UACA,QAAQ;AAAA,UACR,YAAY;AAAA,QACd;AAAA,MACF;AACA,UAAI,qBAAqB,IAAI,GAAG;AAC9B,cAAM,aAAa,WAAW,OAAO,YAAY,QAAQ,MAAM;AAAA;AAAA,UAE7D,QAAQ;AAAA,QACV,CAAC;AACD,eAAO;AAAA,UACL,MAAM;AAAA,UACN;AAAA,UACA;AAAA,UACA,QAAQ,yDAAyD,WAAW,QAAQ;AAAA,UACpF,YAAY,WAAW;AAAA,QACzB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;",
|
|
6
|
+
"names": ["merge", "assert", "camelcase", "followRef", "isEmpty", "isRef", "notRef", "pascalcase", "snakecase", "parse", "camelcase", "followRef", "isRef", "nullable", "name", "isRef", "isEmpty", "schemas", "refs", "notRef", "assert", "merge", "followRef", "pascalcase", "value", "response", "camelcase", "name", "snakecase"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/lib/generate.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,aAAa,EAMd,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/lib/generate.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,aAAa,EAMd,MAAM,mBAAmB,CAAC;AA4G3B,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,aAAa,EACnB,QAAQ,EAAE;IACR,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpE,iBAwNF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sdk-it/dart",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"openapi3-ts": "4.4.0",
|
|
25
|
-
"@sdk-it/core": "0.
|
|
25
|
+
"@sdk-it/core": "0.20.0",
|
|
26
26
|
"lodash-es": "^4.17.21",
|
|
27
27
|
"stringcase": "^4.3.1",
|
|
28
|
-
"@sdk-it/spec": "0.
|
|
28
|
+
"@sdk-it/spec": "0.20.0",
|
|
29
29
|
"fast-content-type-parse": "^3.0.0",
|
|
30
30
|
"yaml": "^2.7.0"
|
|
31
31
|
}
|