mobx-tanstack-query-api 0.25.0 → 0.26.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 (269) hide show
  1. package/bin.cjs +53 -0
  2. package/bin.cjs.map +1 -0
  3. package/bin.d.ts +1 -0
  4. package/bin.js +51 -0
  5. package/bin.js.map +1 -0
  6. package/builtin.cjs +27 -0
  7. package/builtin.cjs.map +1 -0
  8. package/builtin.d.ts +6 -0
  9. package/builtin.js +27 -0
  10. package/builtin.js.map +1 -0
  11. package/cli.cjs +1278 -0
  12. package/cli.cjs.map +1 -0
  13. package/{codegen/types/generate-query-api-params.d.cts → cli.d.ts} +54 -10
  14. package/cli.js +1277 -0
  15. package/cli.js.map +1 -0
  16. package/index.cjs +771 -16
  17. package/index.cjs.map +1 -0
  18. package/index.d.ts +322 -2
  19. package/index.js +768 -2
  20. package/index.js.map +1 -0
  21. package/package.json +25 -62
  22. package/builtin/index.cjs +0 -25
  23. package/builtin/index.d.cts +0 -4
  24. package/builtin/index.d.cts.map +0 -1
  25. package/builtin/index.d.ts +0 -4
  26. package/builtin/index.d.ts.map +0 -1
  27. package/builtin/index.js +0 -22
  28. package/cli/bin.cjs +0 -17
  29. package/cli/bin.d.cts +0 -2
  30. package/cli/bin.d.cts.map +0 -1
  31. package/cli/bin.d.ts +0 -2
  32. package/cli/bin.d.ts.map +0 -1
  33. package/cli/bin.js +0 -15
  34. package/cli/index.cjs +0 -18
  35. package/cli/index.d.cts +0 -3
  36. package/cli/index.d.cts.map +0 -1
  37. package/cli/index.d.ts +0 -3
  38. package/cli/index.d.ts.map +0 -1
  39. package/cli/index.js +0 -2
  40. package/cli/utils/define-config.cjs +0 -9
  41. package/cli/utils/define-config.d.cts +0 -4
  42. package/cli/utils/define-config.d.cts.map +0 -1
  43. package/cli/utils/define-config.d.ts +0 -4
  44. package/cli/utils/define-config.d.ts.map +0 -1
  45. package/cli/utils/define-config.js +0 -5
  46. package/cli/utils/exec-config-path.cjs +0 -16
  47. package/cli/utils/exec-config-path.d.cts +0 -2
  48. package/cli/utils/exec-config-path.d.cts.map +0 -1
  49. package/cli/utils/exec-config-path.d.ts +0 -2
  50. package/cli/utils/exec-config-path.d.ts.map +0 -1
  51. package/cli/utils/exec-config-path.js +0 -12
  52. package/cli/utils/resolve-config-path.cjs +0 -65
  53. package/cli/utils/resolve-config-path.d.cts +0 -3
  54. package/cli/utils/resolve-config-path.d.cts.map +0 -1
  55. package/cli/utils/resolve-config-path.d.ts +0 -3
  56. package/cli/utils/resolve-config-path.d.ts.map +0 -1
  57. package/cli/utils/resolve-config-path.js +0 -25
  58. package/codegen/index.cjs +0 -545
  59. package/codegen/index.d.cts +0 -4
  60. package/codegen/index.d.cts.map +0 -1
  61. package/codegen/index.d.ts +0 -4
  62. package/codegen/index.d.ts.map +0 -1
  63. package/codegen/index.js +0 -524
  64. package/codegen/templates/all-endpoints-per-file.tmpl.cjs +0 -94
  65. package/codegen/templates/all-endpoints-per-file.tmpl.d.cts +0 -14
  66. package/codegen/templates/all-endpoints-per-file.tmpl.d.cts.map +0 -1
  67. package/codegen/templates/all-endpoints-per-file.tmpl.d.ts +0 -14
  68. package/codegen/templates/all-endpoints-per-file.tmpl.d.ts.map +0 -1
  69. package/codegen/templates/all-endpoints-per-file.tmpl.js +0 -90
  70. package/codegen/templates/all-exports.tmpl.cjs +0 -14
  71. package/codegen/templates/all-exports.tmpl.d.cts +0 -9
  72. package/codegen/templates/all-exports.tmpl.d.cts.map +0 -1
  73. package/codegen/templates/all-exports.tmpl.d.ts +0 -9
  74. package/codegen/templates/all-exports.tmpl.d.ts.map +0 -1
  75. package/codegen/templates/all-exports.tmpl.js +0 -9
  76. package/codegen/templates/constants.cjs +0 -5
  77. package/codegen/templates/constants.d.cts +0 -2
  78. package/codegen/templates/constants.d.cts.map +0 -1
  79. package/codegen/templates/constants.d.ts +0 -2
  80. package/codegen/templates/constants.d.ts.map +0 -1
  81. package/codegen/templates/constants.js +0 -2
  82. package/codegen/templates/data-contract.tmpl.cjs +0 -49
  83. package/codegen/templates/data-contract.tmpl.d.cts +0 -8
  84. package/codegen/templates/data-contract.tmpl.d.cts.map +0 -1
  85. package/codegen/templates/data-contract.tmpl.d.ts +0 -8
  86. package/codegen/templates/data-contract.tmpl.d.ts.map +0 -1
  87. package/codegen/templates/data-contract.tmpl.js +0 -45
  88. package/codegen/templates/data-contracts-file.tmpl.cjs +0 -27
  89. package/codegen/templates/data-contracts-file.tmpl.d.cts +0 -6
  90. package/codegen/templates/data-contracts-file.tmpl.d.cts.map +0 -1
  91. package/codegen/templates/data-contracts-file.tmpl.d.ts +0 -6
  92. package/codegen/templates/data-contracts-file.tmpl.d.ts.map +0 -1
  93. package/codegen/templates/data-contracts-file.tmpl.js +0 -23
  94. package/codegen/templates/endpoint-jsdoc.tmpl.cjs +0 -111
  95. package/codegen/templates/endpoint-jsdoc.tmpl.d.cts +0 -8
  96. package/codegen/templates/endpoint-jsdoc.tmpl.d.cts.map +0 -1
  97. package/codegen/templates/endpoint-jsdoc.tmpl.d.ts +0 -8
  98. package/codegen/templates/endpoint-jsdoc.tmpl.d.ts.map +0 -1
  99. package/codegen/templates/endpoint-jsdoc.tmpl.js +0 -107
  100. package/codegen/templates/endpoint-per-file.tmpl.cjs +0 -87
  101. package/codegen/templates/endpoint-per-file.tmpl.d.cts +0 -14
  102. package/codegen/templates/endpoint-per-file.tmpl.d.cts.map +0 -1
  103. package/codegen/templates/endpoint-per-file.tmpl.d.ts +0 -14
  104. package/codegen/templates/endpoint-per-file.tmpl.d.ts.map +0 -1
  105. package/codegen/templates/endpoint-per-file.tmpl.js +0 -83
  106. package/codegen/templates/index-ts-for-endpoint-per-file.tmpl.cjs +0 -10
  107. package/codegen/templates/index-ts-for-endpoint-per-file.tmpl.d.cts +0 -6
  108. package/codegen/templates/index-ts-for-endpoint-per-file.tmpl.d.cts.map +0 -1
  109. package/codegen/templates/index-ts-for-endpoint-per-file.tmpl.d.ts +0 -6
  110. package/codegen/templates/index-ts-for-endpoint-per-file.tmpl.d.ts.map +0 -1
  111. package/codegen/templates/index-ts-for-endpoint-per-file.tmpl.js +0 -6
  112. package/codegen/templates/meta-info.tmpl.cjs +0 -48
  113. package/codegen/templates/meta-info.tmpl.d.cts +0 -9
  114. package/codegen/templates/meta-info.tmpl.d.cts.map +0 -1
  115. package/codegen/templates/meta-info.tmpl.d.ts +0 -9
  116. package/codegen/templates/meta-info.tmpl.d.ts.map +0 -1
  117. package/codegen/templates/meta-info.tmpl.js +0 -42
  118. package/codegen/templates/new-endpoint.tmpl.cjs +0 -188
  119. package/codegen/templates/new-endpoint.tmpl.d.cts +0 -15
  120. package/codegen/templates/new-endpoint.tmpl.d.cts.map +0 -1
  121. package/codegen/templates/new-endpoint.tmpl.d.ts +0 -15
  122. package/codegen/templates/new-endpoint.tmpl.d.ts.map +0 -1
  123. package/codegen/templates/new-endpoint.tmpl.js +0 -184
  124. package/codegen/types/all-import-file-params.cjs +0 -2
  125. package/codegen/types/all-import-file-params.d.cts +0 -5
  126. package/codegen/types/all-import-file-params.d.cts.map +0 -1
  127. package/codegen/types/all-import-file-params.d.ts +0 -5
  128. package/codegen/types/all-import-file-params.d.ts.map +0 -1
  129. package/codegen/types/all-import-file-params.js +0 -1
  130. package/codegen/types/base-tmpl-params.cjs +0 -2
  131. package/codegen/types/base-tmpl-params.d.cts +0 -16
  132. package/codegen/types/base-tmpl-params.d.cts.map +0 -1
  133. package/codegen/types/base-tmpl-params.d.ts +0 -16
  134. package/codegen/types/base-tmpl-params.d.ts.map +0 -1
  135. package/codegen/types/base-tmpl-params.js +0 -1
  136. package/codegen/types/codegen-data-utils.cjs +0 -2
  137. package/codegen/types/codegen-data-utils.d.cts +0 -8
  138. package/codegen/types/codegen-data-utils.d.cts.map +0 -1
  139. package/codegen/types/codegen-data-utils.d.ts +0 -8
  140. package/codegen/types/codegen-data-utils.d.ts.map +0 -1
  141. package/codegen/types/codegen-data-utils.js +0 -1
  142. package/codegen/types/endpoint-data.cjs +0 -2
  143. package/codegen/types/endpoint-data.d.cts +0 -3
  144. package/codegen/types/endpoint-data.d.cts.map +0 -1
  145. package/codegen/types/endpoint-data.d.ts +0 -3
  146. package/codegen/types/endpoint-data.d.ts.map +0 -1
  147. package/codegen/types/endpoint-data.js +0 -1
  148. package/codegen/types/generate-query-api-params.cjs +0 -2
  149. package/codegen/types/generate-query-api-params.d.cts.map +0 -1
  150. package/codegen/types/generate-query-api-params.d.ts +0 -162
  151. package/codegen/types/generate-query-api-params.d.ts.map +0 -1
  152. package/codegen/types/generate-query-api-params.js +0 -1
  153. package/codegen/types/import-file-params.cjs +0 -2
  154. package/codegen/types/import-file-params.d.cts +0 -5
  155. package/codegen/types/import-file-params.d.cts.map +0 -1
  156. package/codegen/types/import-file-params.d.ts +0 -5
  157. package/codegen/types/import-file-params.d.ts.map +0 -1
  158. package/codegen/types/import-file-params.js +0 -1
  159. package/codegen/types/index.cjs +0 -23
  160. package/codegen/types/index.d.cts +0 -8
  161. package/codegen/types/index.d.cts.map +0 -1
  162. package/codegen/types/index.d.ts +0 -8
  163. package/codegen/types/index.d.ts.map +0 -1
  164. package/codegen/types/index.js +0 -7
  165. package/codegen/types/meta-info.cjs +0 -2
  166. package/codegen/types/meta-info.d.cts +0 -6
  167. package/codegen/types/meta-info.d.cts.map +0 -1
  168. package/codegen/types/meta-info.d.ts +0 -6
  169. package/codegen/types/meta-info.d.ts.map +0 -1
  170. package/codegen/types/meta-info.js +0 -1
  171. package/codegen/types/type-info.cjs +0 -2
  172. package/codegen/types/type-info.d.cts +0 -4
  173. package/codegen/types/type-info.d.cts.map +0 -1
  174. package/codegen/types/type-info.d.ts +0 -4
  175. package/codegen/types/type-info.d.ts.map +0 -1
  176. package/codegen/types/type-info.js +0 -1
  177. package/codegen/utils/create-short-model-type.cjs +0 -12
  178. package/codegen/utils/create-short-model-type.d.cts +0 -5
  179. package/codegen/utils/create-short-model-type.d.cts.map +0 -1
  180. package/codegen/utils/create-short-model-type.d.ts +0 -5
  181. package/codegen/utils/create-short-model-type.d.ts.map +0 -1
  182. package/codegen/utils/create-short-model-type.js +0 -8
  183. package/codegen/utils/remove-unused-types.cjs +0 -117
  184. package/codegen/utils/remove-unused-types.d.cts +0 -7
  185. package/codegen/utils/remove-unused-types.d.cts.map +0 -1
  186. package/codegen/utils/remove-unused-types.d.ts +0 -7
  187. package/codegen/utils/remove-unused-types.d.ts.map +0 -1
  188. package/codegen/utils/remove-unused-types.js +0 -110
  189. package/codegen/utils/unpack-filter-option.cjs +0 -23
  190. package/codegen/utils/unpack-filter-option.d.cts +0 -7
  191. package/codegen/utils/unpack-filter-option.d.cts.map +0 -1
  192. package/codegen/utils/unpack-filter-option.d.ts +0 -7
  193. package/codegen/utils/unpack-filter-option.d.ts.map +0 -1
  194. package/codegen/utils/unpack-filter-option.js +0 -19
  195. package/index.d.cts +0 -3
  196. package/index.d.cts.map +0 -1
  197. package/index.d.ts.map +0 -1
  198. package/runtime/endpoint-infinite-query.cjs +0 -101
  199. package/runtime/endpoint-infinite-query.d.cts +0 -17
  200. package/runtime/endpoint-infinite-query.d.cts.map +0 -1
  201. package/runtime/endpoint-infinite-query.d.ts +0 -17
  202. package/runtime/endpoint-infinite-query.d.ts.map +0 -1
  203. package/runtime/endpoint-infinite-query.js +0 -97
  204. package/runtime/endpoint-infinite-query.types.cjs +0 -2
  205. package/runtime/endpoint-infinite-query.types.d.cts +0 -30
  206. package/runtime/endpoint-infinite-query.types.d.cts.map +0 -1
  207. package/runtime/endpoint-infinite-query.types.d.ts +0 -30
  208. package/runtime/endpoint-infinite-query.types.d.ts.map +0 -1
  209. package/runtime/endpoint-infinite-query.types.js +0 -1
  210. package/runtime/endpoint-mutation.cjs +0 -74
  211. package/runtime/endpoint-mutation.d.cts +0 -13
  212. package/runtime/endpoint-mutation.d.cts.map +0 -1
  213. package/runtime/endpoint-mutation.d.ts +0 -13
  214. package/runtime/endpoint-mutation.d.ts.map +0 -1
  215. package/runtime/endpoint-mutation.js +0 -70
  216. package/runtime/endpoint-mutation.types.cjs +0 -2
  217. package/runtime/endpoint-mutation.types.d.cts +0 -36
  218. package/runtime/endpoint-mutation.types.d.cts.map +0 -1
  219. package/runtime/endpoint-mutation.types.d.ts +0 -36
  220. package/runtime/endpoint-mutation.types.d.ts.map +0 -1
  221. package/runtime/endpoint-mutation.types.js +0 -1
  222. package/runtime/endpoint-query-client.cjs +0 -79
  223. package/runtime/endpoint-query-client.d.cts +0 -13
  224. package/runtime/endpoint-query-client.d.cts.map +0 -1
  225. package/runtime/endpoint-query-client.d.ts +0 -13
  226. package/runtime/endpoint-query-client.d.ts.map +0 -1
  227. package/runtime/endpoint-query-client.js +0 -75
  228. package/runtime/endpoint-query-client.types.cjs +0 -2
  229. package/runtime/endpoint-query-client.types.d.cts +0 -16
  230. package/runtime/endpoint-query-client.types.d.cts.map +0 -1
  231. package/runtime/endpoint-query-client.types.d.ts +0 -16
  232. package/runtime/endpoint-query-client.types.d.ts.map +0 -1
  233. package/runtime/endpoint-query-client.types.js +0 -1
  234. package/runtime/endpoint-query.cjs +0 -214
  235. package/runtime/endpoint-query.d.cts +0 -29
  236. package/runtime/endpoint-query.d.cts.map +0 -1
  237. package/runtime/endpoint-query.d.ts +0 -29
  238. package/runtime/endpoint-query.d.ts.map +0 -1
  239. package/runtime/endpoint-query.js +0 -208
  240. package/runtime/endpoint-query.types.cjs +0 -2
  241. package/runtime/endpoint-query.types.d.cts +0 -42
  242. package/runtime/endpoint-query.types.d.cts.map +0 -1
  243. package/runtime/endpoint-query.types.d.ts +0 -42
  244. package/runtime/endpoint-query.types.d.ts.map +0 -1
  245. package/runtime/endpoint-query.types.js +0 -1
  246. package/runtime/endpoint.cjs +0 -131
  247. package/runtime/endpoint.d.cts +0 -73
  248. package/runtime/endpoint.d.cts.map +0 -1
  249. package/runtime/endpoint.d.ts +0 -73
  250. package/runtime/endpoint.d.ts.map +0 -1
  251. package/runtime/endpoint.js +0 -127
  252. package/runtime/endpoint.types.cjs +0 -2
  253. package/runtime/endpoint.types.d.cts +0 -24
  254. package/runtime/endpoint.types.d.cts.map +0 -1
  255. package/runtime/endpoint.types.d.ts +0 -24
  256. package/runtime/endpoint.types.d.ts.map +0 -1
  257. package/runtime/endpoint.types.js +0 -1
  258. package/runtime/http-client.cjs +0 -190
  259. package/runtime/http-client.d.cts +0 -85
  260. package/runtime/http-client.d.cts.map +0 -1
  261. package/runtime/http-client.d.ts +0 -85
  262. package/runtime/http-client.d.ts.map +0 -1
  263. package/runtime/http-client.js +0 -184
  264. package/runtime/index.cjs +0 -25
  265. package/runtime/index.d.cts +0 -10
  266. package/runtime/index.d.cts.map +0 -1
  267. package/runtime/index.d.ts +0 -10
  268. package/runtime/index.d.ts.map +0 -1
  269. package/runtime/index.js +0 -9
