orval 7.7.0 → 7.9.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/bin/orval.js +273 -180
- package/dist/bin/orval.js.map +1 -1
- package/dist/index.js +273 -180
- package/dist/index.js.map +1 -1
- package/package.json +12 -11
package/dist/index.js
CHANGED
|
@@ -31,16 +31,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
// src/index.ts
|
|
32
32
|
var src_exports = {};
|
|
33
33
|
__export(src_exports, {
|
|
34
|
-
Options: () =>
|
|
34
|
+
Options: () => import_core13.Options,
|
|
35
35
|
default: () => src_default,
|
|
36
36
|
defineConfig: () => defineConfig,
|
|
37
37
|
generate: () => generate
|
|
38
38
|
});
|
|
39
39
|
module.exports = __toCommonJS(src_exports);
|
|
40
|
-
var
|
|
40
|
+
var import_core13 = require("@orval/core");
|
|
41
41
|
|
|
42
42
|
// src/generate.ts
|
|
43
|
-
var
|
|
43
|
+
var import_core12 = require("@orval/core");
|
|
44
44
|
|
|
45
45
|
// src/import-specs.ts
|
|
46
46
|
var import_swagger_parser = __toESM(require("@apidevtools/swagger-parser"));
|
|
@@ -2689,6 +2689,7 @@ var mock = __toESM(require("@orval/mock"));
|
|
|
2689
2689
|
var import_query = __toESM(require("@orval/query"));
|
|
2690
2690
|
var import_swr = __toESM(require("@orval/swr"));
|
|
2691
2691
|
var import_zod = __toESM(require("@orval/zod"));
|
|
2692
|
+
var import_mcp = __toESM(require("@orval/mcp"));
|
|
2692
2693
|
var DEFAULT_CLIENT = import_core.OutputClient.AXIOS;
|
|
2693
2694
|
var getGeneratorClient = (outputClient, output) => {
|
|
2694
2695
|
const GENERATOR_CLIENT = {
|
|
@@ -2701,7 +2702,8 @@ var getGeneratorClient = (outputClient, output) => {
|
|
|
2701
2702
|
swr: (0, import_swr.default)()(),
|
|
2702
2703
|
zod: (0, import_zod.default)()(),
|
|
2703
2704
|
hono: (0, import_hono.default)()(),
|
|
2704
|
-
fetch: (0, import_fetch.default)()()
|
|
2705
|
+
fetch: (0, import_fetch.default)()(),
|
|
2706
|
+
mcp: (0, import_mcp.default)()()
|
|
2705
2707
|
};
|
|
2706
2708
|
const generator = (0, import_core.isFunction)(outputClient) ? outputClient(GENERATOR_CLIENT) : GENERATOR_CLIENT[outputClient];
|
|
2707
2709
|
if (!generator) {
|
|
@@ -3240,15 +3242,15 @@ var importSpecs = async (workspace, options) => {
|
|
|
3240
3242
|
};
|
|
3241
3243
|
|
|
3242
3244
|
// src/utils/options.ts
|
|
3243
|
-
var
|
|
3245
|
+
var import_core8 = require("@orval/core");
|
|
3244
3246
|
var import_mock2 = require("@orval/mock");
|
|
3245
|
-
var
|
|
3247
|
+
var import_chalk3 = __toESM(require("chalk"));
|
|
3246
3248
|
|
|
3247
3249
|
// package.json
|
|
3248
3250
|
var package_default = {
|
|
3249
3251
|
name: "orval",
|
|
3250
3252
|
description: "A swagger client generator for typescript",
|
|
3251
|
-
version: "7.
|
|
3253
|
+
version: "7.9.0",
|
|
3252
3254
|
license: "MIT",
|
|
3253
3255
|
files: [
|
|
3254
3256
|
"dist"
|
|
@@ -3303,15 +3305,16 @@ var package_default = {
|
|
|
3303
3305
|
},
|
|
3304
3306
|
dependencies: {
|
|
3305
3307
|
"@apidevtools/swagger-parser": "^10.1.1",
|
|
3306
|
-
"@orval/angular": "7.
|
|
3307
|
-
"@orval/axios": "7.
|
|
3308
|
-
"@orval/core": "7.
|
|
3309
|
-
"@orval/fetch": "7.
|
|
3310
|
-
"@orval/hono": "7.
|
|
3311
|
-
"@orval/
|
|
3312
|
-
"@orval/
|
|
3313
|
-
"@orval/
|
|
3314
|
-
"@orval/
|
|
3308
|
+
"@orval/angular": "7.9.0",
|
|
3309
|
+
"@orval/axios": "7.9.0",
|
|
3310
|
+
"@orval/core": "7.9.0",
|
|
3311
|
+
"@orval/fetch": "7.9.0",
|
|
3312
|
+
"@orval/hono": "7.9.0",
|
|
3313
|
+
"@orval/mcp": "7.9.0",
|
|
3314
|
+
"@orval/mock": "7.9.0",
|
|
3315
|
+
"@orval/query": "7.9.0",
|
|
3316
|
+
"@orval/swr": "7.9.0",
|
|
3317
|
+
"@orval/zod": "7.9.0",
|
|
3315
3318
|
ajv: "^8.17.1",
|
|
3316
3319
|
cac: "^6.7.14",
|
|
3317
3320
|
chalk: "^4.1.2",
|
|
@@ -3324,7 +3327,7 @@ var package_default = {
|
|
|
3324
3327
|
"openapi3-ts": "4.2.2",
|
|
3325
3328
|
"string-argv": "^0.3.2",
|
|
3326
3329
|
tsconfck: "^2.0.1",
|
|
3327
|
-
typedoc: "^0.
|
|
3330
|
+
typedoc: "^0.28.0",
|
|
3328
3331
|
"typedoc-plugin-markdown": "^4.4.2",
|
|
3329
3332
|
typescript: "^5.6.3"
|
|
3330
3333
|
}
|
|
@@ -3482,6 +3485,8 @@ var githubResolver = {
|
|
|
3482
3485
|
};
|
|
3483
3486
|
|
|
3484
3487
|
// src/utils/package-json.ts
|
|
3488
|
+
var import_core6 = require("@orval/core");
|
|
3489
|
+
var import_chalk2 = __toESM(require("chalk"));
|
|
3485
3490
|
var import_find_up = __toESM(require("find-up"));
|
|
3486
3491
|
var import_fs_extra3 = __toESM(require("fs-extra"));
|
|
3487
3492
|
var loadPackageJson = async (packageJson, workspace = process.cwd()) => {
|
|
@@ -3491,26 +3496,88 @@ var loadPackageJson = async (packageJson, workspace = process.cwd()) => {
|
|
|
3491
3496
|
});
|
|
3492
3497
|
if (pkgPath) {
|
|
3493
3498
|
const pkg = await Promise.resolve().then(() => __toESM(require(pkgPath)));
|
|
3494
|
-
return pkg;
|
|
3499
|
+
return await maybeReplaceCatalog(pkg, workspace);
|
|
3495
3500
|
}
|
|
3496
3501
|
return;
|
|
3497
3502
|
}
|
|
3498
3503
|
const normalizedPath = normalizePath(packageJson, workspace);
|
|
3499
3504
|
if (import_fs_extra3.default.existsSync(normalizedPath)) {
|
|
3500
3505
|
const pkg = await Promise.resolve().then(() => __toESM(require(normalizedPath)));
|
|
3501
|
-
return pkg;
|
|
3506
|
+
return await maybeReplaceCatalog(pkg, workspace);
|
|
3502
3507
|
}
|
|
3503
3508
|
return;
|
|
3504
3509
|
};
|
|
3510
|
+
var maybeReplaceCatalog = async (pkg, workspace) => {
|
|
3511
|
+
var _a, _b, _c;
|
|
3512
|
+
if (![
|
|
3513
|
+
...Object.entries((_a = pkg.dependencies) != null ? _a : {}),
|
|
3514
|
+
...Object.entries((_b = pkg.devDependencies) != null ? _b : {}),
|
|
3515
|
+
...Object.entries((_c = pkg.peerDependencies) != null ? _c : {})
|
|
3516
|
+
].some(([key]) => key.startsWith("catalog:"))) {
|
|
3517
|
+
return pkg;
|
|
3518
|
+
}
|
|
3519
|
+
const filePath = await (0, import_find_up.default)("pnpm-workspace.yaml", { cwd: workspace });
|
|
3520
|
+
if (!filePath) {
|
|
3521
|
+
(0, import_core6.log)(
|
|
3522
|
+
`\u26A0\uFE0F ${import_chalk2.default.yellow("package.json contains pnpm catalog: in dependencies, but no pnpm-workspace.yaml was found.")}`
|
|
3523
|
+
);
|
|
3524
|
+
return pkg;
|
|
3525
|
+
}
|
|
3526
|
+
const file = await import_fs_extra3.default.readFile(filePath, "utf8");
|
|
3527
|
+
const pnpmWorkspaceFile = js_yaml_default.load(file);
|
|
3528
|
+
performSubstitution(pkg.dependencies, pnpmWorkspaceFile);
|
|
3529
|
+
performSubstitution(pkg.devDependencies, pnpmWorkspaceFile);
|
|
3530
|
+
performSubstitution(pkg.peerDependencies, pnpmWorkspaceFile);
|
|
3531
|
+
return pkg;
|
|
3532
|
+
};
|
|
3533
|
+
var performSubstitution = (dependencies, pnpmWorkspaceFile) => {
|
|
3534
|
+
var _a, _b;
|
|
3535
|
+
if (!dependencies) return;
|
|
3536
|
+
for (const [packageName, version] of Object.entries(dependencies)) {
|
|
3537
|
+
if (version === "catalog:" || version === "catalog:default") {
|
|
3538
|
+
if (!pnpmWorkspaceFile.catalog) {
|
|
3539
|
+
(0, import_core6.log)(
|
|
3540
|
+
`\u26A0\uFE0F ${import_chalk2.default.yellow(`when reading from pnpm-workspace.yaml, catalog: substitution for the package '${packageName}' failed as there were no default catalog.`)}`
|
|
3541
|
+
);
|
|
3542
|
+
continue;
|
|
3543
|
+
}
|
|
3544
|
+
const sub = pnpmWorkspaceFile.catalog[packageName];
|
|
3545
|
+
if (!sub) {
|
|
3546
|
+
(0, import_core6.log)(
|
|
3547
|
+
`\u26A0\uFE0F ${import_chalk2.default.yellow(`when reading from pnpm-workspace.yaml, catalog: substitution for the package '${packageName}' failed as there were no matching package in the default catalog.`)}`
|
|
3548
|
+
);
|
|
3549
|
+
continue;
|
|
3550
|
+
}
|
|
3551
|
+
dependencies[packageName] = sub;
|
|
3552
|
+
} else if (version.startsWith("catalog:")) {
|
|
3553
|
+
const catalogName = version.substring("catalog:".length);
|
|
3554
|
+
const catalog = (_a = pnpmWorkspaceFile.catalogs) == null ? void 0 : _a[catalogName];
|
|
3555
|
+
if (!catalog) {
|
|
3556
|
+
(0, import_core6.log)(
|
|
3557
|
+
`\u26A0\uFE0F ${import_chalk2.default.yellow(`when reading from pnpm-workspace.yaml, '${version}' substitution for the package '${packageName}' failed as there were no matching catalog named '${catalogName}'. (available named catalogs are: ${Object.keys((_b = pnpmWorkspaceFile.catalogs) != null ? _b : {}).join(", ")})`)}`
|
|
3558
|
+
);
|
|
3559
|
+
continue;
|
|
3560
|
+
}
|
|
3561
|
+
const sub = catalog[packageName];
|
|
3562
|
+
if (!sub) {
|
|
3563
|
+
(0, import_core6.log)(
|
|
3564
|
+
`\u26A0\uFE0F ${import_chalk2.default.yellow(`when reading from pnpm-workspace.yaml, '${version}' substitution for the package '${packageName}' failed as there were no package in the catalog named '${catalogName}'. (packages in the catalog are: ${Object.keys(catalog).join(", ")})`)}`
|
|
3565
|
+
);
|
|
3566
|
+
continue;
|
|
3567
|
+
}
|
|
3568
|
+
dependencies[packageName] = sub;
|
|
3569
|
+
}
|
|
3570
|
+
}
|
|
3571
|
+
};
|
|
3505
3572
|
|
|
3506
3573
|
// src/utils/tsconfig.ts
|
|
3507
|
-
var
|
|
3574
|
+
var import_core7 = require("@orval/core");
|
|
3508
3575
|
var import_find_up2 = __toESM(require("find-up"));
|
|
3509
3576
|
var import_fs_extra4 = __toESM(require("fs-extra"));
|
|
3510
3577
|
var import_tsconfck = require("tsconfck");
|
|
3511
3578
|
var loadTsconfig = async (tsconfig, workspace = process.cwd()) => {
|
|
3512
3579
|
var _a, _b;
|
|
3513
|
-
if ((0,
|
|
3580
|
+
if ((0, import_core7.isUndefined)(tsconfig)) {
|
|
3514
3581
|
const configPath = await (0, import_find_up2.default)(["tsconfig.json", "jsconfig.json"], {
|
|
3515
3582
|
cwd: workspace
|
|
3516
3583
|
});
|
|
@@ -3520,7 +3587,7 @@ var loadTsconfig = async (tsconfig, workspace = process.cwd()) => {
|
|
|
3520
3587
|
}
|
|
3521
3588
|
return;
|
|
3522
3589
|
}
|
|
3523
|
-
if ((0,
|
|
3590
|
+
if ((0, import_core7.isString)(tsconfig)) {
|
|
3524
3591
|
const normalizedPath = normalizePath(tsconfig, workspace);
|
|
3525
3592
|
if (import_fs_extra4.default.existsSync(normalizedPath)) {
|
|
3526
3593
|
const config = await (0, import_tsconfck.parse)(normalizedPath);
|
|
@@ -3531,7 +3598,7 @@ var loadTsconfig = async (tsconfig, workspace = process.cwd()) => {
|
|
|
3531
3598
|
}
|
|
3532
3599
|
return;
|
|
3533
3600
|
}
|
|
3534
|
-
if ((0,
|
|
3601
|
+
if ((0, import_core7.isObject)(tsconfig)) {
|
|
3535
3602
|
return tsconfig;
|
|
3536
3603
|
}
|
|
3537
3604
|
return;
|
|
@@ -3541,19 +3608,44 @@ var loadTsconfig = async (tsconfig, workspace = process.cwd()) => {
|
|
|
3541
3608
|
function defineConfig(options) {
|
|
3542
3609
|
return options;
|
|
3543
3610
|
}
|
|
3611
|
+
var createFormData = (workspace, formData) => {
|
|
3612
|
+
var _a;
|
|
3613
|
+
const defaultArrayHandling = import_core8.FormDataArrayHandling.SERIALIZE;
|
|
3614
|
+
if (formData === void 0)
|
|
3615
|
+
return { disabled: false, arrayHandling: defaultArrayHandling };
|
|
3616
|
+
if ((0, import_core8.isBoolean)(formData))
|
|
3617
|
+
return { disabled: !formData, arrayHandling: defaultArrayHandling };
|
|
3618
|
+
if ((0, import_core8.isString)(formData))
|
|
3619
|
+
return {
|
|
3620
|
+
disabled: false,
|
|
3621
|
+
mutator: normalizeMutator(workspace, formData),
|
|
3622
|
+
arrayHandling: defaultArrayHandling
|
|
3623
|
+
};
|
|
3624
|
+
if ("mutator" in formData || "arrayHandling" in formData)
|
|
3625
|
+
return {
|
|
3626
|
+
disabled: false,
|
|
3627
|
+
mutator: normalizeMutator(workspace, formData.mutator),
|
|
3628
|
+
arrayHandling: (_a = formData.arrayHandling) != null ? _a : defaultArrayHandling
|
|
3629
|
+
};
|
|
3630
|
+
return {
|
|
3631
|
+
disabled: false,
|
|
3632
|
+
mutator: normalizeMutator(workspace, formData),
|
|
3633
|
+
arrayHandling: defaultArrayHandling
|
|
3634
|
+
};
|
|
3635
|
+
};
|
|
3544
3636
|
var normalizeOptions = async (optionsExport, workspace = process.cwd(), globalOptions = {}) => {
|
|
3545
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za, _Aa, _Ba, _Ca, _Da, _Ea, _Fa, _Ga, _Ha, _Ia, _Ja, _Ka, _La, _Ma, _Na, _Oa, _Pa, _Qa, _Ra, _Sa, _Ta, _Ua, _Va, _Wa, _Xa, _Ya, _Za, __a, _$a, _ab, _bb, _cb, _db, _eb, _fb, _gb, _hb, _ib, _jb, _kb, _lb, _mb, _nb, _ob, _pb, _qb, _rb, _sb, _tb, _ub, _vb, _wb, _xb, _yb, _zb, _Ab, _Bb, _Cb, _Db, _Eb, _Fb, _Gb, _Hb, _Ib, _Jb, _Kb, _Lb, _Mb, _Nb, _Ob, _Pb, _Qb, _Rb, _Sb, _Tb, _Ub, _Vb, _Wb, _Xb, _Yb, _Zb, __b, _$b, _ac, _bc;
|
|
3546
|
-
const options = await ((0,
|
|
3637
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za, _Aa, _Ba, _Ca, _Da, _Ea, _Fa, _Ga, _Ha, _Ia, _Ja, _Ka, _La, _Ma, _Na, _Oa, _Pa, _Qa, _Ra, _Sa, _Ta, _Ua, _Va, _Wa, _Xa, _Ya, _Za, __a, _$a, _ab, _bb, _cb, _db, _eb, _fb, _gb, _hb, _ib, _jb, _kb, _lb, _mb, _nb, _ob, _pb, _qb, _rb, _sb, _tb, _ub, _vb, _wb, _xb, _yb, _zb, _Ab, _Bb, _Cb, _Db, _Eb, _Fb, _Gb, _Hb, _Ib, _Jb, _Kb, _Lb, _Mb, _Nb, _Ob, _Pb, _Qb, _Rb, _Sb, _Tb, _Ub, _Vb, _Wb, _Xb, _Yb, _Zb, __b, _$b, _ac, _bc, _cc, _dc;
|
|
3638
|
+
const options = await ((0, import_core8.isFunction)(optionsExport) ? optionsExport() : optionsExport);
|
|
3547
3639
|
if (!options.input) {
|
|
3548
|
-
(0,
|
|
3640
|
+
(0, import_core8.createLogger)().error(import_chalk3.default.red(`Config require an input`));
|
|
3549
3641
|
process.exit(1);
|
|
3550
3642
|
}
|
|
3551
3643
|
if (!options.output) {
|
|
3552
|
-
(0,
|
|
3644
|
+
(0, import_core8.createLogger)().error(import_chalk3.default.red(`Config require an output`));
|
|
3553
3645
|
process.exit(1);
|
|
3554
3646
|
}
|
|
3555
|
-
const inputOptions = (0,
|
|
3556
|
-
const outputOptions = (0,
|
|
3647
|
+
const inputOptions = (0, import_core8.isString)(options.input) ? { target: options.input } : options.input;
|
|
3648
|
+
const outputOptions = (0, import_core8.isString)(options.output) ? { target: options.output } : options.output;
|
|
3557
3649
|
const outputWorkspace = normalizePath(
|
|
3558
3650
|
outputOptions.workspace || "",
|
|
3559
3651
|
workspace
|
|
@@ -3571,7 +3663,8 @@ var normalizeOptions = async (optionsExport, workspace = process.cwd(), globalOp
|
|
|
3571
3663
|
let mock2;
|
|
3572
3664
|
if (typeof mockOption === "boolean" && mockOption) {
|
|
3573
3665
|
mock2 = import_mock2.DEFAULT_MOCK_OPTIONS;
|
|
3574
|
-
} else if ((0,
|
|
3666
|
+
} else if ((0, import_core8.isFunction)(mockOption)) {
|
|
3667
|
+
mock2 = mockOption;
|
|
3575
3668
|
} else if (!mockOption) {
|
|
3576
3669
|
mock2 = void 0;
|
|
3577
3670
|
} else {
|
|
@@ -3602,7 +3695,7 @@ var normalizeOptions = async (optionsExport, workspace = process.cwd(), globalOp
|
|
|
3602
3695
|
)
|
|
3603
3696
|
},
|
|
3604
3697
|
converterOptions: (_d = inputOptions.converterOptions) != null ? _d : {},
|
|
3605
|
-
parserOptions: (0,
|
|
3698
|
+
parserOptions: (0, import_core8.mergeDeep)(
|
|
3606
3699
|
parserDefaultOptions,
|
|
3607
3700
|
(_e = inputOptions.parserOptions) != null ? _e : {}
|
|
3608
3701
|
),
|
|
@@ -3611,11 +3704,11 @@ var normalizeOptions = async (optionsExport, workspace = process.cwd(), globalOp
|
|
|
3611
3704
|
output: {
|
|
3612
3705
|
target: globalOptions.output ? normalizePath(globalOptions.output, process.cwd()) : normalizePath(outputOptions.target, outputWorkspace),
|
|
3613
3706
|
schemas: normalizePath(outputOptions.schemas, outputWorkspace),
|
|
3614
|
-
namingConvention: outputOptions.namingConvention ||
|
|
3707
|
+
namingConvention: outputOptions.namingConvention || import_core8.NamingConvention.CAMEL_CASE,
|
|
3615
3708
|
fileExtension: outputOptions.fileExtension || defaultFileExtension,
|
|
3616
3709
|
workspace: outputOptions.workspace ? outputWorkspace : void 0,
|
|
3617
|
-
client: (_g = (_f = outputOptions.client) != null ? _f : client) != null ? _g :
|
|
3618
|
-
httpClient: (_i = (_h = outputOptions.httpClient) != null ? _h : httpClient) != null ? _i :
|
|
3710
|
+
client: (_g = (_f = outputOptions.client) != null ? _f : client) != null ? _g : import_core8.OutputClient.AXIOS_FUNCTIONS,
|
|
3711
|
+
httpClient: (_i = (_h = outputOptions.httpClient) != null ? _h : httpClient) != null ? _i : import_core8.OutputHttpClient.AXIOS,
|
|
3619
3712
|
mode: normalizeOutputMode((_j = outputOptions.mode) != null ? _j : mode),
|
|
3620
3713
|
mock: mock2,
|
|
3621
3714
|
clean: (_l = (_k = outputOptions.clean) != null ? _k : clean) != null ? _l : false,
|
|
@@ -3654,96 +3747,97 @@ var normalizeOptions = async (optionsExport, workspace = process.cwd(), globalOp
|
|
|
3654
3747
|
outputWorkspace,
|
|
3655
3748
|
(_I = outputOptions.override) == null ? void 0 : _I.mutator
|
|
3656
3749
|
),
|
|
3657
|
-
formData: (
|
|
3750
|
+
formData: createFormData(
|
|
3658
3751
|
outputWorkspace,
|
|
3659
|
-
(
|
|
3660
|
-
)
|
|
3661
|
-
formUrlEncoded: (
|
|
3752
|
+
(_J = outputOptions.override) == null ? void 0 : _J.formData
|
|
3753
|
+
),
|
|
3754
|
+
formUrlEncoded: (_N = !(0, import_core8.isBoolean)((_K = outputOptions.override) == null ? void 0 : _K.formUrlEncoded) ? normalizeMutator(
|
|
3662
3755
|
outputWorkspace,
|
|
3663
|
-
(
|
|
3664
|
-
) : (
|
|
3756
|
+
(_L = outputOptions.override) == null ? void 0 : _L.formUrlEncoded
|
|
3757
|
+
) : (_M = outputOptions.override) == null ? void 0 : _M.formUrlEncoded) != null ? _N : true,
|
|
3665
3758
|
paramsSerializer: normalizeMutator(
|
|
3666
3759
|
outputWorkspace,
|
|
3667
|
-
(
|
|
3760
|
+
(_O = outputOptions.override) == null ? void 0 : _O.paramsSerializer
|
|
3668
3761
|
),
|
|
3669
|
-
header: ((
|
|
3670
|
-
requestOptions: (
|
|
3762
|
+
header: ((_P = outputOptions.override) == null ? void 0 : _P.header) === false ? false : (0, import_core8.isFunction)((_Q = outputOptions.override) == null ? void 0 : _Q.header) ? (_R = outputOptions.override) == null ? void 0 : _R.header : getDefaultFilesHeader,
|
|
3763
|
+
requestOptions: (_T = (_S = outputOptions.override) == null ? void 0 : _S.requestOptions) != null ? _T : true,
|
|
3671
3764
|
components: {
|
|
3672
3765
|
schemas: {
|
|
3673
|
-
suffix:
|
|
3674
|
-
itemSuffix: (
|
|
3675
|
-
...(
|
|
3766
|
+
suffix: import_core8.RefComponentSuffix.schemas,
|
|
3767
|
+
itemSuffix: (_X = (_W = (_V = (_U = outputOptions.override) == null ? void 0 : _U.components) == null ? void 0 : _V.schemas) == null ? void 0 : _W.itemSuffix) != null ? _X : "Item",
|
|
3768
|
+
...(__ = (_Z = (_Y = outputOptions.override) == null ? void 0 : _Y.components) == null ? void 0 : _Z.schemas) != null ? __ : {}
|
|
3676
3769
|
},
|
|
3677
3770
|
responses: {
|
|
3678
|
-
suffix:
|
|
3679
|
-
...(
|
|
3771
|
+
suffix: import_core8.RefComponentSuffix.responses,
|
|
3772
|
+
...(_ba = (_aa = (_$ = outputOptions.override) == null ? void 0 : _$.components) == null ? void 0 : _aa.responses) != null ? _ba : {}
|
|
3680
3773
|
},
|
|
3681
3774
|
parameters: {
|
|
3682
|
-
suffix:
|
|
3683
|
-
...(
|
|
3775
|
+
suffix: import_core8.RefComponentSuffix.parameters,
|
|
3776
|
+
...(_ea = (_da = (_ca = outputOptions.override) == null ? void 0 : _ca.components) == null ? void 0 : _da.parameters) != null ? _ea : {}
|
|
3684
3777
|
},
|
|
3685
3778
|
requestBodies: {
|
|
3686
|
-
suffix:
|
|
3687
|
-
...(
|
|
3779
|
+
suffix: import_core8.RefComponentSuffix.requestBodies,
|
|
3780
|
+
...(_ha = (_ga = (_fa = outputOptions.override) == null ? void 0 : _fa.components) == null ? void 0 : _ga.requestBodies) != null ? _ha : {}
|
|
3688
3781
|
}
|
|
3689
3782
|
},
|
|
3690
|
-
hono: normalizeHonoOptions((
|
|
3783
|
+
hono: normalizeHonoOptions((_ia = outputOptions.override) == null ? void 0 : _ia.hono, workspace),
|
|
3691
3784
|
query: globalQueryOptions,
|
|
3692
3785
|
zod: {
|
|
3693
3786
|
strict: {
|
|
3694
|
-
param: (
|
|
3695
|
-
query: (
|
|
3696
|
-
header: (
|
|
3697
|
-
body: (
|
|
3698
|
-
response: (
|
|
3787
|
+
param: (_ma = (_la = (_ka = (_ja = outputOptions.override) == null ? void 0 : _ja.zod) == null ? void 0 : _ka.strict) == null ? void 0 : _la.param) != null ? _ma : false,
|
|
3788
|
+
query: (_qa = (_pa = (_oa = (_na = outputOptions.override) == null ? void 0 : _na.zod) == null ? void 0 : _oa.strict) == null ? void 0 : _pa.query) != null ? _qa : false,
|
|
3789
|
+
header: (_ua = (_ta = (_sa = (_ra = outputOptions.override) == null ? void 0 : _ra.zod) == null ? void 0 : _sa.strict) == null ? void 0 : _ta.header) != null ? _ua : false,
|
|
3790
|
+
body: (_ya = (_xa = (_wa = (_va = outputOptions.override) == null ? void 0 : _va.zod) == null ? void 0 : _wa.strict) == null ? void 0 : _xa.body) != null ? _ya : false,
|
|
3791
|
+
response: (_Ca = (_Ba = (_Aa = (_za = outputOptions.override) == null ? void 0 : _za.zod) == null ? void 0 : _Aa.strict) == null ? void 0 : _Ba.response) != null ? _Ca : false
|
|
3699
3792
|
},
|
|
3700
3793
|
generate: {
|
|
3701
|
-
param: (
|
|
3702
|
-
query: (
|
|
3703
|
-
header: (
|
|
3704
|
-
body: (
|
|
3705
|
-
response: (
|
|
3794
|
+
param: (_Ga = (_Fa = (_Ea = (_Da = outputOptions.override) == null ? void 0 : _Da.zod) == null ? void 0 : _Ea.generate) == null ? void 0 : _Fa.param) != null ? _Ga : true,
|
|
3795
|
+
query: (_Ka = (_Ja = (_Ia = (_Ha = outputOptions.override) == null ? void 0 : _Ha.zod) == null ? void 0 : _Ia.generate) == null ? void 0 : _Ja.query) != null ? _Ka : true,
|
|
3796
|
+
header: (_Oa = (_Na = (_Ma = (_La = outputOptions.override) == null ? void 0 : _La.zod) == null ? void 0 : _Ma.generate) == null ? void 0 : _Na.header) != null ? _Oa : true,
|
|
3797
|
+
body: (_Sa = (_Ra = (_Qa = (_Pa = outputOptions.override) == null ? void 0 : _Pa.zod) == null ? void 0 : _Qa.generate) == null ? void 0 : _Ra.body) != null ? _Sa : true,
|
|
3798
|
+
response: (_Wa = (_Va = (_Ua = (_Ta = outputOptions.override) == null ? void 0 : _Ta.zod) == null ? void 0 : _Ua.generate) == null ? void 0 : _Va.response) != null ? _Wa : true
|
|
3706
3799
|
},
|
|
3707
3800
|
coerce: {
|
|
3708
|
-
param: (
|
|
3709
|
-
query: (
|
|
3710
|
-
header: (
|
|
3711
|
-
body: (
|
|
3712
|
-
response: (
|
|
3801
|
+
param: (__a = (_Za = (_Ya = (_Xa = outputOptions.override) == null ? void 0 : _Xa.zod) == null ? void 0 : _Ya.coerce) == null ? void 0 : _Za.param) != null ? __a : false,
|
|
3802
|
+
query: (_cb = (_bb = (_ab = (_$a = outputOptions.override) == null ? void 0 : _$a.zod) == null ? void 0 : _ab.coerce) == null ? void 0 : _bb.query) != null ? _cb : false,
|
|
3803
|
+
header: (_gb = (_fb = (_eb = (_db = outputOptions.override) == null ? void 0 : _db.zod) == null ? void 0 : _eb.coerce) == null ? void 0 : _fb.header) != null ? _gb : false,
|
|
3804
|
+
body: (_kb = (_jb = (_ib = (_hb = outputOptions.override) == null ? void 0 : _hb.zod) == null ? void 0 : _ib.coerce) == null ? void 0 : _jb.body) != null ? _kb : false,
|
|
3805
|
+
response: (_ob = (_nb = (_mb = (_lb = outputOptions.override) == null ? void 0 : _lb.zod) == null ? void 0 : _mb.coerce) == null ? void 0 : _nb.response) != null ? _ob : false
|
|
3713
3806
|
},
|
|
3714
3807
|
preprocess: {
|
|
3715
|
-
...((
|
|
3808
|
+
...((_rb = (_qb = (_pb = outputOptions.override) == null ? void 0 : _pb.zod) == null ? void 0 : _qb.preprocess) == null ? void 0 : _rb.param) ? {
|
|
3716
3809
|
param: normalizeMutator(
|
|
3717
3810
|
workspace,
|
|
3718
3811
|
outputOptions.override.zod.preprocess.param
|
|
3719
3812
|
)
|
|
3720
3813
|
} : {},
|
|
3721
|
-
...((
|
|
3814
|
+
...((_ub = (_tb = (_sb = outputOptions.override) == null ? void 0 : _sb.zod) == null ? void 0 : _tb.preprocess) == null ? void 0 : _ub.query) ? {
|
|
3722
3815
|
query: normalizeMutator(
|
|
3723
3816
|
workspace,
|
|
3724
3817
|
outputOptions.override.zod.preprocess.query
|
|
3725
3818
|
)
|
|
3726
3819
|
} : {},
|
|
3727
|
-
...((
|
|
3820
|
+
...((_xb = (_wb = (_vb = outputOptions.override) == null ? void 0 : _vb.zod) == null ? void 0 : _wb.preprocess) == null ? void 0 : _xb.header) ? {
|
|
3728
3821
|
header: normalizeMutator(
|
|
3729
3822
|
workspace,
|
|
3730
3823
|
outputOptions.override.zod.preprocess.header
|
|
3731
3824
|
)
|
|
3732
3825
|
} : {},
|
|
3733
|
-
...((
|
|
3826
|
+
...((_Ab = (_zb = (_yb = outputOptions.override) == null ? void 0 : _yb.zod) == null ? void 0 : _zb.preprocess) == null ? void 0 : _Ab.body) ? {
|
|
3734
3827
|
body: normalizeMutator(
|
|
3735
3828
|
workspace,
|
|
3736
3829
|
outputOptions.override.zod.preprocess.body
|
|
3737
3830
|
)
|
|
3738
3831
|
} : {},
|
|
3739
|
-
...((
|
|
3832
|
+
...((_Db = (_Cb = (_Bb = outputOptions.override) == null ? void 0 : _Bb.zod) == null ? void 0 : _Cb.preprocess) == null ? void 0 : _Db.response) ? {
|
|
3740
3833
|
response: normalizeMutator(
|
|
3741
3834
|
workspace,
|
|
3742
3835
|
outputOptions.override.zod.preprocess.response
|
|
3743
3836
|
)
|
|
3744
3837
|
} : {}
|
|
3745
3838
|
},
|
|
3746
|
-
generateEachHttpStatus: (
|
|
3839
|
+
generateEachHttpStatus: (_Gb = (_Fb = (_Eb = outputOptions.override) == null ? void 0 : _Eb.zod) == null ? void 0 : _Fb.generateEachHttpStatus) != null ? _Gb : false,
|
|
3840
|
+
dateTimeOptions: (_Jb = (_Ib = (_Hb = outputOptions.override) == null ? void 0 : _Hb.zod) == null ? void 0 : _Ib.dateTimeOptions) != null ? _Jb : {}
|
|
3747
3841
|
},
|
|
3748
3842
|
swr: {
|
|
3749
3843
|
...(_Lb = (_Kb = outputOptions.override) == null ? void 0 : _Kb.swr) != null ? _Lb : {}
|
|
@@ -3757,23 +3851,23 @@ var normalizeOptions = async (optionsExport, workspace = process.cwd(), globalOp
|
|
|
3757
3851
|
},
|
|
3758
3852
|
useDates: ((_Ub = outputOptions.override) == null ? void 0 : _Ub.useDates) || false,
|
|
3759
3853
|
useDeprecatedOperations: (_Wb = (_Vb = outputOptions.override) == null ? void 0 : _Vb.useDeprecatedOperations) != null ? _Wb : true,
|
|
3760
|
-
|
|
3761
|
-
suppressReadonlyModifier: ((
|
|
3854
|
+
enumGenerationType: ((_Yb = (_Xb = outputOptions.override) == null ? void 0 : _Xb.useNativeEnums) != null ? _Yb : false) ? "enum" : (__b = (_Zb = outputOptions.override) == null ? void 0 : _Zb.enumGenerationType) != null ? __b : "const",
|
|
3855
|
+
suppressReadonlyModifier: ((_$b = outputOptions.override) == null ? void 0 : _$b.suppressReadonlyModifier) || false
|
|
3762
3856
|
},
|
|
3763
|
-
allParamsOptional: (
|
|
3764
|
-
urlEncodeParameters: (
|
|
3765
|
-
optionsParamRequired: (
|
|
3766
|
-
propertySortOrder: (
|
|
3857
|
+
allParamsOptional: (_ac = outputOptions.allParamsOptional) != null ? _ac : false,
|
|
3858
|
+
urlEncodeParameters: (_bc = outputOptions.urlEncodeParameters) != null ? _bc : false,
|
|
3859
|
+
optionsParamRequired: (_cc = outputOptions.optionsParamRequired) != null ? _cc : false,
|
|
3860
|
+
propertySortOrder: (_dc = outputOptions.propertySortOrder) != null ? _dc : import_core8.PropertySortOrder.SPECIFICATION
|
|
3767
3861
|
},
|
|
3768
3862
|
hooks: options.hooks ? normalizeHooks(options.hooks) : {}
|
|
3769
3863
|
};
|
|
3770
3864
|
if (!normalizedOptions.input.target) {
|
|
3771
|
-
(0,
|
|
3865
|
+
(0, import_core8.createLogger)().error(import_chalk3.default.red(`Config require an input target`));
|
|
3772
3866
|
process.exit(1);
|
|
3773
3867
|
}
|
|
3774
3868
|
if (!normalizedOptions.output.target && !normalizedOptions.output.schemas) {
|
|
3775
|
-
(0,
|
|
3776
|
-
|
|
3869
|
+
(0, import_core8.createLogger)().error(
|
|
3870
|
+
import_chalk3.default.red(`Config require an output target or schemas`)
|
|
3777
3871
|
);
|
|
3778
3872
|
process.exit(1);
|
|
3779
3873
|
}
|
|
@@ -3785,36 +3879,36 @@ var parserDefaultOptions = {
|
|
|
3785
3879
|
};
|
|
3786
3880
|
var normalizeMutator = (workspace, mutator) => {
|
|
3787
3881
|
var _a;
|
|
3788
|
-
if ((0,
|
|
3882
|
+
if ((0, import_core8.isObject)(mutator)) {
|
|
3789
3883
|
if (!mutator.path) {
|
|
3790
|
-
(0,
|
|
3884
|
+
(0, import_core8.createLogger)().error(import_chalk3.default.red(`Mutator need a path`));
|
|
3791
3885
|
process.exit(1);
|
|
3792
3886
|
}
|
|
3793
3887
|
return {
|
|
3794
3888
|
...mutator,
|
|
3795
|
-
path:
|
|
3889
|
+
path: import_core8.upath.resolve(workspace, mutator.path),
|
|
3796
3890
|
default: (_a = mutator.default || !mutator.name) != null ? _a : false
|
|
3797
3891
|
};
|
|
3798
3892
|
}
|
|
3799
|
-
if ((0,
|
|
3893
|
+
if ((0, import_core8.isString)(mutator)) {
|
|
3800
3894
|
return {
|
|
3801
|
-
path:
|
|
3895
|
+
path: import_core8.upath.resolve(workspace, mutator),
|
|
3802
3896
|
default: true
|
|
3803
3897
|
};
|
|
3804
3898
|
}
|
|
3805
3899
|
return mutator;
|
|
3806
3900
|
};
|
|
3807
3901
|
var normalizePathOrUrl = (path, workspace) => {
|
|
3808
|
-
if ((0,
|
|
3902
|
+
if ((0, import_core8.isString)(path) && !(0, import_core8.isUrl)(path)) {
|
|
3809
3903
|
return normalizePath(path, workspace);
|
|
3810
3904
|
}
|
|
3811
3905
|
return path;
|
|
3812
3906
|
};
|
|
3813
3907
|
var normalizePath = (path, workspace) => {
|
|
3814
|
-
if (!(0,
|
|
3908
|
+
if (!(0, import_core8.isString)(path)) {
|
|
3815
3909
|
return path;
|
|
3816
3910
|
}
|
|
3817
|
-
return
|
|
3911
|
+
return import_core8.upath.resolve(workspace, path);
|
|
3818
3912
|
};
|
|
3819
3913
|
var normalizeOperationsAndTags = (operationsOrTags, workspace, global) => {
|
|
3820
3914
|
return Object.fromEntries(
|
|
@@ -3832,7 +3926,7 @@ var normalizeOperationsAndTags = (operationsOrTags, workspace, global) => {
|
|
|
3832
3926
|
...rest
|
|
3833
3927
|
}
|
|
3834
3928
|
]) => {
|
|
3835
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J;
|
|
3929
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K;
|
|
3836
3930
|
return [
|
|
3837
3931
|
key,
|
|
3838
3932
|
{
|
|
@@ -3895,16 +3989,15 @@ var normalizeOperationsAndTags = (operationsOrTags, workspace, global) => {
|
|
|
3895
3989
|
)
|
|
3896
3990
|
} : {}
|
|
3897
3991
|
},
|
|
3898
|
-
generateEachHttpStatus: (_J = zod2 == null ? void 0 : zod2.generateEachHttpStatus) != null ? _J : false
|
|
3992
|
+
generateEachHttpStatus: (_J = zod2 == null ? void 0 : zod2.generateEachHttpStatus) != null ? _J : false,
|
|
3993
|
+
dateTimeOptions: (_K = zod2 == null ? void 0 : zod2.dateTimeOptions) != null ? _K : {}
|
|
3899
3994
|
}
|
|
3900
3995
|
} : {},
|
|
3901
3996
|
...transformer ? { transformer: normalizePath(transformer, workspace) } : {},
|
|
3902
3997
|
...mutator ? { mutator: normalizeMutator(workspace, mutator) } : {},
|
|
3903
|
-
...formData
|
|
3904
|
-
formData: !(0, import_core7.isBoolean)(formData) ? normalizeMutator(workspace, formData) : formData
|
|
3905
|
-
} : {},
|
|
3998
|
+
...createFormData(workspace, formData),
|
|
3906
3999
|
...formUrlEncoded ? {
|
|
3907
|
-
formUrlEncoded: !(0,
|
|
4000
|
+
formUrlEncoded: !(0, import_core8.isBoolean)(formUrlEncoded) ? normalizeMutator(workspace, formUrlEncoded) : formUrlEncoded
|
|
3908
4001
|
} : {},
|
|
3909
4002
|
...paramsSerializer ? {
|
|
3910
4003
|
paramsSerializer: normalizeMutator(
|
|
@@ -3920,18 +4013,18 @@ var normalizeOperationsAndTags = (operationsOrTags, workspace, global) => {
|
|
|
3920
4013
|
};
|
|
3921
4014
|
var normalizeOutputMode = (mode) => {
|
|
3922
4015
|
if (!mode) {
|
|
3923
|
-
return
|
|
4016
|
+
return import_core8.OutputMode.SINGLE;
|
|
3924
4017
|
}
|
|
3925
|
-
if (!Object.values(
|
|
3926
|
-
(0,
|
|
3927
|
-
return
|
|
4018
|
+
if (!Object.values(import_core8.OutputMode).includes(mode)) {
|
|
4019
|
+
(0, import_core8.createLogger)().warn(import_chalk3.default.yellow(`Unknown the provided mode => ${mode}`));
|
|
4020
|
+
return import_core8.OutputMode.SINGLE;
|
|
3928
4021
|
}
|
|
3929
4022
|
return mode;
|
|
3930
4023
|
};
|
|
3931
4024
|
var normalizeHooks = (hooks) => {
|
|
3932
4025
|
const keys = Object.keys(hooks);
|
|
3933
4026
|
return keys.reduce((acc, key) => {
|
|
3934
|
-
if ((0,
|
|
4027
|
+
if ((0, import_core8.isString)(hooks[key])) {
|
|
3935
4028
|
return {
|
|
3936
4029
|
...acc,
|
|
3937
4030
|
[key]: [hooks[key]]
|
|
@@ -3941,12 +4034,12 @@ var normalizeHooks = (hooks) => {
|
|
|
3941
4034
|
...acc,
|
|
3942
4035
|
[key]: hooks[key]
|
|
3943
4036
|
};
|
|
3944
|
-
} else if ((0,
|
|
4037
|
+
} else if ((0, import_core8.isFunction)(hooks[key])) {
|
|
3945
4038
|
return {
|
|
3946
4039
|
...acc,
|
|
3947
4040
|
[key]: [hooks[key]]
|
|
3948
4041
|
};
|
|
3949
|
-
} else if ((0,
|
|
4042
|
+
} else if ((0, import_core8.isObject)(hooks[key])) {
|
|
3950
4043
|
return {
|
|
3951
4044
|
...acc,
|
|
3952
4045
|
[key]: [hooks[key]]
|
|
@@ -3958,10 +4051,10 @@ var normalizeHooks = (hooks) => {
|
|
|
3958
4051
|
var normalizeHonoOptions = (hono2 = {}, workspace) => {
|
|
3959
4052
|
var _a, _b;
|
|
3960
4053
|
return {
|
|
3961
|
-
...hono2.handlers ? { handlers:
|
|
4054
|
+
...hono2.handlers ? { handlers: import_core8.upath.resolve(workspace, hono2.handlers) } : {},
|
|
3962
4055
|
compositeRoute: (_a = hono2.compositeRoute) != null ? _a : "",
|
|
3963
4056
|
validator: (_b = hono2.validator) != null ? _b : true,
|
|
3964
|
-
validatorOutputPath: hono2.validatorOutputPath ?
|
|
4057
|
+
validatorOutputPath: hono2.validatorOutputPath ? import_core8.upath.resolve(workspace, hono2.validatorOutputPath) : ""
|
|
3965
4058
|
};
|
|
3966
4059
|
};
|
|
3967
4060
|
var normalizeQueryOptions = (queryOptions = {}, outputWorkspace, globalOptions = {}) => {
|
|
@@ -3971,12 +4064,12 @@ var normalizeQueryOptions = (queryOptions = {}, outputWorkspace, globalOptions =
|
|
|
3971
4064
|
);
|
|
3972
4065
|
}
|
|
3973
4066
|
return {
|
|
3974
|
-
...!(0,
|
|
3975
|
-
...!(0,
|
|
3976
|
-
...!(0,
|
|
3977
|
-
...!(0,
|
|
3978
|
-
...!(0,
|
|
3979
|
-
...!(0,
|
|
4067
|
+
...!(0, import_core8.isUndefined)(queryOptions.usePrefetch) ? { usePrefetch: queryOptions.usePrefetch } : {},
|
|
4068
|
+
...!(0, import_core8.isUndefined)(queryOptions.useQuery) ? { useQuery: queryOptions.useQuery } : {},
|
|
4069
|
+
...!(0, import_core8.isUndefined)(queryOptions.useSuspenseQuery) ? { useSuspenseQuery: queryOptions.useSuspenseQuery } : {},
|
|
4070
|
+
...!(0, import_core8.isUndefined)(queryOptions.useMutation) ? { useMutation: queryOptions.useMutation } : {},
|
|
4071
|
+
...!(0, import_core8.isUndefined)(queryOptions.useInfinite) ? { useInfinite: queryOptions.useInfinite } : {},
|
|
4072
|
+
...!(0, import_core8.isUndefined)(queryOptions.useSuspenseInfiniteQuery) ? { useSuspenseInfiniteQuery: queryOptions.useSuspenseInfiniteQuery } : {},
|
|
3980
4073
|
...queryOptions.useInfiniteQueryParam ? { useInfiniteQueryParam: queryOptions.useInfiniteQueryParam } : {},
|
|
3981
4074
|
...queryOptions.options ? { options: queryOptions.options } : {},
|
|
3982
4075
|
...globalOptions.queryKey ? {
|
|
@@ -4003,30 +4096,30 @@ var normalizeQueryOptions = (queryOptions = {}, outputWorkspace, globalOptions =
|
|
|
4003
4096
|
queryOptions == null ? void 0 : queryOptions.mutationOptions
|
|
4004
4097
|
)
|
|
4005
4098
|
} : {},
|
|
4006
|
-
...!(0,
|
|
4099
|
+
...!(0, import_core8.isUndefined)(globalOptions.shouldExportQueryKey) ? {
|
|
4007
4100
|
shouldExportQueryKey: globalOptions.shouldExportQueryKey
|
|
4008
4101
|
} : {},
|
|
4009
|
-
...!(0,
|
|
4010
|
-
...!(0,
|
|
4102
|
+
...!(0, import_core8.isUndefined)(queryOptions.shouldExportQueryKey) ? { shouldExportQueryKey: queryOptions.shouldExportQueryKey } : {},
|
|
4103
|
+
...!(0, import_core8.isUndefined)(globalOptions.shouldExportHttpClient) ? {
|
|
4011
4104
|
shouldExportHttpClient: globalOptions.shouldExportHttpClient
|
|
4012
4105
|
} : {},
|
|
4013
|
-
...!(0,
|
|
4014
|
-
...!(0,
|
|
4106
|
+
...!(0, import_core8.isUndefined)(queryOptions.shouldExportHttpClient) ? { shouldExportHttpClient: queryOptions.shouldExportHttpClient } : {},
|
|
4107
|
+
...!(0, import_core8.isUndefined)(globalOptions.shouldExportMutatorHooks) ? {
|
|
4015
4108
|
shouldExportMutatorHooks: globalOptions.shouldExportMutatorHooks
|
|
4016
4109
|
} : {},
|
|
4017
|
-
...!(0,
|
|
4018
|
-
...!(0,
|
|
4110
|
+
...!(0, import_core8.isUndefined)(queryOptions.shouldExportMutatorHooks) ? { shouldExportMutatorHooks: queryOptions.shouldExportMutatorHooks } : {},
|
|
4111
|
+
...!(0, import_core8.isUndefined)(globalOptions.shouldSplitQueryKey) ? {
|
|
4019
4112
|
shouldSplitQueryKey: globalOptions.shouldSplitQueryKey
|
|
4020
4113
|
} : {},
|
|
4021
|
-
...!(0,
|
|
4022
|
-
...!(0,
|
|
4114
|
+
...!(0, import_core8.isUndefined)(queryOptions.shouldSplitQueryKey) ? { shouldSplitQueryKey: queryOptions.shouldSplitQueryKey } : {},
|
|
4115
|
+
...!(0, import_core8.isUndefined)(globalOptions.signal) ? {
|
|
4023
4116
|
signal: globalOptions.signal
|
|
4024
4117
|
} : {},
|
|
4025
|
-
...!(0,
|
|
4026
|
-
...!(0,
|
|
4118
|
+
...!(0, import_core8.isUndefined)(queryOptions.signal) ? { signal: queryOptions.signal } : {},
|
|
4119
|
+
...!(0, import_core8.isUndefined)(globalOptions.version) ? {
|
|
4027
4120
|
version: globalOptions.version
|
|
4028
4121
|
} : {},
|
|
4029
|
-
...!(0,
|
|
4122
|
+
...!(0, import_core8.isUndefined)(queryOptions.version) ? { version: queryOptions.version } : {}
|
|
4030
4123
|
};
|
|
4031
4124
|
};
|
|
4032
4125
|
var getDefaultFilesHeader = ({
|
|
@@ -4042,7 +4135,7 @@ var getDefaultFilesHeader = ({
|
|
|
4042
4135
|
];
|
|
4043
4136
|
|
|
4044
4137
|
// src/utils/watcher.ts
|
|
4045
|
-
var
|
|
4138
|
+
var import_core9 = require("@orval/core");
|
|
4046
4139
|
var startWatcher = async (watchOptions, watchFn, defaultTarget = ".") => {
|
|
4047
4140
|
if (!watchOptions) return;
|
|
4048
4141
|
const { watch } = await Promise.resolve().then(() => __toESM(require("chokidar")));
|
|
@@ -4050,7 +4143,7 @@ var startWatcher = async (watchOptions, watchFn, defaultTarget = ".") => {
|
|
|
4050
4143
|
const watchPaths = typeof watchOptions === "boolean" ? defaultTarget : Array.isArray(watchOptions) ? watchOptions.filter(
|
|
4051
4144
|
(path) => typeof path === "string"
|
|
4052
4145
|
) : watchOptions;
|
|
4053
|
-
(0,
|
|
4146
|
+
(0, import_core9.log)(
|
|
4054
4147
|
`Watching for changes in ${Array.isArray(watchPaths) ? watchPaths.map((v) => '"' + v + '"').join(" | ") : '"' + watchPaths + '"'}`
|
|
4055
4148
|
);
|
|
4056
4149
|
const watcher = watch(watchPaths, {
|
|
@@ -4058,40 +4151,40 @@ var startWatcher = async (watchOptions, watchFn, defaultTarget = ".") => {
|
|
|
4058
4151
|
ignored
|
|
4059
4152
|
});
|
|
4060
4153
|
watcher.on("all", async (type2, file) => {
|
|
4061
|
-
(0,
|
|
4154
|
+
(0, import_core9.log)(`Change detected: ${type2} ${file}`);
|
|
4062
4155
|
try {
|
|
4063
4156
|
await watchFn();
|
|
4064
4157
|
} catch (e) {
|
|
4065
|
-
(0,
|
|
4158
|
+
(0, import_core9.logError)(e);
|
|
4066
4159
|
}
|
|
4067
4160
|
});
|
|
4068
4161
|
};
|
|
4069
4162
|
|
|
4070
4163
|
// src/write-specs.ts
|
|
4071
|
-
var
|
|
4072
|
-
var
|
|
4164
|
+
var import_core11 = require("@orval/core");
|
|
4165
|
+
var import_chalk5 = __toESM(require("chalk"));
|
|
4073
4166
|
var import_execa2 = __toESM(require("execa"));
|
|
4074
4167
|
var import_fs_extra5 = __toESM(require("fs-extra"));
|
|
4075
4168
|
var import_lodash = __toESM(require("lodash.uniq"));
|
|
4076
4169
|
|
|
4077
4170
|
// src/utils/executeHook.ts
|
|
4078
|
-
var
|
|
4079
|
-
var
|
|
4171
|
+
var import_core10 = require("@orval/core");
|
|
4172
|
+
var import_chalk4 = __toESM(require("chalk"));
|
|
4080
4173
|
var import_execa = __toESM(require("execa"));
|
|
4081
4174
|
var import_string_argv = require("string-argv");
|
|
4082
4175
|
var executeHook = async (name, commands = [], args = []) => {
|
|
4083
|
-
(0,
|
|
4176
|
+
(0, import_core10.log)(import_chalk4.default.white(`Running ${name} hook...`));
|
|
4084
4177
|
for (const command of commands) {
|
|
4085
4178
|
try {
|
|
4086
|
-
if ((0,
|
|
4179
|
+
if ((0, import_core10.isString)(command)) {
|
|
4087
4180
|
await executeCommand(command, args);
|
|
4088
|
-
} else if ((0,
|
|
4181
|
+
} else if ((0, import_core10.isFunction)(command)) {
|
|
4089
4182
|
await command(args);
|
|
4090
|
-
} else if ((0,
|
|
4183
|
+
} else if ((0, import_core10.isObject)(command)) {
|
|
4091
4184
|
await executeObjectCommand(command, args);
|
|
4092
4185
|
}
|
|
4093
4186
|
} catch (e) {
|
|
4094
|
-
(0,
|
|
4187
|
+
(0, import_core10.logError)(e, `Failed to run ${name} hook`);
|
|
4095
4188
|
}
|
|
4096
4189
|
}
|
|
4097
4190
|
};
|
|
@@ -4103,9 +4196,9 @@ async function executeObjectCommand(command, args) {
|
|
|
4103
4196
|
if (command.injectGeneratedDirsAndFiles === false) {
|
|
4104
4197
|
args = [];
|
|
4105
4198
|
}
|
|
4106
|
-
if ((0,
|
|
4199
|
+
if ((0, import_core10.isString)(command.command)) {
|
|
4107
4200
|
await executeCommand(command.command, args);
|
|
4108
|
-
} else if ((0,
|
|
4201
|
+
} else if ((0, import_core10.isFunction)(command.command)) {
|
|
4109
4202
|
await command.command();
|
|
4110
4203
|
}
|
|
4111
4204
|
}
|
|
@@ -4116,7 +4209,7 @@ var getHeader = (option, info) => {
|
|
|
4116
4209
|
return "";
|
|
4117
4210
|
}
|
|
4118
4211
|
const header = option(info);
|
|
4119
|
-
return Array.isArray(header) ? (0,
|
|
4212
|
+
return Array.isArray(header) ? (0, import_core11.jsDoc)({ description: header }) : header;
|
|
4120
4213
|
};
|
|
4121
4214
|
var writeSpecs = async (builder, workspace, options, projectName) => {
|
|
4122
4215
|
var _a, _b;
|
|
@@ -4125,7 +4218,7 @@ var writeSpecs = async (builder, workspace, options, projectName) => {
|
|
|
4125
4218
|
const projectTitle = projectName || info.title;
|
|
4126
4219
|
const specsName = Object.keys(schemas).reduce(
|
|
4127
4220
|
(acc, specKey) => {
|
|
4128
|
-
const basePath =
|
|
4221
|
+
const basePath = import_core11.upath.getSpecName(specKey, target);
|
|
4129
4222
|
const name = basePath.slice(1).split("/").join("-");
|
|
4130
4223
|
acc[specKey] = name;
|
|
4131
4224
|
return acc;
|
|
@@ -4138,8 +4231,8 @@ var writeSpecs = async (builder, workspace, options, projectName) => {
|
|
|
4138
4231
|
const fileExtension = ["tags", "tags-split", "split"].includes(output.mode) ? ".ts" : (_a = output.fileExtension) != null ? _a : ".ts";
|
|
4139
4232
|
await Promise.all(
|
|
4140
4233
|
Object.entries(schemas).map(([specKey, schemas2]) => {
|
|
4141
|
-
const schemaPath = !(0,
|
|
4142
|
-
return (0,
|
|
4234
|
+
const schemaPath = !(0, import_core11.isRootKey)(specKey, target) ? import_core11.upath.join(rootSchemaPath, specsName[specKey]) : rootSchemaPath;
|
|
4235
|
+
return (0, import_core11.writeSchemas)({
|
|
4143
4236
|
schemaPath,
|
|
4144
4237
|
schemas: schemas2,
|
|
4145
4238
|
target,
|
|
@@ -4147,7 +4240,7 @@ var writeSpecs = async (builder, workspace, options, projectName) => {
|
|
|
4147
4240
|
fileExtension,
|
|
4148
4241
|
specsName,
|
|
4149
4242
|
specKey,
|
|
4150
|
-
isRootKey: (0,
|
|
4243
|
+
isRootKey: (0, import_core11.isRootKey)(specKey, target),
|
|
4151
4244
|
header,
|
|
4152
4245
|
indexFiles: output.indexFiles
|
|
4153
4246
|
});
|
|
@@ -4169,20 +4262,20 @@ var writeSpecs = async (builder, workspace, options, projectName) => {
|
|
|
4169
4262
|
if (output.workspace) {
|
|
4170
4263
|
const workspacePath = output.workspace;
|
|
4171
4264
|
const imports = implementationPaths.filter(
|
|
4172
|
-
(path) => !output.mock || !path.endsWith(`.${(0,
|
|
4265
|
+
(path) => !output.mock || !path.endsWith(`.${(0, import_core11.getMockFileExtensionByTypeName)(output.mock)}.ts`)
|
|
4173
4266
|
).map(
|
|
4174
|
-
(path) =>
|
|
4267
|
+
(path) => import_core11.upath.relativeSafe(
|
|
4175
4268
|
workspacePath,
|
|
4176
|
-
(0,
|
|
4269
|
+
(0, import_core11.getFileInfo)(path).pathWithoutExtension
|
|
4177
4270
|
)
|
|
4178
4271
|
);
|
|
4179
4272
|
if (output.schemas) {
|
|
4180
4273
|
imports.push(
|
|
4181
|
-
|
|
4274
|
+
import_core11.upath.relativeSafe(workspacePath, (0, import_core11.getFileInfo)(output.schemas).dirname)
|
|
4182
4275
|
);
|
|
4183
4276
|
}
|
|
4184
4277
|
if (output.indexFiles) {
|
|
4185
|
-
const indexFile =
|
|
4278
|
+
const indexFile = import_core11.upath.join(workspacePath, "/index.ts");
|
|
4186
4279
|
if (await import_fs_extra5.default.pathExists(indexFile)) {
|
|
4187
4280
|
const data = await import_fs_extra5.default.readFile(indexFile, "utf8");
|
|
4188
4281
|
const importsNotDeclared = imports.filter((imp) => !data.includes(imp));
|
|
@@ -4212,7 +4305,7 @@ var writeSpecs = async (builder, workspace, options, projectName) => {
|
|
|
4212
4305
|
];
|
|
4213
4306
|
}
|
|
4214
4307
|
const paths = [
|
|
4215
|
-
...output.schemas ? [(0,
|
|
4308
|
+
...output.schemas ? [(0, import_core11.getFileInfo)(output.schemas).dirname] : [],
|
|
4216
4309
|
...implementationPaths
|
|
4217
4310
|
];
|
|
4218
4311
|
if (options.hooks.afterAllFilesWrite) {
|
|
@@ -4226,8 +4319,8 @@ var writeSpecs = async (builder, workspace, options, projectName) => {
|
|
|
4226
4319
|
try {
|
|
4227
4320
|
await (0, import_execa2.default)("prettier", ["--write", ...paths]);
|
|
4228
4321
|
} catch {
|
|
4229
|
-
(0,
|
|
4230
|
-
|
|
4322
|
+
(0, import_core11.log)(
|
|
4323
|
+
import_chalk5.default.yellow(
|
|
4231
4324
|
`\u26A0\uFE0F ${projectTitle ? `${projectTitle} - ` : ""}Prettier not found`
|
|
4232
4325
|
)
|
|
4233
4326
|
);
|
|
@@ -4238,7 +4331,7 @@ var writeSpecs = async (builder, workspace, options, projectName) => {
|
|
|
4238
4331
|
await (0, import_execa2.default)("biome", ["check", "--write", ...paths]);
|
|
4239
4332
|
} catch (e) {
|
|
4240
4333
|
const message = e.exitCode === 1 ? e.stdout + e.stderr : `\u26A0\uFE0F ${projectTitle ? `${projectTitle} - ` : ""}biome not found`;
|
|
4241
|
-
(0,
|
|
4334
|
+
(0, import_core11.log)(import_chalk5.default.yellow(message));
|
|
4242
4335
|
}
|
|
4243
4336
|
}
|
|
4244
4337
|
if (output.docs) {
|
|
@@ -4277,22 +4370,22 @@ var writeSpecs = async (builder, workspace, options, projectName) => {
|
|
|
4277
4370
|
}
|
|
4278
4371
|
} catch (e) {
|
|
4279
4372
|
const message = e.exitCode === 1 ? e.stdout + e.stderr : `\u26A0\uFE0F ${projectTitle ? `${projectTitle} - ` : ""}Unable to generate docs`;
|
|
4280
|
-
(0,
|
|
4373
|
+
(0, import_core11.log)(import_chalk5.default.yellow(message));
|
|
4281
4374
|
}
|
|
4282
4375
|
}
|
|
4283
|
-
(0,
|
|
4376
|
+
(0, import_core11.createSuccessMessage)(projectTitle);
|
|
4284
4377
|
};
|
|
4285
4378
|
var getWriteMode = (mode) => {
|
|
4286
4379
|
switch (mode) {
|
|
4287
|
-
case
|
|
4288
|
-
return
|
|
4289
|
-
case
|
|
4290
|
-
return
|
|
4291
|
-
case
|
|
4292
|
-
return
|
|
4293
|
-
case
|
|
4380
|
+
case import_core11.OutputMode.SPLIT:
|
|
4381
|
+
return import_core11.writeSplitMode;
|
|
4382
|
+
case import_core11.OutputMode.TAGS:
|
|
4383
|
+
return import_core11.writeTagsMode;
|
|
4384
|
+
case import_core11.OutputMode.TAGS_SPLIT:
|
|
4385
|
+
return import_core11.writeSplitTagsMode;
|
|
4386
|
+
case import_core11.OutputMode.SINGLE:
|
|
4294
4387
|
default:
|
|
4295
|
-
return
|
|
4388
|
+
return import_core11.writeSingleMode;
|
|
4296
4389
|
}
|
|
4297
4390
|
};
|
|
4298
4391
|
|
|
@@ -4301,18 +4394,18 @@ var generateSpec = async (workspace, options, projectName) => {
|
|
|
4301
4394
|
if (options.output.clean) {
|
|
4302
4395
|
const extraPatterns = Array.isArray(options.output.clean) ? options.output.clean : [];
|
|
4303
4396
|
if (options.output.target) {
|
|
4304
|
-
await (0,
|
|
4397
|
+
await (0, import_core12.removeFiles)(
|
|
4305
4398
|
["**/*", "!**/*.d.ts", ...extraPatterns],
|
|
4306
|
-
(0,
|
|
4399
|
+
(0, import_core12.getFileInfo)(options.output.target).dirname
|
|
4307
4400
|
);
|
|
4308
4401
|
}
|
|
4309
4402
|
if (options.output.schemas) {
|
|
4310
|
-
await (0,
|
|
4403
|
+
await (0, import_core12.removeFiles)(
|
|
4311
4404
|
["**/*", "!**/*.d.ts", ...extraPatterns],
|
|
4312
|
-
(0,
|
|
4405
|
+
(0, import_core12.getFileInfo)(options.output.schemas).dirname
|
|
4313
4406
|
);
|
|
4314
4407
|
}
|
|
4315
|
-
(0,
|
|
4408
|
+
(0, import_core12.log)(`${projectName ? `${projectName}: ` : ""}Cleaning output folder`);
|
|
4316
4409
|
}
|
|
4317
4410
|
const writeSpecBuilder = await importSpecs(workspace, options);
|
|
4318
4411
|
await writeSpecs(writeSpecBuilder, workspace, options, projectName);
|
|
@@ -4324,24 +4417,24 @@ var generateSpecs = async (config, workspace, projectName) => {
|
|
|
4324
4417
|
try {
|
|
4325
4418
|
await generateSpec(workspace, options, projectName);
|
|
4326
4419
|
} catch (e) {
|
|
4327
|
-
(0,
|
|
4420
|
+
(0, import_core12.logError)(e, projectName);
|
|
4328
4421
|
process.exit(1);
|
|
4329
4422
|
}
|
|
4330
4423
|
} else {
|
|
4331
|
-
(0,
|
|
4424
|
+
(0, import_core12.logError)("Project not found");
|
|
4332
4425
|
process.exit(1);
|
|
4333
4426
|
}
|
|
4334
4427
|
return;
|
|
4335
4428
|
}
|
|
4336
4429
|
let hasErrors;
|
|
4337
|
-
const accumulate = await (0,
|
|
4430
|
+
const accumulate = await (0, import_core12.asyncReduce)(
|
|
4338
4431
|
Object.entries(config),
|
|
4339
4432
|
async (acc, [projectName2, options]) => {
|
|
4340
4433
|
try {
|
|
4341
4434
|
acc.push(await generateSpec(workspace, options, projectName2));
|
|
4342
4435
|
} catch (e) {
|
|
4343
4436
|
hasErrors = true;
|
|
4344
|
-
(0,
|
|
4437
|
+
(0, import_core12.logError)(e, projectName2);
|
|
4345
4438
|
}
|
|
4346
4439
|
return acc;
|
|
4347
4440
|
},
|
|
@@ -4355,15 +4448,15 @@ var generateConfig = async (configFile, options) => {
|
|
|
4355
4448
|
path,
|
|
4356
4449
|
file: configExternal,
|
|
4357
4450
|
error
|
|
4358
|
-
} = await (0,
|
|
4451
|
+
} = await (0, import_core12.loadFile)(configFile, {
|
|
4359
4452
|
defaultFileName: "orval.config"
|
|
4360
4453
|
});
|
|
4361
4454
|
if (!configExternal) {
|
|
4362
4455
|
throw `failed to load from ${path} => ${error}`;
|
|
4363
4456
|
}
|
|
4364
|
-
const workspace =
|
|
4365
|
-
const config = await ((0,
|
|
4366
|
-
const normalizedConfig = await (0,
|
|
4457
|
+
const workspace = import_core12.upath.dirname(path);
|
|
4458
|
+
const config = await ((0, import_core12.isFunction)(configExternal) ? configExternal() : configExternal);
|
|
4459
|
+
const normalizedConfig = await (0, import_core12.asyncReduce)(
|
|
4367
4460
|
Object.entries(config),
|
|
4368
4461
|
async (acc, [key, value]) => {
|
|
4369
4462
|
acc[key] = await normalizeOptions(value, workspace, options);
|
|
@@ -4373,7 +4466,7 @@ var generateConfig = async (configFile, options) => {
|
|
|
4373
4466
|
);
|
|
4374
4467
|
const fileToWatch = Object.entries(normalizedConfig).filter(
|
|
4375
4468
|
([project]) => (options == null ? void 0 : options.projectName) === void 0 || project === (options == null ? void 0 : options.projectName)
|
|
4376
|
-
).map(([, { input }]) => input.target).filter((target) => (0,
|
|
4469
|
+
).map(([, { input }]) => input.target).filter((target) => (0, import_core12.isString)(target));
|
|
4377
4470
|
if ((options == null ? void 0 : options.watch) && fileToWatch.length) {
|
|
4378
4471
|
startWatcher(
|
|
4379
4472
|
options == null ? void 0 : options.watch,
|
|
@@ -4388,7 +4481,7 @@ var generateConfig = async (configFile, options) => {
|
|
|
4388
4481
|
// src/index.ts
|
|
4389
4482
|
__reExport(src_exports, require("@orval/core"), module.exports);
|
|
4390
4483
|
var generate = async (optionsExport, workspace = process.cwd(), options) => {
|
|
4391
|
-
if (!optionsExport || (0,
|
|
4484
|
+
if (!optionsExport || (0, import_core13.isString)(optionsExport)) {
|
|
4392
4485
|
return generateConfig(optionsExport, options);
|
|
4393
4486
|
}
|
|
4394
4487
|
const normalizedOptions = await normalizeOptions(
|
|
@@ -4403,7 +4496,7 @@ var generate = async (optionsExport, workspace = process.cwd(), options) => {
|
|
|
4403
4496
|
try {
|
|
4404
4497
|
await generateSpec(workspace, normalizedOptions);
|
|
4405
4498
|
} catch (e) {
|
|
4406
|
-
(0,
|
|
4499
|
+
(0, import_core13.logError)(e, options == null ? void 0 : options.projectName);
|
|
4407
4500
|
}
|
|
4408
4501
|
},
|
|
4409
4502
|
normalizedOptions.input.target
|
|
@@ -4412,7 +4505,7 @@ var generate = async (optionsExport, workspace = process.cwd(), options) => {
|
|
|
4412
4505
|
try {
|
|
4413
4506
|
return await generateSpec(workspace, normalizedOptions);
|
|
4414
4507
|
} catch (e) {
|
|
4415
|
-
(0,
|
|
4508
|
+
(0, import_core13.logError)(e, options == null ? void 0 : options.projectName);
|
|
4416
4509
|
}
|
|
4417
4510
|
}
|
|
4418
4511
|
};
|