@openapi-qraft/tanstack-query-react-plugin 1.8.0 → 1.9.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 (47) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/generateCode.d.ts +2 -1
  3. package/dist/generateCode.d.ts.map +1 -0
  4. package/dist/generateCode.js +10 -9
  5. package/dist/generateCode.js.map +1 -1
  6. package/dist/index.d.ts +1 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/plugin.d.ts +1 -0
  9. package/dist/plugin.d.ts.map +1 -0
  10. package/dist/plugin.js +8 -6
  11. package/dist/plugin.js.map +1 -1
  12. package/dist/ts-factory/astToString.d.ts +1 -0
  13. package/dist/ts-factory/astToString.d.ts.map +1 -0
  14. package/dist/ts-factory/getClientFactory.d.ts +1 -0
  15. package/dist/ts-factory/getClientFactory.d.ts.map +1 -0
  16. package/dist/ts-factory/getIndexFactory.d.ts +12 -2
  17. package/dist/ts-factory/getIndexFactory.d.ts.map +1 -0
  18. package/dist/ts-factory/getIndexFactory.js +19 -1
  19. package/dist/ts-factory/getIndexFactory.js.map +1 -1
  20. package/dist/ts-factory/getServiceFactory.d.ts +1 -0
  21. package/dist/ts-factory/getServiceFactory.d.ts.map +1 -0
  22. package/dist/ts-factory/getServiceIndexFactory.d.ts +1 -0
  23. package/dist/ts-factory/getServiceIndexFactory.d.ts.map +1 -0
  24. package/package.json +8 -8
  25. package/src/__snapshots__/create-api-client.ts.snapshot.ts +80 -86
  26. package/src/__snapshots__/index.ts.snapshot.ts +8 -12
  27. package/src/__snapshots__/services/ApprovalPoliciesService.ts.snapshot.ts +55 -62
  28. package/src/__snapshots__/services/FilesService.ts.snapshot.ts +49 -55
  29. package/src/__snapshots__/services/index.ts.snapshot.ts +17 -23
  30. package/src/generateCode.ts +15 -12
  31. package/src/plugin.ts +13 -9
  32. package/src/ts-factory/getIndexFactory.ts +37 -1
  33. package/dist/__snapshots__/create-api-client.ts.snapshot.d.ts +0 -1
  34. package/dist/__snapshots__/create-api-client.ts.snapshot.js +0 -88
  35. package/dist/__snapshots__/create-api-client.ts.snapshot.js.map +0 -1
  36. package/dist/__snapshots__/index.ts.snapshot.d.ts +0 -1
  37. package/dist/__snapshots__/index.ts.snapshot.js +0 -13
  38. package/dist/__snapshots__/index.ts.snapshot.js.map +0 -1
  39. package/dist/__snapshots__/services/ApprovalPoliciesService.ts.snapshot.d.ts +0 -1
  40. package/dist/__snapshots__/services/ApprovalPoliciesService.ts.snapshot.js +0 -62
  41. package/dist/__snapshots__/services/ApprovalPoliciesService.ts.snapshot.js.map +0 -1
  42. package/dist/__snapshots__/services/FilesService.ts.snapshot.d.ts +0 -1
  43. package/dist/__snapshots__/services/FilesService.ts.snapshot.js +0 -57
  44. package/dist/__snapshots__/services/FilesService.ts.snapshot.js.map +0 -1
  45. package/dist/__snapshots__/services/index.ts.snapshot.d.ts +0 -1
  46. package/dist/__snapshots__/services/index.ts.snapshot.js +0 -24
  47. package/dist/__snapshots__/services/index.ts.snapshot.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @openapi-qraft/tanstack-query-react-plugin
2
2
 
3
+ ## 1.9.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [943a9d3]
8
+ - Updated dependencies [3a75364]
9
+ - @openapi-qraft/plugin@1.9.0
10
+
3
11
  ## 1.8.0
4
12
 
5
13
  ### Minor Changes
@@ -7,6 +7,7 @@ interface OutputOptions extends OutputOptionsBase {
7
7
  fileHeader: string | undefined;
8
8
  servicesDirName: string;
9
9
  explicitImportExtensions: boolean;
10
+ exportSchemaTypes: boolean | undefined;
10
11
  }
