@openapi-qraft/tanstack-query-react-plugin 2.6.4 → 2.7.1

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 (79) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/generateCode.d.ts +4 -2
  3. package/dist/generateCode.d.ts.map +1 -1
  4. package/dist/generateCode.js +15 -11
  5. package/dist/generateCode.js.map +1 -1
  6. package/dist/plugin.d.ts.map +1 -1
  7. package/dist/plugin.js +42 -5
  8. package/dist/plugin.js.map +1 -1
  9. package/dist/ts-factory/OverrideImportType.d.ts +25 -0
  10. package/dist/ts-factory/OverrideImportType.d.ts.map +1 -0
  11. package/dist/ts-factory/OverrideImportType.js +2 -0
  12. package/dist/ts-factory/OverrideImportType.js.map +1 -0
  13. package/dist/ts-factory/getCreateAPIClientFactory.d.ts +2 -0
  14. package/dist/ts-factory/getCreateAPIClientFactory.d.ts.map +1 -1
  15. package/dist/ts-factory/getCreateAPIClientFactory.js +23 -19
  16. package/dist/ts-factory/getCreateAPIClientFactory.js.map +1 -1
  17. package/dist/ts-factory/getCreatePredefinedParametersRequestFnFactory.d.ts +3 -1
  18. package/dist/ts-factory/getCreatePredefinedParametersRequestFnFactory.d.ts.map +1 -1
  19. package/dist/ts-factory/getCreatePredefinedParametersRequestFnFactory.js +23 -5
  20. package/dist/ts-factory/getCreatePredefinedParametersRequestFnFactory.js.map +1 -1
  21. package/dist/ts-factory/getOverriddenImportDeclarationsFactory.d.ts +4 -0
  22. package/dist/ts-factory/getOverriddenImportDeclarationsFactory.d.ts.map +1 -0
  23. package/dist/ts-factory/getOverriddenImportDeclarationsFactory.js +25 -0
  24. package/dist/ts-factory/getOverriddenImportDeclarationsFactory.js.map +1 -0
  25. package/dist/ts-factory/getServiceFactory.d.ts +2 -1
  26. package/dist/ts-factory/getServiceFactory.d.ts.map +1 -1
  27. package/dist/ts-factory/getServiceFactory.js +20 -11
  28. package/dist/ts-factory/getServiceFactory.js.map +1 -1
  29. package/dist/ts-factory/getServiceIndexFactory.d.ts +1 -1
  30. package/dist/ts-factory/service-operation.generated/ServiceOperationCancelQueries.js +1 -1
  31. package/dist/ts-factory/service-operation.generated/ServiceOperationCancelQueries.js.map +1 -1
  32. package/dist/ts-factory/service-operation.generated/ServiceOperationGetQueriesData.js +1 -1
  33. package/dist/ts-factory/service-operation.generated/ServiceOperationGetQueriesData.js.map +1 -1
  34. package/dist/ts-factory/service-operation.generated/ServiceOperationGetQueryState.js +1 -1
  35. package/dist/ts-factory/service-operation.generated/ServiceOperationGetQueryState.js.map +1 -1
  36. package/dist/ts-factory/service-operation.generated/ServiceOperationInvalidateQueries.js +1 -1
  37. package/dist/ts-factory/service-operation.generated/ServiceOperationInvalidateQueries.js.map +1 -1
  38. package/dist/ts-factory/service-operation.generated/ServiceOperationIsMutatingQueries.d.ts.map +1 -1
  39. package/dist/ts-factory/service-operation.generated/ServiceOperationIsMutatingQueries.js +4 -9
  40. package/dist/ts-factory/service-operation.generated/ServiceOperationIsMutatingQueries.js.map +1 -1
  41. package/dist/ts-factory/service-operation.generated/ServiceOperationRefetchQueries.js +1 -1
  42. package/dist/ts-factory/service-operation.generated/ServiceOperationRefetchQueries.js.map +1 -1
  43. package/dist/ts-factory/service-operation.generated/ServiceOperationResetQueries.js +1 -1
  44. package/dist/ts-factory/service-operation.generated/ServiceOperationResetQueries.js.map +1 -1
  45. package/dist/ts-factory/service-operation.generated/ServiceOperationSetInfiniteQueryData.js +1 -1
  46. package/dist/ts-factory/service-operation.generated/ServiceOperationSetInfiniteQueryData.js.map +1 -1
  47. package/dist/ts-factory/service-operation.generated/ServiceOperationSetQueriesData.js +1 -1
  48. package/dist/ts-factory/service-operation.generated/ServiceOperationSetQueriesData.js.map +1 -1
  49. package/dist/ts-factory/service-operation.generated/ServiceOperationSetQueryData.js +1 -1
  50. package/dist/ts-factory/service-operation.generated/ServiceOperationSetQueryData.js.map +1 -1
  51. package/dist/ts-factory/service-operation.generated/ServiceOperationUseInfiniteQuery.d.ts.map +1 -1
  52. package/dist/ts-factory/service-operation.generated/ServiceOperationUseInfiniteQuery.js +4 -9
  53. package/dist/ts-factory/service-operation.generated/ServiceOperationUseInfiniteQuery.js.map +1 -1
  54. package/dist/ts-factory/service-operation.generated/ServiceOperationUseIsMutating.d.ts.map +1 -1
  55. package/dist/ts-factory/service-operation.generated/ServiceOperationUseIsMutating.js +4 -9
  56. package/dist/ts-factory/service-operation.generated/ServiceOperationUseIsMutating.js.map +1 -1
  57. package/dist/ts-factory/service-operation.generated/ServiceOperationUseMutation.d.ts.map +1 -1
  58. package/dist/ts-factory/service-operation.generated/ServiceOperationUseMutation.js +5 -16
  59. package/dist/ts-factory/service-operation.generated/ServiceOperationUseMutation.js.map +1 -1
  60. package/dist/ts-factory/service-operation.generated/ServiceOperationUseMutationState.d.ts.map +1 -1
  61. package/dist/ts-factory/service-operation.generated/ServiceOperationUseMutationState.js +7 -18
  62. package/dist/ts-factory/service-operation.generated/ServiceOperationUseMutationState.js.map +1 -1
  63. package/dist/ts-factory/service-operation.generated/ServiceOperationUseQuery.d.ts.map +1 -1
  64. package/dist/ts-factory/service-operation.generated/ServiceOperationUseQuery.js +3 -8
  65. package/dist/ts-factory/service-operation.generated/ServiceOperationUseQuery.js.map +1 -1
  66. package/dist/ts-factory/service-operation.generated/ServiceOperationUseSuspenseInfiniteQuery.d.ts.map +1 -1
  67. package/dist/ts-factory/service-operation.generated/ServiceOperationUseSuspenseInfiniteQuery.js +3 -5
  68. package/dist/ts-factory/service-operation.generated/ServiceOperationUseSuspenseInfiniteQuery.js.map +1 -1
  69. package/dist/ts-factory/service-operation.generated/ServiceOperationUseSuspenseQuery.d.ts.map +1 -1
  70. package/dist/ts-factory/service-operation.generated/ServiceOperationUseSuspenseQuery.js +2 -4
  71. package/dist/ts-factory/service-operation.generated/ServiceOperationUseSuspenseQuery.js.map +1 -1
  72. package/package.json +3 -3
  73. package/src/generateCode.ts +36 -13
  74. package/src/plugin.ts +83 -7
  75. package/src/ts-factory/OverrideImportType.ts +27 -0
  76. package/src/ts-factory/getCreateAPIClientFactory.ts +58 -68
  77. package/src/ts-factory/getCreatePredefinedParametersRequestFnFactory.ts +42 -19
  78. package/src/ts-factory/getOverriddenImportDeclarationsFactory.ts +53 -0
  79. package/src/ts-factory/getServiceFactory.ts +41 -15