package/bin.cjs ADDED
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ const cac = require("cac");
4
+ const cli$1 = require("mobx-tanstack-query-api/cli");
5
+ const jiti = require("jiti");
6
+ const fs = require("node:fs");
7
+ const path = require("node:path");
8
+ var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
9
+ const execConfigPath = async (configPath) => {
10
+ const jiti$1 = jiti.createJiti(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("bin.cjs", document.baseURI).href);
11
+ try {
12
+ const config = await jiti$1.import(configPath, { default: true });
13
+ return config;
14
+ } catch (error) {
15
+ console.error(error);
16
+ }
17
+ throw new Error(
18
+ `${configPath} is not valid, This file should return object - result of the defineConfig function`
19
+ );
20
+ };
21
+ const projectDir = process.cwd();
22
+ const resolveConfigPath = (userSpefiedPath) => {
23
+ if (userSpefiedPath) {
24
+ const fullUserSpecifiedPath = path.resolve(projectDir, userSpefiedPath);
25
+ if (!fs.existsSync(fullUserSpecifiedPath)) {
26
+ throw `Config file not found by path - ${userSpefiedPath}`;
27
+ }
28
+ return path.resolve(projectDir, userSpefiedPath);
29
+ }
30
+ if (fs.existsSync(path.resolve(projectDir, "api-codegen.config.js"))) {
31
+ return path.resolve(projectDir, "api-codegen.config.js");
32
+ } else if (fs.existsSync(path.resolve(projectDir, "api-codegen.config.mjs"))) {
33
+ return path.resolve(projectDir, "api-codegen.config.mjs");
34
+ } else if (fs.existsSync(path.resolve(projectDir, "api-codegen.config.json"))) {
35
+ return path.resolve(projectDir, "api-codegen.config.json");
36
+ } else if (fs.existsSync(path.resolve(projectDir, "api-codegen.config.ts"))) {
37
+ return path.resolve(projectDir, "api-codegen.config.ts");
38
+ }
39
+ throw new Error("api-codegen.config.(js|mjs|json|ts) not found");
40
+ };
41
+ let cli = cac.cac("mobx-tanstack-query-api");
42
+ cli = cli.option("-c, --config <file>", `[string] use specified config file`);
43
+ cli.help();
44
+ const parsed = cli.parse();
45
+ if (!parsed.options.help) {
46
+ const configPath = resolveConfigPath(
47
+ typeof parsed.options.config === "string" ? parsed.options.config : null
48
+ );
49
+ execConfigPath(configPath).then((generateApiParams) => {
50
+ cli$1.defineConfig(generateApiParams).forEach(cli$1.generateApi);
51
+ });
52
+ }
53
+ //# sourceMappingURL=bin.cjs.map
package/bin.cjs.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.cjs","sources":["../src/bin/utils/exec-config-path.ts","../src/bin/utils/resolve-config-path.ts","../src/bin/index.ts"],"sourcesContent":["import { createJiti } from 'jiti';\n\nexport const execConfigPath = async (configPath: string) => {\n const jiti = createJiti(import.meta.url);\n\n try {\n const config = await jiti.import(configPath, { default: true });\n return config;\n } catch (error) {\n console.error(error);\n }\n\n throw new Error(\n `${configPath} is not valid, This file should return object - result of the defineConfig function`,\n );\n};\n","import fs, { existsSync } from 'node:fs';\nimport path from 'node:path';\nimport type { Maybe } from 'yummies/types';\n\nconst projectDir = process.cwd();\n\nexport const resolveConfigPath = (userSpefiedPath?: Maybe<string>) => {\n if (userSpefiedPath) {\n const fullUserSpecifiedPath = path.resolve(projectDir, userSpefiedPath);\n\n if (!fs.existsSync(fullUserSpecifiedPath)) {\n throw `Config file not found by path - ${userSpefiedPath}`;\n }\n\n return path.resolve(projectDir, userSpefiedPath);\n }\n\n if (existsSync(path.resolve(projectDir, 'api-codegen.config.js'))) {\n return path.resolve(projectDir, 'api-codegen.config.js');\n } else if (existsSync(path.resolve(projectDir, 'api-codegen.config.mjs'))) {\n return path.resolve(projectDir, 'api-codegen.config.mjs');\n } else if (existsSync(path.resolve(projectDir, 'api-codegen.config.json'))) {\n return path.resolve(projectDir, 'api-codegen.config.json');\n } else if (existsSync(path.resolve(projectDir, 'api-codegen.config.ts'))) {\n return path.resolve(projectDir, 'api-codegen.config.ts');\n }\n\n throw new Error('api-codegen.config.(js|mjs|json|ts) not found');\n};\n","#!/usr/bin/env node\nimport { cac } from 'cac';\nimport { defineConfig, generateApi } from 'mobx-tanstack-query-api/cli';\nimport { execConfigPath } from './utils/exec-config-path.js';\nimport { resolveConfigPath } from './utils/resolve-config-path.js';\n\nlet cli = cac('mobx-tanstack-query-api');\n\ncli = cli.option('-c, --config <file>', `[string] use specified config file`);\n\ncli.help();\n\nconst parsed = cli.parse();\n\nif (!parsed.options.help) {\n const configPath = resolveConfigPath(\n typeof parsed.options.config === 'string' ? parsed.options.config : null,\n );\n\n execConfigPath(configPath).then((generateApiParams) => {\n defineConfig(generateApiParams as any).forEach(generateApi);\n });\n}\n"],"names":["jiti","createJiti","existsSync","cac","defineConfig","generateApi"],"mappings":";;;;;;;;AAEO,MAAM,iBAAiB,OAAO,eAAuB;AAC1D,QAAMA,SAAOC,KAAAA,2PAA0B;AAEvC,MAAI;AACF,UAAM,SAAS,MAAMD,OAAK,OAAO,YAAY,EAAE,SAAS,MAAM;AAC9D,WAAO;AAAA,EACT,SAAS,OAAO;AACd,YAAQ,MAAM,KAAK;AAAA,EACrB;AAEA,QAAM,IAAI;AAAA,IACR,GAAG,UAAU;AAAA,EAAA;AAEjB;ACXA,MAAM,aAAa,QAAQ,IAAA;AAEpB,MAAM,oBAAoB,CAAC,oBAAoC;AACpE,MAAI,iBAAiB;AACnB,UAAM,wBAAwB,KAAK,QAAQ,YAAY,eAAe;AAEtE,QAAI,CAAC,GAAG,WAAW,qBAAqB,GAAG;AACzC,YAAM,mCAAmC,eAAe;AAAA,IAC1D;AAEA,WAAO,KAAK,QAAQ,YAAY,eAAe;AAAA,EACjD;AAEA,MAAIE,GAAAA,WAAW,KAAK,QAAQ,YAAY,uBAAuB,CAAC,GAAG;AACjE,WAAO,KAAK,QAAQ,YAAY,uBAAuB;AAAA,EACzD,WAAWA,GAAAA,WAAW,KAAK,QAAQ,YAAY,wBAAwB,CAAC,GAAG;AACzE,WAAO,KAAK,QAAQ,YAAY,wBAAwB;AAAA,EAC1D,WAAWA,GAAAA,WAAW,KAAK,QAAQ,YAAY,yBAAyB,CAAC,GAAG;AAC1E,WAAO,KAAK,QAAQ,YAAY,yBAAyB;AAAA,EAC3D,WAAWA,GAAAA,WAAW,KAAK,QAAQ,YAAY,uBAAuB,CAAC,GAAG;AACxE,WAAO,KAAK,QAAQ,YAAY,uBAAuB;AAAA,EACzD;AAEA,QAAM,IAAI,MAAM,+CAA+C;AACjE;ACtBA,IAAI,MAAMC,IAAAA,IAAI,yBAAyB;AAEvC,MAAM,IAAI,OAAO,uBAAuB,oCAAoC;AAE5E,IAAI,KAAA;AAEJ,MAAM,SAAS,IAAI,MAAA;AAEnB,IAAI,CAAC,OAAO,QAAQ,MAAM;AACxB,QAAM,aAAa;AAAA,IACjB,OAAO,OAAO,QAAQ,WAAW,WAAW,OAAO,QAAQ,SAAS;AAAA,EAAA;AAGtE,iBAAe,UAAU,EAAE,KAAK,CAAC,sBAAsB;AACrDC,UAAAA,aAAa,iBAAwB,EAAE,QAAQC,iBAAW;AAAA,EAC5D,CAAC;AACH;"}
package/bin.d.ts ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
package/bin.js ADDED
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env node
2
+ import { cac } from "cac";
3
+ import { defineConfig, generateApi } from "mobx-tanstack-query-api/cli";
4
+ import { createJiti } from "jiti";
5
+ import fs, { existsSync } from "node:fs";
6
+ import path from "node:path";
7
+ const execConfigPath = async (configPath) => {
8
+ const jiti = createJiti(import.meta.url);
9
+ try {
10
+ const config = await jiti.import(configPath, { default: true });
11
+ return config;
12
+ } catch (error) {
13
+ console.error(error);
14
+ }
15
+ throw new Error(
16
+ `${configPath} is not valid, This file should return object - result of the defineConfig function`
17
+ );
18
+ };
19
+ const projectDir = process.cwd();
20
+ const resolveConfigPath = (userSpefiedPath) => {
21
+ if (userSpefiedPath) {
22
+ const fullUserSpecifiedPath = path.resolve(projectDir, userSpefiedPath);
23
+ if (!fs.existsSync(fullUserSpecifiedPath)) {
24
+ throw `Config file not found by path - ${userSpefiedPath}`;
25
+ }
26
+ return path.resolve(projectDir, userSpefiedPath);
27
+ }
28
+ if (existsSync(path.resolve(projectDir, "api-codegen.config.js"))) {
29
+ return path.resolve(projectDir, "api-codegen.config.js");
30
+ } else if (existsSync(path.resolve(projectDir, "api-codegen.config.mjs"))) {
31
+ return path.resolve(projectDir, "api-codegen.config.mjs");
32
+ } else if (existsSync(path.resolve(projectDir, "api-codegen.config.json"))) {
33
+ return path.resolve(projectDir, "api-codegen.config.json");
34
+ } else if (existsSync(path.resolve(projectDir, "api-codegen.config.ts"))) {
35
+ return path.resolve(projectDir, "api-codegen.config.ts");
36
+ }
37
+ throw new Error("api-codegen.config.(js|mjs|json|ts) not found");
38
+ };
39
+ let cli = cac("mobx-tanstack-query-api");
40
+ cli = cli.option("-c, --config <file>", `[string] use specified config file`);
41
+ cli.help();
42
+ const parsed = cli.parse();
43
+ if (!parsed.options.help) {
44
+ const configPath = resolveConfigPath(
45
+ typeof parsed.options.config === "string" ? parsed.options.config : null
46
+ );
47
+ execConfigPath(configPath).then((generateApiParams) => {
48
+ defineConfig(generateApiParams).forEach(generateApi);
49
+ });
50
+ }
51
+ //# sourceMappingURL=bin.js.map
package/bin.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.js","sources":["../src/bin/utils/exec-config-path.ts","../src/bin/utils/resolve-config-path.ts","../src/bin/index.ts"],"sourcesContent":["import { createJiti } from 'jiti';\n\nexport const execConfigPath = async (configPath: string) => {\n const jiti = createJiti(import.meta.url);\n\n try {\n const config = await jiti.import(configPath, { default: true });\n return config;\n } catch (error) {\n console.error(error);\n }\n\n throw new Error(\n `${configPath} is not valid, This file should return object - result of the defineConfig function`,\n );\n};\n","import fs, { existsSync } from 'node:fs';\nimport path from 'node:path';\nimport type { Maybe } from 'yummies/types';\n\nconst projectDir = process.cwd();\n\nexport const resolveConfigPath = (userSpefiedPath?: Maybe<string>) => {\n if (userSpefiedPath) {\n const fullUserSpecifiedPath = path.resolve(projectDir, userSpefiedPath);\n\n if (!fs.existsSync(fullUserSpecifiedPath)) {\n throw `Config file not found by path - ${userSpefiedPath}`;\n }\n\n return path.resolve(projectDir, userSpefiedPath);\n }\n\n if (existsSync(path.resolve(projectDir, 'api-codegen.config.js'))) {\n return path.resolve(projectDir, 'api-codegen.config.js');\n } else if (existsSync(path.resolve(projectDir, 'api-codegen.config.mjs'))) {\n return path.resolve(projectDir, 'api-codegen.config.mjs');\n } else if (existsSync(path.resolve(projectDir, 'api-codegen.config.json'))) {\n return path.resolve(projectDir, 'api-codegen.config.json');\n } else if (existsSync(path.resolve(projectDir, 'api-codegen.config.ts'))) {\n return path.resolve(projectDir, 'api-codegen.config.ts');\n }\n\n throw new Error('api-codegen.config.(js|mjs|json|ts) not found');\n};\n","#!/usr/bin/env node\nimport { cac } from 'cac';\nimport { defineConfig, generateApi } from 'mobx-tanstack-query-api/cli';\nimport { execConfigPath } from './utils/exec-config-path.js';\nimport { resolveConfigPath } from './utils/resolve-config-path.js';\n\nlet cli = cac('mobx-tanstack-query-api');\n\ncli = cli.option('-c, --config <file>', `[string] use specified config file`);\n\ncli.help();\n\nconst parsed = cli.parse();\n\nif (!parsed.options.help) {\n const configPath = resolveConfigPath(\n typeof parsed.options.config === 'string' ? parsed.options.config : null,\n );\n\n execConfigPath(configPath).then((generateApiParams) => {\n defineConfig(generateApiParams as any).forEach(generateApi);\n });\n}\n"],"names":[],"mappings":";;;;;;AAEO,MAAM,iBAAiB,OAAO,eAAuB;AAC1D,QAAM,OAAO,WAAW,YAAY,GAAG;AAEvC,MAAI;AACF,UAAM,SAAS,MAAM,KAAK,OAAO,YAAY,EAAE,SAAS,MAAM;AAC9D,WAAO;AAAA,EACT,SAAS,OAAO;AACd,YAAQ,MAAM,KAAK;AAAA,EACrB;AAEA,QAAM,IAAI;AAAA,IACR,GAAG,UAAU;AAAA,EAAA;AAEjB;ACXA,MAAM,aAAa,QAAQ,IAAA;AAEpB,MAAM,oBAAoB,CAAC,oBAAoC;AACpE,MAAI,iBAAiB;AACnB,UAAM,wBAAwB,KAAK,QAAQ,YAAY,eAAe;AAEtE,QAAI,CAAC,GAAG,WAAW,qBAAqB,GAAG;AACzC,YAAM,mCAAmC,eAAe;AAAA,IAC1D;AAEA,WAAO,KAAK,QAAQ,YAAY,eAAe;AAAA,EACjD;AAEA,MAAI,WAAW,KAAK,QAAQ,YAAY,uBAAuB,CAAC,GAAG;AACjE,WAAO,KAAK,QAAQ,YAAY,uBAAuB;AAAA,EACzD,WAAW,WAAW,KAAK,QAAQ,YAAY,wBAAwB,CAAC,GAAG;AACzE,WAAO,KAAK,QAAQ,YAAY,wBAAwB;AAAA,EAC1D,WAAW,WAAW,KAAK,QAAQ,YAAY,yBAAyB,CAAC,GAAG;AAC1E,WAAO,KAAK,QAAQ,YAAY,yBAAyB;AAAA,EAC3D,WAAW,WAAW,KAAK,QAAQ,YAAY,uBAAuB,CAAC,GAAG;AACxE,WAAO,KAAK,QAAQ,YAAY,uBAAuB;AAAA,EACzD;AAEA,QAAM,IAAI,MAAM,+CAA+C;AACjE;ACtBA,IAAI,MAAM,IAAI,yBAAyB;AAEvC,MAAM,IAAI,OAAO,uBAAuB,oCAAoC;AAE5E,IAAI,KAAA;AAEJ,MAAM,SAAS,IAAI,MAAA;AAEnB,IAAI,CAAC,OAAO,QAAQ,MAAM;AACxB,QAAM,aAAa;AAAA,IACjB,OAAO,OAAO,QAAQ,WAAW,WAAW,OAAO,QAAQ,SAAS;AAAA,EAAA;AAGtE,iBAAe,UAAU,EAAE,KAAK,CAAC,sBAAsB;AACrD,iBAAa,iBAAwB,EAAE,QAAQ,WAAW;AAAA,EAC5D,CAAC;AACH;"}
package/builtin.cjs ADDED
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const mobxTanstackQueryApi = require("mobx-tanstack-query-api");
4
+ const MAX_FAILURE_COUNT = 3;
5
+ const queryClient = new mobxTanstackQueryApi.EndpointQueryClient({
6
+ defaultOptions: {
7
+ queries: {
8
+ throwOnError: true,
9
+ refetchOnWindowFocus: true,
10
+ refetchOnReconnect: true,
11
+ staleTime: 5 * 60 * 1e3,
12
+ retry: (failureCount, error) => {
13
+ if (mobxTanstackQueryApi.isHttpBadResponse(error) && error.status >= 500) {
14
+ return MAX_FAILURE_COUNT - failureCount > 0;
15
+ }
16
+ return false;
17
+ }
18
+ },
19
+ mutations: {
20
+ throwOnError: true
21
+ }
22
+ }
23
+ });
24
+ const http = new mobxTanstackQueryApi.HttpClient({});
25
+ exports.http = http;
26
+ exports.queryClient = queryClient;
27
+ //# sourceMappingURL=builtin.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builtin.cjs","sources":["../src/builtin/index.ts"],"sourcesContent":["import {\n EndpointQueryClient,\n HttpClient,\n isHttpBadResponse,\n} from 'mobx-tanstack-query-api';\n\nconst MAX_FAILURE_COUNT = 3;\n\nexport const queryClient = new EndpointQueryClient({\n defaultOptions: {\n queries: {\n throwOnError: true,\n refetchOnWindowFocus: true,\n refetchOnReconnect: true,\n staleTime: 5 * 60 * 1000,\n retry: (failureCount, error) => {\n if (isHttpBadResponse(error) && error.status >= 500) {\n return MAX_FAILURE_COUNT - failureCount > 0;\n }\n return false;\n },\n },\n mutations: {\n throwOnError: true,\n },\n },\n});\n\nexport const http = new HttpClient({});\n"],"names":["EndpointQueryClient","isHttpBadResponse","HttpClient"],"mappings":";;;AAMA,MAAM,oBAAoB;AAEnB,MAAM,cAAc,IAAIA,qBAAAA,oBAAoB;AAAA,EACjD,gBAAgB;AAAA,IACd,SAAS;AAAA,MACP,cAAc;AAAA,MACd,sBAAsB;AAAA,MACtB,oBAAoB;AAAA,MACpB,WAAW,IAAI,KAAK;AAAA,MACpB,OAAO,CAAC,cAAc,UAAU;AAC9B,YAAIC,qBAAAA,kBAAkB,KAAK,KAAK,MAAM,UAAU,KAAK;AACnD,iBAAO,oBAAoB,eAAe;AAAA,QAC5C;AACA,eAAO;AAAA,MACT;AAAA,IAAA;AAAA,IAEF,WAAW;AAAA,MACT,cAAc;AAAA,IAAA;AAAA,EAChB;AAEJ,CAAC;AAEM,MAAM,OAAO,IAAIC,qBAAAA,WAAW,CAAA,CAAE;;;"}
package/builtin.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { EndpointQueryClient, HttpClient } from 'mobx-tanstack-query-api';
2
+
3
+ declare const queryClient: EndpointQueryClient;
4
+ declare const http: HttpClient<unknown>;
5
+
6
+ export { http, queryClient };
package/builtin.js ADDED
@@ -0,0 +1,27 @@
1
+ import { EndpointQueryClient, isHttpBadResponse, HttpClient } from "mobx-tanstack-query-api";
2
+ const MAX_FAILURE_COUNT = 3;
3
+ const queryClient = new EndpointQueryClient({
4
+ defaultOptions: {
5
+ queries: {
6
+ throwOnError: true,
7
+ refetchOnWindowFocus: true,
8
+ refetchOnReconnect: true,
9
+ staleTime: 5 * 60 * 1e3,
10
+ retry: (failureCount, error) => {
11
+ if (isHttpBadResponse(error) && error.status >= 500) {
12
+ return MAX_FAILURE_COUNT - failureCount > 0;
13
+ }
14
+ return false;
15
+ }
16
+ },
17
+ mutations: {
18
+ throwOnError: true
19
+ }
20
+ }
21
+ });
22
+ const http = new HttpClient({});
23
+ export {
24
+ http,
25
+ queryClient
26
+ };
27
+ //# sourceMappingURL=builtin.js.map
package/builtin.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builtin.js","sources":["../src/builtin/index.ts"],"sourcesContent":["import {\n EndpointQueryClient,\n HttpClient,\n isHttpBadResponse,\n} from 'mobx-tanstack-query-api';\n\nconst MAX_FAILURE_COUNT = 3;\n\nexport const queryClient = new EndpointQueryClient({\n defaultOptions: {\n queries: {\n throwOnError: true,\n refetchOnWindowFocus: true,\n refetchOnReconnect: true,\n staleTime: 5 * 60 * 1000,\n retry: (failureCount, error) => {\n if (isHttpBadResponse(error) && error.status >= 500) {\n return MAX_FAILURE_COUNT - failureCount > 0;\n }\n return false;\n },\n },\n mutations: {\n throwOnError: true,\n },\n },\n});\n\nexport const http = new HttpClient({});\n"],"names":[],"mappings":";AAMA,MAAM,oBAAoB;AAEnB,MAAM,cAAc,IAAI,oBAAoB;AAAA,EACjD,gBAAgB;AAAA,IACd,SAAS;AAAA,MACP,cAAc;AAAA,MACd,sBAAsB;AAAA,MACtB,oBAAoB;AAAA,MACpB,WAAW,IAAI,KAAK;AAAA,MACpB,OAAO,CAAC,cAAc,UAAU;AAC9B,YAAI,kBAAkB,KAAK,KAAK,MAAM,UAAU,KAAK;AACnD,iBAAO,oBAAoB,eAAe;AAAA,QAC5C;AACA,eAAO;AAAA,MACT;AAAA,IAAA;AAAA,IAEF,WAAW;AAAA,MACT,cAAc;AAAA,IAAA;AAAA,EAChB;AAEJ,CAAC;AAEM,MAAM,OAAO,IAAI,WAAW,CAAA,CAAE;"}