11
12
  export declare const generateCode: ({ spinner, services, serviceImports, output, }: {
12
13
  spinner: Ora;
@@ -14,5 +15,5 @@ export declare const generateCode: ({ spinner, services, serviceImports, output,
14
15
  serviceImports: ServiceImportsFactoryOptions;
15
16
  output: OutputOptions;
16
17
  }) => Promise<GeneratorFile[]>;
17
- export declare const getFileHeader: ({ fileHeader, }: Pick<OutputOptions, 'fileHeader'>) => string | undefined;
18
18
  export {};
19
+ //# sourceMappingURL=generateCode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateCode.d.ts","sourceRoot":"","sources":["../src/generateCode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,gDAAgD,CAAC;AACzE,OAAO,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAI7F,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAK1B,OAAO,EAEL,4BAA4B,EAC7B,MAAM,mCAAmC,CAAC;AAG3C,UAAU,aAAc,SAAQ,iBAAiB;IAC/C,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,eAAe,EAAE,MAAM,CAAC;IACxB,wBAAwB,EAAE,OAAO,CAAC;IAClC,iBAAiB,EAAE,OAAO,GAAG,SAAS,CAAC;CACxC;AAED,eAAO,MAAM,YAAY;aAMd,GAAG;cACF,OAAO,EAAE;oBACH,4BAA4B;YACpC,aAAa;8BAQtB,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { formatFileHeader } from '@openapi-qraft/plugin/lib/formatFileHeader';
1
2
  import c from 'ansi-colors';
2
3
  import { URL } from 'node:url';
3
4
  import { astToString } from './ts-factory/astToString.js';
@@ -10,7 +11,7 @@ export const generateCode = async ({ spinner, services, serviceImports, output,
10
11
  ...(await generateServices(spinner, services, serviceImports, output)),
11
12
  ...(await generateServiceIndex(spinner, services, output)),
12
13
  ...(await generateClient(spinner, output)),
13
- ...(await generateIndex(spinner, output)),
14
+ ...(await generateIndex(spinner, serviceImports, output)),
14
15
  ];
15
16
  };
16
17
  const composeServicesDirPath = (output) => {
@@ -35,7 +36,7 @@ const generateServices = async (spinner, services, serviceImports, output) => {
35
36
  }, operations, serviceImports));
36
37
  serviceFiles.push({
37
38
  file: new URL(`${fileBaseName}.ts`, servicesDir),
38
- code: getFileHeader(output) + code,
39
+ code: formatFileHeader(output.fileHeader) + code,
39
40
  });
40
41
  }
41
42
  catch (error) {
@@ -60,7 +61,7 @@ const generateServiceIndex = async (spinner, services, output) => {
60
61
  }));
61
62
  serviceIndexFiles.push({
62
63
  file: new URL('index.ts', composeServicesDirPath(output)),
63
- code: getFileHeader(output) + code,
64
+ code: formatFileHeader(output.fileHeader) + code,
64
65
  });
65
66
  }
66
67
  catch (error) {
@@ -80,7 +81,7 @@ const generateClient = async (spinner, output) => {
80
81
  }));
81
82
  clientFiles.push({
82
83
  file: new URL('create-api-client.ts', output.dir),
83
- code: getFileHeader(output) + code,
84
+ code: formatFileHeader(output.fileHeader) + code,
84
85
  });
85
86
  }
