mobx-tanstack-query-api 0.40.1 → 0.41.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/cli.cjs CHANGED
@@ -219,6 +219,10 @@ const createShortModelType = (shortModelType) => {
219
219
  description: shortModelType.description || ""
220
220
  };
221
221
  };
222
+ const DEFAULT_ZOD_CONTRACT_SUFFIX = "Contract";
223
+ function getZodContractSuffix(zodContracts) {
224
+ return (typeof zodContracts === "object" && zodContracts !== null && typeof zodContracts.suffix === "string" ? zodContracts.suffix : void 0) ?? DEFAULT_ZOD_CONTRACT_SUFFIX;
225
+ }
222
226
  const REF_PREFIX = "#/components/schemas/";
223
227
  const REF_PREFIX_PARAMS = "#/components/parameters/";
224
228
  function parseRef(ref) {
@@ -270,14 +274,14 @@ function schemaToNumber(schema) {
270
274
  if (schema.maximum != null) n += `.max(${schema.maximum})`;
271
275
  return n;
272
276
  }
273
- function schemaToArray(schema, schemas, schemaKeyToVarName2, visited) {
274
- const items = schema.items ? schemaToZodExpr(schema.items, schemas, schemaKeyToVarName2, visited) : "z.any()";
277
+ function schemaToArray(schema, schemas, schemaKeyToVarName, visited) {
278
+ const items = schema.items ? schemaToZodExpr(schema.items, schemas, schemaKeyToVarName, visited) : "z.any()";
275
279
  let a = `z.array(${items})`;
276
280
  if (schema.minItems != null) a += `.min(${schema.minItems})`;
277
281
  if (schema.maxItems != null) a += `.max(${schema.maxItems})`;
278
282
  return a;
279
283
  }
280
- function schemaToObject(schema, schemas, schemaKeyToVarName2, visited) {
284
+ function schemaToObject(schema, schemas, schemaKeyToVarName, visited) {
281
285
  if (schema.properties && Object.keys(schema.properties).length > 0) {
282
286
  const required = new Set(schema.required ?? []);
283
287
  const entries = Object.entries(schema.properties).map(
@@ -285,7 +289,7 @@ function schemaToObject(schema, schemas, schemaKeyToVarName2, visited) {
285
289
  const expr = schemaToZodExpr(
286
290
  propSchema,
287
291
  schemas,
288
- schemaKeyToVarName2,
292
+ schemaKeyToVarName,
289
293
  visited
290
294
  );
291
295
  const optional = !required.has(propName);
@@ -303,26 +307,26 @@ ${entries.join(",\n")}
303
307
  const value = schemaToZodExpr(
304
308
  schema.additionalProperties,
305
309
  schemas,
306
- schemaKeyToVarName2,
310
+ schemaKeyToVarName,
307
311
  visited
308
312
  );
309
313
  return `z.record(z.string(), ${value})`;
310
314
  }
311
315
  return "z.record(z.string(), z.any())";
312
316
  }
313
- function schemaToZodExpr(schema, schemas, schemaKeyToVarName2, visited) {
317
+ function schemaToZodExpr(schema, schemas, schemaKeyToVarName, visited) {
314
318
  if (!schema) return "z.any()";
315
319
  if (schema.$ref) {
316
320
  const key = parseRef(schema.$ref);
317
321
  if (key && key in schemas) {
318
322
  const isCycle = visited.has(key);
319
- return isCycle ? `z.lazy((): z.ZodTypeAny => ${schemaKeyToVarName2(key)})` : `z.lazy(() => ${schemaKeyToVarName2(key)})`;
323
+ return isCycle ? `z.lazy((): z.ZodTypeAny => ${schemaKeyToVarName(key)})` : `z.lazy(() => ${schemaKeyToVarName(key)})`;
320
324
  }
321
325
  return "z.any()";
322
326
  }
323
327
  if (schema.allOf && schema.allOf.length > 0) {
324
328
  const parts = schema.allOf.map(
325
- (part) => schemaToZodExpr(part, schemas, schemaKeyToVarName2, visited)
329
+ (part) => schemaToZodExpr(part, schemas, schemaKeyToVarName, visited)
326
330
  );
327
331
  const base2 = parts.length === 1 ? parts[0] : parts.reduce((acc, p) => `z.intersection(${acc}, ${p})`);
328
332
  return schema.nullable === true ? `${base2}.nullable()` : base2;
@@ -341,10 +345,10 @@ function schemaToZodExpr(schema, schemas, schemaKeyToVarName2, visited) {
341
345
  base = "z.boolean()";
342
346
  break;
343
347
  case "array":
344
- base = schemaToArray(schema, schemas, schemaKeyToVarName2, visited);
348
+ base = schemaToArray(schema, schemas, schemaKeyToVarName, visited);
345
349
  break;
346
350
  case "object":
347
- base = schemaToObject(schema, schemas, schemaKeyToVarName2, visited);
351
+ base = schemaToObject(schema, schemas, schemaKeyToVarName, visited);
348
352
  break;
349
353
  default:
350
354
  base = "z.any()";
@@ -374,9 +378,9 @@ function collectRefs(schema, schemas, out) {
374
378
  collectRefs(schema.additionalProperties, schemas, out);
375
379
  }
376
380
  }
377
- function schemaKeyToVarName(key, utils) {
381
+ function schemaKeyToContractVarName(key, utils, contractSuffix = DEFAULT_ZOD_CONTRACT_SUFFIX) {
378
382
  const _ = utils._;
379
- return `${_.camelCase(key)}Schema`;
383
+ return `${_.camelCase(key)}${contractSuffix}`;
380
384
  }
381
385
  function resolveQueryParameters(operation, componentsParameters) {
382
386
  const list = [];
@@ -405,13 +409,13 @@ function resolveQueryParameters(operation, componentsParameters) {
405
409
  }
406
410
  return list;
407
411
  }
408
- function queryParamsToZodObject(queryParams, schemas, schemaKeyToVarName2) {
412
+ function queryParamsToZodObject(queryParams, schemas, schemaKeyToContractVarName2) {
409
413
  if (queryParams.length === 0) return "z.object({})";
410
414
  const entries = queryParams.map(({ name, required, schema }) => {
411
415
  const expr = schemaToZodExpr(
412
416
  schema,
413
417
  schemas,
414
- schemaKeyToVarName2,
418
+ schemaKeyToContractVarName2,
415
419
  /* @__PURE__ */ new Set()
416
420
  );
417
421
  const field = required ? expr : `${expr}.optional()`;
@@ -421,32 +425,36 @@ function queryParamsToZodObject(queryParams, schemas, schemaKeyToVarName2) {
421
425
  ${entries.join(",\n")}
422
426
  })`;
423
427
  }
424
- function generateAuxiliarySchemas(schemaKeys, schemas, schemaKeyToVarNameFn, visited) {
428
+ function generateAuxiliarySchemas(schemaKeys, schemas, schemaKeyToContractVarNameFn, visited) {
425
429
  const lines = [];
426
430
  for (const key of schemaKeys) {
427
431
  if (visited.has(key)) continue;
428
432
  visited.add(key);
429
433
  const schema = schemas[key];
430
434
  if (!schema) continue;
431
- const varName = schemaKeyToVarNameFn(key);
435
+ const varName = schemaKeyToContractVarNameFn(key);
432
436
  const cyclePath = /* @__PURE__ */ new Set([key]);
433
437
  const expr = schemaToZodExpr(
434
438
  schema,
435
439
  schemas,
436
- schemaKeyToVarNameFn,
440
+ schemaKeyToContractVarNameFn,
437
441
  cyclePath
438
442
  );
439
443
  lines.push(`export const ${varName} = ${expr};`);
440
444
  }
441
445
  return lines;
442
446
  }
443
- function buildCentralZodSchemasFile(params) {
444
- const { componentsSchemas, utils } = params;
445
- const schemaKeyToVarNameFn = (key) => schemaKeyToVarName(key, utils);
447
+ function buildCentralZodContractsFile(params) {
448
+ const {
449
+ componentsSchemas,
450
+ utils,
451
+ contractSuffix = DEFAULT_ZOD_CONTRACT_SUFFIX
452
+ } = params;
453
+ const schemaKeyToContractVarNameFn = (key) => schemaKeyToContractVarName(key, utils, contractSuffix);
446
454
  const lines = generateAuxiliarySchemas(
447
455
  Object.keys(componentsSchemas),
448
456
  componentsSchemas,
449
- schemaKeyToVarNameFn,
457
+ schemaKeyToContractVarNameFn,
450
458
  /* @__PURE__ */ new Set()
451
459
  );
452
460
  return `import * as z from "zod";
@@ -468,7 +476,7 @@ function typeToZodSchemaFallback(typeStr) {
468
476
  if (t === "unknown") return "z.unknown()";
469
477
  return "z.any()";
470
478
  }
471
- function typeToZodSchemaWithSchema(typeStr, schemas, utils, typeSuffix) {
479
+ function typeToZodSchemaWithSchema(typeStr, schemas, utils, typeSuffix, contractSuffix = DEFAULT_ZOD_CONTRACT_SUFFIX) {
472
480
  const t = typeStr.trim();
473
481
  if (!schemas || Object.keys(schemas).length === 0) {
474
482
  return { expr: typeToZodSchemaFallback(t), refs: [] };
@@ -481,36 +489,36 @@ function typeToZodSchemaWithSchema(typeStr, schemas, utils, typeSuffix) {
481
489
  }
482
490
  const refs = /* @__PURE__ */ new Set();
483
491
  collectRefs(schema, schemas, refs);
484
- const schemaKeyToVarNameFn = (key) => schemaKeyToVarName(key, utils);
492
+ const schemaKeyToContractVarNameFn = (key) => schemaKeyToContractVarName(key, utils, contractSuffix);
485
493
  const expr = schemaToZodExpr(
486
494
  schema,
487
495
  schemas,
488
- schemaKeyToVarNameFn,
496
+ schemaKeyToContractVarNameFn,
489
497
  /* @__PURE__ */ new Set()
490
498
  );
491
499
  return { expr, refs: [...refs] };
492
500
  }
493
- function schemaKeyToZod(schemaKey, schemas, utils) {
501
+ function schemaKeyToZod(schemaKey, schemas, utils, contractSuffix = DEFAULT_ZOD_CONTRACT_SUFFIX) {
494
502
  const schema = schemas[schemaKey];
495
503
  if (!schema) return { expr: "z.any()", refs: [] };
496
504
  const refs = /* @__PURE__ */ new Set();
497
505
  collectRefs(schema, schemas, refs);
498
- const schemaKeyToVarNameFn = (key) => schemaKeyToVarName(key, utils);
506
+ const schemaKeyToContractVarNameFn = (key) => schemaKeyToContractVarName(key, utils, contractSuffix);
499
507
  const expr = schemaToZodExpr(
500
508
  schema,
501
509
  schemas,
502
- schemaKeyToVarNameFn,
510
+ schemaKeyToContractVarNameFn,
503
511
  /* @__PURE__ */ new Set()
504
512
  );
505
513
  return { expr, refs: [...refs] };
506
514
  }
507
515
  function buildEndpointZodContractsCode(params) {
508
516
  const {
509
- routeNameUsage,
510
517
  inputParams,
511
518
  responseDataTypeName,
512
- contractsVarName,
519
+ contractVarName,
513
520
  utils,
521
+ contractSuffix = DEFAULT_ZOD_CONTRACT_SUFFIX,
514
522
  componentsSchemas = null,
515
523
  typeSuffix = "DC",
516
524
  responseSchemaKey,
@@ -519,13 +527,11 @@ function buildEndpointZodContractsCode(params) {
519
527
  openApiComponentsParameters = null,
520
528
  queryParamName = "query"
521
529
  } = params;
522
- const _ = utils._;
523
- const paramsSchemaName = `${_.camelCase(routeNameUsage)}ParamsSchema`;
524
- const dataSchemaName = `${_.camelCase(routeNameUsage)}DataSchema`;
530
+ utils._;
525
531
  const allAuxiliaryKeys = /* @__PURE__ */ new Set();
526
532
  const paramParts = [];
527
533
  const resolvedQueryParams = openApiOperation && (openApiComponentsParameters || openApiOperation.parameters?.length) ? resolveQueryParameters(openApiOperation, openApiComponentsParameters) : [];
528
- const schemaKeyToVarNameFn = (key) => schemaKeyToVarName(key, utils);
534
+ const schemaKeyToContractVarNameFn = (key) => schemaKeyToContractVarName(key, utils, contractSuffix);
529
535
  for (const p of inputParams) {
530
536
  let expr;
531
537
  let refKeys = [];
@@ -533,14 +539,15 @@ function buildEndpointZodContractsCode(params) {
533
539
  expr = queryParamsToZodObject(
534
540
  resolvedQueryParams,
535
541
  componentsSchemas,
536
- schemaKeyToVarNameFn
542
+ schemaKeyToContractVarNameFn
537
543
  );
538
544
  } else {
539
545
  const result = typeToZodSchemaWithSchema(
540
546
  p.type,
541
547
  componentsSchemas,
542
548
  utils,
543
- typeSuffix
549
+ typeSuffix,
550
+ contractSuffix
544
551
  );
545
552
  expr = result.expr;
546
553
  refKeys = result.refs;
@@ -549,11 +556,17 @@ function buildEndpointZodContractsCode(params) {
549
556
  const schemaWithOptional = p.optional ? `${expr}.optional()` : expr;
550
557
  paramParts.push(`${p.name}: ${schemaWithOptional}`);
551
558
  }
552
- const responseResult = responseSchemaKey && componentsSchemas && responseSchemaKey in componentsSchemas ? schemaKeyToZod(responseSchemaKey, componentsSchemas, utils) : typeToZodSchemaWithSchema(
559
+ const responseResult = responseSchemaKey && componentsSchemas && responseSchemaKey in componentsSchemas ? schemaKeyToZod(
560
+ responseSchemaKey,
561
+ componentsSchemas,
562
+ utils,
563
+ contractSuffix
564
+ ) : typeToZodSchemaWithSchema(
553
565
  responseDataTypeName,
554
566
  componentsSchemas,
555
567
  utils,
556
- typeSuffix
568
+ typeSuffix,
569
+ contractSuffix
557
570
  );
558
571
  const useDataSchemaFromCentral = useExternalZodSchemas && responseSchemaKey && componentsSchemas && responseSchemaKey in componentsSchemas;
559
572
  if (useDataSchemaFromCentral) {
@@ -561,31 +574,27 @@ function buildEndpointZodContractsCode(params) {
561
574
  } else {
562
575
  for (const k of responseResult.refs) allAuxiliaryKeys.add(k);
563
576
  }
564
- const zodSchemaImportNames = useExternalZodSchemas && allAuxiliaryKeys.size > 0 ? [...allAuxiliaryKeys].map(schemaKeyToVarNameFn) : [];
577
+ const zodContractImportNames = useExternalZodSchemas && allAuxiliaryKeys.size > 0 ? [...allAuxiliaryKeys].map(schemaKeyToContractVarNameFn) : [];
565
578
  const allAuxiliary = useExternalZodSchemas ? [] : generateAuxiliarySchemas(
566
579
  [...allAuxiliaryKeys],
567
580
  componentsSchemas ?? {},
568
- schemaKeyToVarNameFn,
581
+ schemaKeyToContractVarNameFn,
569
582
  /* @__PURE__ */ new Set()
570
583
  );
571
- const paramsFields = paramParts.join(",\n ");
572
- const paramsSchemaCode = `export const ${paramsSchemaName} = z.object({
573
- ${paramsFields},
574
- });`;
575
- const dataSchemaCode = useDataSchemaFromCentral ? `export const ${dataSchemaName} = ${schemaKeyToVarNameFn(responseSchemaKey)};` : `export const ${dataSchemaName} = ${responseResult.expr};`;
576
- const contractsCode = `export const ${contractsVarName} = {
577
- params: ${paramsSchemaName},
578
- data: ${dataSchemaName},
584
+ const paramsFields = paramParts.join(",\n ");
585
+ const paramsSchemaExpr = `z.object({
586
+ ${paramsFields},
587
+ })`;
588
+ const dataSchemaExpr = useDataSchemaFromCentral ? schemaKeyToContractVarNameFn(responseSchemaKey) : responseResult.expr;
589
+ const contractsCode = `export const ${contractVarName} = {
590
+ params: ${paramsSchemaExpr},
591
+ data: ${dataSchemaExpr},
579
592
  };`;
580
593
  const auxiliaryBlock = allAuxiliary.length > 0 ? `${allAuxiliary.join("\n\n")}
581
594
 
582
595
  ` : "";
583
- const content = `${auxiliaryBlock}${paramsSchemaCode}
584
-
585
- ${dataSchemaCode}
586
-
587
- ${contractsCode}`;
588
- return { content, zodSchemaImportNames };
596
+ const content = `${auxiliaryBlock}${contractsCode}`;
597
+ return { content, zodContractImportNames };
589
598
  }
590
599
  const formatGroupNameEnumKey = (groupName, { _ }) => _.upperFirst(_.camelCase(groupName));
591
600
  const formatTagNameEnumKey = (tagName, utils) => formatGroupNameEnumKey(tagName, utils);
@@ -745,10 +754,7 @@ const newEndpointTmpl = ({
745
754
  }) => {
746
755
  const zodContractsIsObject = typeof zodContracts === "object" && zodContracts !== null;
747
756
  const hasZodContracts = zodContracts === true || zodContractsIsObject;
748
- const validateOpt = zodContractsIsObject ? zodContracts.validate : zodContracts === true ? true : void 0;
749
- const throwOpt = zodContractsIsObject ? zodContracts.throw : void 0;
750
- const validateOptObj = validateOpt != null && typeof validateOpt === "object" && !Array.isArray(validateOpt) ? validateOpt : null;
751
- const throwOptObj = throwOpt != null && typeof throwOpt === "object" && !Array.isArray(throwOpt) ? throwOpt : null;
757
+ const contractSuffix = getZodContractSuffix(zodContracts);
752
758
  const { _ } = utils;
753
759
  const positiveResponseTypes = route.raw.responsesTypes?.filter(
754
760
  (it) => +it.status >= 200 && +it.status < 300 && (!it.typeData || filterTypes(it.typeData))
@@ -862,7 +868,24 @@ const newEndpointTmpl = ({
862
868
  });
863
869
  const isAllowedInputType = filterTypes(requestInputTypeDc);
864
870
  const defaultOkResponseType = positiveResponseTypes?.[0]?.type ?? "unknown";
865
- const contractsVarName = hasZodContracts ? `${_.camelCase(route.routeName.usage)}Contracts` : null;
871
+ const contractVarName = hasZodContracts ? `${_.camelCase(route.routeName.usage)}${contractSuffix}` : null;
872
+ const routeInfoForContracts = contractVarName != null ? {
873
+ operationId: raw.operationId ?? "",
874
+ path: path2,
875
+ method,
876
+ contractName: contractVarName
877
+ } : null;
878
+ const resolveZodContractsMaybeFn = (value) => {
879
+ if (typeof value === "function" && routeInfoForContracts != null) {
880
+ return value(routeInfoForContracts.contractName, routeInfoForContracts);
881
+ }
882
+ return value;
883
+ };
884
+ const validateOpt = zodContractsIsObject ? resolveZodContractsMaybeFn(zodContracts.validate) : zodContracts === true ? true : void 0;
885
+ const throwOpt = zodContractsIsObject ? resolveZodContractsMaybeFn(zodContracts.throw) : void 0;
886
+ const isRuntimeContractsRuleObject = (value) => value != null && typeof value === "object" && !Array.isArray(value);
887
+ const validateOptObj = isRuntimeContractsRuleObject(validateOpt) ? validateOpt : null;
888
+ const throwOptObj = isRuntimeContractsRuleObject(throwOpt) ? throwOpt : null;
866
889
  const swaggerSchema = configuration.config?.swaggerSchema ?? configuration?.swaggerSchema;
867
890
  const componentsSchemas = swaggerSchema?.components?.schemas;
868
891
  let operationFromSpec = null;
@@ -899,46 +922,36 @@ const newEndpointTmpl = ({
899
922
  if (candidate in componentsSchemas) responseSchemaKey = candidate;
900
923
  }
901
924
  }
902
- const contractsCode = hasZodContracts && contractsVarName ? buildEndpointZodContractsCode({
925
+ const contractsCode = hasZodContracts && contractVarName ? buildEndpointZodContractsCode({
903
926
  routeNameUsage: route.routeName.usage,
904
927
  inputParams,
905
928
  responseDataTypeName: defaultOkResponseType,
906
- contractsVarName,
929
+ contractVarName,
907
930
  utils,
908
931
  componentsSchemas: componentsSchemas ?? void 0,
909
932
  typeSuffix: "DC",
910
933
  responseSchemaKey: responseSchemaKey ?? void 0,
911
934
  useExternalZodSchemas: Boolean(relativePathZodSchemas),
935
+ contractSuffix,
912
936
  openApiOperation: operationFromSpec ?? void 0,
913
937
  openApiComponentsParameters: swaggerSchema?.components?.parameters ?? void 0,
914
938
  queryParamName: queryName
915
939
  }) : null;
916
- const appendRuleOpt = zodContractsIsObject && zodContracts.appendRule != null ? zodContracts.appendRule : null;
917
- const routeInfoForAppend = contractsVarName != null ? {
918
- operationId: raw.operationId ?? "",
919
- path: path2,
920
- method,
921
- contractName: contractsVarName
922
- } : null;
923
- const contractsLine = (() => {
924
- if (contractsVarName == null) return "";
940
+ const appendRuleOpt = zodContractsIsObject && zodContracts.appendRule != null ? resolveZodContractsMaybeFn(zodContracts.appendRule) : null;
941
+ const contractLine = (() => {
942
+ if (contractVarName == null) return "";
925
943
  if (typeof appendRuleOpt === "string")
926
- return `contracts: ${appendRuleOpt} ? ${contractsVarName} : undefined,`;
927
- if (typeof appendRuleOpt === "function" && routeInfoForAppend) {
928
- const include = appendRuleOpt(
929
- routeInfoForAppend.contractName,
930
- routeInfoForAppend
931
- );
932
- return include ? `contracts: ${contractsVarName},` : "contracts: undefined,";
933
- }
934
- return `contracts: ${contractsVarName},`;
944
+ return `contract: ${appendRuleOpt} ? ${contractVarName} : undefined,`;
945
+ if (appendRuleOpt === false) return "contract: undefined,";
946
+ if (appendRuleOpt === true) return `contract: ${contractVarName},`;
947
+ return `contract: ${contractVarName},`;
935
948
  })();
936
- const validateContractsLine = (() => {
949
+ const validateContractLine = (() => {
937
950
  if (validateOpt === void 0) return "";
938
951
  if (typeof validateOpt === "string")
939
- return `validateContracts: ${validateOpt},`;
952
+ return `validateContract: ${validateOpt},`;
940
953
  if (typeof validateOpt === "boolean")
941
- return `validateContracts: ${validateOpt},`;
954
+ return `validateContract: ${validateOpt},`;
942
955
  if (validateOptObj !== null) {
943
956
  const parts = [];
944
957
  if (validateOptObj.params !== void 0)
@@ -949,7 +962,7 @@ const newEndpointTmpl = ({
949
962
  parts.push(
950
963
  `data: ${typeof validateOptObj.data === "string" ? validateOptObj.data : validateOptObj.data}`
951
964
  );
952
- return parts.length > 0 ? `validateContracts: { ${parts.join(", ")} },` : "";
965
+ return parts.length > 0 ? `validateContract: { ${parts.join(", ")} },` : "";
953
966
  }
954
967
  return "";
955
968
  })();
@@ -971,7 +984,7 @@ const newEndpointTmpl = ({
971
984
  reservedDataContractNames,
972
985
  localModelTypes: isAllowedInputType ? [requestInputTypeDc] : [],
973
986
  contractsCode: contractsCode ?? void 0,
974
- contractsVarName: contractsVarName ?? void 0,
987
+ contractVarName: contractVarName ?? void 0,
975
988
  content: `
976
989
  new ${importFileParams.endpoint.exportName}<
977
990
  ${getHttpRequestGenerics()},
@@ -1004,8 +1017,8 @@ new ${importFileParams.endpoint.exportName}<
1004
1017
  ${groupName ? `group: ${metaInfo ? `Group.${formatGroupNameEnumKey(groupName, utils)}` : `"${groupName}"`},` : ""}
1005
1018
  ${metaInfo?.namespace ? `namespace,` : ""}
1006
1019
  meta: ${requestInfoMeta?.tmplData ?? "{} as any"},
1007
- ${contractsLine}
1008
- ${validateContractsLine}
1020
+ ${contractLine}
1021
+ ${validateContractLine}
1009
1022
  ${throwContractsLine}
1010
1023
  },
1011
1024
  ${importFileParams.queryClient.exportName},
@@ -1055,17 +1068,17 @@ const allEndpointPerFileTmpl = async (params) => {
1055
1068
  const hasAnyZodContracts = newEndpointTemplates.some(
1056
1069
  (t) => t.contractsCode != null
1057
1070
  );
1058
- const allZodSchemaImportNames = /* @__PURE__ */ new Set();
1071
+ const allZodContractImportNames = /* @__PURE__ */ new Set();
1059
1072
  newEndpointTemplates.forEach((t) => {
1060
1073
  const c = t.contractsCode;
1061
- if (c != null && typeof c === "object" && c.zodSchemaImportNames?.length) {
1062
- for (const n of c.zodSchemaImportNames) {
1063
- allZodSchemaImportNames.add(n);
1074
+ if (c != null && typeof c === "object" && c.zodContractImportNames?.length) {
1075
+ for (const n of c.zodContractImportNames) {
1076
+ allZodContractImportNames.add(n);
1064
1077
  }
1065
1078
  }
1066
1079
  });
1067
1080
  const zodImportLine = hasAnyZodContracts ? 'import * as z from "zod";' : "";
1068
- const zodSchemasImportLine = allZodSchemaImportNames.size && relativePathZodSchemas ? `import { ${[...allZodSchemaImportNames].sort().join(", ")} } from "${relativePathZodSchemas}";` : "";
1081
+ const zodSchemasImportLine = allZodContractImportNames.size && relativePathZodSchemas ? `import { ${[...allZodContractImportNames].sort().join(", ")} } from "${relativePathZodSchemas}";` : "";
1069
1082
  const endpointTemplates = await Promise.all(
1070
1083
  newEndpointTemplates.map(
1071
1084
  async ({
@@ -1169,7 +1182,7 @@ const allExportsTmpl = async ({
1169
1182
  }) => {
1170
1183
  return await formatTSContent(`${LINTERS_IGNORE}
1171
1184
  export * from './data-contracts';
1172
- ${exportSchemas ? " export * from './schemas';\n " : ""}${collectedExportFiles.map((fileName) => `export * from './${fileName}';`).join("\n")}
1185
+ ${exportSchemas ? " export * from './contracts';\n " : ""}${collectedExportFiles.map((fileName) => `export * from './${fileName}';`).join("\n")}
1173
1186
  ${metaInfo ? 'export * from "./meta-info";' : ""}
1174
1187
  `);
1175
1188
  };
@@ -1251,7 +1264,7 @@ const endpointPerFileTmpl = async (params) => {
1251
1264
  const dataContractImportToken = "/*__DATA_CONTRACT_IMPORTS__*/";
1252
1265
  const contractsResult = contractsCode != null && typeof contractsCode === "object" ? contractsCode : null;
1253
1266
  const zodImportLine = contractsResult != null ? 'import * as z from "zod";' : "";
1254
- const zodSchemasImportLine = contractsResult?.zodSchemaImportNames?.length && relativePathZodSchemas ? `import { ${contractsResult.zodSchemaImportNames.join(", ")} } from "${relativePathZodSchemas}";` : "";
1267
+ const zodSchemasImportLine = contractsResult?.zodContractImportNames?.length && relativePathZodSchemas ? `import { ${contractsResult.zodContractImportNames.join(", ")} } from "${relativePathZodSchemas}";` : "";
1255
1268
  const contractsBlock = contractsResult != null ? `
1256
1269
 
1257
1270
  ${contractsResult.content}
@@ -1661,7 +1674,8 @@ const generateApi = async (params) => {
1661
1674
  };
1662
1675
  const reservedDataContractNamesMap = /* @__PURE__ */ new Map();
1663
1676
  const componentsSchemasForZod = generated.configuration.config?.swaggerSchema?.components?.schemas ?? generated.configuration.swaggerSchema?.components?.schemas;
1664
- const hasZodSchemasFile = (params.zodContracts === true || typeof params.zodContracts === "object" && params.zodContracts != null) && componentsSchemasForZod && typeof componentsSchemasForZod === "object" && Object.keys(componentsSchemasForZod).length > 0;
1677
+ const zodContractSuffix = getZodContractSuffix(params.zodContracts);
1678
+ const hasZodContractsFile = (params.zodContracts === true || typeof params.zodContracts === "object" && params.zodContracts != null) && componentsSchemasForZod && typeof componentsSchemasForZod === "object" && Object.keys(componentsSchemasForZod).length > 0;
1665
1679
  const collectedExportFilesFromIndexFile = [];
1666
1680
  const groupsMap = /* @__PURE__ */ new Map();
1667
1681
  const nonEmptyGroups = /* @__PURE__ */ new Set();
@@ -1684,7 +1698,7 @@ const generateApi = async (params) => {
1684
1698
  groupNames: [],
1685
1699
  namespace
1686
1700
  },
1687
- relativePathZodSchemas: hasZodSchemasFile ? "../schemas" : null
1701
+ relativePathZodSchemas: hasZodContractsFile ? "../contracts" : null
1688
1702
  });
1689
1703
  if (Array.isArray(route.raw.tags)) {
1690
1704
  route.raw.tags.forEach((tag) => {
@@ -1729,7 +1743,7 @@ const generateApi = async (params) => {
1729
1743
  namespace,
1730
1744
  groupNames: []
1731
1745
  },
1732
- relativePathZodSchemas: hasZodSchemasFile ? "./schemas" : null
1746
+ relativePathZodSchemas: hasZodContractsFile ? "./contracts" : null
1733
1747
  });
1734
1748
  reservedDataContractNames.forEach((name) => {
1735
1749
  reservedDataContractNamesMap.set(
@@ -1802,6 +1816,7 @@ const generateApi = async (params) => {
1802
1816
  ...baseTmplParams,
1803
1817
  route,
1804
1818
  relativePathDataContracts: "../../data-contracts",
1819
+ relativePathZodSchemas: hasZodContractsFile ? "../../contracts" : null,
1805
1820
  groupName,
1806
1821
  metaInfo: params.noMetaInfo ? null : {
1807
1822
  namespace,
@@ -1844,6 +1859,7 @@ const generateApi = async (params) => {
1844
1859
  ...baseTmplParams,
1845
1860
  routes,
1846
1861
  relativePathDataContracts: "../data-contracts",
1862
+ relativePathZodSchemas: hasZodContractsFile ? "../contracts" : null,
1847
1863
  groupName,
1848
1864
  metaInfo: params.noMetaInfo ? null : {
1849
1865
  namespace,
@@ -1925,20 +1941,21 @@ export * as ${exportGroupName} from './endpoints';
1925
1941
  withPrefix: false,
1926
1942
  content: dataContractsContent
1927
1943
  });
1928
- if (hasZodSchemasFile && componentsSchemasForZod) {
1929
- const schemasTsContent = buildCentralZodSchemasFile({
1944
+ if (hasZodContractsFile && componentsSchemasForZod) {
1945
+ const contractsTsContent = buildCentralZodContractsFile({
1930
1946
  componentsSchemas: componentsSchemasForZod,
1931
- utils
1947
+ utils,
1948
+ contractSuffix: zodContractSuffix
1932
1949
  });
1933
- const formattedSchemasContent = await generated.formatTSContent(
1950
+ const formattedContractsContent = await generated.formatTSContent(
1934
1951
  `${LINTERS_IGNORE}
1935
- ${schemasTsContent}`
1952
+ ${contractsTsContent}`
1936
1953
  );
1937
1954
  codegenFs.createFile({
1938
1955
  path: paths.outputDir,
1939
- fileName: "schemas.ts",
1956
+ fileName: "contracts.ts",
1940
1957
  withPrefix: false,
1941
- content: formattedSchemasContent
1958
+ content: formattedContractsContent
1942
1959
  });
1943
1960
  }
1944
1961
  if (metaInfo) {
@@ -1961,7 +1978,7 @@ ${schemasTsContent}`
1961
1978
  ...baseTmplParams,
1962
1979
  collectedExportFiles: collectedExportFilesFromIndexFile,
1963
1980
  metaInfo,
1964
- exportSchemas: hasZodSchemasFile
1981
+ exportSchemas: hasZodContractsFile
1965
1982
  })
1966
1983
  });
1967
1984
  if (shouldGenerateBarrelFiles) {
@@ -1984,7 +2001,7 @@ export * as ${namespace} from './__exports';
1984
2001
  ...baseTmplParams,
1985
2002
  collectedExportFiles: collectedExportFilesFromIndexFile,
1986
2003
  metaInfo,
1987
- exportSchemas: hasZodSchemasFile
2004
+ exportSchemas: hasZodContractsFile
1988
2005
  })
1989
2006
  });
1990
2007
  }