mobx-tanstack-query-api 0.36.0 → 0.37.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.
Files changed (5) hide show
  1. package/cli.cjs +277 -110
  2. package/cli.cjs.map +1 -1
  3. package/cli.js +277 -110
  4. package/cli.js.map +1 -1
  5. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -56,38 +56,72 @@ ${contract2.content}}`;
56
56
  const contractType = `${"export "}${templateFn(contract)}`;
57
57
  return result + contractType;
58
58
  };
59
+ function getResponseContentTypes(raw) {
60
+ const out = [];
61
+ if (Array.isArray(raw.produces)) out.push(...raw.produces);
62
+ const status = raw.responses && Object.keys(raw.responses).find((s) => {
63
+ const code = Number.parseInt(s, 10);
64
+ return code >= 200 && code < 300;
65
+ });
66
+ const content = status && raw.responses[status]?.content;
67
+ if (content && typeof content === "object") out.push(...Object.keys(content));
68
+ return [...new Set(out)];
69
+ }
70
+ function getRequestContentTypes(raw) {
71
+ const out = [];
72
+ if (Array.isArray(raw.consumes)) out.push(...raw.consumes);
73
+ const body = raw.requestBody?.content;
74
+ if (body && typeof body === "object") out.push(...Object.keys(body));
75
+ return [...new Set(out)];
76
+ }
77
+ function getSecuritySchemeNames(security) {
78
+ if (!Array.isArray(security)) return [];
79
+ return security.flatMap(
80
+ (s) => typeof s === "object" && s !== null ? Object.keys(s) : []
81
+ ).filter(Boolean);
82
+ }
83
+ function getExternalDocsLine(externalDocs, formatDescription) {
84
+ if (!externalDocs || typeof externalDocs !== "object" || !("url" in externalDocs))
85
+ return null;
86
+ const url = externalDocs.url;
87
+ if (!url) return null;
88
+ const desc = externalDocs.description;
89
+ const extDesc = desc ? ` ${formatDescription(String(desc).slice(0, 60), true)}` : "";
90
+ return { name: "see", content: `${url}${extDesc}`.trim() };
91
+ }
92
+ function getSummaryAndDescriptionLines(rawRoute, formatDescription) {
93
+ const out = [];
94
+ if (rawRoute.summary) {
95
+ const summaryLines = text.splitTextByLines(rawRoute.summary, 60).filter(Boolean).map((line) => ({ content: `**${formatDescription(line, true)}**` }));
96
+ if (summaryLines.length > 0) out.push(...summaryLines, { content: "" });
97
+ }
98
+ if (rawRoute.description) {
99
+ const descriptionLines = text.splitTextByLines(rawRoute.description, 60).filter(Boolean).map((line) => ({ content: formatDescription(line, true) }));
100
+ if (descriptionLines.length > 0)
101
+ out.push(...descriptionLines, { content: "" });
102
+ } else if (!rawRoute.summary) {
103
+ out.push({ content: "No description" });
104
+ }
105
+ return out;
106
+ }
59
107
  const endpointJSDocTmpl = (params) => {
60
108
  const { route, configuration, offset = 0 } = params;
61
109
  const { routeName } = route;
62
110
  const rawRoute = route.raw;
63
111
  const routeRequest = route.request;
112
+ const path2 = routeRequest?.path;
113
+ const method = routeRequest?.method;
64
114
  const { utils } = configuration;
65
115
  const { _, formatDescription } = utils;
116
+ const schema = configuration.config?.swaggerSchema ?? configuration.swaggerSchema;
117
+ const pathKey = path2?.startsWith("/") ? path2 : `/${path2 || ""}`;
118
+ const methodKey = method?.toLowerCase?.() ?? method;
119
+ const schemaOp = pathKey && methodKey ? schema?.paths?.[pathKey]?.[methodKey] : null;
120
+ const rawWithSpec = schemaOp && typeof schemaOp === "object" ? { ...schemaOp, ...rawRoute } : rawRoute;
66
121
  const jsDocLines = [];
67
- if (rawRoute.summary) {
68
- const summaryLines = text.splitTextByLines(rawRoute.summary, 60).filter(Boolean).map((line) => ({
69
- content: `**${formatDescription(line, true)}**`
70
- }));
71
- if (summaryLines.length > 0) {
72
- jsDocLines.push(...summaryLines, { content: "" });
73
- }
74
- }
75
- if (rawRoute.description) {
76
- const descriptionLines = text.splitTextByLines(rawRoute.description, 60).filter(Boolean).map((line) => ({
77
- content: formatDescription(line, true)
78
- }));
79
- if (descriptionLines.length > 0) {
80
- jsDocLines.push(...descriptionLines, { content: "" });
81
- } else {
82
- jsDocLines.push({
83
- content: "No description"
84
- });
85
- }
86
- } else {
87
- jsDocLines.push({
88
- content: "No description"
89
- });
90
- }
122
+ jsDocLines.push(
123
+ ...getSummaryAndDescriptionLines(rawRoute, formatDescription)
124
+ );
91
125
  if (rawRoute.operationId) {
92
126
  jsDocLines.push({
93
127
  name: "operationId",
@@ -104,6 +138,20 @@ const endpointJSDocTmpl = (params) => {
104
138
  name: "request",
105
139
  content: `**${_.upperCase(routeRequest.method)}:${rawRoute.route}**`
106
140
  });
141
+ const responseTypes = getResponseContentTypes(rawWithSpec);
142
+ if (responseTypes.length > 0) {
143
+ jsDocLines.push({
144
+ name: "produces",
145
+ content: responseTypes.join(", ")
146
+ });
147
+ }
148
+ const requestTypes = getRequestContentTypes(rawWithSpec);
149
+ if (requestTypes.length > 0) {
150
+ jsDocLines.push({
151
+ name: "consumes",
152
+ content: requestTypes.join(", ")
153
+ });
154
+ }
107
155
  if (rawRoute.deprecated) {
108
156
  jsDocLines.push({
109
157
  name: "deprecated"
@@ -121,10 +169,17 @@ const endpointJSDocTmpl = (params) => {
121
169
  );
122
170
  }
123
171
  if (routeRequest.security) {
124
- jsDocLines.push({
125
- name: "secure"
126
- });
172
+ jsDocLines.push({ name: "secure" });
173
+ const schemeNames = getSecuritySchemeNames(rawWithSpec.security);
174
+ if (schemeNames.length > 0) {
175
+ jsDocLines.push({ name: "security", content: schemeNames.join(", ") });
176
+ }
127
177
  }
178
+ const externalDocsLine = getExternalDocsLine(
179
+ rawWithSpec.externalDocs,
180
+ formatDescription
181
+ );
182
+ if (externalDocsLine) jsDocLines.push(externalDocsLine);
128
183
  if (rawRoute.responsesTypes.length > 0) {
129
184
  jsDocLines.push({
130
185
  name: "responses"
@@ -219,6 +274,94 @@ const responseContentKind = {
219
274
  FORM_DATA: '"formData"',
220
275
  BYTES: '"bytes"'
221
276
  };
277
+ function inferResponseFormatFromRaw(raw) {
278
+ const contentTypes = [];
279
+ if (Array.isArray(raw.produces)) {
280
+ contentTypes.push(...raw.produces);
281
+ }
282
+ const successStatus = raw.responses && Object.keys(raw.responses).find((s) => {
283
+ const code = Number.parseInt(s, 10);
284
+ return code >= 200 && code < 300;
285
+ });
286
+ const content = successStatus && raw.responses[successStatus]?.content;
287
+ if (content && typeof content === "object") {
288
+ contentTypes.push(...Object.keys(content));
289
+ }
290
+ if (contentTypes.length === 0) return null;
291
+ const mimeToFormat = (mime) => {
292
+ if (mime.includes("application/json") || mime.includes("+json"))
293
+ return '"json"';
294
+ if (mime.startsWith("text/")) return '"text"';
295
+ if (mime.includes("form-data") || mime.includes("multipart"))
296
+ return '"formData"';
297
+ if (mime.includes("octet-stream") || mime.includes("spreadsheet") || mime.includes("vnd.") || mime.startsWith("application/") || mime.startsWith("image/") || mime.startsWith("audio/") || mime.startsWith("video/") || mime.startsWith("font/") || mime.startsWith("model/") || mime.startsWith("message/") || mime.startsWith("haptics/"))
298
+ return '"blob"';
299
+ return null;
300
+ };
301
+ const preferredOrder = ['"json"', '"text"', '"formData"', '"blob"'];
302
+ for (const fmt of preferredOrder) {
303
+ const found = contentTypes.map(mimeToFormat).find((f) => f === fmt);
304
+ if (found) return found;
305
+ }
306
+ return null;
307
+ }
308
+ function getResponseFormat(responseBodyInfo, raw, configuration, path2, method) {
309
+ const fromContentKind = responseContentKind[responseBodyInfo.success?.schema?.contentKind];
310
+ if (fromContentKind) return fromContentKind;
311
+ const swaggerSchema = configuration.config?.swaggerSchema ?? configuration.swaggerSchema;
312
+ const schemaPaths = swaggerSchema?.paths;
313
+ const pathKey = path2?.startsWith("/") ? path2 : `/${path2 || ""}`;
314
+ const methodKey = method?.toLowerCase?.() ?? method;
315
+ const schemaOperation = pathKey && methodKey ? schemaPaths?.[pathKey]?.[methodKey] : null;
316
+ const rawWithProduces = schemaOperation && typeof schemaOperation === "object" ? { ...schemaOperation, ...raw } : raw;
317
+ return inferResponseFormatFromRaw(rawWithProduces);
318
+ }
319
+ function inferRequestBodyContentTypeFromRaw(raw) {
320
+ const contentTypes = [];
321
+ if (Array.isArray(raw.consumes)) {
322
+ contentTypes.push(...raw.consumes);
323
+ }
324
+ const requestBody = raw.requestBody;
325
+ if (requestBody?.content && typeof requestBody.content === "object") {
326
+ contentTypes.push(...Object.keys(requestBody.content));
327
+ }
328
+ if (contentTypes.length === 0) return null;
329
+ const mimeToContentType = (mime) => {
330
+ if (mime.includes("application/json") || mime.includes("+json"))
331
+ return '"application/json"';
332
+ if (mime.includes("application/x-www-form-urlencoded"))
333
+ return '"application/x-www-form-urlencoded"';
334
+ if (mime.includes("multipart/form-data") || mime.includes("multipart/"))
335
+ return '"multipart/form-data"';
336
+ if (mime.startsWith("text/")) return '"text/plain"';
337
+ if (mime.includes("octet-stream") || mime.startsWith("application/") || mime.startsWith("image/") || mime.startsWith("audio/") || mime.startsWith("video/") || mime.startsWith("font/") || mime.startsWith("model/") || mime.includes("vnd."))
338
+ return '"application/octet-stream"';
339
+ return null;
340
+ };
341
+ const preferredOrder = [
342
+ '"application/json"',
343
+ '"application/x-www-form-urlencoded"',
344
+ '"multipart/form-data"',
345
+ '"text/plain"',
346
+ '"application/octet-stream"'
347
+ ];
348
+ for (const ct of preferredOrder) {
349
+ const found = contentTypes.map(mimeToContentType).find((c) => c === ct);
350
+ if (found) return found;
351
+ }
352
+ return null;
353
+ }
354
+ function getRequestBodyContentType(requestBodyInfo, raw, configuration, path2, method) {
355
+ const fromContentKind = requestContentKind[requestBodyInfo?.contentKind];
356
+ if (fromContentKind) return fromContentKind;
357
+ const swaggerSchema = configuration.config?.swaggerSchema ?? configuration.swaggerSchema;
358
+ const schemaPaths = swaggerSchema?.paths;
359
+ const pathKey = path2?.startsWith("/") ? path2 : `/${path2 || ""}`;
360
+ const methodKey = method?.toLowerCase?.() ?? method;
361
+ const schemaOperation = pathKey && methodKey ? schemaPaths?.[pathKey]?.[methodKey] : null;
362
+ const rawWithConsumes = schemaOperation && typeof schemaOperation === "object" ? { ...schemaOperation, ...raw } : raw;
363
+ return inferRequestBodyContentTypeFromRaw(rawWithConsumes);
364
+ }
222
365
  const newEndpointTmpl = ({
223
366
  route,
224
367
  codegenParams,
@@ -285,8 +428,20 @@ const newEndpointTmpl = ({
285
428
  const requestInfoMeta = codegenParams.getEndpointMeta?.(route, utils);
286
429
  const requestMeta = codegenParams.getRequestMeta?.(route, utils);
287
430
  const resultPath = (codegenParams.requestPathPrefix ?? "") + path2 + (codegenParams.requestPathSuffix ?? "");
288
- const bodyContentType = requestContentKind[requestBodyInfo.contentKind] || null;
289
- const responseFormat = responseContentKind[responseBodyInfo.success?.schema?.contentKind] || null;
431
+ const bodyContentType = getRequestBodyContentType(
432
+ requestBodyInfo,
433
+ raw,
434
+ configuration,
435
+ path2,
436
+ method
437
+ ) || null;
438
+ const responseFormat = getResponseFormat(
439
+ responseBodyInfo,
440
+ raw,
441
+ configuration,
442
+ path2,
443
+ method
444
+ ) || null;
290
445
  const reservedDataContractNames = _.uniq([
291
446
  ...requestOutputDataTypes,
292
447
  requestOutputErrorType || "any",
@@ -385,17 +540,17 @@ const allEndpointPerFileTmpl = async (params) => {
385
540
  } = params;
386
541
  const { _ } = utils;
387
542
  const dataContractNamesInThisFile = [];
543
+ const dataContactNames = new Set(
544
+ Object.keys(
545
+ configuration.config.swaggerSchema?.components?.schemas
546
+ ).map((schemaName) => utils.formatModelName(schemaName))
547
+ );
388
548
  const newEndpointTemplates = routes.map((route) => {
389
549
  const newEndpointTemplateData = newEndpointTmpl({
390
550
  ...params,
391
551
  route
392
552
  });
393
553
  const { reservedDataContractNames } = newEndpointTemplateData;
394
- const dataContactNames = new Set(
395
- Object.keys(
396
- configuration.config.swaggerSchema?.components?.schemas
397
- ).map((schemaName) => utils.formatModelName(schemaName))
398
- );
399
554
  reservedDataContractNames.forEach((reservedDataContractName) => {
400
555
  if (!dataContactNames.has(reservedDataContractName)) {
401
556
  dataContractNamesInThisFile.push(reservedDataContractName);
@@ -438,14 +593,14 @@ const allEndpointPerFileTmpl = async (params) => {
438
593
  }
439
594
  )
440
595
  );
596
+ const endpointTemplatesContent = endpointTemplates.filter(Boolean).join("\n\n");
441
597
  if (metaInfo) {
442
598
  extraImportLines.push(
443
599
  `import { ${[groupName && "Group", metaInfo?.namespace && "namespace", "Tag"].filter(Boolean).join(",")} } from "${groupName ? "../" : "./"}meta-info";`
444
600
  );
445
601
  }
446
- return {
447
- reservedDataContractNames: dataContractNamesInThisFile,
448
- content: await formatTSContent(`${LINTERS_IGNORE}
602
+ const dataContractImportToken = "/*__DATA_CONTRACT_IMPORTS__*/";
603
+ const contentWithImportToken = await formatTSContent(`${LINTERS_IGNORE}
449
604
  import {
450
605
  RequestParams,
451
606
  HttpResponse,
@@ -455,32 +610,40 @@ const allEndpointPerFileTmpl = async (params) => {
455
610
  import { ${importFileParams.httpClient.exportName} } from "${importFileParams.httpClient.path}";
456
611
  import { ${importFileParams.queryClient.exportName} } from "${importFileParams.queryClient.path}";
457
612
  ${extraImportLines.join("\n")}
458
-
459
- ${configuration.modelTypes.length > 0 ? `
460
- import { ${configuration.modelTypes.map((it) => it.name).filter(
461
- (it) => !dataContractNamesInThisFile.includes(it)
462
- )} } from "${relativePathDataContracts}";
463
- ` : ""}
613
+ ${dataContractImportToken}
464
614
 
465
615
  ${(await Promise.all(
466
- dataContractNamesInThisFile.map(async (dataContractName) => {
467
- const modelType = configuration.modelTypes.find(
468
- (modelType2) => modelType2.name === dataContractName
469
- );
470
- if (!modelType) {
471
- return "";
472
- }
473
- const contractType = await dataContractTmpl({
474
- ...params,
475
- contract: modelType,
476
- addExportKeyword: true
477
- });
478
- return contractType;
479
- })
480
- )).filter(Boolean).join("\n\n")}
616
+ dataContractNamesInThisFile.map(async (dataContractName) => {
617
+ const modelType = configuration.modelTypes.find(
618
+ (modelType2) => modelType2.name === dataContractName
619
+ );
620
+ if (!modelType) {
621
+ return "";
622
+ }
623
+ const contractType = await dataContractTmpl({
624
+ ...params,
625
+ contract: modelType,
626
+ addExportKeyword: true
627
+ });
628
+ return contractType;
629
+ })
630
+ )).filter(Boolean).join("\n\n")}
481
631
 
482
- ${endpointTemplates.filter(Boolean).join("\n\n")}
483
- `)
632
+ ${endpointTemplatesContent}
633
+ `);
634
+ const escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
635
+ const usedDataContractNames = configuration.modelTypes.map((modelType) => modelType.name).filter(
636
+ (modelTypeName) => !dataContractNamesInThisFile.includes(modelTypeName) && dataContactNames.has(modelTypeName) && new RegExp(`\\b${escapeRegExp(modelTypeName)}\\b`).test(
637
+ contentWithImportToken
638
+ )
639
+ );
640
+ const dataContractImportLine = usedDataContractNames.length > 0 ? `import { ${usedDataContractNames.join(", ")} } from "${relativePathDataContracts}";` : "";
641
+ return {
642
+ reservedDataContractNames: dataContractNamesInThisFile,
643
+ content: contentWithImportToken.replace(
644
+ dataContractImportToken,
645
+ dataContractImportLine
646
+ )
484
647
  };
485
648
  };
486
649
  const allExportsTmpl = async ({
@@ -565,9 +728,8 @@ const endpointPerFileTmpl = async (params) => {
565
728
  `import { ${requestInfoMeta.typeName} } from "${requestInfoMeta.typeNameImportPath}";`
566
729
  );
567
730
  }
568
- return {
569
- reservedDataContractNames: dataContractNamesInThisFile,
570
- content: await formatTSContent(`${LINTERS_IGNORE}
731
+ const dataContractImportToken = "/*__DATA_CONTRACT_IMPORTS__*/";
732
+ const contentWithImportToken = await formatTSContent(`${LINTERS_IGNORE}
571
733
  import {
572
734
  RequestParams,
573
735
  HttpResponse,
@@ -577,47 +739,55 @@ const endpointPerFileTmpl = async (params) => {
577
739
  import { ${importFileParams.httpClient.exportName} } from "${importFileParams.httpClient.path}";
578
740
  import { ${importFileParams.queryClient.exportName} } from "${importFileParams.queryClient.path}";
579
741
  ${extraImportLines.join("\n")}
580
-
581
- ${configuration.modelTypes.length > 0 ? `
582
- import { ${configuration.modelTypes.map((it) => it.name).filter(
583
- (it) => !dataContractNamesInThisFile.includes(it)
584
- )} } from "${relativePathDataContracts}";
585
- ` : ""}
742
+ ${dataContractImportToken}
586
743
 
587
744
  ${(await Promise.all(
588
- dataContractNamesInThisFile.map(async (dataContractName) => {
589
- const modelType = configuration.modelTypes.find(
590
- (modelType2) => modelType2.name === dataContractName
591
- );
592
- if (!modelType) {
593
- return "";
594
- }
595
- const contractType = await dataContractTmpl({
596
- ...params,
597
- contract: modelType,
598
- addExportKeyword: true
599
- });
600
- return contractType;
601
- })
602
- )).filter(Boolean).join("\n\n")}
745
+ dataContractNamesInThisFile.map(async (dataContractName) => {
746
+ const modelType = configuration.modelTypes.find(
747
+ (modelType2) => modelType2.name === dataContractName
748
+ );
749
+ if (!modelType) {
750
+ return "";
751
+ }
752
+ const contractType = await dataContractTmpl({
753
+ ...params,
754
+ contract: modelType,
755
+ addExportKeyword: true
756
+ });
757
+ return contractType;
758
+ })
759
+ )).filter(Boolean).join("\n\n")}
603
760
 
604
761
  ${(await Promise.all(
605
- localModelTypes.map(async (modelType) => {
606
- const contractType = await dataContractTmpl({
607
- ...params,
608
- contract: modelType,
609
- addExportKeyword: true
610
- });
611
- return contractType;
612
- })
613
- )).filter(Boolean).join("\n\n")}
762
+ localModelTypes.map(async (modelType) => {
763
+ const contractType = await dataContractTmpl({
764
+ ...params,
765
+ contract: modelType,
766
+ addExportKeyword: true
767
+ });
768
+ return contractType;
769
+ })
770
+ )).filter(Boolean).join("\n\n")}
614
771
 
615
772
  ${endpointJSDocTmpl({
616
- ...params,
617
- route
618
- })}
773
+ ...params,
774
+ route
775
+ })}
619
776
  export const ${_.camelCase(route.routeName.usage)} = ${requestInfoInstanceContent}
620
- `)
777
+ `);
778
+ const escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
779
+ const usedDataContractNames = configuration.modelTypes.map((modelType) => modelType.name).filter(
780
+ (modelTypeName) => !dataContractNamesInThisFile.includes(modelTypeName) && dataContactNames.has(modelTypeName) && new RegExp(`\\b${escapeRegExp(modelTypeName)}\\b`).test(
781
+ contentWithImportToken
782
+ )
783
+ );
784
+ const dataContractImportLine = usedDataContractNames.length > 0 ? `import { ${usedDataContractNames.join(", ")} } from "${relativePathDataContracts}";` : "";
785
+ return {
786
+ reservedDataContractNames: dataContractNamesInThisFile,
787
+ content: contentWithImportToken.replace(
788
+ dataContractImportToken,
789
+ dataContractImportLine
790
+ )
621
791
  };
622
792
  };
623
793
  const indexTsForEndpointPerFileTmpl = async ({
@@ -731,15 +901,11 @@ const removeUnusedTypesItteration = async ({
731
901
  }
732
902
  }
733
903
  let removedCount = 0;
734
- const isNeedToRemoveType = unpackFilterOption(
735
- keepTypes,
736
- (name) => name,
737
- false
738
- );
904
+ const isKeepType = unpackFilterOption(keepTypes, (name) => name, false);
739
905
  for (const [name, declarations] of candidateTypes) {
740
906
  if (usedTypes.has(name)) continue;
741
907
  for (const decl of declarations) {
742
- if ("remove" in decl && isNeedToRemoveType(name)) {
908
+ if ("remove" in decl && !isKeepType(name)) {
743
909
  decl.remove();
744
910
  removedCount++;
745
911
  }
@@ -930,6 +1096,7 @@ const generateApi = async (params) => {
930
1096
  });
931
1097
  const utils = codegenProcess.getRenderTemplateData().utils;
932
1098
  const { _ } = utils;
1099
+ const outputType = params.outputType ?? "one-endpoint-per-file";
933
1100
  const shouldGenerateBarrelFiles = !params.noBarrelFiles;
934
1101
  let namespace = null;
935
1102
  if (params.namespace) {
@@ -940,8 +1107,8 @@ const generateApi = async (params) => {
940
1107
  }
941
1108
  }
942
1109
  const codegenFs = codegenProcess.fileSystem;
943
- codegenFs.cleanDir(params.output);
944
- codegenFs.createDir(params.output);
1110
+ codegenFs.cleanDir(paths.outputDir);
1111
+ codegenFs.createDir(paths.outputDir);
945
1112
  const filterTypes = unpackFilterOption(
946
1113
  params.filterTypes,
947
1114
  (modelType) => modelType.name
@@ -973,7 +1140,7 @@ const generateApi = async (params) => {
973
1140
  const tagsSet = /* @__PURE__ */ new Set();
974
1141
  if (params.groupBy == null) {
975
1142
  collectedExportFilesFromIndexFile.push("endpoints");
976
- if (params.outputType === "one-endpoint-per-file") {
1143
+ if (outputType === "one-endpoint-per-file") {
977
1144
  codegenFs.createDir(path.resolve(params.output, "endpoints"));
978
1145
  const fileNamesWithRequestInfo = [];
979
1146
  for await (const route of allRoutes) {
@@ -1053,7 +1220,7 @@ const generateApi = async (params) => {
1053
1220
  const fileName = "endpoints.ts";
1054
1221
  collectedExportFilesFromIndexFile.push("endpoints");
1055
1222
  codegenFs.createFile({
1056
- path: params.output,
1223
+ path: paths.outputDir,
1057
1224
  fileName,
1058
1225
  withPrefix: false,
1059
1226
  content: requestInfoPerFileContent
@@ -1095,7 +1262,7 @@ const generateApi = async (params) => {
1095
1262
  );
1096
1263
  codegenFs.createDir(groupDirectory);
1097
1264
  let hasFilteredRoutes = false;
1098
- if (params.outputType === "one-endpoint-per-file") {
1265
+ if (outputType === "one-endpoint-per-file") {
1099
1266
  codegenFs.createDir(path.resolve(groupDirectory, "endpoints"));
1100
1267
  for await (const route of routes) {
1101
1268
  const {
@@ -1192,7 +1359,7 @@ export * as ${exportGroupName} from './endpoints';
1192
1359
  `
1193
1360
  });
1194
1361
  }
1195
- if (shouldGenerateBarrelFiles && params.outputType === "one-endpoint-per-file") {
1362
+ if (shouldGenerateBarrelFiles && outputType === "one-endpoint-per-file") {
1196
1363
  codegenFs.createFile({
1197
1364
  path: path.resolve(groupDirectory, "endpoints"),
1198
1365
  fileName: "index.ts",
@@ -1276,7 +1443,7 @@ export * as ${namespace} from './__exports';
1276
1443
  }
1277
1444
  if (params.removeUnusedTypes) {
1278
1445
  await removeUnusedTypes({
1279
- directory: params.output,
1446
+ directory: paths.outputDir,
1280
1447
  keepTypes: params.removeUnusedTypes === true ? void 0 : params.removeUnusedTypes.keepTypes
1281
1448
  });
1282
1449
  }