86
87
  catch (error) {
@@ -90,17 +91,20 @@ const generateClient = async (spinner, output) => {
90
91
  spinner.succeed(c.green('Client has been generated'));
91
92
  return clientFiles;
92
93
  };
93
- const generateIndex = async (spinner, output) => {
94
+ const generateIndex = async (spinner, serviceImports, output) => {
94
95
  spinner.start('Generating index');
95
96
  const indexFiles = [];
96
97
  try {
97
98
  const code = astToString(getIndexFactory({
98
99
  servicesDirName: output.servicesDirName,
99
100
  explicitImportExtensions: Boolean(output.explicitImportExtensions),
101
+ openapiTypesImportPath: output.exportSchemaTypes
102
+ ? serviceImports.openapiTypesImportPath
103
+ : undefined,
100
104
  }));
101
105
  indexFiles.push({
102
106
  file: new URL('index.ts', output.dir),
103
- code: getFileHeader(output) + code,
107
+ code: formatFileHeader(output.fileHeader) + code,
104
108
  });
105
109
  }
106
110
  catch (error) {
@@ -110,7 +114,4 @@ const generateIndex = async (spinner, output) => {
110
114
  spinner.succeed(c.green('Index has been generated'));
111
115
  return indexFiles;
112
116
  };
113
- export const getFileHeader = ({ fileHeader, }) => {
114
- return fileHeader && `${fileHeader}\n`;
115
- };
116
117
  //# sourceMappingURL=generateCode.js.map
@@ -1 +1 @@
1
-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ugin } from './plugin.js';
2
2
  export default plugin;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,eAAe,MAAM,CAAC"}
package/dist/plugin.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  import { QraftCommandPlugin } from '@openapi-qraft/plugin/lib/QraftCommandPlugin';
2
2
  export declare const plugin: QraftCommandPlugin;
3
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAC;AAIlF,eAAO,MAAM,MAAM,EAAE,kBA0CpB,CAAC"}
package/dist/plugin.js CHANGED
@@ -4,13 +4,14 @@ export const plugin = {
4
4
  setupCommand(command) {
5
5
  command
6
6
  .description('Generate TanStack Query React client from OpenAPI Schema')
7
- .requiredOption('--openapi-types-import-path <path>', // todo::specify better param name to avoid confusion with real path
8
- 'Path to schema types file (.d.ts), eg: "../openapi.d.ts"')
9
- .option('--file-header <string>', 'Header to be added to the generated file (eg: /* eslint-disable */)')
7
+ .requiredOption('--openapi-types-import-path <path>', 'Path to schema types file (.d.ts), eg: "../schema.d.ts"')
10
8
  .option('--explicit-import-extensions', 'All import statements will include explicit `.js` extensions. Ideal for projects using ECMAScript modules.')
9
+ .option('--export-openapi-types [bool]', 'Export the OpenAPI schema types from the generated `./index.ts` file', (arg) => {
10
+ return arg?.toLowerCase() !== 'false';
11
+ })
11
12
  .option('--operation-generics-import-path <path>', 'Path to operation generics file', '@openapi-qraft/react')
12
- .action(({ spinner, output, args, services }, resolve) => {
13
- return void generateCode({
13
+ .action(async ({ spinner, output, args, services }, resolve) => {
14
+ return void (await generateCode({
14
15
  spinner,
15
16
  services,
16
17
  serviceImports: {
@@ -22,8 +23,9 @@ export const plugin = {
22
23
  fileHeader: args.fileHeader ?? fileHeader,
23
24
  explicitImportExtensions: args.explicitImportExtensions,
24
25
  servicesDirName: 'services',
26
+ exportSchemaTypes: args.exportOpenapiTypes,
25
27
  },
26
- }).then(resolve);
28
+ }).then(resolve));
27
29
  });
28
30
  },
29
31
  };
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AAIlE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,CAAC,MAAM,MAAM,GAAuB;IACxC,YAAY,CAAC,OAAqB;QAChC,OAAO;aACJ,WAAW,CAAC,0DAA0D,CAAC;aACvE,cAAc,CACb,oCAAoC,EAAE,oEAAoE;QAC1G,0DAA0D,CAC3D;aACA,MAAM,CACL,wBAAwB,EACxB,qEAAqE,CACtE;aACA,MAAM,CACL,8BAA8B,EAC9B,4GAA4G,CAC7G;aACA,MAAM,CACL,yCAAyC,EACzC,iCAAiC,EACjC,sBAAsB,CACvB;aACA,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,EAAE;YACvD,OAAO,KAAK,YAAY,CAAC;gBACvB,OAAO;gBACP,QAAQ;gBACR,cAAc,EAAE;oBACd,2BAA2B,EAAE,IAAI,CAAC,2BAA2B;oBAC7D,sBAAsB,EAAE,IAAI,CAAC,sBAAsB;iBACpD;gBACD,MAAM,EAAE;oBACN,GAAG,MAAM;oBACT,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,UAAU;oBACzC,wBAAwB,EAAE,IAAI,CAAC,wBAAwB;oBACvD,eAAe,EAAE,UAAU;iBAC5B;aACF,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnB,CAAC,CAAC,CAAC;IACP,CAAC;CACF,CAAC"}
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AAIlE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,CAAC,MAAM,MAAM,GAAuB;IACxC,YAAY,CAAC,OAAqB;QAChC,OAAO;aACJ,WAAW,CAAC,0DAA0D,CAAC;aACvE,cAAc,CACb,oCAAoC,EACpC,yDAAyD,CAC1D;aACA,MAAM,CACL,8BAA8B,EAC9B,4GAA4G,CAC7G;aACA,MAAM,CACL,+BAA+B,EAC/B,sEAAsE,EACtE,CAAC,GAAG,EAAE,EAAE;YACN,OAAO,GAAG,EAAE,WAAW,EAAE,KAAK,OAAO,CAAC;QACxC,CAAC,CACF;aACA,MAAM,CACL,yCAAyC,EACzC,iCAAiC,EACjC,sBAAsB,CACvB;aACA,MAAM,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,EAAE;YAC7D,OAAO,KAAK,CAAC,MAAM,YAAY,CAAC;gBAC9B,OAAO;gBACP,QAAQ;gBACR,cAAc,EAAE;oBACd,2BAA2B,EAAE,IAAI,CAAC,2BAA2B;oBAC7D,sBAAsB,EAAE,IAAI,CAAC,sBAAsB;iBACpD;gBACD,MAAM,EAAE;oBACN,GAAG,MAAM;oBACT,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,UAAU;oBACzC,wBAAwB,EAAE,IAAI,CAAC,wBAAwB;oBACvD,eAAe,EAAE,UAAU;oBAC3B,iBAAiB,EAAE,IAAI,CAAC,kBAAkB;iBAC3C;aACF,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;IACP,CAAC;CACF,CAAC"}
@@ -6,3 +6,4 @@ export interface AstToStringOptions {
6
6
  }
7
7
  /** Convert TypeScript AST to string */
8
8
  export declare function astToString(ast: ts.Node | ts.Node[] | ts.TypeElement | ts.TypeElement[], options?: AstToStringOptions): string;
9
+ //# sourceMappingURL=astToString.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"astToString.d.ts","sourceRoot":"","sources":["../../src/ts-factory/astToString.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC;CACnC;AAED,uCAAuC;AACvC,wBAAgB,WAAW,CACzB,GAAG,EAAE,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,WAAW,GAAG,EAAE,CAAC,WAAW,EAAE,EAC5D,OAAO,CAAC,EAAE,kBAAkB,GAC3B,MAAM,CAqBR"}
@@ -5,3 +5,4 @@ type Options = {
5
5
  };
6
6
  export declare const getClientFactory: (options: Options) => (ts.ImportDeclaration | ts.VariableStatement | ts.FunctionDeclaration)[];
7
7
  export {};
8
+ //# sourceMappingURL=getClientFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getClientFactory.d.ts","sourceRoot":"","sources":["../../src/ts-factory/getClientFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,KAAK,OAAO,GAAG;IACb,eAAe,EAAE,MAAM,CAAC;IACxB,wBAAwB,EAAE,OAAO,CAAC;CACnC,CAAC;AAEF,eAAO,MAAM,gBAAgB,YAAa,OAAO,6EAMhD,CAAC"}
@@ -1,5 +1,15 @@
1
1
  import ts from 'typescript';
2
- export declare const getIndexFactory: ({ servicesDirName, explicitImportExtensions, }: {
2
+ import type { ServiceImportsFactoryOptions } from './getServiceFactory.js';
3
+ export declare const getIndexFactory: ({ openapiTypesImportPath, servicesDirName, explicitImportExtensions, }: {
3
4
  servicesDirName: string;
4
5
  explicitImportExtensions: boolean;
5
- }) => ts.ExportDeclaration[];
6
+ } & Partial<Pick<ServiceImportsFactoryOptions, "openapiTypesImportPath">>) => ts.ExportDeclaration[];
7
+ /**
8
+ * Resolve the import path if it's a relative path.
9
+ * Normally,`openapiTypesImportPath` is a relative path to services directory.
10
+ */
11
+ export declare function maybeResolveImport<T extends string | undefined>({ openapiTypesImportPath, servicesDirName, }: {
12
+ openapiTypesImportPath: T;
13
+ servicesDirName: string;
14
+ }): string | T;
15
+ //# sourceMappingURL=getIndexFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getIndexFactory.d.ts","sourceRoot":"","sources":["../../src/ts-factory/getIndexFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AAE3E,eAAO,MAAM,eAAe;qBAKT,MAAM;8BACG,OAAO;oGA+DlC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,MAAM,GAAG,SAAS,EAAE,EAC/D,sBAAsB,EACtB,eAAe,GAChB,EAAE;IACD,sBAAsB,EAAE,CAAC,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;CACzB,cAQA"}
@@ -1,8 +1,13 @@
1
1
  import ts from 'typescript';
2
- export const getIndexFactory = ({ servicesDirName, explicitImportExtensions, }) => {
2
+ export const getIndexFactory = ({ openapiTypesImportPath, servicesDirName, explicitImportExtensions, }) => {
3
3
  const factory = ts.factory;
4
4
  const importExtension = explicitImportExtensions ? '.js' : '';
5
5
  return [
6
+ ...(openapiTypesImportPath
7
+ ? [
8
+ factory.createExportDeclaration(undefined, true, undefined, factory.createStringLiteral(maybeResolveImport({ openapiTypesImportPath, servicesDirName })), undefined),
9
+ ]
10
+ : []),
6
11
  factory.createExportDeclaration(undefined, false, factory.createNamedExports([
7
12
  factory.createExportSpecifier(false, undefined, factory.createIdentifier('services')),
8
13
  ]), factory.createStringLiteral(`./${servicesDirName}/index${importExtension}`), undefined),
@@ -14,4 +19,17 @@ export const getIndexFactory = ({ servicesDirName, explicitImportExtensions, })
14
19
  ]), factory.createStringLiteral(`./create-api-client${importExtension}`), undefined),
15
20
  ];
16
21
  };
22
+ /**
23
+ * Resolve the import path if it's a relative path.
24
+ * Normally,`openapiTypesImportPath` is a relative path to services directory.
25
+ */
26
+ export function maybeResolveImport({ openapiTypesImportPath, servicesDirName, }) {
27
+ if (openapiTypesImportPath?.startsWith('../')) {
28
+ return `./${openapiTypesImportPath.slice(3)}`;
29
+ }
30
+ else if (openapiTypesImportPath?.startsWith('./')) {
31
+ return `./${servicesDirName}/${openapiTypesImportPath.slice(2)}`;
32
+ }
33
+ return openapiTypesImportPath;
34
+ }
17
35
  //# sourceMappingURL=getIndexFactory.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getIndexFactory.js","sourceRoot":"","sources":["../../src/ts-factory/getIndexFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAC9B,eAAe,EACf,wBAAwB,GAIzB,EAAE,EAAE;IACH,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC;IAC3B,MAAM,eAAe,GAAG,wBAAwB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IAE9D,OAAO;QACL,OAAO,CAAC,uBAAuB,CAC7B,SAAS,EACT,KAAK,EACL,OAAO,CAAC,kBAAkB,CAAC;YACzB,OAAO,CAAC,qBAAqB,CAC3B,KAAK,EACL,SAAS,EACT,OAAO,CAAC,gBAAgB,CAAC,UAAU,CAAC,CACrC;SACF,CAAC,EACF,OAAO,CAAC,mBAAmB,CACzB,KAAK,eAAe,SAAS,eAAe,EAAE,CAC/C,EACD,SAAS,CACV;QACD,OAAO,CAAC,uBAAuB,CAC7B,SAAS,EACT,IAAI,EACJ,OAAO,CAAC,kBAAkB,CAAC;YACzB,OAAO,CAAC,qBAAqB,CAC3B,KAAK,EACL,SAAS,EACT,OAAO,CAAC,gBAAgB,CAAC,UAAU,CAAC,CACrC;SACF,CAAC,EACF,OAAO,CAAC,mBAAmB,CACzB,KAAK,eAAe,SAAS,eAAe,EAAE,CAC/C,EACD,SAAS,CACV;QACD,OAAO,CAAC,uBAAuB,CAC7B,SAAS,EACT,KAAK,EACL,OAAO,CAAC,kBAAkB,CAAC;YACzB,OAAO,CAAC,qBAAqB,CAC3B,KAAK,EACL,SAAS,EACT,OAAO,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,CAC5C;SACF,CAAC,EACF,OAAO,CAAC,mBAAmB,CAAC,sBAAsB,eAAe,EAAE,CAAC,EACpE,SAAS,CACV;KACF,CAAC;AACJ,CAAC,CAAC"}
1
+ {"version":3,"file":"getIndexFactory.js","sourceRoot":"","sources":["../../src/ts-factory/getIndexFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAI5B,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAC9B,sBAAsB,EACtB,eAAe,EACf,wBAAwB,GAI+C,EAAE,EAAE;IAC3E,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC;IAC3B,MAAM,eAAe,GAAG,wBAAwB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IAE9D,OAAO;QACL,GAAG,CAAC,sBAAsB;YACxB,CAAC,CAAC;gBACE,OAAO,CAAC,uBAAuB,CAC7B,SAAS,EACT,IAAI,EACJ,SAAS,EACT,OAAO,CAAC,mBAAmB,CACzB,kBAAkB,CAAC,EAAE,sBAAsB,EAAE,eAAe,EAAE,CAAC,CAChE,EACD,SAAS,CACV;aACF;YACH,CAAC,CAAC,EAAE,CAAC;QACP,OAAO,CAAC,uBAAuB,CAC7B,SAAS,EACT,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8,3 +8,4 @@ export declare const getServiceFactory: (service: {
8
8
  typeName: string;
9
9
  variableName: string;
10
10
  }, operations: ServiceOperation[], { openapiTypesImportPath, operationGenericsImportPath, }: ServiceImportsFactoryOptions) => (ts.ImportDeclaration | ts.VariableStatement | ts.InterfaceDeclaration)[];
11
+ //# sourceMappingURL=getServiceFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getServiceFactory.d.ts","sourceRoot":"","sources":["../../src/ts-factory/getServiceFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAC;AAElF,OAAO,EAAE,MAAM,YAAY,CAAC;AAO5B,MAAM,MAAM,4BAA4B,GAAG;IACzC,sBAAsB,EAAE,MAAM,CAAC;IAC/B,2BAA2B,EAAE,MAAM,CAAC;CACrC,CAAC;AAEF,eAAO,MAAM,iBAAiB,YACnB;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,cACvC,gBAAgB,EAAE,4DAI3B,4BAA4B,8EAWhC,CAAC"}
@@ -5,3 +5,4 @@ type Options = {
5
5
  };
6
6
  export declare const getServiceIndexFactory: (services: Service[], options: Options) => (ts.ImportDeclaration | ts.VariableStatement | ts.TypeAliasDeclaration)[];
7
7
  export {};
8
+ //# sourceMappingURL=getServiceIndexFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getServiceIndexFactory.d.ts","sourceRoot":"","sources":["../../src/ts-factory/getServiceIndexFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gDAAgD,CAAC;AAEzE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,KAAK,OAAO,GAAG;IAAE,wBAAwB,EAAE,OAAO,CAAA;CAAE,CAAC;AAErD,eAAO,MAAM,sBAAsB,aACvB,OAAO,EAAE,WACV,OAAO,8EAOjB,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "name": "@openapi-qraft/tanstack-query-react-plugin",
3
- "version": "1.8.0",
4
- "packageManager": "yarn@4.0.2",
3
+ "version": "1.9.0",
5
4
  "type": "module",
6
5
  "scripts": {
7
6
  "build": "rimraf dist/ && tsc --project tsconfig.build.json",
@@ -10,6 +9,9 @@
10
9
  "typecheck": "tsc --noEmit",
11
10
  "lint": "eslint"
12
11
  },
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
13
15
  "exports": {
14
16
  "./package.json": "./package.json",
15
17
  ".": "./dist/index.js",
@@ -23,14 +25,14 @@
23
25
  }
24
26
  },
25
27
  "dependencies": {
26
- "@openapi-qraft/plugin": "^1.8.0",
28
+ "@openapi-qraft/plugin": "^1.9.0",
27
29
  "typescript": "^5.3.3"
28
30
  },
29
31
  "devDependencies": {
30
32
  "@openapi-qraft/eslint-config": "~1.0.0",
31
- "@types/mock-fs": "^4.13.4",
33
+ "@openapi-qraft/test-fixtures": "~1.0.0",
32
34
  "eslint": "^9.0.0",
33
- "mock-fs": "^5.2.0",
35
+ "memfs": "^4.9.2",
34
36
  "rimraf": "^5.0.5",
35
37
  "vitest": "^1.4.0"
36
38
  },
@@ -42,7 +44,5 @@
42
44
  "!src/**/*.test.*",
43
45
  "!src/**/*.spec.*"
44
46
  ],
45
- "publishConfig": {
46
- "access": "public"
47
- }
47
+ "packageManager": "yarn@4.0.2"
48
48
  }
@@ -1,88 +1,82 @@
1
- import fs from 'node:fs';
2
- import { expect } from 'vitest';
1
+ /**
2
+ * This file was auto-generated by @openapi-qraft/cli.
3
+ * Do not make direct changes to the file.
4
+ */
3
5
 
4
- export default function () {
5
- expect(fs.readFileSync('/mock-fs/create-api-client.ts', 'utf-8'))
6
- .toMatchInlineSnapshot(`
7
- "/* generated using @openapi-qraft/cli -- do no edit */
8
- /* istanbul ignore file */
9
- import { qraftAPIClient, QraftClientOptions } from "@openapi-qraft/react";
10
- import { getInfiniteQueryData } from "@openapi-qraft/react/callbacks/getInfiniteQueryData";
11
- import { getInfiniteQueryKey } from "@openapi-qraft/react/callbacks/getInfiniteQueryKey";
12
- import { getMutationKey } from "@openapi-qraft/react/callbacks/getMutationKey";
13
- import { getQueryData } from "@openapi-qraft/react/callbacks/getQueryData";
14
- import { getQueriesData } from "@openapi-qraft/react/callbacks/getQueriesData";
15
- import { getQueryKey } from "@openapi-qraft/react/callbacks/getQueryKey";
16
- import { mutationFn } from "@openapi-qraft/react/callbacks/mutationFn";
17
- import { queryFn } from "@openapi-qraft/react/callbacks/queryFn";
18
- import { setInfiniteQueryData } from "@openapi-qraft/react/callbacks/setInfiniteQueryData";
19
- import { setQueryData } from "@openapi-qraft/react/callbacks/setQueryData";
20
- import { setQueriesData } from "@openapi-qraft/react/callbacks/setQueriesData";
21
- import { useInfiniteQuery } from "@openapi-qraft/react/callbacks/useInfiniteQuery";
22
- import { useMutation } from "@openapi-qraft/react/callbacks/useMutation";
23
- import { useQuery } from "@openapi-qraft/react/callbacks/useQuery";
24
- import { useSuspenseQuery } from "@openapi-qraft/react/callbacks/useSuspenseQuery";
25
- import { useSuspenseInfiniteQuery } from "@openapi-qraft/react/callbacks/useSuspenseInfiniteQuery";
26
- import { useMutationState } from "@openapi-qraft/react/callbacks/useMutationState";
27
- import { useIsMutating } from "@openapi-qraft/react/callbacks/useIsMutating";
28
- import { useQueries } from "@openapi-qraft/react/callbacks/useQueries";
29
- import { useSuspenseQueries } from "@openapi-qraft/react/callbacks/useSuspenseQueries";
30
- import { invalidateQueries } from "@openapi-qraft/react/callbacks/invalidateQueries";
31
- import { cancelQueries } from "@openapi-qraft/react/callbacks/cancelQueries";
32
- import { resetQueries } from "@openapi-qraft/react/callbacks/resetQueries";
33
- import { removeQueries } from "@openapi-qraft/react/callbacks/removeQueries";
34
- import { refetchQueries } from "@openapi-qraft/react/callbacks/refetchQueries";
35
- import { isFetching } from "@openapi-qraft/react/callbacks/isFetching";
36
- import { isMutating } from "@openapi-qraft/react/callbacks/isMutating";
37
- import { useIsFetching } from "@openapi-qraft/react/callbacks/useIsFetching";
38
- import { fetchQuery } from "@openapi-qraft/react/callbacks/fetchQuery";
39
- import { prefetchQuery } from "@openapi-qraft/react/callbacks/prefetchQuery";
40
- import { fetchInfiniteQuery } from "@openapi-qraft/react/callbacks/fetchInfiniteQuery";
41
- import { prefetchInfiniteQuery } from "@openapi-qraft/react/callbacks/prefetchInfiniteQuery";
42
- import { getQueryState } from "@openapi-qraft/react/callbacks/getQueryState";
43
- import { getInfiniteQueryState } from "@openapi-qraft/react/callbacks/getInfiniteQueryState";
44
- import { operationInvokeFn } from "@openapi-qraft/react/callbacks/operationInvokeFn";
45
- import { services, Services } from "./services/index.js";
46
- const callbacks = {
47
- getInfiniteQueryData,
48
- getInfiniteQueryKey,
49
- getMutationKey,
50
- getQueryData,
51
- getQueriesData,
52
- getQueryKey,
53
- mutationFn,
54
- queryFn,
55
- setInfiniteQueryData,
56
- setQueryData,
57
- setQueriesData,
58
- useInfiniteQuery,
59
- useMutation,
60
- useQuery,
61
- useSuspenseQuery,
62
- useSuspenseInfiniteQuery,
63
- useMutationState,
64
- useIsMutating,
65
- useQueries,
66
- useSuspenseQueries,
67
- invalidateQueries,
68
- cancelQueries,
69
- resetQueries,
70
- removeQueries,
71
- refetchQueries,
72
- isFetching,
73
- isMutating,
74
- useIsFetching,
75
- fetchQuery,
76
- prefetchQuery,
77
- fetchInfiniteQuery,
78
- prefetchInfiniteQuery,
79
- getQueryState,
80
- getInfiniteQueryState,
81
- operationInvokeFn
82
- };
83
- export function createAPIClient(options?: QraftClientOptions): Services {
84
- return qraftAPIClient<Services, typeof callbacks>(services, callbacks, options);
85
- }
86
- "
87
- `);
6
+ import { qraftAPIClient, QraftClientOptions } from "@openapi-qraft/react";
7
+ import { getInfiniteQueryData } from "@openapi-qraft/react/callbacks/getInfiniteQueryData";
8
+ import { getInfiniteQueryKey } from "@openapi-qraft/react/callbacks/getInfiniteQueryKey";
9
+ import { getMutationKey } from "@openapi-qraft/react/callbacks/getMutationKey";
10
+ import { getQueryData } from "@openapi-qraft/react/callbacks/getQueryData";
11
+ import { getQueriesData } from "@openapi-qraft/react/callbacks/getQueriesData";
12
+ import { getQueryKey } from "@openapi-qraft/react/callbacks/getQueryKey";
13
+ import { mutationFn } from "@openapi-qraft/react/callbacks/mutationFn";
14
+ import { queryFn } from "@openapi-qraft/react/callbacks/queryFn";
15
+ import { setInfiniteQueryData } from "@openapi-qraft/react/callbacks/setInfiniteQueryData";
16
+ import { setQueryData } from "@openapi-qraft/react/callbacks/setQueryData";
17
+ import { setQueriesData } from "@openapi-qraft/react/callbacks/setQueriesData";
18
+ import { useInfiniteQuery } from "@openapi-qraft/react/callbacks/useInfiniteQuery";
19
+ import { useMutation } from "@openapi-qraft/react/callbacks/useMutation";
20
+ import { useQuery } from "@openapi-qraft/react/callbacks/useQuery";
21
+ import { useSuspenseQuery } from "@openapi-qraft/react/callbacks/useSuspenseQuery";
22
+ import { useSuspenseInfiniteQuery } from "@openapi-qraft/react/callbacks/useSuspenseInfiniteQuery";
23
+ import { useMutationState } from "@openapi-qraft/react/callbacks/useMutationState";
24
+ import { useIsMutating } from "@openapi-qraft/react/callbacks/useIsMutating";
25
+ import { useQueries } from "@openapi-qraft/react/callbacks/useQueries";
26
+ import { useSuspenseQueries } from "@openapi-qraft/react/callbacks/useSuspenseQueries";
27
+ import { invalidateQueries } from "@openapi-qraft/react/callbacks/invalidateQueries";
28
+ import { cancelQueries } from "@openapi-qraft/react/callbacks/cancelQueries";
29
+ import { resetQueries } from "@openapi-qraft/react/callbacks/resetQueries";
30
+ import { removeQueries } from "@openapi-qraft/react/callbacks/removeQueries";
31
+ import { refetchQueries } from "@openapi-qraft/react/callbacks/refetchQueries";
32
+ import { isFetching } from "@openapi-qraft/react/callbacks/isFetching";
33
+ import { isMutating } from "@openapi-qraft/react/callbacks/isMutating";
34
+ import { useIsFetching } from "@openapi-qraft/react/callbacks/useIsFetching";
35
+ import { fetchQuery } from "@openapi-qraft/react/callbacks/fetchQuery";
36
+ import { prefetchQuery } from "@openapi-qraft/react/callbacks/prefetchQuery";
37
+ import { fetchInfiniteQuery } from "@openapi-qraft/react/callbacks/fetchInfiniteQuery";
38
+ import { prefetchInfiniteQuery } from "@openapi-qraft/react/callbacks/prefetchInfiniteQuery";
39
+ import { getQueryState } from "@openapi-qraft/react/callbacks/getQueryState";
40
+ import { getInfiniteQueryState } from "@openapi-qraft/react/callbacks/getInfiniteQueryState";
41
+ import { operationInvokeFn } from "@openapi-qraft/react/callbacks/operationInvokeFn";
42
+ import { services, Services } from "./services/index.js";
43
+ const callbacks = {
44
+ getInfiniteQueryData,
45
+ getInfiniteQueryKey,
46
+ getMutationKey,
47
+ getQueryData,
48
+ getQueriesData,
49
+ getQueryKey,
50
+ mutationFn,
51
+ queryFn,
52
+ setInfiniteQueryData,
53
+ setQueryData,
54
+ setQueriesData,
55
+ useInfiniteQuery,
56
+ useMutation,
57
+ useQuery,
58
+ useSuspenseQuery,
59
+ useSuspenseInfiniteQuery,
60
+ useMutationState,
61
+ useIsMutating,
62
+ useQueries,
63
+ useSuspenseQueries,
64
+ invalidateQueries,
65
+ cancelQueries,
66
+ resetQueries,
67
+ removeQueries,
68
+ refetchQueries,
69
+ isFetching,
70
+ isMutating,
71
+ useIsFetching,
72
+ fetchQuery,
73
+ prefetchQuery,
74
+ fetchInfiniteQuery,
75
+ prefetchInfiniteQuery,
76
+ getQueryState,
77
+ getInfiniteQueryState,
78
+ operationInvokeFn
79
+ };
80
+ export function createAPIClient(options?: QraftClientOptions): Services {
81
+ return qraftAPIClient<Services, typeof callbacks>(services, callbacks, options);
88
82
  }
@@ -1,13 +1,9 @@
1
- import fs from 'node:fs';
2
- import { expect } from 'vitest';
1
+ /**
2
+ * This file was auto-generated by @openapi-qraft/cli.
3
+ * Do not make direct changes to the file.
4
+ */
3
5
 
4
- export default function () {
5
- expect(fs.readFileSync('/mock-fs/index.ts', 'utf-8')).toMatchInlineSnapshot(`
6
- "/* generated using @openapi-qraft/cli -- do no edit */
7
- /* istanbul ignore file */
8
- export { services } from "./services/index.js";
9
- export type { Services } from "./services/index.js";
10
- export { createAPIClient } from "./create-api-client.js";
11
- "
12
- `);
13
- }
6
+ export type * from "./../openapi.js";
7
+ export { services } from "./services/index.js";
8
+ export type { Services } from "./services/index.js";
9
+ export { createAPIClient } from "./create-api-client.js";