@genapi/presets 4.0.0 → 4.1.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 (51) hide show
  1. package/LICENSE.md +21 -21
  2. package/README.md +36 -108
  3. package/dist/_shared/query/config.d.mts +14 -0
  4. package/dist/_shared/query/config.mjs +58 -0
  5. package/dist/_shared/query/index.d.mts +3 -0
  6. package/dist/_shared/query/index.mjs +4 -0
  7. package/dist/_shared/query/parser.d.mts +7 -0
  8. package/dist/_shared/query/parser.mjs +75 -0
  9. package/dist/_shared/schema/compiler.mjs +8 -6
  10. package/dist/_shared/schema/config.mjs +8 -5
  11. package/dist/axios/js/config/index.mjs +3 -1
  12. package/dist/axios/js/parser/index.mjs +3 -3
  13. package/dist/axios/ts/config/index.mjs +4 -2
  14. package/dist/axios/ts/parser/index.mjs +3 -3
  15. package/dist/fetch/js/parser/index.mjs +3 -3
  16. package/dist/fetch/schema/index.d.mts +1 -0
  17. package/dist/fetch/schema/parser/index.d.mts +1 -0
  18. package/dist/fetch/ts/parser/index.mjs +3 -3
  19. package/dist/got/js/config/index.mjs +3 -1
  20. package/dist/got/js/parser/index.mjs +3 -3
  21. package/dist/got/ts/config/index.mjs +4 -2
  22. package/dist/got/ts/parser/index.mjs +3 -3
  23. package/dist/index.d.mts +10 -7
  24. package/dist/index.mjs +11 -8
  25. package/dist/ky/js/config/index.mjs +3 -1
  26. package/dist/ky/js/parser/index.mjs +3 -3
  27. package/dist/ky/ts/config/index.mjs +4 -2
  28. package/dist/ky/ts/parser/index.mjs +3 -3
  29. package/dist/ofetch/js/config/index.mjs +3 -1
  30. package/dist/ofetch/js/parser/index.mjs +3 -3
  31. package/dist/ofetch/schema/index.d.mts +1 -0
  32. package/dist/ofetch/schema/parser/index.d.mts +1 -0
  33. package/dist/ofetch/ts/config/index.mjs +4 -2
  34. package/dist/ofetch/ts/parser/index.mjs +3 -3
  35. package/dist/tanstack/colada/config/index.d.mts +2 -2
  36. package/dist/tanstack/colada/config/index.mjs +2 -11
  37. package/dist/tanstack/colada/index.d.mts +1 -1
  38. package/dist/tanstack/colada/parser/index.mjs +2 -66
  39. package/dist/tanstack/react/config/index.d.mts +2 -2
  40. package/dist/tanstack/react/config/index.mjs +2 -11
  41. package/dist/tanstack/react/index.d.mts +1 -1
  42. package/dist/tanstack/react/parser/index.mjs +2 -70
  43. package/dist/tanstack/vue/config/index.d.mts +2 -2
  44. package/dist/tanstack/vue/config/index.mjs +2 -11
  45. package/dist/tanstack/vue/index.d.mts +1 -1
  46. package/dist/tanstack/vue/parser/index.mjs +2 -66
  47. package/dist/uni/js/config/index.mjs +3 -1
  48. package/dist/uni/js/parser/index.mjs +3 -3
  49. package/dist/uni/ts/config/index.mjs +4 -2
  50. package/dist/uni/ts/parser/index.mjs +3 -3
  51. package/package.json +5 -5
@@ -1,5 +1,6 @@
1
1
  import { config as config$1 } from "@genapi/pipeline";
2
2
  import { replaceMainext } from "@genapi/parser";
3
+ import { inject } from "@genapi/shared";
3
4
 
4
5
  //#region src/uni/js/config/index.ts
