@toktokhan-dev/cli-plugin-gen-api-react-query 0.1.1 → 0.1.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toktokhan-dev/cli-plugin-gen-api-react-query",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "A CLI plugin for generating API hooks with React Query built by TOKTOKHAN.DEV",
5
5
  "author": "TOKTOKHAN.DEV <fe-system@toktokhan.dev>",
6
6
  "license": "ISC",
@@ -40,7 +40,16 @@
40
40
 
41
41
  },
42
42
  interface: (contract) => {
43
- return `interface ${contract.name} {\r\n${contract.content}}`;
43
+ let content = contract.content;
44
+
45
+ const nullalbeEnums = contract.rawContent.filter((c) => !!c.enum?.length && c.isNullable )
46
+
47
+ nullalbeEnums.forEach((c) => {
48
+ const { field } = c
49
+ content = content.replace(field, `${field} | null`)
50
+ })
51
+
52
+ return `interface ${contract.name} {\r\n${content}}`;
44
53
  },
45
54
  type: (contract) => {
46
55
  return `type ${contract.name} = ${contract.content}`;
@@ -23,7 +23,7 @@ const apiInstanceName = route.moduleName + "Api";
23
23
  const queryKeyName = "QUERY_KEY_" + _.upperCase(apiClassName).replace(/ /g, '_');
24
24
 
25
25
  const hasPaginationKeyword = (queryString, keywords = paginationKeywords ) => {
26
- if (!myConfig?.includeReactInfiniteQuery) return false;
26
+ if(!includeReactQuery && !includeReactSuspenseQuery ) return false;
27
27
  const keywordUnion = keywords.map(str => `.*${str}.*`).join("|");
28
28
  const rgxSting = keywords.map(str => `(${keywordUnion})`).join("");
29
29
  const rgx = new RegExp(rgxSting);
@@ -40,7 +40,16 @@
40
40
 
41
41
  },
42
42
  interface: (contract) => {
43
- return `interface ${contract.name} {\r\n${contract.content}}`;
43
+ let content = contract.content;
44
+
45
+ const nullalbeEnums = contract.rawContent.filter((c) => !!c.enum?.length && c.isNullable )
46
+
47
+ nullalbeEnums.forEach((c) => {
48
+ const { field } = c
49
+ content = content.replace(field, `${field} | null`)
50
+ })
51
+
52
+ return `interface ${contract.name} {\r\n${content}}`;
44
53
  },
45
54
  type: (contract) => {
46
55
  return `type ${contract.name} = ${contract.content}`;