react-query-lightbase-codegen 0.1.10 → 0.2.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.
@@ -345,11 +345,12 @@ const generateRestfulComponent = ({ operation, verb, route, operationIds, parame
345
345
  }), 'in');
346
346
  const headerParams = header.filter((p) => !headerFilters?.includes(p.name));
347
347
  let enabled = [];
348
+ // TODO: extract all requestBody or remove useQuery variants
348
349
  let enabledParam = '!!props';
349
350
  [...queryParams, ...pathParams, ...headerParams].forEach((item) => {
350
351
  if (item.required) {
351
352
  enabled.push(`["${item.name}"]`);
352
- if (enabledParam) {
353
+ if (enabledParam && enabledParam !== '!!props') {
353
354
  enabledParam += `&& props['${item.name}'] != null`;
354
355
  }
355
356
  else {
@@ -967,14 +968,16 @@ const importOpenApi = async ({ data, format, apiDirectory, queryClientDir, heade
967
968
  UseMutationOptions,
968
969
  QueryKey,
969
970
  SetDataOptions,
970
- } from 'react-query';
971
- import { Updater, QueryFilters } from 'react-query/types/core/utils';
972
-
971
+ QueryFilters
972
+ } from '@tanstack/react-query';
973
+
973
974
  import queryString from 'query-string';
974
975
  import { AxiosError } from 'axios';
975
976
  import { api } from '${apiDirectory}';
976
977
  import { queryClient } from '${queryClientDir}';
977
978
 
979
+ type Updater<TInput, TOutput> = TOutput | ((input: TInput) => TOutput);
980
+
978
981
  // SCEHMAS
979
982
  ${(0, exports.generateSchemasDefinition)(specs.components?.schemas)}
980
983
 
@@ -325,11 +325,12 @@ export const generateRestfulComponent = ({ operation, verb, route, operationIds,
325
325
  }), 'in');
326
326
  const headerParams = header.filter((p) => !headerFilters?.includes(p.name));
327
327
  let enabled = [];
328
+ // TODO: extract all requestBody or remove useQuery variants
328
329
  let enabledParam = '!!props';
329
330
  [...queryParams, ...pathParams, ...headerParams].forEach((item) => {
330
331
  if (item.required) {
331
332
  enabled.push(`["${item.name}"]`);
332
- if (enabledParam) {
333
+ if (enabledParam && enabledParam !== '!!props') {
333
334
  enabledParam += `&& props['${item.name}'] != null`;
334
335
  }
335
336
  else {
@@ -946,14 +947,16 @@ export const importOpenApi = async ({ data, format, apiDirectory, queryClientDir
946
947
  UseMutationOptions,
947
948
  QueryKey,
948
949
  SetDataOptions,
949
- } from 'react-query';
950
- import { Updater, QueryFilters } from 'react-query/types/core/utils';
951
-
950
+ QueryFilters
951
+ } from '@tanstack/react-query';
952
+
952
953
  import queryString from 'query-string';
953
954
  import { AxiosError } from 'axios';
954
955
  import { api } from '${apiDirectory}';
955
956
  import { queryClient } from '${queryClientDir}';
956
957
 
958
+ type Updater<TInput, TOutput> = TOutput | ((input: TInput) => TOutput);
959
+
957
960
  // SCEHMAS
958
961
  ${generateSchemasDefinition(specs.components?.schemas)}
959
962
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-query-lightbase-codegen",
3
- "version": "0.1.10",
3
+ "version": "0.2.0",
4
4
  "license": "MIT",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",
@@ -13,6 +13,7 @@
13
13
  "test": "yarn tsc && node test/script.mjs && eslint . --ext .js,.jsx,.ts,.tsx --fix"
14
14
  },
15
15
  "dependencies": {
16
+ "@tanstack/react-query": "^4.0.9",
16
17
  "axios": "0.27.2",
17
18
  "case": "1.6.3",
18
19
  "chalk": "4.1.0",
@@ -21,7 +22,6 @@
21
22
  "openapi3-ts": "2.0.2",
22
23
  "qs": "6.10.3",
23
24
  "query-string": "7.1.1",
24
- "react-query": "3.39.0",
25
25
  "swagger2openapi": "7.0.8",
26
26
  "yamljs": "0.3.0"
27
27
  },