5
6
  function config(userConfig) {
@@ -9,7 +10,8 @@ function config(userConfig) {
9
10
  userConfig.meta.import.http = userConfig.meta.import.http || "@uni-helper/uni-network";
10
11
  userConfig.output = replaceMainext(userConfig.output) || "src/api/index.js";
11
12
  const configRead = config$1(userConfig);
12
- configRead.graphs.imports.push({
13
+ const { imports } = inject();
14
+ imports.add("main", {
13
15
  name: "http",
14
16
  value: userConfig.meta.import.http
15
17
  });
@@ -8,7 +8,7 @@ const parser = createParser((config, { configRead, functions, interfaces }) => {
8
8
  });
9
9
  let { name, description, url, responseType } = parseMethodMetadata(config);
10
10
  options.push(["...", "config"]);
11
- interfaces.push(...attachInters);
11
+ attachInters.forEach((i) => interfaces.add("type", i));
12
12
  parameters.push({
13
13
  type: "import('@uni-helper/uni-network').UnConfig<never>",
14
14
  name: "config",
@@ -21,12 +21,12 @@ const parser = createParser((config, { configRead, functions, interfaces }) => {
21
21
  syntax: "ecmascript",
22
22
  configRead,
23
23
  description,
24
- interfaces,
24
+ interfaces: interfaces.all(),
25
25
  responseType,
26
26
  generic: "import('@uni-helper/uni-network').UnResponse<{__type__}>"
27
27
  });
28
28
  url = transformUrlSyntax(url);
29
- functions.push({
29
+ functions.add("main", {
30
30
  export: true,
31
31
  name,
32
32
  description,
@@ -1,4 +1,5 @@
1
1
  import { config as config$1 } from "@genapi/pipeline";
2
+ import { inject } from "@genapi/shared";
2
3
 
3
4
  //#region src/uni/ts/config/index.ts
4
5
  function config(userConfig) {
@@ -6,12 +7,13 @@ function config(userConfig) {
6
7
  userConfig.meta.import = userConfig.meta.import || {};
7
8
  userConfig.meta.import.http = userConfig.meta.import.http || "@uni-helper/uni-network";
8
9
  const configRead = config$1(userConfig);
9
- configRead.graphs.imports.push({
10
+ const { imports } = inject();
11
+ imports.add("main", {
10
12
  name: "http",
11
13
  names: userConfig.meta.import.http === "@uni-helper/uni-network" ? ["UnConfig"] : void 0,
12
14
  value: userConfig.meta.import.http
13
15
  });
14
- if (userConfig.meta.import.http !== "@uni-helper/uni-network") configRead.graphs.imports.push({
16
+ if (userConfig.meta.import.http !== "@uni-helper/uni-network") imports.add("main", {
15
17
  names: ["UnConfig"],
16
18
  value: "@uni-helper/uni-network"
17
19
  });
@@ -8,7 +8,7 @@ const parser = createParser((config, { configRead, functions, interfaces }) => {
8
8
  });
9
9
  let { name, description, url, responseType } = parseMethodMetadata(config);
10
10
  options.push(["...", "config"]);
11
- interfaces.push(...attachInters);
11
+ attachInters.forEach((i) => interfaces.add("type", i));
12
12
  parameters.push({
13
13
  name: "config",
14
14
  type: "UnConfig<never>",
@@ -18,14 +18,14 @@ const parser = createParser((config, { configRead, functions, interfaces }) => {
18
18
  options.unshift(["method", `"${config.method}"`]);
19
19
  if (configRead.config.meta?.baseURL) options.unshift("baseURL");
20
20
  const { spaceResponseType } = transformParameters(parameters, {
21
+ interfaces: interfaces.values("type"),
21
22
  syntax: "typescript",
22
23
  configRead,
23
24
  description,
24
- interfaces,
25
25
  responseType
26
26
  });
27
27
  url = transformUrlSyntax(url);
28
- functions.push({
28
+ functions.add("main", {
29
29
  export: true,
30
30
  name,
31
31
  description,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@genapi/presets",
3
3
  "type": "module",
4
- "version": "4.0.0",
4
+ "version": "4.1.0",
5
5
  "author": "Hairyf <wwu710632@gmail.com>",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/hairyf/genapi#readme",
@@ -78,11 +78,11 @@
78
78
  "dist"
79
79
  ],
80
80
  "dependencies": {
81
- "knitwork-x": "^0.2.0",
81
+ "knitwork-x": "^0.3.1",
82
82
  "openapi-specification-types": "^0.3.0",
83
- "@genapi/parser": "4.0.0",
84
- "@genapi/pipeline": "4.0.0",
85
- "@genapi/shared": "4.0.0"
83
+ "@genapi/parser": "4.1.0",
84
+ "@genapi/pipeline": "4.1.0",
85
+ "@genapi/shared": "4.1.0"
86
86
  },
87
87
  "scripts": {
88
88
  "build": "tsdown",