@orval/core 8.7.0 → 8.8.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 +19 -1
- package/dist/index.mjs +49 -48
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -108,6 +108,7 @@ interface NormalizedOverrideOutput {
|
|
|
108
108
|
};
|
|
109
109
|
};
|
|
110
110
|
hono: NormalizedHonoOptions;
|
|
111
|
+
mcp: NormalizedMcpOptions;
|
|
111
112
|
query: NormalizedQueryOptions;
|
|
112
113
|
angular: NormalizedAngularOptions;
|
|
113
114
|
swr: SwrOptions;
|
|
@@ -437,6 +438,7 @@ interface OverrideOutput {
|
|
|
437
438
|
};
|
|
438
439
|
};
|
|
439
440
|
hono?: HonoOptions;
|
|
441
|
+
mcp?: McpOptions;
|
|
440
442
|
query?: QueryOptions;
|
|
441
443
|
swr?: SwrOptions;
|
|
442
444
|
angular?: AngularOptions;
|
|
@@ -592,6 +594,22 @@ interface HonoOptions {
|
|
|
592
594
|
validator?: boolean | 'hono';
|
|
593
595
|
validatorOutputPath?: string;
|
|
594
596
|
}
|
|
597
|
+
interface McpServerOptions {
|
|
598
|
+
path: string;
|
|
599
|
+
name?: string;
|
|
600
|
+
default?: boolean;
|
|
601
|
+
}
|
|
602
|
+
interface NormalizedMcpServerOptions {
|
|
603
|
+
path: string;
|
|
604
|
+
name?: string;
|
|
605
|
+
default: boolean;
|
|
606
|
+
}
|
|
607
|
+
interface McpOptions {
|
|
608
|
+
server?: McpServerOptions;
|
|
609
|
+
}
|
|
610
|
+
interface NormalizedMcpOptions {
|
|
611
|
+
server?: NormalizedMcpServerOptions;
|
|
612
|
+
}
|
|
595
613
|
interface NormalizedQueryOptions {
|
|
596
614
|
useQuery?: boolean;
|
|
597
615
|
useSuspenseQuery?: boolean;
|
|
@@ -2315,5 +2333,5 @@ declare function generateTargetForTags(builder: WriteSpecBuilder, options: Norma
|
|
|
2315
2333
|
declare function getOrvalGeneratedTypes(): string;
|
|
2316
2334
|
declare function getTypedResponse(): string;
|
|
2317
2335
|
//#endregion
|
|
2318
|
-
export { AngularHttpResourceOptions, AngularOptions, BODY_TYPE_NAME, BaseUrlFromConstant, BaseUrlFromSpec, BaseUrlRuntime, ClientBuilder, ClientDependenciesBuilder, ClientExtraFilesBuilder, ClientFileBuilder, ClientFooterBuilder, ClientGeneratorsBuilder, ClientHeaderBuilder, ClientMockBuilder, ClientMockGeneratorBuilder, ClientMockGeneratorImplementation, ClientTitleBuilder, Config, ConfigExternal, ConfigFn, ContentTypeFilter, ContextSpec, DeepNonNullable, EnumGeneration, ErrorWithTag, FetchOptions, FormDataArrayHandling, FormDataContext, FormDataType, GenerateMockImports, GenerateVerbOptionsParams, GenerateVerbsOptionsParams, GeneratorApiBuilder, GeneratorApiOperations, GeneratorApiResponse, GeneratorClient, GeneratorClientExtra, GeneratorClientFooter, GeneratorClientHeader, GeneratorClientImports, GeneratorClientTitle, GeneratorClients, GeneratorDependency, GeneratorImport, GeneratorMutator, GeneratorMutatorParsingInfo, GeneratorOperation, GeneratorOperations, GeneratorOptions, GeneratorSchema, GeneratorTarget, GeneratorTargetFull, GeneratorVerbOptions, GeneratorVerbsOptions, GetterBody, GetterParam, GetterParameters, GetterParams, GetterProp, GetterPropType, GetterProps, GetterQueryParam, GetterResponse, GlobalMockOptions, GlobalOptions, HonoOptions, Hook, HookCommand, HookFunction, HookOption, HooksOptions, ImportOpenApi, InputFiltersOptions, InputOptions, InputTransformerFn, InvalidateTarget, JsDocOptions, LogLevel, LogLevels, LogOptions, LogType, Logger, LoggerOptions, MockData, MockDataArray, MockDataArrayFn, MockDataObject, MockDataObjectFn, MockOptions, MockProperties, MockPropertiesObject, MockPropertiesObjectFn, MutationInvalidatesConfig, MutationInvalidatesRule, Mutator, MutatorObject, NamingConvention, NormalizedAngularOptions, NormalizedConfig, NormalizedFetchOptions, NormalizedFormDataType, NormalizedHonoOptions, NormalizedHookCommand, NormalizedHookOptions, NormalizedInputOptions, NormalizedJsDocOptions, NormalizedMutator, NormalizedOperationOptions, NormalizedOptions, NormalizedOutputOptions, NormalizedOverrideOutput, NormalizedParamsSerializerOptions, NormalizedQueryOptions, NormalizedSchemaOptions, NormalizedZodOptions, OpenApiComponentsObject, OpenApiDocument, OpenApiEncodingObject, OpenApiExampleObject, OpenApiInfoObject, OpenApiMediaTypeObject, OpenApiOperationObject, OpenApiParameterObject, OpenApiPathItemObject, OpenApiPathsObject, OpenApiReferenceObject, OpenApiRequestBodyObject, OpenApiResponseObject, OpenApiResponsesObject, OpenApiSchemaObject, OpenApiSchemaObjectType, OpenApiSchemasObject, OpenApiServerObject, OperationOptions, Options, OptionsExport, OptionsFn, OutputClient, OutputClientFunc, OutputDocsOptions, OutputHttpClient, OutputMockType, OutputMode, OutputOptions, OverrideInput, OverrideMockOptions, OverrideOutput, OverrideOutputContentType, PackageJson, ParamsSerializerOptions, PreferredContentType, PropertySortOrder, QueryOptions, ReadonlyRequestBodiesMode, RefComponentSuffix, RefInfo, ResReqTypesValue, ResolverValue, ResponseTypeCategory, ScalarValue, SchemaGenerationType, SchemaOptions, SchemaType, SupportedFormatter, SwrOptions, TEMPLATE_TAG_REGEX, TsConfigTarget, Tsconfig, URL_REGEX, VERBS_WITH_BODY, Verbs, WriteModeProps, WriteSpecBuilder, ZodCoerceType, ZodDateTimeOptions, ZodOptions, ZodTimeOptions, _filteredVerbs, addDependency, asyncReduce, camel, combineSchemas, compareVersions, conventionName, count, createDebugger, createLogger, createSuccessMessage, createTypeAliasIfNeeded, dedupeUnionType, dynamicImport, escape, escapeRegExp, filterByContentType, fixCrossDirectoryImports, fixRegularSchemaImports, generalJSTypes, generalJSTypesWithArray, generateAxiosOptions, generateBodyMutatorConfig, generateBodyOptions, generateComponentDefinition, generateDependencyImports, 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, getEnum, getEnumDescriptions, getEnumImplementation, getEnumNames, getEnumUnionFromSchema, getExtension, getFileInfo, getFormDataFieldFileType, getFullRoute, getIsBodyVerb, getKey, getMockFileExtensionByTypeName, getNumberWord, getObject, getOperationId, getOrvalGeneratedTypes, getParameters, getParams, getParamsInPath, getPropertySafe, getProps, getQueryParams, getRefInfo, getResReqTypes, getResponse, getResponseTypeCategory, getRoute, getRouteAsArray, getScalar, getSuccessResponseType, getTypedResponse, getWarningCount, isBinaryContentType, isBoolean, isDirectory, isFunction, isModule, isNullish, isNumber, isNumeric, isObject, isReference, isSchema, isString, isStringLike, isSyntheticDefaultImportsAllow, isUrl, isVerb, isVerbose, jsDoc, jsStringEscape, kebab, keyValuePairsToJsDoc, log, logError, logVerbose, logWarning, mergeDeep, mismatchArgsMessage, pascal, removeFilesAndEmptyFolders, resetWarnings, resolveDiscriminators, resolveExampleRefs, resolveInstalledVersion, resolveInstalledVersions, resolveObject, resolveRef, resolveValue, sanitize, setVerbose, snake, sortByPriority, splitSchemasByType, startMessage, stringify, toObjectString, path_d_exports as upath, upper, writeModelInline, writeModelsInline, writeSchema, writeSchemas, writeSingleMode, writeSplitMode, writeSplitTagsMode, writeTagsMode };
|
|
2336
|
+
export { AngularHttpResourceOptions, AngularOptions, BODY_TYPE_NAME, BaseUrlFromConstant, BaseUrlFromSpec, BaseUrlRuntime, ClientBuilder, ClientDependenciesBuilder, ClientExtraFilesBuilder, ClientFileBuilder, ClientFooterBuilder, ClientGeneratorsBuilder, ClientHeaderBuilder, ClientMockBuilder, ClientMockGeneratorBuilder, ClientMockGeneratorImplementation, ClientTitleBuilder, Config, ConfigExternal, ConfigFn, ContentTypeFilter, ContextSpec, DeepNonNullable, EnumGeneration, ErrorWithTag, FetchOptions, FormDataArrayHandling, FormDataContext, FormDataType, GenerateMockImports, GenerateVerbOptionsParams, GenerateVerbsOptionsParams, GeneratorApiBuilder, GeneratorApiOperations, GeneratorApiResponse, GeneratorClient, GeneratorClientExtra, GeneratorClientFooter, GeneratorClientHeader, GeneratorClientImports, GeneratorClientTitle, GeneratorClients, GeneratorDependency, GeneratorImport, GeneratorMutator, GeneratorMutatorParsingInfo, GeneratorOperation, GeneratorOperations, GeneratorOptions, GeneratorSchema, GeneratorTarget, GeneratorTargetFull, GeneratorVerbOptions, GeneratorVerbsOptions, GetterBody, GetterParam, GetterParameters, GetterParams, GetterProp, GetterPropType, GetterProps, GetterQueryParam, GetterResponse, GlobalMockOptions, GlobalOptions, HonoOptions, Hook, HookCommand, HookFunction, HookOption, HooksOptions, ImportOpenApi, InputFiltersOptions, InputOptions, InputTransformerFn, InvalidateTarget, JsDocOptions, LogLevel, LogLevels, LogOptions, LogType, Logger, LoggerOptions, McpOptions, McpServerOptions, MockData, MockDataArray, MockDataArrayFn, MockDataObject, MockDataObjectFn, MockOptions, MockProperties, MockPropertiesObject, MockPropertiesObjectFn, MutationInvalidatesConfig, MutationInvalidatesRule, Mutator, MutatorObject, NamingConvention, NormalizedAngularOptions, NormalizedConfig, NormalizedFetchOptions, NormalizedFormDataType, NormalizedHonoOptions, NormalizedHookCommand, NormalizedHookOptions, NormalizedInputOptions, NormalizedJsDocOptions, NormalizedMcpOptions, NormalizedMcpServerOptions, NormalizedMutator, NormalizedOperationOptions, NormalizedOptions, NormalizedOutputOptions, NormalizedOverrideOutput, NormalizedParamsSerializerOptions, NormalizedQueryOptions, NormalizedSchemaOptions, NormalizedZodOptions, OpenApiComponentsObject, OpenApiDocument, OpenApiEncodingObject, OpenApiExampleObject, OpenApiInfoObject, OpenApiMediaTypeObject, OpenApiOperationObject, OpenApiParameterObject, OpenApiPathItemObject, OpenApiPathsObject, OpenApiReferenceObject, OpenApiRequestBodyObject, OpenApiResponseObject, OpenApiResponsesObject, OpenApiSchemaObject, OpenApiSchemaObjectType, OpenApiSchemasObject, OpenApiServerObject, OperationOptions, Options, OptionsExport, OptionsFn, OutputClient, OutputClientFunc, OutputDocsOptions, OutputHttpClient, OutputMockType, OutputMode, OutputOptions, OverrideInput, OverrideMockOptions, OverrideOutput, OverrideOutputContentType, PackageJson, ParamsSerializerOptions, PreferredContentType, PropertySortOrder, QueryOptions, ReadonlyRequestBodiesMode, RefComponentSuffix, RefInfo, ResReqTypesValue, ResolverValue, ResponseTypeCategory, ScalarValue, SchemaGenerationType, SchemaOptions, SchemaType, SupportedFormatter, SwrOptions, TEMPLATE_TAG_REGEX, TsConfigTarget, Tsconfig, URL_REGEX, VERBS_WITH_BODY, Verbs, WriteModeProps, WriteSpecBuilder, ZodCoerceType, ZodDateTimeOptions, ZodOptions, ZodTimeOptions, _filteredVerbs, addDependency, asyncReduce, camel, combineSchemas, compareVersions, conventionName, count, createDebugger, createLogger, createSuccessMessage, createTypeAliasIfNeeded, dedupeUnionType, dynamicImport, escape, escapeRegExp, filterByContentType, fixCrossDirectoryImports, fixRegularSchemaImports, generalJSTypes, generalJSTypesWithArray, generateAxiosOptions, generateBodyMutatorConfig, generateBodyOptions, generateComponentDefinition, generateDependencyImports, 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, getEnum, getEnumDescriptions, getEnumImplementation, getEnumNames, getEnumUnionFromSchema, getExtension, getFileInfo, getFormDataFieldFileType, getFullRoute, getIsBodyVerb, getKey, getMockFileExtensionByTypeName, getNumberWord, getObject, getOperationId, getOrvalGeneratedTypes, getParameters, getParams, getParamsInPath, getPropertySafe, getProps, getQueryParams, getRefInfo, getResReqTypes, getResponse, getResponseTypeCategory, getRoute, getRouteAsArray, getScalar, getSuccessResponseType, getTypedResponse, getWarningCount, isBinaryContentType, isBoolean, isDirectory, isFunction, isModule, isNullish, isNumber, isNumeric, isObject, isReference, isSchema, isString, isStringLike, isSyntheticDefaultImportsAllow, isUrl, isVerb, isVerbose, jsDoc, jsStringEscape, kebab, keyValuePairsToJsDoc, log, logError, logVerbose, logWarning, mergeDeep, mismatchArgsMessage, pascal, removeFilesAndEmptyFolders, resetWarnings, resolveDiscriminators, resolveExampleRefs, resolveInstalledVersion, resolveInstalledVersions, resolveObject, resolveRef, resolveValue, sanitize, setVerbose, snake, sortByPriority, splitSchemasByType, startMessage, stringify, toObjectString, path_d_exports as upath, upper, writeModelInline, writeModelsInline, writeSchema, writeSchemas, writeSingleMode, writeSplitMode, writeSplitTagsMode, writeTagsMode };
|
|
2319
2337
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { t as __exportAll } from "./chunk-C7Uep-_p.mjs";
|
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { entries, groupBy, isArray, isBoolean, isBoolean as isBoolean$1, isEmptyish, isFunction, 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 path from "node:path";
|
|
6
6
|
import { compare } from "compare-versions";
|
|
7
7
|
import debug from "debug";
|
|
8
8
|
import { pathToFileURL } from "node:url";
|
|
@@ -140,7 +140,7 @@ function isReference(obj) {
|
|
|
140
140
|
return !isNullish$1(obj) && Object.hasOwn(obj, "$ref");
|
|
141
141
|
}
|
|
142
142
|
function isDirectory(pathValue) {
|
|
143
|
-
return !
|
|
143
|
+
return !path.extname(pathValue);
|
|
144
144
|
}
|
|
145
145
|
function isObject(x) {
|
|
146
146
|
return Object.prototype.toString.call(x) === "[object Object]";
|
|
@@ -456,8 +456,8 @@ async function dynamicImport(toImport, from = process.cwd(), takeDefault = true)
|
|
|
456
456
|
if (!toImport) return toImport;
|
|
457
457
|
try {
|
|
458
458
|
if (isString(toImport)) {
|
|
459
|
-
const filePath =
|
|
460
|
-
const extension =
|
|
459
|
+
const filePath = path.resolve(from, toImport);
|
|
460
|
+
const extension = path.extname(filePath);
|
|
461
461
|
if (TS_MODULE_EXTENSIONS.has(extension)) {
|
|
462
462
|
const data = await createJiti(from, { interopDefault: true }).import(filePath);
|
|
463
463
|
if (takeDefault && (isObject(data) || isModule(data)) && data.default) return data.default;
|
|
@@ -484,14 +484,14 @@ function getExtension(path) {
|
|
|
484
484
|
//#region src/utils/file.ts
|
|
485
485
|
function getFileInfo(target = "", { backupFilename = "filename", extension = ".ts" } = {}) {
|
|
486
486
|
const isDir = isDirectory(target);
|
|
487
|
-
const filePath = isDir ?
|
|
487
|
+
const filePath = isDir ? path.join(target, backupFilename + extension) : target;
|
|
488
488
|
return {
|
|
489
489
|
path: filePath,
|
|
490
490
|
pathWithoutExtension: filePath.replace(/\.[^/.]+$/, ""),
|
|
491
491
|
extension,
|
|
492
492
|
isDirectory: isDir,
|
|
493
|
-
dirname:
|
|
494
|
-
filename:
|
|
493
|
+
dirname: path.dirname(filePath),
|
|
494
|
+
filename: path.basename(filePath, extension.startsWith(".") ? extension : `.${extension}`)
|
|
495
495
|
};
|
|
496
496
|
}
|
|
497
497
|
async function removeFilesAndEmptyFolders(patterns, dir) {
|
|
@@ -706,13 +706,13 @@ function toUnix(value) {
|
|
|
706
706
|
return value;
|
|
707
707
|
}
|
|
708
708
|
function join(...args) {
|
|
709
|
-
return toUnix(
|
|
709
|
+
return toUnix(path.join(...args.map((a) => toUnix(a))));
|
|
710
710
|
}
|
|
711
711
|
/**
|
|
712
712
|
* Behaves exactly like `path.relative(from, to)`, but keeps the first meaningful "./"
|
|
713
713
|
*/
|
|
714
714
|
function relativeSafe(from, to) {
|
|
715
|
-
return normalizeSafe(`.${separator}${toUnix(
|
|
715
|
+
return normalizeSafe(`.${separator}${toUnix(path.relative(toUnix(from), toUnix(to)))}`);
|
|
716
716
|
}
|
|
717
717
|
function getSchemaFileName(path) {
|
|
718
718
|
return path.replace(`.${getExtension(path)}`, "").slice(path.lastIndexOf("/") + 1);
|
|
@@ -721,13 +721,13 @@ const separator = "/";
|
|
|
721
721
|
function normalizeSafe(value) {
|
|
722
722
|
let result;
|
|
723
723
|
value = toUnix(value);
|
|
724
|
-
result = toUnix(
|
|
724
|
+
result = toUnix(path.normalize(value));
|
|
725
725
|
if (value.startsWith("./") && !result.startsWith("./") && !result.startsWith("..")) result = "./" + result;
|
|
726
726
|
else if (value.startsWith("//") && !result.startsWith("//")) result = value.startsWith("//./") ? "//." + result : "/" + result;
|
|
727
727
|
return result;
|
|
728
728
|
}
|
|
729
729
|
function joinSafe(...values) {
|
|
730
|
-
let result = toUnix(
|
|
730
|
+
let result = toUnix(path.join(...values.map((v) => toUnix(v))));
|
|
731
731
|
if (values.length > 0) {
|
|
732
732
|
const firstValue = toUnix(values[0]);
|
|
733
733
|
if (firstValue.startsWith("./") && !result.startsWith("./") && !result.startsWith("..")) result = "./" + result;
|
|
@@ -758,14 +758,14 @@ function joinSafe(...values) {
|
|
|
758
758
|
* @returns The relative import path string.
|
|
759
759
|
*/
|
|
760
760
|
function getRelativeImportPath(importerFilePath, exporterFilePath, includeFileExtension = false) {
|
|
761
|
-
if (!
|
|
762
|
-
if (!
|
|
763
|
-
const importerDir =
|
|
764
|
-
const relativePath =
|
|
765
|
-
let posixPath =
|
|
761
|
+
if (!path.isAbsolute(importerFilePath)) throw new Error(`'importerFilePath' is not an absolute path. "${importerFilePath}"`);
|
|
762
|
+
if (!path.isAbsolute(exporterFilePath)) throw new Error(`'exporterFilePath' is not an absolute path. "${exporterFilePath}"`);
|
|
763
|
+
const importerDir = path.dirname(importerFilePath);
|
|
764
|
+
const relativePath = path.relative(importerDir, exporterFilePath);
|
|
765
|
+
let posixPath = path.posix.join(...relativePath.split(path.sep));
|
|
766
766
|
if (!posixPath.startsWith("./") && !posixPath.startsWith("../")) posixPath = `./${posixPath}`;
|
|
767
767
|
if (!includeFileExtension) {
|
|
768
|
-
const ext =
|
|
768
|
+
const ext = path.extname(posixPath);
|
|
769
769
|
if (ext && posixPath.endsWith(ext)) posixPath = posixPath.slice(0, -ext.length);
|
|
770
770
|
}
|
|
771
771
|
return posixPath;
|
|
@@ -775,20 +775,20 @@ function getRelativeImportPath(importerFilePath, exporterFilePath, includeFileEx
|
|
|
775
775
|
//#region src/utils/resolve-version.ts
|
|
776
776
|
function resolveInstalledVersion(packageName, fromDir) {
|
|
777
777
|
try {
|
|
778
|
-
const require = createRequire(
|
|
778
|
+
const require = createRequire(path.join(fromDir, "noop.js"));
|
|
779
779
|
try {
|
|
780
780
|
return require(`${packageName}/package.json`).version;
|
|
781
781
|
} catch (directError) {
|
|
782
782
|
if (directError instanceof Error && "code" in directError && directError.code === "ERR_PACKAGE_PATH_NOT_EXPORTED") {
|
|
783
783
|
const entryPath = require.resolve(packageName);
|
|
784
|
-
let dir =
|
|
785
|
-
while (dir !==
|
|
786
|
-
const pkgPath =
|
|
784
|
+
let dir = path.dirname(entryPath);
|
|
785
|
+
while (dir !== path.parse(dir).root) {
|
|
786
|
+
const pkgPath = path.join(dir, "package.json");
|
|
787
787
|
if (existsSync(pkgPath)) {
|
|
788
788
|
const pkgData = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
789
789
|
if (pkgData.name === packageName) return pkgData.version;
|
|
790
790
|
}
|
|
791
|
-
dir =
|
|
791
|
+
dir = path.dirname(dir);
|
|
792
792
|
}
|
|
793
793
|
return;
|
|
794
794
|
}
|
|
@@ -2103,17 +2103,18 @@ function getKey(key) {
|
|
|
2103
2103
|
//#region src/getters/object.ts
|
|
2104
2104
|
/**
|
|
2105
2105
|
* Extract enum values from propertyNames schema (OpenAPI 3.1)
|
|
2106
|
-
*
|
|
2106
|
+
* Handles both `enum` and `const` (treated as a single-element enum)
|
|
2107
|
+
* Returns undefined if propertyNames has neither
|
|
2107
2108
|
*/
|
|
2108
2109
|
function getPropertyNamesEnum(item) {
|
|
2109
|
-
if ("propertyNames" in item
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2110
|
+
if (!("propertyNames" in item) || !item.propertyNames) return;
|
|
2111
|
+
const propertyNames = item.propertyNames;
|
|
2112
|
+
if (Array.isArray(propertyNames.enum)) return propertyNames.enum.filter((val) => isString(val));
|
|
2113
|
+
if (isString(propertyNames.const)) return [propertyNames.const];
|
|
2113
2114
|
}
|
|
2114
2115
|
/**
|
|
2115
|
-
* Generate index signature key type based on propertyNames enum
|
|
2116
|
-
* Returns union type string like "'foo' | 'bar'" or 'string' if
|
|
2116
|
+
* Generate index signature key type based on propertyNames enum or const
|
|
2117
|
+
* Returns union type string like "'foo' | 'bar'", "'x'", or 'string' if neither
|
|
2117
2118
|
*/
|
|
2118
2119
|
function getIndexSignatureKey(item) {
|
|
2119
2120
|
const enumValues = getPropertyNamesEnum(item);
|
|
@@ -4246,7 +4247,7 @@ function normalizeCanonicalImportPaths(schemas, canonicalPathMap, canonicalNameM
|
|
|
4246
4247
|
const canonicalByPath = canonicalPathMap.get(resolvedImportKey);
|
|
4247
4248
|
const canonical = canonicalByName ?? canonicalByPath;
|
|
4248
4249
|
if (!canonical?.importPath) return imp;
|
|
4249
|
-
const importPath =
|
|
4250
|
+
const importPath = removeTSExtension(relativeSafe(schemaPath, canonical.importPath.replaceAll("\\", "/")));
|
|
4250
4251
|
return {
|
|
4251
4252
|
...imp,
|
|
4252
4253
|
importPath
|
|
@@ -4269,8 +4270,8 @@ function mergeSchemaGroup(schemas) {
|
|
|
4269
4270
|
function resolveImportKey(schemaPath, importPath, fileExtension) {
|
|
4270
4271
|
return join(schemaPath, `${importPath}${fileExtension}`).toLowerCase().replaceAll("\\", "/");
|
|
4271
4272
|
}
|
|
4272
|
-
function
|
|
4273
|
-
return path.endsWith(
|
|
4273
|
+
function removeTSExtension(path) {
|
|
4274
|
+
return path.endsWith(".ts") ? path.slice(0, -3) : path;
|
|
4274
4275
|
}
|
|
4275
4276
|
function getSchema({ schema: { imports, model }, header, namingConvention = NamingConvention.CAMEL_CASE }) {
|
|
4276
4277
|
let file = header;
|
|
@@ -4282,8 +4283,8 @@ function getSchema({ schema: { imports, model }, header, namingConvention = Nami
|
|
|
4282
4283
|
file += model;
|
|
4283
4284
|
return file;
|
|
4284
4285
|
}
|
|
4285
|
-
function getPath(path, name, fileExtension) {
|
|
4286
|
-
return
|
|
4286
|
+
function getPath(path$1, name, fileExtension) {
|
|
4287
|
+
return path.join(path$1, `${name}${fileExtension}`);
|
|
4287
4288
|
}
|
|
4288
4289
|
function writeModelInline(acc, model) {
|
|
4289
4290
|
return acc + `${model}\n`;
|
|
@@ -4332,7 +4333,7 @@ async function writeSchemas({ schemaPath, schemas, target, namingConvention, fil
|
|
|
4332
4333
|
});
|
|
4333
4334
|
}
|
|
4334
4335
|
if (indexFiles) {
|
|
4335
|
-
const schemaFilePath =
|
|
4336
|
+
const schemaFilePath = path.join(schemaPath, `index.ts`);
|
|
4336
4337
|
await fs$1.ensureFile(schemaFilePath);
|
|
4337
4338
|
const ext = fileExtension.endsWith(".ts") ? fileExtension.slice(0, -3) : fileExtension;
|
|
4338
4339
|
const conventionNamesSet = new Set(Object.values(schemaGroups).map((group) => conventionName(group[0].name, namingConvention)));
|
|
@@ -4610,7 +4611,7 @@ async function writeSplitMode({ builder, output, projectName, header, needSchema
|
|
|
4610
4611
|
isAllowSyntheticDefaultImports,
|
|
4611
4612
|
options: isFunction(output.mock) ? void 0 : output.mock
|
|
4612
4613
|
});
|
|
4613
|
-
const schemasPath = output.schemas ? void 0 :
|
|
4614
|
+
const schemasPath = output.schemas ? void 0 : path.join(dirname, filename + ".schemas" + extension);
|
|
4614
4615
|
if (schemasPath && needSchema) await writeGeneratedFile(schemasPath, generateSchemasInline ? header + generateSchemasInline() : header + generateModelsInline(builder.schemas));
|
|
4615
4616
|
if (mutators) implementationData += generateMutatorImports({
|
|
4616
4617
|
mutators,
|
|
@@ -4632,9 +4633,9 @@ async function writeSplitMode({ builder, output, projectName, header, needSchema
|
|
|
4632
4633
|
implementationData += `\n${implementation}`;
|
|
4633
4634
|
mockData += `\n${implementationMock}`;
|
|
4634
4635
|
const implementationFilename = filename + (OutputClient.ANGULAR === output.client ? ".service" : "") + extension;
|
|
4635
|
-
const implementationPath =
|
|
4636
|
+
const implementationPath = path.join(dirname, implementationFilename);
|
|
4636
4637
|
await writeGeneratedFile(implementationPath, implementationData);
|
|
4637
|
-
const mockPath = output.mock ?
|
|
4638
|
+
const mockPath = output.mock ? path.join(dirname, filename + "." + getMockFileExtensionByTypeName(output.mock) + extension) : void 0;
|
|
4638
4639
|
if (mockPath) await writeGeneratedFile(mockPath, mockData);
|
|
4639
4640
|
return [
|
|
4640
4641
|
implementationPath,
|
|
@@ -4771,7 +4772,7 @@ async function writeSplitTagsMode({ builder, output, projectName, header, needSc
|
|
|
4771
4772
|
const target = generateTargetForTags(builder, output);
|
|
4772
4773
|
const isAllowSyntheticDefaultImports = isSyntheticDefaultImportsAllow(output.tsconfig);
|
|
4773
4774
|
const mockOption = output.mock && !isFunction(output.mock) ? output.mock : void 0;
|
|
4774
|
-
const indexFilePath = mockOption?.indexMockFiles ?
|
|
4775
|
+
const indexFilePath = mockOption?.indexMockFiles ? path.join(dirname, "index." + getMockFileExtensionByTypeName(mockOption) + extension) : void 0;
|
|
4775
4776
|
if (indexFilePath) await fs$1.outputFile(indexFilePath, "");
|
|
4776
4777
|
const tagEntries = Object.entries(target);
|
|
4777
4778
|
const generatedFilePathsArray = await Promise.all(tagEntries.map(async ([tag, target]) => {
|
|
@@ -4779,19 +4780,19 @@ async function writeSplitTagsMode({ builder, output, projectName, header, needSc
|
|
|
4779
4780
|
const { imports, implementation, implementationMock, importsMock, mutators, clientMutators, formData, fetchReviver, formUrlEncoded, paramsSerializer } = target;
|
|
4780
4781
|
let implementationData = header;
|
|
4781
4782
|
let mockData = header;
|
|
4782
|
-
const importerPath =
|
|
4783
|
+
const importerPath = path.join(dirname, tag, tag + extension);
|
|
4783
4784
|
const relativeSchemasPath = output.schemas ? getRelativeImportPath(importerPath, getFileInfo(isString(output.schemas) ? output.schemas : output.schemas.path, { extension: output.fileExtension }).dirname) : "../" + filename + ".schemas" + extension.replace(/\.ts$/, "");
|
|
4784
4785
|
const tagNames = new Set(tagEntries.map(([t]) => t));
|
|
4785
4786
|
const serviceSuffix = OutputClient.ANGULAR === output.client ? ".service" : "";
|
|
4786
4787
|
const importsForBuilder = generateImportsForBuilder(output, imports.map((imp) => {
|
|
4787
4788
|
if (!imp.importPath) return imp;
|
|
4788
4789
|
if (!imp.importPath.startsWith(".")) return imp;
|
|
4789
|
-
const resolvedPath =
|
|
4790
|
-
const targetBasename =
|
|
4790
|
+
const resolvedPath = path.resolve(dirname, imp.importPath);
|
|
4791
|
+
const targetBasename = path.basename(resolvedPath);
|
|
4791
4792
|
let targetFile;
|
|
4792
4793
|
if (tagNames.has(targetBasename)) {
|
|
4793
4794
|
const tagFilename = targetBasename + serviceSuffix + extension;
|
|
4794
|
-
targetFile =
|
|
4795
|
+
targetFile = path.join(resolvedPath, tagFilename);
|
|
4795
4796
|
} else targetFile = resolvedPath + extension;
|
|
4796
4797
|
const adjustedPath = getRelativeImportPath(importerPath, targetFile);
|
|
4797
4798
|
return {
|
|
@@ -4821,7 +4822,7 @@ async function writeSplitTagsMode({ builder, output, projectName, header, needSc
|
|
|
4821
4822
|
isAllowSyntheticDefaultImports,
|
|
4822
4823
|
options: isFunction(output.mock) ? void 0 : output.mock
|
|
4823
4824
|
});
|
|
4824
|
-
const schemasPath = output.schemas ? void 0 :
|
|
4825
|
+
const schemasPath = output.schemas ? void 0 : path.join(dirname, filename + ".schemas" + extension);
|
|
4825
4826
|
if (schemasPath && needSchema) await writeGeneratedFile(schemasPath, generateSchemasInline ? header + generateSchemasInline() : header + generateModelsInline(builder.schemas));
|
|
4826
4827
|
if (mutators) implementationData += generateMutatorImports({
|
|
4827
4828
|
mutators,
|
|
@@ -4859,9 +4860,9 @@ async function writeSplitTagsMode({ builder, output, projectName, header, needSc
|
|
|
4859
4860
|
implementationData += `\n${implementation}`;
|
|
4860
4861
|
mockData += `\n${implementationMock}`;
|
|
4861
4862
|
const implementationFilename = tag + (OutputClient.ANGULAR === output.client ? ".service" : "") + extension;
|
|
4862
|
-
const implementationPath =
|
|
4863
|
+
const implementationPath = path.join(dirname, tag, implementationFilename);
|
|
4863
4864
|
await writeGeneratedFile(implementationPath, implementationData);
|
|
4864
|
-
const mockPath = output.mock ?
|
|
4865
|
+
const mockPath = output.mock ? path.join(dirname, tag, tag + "." + getMockFileExtensionByTypeName(output.mock) + extension) : void 0;
|
|
4865
4866
|
if (mockPath) await writeGeneratedFile(mockPath, mockData);
|
|
4866
4867
|
return [
|
|
4867
4868
|
implementationPath,
|
|
@@ -4931,7 +4932,7 @@ async function writeTagsMode({ builder, output, projectName, header, needSchema,
|
|
|
4931
4932
|
options: isFunction(output.mock) ? void 0 : output.mock
|
|
4932
4933
|
});
|
|
4933
4934
|
}
|
|
4934
|
-
const schemasPath = output.schemas ? void 0 :
|
|
4935
|
+
const schemasPath = output.schemas ? void 0 : path.join(dirname, filename + ".schemas" + extension);
|
|
4935
4936
|
if (schemasPath && needSchema) await writeGeneratedFile(schemasPath, generateSchemasInline ? header + generateSchemasInline() : header + generateModelsInline(builder.schemas));
|
|
4936
4937
|
if (mutators) data += generateMutatorImports({
|
|
4937
4938
|
mutators,
|
|
@@ -4956,7 +4957,7 @@ async function writeTagsMode({ builder, output, projectName, header, needSchema,
|
|
|
4956
4957
|
data += "\n\n";
|
|
4957
4958
|
data += implementationMock;
|
|
4958
4959
|
}
|
|
4959
|
-
const implementationPath =
|
|
4960
|
+
const implementationPath = path.join(dirname, `${kebab(tag)}${extension}`);
|
|
4960
4961
|
await writeGeneratedFile(implementationPath, data);
|
|
4961
4962
|
return [implementationPath, ...schemasPath ? [schemasPath] : []];
|
|
4962
4963
|
} catch (error) {
|