@@ -1 +1 @@
1
- {"version":3,"file":"ServiceOperationUseSuspenseQuery.js","sourceRoot":"","sources":["../../../src/ts-factory/service-operation.generated/ServiceOperationUseSuspenseQuery.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC;AAC3B,MAAM,CAAC,MAAM,2CAA2C,GAAG,GAAG,EAAE,CAAC;IAC/D,OAAO,CAAC,uBAAuB,CAC7B,SAAS,EACT,OAAO,CAAC,kBAAkB,CACxB,IAAI,EACJ,SAAS,EACT,OAAO,CAAC,kBAAkB,CAAC;QACzB,OAAO,CAAC,qBAAqB,CAC3B,KAAK,EACL,SAAS,EACT,OAAO,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAC3C;QACD,OAAO,CAAC,qBAAqB,CAC3B,KAAK,EACL,SAAS,EACT,OAAO,CAAC,gBAAgB,CAAC,cAAc,CAAC,CACzC;QACD,OAAO,CAAC,qBAAqB,CAC3B,KAAK,EACL,SAAS,EACT,OAAO,CAAC,gBAAgB,CAAC,0BAA0B,CAAC,CACrD;KACF,CAAC,CACH,EACD,OAAO,CAAC,mBAAmB,CAAC,2CAA2C,CAAC,EACxE,SAAS,CACV;IACD,OAAO,CAAC,uBAAuB,CAC7B,SAAS,EACT,OAAO,CAAC,kBAAkB,CACxB,IAAI,EACJ,SAAS,EACT,OAAO,CAAC,kBAAkB,CAAC;QACzB,OAAO,CAAC,qBAAqB,CAC3B,KAAK,EACL,SAAS,EACT,OAAO,CAAC,gBAAgB,CAAC,yBAAyB,CAAC,CACpD;QACD,O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,gBAAgB,CAAC,wBAAwB,CAAC,EAClD;YACE,OAAO,CAAC,uBAAuB,CAC7B,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,EACjC,SAAS,CACV;YACD,OAAO,CAAC,mBAAmB,CAAC;gBAC1B,OAAO,CAAC,uBAAuB,CAC7B,OAAO,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAClC,SAAS,CACV;gBACD,OAAO,CAAC,uBAAuB,CAC7B,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,EACjC,SAAS,CACV;aACF,CAAC;SACH,CACF,CACF,CAAC,CACH;CACF,CAAC"}
1
+ {"version":3,"file":"ServiceOperationUseSuspenseQuery.js","sourceRoot":"","sources":["../../../src/ts-factory/service-operation.generated/ServiceOperationUseSuspenseQuery.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC;AAC3B,MAAM,CAAC,MAAM,2CAA2C,GAAG,GAAG,EAAE,CAAC;IAC/D,OAAO,CAAC,uBAAuB,CAC7B,SAAS,EACT,OAAO,CAAC,kBAAkB,CACxB,IAAI,EACJ,SAAS,EACT,OAAO,CAAC,kBAAkB,CAAC;QACzB,OAAO,CAAC,qBAAqB,CAC3B,KAAK,EACL,SAAS,EACT,OAAO,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAC3C;QACD,OAAO,CAAC,qBAAqB,CAC3B,KAAK,EACL,SAAS,EACT,OAAO,CAAC,gBAAgB,CAAC,cAAc,CAAC,CACzC;QACD,OAAO,CAAC,qBAAqB,CAC3B,KAAK,EACL,SAAS,EACT,OAAO,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAC3C;QACD,OAAO,CAAC,qBAAqB,CAC3B,KAAK,EACL,SAAS,EACT,OAAO,CAAC,gBAAgB,CAAC,0BAA0B,CAAC,CACrD;KACF,CAAC,CACH,EACD,OAAO,CAAC,mBAAmB,C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;wBACD,OAAO,CAAC,uBAAuB,CAC7B,OAAO,CAAC,gBAAgB,CAAC,cAAc,CAAC,EACxC,SAAS,CACV;qBACF,CACF;iBACF,CACF;gBACD,OAAO,CAAC,qBAAqB,CAAC,OAAO,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;aACvE,CACF,EACD,SAAS,CACV;SACF,EACD,OAAO,CAAC,uBAAuB,CAC7B,OAAO,CAAC,gBAAgB,CAAC,wBAAwB,CAAC,EAClD;YACE,OAAO,CAAC,uBAAuB,CAC7B,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,EACjC,SAAS,CACV;YACD,OAAO,CAAC,uBAAuB,CAC7B,OAAO,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,EAC1C,CAAC,OAAO,CAAC,uBAAuB,CAC9B,OAAO,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAClC,SAAS,CACV,CAAC,CACH;SACF,CACF,CACF,CAAC,CACH;CACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openapi-qraft/tanstack-query-react-plugin",
3
- "version": "2.6.4",
3
+ "version": "2.7.1",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "tsc --project tsconfig.build.json",
@@ -35,12 +35,12 @@
35
35
  }
36
36
  },
37
37
  "dependencies": {
38
- "@openapi-qraft/plugin": "^2.6.4",
38
+ "@openapi-qraft/plugin": "^2.7.1",
39
39
  "typescript": "^5.6.2"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@openapi-qraft/eslint-config": "1.0.1",
43
- "@openapi-qraft/tanstack-query-react-types": "2.6.4",
43
+ "@openapi-qraft/tanstack-query-react-types": "2.7.1",
44
44
  "@openapi-qraft/test-fixtures": "1.1.0",
45
45
  "@openapi-qraft/ts-factory-code-generator": "1.0.2",
46
46
  "camelcase": "^8.0.0",
@@ -1,3 +1,4 @@
1
+ import type { OverrideImportType } from './ts-factory/OverrideImportType.js';
1
2
  import { URL } from 'node:url';
2
3
  import { formatFileHeader } from '@openapi-qraft/plugin/lib/formatFileHeader';
3
4
  import { GeneratorFile } from '@openapi-qraft/plugin/lib/GeneratorFile';
@@ -33,26 +34,35 @@ interface OutputOptions extends OutputOptionsBase {
33
34
  export const generateCode = async ({
34
35
  spinner,
35
36
  services,
36
- serviceImports,
37
+ serviceOptions,
37
38
  output,
39
+ overrideImportType,
38
40
  }: {
39
41
  spinner: Ora;
40
42
  services: OpenAPIService[];
41
- serviceImports: ServiceFactoryOptions;
43
+ serviceOptions: ServiceFactoryOptions;
42
44
  output: OutputOptions;
45
+ overrideImportType: OverrideImportType | undefined;
43
46
  }) => {
44
47
  return [
45
- ...(await generateServices(spinner, services, serviceImports, output)),
48
+ ...(await generateServices(
49
+ spinner,
50
+ services,
51
+ serviceOptions,
52
+ output,
53
+ overrideImportType
54
+ )),
46
55
  ...(await generateServiceIndex(spinner, services, output)),
47
- ...(await generateOperationClient(spinner, output)),
56
+ ...(await generateOperationClient(spinner, output, overrideImportType)),
48
57
  ...(output.operationPredefinedParameters
49
58
  ? await generateCreatePredefinedParametersRequestFn(
50
59
  spinner,
51
- serviceImports,
52
- output
60
+ serviceOptions,
61
+ output,
62
+ overrideImportType
53
63
  )
54
64
  : []),
55
- ...(await generateIndex(spinner, serviceImports, output)),
65
+ ...(await generateIndex(spinner, serviceOptions, output)),
56
66
  ];
57
67
  };
58
68
 
@@ -66,7 +76,8 @@ const generateServices = async (
66
76
  spinner: Ora,
67
77
  services: OpenAPIService[],
68
78
  serviceImports: ServiceFactoryOptions,
69
- output: OutputOptions
79
+ output: OutputOptions,
80
+ overrideImportType: OverrideImportType | undefined
70
81
  ) => {
71
82
  const servicesDir = composeServicesDirPath(output);
72
83
 
@@ -92,7 +103,8 @@ const generateServices = async (
92
103
  variableName,
93
104
  },
94
105
  operations,
95
- serviceImports
106
+ serviceImports,
107
+ overrideImportType?.[output.servicesDirName]
96
108
  )
97
109
  );
98
110
 
@@ -150,13 +162,19 @@ const generateServiceIndex = async (
150
162
  return serviceIndexFiles;
151
163
  };
152
164
 
153
- const generateOperationClient = async (spinner: Ora, output: OutputOptions) => {
165
+ const generateOperationClient = async (
166
+ spinner: Ora,
167
+ output: OutputOptions,
168
+ overrideImportType: OverrideImportType | undefined
169
+ ) => {
154
170
  spinner.start('Generating operation client');
155
171
 
156
172
  const operationClientFiles: GeneratorFile[] = [];
157
173
 
158
174
  try {
159
175
  output.createApiClientFn.map(([functionName, value]) => {
176
+ const fileName = value.filename?.[0] ?? functionName;
177
+
160
178
  const code = astToString(
161
179
  getCreateAPIClientFactory({
162
180
  defaultClientCallbacks: value.callbacks,
@@ -164,11 +182,12 @@ const generateOperationClient = async (spinner: Ora, output: OutputOptions) => {
164
182
  createAPIClientFnName: functionName,
165
183
  servicesDirName: output.servicesDirName,
166
184
  explicitImportExtensions: output.explicitImportExtensions,
185
+ createAPIClientFnImportTypeOverrides: overrideImportType?.[fileName],
167
186
  })
168
187
  );
169
188
 
170
189
  operationClientFiles.push({
171
- file: new URL(`${value.filename?.[0] ?? functionName}.ts`, output.dir),
190
+ file: new URL(`${fileName}.ts`, output.dir),
172
191
  code: formatFileHeader(output.fileHeader) + code,
173
192
  });
174
193
  });
@@ -188,23 +207,27 @@ const generateOperationClient = async (spinner: Ora, output: OutputOptions) => {
188
207
  const generateCreatePredefinedParametersRequestFn = async (
189
208
  spinner: Ora,
190
209
  serviceImports: ServiceFactoryOptions,
191
- output: OutputOptions
210
+ output: OutputOptions,
211
+ overrideImportType: OverrideImportType | undefined
192
212
  ) => {
193
213
  spinner.start('Generating "createPredefinedParametersRequestFn"');
194
214
 
195
215
  const clientFiles: GeneratorFile[] = [];
196
216
 
197
217
  try {
218
+ const filename = 'create-predefined-parameters-request-fn';
219
+
198
220
  const code = astToString(
199
221
  getCreatePredefinedParametersRequestFnFactory({
200
222
  servicesDirName: output.servicesDirName,
201
223
  operationPredefinedParameters: output.operationPredefinedParameters,
202
224
  openapiTypesImportPath: serviceImports.openapiTypesImportPath,
225
+ importTypeOverrides: overrideImportType?.[filename],
203
226
  })
204
227
  );
205
228
 
206
229
  clientFiles.push({
207
- file: new URL('create-predefined-parameters-request-fn.ts', output.dir),
230
+ file: new URL(`${filename}.ts`, output.dir),
208
231
  code: formatFileHeader(output.fileHeader) + code,
209
232
  });
210
233
  } catch (error) {
package/src/plugin.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { OverrideImportType } from './ts-factory/OverrideImportType.js';
1
2
  import { fileHeader } from '@openapi-qraft/plugin/lib/fileHeader';
2
3
  import {
3
4
  createPredefinedParametersGlobs,
@@ -31,7 +32,7 @@ export const plugin: QraftCommandPlugin = {
31
32
  )
32
33
  .option(
33
34
  '--export-openapi-types [bool]',
34
- "Add an export statement of the generated OpenAPI document types from the `./index.ts' file. Useful for sharing types within your project.",
35
+ "Add an export statement of the generated OpenAPI document types from the `./index.ts' file. Useful for sharing types within your project. Default: true when --plugin openapi-typescript is used.",
35
36
  parseBooleanOption
36
37
  )
37
38
  .option(
@@ -39,22 +40,37 @@ export const plugin: QraftCommandPlugin = {
39
40
  'Enable generation of query hooks (useQuery, useSuspenseQuery, etc.) for writable HTTP methods like POST, PUT, PATCH. By default, only mutation hooks are generated for writable operations.',
40
41
  parseBooleanOption
41
42
  )
43
+ .addOption(
44
+ (() => {
45
+ const option = new Option(
46
+ '--create-api-client-fn <functionName> [options...]',
47
+ 'Configure API client creation function. Allows specifying the function name, included services, and callbacks. Can be specified multiple times to generate several different API client functions from a single OpenAPI document.'
48
+ )
49
+ .argParser(parseCreateApiClientFn)
50
+ .default(createApiClientFnDefault);
51
+
52
+ option.defaultValueDescription = 'null';
53
+
54
+ return option;
55
+ })()
56
+ )
42
57
  .addOption(
43
58
  new Option(
44
- '--create-api-client-fn [name...]',
45
- 'Name, default callbacks and services of the generated `createAPIClient` function'
46
- )
47
- .argParser(parseCreateApiClientFn)
48
- .default(createApiClientFnDefault)
59
+ '--override-import-type <pathname overrides...>',
60
+ 'Override import paths for specific types in generated files. This allows using custom type implementations instead of the default ones. Expected format: filepath originalModule:importTypeName:customImportPath'
61
+ ).argParser(parseOverrideImportType)
49
62
  )
50
63
  .action(async ({ spinner, output, args, services, schema }, resolve) => {
51
64
  return void (await generateCode({
52
65
  spinner,
53
66
  services,
54
- serviceImports: {
67
+ serviceOptions: {
55
68
  openapiTypesImportPath: args.openapiTypesImportPath,
56
69
  queryableWriteOperations: args.queryableWriteOperations,
57
70
  },
71
+ overrideImportType: Array.isArray(args.overrideImportType)
72
+ ? args.overrideImportType[0]
73
+ : undefined,
58
74
  output: {
59
75
  ...output,
60
76
  fileHeader: args.fileHeader ?? fileHeader,
@@ -185,6 +201,66 @@ function parseCreateApiClientFn(
185
201
  return nextValue;
186
202
  }
187
203
 
204
+ type ParsedOverrideImportTypeOption = [
205
+ overrides: OverrideImportType,
206
+ filepath?: string,
207
+ ];
208
+
209
+ function parseOverrideImportType(
210
+ value: string,
211
+ previousValue: unknown
212
+ ): ParsedOverrideImportTypeOption {
213
+ const previous = (
214
+ Array.isArray(previousValue) ? previousValue : [{}]
215
+ ) as ParsedOverrideImportTypeOption;
216
+
217
+ if (!value.includes(':')) {
218
+ previous.push(value);
219
+
220
+ return previous;
221
+ }
222
+
223
+ const importOverrides = value.split(':');
224
+
225
+ if (importOverrides.length === 3) {
226
+ const originalModule = importOverrides[0];
227
+ const typeName = importOverrides[1];
228
+ const overrideModule = importOverrides[2];
229
+
230
+ if (!originalModule || !typeName || !overrideModule) {
231
+ throw new CommanderError(
232
+ 1,
233
+ 'ERR_INVALID_IMPORT_TYPE_OVERRIDE',
234
+ `Invalid import type override: ${value}. Expected format: originalModule:importTypeName:customImportPath`
235
+ );
236
+ }
237
+
238
+ const filePath = previous[previous.length - 1];
239
+
240
+ if (!filePath || typeof filePath !== 'string') {
241
+ throw new CommanderError(
242
+ 1,
243
+ 'ERR_INVALID_IMPORT_TYPE_OVERRIDE',
244
+ `Invalid import type override: ${value}. Expected format: filepath originalModule:importTypeName:customImportPath`
245
+ );
246
+ }
247
+
248
+ const [overrides] = previous;
249
+ overrides[filePath] = overrides[filePath] ?? {};
250
+ overrides[filePath][originalModule] =
251
+ overrides[filePath][originalModule] ?? {};
252
+ overrides[filePath][originalModule][typeName] = overrideModule;
253
+
254
+ return previous;
255
+ } else {
256
+ throw new CommanderError(
257
+ 1,
258
+ 'ERR_INVALID_IMPORT_TYPE_OVERRIDE',
259
+ `Invalid import type override: ${value}. Expected format: filepath namespace:importTypeName:importPath`
260
+ );
261
+ }
262
+ }
263
+
188
264
  type CreateAPIClientFnArg = [
189
265
  functionName: string,
190
266
  value: Partial<CreateAPIClientFnOptions>,
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Allows you to override standard type imports by specifying custom paths for them.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * {
7
+ * services: {
8
+ * '@openapi-qraft/tanstack-query-react-types': {
9
+ * OperationError: '../custom/types/ErrorType.js',
10
+ * RequestFn: '../custom/types/ApiClient.js',
11
+ * },
12
+ * '@openapi-qraft/react': {
13
+ * Result: '../custom/types/ApiResult.js',
14
+ * },
15
+ * },
16
+ * 'create-api-client': {
17
+ * '@openapi-qraft/react': {
18
+ * CreateAPIQueryClientOptions:
19
+ * '../custom/types/CreateAPIQueryClientOptions',
20
+ * },
21
+ * },
22
+ * }
23
+ **/
24
+ export type OverrideImportType = Record<
25
+ string,
26
+ Record<string, Record<string, string>>
27
+ >;
@@ -1,4 +1,6 @@
1
+ import type { OverrideImportType } from './OverrideImportType.js';
1
2
  import ts from 'typescript';
3
+ import { getOverriddenImportDeclarationsFactory } from './getOverriddenImportDeclarationsFactory.js';
2
4
 
3
5
  type Options = {
4
6
  servicesDirName: string;
@@ -6,6 +8,9 @@ type Options = {
6
8
  defaultClientCallbacks: string[] | ['all'] | ['none'] | undefined;
7
9
  defaultClientServices: string[] | ['all'] | ['none'] | undefined;
8
10
  createAPIClientFnName: string;
11
+ createAPIClientFnImportTypeOverrides:
12
+ | OverrideImportType[keyof OverrideImportType]
13
+ | undefined;
9
14
  };
10
15
 
11
16
  export const getCreateAPIClientFactory = (options: Options) => {
@@ -20,6 +25,7 @@ const getOperationClientImportsFactory = ({
20
25
  explicitImportExtensions,
21
26
  defaultClientCallbacks,
22
27
  defaultClientServices,
28
+ createAPIClientFnImportTypeOverrides,
23
29
  }: Options) => {
24
30
  const factory = ts.factory;
25
31
 
@@ -35,75 +41,59 @@ const getOperationClientImportsFactory = ({
35
41
  (name) => name !== 'all' && name !== 'none'
36
42
  ) || [];
37
43
 
38
- const imports: ts.Statement[] = [
39
- factory.createImportDeclaration(
40
- undefined,
41
- factory.createImportClause(
42
- true,
44
+ const qraftImportTypeOverrides =
45
+ createAPIClientFnImportTypeOverrides?.['@openapi-qraft/react'];
46
+
47
+ const availableQraftImportedTypes = [
48
+ 'APIBasicClientServices',
49
+ 'APIBasicQueryClientServices',
50
+ 'APIDefaultQueryClientServices',
51
+ !shouldImportAllCallbacks && 'APIQueryClientServices',
52
+ 'APIUtilityClientServices',
53
+ 'CreateAPIBasicClientOptions',
54
+ 'CreateAPIBasicQueryClientOptions',
55
+ 'CreateAPIClientOptions',
56
+ 'CreateAPIQueryClientOptions',
57
+ !shouldImportAllServices && 'UnionServiceOperationsDeclaration',
58
+ ].filter((typeName) => typeof typeName === 'string');
59
+
60
+ const imports: ts.Statement[] = [];
61
+
62
+ const qraftTypesToImport = availableQraftImportedTypes.filter(
63
+ (typeName) => !qraftImportTypeOverrides?.[typeName]
64
+ );
65
+
66
+ if (qraftTypesToImport.length) {
67
+ imports.push(
68
+ factory.createImportDeclaration(
43
69
  undefined,
44
- factory.createNamedImports(
45
- [
46
- factory.createImportSpecifier(
47
- false,
48
- undefined,
49
- factory.createIdentifier('APIBasicClientServices')
50
- ),
51
- factory.createImportSpecifier(
52
- false,
53
- undefined,
54
- factory.createIdentifier('APIBasicQueryClientServices')
55
- ),
56
- factory.createImportSpecifier(
57
- false,
58
- undefined,
59
- factory.createIdentifier('APIDefaultQueryClientServices')
60
- ),
61
- shouldImportAllCallbacks
62
- ? null
63
- : factory.createImportSpecifier(
64
- false,
65
- undefined,
66
- factory.createIdentifier('APIQueryClientServices')
67
- ),
68
- factory.createImportSpecifier(
69
- false,
70
- undefined,
71
- factory.createIdentifier('APIUtilityClientServices')
72
- ),
73
- factory.createImportSpecifier(
74
- false,
75
- undefined,
76
- factory.createIdentifier('CreateAPIBasicClientOptions')
77
- ),
78
- factory.createImportSpecifier(
79
- false,
80
- undefined,
81
- factory.createIdentifier('CreateAPIBasicQueryClientOptions')
82
- ),
83
- factory.createImportSpecifier(
84
- false,
85
- undefined,
86
- factory.createIdentifier('CreateAPIClientOptions')
87
- ),
88
- factory.createImportSpecifier(
89
- false,
90
- undefined,
91
- factory.createIdentifier('CreateAPIQueryClientOptions')
92
- ),
93
- shouldImportAllServices
94
- ? null
95
- : factory.createImportSpecifier(
96
- false,
97
- undefined,
98
- factory.createIdentifier('UnionServiceOperationsDeclaration')
99
- ),
100
- ].filter(nonNullable)
101
- )
102
- ),
103
- factory.createStringLiteral('@openapi-qraft/react'),
104
- undefined
105
- ),
106
- ];
70
+ factory.createImportClause(
71
+ true,
72
+ undefined,
73
+ factory.createNamedImports(
74
+ qraftTypesToImport.map((name) =>
75
+ factory.createImportSpecifier(
76
+ false,
77
+ undefined,
78
+ factory.createIdentifier(name)
79
+ )
80
+ )
81
+ )
82
+ ),
83
+ factory.createStringLiteral('@openapi-qraft/react'),
84
+ undefined
85
+ )
86
+ );
87
+ }
88
+
89
+ if (qraftImportTypeOverrides) {
90
+ imports.push(
91
+ ...getOverriddenImportDeclarationsFactory(
92
+ { '@openapi-qraft/react': availableQraftImportedTypes },
93
+ createAPIClientFnImportTypeOverrides
94
+ )
95
+ );
96
+ }
107
97
 
108
98
  imports.push(
109
99
  factory.createImportDeclaration(
@@ -1,11 +1,14 @@
1
+ import type { OverrideImportType } from './OverrideImportType.js';
1
2
  import { PredefinedParametersGlob } from '@openapi-qraft/plugin/lib/predefineSchemaParameters';
2
3
  import ts from 'typescript';
3
4
  import { maybeResolveImport } from '../lib/maybeResolveImport.js';
5
+ import { getOverriddenImportDeclarationsFactory } from './getOverriddenImportDeclarationsFactory.js';
4
6
 
5
7
  type Options = {
6
8
  servicesDirName: string;
7
9
  operationPredefinedParameters: Array<PredefinedParametersGlob> | undefined;
8
10
  openapiTypesImportPath: string | undefined;
11
+ importTypeOverrides: OverrideImportType[keyof OverrideImportType] | undefined;
9
12
  };
10
13
 
11
14
  export const getCreatePredefinedParametersRequestFnFactory = (
@@ -25,28 +28,53 @@ export const getCreatePredefinedParametersRequestFnFactory = (
25
28
  const getCreatePredefinedParametersRequestFnImportsFactory = ({
26
29
  servicesDirName,
27
30
  openapiTypesImportPath,
31
+ importTypeOverrides,
28
32
  }: Options) => {
29
33
  if (!openapiTypesImportPath) return [];
30
34
 
31
35
  const factory = ts.factory;
32
36
 
33
- return [
34
- factory.createImportDeclaration(
35
- undefined,
36
- factory.createImportClause(
37
- true,
38
- undefined,
39
- factory.createNamedImports([
37
+ const qraftImports = {
38
+ '@openapi-qraft/react': ['RequestFn'],
39
+ '@openapi-qraft/react/qraftPredefinedParametersRequestFn': [
40
+ 'QraftPredefinedParameterValue',
41
+ ],
42
+ };
43
+
44
+ const internalImports = Object.entries(qraftImports)
45
+ .map(([importPath, typeNames]) => {
46
+ const importSpecifiers = typeNames
47
+ .filter((typeName) => !importTypeOverrides?.[importPath]?.[typeName])
48
+ .map((typeName) =>
40
49
  factory.createImportSpecifier(
41
50
  false,
42
51
  undefined,
43
- factory.createIdentifier('RequestFn')
44
- ),
45
- ])
46
- ),
47
- factory.createStringLiteral('@openapi-qraft/react'),
48
- undefined
49
- ),
52
+ factory.createIdentifier(typeName)
53
+ )
54
+ );
55
+
56
+ if (!importSpecifiers.length) return null;
57
+
58
+ return factory.createImportDeclaration(
59
+ undefined,
60
+ factory.createImportClause(
61
+ true,
62
+ undefined,
63
+ factory.createNamedImports(importSpecifiers)
64
+ ),
65
+ factory.createStringLiteral(importPath),
66
+ undefined
67
+ );
68
+ })
69
+ .filter((importDeclaration) => !!importDeclaration);
70
+
71
+ const overrideImports = importTypeOverrides
72
+ ? getOverriddenImportDeclarationsFactory(qraftImports, importTypeOverrides)
73
+ : [];
74
+
75
+ return [
76
+ ...internalImports,
77
+ ...overrideImports,
50
78
  factory.createImportDeclaration(
51
79
  undefined,
52
80
  factory.createImportClause(
@@ -58,11 +86,6 @@ const getCreatePredefinedParametersRequestFnImportsFactory = ({
58
86
  undefined,
59
87
  factory.createIdentifier('qraftPredefinedParametersRequestFn')
60
88
  ),
61
- factory.createImportSpecifier(
62
- true,
63
- undefined,
64
- factory.createIdentifier('QraftPredefinedParameterValue')
65
- ),
66
89
  ])
67
90
  ),
68
91
  factory.createStringLiteral(
@@ -0,0 +1,53 @@
1
+ import type { ImportDeclaration } from 'typescript';
2
+ import type { OverrideImportType } from './OverrideImportType.js';
3
+ import { factory } from 'typescript';
4
+
5
+ export function getOverriddenImportDeclarationsFactory(
6
+ moduleImports: Record<string, string[]>,
7
+ serviceImportTypeOverrides: OverrideImportType[keyof OverrideImportType]
8
+ ) {
9
+ const customImportDeclarations: ImportDeclaration[] = [];
10
+
11
+ if (serviceImportTypeOverrides) {
12
+ Object.entries(moduleImports).forEach(([moduleName, importSpecifiers]) => {
13
+ if (serviceImportTypeOverrides[moduleName]) {
14
+ const importsByPath: Record<string, string[]> = {};
15
+
16
+ importSpecifiers.forEach((specifier) => {
17
+ if (serviceImportTypeOverrides[moduleName][specifier]) {
18
+ const customPath =
19
+ serviceImportTypeOverrides[moduleName][specifier];
20
+ if (!importsByPath[customPath]) {
21
+ importsByPath[customPath] = [];
22
+ }
23
+ importsByPath[customPath].push(specifier);
24
+ }
25
+ });
26
+
27
+ Object.entries(importsByPath).forEach(([customPath, specifiers]) => {
28
+ customImportDeclarations.push(
29
+ factory.createImportDeclaration(
30
+ undefined,
31
+ factory.createImportClause(
32
+ true,
33
+ undefined,
34
+ factory.createNamedImports(
35
+ specifiers.map((specifier) =>
36
+ factory.createImportSpecifier(
37
+ false,
38
+ undefined,
39
+ factory.createIdentifier(specifier)
40
+ )
41
+ )
42
+ )
43
+ ),
44
+ factory.createStringLiteral(customPath)
45
+ )
46
+ );
47
+ });
48
+ }
49
+ });
50
+ }
51
+
52
+ return customImportDeclarations;
53
+ }