@orval/core 8.19.0 → 8.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.d.mts +59 -5
- package/dist/index.mjs +142 -91
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { t as __exportAll } from "./chunk-8H4AJuhK.mjs";
|
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { entries, groupBy, isArray, isBoolean, isBoolean as isBoolean$1, isEmptyish, isFunction, isFunction as isFunction$1, isNullish, isNullish as isNullish$1, isNumber, isString, isString as isString$1, prop, unique, uniqueBy, uniqueWith } from "remeda";
|
|
4
4
|
import { keyword } from "esutils";
|
|
5
|
-
import
|
|
5
|
+
import nodePath from "node:path";
|
|
6
6
|
import { compare } from "compare-versions";
|
|
7
7
|
import debug from "debug";
|
|
8
8
|
import { pathToFileURL } from "node:url";
|
|
@@ -74,12 +74,13 @@ const FormDataArrayHandling = {
|
|
|
74
74
|
SERIALIZE_WITH_BRACKETS: "serialize-with-brackets"
|
|
75
75
|
};
|
|
76
76
|
const Verbs = {
|
|
77
|
-
POST: "post",
|
|
78
|
-
PUT: "put",
|
|
79
77
|
GET: "get",
|
|
80
|
-
|
|
78
|
+
PUT: "put",
|
|
79
|
+
POST: "post",
|
|
81
80
|
DELETE: "delete",
|
|
82
|
-
|
|
81
|
+
OPTIONS: "options",
|
|
82
|
+
HEAD: "head",
|
|
83
|
+
PATCH: "patch"
|
|
83
84
|
};
|
|
84
85
|
/**
|
|
85
86
|
* Canonical tag name used for the generated bucket that collects untagged operations.
|
|
@@ -168,7 +169,7 @@ function isDynamicReference(obj) {
|
|
|
168
169
|
* @param pathValue - Path string to inspect.
|
|
169
170
|
*/
|
|
170
171
|
function isDirectory(pathValue) {
|
|
171
|
-
return !
|
|
172
|
+
return !nodePath.extname(pathValue);
|
|
172
173
|
}
|
|
173
174
|
/**
|
|
174
175
|
* Type guard for plain objects created with `{}` or `new Object()`.
|
|
@@ -369,10 +370,17 @@ function conventionName(name, convention) {
|
|
|
369
370
|
}
|
|
370
371
|
//#endregion
|
|
371
372
|
//#region src/utils/compare-version.ts
|
|
373
|
+
const getComparableVersion = (version) => {
|
|
374
|
+
const npmAliasVersion = version.match(/^npm:(?:@[^/]+\/)?[^@]+@(.+)$/)?.[1];
|
|
375
|
+
if (npmAliasVersion) return npmAliasVersion;
|
|
376
|
+
if (version.startsWith("npm:")) return "latest";
|
|
377
|
+
return version;
|
|
378
|
+
};
|
|
372
379
|
function compareVersions(firstVersion, secondVersions, operator = ">=") {
|
|
373
|
-
|
|
374
|
-
if (
|
|
375
|
-
|
|
380
|
+
const comparableVersion = getComparableVersion(firstVersion);
|
|
381
|
+
if (comparableVersion === "latest" || comparableVersion === "*") return true;
|
|
382
|
+
if (comparableVersion.startsWith("catalog:")) return true;
|
|
383
|
+
return compare(comparableVersion.replace(/(\s(.*))/, ""), secondVersions, operator);
|
|
376
384
|
}
|
|
377
385
|
//#endregion
|
|
378
386
|
//#region src/utils/content-type.ts
|
|
@@ -560,8 +568,8 @@ async function dynamicImport(toImport, from = process.cwd(), takeDefault = true)
|
|
|
560
568
|
if (!toImport) return toImport;
|
|
561
569
|
try {
|
|
562
570
|
if (isString(toImport)) {
|
|
563
|
-
const filePath =
|
|
564
|
-
const extension =
|
|
571
|
+
const filePath = nodePath.resolve(from, toImport);
|
|
572
|
+
const extension = nodePath.extname(filePath);
|
|
565
573
|
if (TS_MODULE_EXTENSIONS.has(extension)) {
|
|
566
574
|
const data = await createJiti(from, { interopDefault: true }).import(filePath);
|
|
567
575
|
if (takeDefault && (isObject(data) || isModule(data)) && data.default) return data.default;
|
|
@@ -586,14 +594,14 @@ function getExtension(path) {
|
|
|
586
594
|
//#region src/utils/file.ts
|
|
587
595
|
function getFileInfo(target = "", { backupFilename = "filename", extension = ".ts" } = {}) {
|
|
588
596
|
const isDir = isDirectory(target);
|
|
589
|
-
const filePath = isDir ?
|
|
597
|
+
const filePath = isDir ? nodePath.join(target, backupFilename + extension) : target;
|
|
590
598
|
return {
|
|
591
599
|
path: filePath,
|
|
592
600
|
pathWithoutExtension: filePath.replace(/\.[^/.]+$/, ""),
|
|
593
601
|
extension,
|
|
594
602
|
isDirectory: isDir,
|
|
595
|
-
dirname:
|
|
596
|
-
filename:
|
|
603
|
+
dirname: nodePath.dirname(filePath),
|
|
604
|
+
filename: nodePath.basename(filePath, extension.startsWith(".") ? extension : `.${extension}`)
|
|
597
605
|
};
|
|
598
606
|
}
|
|
599
607
|
async function removeFilesAndEmptyFolders(patterns, dir) {
|
|
@@ -804,10 +812,10 @@ var path_exports = /* @__PURE__ */ __exportAll({
|
|
|
804
812
|
toUnix: () => toUnix
|
|
805
813
|
});
|
|
806
814
|
function isAbsolute(value) {
|
|
807
|
-
return
|
|
815
|
+
return nodePath.isAbsolute(value);
|
|
808
816
|
}
|
|
809
817
|
function resolve(...args) {
|
|
810
|
-
return toUnix(
|
|
818
|
+
return toUnix(nodePath.resolve(...args));
|
|
811
819
|
}
|
|
812
820
|
function toUnix(value) {
|
|
813
821
|
value = value.replaceAll("\\", "/");
|
|
@@ -815,13 +823,13 @@ function toUnix(value) {
|
|
|
815
823
|
return value;
|
|
816
824
|
}
|
|
817
825
|
function join(...args) {
|
|
818
|
-
return toUnix(
|
|
826
|
+
return toUnix(nodePath.join(...args.map((a) => toUnix(a))));
|
|
819
827
|
}
|
|
820
828
|
/**
|
|
821
829
|
* Behaves exactly like `path.relative(from, to)`, but keeps the first meaningful "./"
|
|
822
830
|
*/
|
|
823
831
|
function relativeSafe(from, to) {
|
|
824
|
-
return normalizeSafe(`./${toUnix(
|
|
832
|
+
return normalizeSafe(`./${toUnix(nodePath.relative(toUnix(from), toUnix(to)))}`);
|
|
825
833
|
}
|
|
826
834
|
function getSchemaFileName(path) {
|
|
827
835
|
return path.replace(`.${getExtension(path)}`, "").slice(path.lastIndexOf("/") + 1);
|
|
@@ -829,13 +837,13 @@ function getSchemaFileName(path) {
|
|
|
829
837
|
function normalizeSafe(value) {
|
|
830
838
|
let result;
|
|
831
839
|
value = toUnix(value);
|
|
832
|
-
result = toUnix(
|
|
840
|
+
result = toUnix(nodePath.normalize(value));
|
|
833
841
|
if (value.startsWith("./") && !result.startsWith("./") && !result.startsWith("..")) result = "./" + result;
|
|
834
842
|
else if (value.startsWith("//") && !result.startsWith("//")) result = value.startsWith("//./") ? "//." + result : "/" + result;
|
|
835
843
|
return result;
|
|
836
844
|
}
|
|
837
845
|
function joinSafe(...values) {
|
|
838
|
-
let result = toUnix(
|
|
846
|
+
let result = toUnix(nodePath.join(...values.map((v) => toUnix(v))));
|
|
839
847
|
if (values.length > 0) {
|
|
840
848
|
const firstValue = toUnix(values[0]);
|
|
841
849
|
if (firstValue.startsWith("./") && !result.startsWith("./") && !result.startsWith("..")) result = "./" + result;
|
|
@@ -866,14 +874,14 @@ function joinSafe(...values) {
|
|
|
866
874
|
* @returns The relative import path string.
|
|
867
875
|
*/
|
|
868
876
|
function getRelativeImportPath(importerFilePath, exporterFilePath, includeFileExtension = false) {
|
|
869
|
-
if (!
|
|
870
|
-
if (!
|
|
871
|
-
const importerDir =
|
|
872
|
-
const relativePath =
|
|
873
|
-
let posixPath =
|
|
877
|
+
if (!nodePath.isAbsolute(importerFilePath)) throw new Error(`'importerFilePath' is not an absolute path. "${importerFilePath}"`);
|
|
878
|
+
if (!nodePath.isAbsolute(exporterFilePath)) throw new Error(`'exporterFilePath' is not an absolute path. "${exporterFilePath}"`);
|
|
879
|
+
const importerDir = nodePath.dirname(importerFilePath);
|
|
880
|
+
const relativePath = nodePath.relative(importerDir, exporterFilePath);
|
|
881
|
+
let posixPath = nodePath.posix.join(...relativePath.split(nodePath.sep));
|
|
874
882
|
if (!posixPath.startsWith("./") && !posixPath.startsWith("../")) posixPath = `./${posixPath}`;
|
|
875
883
|
if (!includeFileExtension) {
|
|
876
|
-
const ext =
|
|
884
|
+
const ext = nodePath.extname(posixPath);
|
|
877
885
|
if (ext && posixPath.endsWith(ext)) posixPath = posixPath.slice(0, -ext.length);
|
|
878
886
|
}
|
|
879
887
|
return posixPath;
|
|
@@ -882,20 +890,20 @@ function getRelativeImportPath(importerFilePath, exporterFilePath, includeFileEx
|
|
|
882
890
|
//#region src/utils/resolve-version.ts
|
|
883
891
|
function resolveInstalledVersion(packageName, fromDir) {
|
|
884
892
|
try {
|
|
885
|
-
const require = createRequire(
|
|
893
|
+
const require = createRequire(nodePath.join(fromDir, "noop.js"));
|
|
886
894
|
try {
|
|
887
895
|
return require(`${packageName}/package.json`).version;
|
|
888
896
|
} catch (directError) {
|
|
889
897
|
if (directError instanceof Error && "code" in directError && directError.code === "ERR_PACKAGE_PATH_NOT_EXPORTED") {
|
|
890
898
|
const entryPath = require.resolve(packageName);
|
|
891
|
-
let dir =
|
|
892
|
-
while (dir !==
|
|
893
|
-
const pkgPath =
|
|
899
|
+
let dir = nodePath.dirname(entryPath);
|
|
900
|
+
while (dir !== nodePath.parse(dir).root) {
|
|
901
|
+
const pkgPath = nodePath.join(dir, "package.json");
|
|
894
902
|
if (existsSync(pkgPath)) {
|
|
895
903
|
const pkgData = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
896
904
|
if (pkgData.name === packageName) return pkgData.version;
|
|
897
905
|
}
|
|
898
|
-
dir =
|
|
906
|
+
dir = nodePath.dirname(dir);
|
|
899
907
|
}
|
|
900
908
|
return;
|
|
901
909
|
}
|
|
@@ -1635,7 +1643,7 @@ function combineSchemas({ name, schema, separator, context, nullable, formDataCo
|
|
|
1635
1643
|
hasReadonlyProps: false,
|
|
1636
1644
|
example: schema.example,
|
|
1637
1645
|
examples: resolveExampleRefs(schema.examples, context),
|
|
1638
|
-
requiredProperties: separator === "allOf" ?
|
|
1646
|
+
requiredProperties: separator === "allOf" ? [...normalizedSchema.required ?? []] : []
|
|
1639
1647
|
};
|
|
1640
1648
|
for (const subSchema of items) {
|
|
1641
1649
|
let propName;
|
|
@@ -1643,7 +1651,6 @@ function combineSchemas({ name, schema, separator, context, nullable, formDataCo
|
|
|
1643
1651
|
propName = name ? name + pascal(separator) : void 0;
|
|
1644
1652
|
if (propName && resolvedData.schemas.length > 0) propName = propName + pascal(getNumberWord(resolvedData.schemas.length + 1));
|
|
1645
1653
|
}
|
|
1646
|
-
if (separator === "allOf" && isSchema(subSchema) && subSchema.required) resolvedData.requiredProperties.push(...subSchema.required);
|
|
1647
1654
|
const resolvedValue = resolveObject({
|
|
1648
1655
|
schema: subSchema,
|
|
1649
1656
|
propName,
|
|
@@ -1651,6 +1658,10 @@ function combineSchemas({ name, schema, separator, context, nullable, formDataCo
|
|
|
1651
1658
|
context,
|
|
1652
1659
|
formDataContext
|
|
1653
1660
|
});
|
|
1661
|
+
if (separator === "allOf") {
|
|
1662
|
+
const memberRequired = resolvedValue.originalSchema?.required;
|
|
1663
|
+
if (Array.isArray(memberRequired)) resolvedData.requiredProperties.push(...memberRequired);
|
|
1664
|
+
}
|
|
1654
1665
|
const aliasedImports = getAliasedImports({
|
|
1655
1666
|
context,
|
|
1656
1667
|
name,
|
|
@@ -2581,27 +2592,59 @@ function buildInlineDynamicScope(schema) {
|
|
|
2581
2592
|
return scope;
|
|
2582
2593
|
}
|
|
2583
2594
|
/**
|
|
2595
|
+
* Lazily build and memoize the `$dynamicAnchor` index on the context.
|
|
2596
|
+
*
|
|
2597
|
+
* Scans `components.schemas` once per spec and stores, per anchor name, the
|
|
2598
|
+
* compact match info required by the {@link resolveDynamicRef} fallback (see
|
|
2599
|
+
* {@link DynamicAnchorIndexEntry}). Subsequent fallback lookups are O(1)
|
|
2600
|
+
* instead of re-scanning every schema per `$dynamicRef`.
|
|
2601
|
+
*
|
|
2602
|
+
* Recording of non-exact matches stops once `count >= 2` — the fallback only
|
|
2603
|
+
* distinguishes "exactly one non-exact" from "ambiguous", so further non-exact
|
|
2604
|
+
* names are irrelevant. Iteration continues regardless because a later schema
|
|
2605
|
+
* whose key equals the anchor name is still the definitive (`exactName`)
|
|
2606
|
+
* winner. This is the safe form of "bail early when ambiguous": a literal
|
|
2607
|
+
* early-return at `count === 2` would regress the exact-name rule when the
|
|
2608
|
+
* exact schema appears later in iteration order.
|
|
2609
|
+
*/
|
|
2610
|
+
function getDynamicAnchorIndex(context) {
|
|
2611
|
+
const cached = context.dynamicAnchorIndex;
|
|
2612
|
+
if (cached) return cached;
|
|
2613
|
+
const index = /* @__PURE__ */ new Map();
|
|
2614
|
+
const schemas = context.spec.components?.schemas;
|
|
2615
|
+
if (schemas && typeof schemas === "object") for (const [schemaName, schemaObj] of Object.entries(schemas)) {
|
|
2616
|
+
if (!schemaObj || typeof schemaObj !== "object") continue;
|
|
2617
|
+
const anchor = schemaObj.$dynamicAnchor;
|
|
2618
|
+
if (typeof anchor !== "string") continue;
|
|
2619
|
+
let entry = index.get(anchor);
|
|
2620
|
+
if (!entry) {
|
|
2621
|
+
entry = { count: 0 };
|
|
2622
|
+
index.set(anchor, entry);
|
|
2623
|
+
}
|
|
2624
|
+
if (schemaName === anchor) entry.exactName = schemaName;
|
|
2625
|
+
else if (entry.count < 2) {
|
|
2626
|
+
entry.count += 1;
|
|
2627
|
+
if (!entry.firstName) entry.firstName = schemaName;
|
|
2628
|
+
}
|
|
2629
|
+
}
|
|
2630
|
+
context.dynamicAnchorIndex = index;
|
|
2631
|
+
return index;
|
|
2632
|
+
}
|
|
2633
|
+
/**
|
|
2584
2634
|
* Resolve a `$dynamicRef` anchor to its concrete type using the current dynamic scope.
|
|
2585
2635
|
* Returns `{ schema: {}, resolvedTypeName: 'unknown' }` when no scope override exists.
|
|
2586
2636
|
*/
|
|
2587
2637
|
function resolveDynamicRef(anchorName, context, imports = []) {
|
|
2588
2638
|
let scopeEntry = (context.dynamicScope ?? {})[anchorName];
|
|
2589
2639
|
if (!scopeEntry) {
|
|
2590
|
-
const
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
if (match) {
|
|
2599
|
-
const refInfo = getRefInfo(`#/components/schemas/${encodeJsonPointerSegment(match)}`, context);
|
|
2600
|
-
scopeEntry = {
|
|
2601
|
-
name: refInfo.name,
|
|
2602
|
-
schemaName: refInfo.originalName
|
|
2603
|
-
};
|
|
2604
|
-
}
|
|
2640
|
+
const entry = getDynamicAnchorIndex(context).get(anchorName);
|
|
2641
|
+
const match = entry?.exactName ?? (entry?.count === 1 ? entry?.firstName : void 0);
|
|
2642
|
+
if (match) {
|
|
2643
|
+
const refInfo = getRefInfo(`#/components/schemas/${encodeJsonPointerSegment(match)}`, context);
|
|
2644
|
+
scopeEntry = {
|
|
2645
|
+
name: refInfo.name,
|
|
2646
|
+
schemaName: refInfo.originalName
|
|
2647
|
+
};
|
|
2605
2648
|
}
|
|
2606
2649
|
}
|
|
2607
2650
|
if (!scopeEntry) return {
|
|
@@ -4721,8 +4764,9 @@ function parseFunction(ast, funcName) {
|
|
|
4721
4764
|
//#region src/generators/mutator.ts
|
|
4722
4765
|
const BODY_TYPE_NAME = "BodyType";
|
|
4723
4766
|
const getImport = (output, mutator, tsconfig) => {
|
|
4767
|
+
if (mutator.resolvedPath || !nodePath.isAbsolute(mutator.path)) return mutator.path;
|
|
4724
4768
|
const outputFile = getFileInfo(output).path;
|
|
4725
|
-
const ext = mutator.extension ?? getImportExtension(
|
|
4769
|
+
const ext = mutator.extension ?? getImportExtension(nodePath.extname(mutator.path), tsconfig);
|
|
4726
4770
|
return `${getRelativeImportPath(outputFile, mutator.path)}${ext}`;
|
|
4727
4771
|
};
|
|
4728
4772
|
async function generateMutator({ output, mutator, name, workspace, tsconfig }) {
|
|
@@ -4730,15 +4774,16 @@ async function generateMutator({ output, mutator, name, workspace, tsconfig }) {
|
|
|
4730
4774
|
const isDefault = mutator.default;
|
|
4731
4775
|
const importName = mutator.name ?? `${name}Mutator`;
|
|
4732
4776
|
const importPath = mutator.path;
|
|
4777
|
+
const inspectionPath = mutator.resolvedPath ?? mutator.path;
|
|
4733
4778
|
const mutatorInfoName = isDefault ? "default" : mutator.name;
|
|
4734
4779
|
if (mutatorInfoName === void 0) throw new Error(styleText("red", `Mutator ${importPath} must have a named or default export.`));
|
|
4735
|
-
let rawFile = await fs$1.readFile(
|
|
4780
|
+
let rawFile = nodePath.isAbsolute(inspectionPath) ? await fs$1.readFile(inspectionPath, "utf8") : "";
|
|
4736
4781
|
rawFile = removeComments(rawFile);
|
|
4737
|
-
const hasErrorType = rawFile.includes("export type ErrorType") || rawFile.includes("export interface ErrorType");
|
|
4738
|
-
const hasBodyType = rawFile.includes(`export type BodyType`) || rawFile.includes(`export interface BodyType`);
|
|
4782
|
+
const hasErrorType = !!rawFile && (rawFile.includes("export type ErrorType") || rawFile.includes("export interface ErrorType"));
|
|
4783
|
+
const hasBodyType = !!rawFile && (rawFile.includes(`export type BodyType`) || rawFile.includes(`export interface BodyType`));
|
|
4739
4784
|
const errorTypeName = mutator.default ? `${pascal(name)}ErrorType` : "ErrorType";
|
|
4740
4785
|
const bodyTypeName = mutator.default ? `${pascal(name)}${BODY_TYPE_NAME}` : BODY_TYPE_NAME;
|
|
4741
|
-
const mutatorInfo = await getMutatorInfo(
|
|
4786
|
+
const mutatorInfo = await getMutatorInfo(inspectionPath, {
|
|
4742
4787
|
root: workspace,
|
|
4743
4788
|
namedExport: mutatorInfoName,
|
|
4744
4789
|
alias: mutator.alias,
|
|
@@ -5773,8 +5818,8 @@ function getSchema({ schema: { imports, model }, header, namingConvention = Nami
|
|
|
5773
5818
|
file += model;
|
|
5774
5819
|
return file;
|
|
5775
5820
|
}
|
|
5776
|
-
function getPath(path
|
|
5777
|
-
return
|
|
5821
|
+
function getPath(path, name, fileExtension) {
|
|
5822
|
+
return nodePath.join(path, `${name}${fileExtension}`);
|
|
5778
5823
|
}
|
|
5779
5824
|
function writeModelInline(acc, model) {
|
|
5780
5825
|
return acc + `${model}\n`;
|
|
@@ -5867,14 +5912,14 @@ async function writeSchemas({ schemaPath, schemas, target, namingConvention, fil
|
|
|
5867
5912
|
await writeGeneratedFile(getPath(factoryDir, factoryFileName, fileExtension), factoryFile);
|
|
5868
5913
|
}
|
|
5869
5914
|
if (indexFiles) {
|
|
5870
|
-
const schemaFilePath =
|
|
5915
|
+
const schemaFilePath = nodePath.join(schemaPath, `index.ts`);
|
|
5871
5916
|
await fs$1.ensureFile(schemaFilePath);
|
|
5872
5917
|
const ext = getImportExtension(fileExtension, tsconfig);
|
|
5873
5918
|
const conventionNamesSet = new Set(Object.values(schemaGroups).map((group) => conventionName(group[0].name, namingConvention)));
|
|
5874
5919
|
try {
|
|
5875
5920
|
const currentExports = [...conventionNamesSet].map((schemaName) => `export * from './${schemaName}${ext}';`);
|
|
5876
5921
|
if (factoryOutputDirectory && normalizeSafe(factoryOutputDirectory) !== normalizeSafe(schemaPath) && (isCombined.value || separateFactoryNames.length > 0)) {
|
|
5877
|
-
const factoryIndexFilePath =
|
|
5922
|
+
const factoryIndexFilePath = nodePath.join(factoryOutputDirectory, `index.ts`);
|
|
5878
5923
|
await fs$1.ensureFile(factoryIndexFilePath);
|
|
5879
5924
|
const factoryExports = [];
|
|
5880
5925
|
if (isCombined.value) {
|
|
@@ -5909,9 +5954,9 @@ async function writeSchemasTagsSplit({ schemaPath, schemas, target, namingConven
|
|
|
5909
5954
|
}
|
|
5910
5955
|
for (const [groupDir, groupSchemas] of groups) {
|
|
5911
5956
|
const isRoot = groupDir === ".";
|
|
5912
|
-
const groupPath = isRoot ? schemaPath :
|
|
5957
|
+
const groupPath = isRoot ? schemaPath : nodePath.join(schemaPath, groupDir);
|
|
5913
5958
|
fixCrossTagImports(groupSchemas, schemaTagMap, schemaPath, groupDir, namingConvention, importExtension);
|
|
5914
|
-
const groupFactoryDir = factoryOutputDirectory ? isRoot ? factoryOutputDirectory :
|
|
5959
|
+
const groupFactoryDir = factoryOutputDirectory ? isRoot ? factoryOutputDirectory : nodePath.join(factoryOutputDirectory, groupDir) : void 0;
|
|
5915
5960
|
await writeSchemas({
|
|
5916
5961
|
schemaPath: groupPath,
|
|
5917
5962
|
schemas: groupSchemas,
|
|
@@ -5925,7 +5970,7 @@ async function writeSchemasTagsSplit({ schemaPath, schemas, target, namingConven
|
|
|
5925
5970
|
});
|
|
5926
5971
|
}
|
|
5927
5972
|
if (indexFiles && groups.size > 0) {
|
|
5928
|
-
const rootIndexPath =
|
|
5973
|
+
const rootIndexPath = nodePath.join(schemaPath, "index.ts");
|
|
5929
5974
|
const rootExports = (groups.get(".") ?? []).map((s) => {
|
|
5930
5975
|
return `export * from './${conventionName(s.name, namingConvention)}${importExtension}';`;
|
|
5931
5976
|
});
|
|
@@ -5936,12 +5981,12 @@ async function writeSchemasTagsSplit({ schemaPath, schemas, target, namingConven
|
|
|
5936
5981
|
}
|
|
5937
5982
|
}
|
|
5938
5983
|
function fixCrossTagImports(schemas, schemaTagMap, schemaPath, currentGroupDir, namingConvention, importExtension) {
|
|
5939
|
-
const fromPath = currentGroupDir === "." ? schemaPath :
|
|
5984
|
+
const fromPath = currentGroupDir === "." ? schemaPath : nodePath.join(schemaPath, currentGroupDir);
|
|
5940
5985
|
for (const schema of schemas) {
|
|
5941
5986
|
const fixImports = (imports) => imports.map((imp) => {
|
|
5942
5987
|
const targetGroup = schemaTagMap.get(imp.name);
|
|
5943
5988
|
if (targetGroup === void 0 || targetGroup === currentGroupDir) return imp;
|
|
5944
|
-
const importPath = joinSafe(relativeSafe(fromPath, targetGroup === "." ? schemaPath :
|
|
5989
|
+
const importPath = joinSafe(relativeSafe(fromPath, targetGroup === "." ? schemaPath : nodePath.join(schemaPath, targetGroup)), conventionName(imp.name, namingConvention)) + importExtension;
|
|
5945
5990
|
return {
|
|
5946
5991
|
...imp,
|
|
5947
5992
|
importPath
|
|
@@ -6129,11 +6174,17 @@ function hasAnyMockPath(mockConfig) {
|
|
|
6129
6174
|
return mockConfig.generators.some((g) => !isFunction(g) && !!g.path);
|
|
6130
6175
|
}
|
|
6131
6176
|
function resolveMockSchemasPath(mockFilePath, schemasTarget) {
|
|
6132
|
-
const ext =
|
|
6133
|
-
const targetExt =
|
|
6177
|
+
const ext = nodePath.extname(mockFilePath);
|
|
6178
|
+
const targetExt = nodePath.extname(schemasTarget);
|
|
6134
6179
|
return getRelativeImportPath(mockFilePath, targetExt === ".schemas" ? schemasTarget + ext : targetExt ? schemasTarget : schemasTarget + ext);
|
|
6135
6180
|
}
|
|
6136
6181
|
//#endregion
|
|
6182
|
+
//#region src/writers/typescript-version.ts
|
|
6183
|
+
const getTypeScriptVersion = (packageJson) => {
|
|
6184
|
+
return packageJson?.resolvedVersions?.typescript ?? packageJson?.dependencies?.typescript ?? packageJson?.devDependencies?.typescript ?? packageJson?.peerDependencies?.typescript ?? "4.4.0";
|
|
6185
|
+
};
|
|
6186
|
+
const hasTypeScriptAwaitedType = (packageJson) => compareVersions(getTypeScriptVersion(packageJson), "4.5.0");
|
|
6187
|
+
//#endregion
|
|
6137
6188
|
//#region src/writers/target.ts
|
|
6138
6189
|
function emptyMockOutputFull$1(type) {
|
|
6139
6190
|
return {
|
|
@@ -6209,7 +6260,7 @@ function generateTarget(builder, options) {
|
|
|
6209
6260
|
if (operation.fetchReviver) target.fetchReviver.push(operation.fetchReviver);
|
|
6210
6261
|
if (index === operations.length - 1) {
|
|
6211
6262
|
const isMutator = target.mutators.some((mutator) => isAngularClient ? mutator.hasThirdArg : mutator.hasSecondArg);
|
|
6212
|
-
const hasAwaitedType =
|
|
6263
|
+
const hasAwaitedType = hasTypeScriptAwaitedType(options.packageJson);
|
|
6213
6264
|
const header = builder.header({
|
|
6214
6265
|
outputClient: options.client,
|
|
6215
6266
|
isRequestOptions: options.override.requestOptions !== false,
|
|
@@ -6387,7 +6438,7 @@ async function writeSingleMode({ builder, output, projectName, header, needSchem
|
|
|
6387
6438
|
if (!rawEntry) continue;
|
|
6388
6439
|
const mockExtension = isFunction(rawEntry) ? OutputMockType.MSW : getMockFileExtensionByTypeName(rawEntry);
|
|
6389
6440
|
const mockDir = getMockDir(rawEntry, output.mock) ?? dirname;
|
|
6390
|
-
const mockFilePath =
|
|
6441
|
+
const mockFilePath = nodePath.join(mockDir, filename + "." + mockExtension + extension);
|
|
6391
6442
|
const mockRelativeSchemasPath = schemaCustomImportPath ?? resolveMockSchemasPath(mockFilePath, schemasTarget);
|
|
6392
6443
|
const finalizeMockOptions = getFinalizeMockImplementationOptions(output, mockOutput);
|
|
6393
6444
|
const finalizedMockImplementation = builder.finalizeMockImplementation ? builder.finalizeMockImplementation(mockOutput.implementation, finalizeMockOptions) : mockOutput.implementation;
|
|
@@ -6417,7 +6468,7 @@ async function writeSingleMode({ builder, output, projectName, header, needSchem
|
|
|
6417
6468
|
if (output.mock.indexMockFiles) {
|
|
6418
6469
|
const importExtension = getImportExtension(output.fileExtension, output.tsconfig);
|
|
6419
6470
|
for (const { extension: mockExt, mockDir } of writtenMockEntries) {
|
|
6420
|
-
const indexMockPath =
|
|
6471
|
+
const indexMockPath = nodePath.join(mockDir, `index.${mockExt}${extension}`);
|
|
6421
6472
|
await writeGeneratedFile(indexMockPath, `export * from './${filename}.${mockExt}${importExtension}'\n`);
|
|
6422
6473
|
extraPaths.push(indexMockPath);
|
|
6423
6474
|
}
|
|
@@ -6441,7 +6492,7 @@ async function writeSplitMode({ builder, output, projectName, header, needSchema
|
|
|
6441
6492
|
let implementationData = header;
|
|
6442
6493
|
const schemaCustomImportPath = getSchemasImportPath(output.schemas);
|
|
6443
6494
|
const relativeSchemasPath = output.schemas ? schemaCustomImportPath ?? getRelativeImportPath(targetPath, isString(output.schemas) ? output.schemas : output.schemas.path, true) : "./" + filename + ".schemas" + getImportExtension(extension, output.tsconfig);
|
|
6444
|
-
const schemasTarget = output.schemas ? isString(output.schemas) ? output.schemas : output.schemas.path :
|
|
6495
|
+
const schemasTarget = output.schemas ? isString(output.schemas) ? output.schemas : output.schemas.path : nodePath.join(dirname, filename + ".schemas" + getImportExtension(extension, output.tsconfig));
|
|
6445
6496
|
const isAllowSyntheticDefaultImports = isSyntheticDefaultImportsAllow(output.tsconfig);
|
|
6446
6497
|
const importsForBuilder = generateImportsForBuilder(output, imports, relativeSchemasPath, schemaTagMap);
|
|
6447
6498
|
implementationData += builder.imports({
|
|
@@ -6457,7 +6508,7 @@ async function writeSplitMode({ builder, output, projectName, header, needSchema
|
|
|
6457
6508
|
packageJson: output.packageJson,
|
|
6458
6509
|
output
|
|
6459
6510
|
});
|
|
6460
|
-
const schemasPath = !output.schemas && needSchema ?
|
|
6511
|
+
const schemasPath = !output.schemas && needSchema ? nodePath.join(dirname, filename + ".schemas" + extension) : void 0;
|
|
6461
6512
|
if (schemasPath) await writeGeneratedFile(schemasPath, generateSchemasInline ? header + generateSchemasInline() : header + generateModelsInline(builder.schemas));
|
|
6462
6513
|
if (mutators) implementationData += generateMutatorImports({
|
|
6463
6514
|
mutators,
|
|
@@ -6479,7 +6530,7 @@ async function writeSplitMode({ builder, output, projectName, header, needSchema
|
|
|
6479
6530
|
}
|
|
6480
6531
|
implementationData += `\n${implementation}`;
|
|
6481
6532
|
const implementationFilename = filename + (OutputClient.ANGULAR === output.client ? ".service" : "") + extension;
|
|
6482
|
-
const implementationPath =
|
|
6533
|
+
const implementationPath = nodePath.join(dirname, implementationFilename);
|
|
6483
6534
|
await writeGeneratedFile(implementationPath, implementationData);
|
|
6484
6535
|
const mockPaths = [];
|
|
6485
6536
|
const seenMockIndexKeys = /* @__PURE__ */ new Set();
|
|
@@ -6492,7 +6543,7 @@ async function writeSplitMode({ builder, output, projectName, header, needSchema
|
|
|
6492
6543
|
if (!rawEntry) continue;
|
|
6493
6544
|
const mockExtension = isFunction(rawEntry) ? OutputMockType.MSW : getMockFileExtensionByTypeName(rawEntry);
|
|
6494
6545
|
const mockDir = getMockDir(rawEntry, output.mock) ?? dirname;
|
|
6495
|
-
const mockFilePath =
|
|
6546
|
+
const mockFilePath = nodePath.join(mockDir, filename + "." + mockExtension + extension);
|
|
6496
6547
|
const mockRelativeSchemasPath = schemaCustomImportPath ?? resolveMockSchemasPath(mockFilePath, schemasTarget);
|
|
6497
6548
|
const finalizeMockOptions = getFinalizeMockImplementationOptions(output, mockOutput);
|
|
6498
6549
|
const finalizedMockImplementation = builder.finalizeMockImplementation ? builder.finalizeMockImplementation(mockOutput.implementation, finalizeMockOptions) : mockOutput.implementation;
|
|
@@ -6523,7 +6574,7 @@ async function writeSplitMode({ builder, output, projectName, header, needSchema
|
|
|
6523
6574
|
if (output.mock.indexMockFiles) {
|
|
6524
6575
|
const importExtension = getImportExtension(output.fileExtension, output.tsconfig);
|
|
6525
6576
|
for (const { extension: mockExt, mockDir } of writtenMockEntries) {
|
|
6526
|
-
const indexMockPath =
|
|
6577
|
+
const indexMockPath = nodePath.join(mockDir, `index.${mockExt}${extension}`);
|
|
6527
6578
|
await writeGeneratedFile(indexMockPath, `export * from './${filename}.${mockExt}${importExtension}'\n`);
|
|
6528
6579
|
indexMockPaths.push(indexMockPath);
|
|
6529
6580
|
}
|
|
@@ -6657,7 +6708,7 @@ function generateTargetForTags(builder, options) {
|
|
|
6657
6708
|
for (const [tag, target] of Object.entries(allTargetTags)) {
|
|
6658
6709
|
const isMutator = !!target.mutators?.some((mutator) => isAngularClient ? mutator.hasThirdArg : mutator.hasSecondArg);
|
|
6659
6710
|
const operationNames = operations.filter((operation) => isOperationInTagBucket(operation, tag)).map(({ operationName }) => operationName);
|
|
6660
|
-
const hasAwaitedType =
|
|
6711
|
+
const hasAwaitedType = hasTypeScriptAwaitedType(options.packageJson);
|
|
6661
6712
|
const titles = builder.title({
|
|
6662
6713
|
outputClient: options.client,
|
|
6663
6714
|
title: pascal(tag),
|
|
@@ -6735,7 +6786,7 @@ async function writeSplitTagsMode({ builder, output, projectName, header, needSc
|
|
|
6735
6786
|
const isAllowSyntheticDefaultImports = isSyntheticDefaultImportsAllow(output.tsconfig);
|
|
6736
6787
|
const mockIndexEntries = [];
|
|
6737
6788
|
const seenMockIndexKeys = /* @__PURE__ */ new Set();
|
|
6738
|
-
const schemasTarget = output.schemas ? isString(output.schemas) ? output.schemas : output.schemas.path :
|
|
6789
|
+
const schemasTarget = output.schemas ? isString(output.schemas) ? output.schemas : output.schemas.path : nodePath.join(dirname, filename + ".schemas" + getImportExtension(extension, output.tsconfig));
|
|
6739
6790
|
const tagEntries = Object.entries(target).toSorted(([a], [b]) => a.localeCompare(b));
|
|
6740
6791
|
const deduplicationEnabled = output.tagsSplitDeduplication && !output.workspace;
|
|
6741
6792
|
const collectedSharedTypes = [];
|
|
@@ -6749,7 +6800,7 @@ async function writeSplitTagsMode({ builder, output, projectName, header, needSc
|
|
|
6749
6800
|
}
|
|
6750
6801
|
const commonTypesImportExtension = getImportExtension(extension, output.tsconfig);
|
|
6751
6802
|
const commonTypesBasename = output.commonTypesFileName;
|
|
6752
|
-
const commonTypesPath =
|
|
6803
|
+
const commonTypesPath = nodePath.join(dirname, commonTypesBasename + extension);
|
|
6753
6804
|
const commonTypesRelativeImport = "../" + commonTypesBasename + (deduplicationEnabled ? commonTypesImportExtension : "");
|
|
6754
6805
|
const generatedFilePathsArray = await Promise.all(tagEntries.map(async ([tag, target]) => {
|
|
6755
6806
|
try {
|
|
@@ -6759,7 +6810,7 @@ async function writeSplitTagsMode({ builder, output, projectName, header, needSc
|
|
|
6759
6810
|
const typeNames = target.sharedTypes.map((t) => t.name).join(", ");
|
|
6760
6811
|
implementationData += `import type { ${typeNames} } from '${commonTypesRelativeImport}';\n`;
|
|
6761
6812
|
}
|
|
6762
|
-
const importerPath =
|
|
6813
|
+
const importerPath = nodePath.join(dirname, tag, tag + extension);
|
|
6763
6814
|
const schemaCustomImportPath = getSchemasImportPath(output.schemas);
|
|
6764
6815
|
const relativeSchemasPath = output.schemas ? schemaCustomImportPath ?? getRelativeImportPath(importerPath, isString(output.schemas) ? output.schemas : output.schemas.path, true) : "../" + filename + ".schemas" + getImportExtension(extension, output.tsconfig);
|
|
6765
6816
|
const tagNames = new Set(tagEntries.map(([t]) => t));
|
|
@@ -6767,12 +6818,12 @@ async function writeSplitTagsMode({ builder, output, projectName, header, needSc
|
|
|
6767
6818
|
const importsForBuilder = generateImportsForBuilder(output, imports.map((imp) => {
|
|
6768
6819
|
if (!imp.importPath) return imp;
|
|
6769
6820
|
if (!imp.importPath.startsWith(".")) return imp;
|
|
6770
|
-
const resolvedPath =
|
|
6771
|
-
const targetBasename =
|
|
6821
|
+
const resolvedPath = nodePath.resolve(dirname, imp.importPath);
|
|
6822
|
+
const targetBasename = nodePath.basename(resolvedPath);
|
|
6772
6823
|
let targetFile;
|
|
6773
6824
|
if (tagNames.has(targetBasename)) {
|
|
6774
6825
|
const tagFilename = targetBasename + serviceSuffix + extension;
|
|
6775
|
-
targetFile =
|
|
6826
|
+
targetFile = nodePath.join(resolvedPath, tagFilename);
|
|
6776
6827
|
} else targetFile = resolvedPath + extension;
|
|
6777
6828
|
const adjustedPath = getRelativeImportPath(importerPath, targetFile);
|
|
6778
6829
|
return {
|
|
@@ -6793,7 +6844,7 @@ async function writeSplitTagsMode({ builder, output, projectName, header, needSc
|
|
|
6793
6844
|
packageJson: output.packageJson,
|
|
6794
6845
|
output
|
|
6795
6846
|
});
|
|
6796
|
-
const schemasPath = !output.schemas && needSchema ?
|
|
6847
|
+
const schemasPath = !output.schemas && needSchema ? nodePath.join(dirname, filename + ".schemas" + extension) : void 0;
|
|
6797
6848
|
if (schemasPath) await writeGeneratedFile(schemasPath, generateSchemasInline ? header + generateSchemasInline() : header + generateModelsInline(builder.schemas));
|
|
6798
6849
|
if (mutators) implementationData += generateMutatorImports({
|
|
6799
6850
|
mutators,
|
|
@@ -6834,7 +6885,7 @@ async function writeSplitTagsMode({ builder, output, projectName, header, needSc
|
|
|
6834
6885
|
}
|
|
6835
6886
|
implementationData += `\n${implementation}`;
|
|
6836
6887
|
const implementationFilename = tag + (OutputClient.ANGULAR === output.client ? ".service" : "") + extension;
|
|
6837
|
-
const implementationPath =
|
|
6888
|
+
const implementationPath = nodePath.join(dirname, tag, implementationFilename);
|
|
6838
6889
|
await writeGeneratedFile(implementationPath, implementationData);
|
|
6839
6890
|
const mockPaths = [];
|
|
6840
6891
|
for (const mockOutput of mockOutputs) {
|
|
@@ -6845,7 +6896,7 @@ async function writeSplitTagsMode({ builder, output, projectName, header, needSc
|
|
|
6845
6896
|
if (!rawEntry) continue;
|
|
6846
6897
|
const mockExtension = isFunction(rawEntry) ? OutputMockType.MSW : getMockFileExtensionByTypeName(rawEntry);
|
|
6847
6898
|
const mockDir = getMockDir(rawEntry, output.mock) ?? dirname;
|
|
6848
|
-
const mockFilePath =
|
|
6899
|
+
const mockFilePath = nodePath.join(mockDir, tag, tag + "." + mockExtension + extension);
|
|
6849
6900
|
const mockRelativeSchemasPath = schemaCustomImportPath ?? resolveMockSchemasPath(mockFilePath, schemasTarget);
|
|
6850
6901
|
const finalizeMockOptions = getFinalizeMockImplementationOptions(output, mockOutput);
|
|
6851
6902
|
const finalizedMockImplementation = builder.finalizeMockImplementation ? builder.finalizeMockImplementation(mockOutput.implementation, finalizeMockOptions) : mockOutput.implementation;
|
|
@@ -6887,7 +6938,7 @@ async function writeSplitTagsMode({ builder, output, projectName, header, needSc
|
|
|
6887
6938
|
}));
|
|
6888
6939
|
if (output.mock.indexMockFiles) {
|
|
6889
6940
|
const mockImportExtension = getImportExtension(extension, output.tsconfig);
|
|
6890
|
-
for (const { ext, mockDir, tags } of mockIndexEntries) await writeGeneratedFile(
|
|
6941
|
+
for (const { ext, mockDir, tags } of mockIndexEntries) await writeGeneratedFile(nodePath.join(mockDir, `index.${ext}${extension}`), tags.toSorted((a, b) => a.localeCompare(b)).map((tag) => {
|
|
6891
6942
|
const localMockPath = joinSafe("./", tag, tag + "." + ext + mockImportExtension);
|
|
6892
6943
|
return ext === OutputMockType.MSW ? `export { get${pascal(tag)}Mock } from '${localMockPath}'\n` : `export * from '${localMockPath}'\n`;
|
|
6893
6944
|
}).join(""));
|
|
@@ -6906,11 +6957,11 @@ async function writeSplitTagsMode({ builder, output, projectName, header, needSc
|
|
|
6906
6957
|
const indexContent = (publicSharedTypeNames.length > 0 ? `export type { ${publicSharedTypeNames.join(", ")} } from './${commonTypesBasename}${importExtension}';\n` : "") + tagEntries.map(([tag]) => {
|
|
6907
6958
|
return `export * from '${joinSafe("./", tag, tag + serviceSuffix + importExtension)}';\n`;
|
|
6908
6959
|
}).join("");
|
|
6909
|
-
indexFilePath =
|
|
6960
|
+
indexFilePath = nodePath.join(dirname, `index${extension}`);
|
|
6910
6961
|
await writeGeneratedFile(indexFilePath, indexContent);
|
|
6911
6962
|
}
|
|
6912
6963
|
return [...new Set([
|
|
6913
|
-
...output.mock.indexMockFiles ? mockIndexEntries.map(({ mockDir, ext }) =>
|
|
6964
|
+
...output.mock.indexMockFiles ? mockIndexEntries.map(({ mockDir, ext }) => nodePath.join(mockDir, `index.${ext}${extension}`)) : [],
|
|
6914
6965
|
...commonTypesFilePath ? [commonTypesFilePath] : [],
|
|
6915
6966
|
...indexFilePath ? [indexFilePath] : [],
|
|
6916
6967
|
...generatedFilePathsArray.flat()
|
|
@@ -6930,7 +6981,7 @@ async function writeTagsMode({ builder, output, projectName, header, needSchema,
|
|
|
6930
6981
|
const seenMockIndexKeys = /* @__PURE__ */ new Set();
|
|
6931
6982
|
const schemaCustomImportPath = getSchemasImportPath(output.schemas);
|
|
6932
6983
|
const schemasPathRelative = output.schemas ? schemaCustomImportPath ?? getRelativeImportPath(targetPath, getFileInfo(isString(output.schemas) ? output.schemas : output.schemas.path, { extension: output.fileExtension }).dirname) : "./" + filename + ".schemas" + getImportExtension(extension, output.tsconfig);
|
|
6933
|
-
const schemasTarget = output.schemas ? getFileInfo(isString(output.schemas) ? output.schemas : output.schemas.path, { extension: output.fileExtension }).dirname :
|
|
6984
|
+
const schemasTarget = output.schemas ? getFileInfo(isString(output.schemas) ? output.schemas : output.schemas.path, { extension: output.fileExtension }).dirname : nodePath.join(dirname, filename + ".schemas" + getImportExtension(extension, output.tsconfig));
|
|
6934
6985
|
const tagEntries = Object.entries(target).toSorted(([a], [b]) => a.localeCompare(b));
|
|
6935
6986
|
const generatedFilePathsArray = await Promise.all(tagEntries.map(async ([tag, target]) => {
|
|
6936
6987
|
try {
|
|
@@ -6976,7 +7027,7 @@ async function writeTagsMode({ builder, output, projectName, header, needSchema,
|
|
|
6976
7027
|
options: entry && !isFunction(entry) ? entry : void 0
|
|
6977
7028
|
});
|
|
6978
7029
|
}
|
|
6979
|
-
const schemasPath = !output.schemas && needSchema ?
|
|
7030
|
+
const schemasPath = !output.schemas && needSchema ? nodePath.join(dirname, filename + ".schemas" + extension) : void 0;
|
|
6980
7031
|
if (schemasPath) await writeGeneratedFile(schemasPath, generateSchemasInline ? header + generateSchemasInline() : header + generateModelsInline(builder.schemas));
|
|
6981
7032
|
if (mutators) data += generateMutatorImports({
|
|
6982
7033
|
mutators,
|
|
@@ -7007,7 +7058,7 @@ async function writeTagsMode({ builder, output, projectName, header, needSchema,
|
|
|
7007
7058
|
}
|
|
7008
7059
|
}
|
|
7009
7060
|
const kebabTag = kebab(tag);
|
|
7010
|
-
const implementationPath =
|
|
7061
|
+
const implementationPath = nodePath.join(dirname, `${kebabTag}${extension}`);
|
|
7011
7062
|
await writeGeneratedFile(implementationPath, data);
|
|
7012
7063
|
const extraPaths = [];
|
|
7013
7064
|
if (shouldDeinlineMocks) for (const mockOutput of rawMockOutputs) {
|
|
@@ -7018,7 +7069,7 @@ async function writeTagsMode({ builder, output, projectName, header, needSchema,
|
|
|
7018
7069
|
if (!rawEntry) continue;
|
|
7019
7070
|
const mockExtension = isFunction(rawEntry) ? OutputMockType.MSW : getMockFileExtensionByTypeName(rawEntry);
|
|
7020
7071
|
const mockDir = getMockDir(rawEntry, output.mock) ?? dirname;
|
|
7021
|
-
const mockFilePath =
|
|
7072
|
+
const mockFilePath = nodePath.join(mockDir, kebabTag, kebabTag + "." + mockExtension + extension);
|
|
7022
7073
|
const mockRelativeSchemasPath = schemaCustomImportPath ?? resolveMockSchemasPath(mockFilePath, schemasTarget);
|
|
7023
7074
|
const finalizeMockOptions = getFinalizeMockImplementationOptions(output, mockOutput);
|
|
7024
7075
|
const finalizedMockImplementation = builder.finalizeMockImplementation ? builder.finalizeMockImplementation(mockOutput.implementation, finalizeMockOptions) : mockOutput.implementation;
|
|
@@ -7061,7 +7112,7 @@ async function writeTagsMode({ builder, output, projectName, header, needSchema,
|
|
|
7061
7112
|
if (shouldDeinlineMocks && output.mock.indexMockFiles) {
|
|
7062
7113
|
const mockImportExtension = getImportExtension(extension, output.tsconfig);
|
|
7063
7114
|
for (const { ext, mockDir, tags } of mockIndexEntries) {
|
|
7064
|
-
const indexPath =
|
|
7115
|
+
const indexPath = nodePath.join(mockDir, `index.${ext}${extension}`);
|
|
7065
7116
|
await writeGeneratedFile(indexPath, tags.toSorted((a, b) => a.localeCompare(b)).map((kebabTag) => {
|
|
7066
7117
|
const localMockPath = joinSafe("./", kebabTag, kebabTag + "." + ext + mockImportExtension);
|
|
7067
7118
|
return ext === OutputMockType.MSW ? `export { get${pascal(kebabTag)}Mock } from '${localMockPath}'\n` : `export * from '${localMockPath}'\n`;
|
|
@@ -7072,6 +7123,6 @@ async function writeTagsMode({ builder, output, projectName, header, needSchema,
|
|
|
7072
7123
|
return generatedFilePathsArray.flat();
|
|
7073
7124
|
}
|
|
7074
7125
|
//#endregion
|
|
7075
|
-
export { BODY_TYPE_NAME, DefaultTag, EnumGeneration, ErrorWithTag, FormDataArrayHandling, GetterPropType, LogLevels, NAMED_COMPONENT_SECTIONS, NamingConvention, OutputClient, OutputHttpClient, OutputMockType, OutputMode, PropertySortOrder, RefComponentSuffix, SHARED_DIR, SchemaType, SupportedFormatter, TEMPLATE_TAG_REGEX, URL_REGEX, VERBS_WITH_BODY, Verbs, addDependency, asyncReduce, buildAngularParamsFilterExpression, buildDynamicScope, buildInlineDynamicScope, buildSchemaTagMap, camel, collectReferencedComponents, combineSchemas, compareVersions, conventionName, count, createDebugger, createLogger, createSuccessMessage, createTypeAliasIfNeeded, dedupeUnionType, dynamicAnchorToParamName, dynamicAnchorsToUniqueParamNames, dynamicImport, escape, escapeRegExp, extractBoundAliasInfo, filterByContentType, filteredVerbs, fixCrossDirectoryImports, fixRegularSchemaImports, generalJSTypes, generalJSTypesWithArray, generateAxiosOptions, generateBodyMutatorConfig, generateBodyOptions, generateComponentDefinition, generateDependencyImports, generateFactory, generateFormDataAndUrlEncodedFunction, generateImports, generateModelInline, generateModelsInline, generateMutator, generateMutatorConfig, generateMutatorImports, generateMutatorRequestOptions, generateOptions, generateParameterDefinition, generateQueryParamsAxiosConfig, generateSchemasDefinition, generateTarget, generateTargetForTags, generateVerbImports, generateVerbOptions, generateVerbsOptions, getAngularFilteredParamsCallExpression, getAngularFilteredParamsExpression, getAngularFilteredParamsHelperBody, getArray, getBaseUrlRuntimeImports, getBodiesByContentType, getBody, getCombinedEnumValue, getDefaultContentType, getDynamicAnchorName, getEnum, getEnumDescriptions, getEnumImplementation, getEnumNames, getEnumUnionFromSchema, getExtension, getFileInfo, getFormDataFieldFileType, getFullRoute, getImportExtension, getIsBodyVerb, getKey, getMockFileExtensionByTypeName, getNumberWord, getObject, getOperationId, getOperationTagKey, getOrvalGeneratedTypes, getParameters, getParams, getParamsInPath, getPropertySafe, getProps, getQueryParams, getRefInfo, getResReqTypes, getResponse, getResponseTypeCategory, getRoute, getRouteAsArray, getScalar, getSchemasImportPath, getSuccessResponseType, getTagKey, getTypedResponse, getWarningCount, isBinaryContentType, isBinaryScalarSchema, isBoolean, isComponentRef, isDirectory, isDynamicReference, isFakerMock, isFunction, isModule, isMswMock, isNullish, isNumber, isNumeric, isObject, isOperationInTagBucket, isReference, isSchema, isString, isStringLike, isSyntheticDefaultImportsAllow, isUrl, isVerb, isVerbose, jsDoc, jsStringEscape, jsStringLiteralEscape, kebab, keyValuePairsToJsDoc, log, logError, logVerbose, logWarning, makeRouteSafe, mergeDeep, mismatchArgsMessage, pascal, removeFilesAndEmptyFolders, resetWarnings, resolveDiscriminators, resolveDynamicRef, resolveExampleRefs, resolveInstalledVersion, resolveInstalledVersions, resolveObject, resolveRef, resolveValue, sanitize, setVerbose, snake, sortByPriority, splitSchemasByType, startMessage, stringify, toObjectString, path_exports as upath, upper, wrapRouteParameters, writeGeneratedFile, writeModelInline, writeModelsInline, writeSchema, writeSchemas, writeSchemasTagsSplit, writeSingleMode, writeSplitMode, writeSplitTagsMode, writeTagsMode };
|
|
7126
|
+
export { BODY_TYPE_NAME, DefaultTag, EnumGeneration, ErrorWithTag, FormDataArrayHandling, GetterPropType, LogLevels, NAMED_COMPONENT_SECTIONS, NamingConvention, OutputClient, OutputHttpClient, OutputMockType, OutputMode, PropertySortOrder, RefComponentSuffix, SHARED_DIR, SchemaType, SupportedFormatter, TEMPLATE_TAG_REGEX, URL_REGEX, VERBS_WITH_BODY, Verbs, addDependency, asyncReduce, buildAngularParamsFilterExpression, buildDynamicScope, buildInlineDynamicScope, buildSchemaTagMap, camel, collectReferencedComponents, combineSchemas, compareVersions, conventionName, count, createDebugger, createLogger, createSuccessMessage, createTypeAliasIfNeeded, dedupeUnionType, dynamicAnchorToParamName, dynamicAnchorsToUniqueParamNames, dynamicImport, escape, escapeRegExp, extractBoundAliasInfo, filterByContentType, filteredVerbs, fixCrossDirectoryImports, fixRegularSchemaImports, generalJSTypes, generalJSTypesWithArray, generateAxiosOptions, generateBodyMutatorConfig, generateBodyOptions, generateComponentDefinition, generateDependencyImports, generateFactory, generateFormDataAndUrlEncodedFunction, generateImports, generateModelInline, generateModelsInline, generateMutator, generateMutatorConfig, generateMutatorImports, generateMutatorRequestOptions, generateOptions, generateParameterDefinition, generateQueryParamsAxiosConfig, generateSchemasDefinition, generateTarget, generateTargetForTags, generateVerbImports, generateVerbOptions, generateVerbsOptions, getAngularFilteredParamsCallExpression, getAngularFilteredParamsExpression, getAngularFilteredParamsHelperBody, getArray, getBaseUrlRuntimeImports, getBodiesByContentType, getBody, getCombinedEnumValue, getDefaultContentType, getDynamicAnchorIndex, getDynamicAnchorName, getEnum, getEnumDescriptions, getEnumImplementation, getEnumNames, getEnumUnionFromSchema, getExtension, getFileInfo, getFormDataFieldFileType, getFullRoute, getImportExtension, getIsBodyVerb, getKey, getMockFileExtensionByTypeName, getNumberWord, getObject, getOperationId, getOperationTagKey, getOrvalGeneratedTypes, getParameters, getParams, getParamsInPath, getPropertySafe, getProps, getQueryParams, getRefInfo, getResReqTypes, getResponse, getResponseTypeCategory, getRoute, getRouteAsArray, getScalar, getSchemasImportPath, getSuccessResponseType, getTagKey, getTypedResponse, getWarningCount, isBinaryContentType, isBinaryScalarSchema, isBoolean, isComponentRef, isDirectory, isDynamicReference, isFakerMock, isFunction, isModule, isMswMock, isNullish, isNumber, isNumeric, isObject, isOperationInTagBucket, isReference, isSchema, isString, isStringLike, isSyntheticDefaultImportsAllow, isUrl, isVerb, isVerbose, jsDoc, jsStringEscape, jsStringLiteralEscape, kebab, keyValuePairsToJsDoc, log, logError, logVerbose, logWarning, makeRouteSafe, mergeDeep, mismatchArgsMessage, pascal, removeFilesAndEmptyFolders, resetWarnings, resolveDiscriminators, resolveDynamicRef, resolveExampleRefs, resolveInstalledVersion, resolveInstalledVersions, resolveObject, resolveRef, resolveValue, sanitize, setVerbose, snake, sortByPriority, splitSchemasByType, startMessage, stringify, toObjectString, path_exports as upath, upper, wrapRouteParameters, writeGeneratedFile, writeModelInline, writeModelsInline, writeSchema, writeSchemas, writeSchemasTagsSplit, writeSingleMode, writeSplitMode, writeSplitTagsMode, writeTagsMode };
|
|
7076
7127
|
|
|
7077
7128
|
//# sourceMappingURL=index.mjs.map
|