@orval/core 8.17.0 → 8.18.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 CHANGED
@@ -265,7 +265,7 @@ interface NormalizedFactoryMethodsOptions {
265
265
  }
266
266
  interface SchemaOptions {
267
267
  path: string;
268
- type: SchemaGenerationType;
268
+ type?: SchemaGenerationType;
269
269
  importPath?: string;
270
270
  }
271
271
  interface NormalizedSchemaOptions {
@@ -407,6 +407,7 @@ interface MswMockOptions extends CommonMockOptions {
407
407
  interface FakerMockOptions extends CommonMockOptions {
408
408
  type: typeof OutputMockType.FAKER;
409
409
  schemas?: boolean;
410
+ schemasImportPath?: string;
410
411
  operationResponses?: boolean;
411
412
  path?: string;
412
413
  }
@@ -671,7 +672,7 @@ interface EffectOptions {
671
672
  generateEachHttpStatus?: boolean;
672
673
  useBrandedTypes?: boolean;
673
674
  }
674
- type ZodCoerceType = 'string' | 'number' | 'boolean' | 'bigint' | 'date';
675
+ type ZodCoerceType = 'string' | 'number' | 'boolean' | 'bigint' | 'date' | 'array';
675
676
  interface NormalizedZodOptions {
676
677
  strict: {
677
678
  param: boolean;
@@ -1074,11 +1075,13 @@ interface GeneratorApiResponse {
1074
1075
  schemas: GeneratorSchema[];
1075
1076
  }
1076
1077
  type GeneratorOperations = Record<string, GeneratorOperation>;
1078
+ type StrictMockSchemaKind = 'object' | 'alias' | 'binary';
1077
1079
  interface GeneratorMockOutput {
1078
1080
  type: OutputMockType;
1079
1081
  implementation: string;
1080
1082
  imports: GeneratorImport[];
1081
1083
  strictMockSchemaTypeNames?: string[];
1084
+ strictMockSchemaKinds?: Record<string, StrictMockSchemaKind>;
1082
1085
  }
1083
1086
  interface GeneratorMockOutputFull {
1084
1087
  type: OutputMockType;
@@ -1089,6 +1092,7 @@ interface GeneratorMockOutputFull {
1089
1092
  };
1090
1093
  imports: GeneratorImport[];
1091
1094
  strictMockSchemaTypeNames?: string[];
1095
+ strictMockSchemaKinds?: Record<string, StrictMockSchemaKind>;
1092
1096
  }
1093
1097
  interface GeneratorTarget {
1094
1098
  imports: GeneratorImport[];
@@ -1225,6 +1229,7 @@ interface ClientMockGeneratorBuilder {
1225
1229
  imports: GeneratorImport[];
1226
1230
  implementation: ClientMockGeneratorImplementation;
1227
1231
  strictMockSchemaTypeNames?: string[];
1232
+ strictMockSchemaKinds?: Record<string, StrictMockSchemaKind>;
1228
1233
  }
1229
1234
  type ClientMockBuilder = (verbOptions: GeneratorVerbOptions, generatorOptions: GeneratorOptions) => ClientMockGeneratorBuilder;
1230
1235
  interface ClientGeneratorsBuilder {
@@ -1364,6 +1369,7 @@ type ResReqTypesValue = ScalarValue & {
1364
1369
  interface FinalizeMockImplementationOptions {
1365
1370
  mockOptions?: Pick<MockOptions, 'required' | 'nonNullable'>;
1366
1371
  strictSchemaTypeNames?: readonly string[];
1372
+ strictMockSchemaKinds?: Readonly<Record<string, StrictMockSchemaKind>>;
1367
1373
  }
1368
1374
  interface WriteSpecBuilder {
1369
1375
  operations: GeneratorOperations;
@@ -2874,5 +2880,5 @@ declare function generateTargetForTags(builder: WriteSpecBuilder, options: Norma
2874
2880
  declare function getOrvalGeneratedTypes(): string;
2875
2881
  declare function getTypedResponse(): string;
2876
2882
  //#endregion
2877
- export { AngularHttpResourceOptions, AngularOptions, BODY_TYPE_NAME, BaseUrlFromConstant, BaseUrlFromSpec, BaseUrlRuntime, BoundAliasInfo, ClientBuilder, ClientDependenciesBuilder, ClientExtraFilesBuilder, ClientFileBuilder, ClientFooterBuilder, ClientGeneratorsBuilder, ClientHeaderBuilder, ClientMockBuilder, ClientMockGeneratorBuilder, ClientMockGeneratorImplementation, ClientTitleBuilder, CommonMockOptions, Config, ConfigExternal, ConfigFn, ContentTypeFilter, ContextSpec, DeepNonNullable, DefaultTag, DynamicScopeEntry, EffectOptions, EnumGeneration, ErrorWithTag, FactoryMethodsMode, FactoryMethodsOptions, FakerMockOptions, FetchOptions, FinalizeMockImplementationOptions, FormDataArrayHandling, FormDataContext, FormDataType, GenerateMockImports, GenerateVerbOptionsParams, GenerateVerbsOptionsParams, GeneratorApiBuilder, GeneratorApiOperations, GeneratorApiResponse, GeneratorClient, GeneratorClientExtra, GeneratorClientFooter, GeneratorClientHeader, GeneratorClientImports, GeneratorClientTitle, GeneratorClients, GeneratorDependency, GeneratorImport, GeneratorMockOutput, GeneratorMockOutputFull, GeneratorMutator, GeneratorMutatorParsingInfo, GeneratorOperation, GeneratorOperations, GeneratorOptions, GeneratorSchema, GeneratorTarget, GeneratorTargetFull, GeneratorVerbOptions, GeneratorVerbsOptions, GetterBody, GetterParam, GetterParameters, GetterParams, GetterProp, GetterPropType, GetterProps, GetterQueryParam, GetterResponse, GlobalMockOptions, GlobalOptions, HonoHandlerStrategy, HonoOptions, Hook, HookCommand, HookFunction, HookOption, HooksOptions, ImportOpenApi, InputFiltersOptions, InputOptions, InputTransformerFn, InvalidateTarget, InvalidateTargetParam, JsDocOptions, LogLevel, LogLevels, LogOptions, LogType, Logger, LoggerOptions, McpOptions, McpServerOptions, MockData, MockDataArray, MockDataArrayFn, MockDataObject, MockDataObjectFn, MockOptions, MockProperties, MockPropertiesObject, MockPropertiesObjectFn, MswMockOptions, MutationInvalidatesConfig, MutationInvalidatesRule, Mutator, MutatorObject, NAMED_COMPONENT_SECTIONS, NamingConvention, NormalizedAngularOptions, NormalizedConfig, NormalizedEffectOptions, NormalizedFactoryMethodsOptions, NormalizedFetchOptions, NormalizedFormDataType, NormalizedHonoOptions, NormalizedHookCommand, NormalizedHookOptions, NormalizedInputOptions, NormalizedJsDocOptions, NormalizedMcpOptions, NormalizedMcpServerOptions, NormalizedMocksConfig, NormalizedMutator, NormalizedOperationOptions, NormalizedOptions, NormalizedOutputOptions, NormalizedOverrideOutput, NormalizedParamsSerializerOptions, NormalizedQueryOptions, NormalizedSchemaOptions, NormalizedZodOptions, OpenApiComponentsObject, OpenApiDocument, OpenApiDynamicReferenceObject, 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, OutputMocksConfig, OutputMocksOption, OutputMode, OutputOptions, OverrideInput, OverrideMockOptions, OverrideOutput, OverrideOutputContentType, PackageJson, ParamsSerializerOptions, PreferredContentType, PropertySortOrder, QueryOptions, ReadonlyRequestBodiesMode, RefComponentSuffix, RefInfo, ResReqTypesValue, ResolverValue, ResponseTypeCategory, ScalarValue, SchemaGenerationType, SchemaOptionLike, SchemaOptions, SchemaType, SupportedFormatter, SwrOptions, TEMPLATE_TAG_REGEX, TsConfigModule, TsConfigModuleResolution, TsConfigTarget, Tsconfig, URL_REGEX, VERBS_WITH_BODY, Verbs, WriteModeProps, WriteSpecBuilder, ZodCoerceType, ZodDateTimeOptions, ZodOptions, ZodTimeOptions, addDependency, asyncReduce, buildAngularParamsFilterExpression, buildDynamicScope, 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, getOrvalGeneratedTypes, getParameters, getParams, getParamsInPath, getPropertySafe, getProps, getQueryParams, getRefInfo, getResReqTypes, getResponse, getResponseTypeCategory, getRoute, getRouteAsArray, getScalar, getSchemasImportPath, getSuccessResponseType, getTypedResponse, getWarningCount, isBinaryContentType, isBinaryScalarSchema, isBoolean, isComponentRef, isDirectory, isDynamicReference, isFakerMock, isFunction, isModule, isMswMock, isNullish, isNumber, isNumeric, isObject, 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_d_exports as upath, upper, wrapRouteParameters, writeGeneratedFile, writeModelInline, writeModelsInline, writeSchema, writeSchemas, writeSingleMode, writeSplitMode, writeSplitTagsMode, writeTagsMode };
2883
+ export { AngularHttpResourceOptions, AngularOptions, BODY_TYPE_NAME, BaseUrlFromConstant, BaseUrlFromSpec, BaseUrlRuntime, BoundAliasInfo, ClientBuilder, ClientDependenciesBuilder, ClientExtraFilesBuilder, ClientFileBuilder, ClientFooterBuilder, ClientGeneratorsBuilder, ClientHeaderBuilder, ClientMockBuilder, ClientMockGeneratorBuilder, ClientMockGeneratorImplementation, ClientTitleBuilder, CommonMockOptions, Config, ConfigExternal, ConfigFn, ContentTypeFilter, ContextSpec, DeepNonNullable, DefaultTag, DynamicScopeEntry, EffectOptions, EnumGeneration, ErrorWithTag, FactoryMethodsMode, FactoryMethodsOptions, FakerMockOptions, FetchOptions, FinalizeMockImplementationOptions, FormDataArrayHandling, FormDataContext, FormDataType, GenerateMockImports, GenerateVerbOptionsParams, GenerateVerbsOptionsParams, GeneratorApiBuilder, GeneratorApiOperations, GeneratorApiResponse, GeneratorClient, GeneratorClientExtra, GeneratorClientFooter, GeneratorClientHeader, GeneratorClientImports, GeneratorClientTitle, GeneratorClients, GeneratorDependency, GeneratorImport, GeneratorMockOutput, GeneratorMockOutputFull, GeneratorMutator, GeneratorMutatorParsingInfo, GeneratorOperation, GeneratorOperations, GeneratorOptions, GeneratorSchema, GeneratorTarget, GeneratorTargetFull, GeneratorVerbOptions, GeneratorVerbsOptions, GetterBody, GetterParam, GetterParameters, GetterParams, GetterProp, GetterPropType, GetterProps, GetterQueryParam, GetterResponse, GlobalMockOptions, GlobalOptions, HonoHandlerStrategy, HonoOptions, Hook, HookCommand, HookFunction, HookOption, HooksOptions, ImportOpenApi, InputFiltersOptions, InputOptions, InputTransformerFn, InvalidateTarget, InvalidateTargetParam, JsDocOptions, LogLevel, LogLevels, LogOptions, LogType, Logger, LoggerOptions, McpOptions, McpServerOptions, MockData, MockDataArray, MockDataArrayFn, MockDataObject, MockDataObjectFn, MockOptions, MockProperties, MockPropertiesObject, MockPropertiesObjectFn, MswMockOptions, MutationInvalidatesConfig, MutationInvalidatesRule, Mutator, MutatorObject, NAMED_COMPONENT_SECTIONS, NamingConvention, NormalizedAngularOptions, NormalizedConfig, NormalizedEffectOptions, NormalizedFactoryMethodsOptions, NormalizedFetchOptions, NormalizedFormDataType, NormalizedHonoOptions, NormalizedHookCommand, NormalizedHookOptions, NormalizedInputOptions, NormalizedJsDocOptions, NormalizedMcpOptions, NormalizedMcpServerOptions, NormalizedMocksConfig, NormalizedMutator, NormalizedOperationOptions, NormalizedOptions, NormalizedOutputOptions, NormalizedOverrideOutput, NormalizedParamsSerializerOptions, NormalizedQueryOptions, NormalizedSchemaOptions, NormalizedZodOptions, OpenApiComponentsObject, OpenApiDocument, OpenApiDynamicReferenceObject, 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, OutputMocksConfig, OutputMocksOption, OutputMode, OutputOptions, OverrideInput, OverrideMockOptions, OverrideOutput, OverrideOutputContentType, PackageJson, ParamsSerializerOptions, PreferredContentType, PropertySortOrder, QueryOptions, ReadonlyRequestBodiesMode, RefComponentSuffix, RefInfo, ResReqTypesValue, ResolverValue, ResponseTypeCategory, ScalarValue, SchemaGenerationType, SchemaOptionLike, SchemaOptions, SchemaType, StrictMockSchemaKind, SupportedFormatter, SwrOptions, TEMPLATE_TAG_REGEX, TsConfigModule, TsConfigModuleResolution, TsConfigTarget, Tsconfig, URL_REGEX, VERBS_WITH_BODY, Verbs, WriteModeProps, WriteSpecBuilder, ZodCoerceType, ZodDateTimeOptions, ZodOptions, ZodTimeOptions, addDependency, asyncReduce, buildAngularParamsFilterExpression, buildDynamicScope, 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, getOrvalGeneratedTypes, getParameters, getParams, getParamsInPath, getPropertySafe, getProps, getQueryParams, getRefInfo, getResReqTypes, getResponse, getResponseTypeCategory, getRoute, getRouteAsArray, getScalar, getSchemasImportPath, getSuccessResponseType, getTypedResponse, getWarningCount, isBinaryContentType, isBinaryScalarSchema, isBoolean, isComponentRef, isDirectory, isDynamicReference, isFakerMock, isFunction, isModule, isMswMock, isNullish, isNumber, isNumeric, isObject, 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_d_exports as upath, upper, wrapRouteParameters, writeGeneratedFile, writeModelInline, writeModelsInline, writeSchema, writeSchemas, writeSingleMode, writeSplitMode, writeSplitTagsMode, writeTagsMode };
2878
2884
  //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs CHANGED
@@ -955,17 +955,18 @@ const sortByPriority = (arr) => arr.toSorted((a, b) => {
955
955
  function stringify(data) {
956
956
  if (data === void 0) return;
957
957
  if (data === null) return "null";
958
- if (isString(data)) return `'${data.replaceAll("'", String.raw`\'`)}'`;
958
+ if (isString(data)) return `'${jsStringLiteralEscape(data)}'`;
959
959
  if (isNumber(data) || isBoolean(data) || isFunction(data)) return String(data);
960
960
  if (Array.isArray(data)) return `[${data.map((item) => stringify(item)).join(", ")}]`;
961
961
  const entries = Object.entries(data);
962
962
  let result = "";
963
963
  for (const [index, [key, value]] of entries.entries()) {
964
964
  const strValue = stringify(value);
965
- if (entries.length === 1) result = `{ ${key}: ${strValue}, }`;
966
- else if (!index) result = `{ ${key}: ${strValue}, `;
967
- else if (entries.length - 1 === index) result += `${key}: ${strValue}, }`;
968
- else result += `${key}: ${strValue}, `;
965
+ const safeKey = key === "__proto__" ? `['${jsStringLiteralEscape(key)}']` : keyword.isIdentifierNameES5(key) ? key : `'${jsStringLiteralEscape(key)}'`;
966
+ if (entries.length === 1) result = `{ ${safeKey}: ${strValue}, }`;
967
+ else if (!index) result = `{ ${safeKey}: ${strValue}, `;
968
+ else if (entries.length - 1 === index) result += `${safeKey}: ${strValue}, }`;
969
+ else result += `${safeKey}: ${strValue}, `;
969
970
  }
970
971
  return result;
971
972
  }
@@ -4618,9 +4619,10 @@ function parseFunction(ast, funcName) {
4618
4619
  //#endregion
4619
4620
  //#region src/generators/mutator.ts
4620
4621
  const BODY_TYPE_NAME = "BodyType";
4621
- const getImport = (output, mutator) => {
4622
+ const getImport = (output, mutator, tsconfig) => {
4622
4623
  const outputFile = getFileInfo(output).path;
4623
- return `${getRelativeImportPath(outputFile, mutator.path)}${mutator.extension ?? ""}`;
4624
+ const ext = mutator.extension ?? getImportExtension(nodePath.extname(mutator.path), tsconfig);
4625
+ return `${getRelativeImportPath(outputFile, mutator.path)}${ext}`;
4624
4626
  };
4625
4627
  async function generateMutator({ output, mutator, name, workspace, tsconfig }) {
4626
4628
  if (!mutator || !output) return;
@@ -4643,7 +4645,7 @@ async function generateMutator({ output, mutator, name, workspace, tsconfig }) {
4643
4645
  tsconfig
4644
4646
  });
4645
4647
  if (!mutatorInfo) throw new Error(styleText("red", `Your mutator file doesn't have the ${mutatorInfoName} exported function`));
4646
- const importStatementPath = getImport(output, mutator);
4648
+ const importStatementPath = getImport(output, mutator, tsconfig);
4647
4649
  const isHook = mutator.name ? mutator.name.startsWith("use") && !mutatorInfo.numberOfParams : !mutatorInfo.numberOfParams;
4648
4650
  return {
4649
4651
  name: mutator.name || !isHook ? importName : `use${pascal(importName)}`,
@@ -4685,11 +4687,19 @@ const getAngularFilteredParamsExpression = (paramsExpression, requiredNullablePa
4685
4687
  continue;
4686
4688
  }
4687
4689
  ` : "";
4688
- const preserveNullableBranch = preserveRequiredNullables ? ` } else if (value === null && requiredNullableParamKeys.has(key)) {
4690
+ let preserveNullableBranch;
4691
+ let requiredNullableParamKeysBranch;
4692
+ if (preserveRequiredNullables) {
4693
+ preserveNullableBranch = ` } else if (value === null && requiredNullableParamKeys.has(key)) {
4689
4694
  filteredParams[key] = null;
4690
- ` : "";
4695
+ `;
4696
+ requiredNullableParamKeysBranch = `const requiredNullableParamKeys = new Set<string>(${JSON.stringify(requiredNullableParamKeys)});`;
4697
+ } else {
4698
+ preserveNullableBranch = "";
4699
+ requiredNullableParamKeysBranch = "";
4700
+ }
4691
4701
  return `(() => {
4692
- ${hasPassthrough ? ` const passthroughKeys = new Set<string>(${JSON.stringify(nonPrimitiveKeys)});\n` : ""} const requiredNullableParamKeys = new Set<string>(${JSON.stringify(requiredNullableParamKeys)});
4702
+ ${hasPassthrough ? ` const passthroughKeys = new Set<string>(${JSON.stringify(nonPrimitiveKeys)});\n` : ""} ${requiredNullableParamKeysBranch}
4693
4703
  const filteredParams: Record<string, ${filteredParamValueType}> = {};
4694
4704
  for (const [key, value] of Object.entries(${paramsExpression})) {
4695
4705
  ${passthroughBranch} if (Array.isArray(value)) {
@@ -5747,12 +5757,25 @@ async function writeSchemas({ schemaPath, schemas, target, namingConvention, fil
5747
5757
  //#endregion
5748
5758
  //#region src/writers/finalize-mock-implementation.ts
5749
5759
  function getFinalizeMockImplementationOptions(output, mockOutputs) {
5750
- const strictSchemaTypeNames = [...new Set((Array.isArray(mockOutputs) ? mockOutputs : [mockOutputs]).flatMap((mockOutput) => mockOutput.strictMockSchemaTypeNames ?? []))];
5760
+ const outputs = Array.isArray(mockOutputs) ? mockOutputs : [mockOutputs];
5761
+ const strictSchemaTypeNames = [...new Set(outputs.flatMap((mockOutput) => mockOutput.strictMockSchemaTypeNames ?? []))];
5762
+ const strictMockSchemaKinds = outputs.reduce((acc, mockOutput) => {
5763
+ if (!mockOutput.strictMockSchemaKinds) return acc;
5764
+ for (const [name, kind] of Object.entries(mockOutput.strictMockSchemaKinds)) acc[name] ??= kind;
5765
+ return acc;
5766
+ }, {});
5751
5767
  return {
5752
5768
  mockOptions: output.override.mock,
5753
- strictSchemaTypeNames: strictSchemaTypeNames.length > 0 ? strictSchemaTypeNames : void 0
5769
+ strictSchemaTypeNames: strictSchemaTypeNames.length > 0 ? strictSchemaTypeNames : void 0,
5770
+ strictMockSchemaKinds: Object.keys(strictMockSchemaKinds).length > 0 ? strictMockSchemaKinds : void 0
5754
5771
  };
5755
5772
  }
5773
+ /** Drop schema-factory `{Schema}Mock` type imports that are declared locally. */
5774
+ function filterLocalStrictMockTypeImports(imports, strictSchemaTypeNames) {
5775
+ if (!strictSchemaTypeNames?.length) return [...imports];
5776
+ const localMockTypeNames = new Set(strictSchemaTypeNames.map((name) => `${name}Mock`));
5777
+ return imports.filter((imp) => !(imp.schemaFactory && !imp.values && localMockTypeNames.has(imp.name)));
5778
+ }
5756
5779
  //#endregion
5757
5780
  //#region src/writers/generate-imports-for-builder.ts
5758
5781
  function generateImportsForBuilder(output, imports, relativeSchemasPath) {
@@ -5760,9 +5783,10 @@ function generateImportsForBuilder(output, imports, relativeSchemasPath) {
5760
5783
  const isZodSchemaOutput = isObject(output.schemas) && output.schemas.type === "zod";
5761
5784
  const schemaFactoryImports = imports.filter((i) => i.schemaFactory);
5762
5785
  const schemaFactoryImportExtension = isPackageImport ? "" : getImportExtension(output.fileExtension, output.tsconfig);
5786
+ const schemaFactoryDependency = getFakerSchemasImportPath(output.mock) ?? joinSafe(relativeSchemasPath, `index.faker${schemaFactoryImportExtension}`);
5763
5787
  const schemaFactoryDeps = schemaFactoryImports.length > 0 ? [{
5764
5788
  exports: uniqueBy(schemaFactoryImports, (entry) => `${entry.name}|${entry.alias ?? ""}`),
5765
- dependency: joinSafe(relativeSchemasPath, `index.faker${schemaFactoryImportExtension}`)
5789
+ dependency: schemaFactoryDependency
5766
5790
  }] : [];
5767
5791
  imports = imports.filter((i) => !i.schemaFactory);
5768
5792
  let schemaImports;
@@ -5797,6 +5821,16 @@ function generateImportsForBuilder(output, imports, relativeSchemasPath) {
5797
5821
  ...otherImports
5798
5822
  ];
5799
5823
  }
5824
+ /**
5825
+ * Extracts the faker generator's `schemasImportPath` from the normalized mock
5826
+ * config, if one is configured. Returns `undefined` when there is no faker
5827
+ * generator with schema factories enabled, or when `schemasImportPath` is not
5828
+ * set.
5829
+ */
5830
+ function getFakerSchemasImportPath(mock) {
5831
+ if (!mock) return;
5832
+ return mock.generators.find((g) => !isFunction(g) && g.type === OutputMockType.FAKER && g.schemas === true)?.schemasImportPath;
5833
+ }
5800
5834
  //#endregion
5801
5835
  //#region src/writers/mock-outputs.ts
5802
5836
  /**
@@ -5844,7 +5878,8 @@ function flattenMockOutput$1(full) {
5844
5878
  type: full.type,
5845
5879
  implementation: full.implementation.function + full.implementation.handler,
5846
5880
  imports: full.imports,
5847
- strictMockSchemaTypeNames: full.strictMockSchemaTypeNames
5881
+ strictMockSchemaTypeNames: full.strictMockSchemaTypeNames,
5882
+ strictMockSchemaKinds: full.strictMockSchemaKinds
5848
5883
  };
5849
5884
  }
5850
5885
  function generateTarget(builder, options) {
@@ -5880,6 +5915,10 @@ function generateTarget(builder, options) {
5880
5915
  }
5881
5916
  acc.imports.push(...opMock.imports);
5882
5917
  if (opMock.strictMockSchemaTypeNames?.length) acc.strictMockSchemaTypeNames = [...new Set([...acc.strictMockSchemaTypeNames ?? [], ...opMock.strictMockSchemaTypeNames])];
5918
+ if (opMock.strictMockSchemaKinds) acc.strictMockSchemaKinds = {
5919
+ ...acc.strictMockSchemaKinds,
5920
+ ...opMock.strictMockSchemaKinds
5921
+ };
5883
5922
  acc.implementation.function += opMock.implementation.function;
5884
5923
  acc.implementation.handler += opMock.implementation.handler;
5885
5924
  if (opMock.implementation.handlerName) {
@@ -6019,7 +6058,8 @@ async function writeSingleMode({ builder, output, projectName, header, needSchem
6019
6058
  });
6020
6059
  if (!shouldDeinlineMocks) for (const mockOutput of collapsedMockOutputs) {
6021
6060
  const entry = output.mock.generators.find((g) => !isFunction(g) && g.type === mockOutput.type);
6022
- const filteredMockImports = mockOutput.imports.filter((impMock) => !normalizedImports.some((imp) => imp.name === impMock.name && (imp.alias ?? "") === (impMock.alias ?? "")));
6061
+ const finalizeMockOptions = getFinalizeMockImplementationOptions(output, mockOutput);
6062
+ const filteredMockImports = filterLocalStrictMockTypeImports(mockOutput.imports.filter((impMock) => !normalizedImports.some((imp) => imp.name === impMock.name && (imp.alias ?? "") === (impMock.alias ?? ""))), finalizeMockOptions.strictSchemaTypeNames);
6023
6063
  const importsMockForBuilder = schemasPath ? generateImportsForBuilder(output, filteredMockImports, relativeSchemasPath) : generateImportsForBuilder(output, filteredMockImports.filter((imp) => !!imp.importPath), ".");
6024
6064
  data += builder.importsMock({
6025
6065
  implementation: mockOutput.implementation,
@@ -6112,6 +6152,78 @@ async function writeSingleMode({ builder, output, projectName, header, needSchem
6112
6152
  }
6113
6153
  }
6114
6154
  //#endregion
6155
+ //#region src/writers/mock-imports.ts
6156
+ /** Maps `components/schemas` names to consolidated index.faker import symbols. */
6157
+ function buildKnownSchemaFactoryImportSets(schemaNames) {
6158
+ const factoryNames = /* @__PURE__ */ new Set();
6159
+ const typeNames = /* @__PURE__ */ new Set();
6160
+ for (const name of schemaNames) {
6161
+ const typeName = pascal(name);
6162
+ factoryNames.add(`get${typeName}Mock`);
6163
+ typeNames.add(`${typeName}Mock`);
6164
+ }
6165
+ return {
6166
+ factoryNames,
6167
+ typeNames
6168
+ };
6169
+ }
6170
+ /**
6171
+ * Recover schema-factory imports referenced in generated mock bodies but
6172
+ * missing from the collected import list (e.g. after shared-array import
6173
+ * aggregation on large specs). Scans for `get<Schema>Mock()` calls and
6174
+ * `as <Schema>Mock` casts emitted by strict schema delegation (#3590).
6175
+ *
6176
+ * When `knownSets` is provided, only symbols that exist in the consolidated
6177
+ * schemas faker file are recovered — this avoids importing one-off split
6178
+ * response helper factories that live in the tag file itself.
6179
+ */
6180
+ function collectSchemaFactoryImportsFromImplementation(implementation, knownSets) {
6181
+ const imports = [];
6182
+ const seen = /* @__PURE__ */ new Set();
6183
+ for (const match of implementation.matchAll(/\b(get[A-Za-z0-9]+Mock)\(\)/g)) {
6184
+ const factoryName = match[1];
6185
+ if (knownSets && !knownSets.factoryNames.has(factoryName)) continue;
6186
+ const key = `value::${factoryName}`;
6187
+ if (seen.has(key)) continue;
6188
+ seen.add(key);
6189
+ imports.push({
6190
+ name: factoryName,
6191
+ values: true,
6192
+ schemaFactory: true
6193
+ });
6194
+ }
6195
+ for (const match of implementation.matchAll(/\bas ([A-Za-z0-9]+Mock)\b/g)) {
6196
+ const typeName = match[1];
6197
+ if (knownSets && !knownSets.typeNames.has(typeName)) continue;
6198
+ const key = `type::${typeName}`;
6199
+ if (seen.has(key)) continue;
6200
+ seen.add(key);
6201
+ imports.push({
6202
+ name: typeName,
6203
+ values: false,
6204
+ schemaFactory: true
6205
+ });
6206
+ }
6207
+ return imports;
6208
+ }
6209
+ function mergeGeneratorImports(...groups) {
6210
+ const merged = /* @__PURE__ */ new Map();
6211
+ for (const group of groups) for (const imp of group) {
6212
+ const key = `${imp.name}::${imp.alias ?? ""}`;
6213
+ const existing = merged.get(key);
6214
+ if (!existing) {
6215
+ merged.set(key, imp);
6216
+ continue;
6217
+ }
6218
+ if (!existing.values && imp.values) merged.set(key, imp);
6219
+ }
6220
+ return [...merged.values()];
6221
+ }
6222
+ /** Recover missing index.faker imports when `schemas: true` is enabled. */
6223
+ function collectRecoveredSchemaFactoryImports(implementation, componentSchemaNames) {
6224
+ return collectSchemaFactoryImportsFromImplementation(implementation, buildKnownSchemaFactoryImportSets(componentSchemaNames));
6225
+ }
6226
+ //#endregion
6115
6227
  //#region src/writers/split-mode.ts
6116
6228
  async function writeSplitMode({ builder, output, projectName, header, needSchema, generateSchemasInline }) {
6117
6229
  try {
@@ -6122,8 +6234,8 @@ async function writeSplitMode({ builder, output, projectName, header, needSchema
6122
6234
  const { imports, implementation, mockOutputs, mutators, clientMutators, formData, formUrlEncoded, paramsSerializer, paramsFilter, fetchReviver } = generateTarget(builder, output);
6123
6235
  let implementationData = header;
6124
6236
  const schemaCustomImportPath = getSchemasImportPath(output.schemas);
6125
- const relativeSchemasPath = output.schemas ? schemaCustomImportPath ?? getRelativeImportPath(targetPath, getFileInfo(isString(output.schemas) ? output.schemas : output.schemas.path, { extension: output.fileExtension }).dirname) : "./" + filename + ".schemas" + extension.replace(/\.ts$/, "");
6126
- const schemasTarget = output.schemas ? getFileInfo(isString(output.schemas) ? output.schemas : output.schemas.path, { extension: output.fileExtension }).dirname : nodePath.join(dirname, filename + ".schemas" + extension.replace(/\.ts$/, ""));
6237
+ const relativeSchemasPath = output.schemas ? schemaCustomImportPath ?? getRelativeImportPath(targetPath, getFileInfo(isString(output.schemas) ? output.schemas : output.schemas.path, { extension: output.fileExtension }).dirname) : "./" + filename + ".schemas" + getImportExtension(extension, output.tsconfig);
6238
+ 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));
6127
6239
  const isAllowSyntheticDefaultImports = isSyntheticDefaultImportsAllow(output.tsconfig);
6128
6240
  const importsForBuilder = generateImportsForBuilder(output, imports, relativeSchemasPath);
6129
6241
  implementationData += builder.imports({
@@ -6176,9 +6288,11 @@ async function writeSplitMode({ builder, output, projectName, header, needSchema
6176
6288
  const mockDir = getMockDir(rawEntry, output.mock) ?? dirname;
6177
6289
  const mockFilePath = nodePath.join(mockDir, filename + "." + mockExtension + extension);
6178
6290
  const mockRelativeSchemasPath = schemaCustomImportPath ?? resolveMockSchemasPath(mockFilePath, schemasTarget);
6179
- const importsMockForBuilder = generateImportsForBuilder(output, mockOutput.imports, mockRelativeSchemasPath);
6291
+ const finalizeMockOptions = getFinalizeMockImplementationOptions(output, mockOutput);
6292
+ const finalizedMockImplementation = builder.finalizeMockImplementation ? builder.finalizeMockImplementation(mockOutput.implementation, finalizeMockOptions) : mockOutput.implementation;
6293
+ const recoveredSchemaFactoryImports = !isFunction(rawEntry) && rawEntry.type === OutputMockType.FAKER && rawEntry.schemas === true && output.schemas ? collectRecoveredSchemaFactoryImports(finalizedMockImplementation, builder.schemas.filter((s) => s.schema).map((s) => s.name)) : [];
6294
+ const importsMockForBuilder = generateImportsForBuilder(output, filterLocalStrictMockTypeImports(mergeGeneratorImports(mockOutput.imports, recoveredSchemaFactoryImports), finalizeMockOptions.strictSchemaTypeNames), mockRelativeSchemasPath);
6180
6295
  let mockData = header;
6181
- const finalizedMockImplementation = builder.finalizeMockImplementation ? builder.finalizeMockImplementation(mockOutput.implementation, getFinalizeMockImplementationOptions(output, mockOutput)) : mockOutput.implementation;
6182
6296
  mockData += builder.importsMock({
6183
6297
  implementation: finalizedMockImplementation,
6184
6298
  imports: importsMockForBuilder,
@@ -6248,7 +6362,8 @@ function flattenMockOutput(full) {
6248
6362
  type: full.type,
6249
6363
  implementation: full.implementation.function + full.implementation.handler,
6250
6364
  imports: full.imports,
6251
- strictMockSchemaTypeNames: full.strictMockSchemaTypeNames
6365
+ strictMockSchemaTypeNames: full.strictMockSchemaTypeNames,
6366
+ strictMockSchemaKinds: full.strictMockSchemaKinds
6252
6367
  };
6253
6368
  }
6254
6369
  function mergeOperationMockOutputs(accMockOutputs, opMockOutputs) {
@@ -6256,7 +6371,8 @@ function mergeOperationMockOutputs(accMockOutputs, opMockOutputs) {
6256
6371
  type: m.type,
6257
6372
  implementation: { ...m.implementation },
6258
6373
  imports: [...m.imports],
6259
- strictMockSchemaTypeNames: m.strictMockSchemaTypeNames ? [...m.strictMockSchemaTypeNames] : void 0
6374
+ strictMockSchemaTypeNames: m.strictMockSchemaTypeNames ? [...m.strictMockSchemaTypeNames] : void 0,
6375
+ strictMockSchemaKinds: m.strictMockSchemaKinds ? { ...m.strictMockSchemaKinds } : void 0
6260
6376
  }));
6261
6377
  for (const op of opMockOutputs) {
6262
6378
  let acc = result.find((m) => m.type === op.type);
@@ -6266,6 +6382,10 @@ function mergeOperationMockOutputs(accMockOutputs, opMockOutputs) {
6266
6382
  }
6267
6383
  acc.imports.push(...op.imports);
6268
6384
  if (op.strictMockSchemaTypeNames?.length) acc.strictMockSchemaTypeNames = [...new Set([...acc.strictMockSchemaTypeNames ?? [], ...op.strictMockSchemaTypeNames])];
6385
+ if (op.strictMockSchemaKinds) acc.strictMockSchemaKinds = {
6386
+ ...acc.strictMockSchemaKinds,
6387
+ ...op.strictMockSchemaKinds
6388
+ };
6269
6389
  acc.implementation.function += op.implementation.function;
6270
6390
  acc.implementation.handler += op.implementation.handler;
6271
6391
  if (op.implementation.handlerName) {
@@ -6284,7 +6404,8 @@ function initialMockOutputsForOperation(op) {
6284
6404
  handlerName: m.implementation.handlerName ? " " + m.implementation.handlerName + "()" : ""
6285
6405
  },
6286
6406
  imports: [...m.imports],
6287
- strictMockSchemaTypeNames: m.strictMockSchemaTypeNames ? [...m.strictMockSchemaTypeNames] : void 0
6407
+ strictMockSchemaTypeNames: m.strictMockSchemaTypeNames ? [...m.strictMockSchemaTypeNames] : void 0,
6408
+ strictMockSchemaKinds: m.strictMockSchemaKinds ? { ...m.strictMockSchemaKinds } : void 0
6288
6409
  }));
6289
6410
  }
6290
6411
  function generateTargetTags(currentAcc, operation) {
@@ -6367,7 +6488,8 @@ function generateTargetForTags(builder, options) {
6367
6488
  handlerName: m.implementation.handlerName
6368
6489
  },
6369
6490
  imports: m.imports,
6370
- strictMockSchemaTypeNames: m.strictMockSchemaTypeNames
6491
+ strictMockSchemaTypeNames: m.strictMockSchemaTypeNames,
6492
+ strictMockSchemaKinds: m.strictMockSchemaKinds
6371
6493
  }));
6372
6494
  transformed[tag] = {
6373
6495
  implementation: header.implementation + target.implementation + footer.implementation,
@@ -6403,7 +6525,7 @@ async function writeSplitTagsMode({ builder, output, projectName, header, needSc
6403
6525
  const isAllowSyntheticDefaultImports = isSyntheticDefaultImportsAllow(output.tsconfig);
6404
6526
  const mockIndexEntries = [];
6405
6527
  const seenMockIndexKeys = /* @__PURE__ */ new Set();
6406
- const schemasTarget = output.schemas ? getFileInfo(isString(output.schemas) ? output.schemas : output.schemas.path, { extension: output.fileExtension }).dirname : nodePath.join(dirname, filename + ".schemas" + extension.replace(/\.ts$/, ""));
6528
+ 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));
6407
6529
  const tagEntries = Object.entries(target).toSorted(([a], [b]) => a.localeCompare(b));
6408
6530
  const generatedFilePathsArray = await Promise.all(tagEntries.map(async ([tag, target]) => {
6409
6531
  try {
@@ -6411,7 +6533,7 @@ async function writeSplitTagsMode({ builder, output, projectName, header, needSc
6411
6533
  let implementationData = header;
6412
6534
  const importerPath = nodePath.join(dirname, tag, tag + extension);
6413
6535
  const schemaCustomImportPath = getSchemasImportPath(output.schemas);
6414
- const relativeSchemasPath = output.schemas ? schemaCustomImportPath ?? getRelativeImportPath(importerPath, getFileInfo(isString(output.schemas) ? output.schemas : output.schemas.path, { extension: output.fileExtension }).dirname) : "../" + filename + ".schemas" + extension.replace(/\.ts$/, "");
6536
+ const relativeSchemasPath = output.schemas ? schemaCustomImportPath ?? getRelativeImportPath(importerPath, getFileInfo(isString(output.schemas) ? output.schemas : output.schemas.path, { extension: output.fileExtension }).dirname) : "../" + filename + ".schemas" + getImportExtension(extension, output.tsconfig);
6415
6537
  const tagNames = new Set(tagEntries.map(([t]) => t));
6416
6538
  const serviceSuffix = OutputClient.ANGULAR === output.client ? ".service" : "";
6417
6539
  const importsForBuilder = generateImportsForBuilder(output, imports.map((imp) => {
@@ -6497,8 +6619,10 @@ async function writeSplitTagsMode({ builder, output, projectName, header, needSc
6497
6619
  const mockDir = getMockDir(rawEntry, output.mock) ?? dirname;
6498
6620
  const mockFilePath = nodePath.join(mockDir, tag, tag + "." + mockExtension + extension);
6499
6621
  const mockRelativeSchemasPath = schemaCustomImportPath ?? resolveMockSchemasPath(mockFilePath, schemasTarget);
6500
- const importsMockForBuilder = generateImportsForBuilder(output, mockOutput.imports, mockRelativeSchemasPath);
6501
- const finalizedMockImplementation = builder.finalizeMockImplementation ? builder.finalizeMockImplementation(mockOutput.implementation, getFinalizeMockImplementationOptions(output, mockOutput)) : mockOutput.implementation;
6622
+ const finalizeMockOptions = getFinalizeMockImplementationOptions(output, mockOutput);
6623
+ const finalizedMockImplementation = builder.finalizeMockImplementation ? builder.finalizeMockImplementation(mockOutput.implementation, finalizeMockOptions) : mockOutput.implementation;
6624
+ const recoveredSchemaFactoryImports = !isFunction(rawEntry) && rawEntry.type === OutputMockType.FAKER && rawEntry.schemas === true && output.schemas ? collectRecoveredSchemaFactoryImports(finalizedMockImplementation, builder.schemas.filter((s) => s.schema).map((s) => s.name)) : [];
6625
+ const importsMockForBuilder = generateImportsForBuilder(output, filterLocalStrictMockTypeImports(mergeGeneratorImports(mockOutput.imports, recoveredSchemaFactoryImports), finalizeMockOptions.strictSchemaTypeNames), mockRelativeSchemasPath);
6502
6626
  let mockData = header;
6503
6627
  mockData += builder.importsMock({
6504
6628
  implementation: finalizedMockImplementation,
@@ -6533,10 +6657,13 @@ async function writeSplitTagsMode({ builder, output, projectName, header, needSc
6533
6657
  throw new Error(`Oups... 🍻. An Error occurred while splitting tag ${tag} => ${String(error)}`, { cause: error });
6534
6658
  }
6535
6659
  }));
6536
- if (output.mock.indexMockFiles) for (const { ext, mockDir, tags } of mockIndexEntries) await writeGeneratedFile(nodePath.join(mockDir, `index.${ext}${extension}`), tags.toSorted((a, b) => a.localeCompare(b)).map((tag) => {
6537
- const localMockPath = joinSafe("./", tag, tag + "." + ext);
6538
- return ext === OutputMockType.MSW ? `export { get${pascal(tag)}Mock } from '${localMockPath}'\n` : `export * from '${localMockPath}'\n`;
6539
- }).join(""));
6660
+ if (output.mock.indexMockFiles) {
6661
+ const mockImportExtension = getImportExtension(extension, output.tsconfig);
6662
+ for (const { ext, mockDir, tags } of mockIndexEntries) await writeGeneratedFile(nodePath.join(mockDir, `index.${ext}${extension}`), tags.toSorted((a, b) => a.localeCompare(b)).map((tag) => {
6663
+ const localMockPath = joinSafe("./", tag, tag + "." + ext + mockImportExtension);
6664
+ return ext === OutputMockType.MSW ? `export { get${pascal(tag)}Mock } from '${localMockPath}'\n` : `export * from '${localMockPath}'\n`;
6665
+ }).join(""));
6666
+ }
6540
6667
  return [...new Set([...output.mock.indexMockFiles ? mockIndexEntries.map(({ mockDir, ext }) => nodePath.join(mockDir, `index.${ext}${extension}`)) : [], ...generatedFilePathsArray.flat()])];
6541
6668
  }
6542
6669
  //#endregion
@@ -6552,8 +6679,8 @@ async function writeTagsMode({ builder, output, projectName, header, needSchema,
6552
6679
  const mockIndexEntries = [];
6553
6680
  const seenMockIndexKeys = /* @__PURE__ */ new Set();
6554
6681
  const schemaCustomImportPath = getSchemasImportPath(output.schemas);
6555
- const schemasPathRelative = output.schemas ? schemaCustomImportPath ?? getRelativeImportPath(targetPath, getFileInfo(isString(output.schemas) ? output.schemas : output.schemas.path, { extension: output.fileExtension }).dirname) : "./" + filename + ".schemas" + extension.replace(/\.ts$/, "");
6556
- const schemasTarget = output.schemas ? getFileInfo(isString(output.schemas) ? output.schemas : output.schemas.path, { extension: output.fileExtension }).dirname : nodePath.join(dirname, filename + ".schemas" + extension.replace(/\.ts$/, ""));
6682
+ 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);
6683
+ 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));
6557
6684
  const tagEntries = Object.entries(target).toSorted(([a], [b]) => a.localeCompare(b));
6558
6685
  const generatedFilePathsArray = await Promise.all(tagEntries.map(async ([tag, target]) => {
6559
6686
  try {
@@ -6643,9 +6770,11 @@ async function writeTagsMode({ builder, output, projectName, header, needSchema,
6643
6770
  const mockDir = getMockDir(rawEntry, output.mock) ?? dirname;
6644
6771
  const mockFilePath = nodePath.join(mockDir, kebabTag, kebabTag + "." + mockExtension + extension);
6645
6772
  const mockRelativeSchemasPath = schemaCustomImportPath ?? resolveMockSchemasPath(mockFilePath, schemasTarget);
6646
- const importsMockForBuilder = generateImportsForBuilder(output, mockOutput.imports, mockRelativeSchemasPath);
6773
+ const finalizeMockOptions = getFinalizeMockImplementationOptions(output, mockOutput);
6774
+ const finalizedMockImplementation = builder.finalizeMockImplementation ? builder.finalizeMockImplementation(mockOutput.implementation, finalizeMockOptions) : mockOutput.implementation;
6775
+ const recoveredSchemaFactoryImports = !isFunction(rawEntry) && rawEntry.type === OutputMockType.FAKER && rawEntry.schemas === true && output.schemas ? collectRecoveredSchemaFactoryImports(finalizedMockImplementation, builder.schemas.filter((s) => s.schema).map((s) => s.name)) : [];
6776
+ const importsMockForBuilder = generateImportsForBuilder(output, filterLocalStrictMockTypeImports(mergeGeneratorImports(mockOutput.imports, recoveredSchemaFactoryImports), finalizeMockOptions.strictSchemaTypeNames), mockRelativeSchemasPath);
6647
6777
  let mockData = header;
6648
- const finalizedMockImplementation = builder.finalizeMockImplementation ? builder.finalizeMockImplementation(mockOutput.implementation, getFinalizeMockImplementationOptions(output, mockOutput)) : mockOutput.implementation;
6649
6778
  mockData += builder.importsMock({
6650
6779
  implementation: finalizedMockImplementation,
6651
6780
  imports: importsMockForBuilder,
@@ -6679,13 +6808,16 @@ async function writeTagsMode({ builder, output, projectName, header, needSchema,
6679
6808
  throw new Error(`Oups... 🍻. An Error occurred while writing tag ${tag} => ${String(error)}`, { cause: error });
6680
6809
  }
6681
6810
  }));
6682
- if (shouldDeinlineMocks && output.mock.indexMockFiles) for (const { ext, mockDir, tags } of mockIndexEntries) {
6683
- const indexPath = nodePath.join(mockDir, `index.${ext}${extension}`);
6684
- await writeGeneratedFile(indexPath, tags.toSorted((a, b) => a.localeCompare(b)).map((kebabTag) => {
6685
- const localMockPath = joinSafe("./", kebabTag, kebabTag + "." + ext);
6686
- return ext === OutputMockType.MSW ? `export { get${pascal(kebabTag)}Mock } from '${localMockPath}'\n` : `export * from '${localMockPath}'\n`;
6687
- }).join(""));
6688
- generatedFilePathsArray.push([indexPath]);
6811
+ if (shouldDeinlineMocks && output.mock.indexMockFiles) {
6812
+ const mockImportExtension = getImportExtension(extension, output.tsconfig);
6813
+ for (const { ext, mockDir, tags } of mockIndexEntries) {
6814
+ const indexPath = nodePath.join(mockDir, `index.${ext}${extension}`);
6815
+ await writeGeneratedFile(indexPath, tags.toSorted((a, b) => a.localeCompare(b)).map((kebabTag) => {
6816
+ const localMockPath = joinSafe("./", kebabTag, kebabTag + "." + ext + mockImportExtension);
6817
+ return ext === OutputMockType.MSW ? `export { get${pascal(kebabTag)}Mock } from '${localMockPath}'\n` : `export * from '${localMockPath}'\n`;
6818
+ }).join(""));
6819
+ generatedFilePathsArray.push([indexPath]);
6820
+ }
6689
6821
  }
6690
6822
  return generatedFilePathsArray.flat();
6691
6823
  }