@genapi/presets 3.4.0 → 3.5.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 (181) hide show
  1. package/dist/axios/index.d.mts +9 -0
  2. package/dist/axios/index.mjs +9 -7
  3. package/dist/axios/js/config/index.d.mts +3 -0
  4. package/dist/axios/js/config/index.mjs +3 -18
  5. package/dist/axios/js/index.d.mts +5 -0
  6. package/dist/axios/js/index.mjs +5 -31
  7. package/dist/axios/js/parser/index.d.mts +3 -0
  8. package/dist/axios/js/parser/index.mjs +3 -77
  9. package/dist/axios/ts/config/index.d.mts +3 -0
  10. package/dist/axios/ts/config/index.mjs +3 -22
  11. package/dist/axios/ts/index.d.mts +5 -0
  12. package/dist/axios/ts/index.mjs +5 -31
  13. package/dist/axios/ts/parser/index.d.mts +3 -0
  14. package/dist/axios/ts/parser/index.mjs +3 -76
  15. package/dist/axios-CG6HLmR9.mjs +13 -0
  16. package/dist/chunk-BL35Yyzp.mjs +12 -0
  17. package/dist/config-B6UDPRkS.mjs +12 -0
  18. package/dist/config-B89EoGE7.mjs +21 -0
  19. package/dist/config-BJZnXcL3.mjs +14 -0
  20. package/dist/config-CDvaM7ZL.mjs +19 -0
  21. package/dist/config-CwmGeydd.mjs +19 -0
  22. package/dist/config-DdUVYIe0.mjs +19 -0
  23. package/dist/config-Dm0OCPw8.mjs +19 -0
  24. package/dist/config-Dp9C4aUE.mjs +21 -0
  25. package/dist/config-IeVj3de_.mjs +21 -0
  26. package/dist/config-aVU8JEKy.mjs +21 -0
  27. package/dist/fetch/index.d.mts +9 -0
  28. package/dist/fetch/index.mjs +9 -7
  29. package/dist/fetch/js/config/index.d.mts +3 -0
  30. package/dist/fetch/js/config/index.mjs +3 -13
  31. package/dist/fetch/js/index.d.mts +5 -0
  32. package/dist/fetch/js/index.mjs +5 -31
  33. package/dist/fetch/js/parser/index.d.mts +3 -0
  34. package/dist/fetch/js/parser/index.mjs +3 -83
  35. package/dist/fetch/ts/config/index.d.mts +3 -0
  36. package/dist/fetch/ts/config/index.mjs +3 -11
  37. package/dist/fetch/ts/index.d.mts +5 -0
  38. package/dist/fetch/ts/index.mjs +5 -31
  39. package/dist/fetch/ts/parser/index.d.mts +3 -0
  40. package/dist/fetch/ts/parser/index.mjs +3 -79
  41. package/dist/fetch-DDSgFojK.mjs +13 -0
  42. package/dist/got/index.d.mts +9 -0
  43. package/dist/got/index.mjs +9 -7
  44. package/dist/got/js/config/index.d.mts +3 -0
  45. package/dist/got/js/config/index.mjs +3 -18
  46. package/dist/got/js/index.d.mts +5 -0
  47. package/dist/got/js/index.mjs +5 -31
  48. package/dist/got/js/parser/index.d.mts +3 -0
  49. package/dist/got/js/parser/index.mjs +3 -82
  50. package/dist/got/ts/config/index.d.mts +3 -0
  51. package/dist/got/ts/config/index.mjs +3 -22
  52. package/dist/got/ts/index.d.mts +5 -0
  53. package/dist/got/ts/index.mjs +5 -31
  54. package/dist/got/ts/parser/index.d.mts +3 -0
  55. package/dist/got/ts/parser/index.mjs +3 -82
  56. package/dist/got-DhRc0hx6.mjs +13 -0
  57. package/dist/index.d-B-u-rHVf.d.mts +7 -0
  58. package/dist/index.d-B5ex0iL6.d.mts +18 -0
  59. package/dist/index.d-B6ea0pDX.d.mts +7 -0
  60. package/dist/index.d-B9YjsDSU.d.mts +7 -0
  61. package/dist/index.d-BCl4h5vb.d.mts +18 -0
  62. package/dist/index.d-BEPmcVlv.d.mts +12 -0
  63. package/dist/{axios/ts/parser/index.d.ts → index.d-BVDe1tFu.d.mts} +5 -3
  64. package/dist/index.d-Ba1tOHnm.d.mts +18 -0
  65. package/dist/{fetch/ts/parser/index.d.ts → index.d-BvMhV1lw.d.mts} +5 -3
  66. package/dist/index.d-C-mKHl9s.d.mts +7 -0
  67. package/dist/index.d-C-mT1tVI.d.mts +12 -0
  68. package/dist/index.d-C10wnMdy.d.mts +14 -0
  69. package/dist/index.d-C38NRU-q.d.mts +18 -0
  70. package/dist/index.d-CGbHzQH8.d.mts +18 -0
  71. package/dist/{axios/js/parser/index.d.ts → index.d-Ch6ZYMn0.d.mts} +5 -3
  72. package/dist/index.d-CozwYURq.d.mts +14 -0
  73. package/dist/index.d-D0ou41dA.d.mts +18 -0
  74. package/dist/index.d-D6AeBSov.d.mts +14 -0
  75. package/dist/index.d-D9OXwZhj.d.mts +7 -0
  76. package/dist/index.d-DBNQTE-q.d.mts +18 -0
  77. package/dist/index.d-DD5okdfE.d.mts +12 -0
  78. package/dist/index.d-DD9vtQSr.d.mts +14 -0
  79. package/dist/index.d-DT6dJ1Sg.d.mts +14 -0
  80. package/dist/index.d-DTsMFJM4.d.mts +18 -0
  81. package/dist/index.d-DgSgg69k.d.mts +18 -0
  82. package/dist/index.d-DkWb7AYg.d.mts +7 -0
  83. package/dist/index.d-DlncPuTy.d.mts +7 -0
  84. package/dist/index.d-DndBUrRi.d.mts +18 -0
  85. package/dist/index.d-Dsok7fEc.d.mts +7 -0
  86. package/dist/index.d-Dx6IWWI4.d.mts +7 -0
  87. package/dist/index.d-YNb6GO8o.d.mts +12 -0
  88. package/dist/index.d-qxp4tWxk.d.mts +7 -0
  89. package/dist/index.d-sEb0cOvU.d.mts +12 -0
  90. package/dist/index.d-xT7aQSB2.d.mts +14 -0
  91. package/dist/{fetch/js/parser/index.d.ts → index.d-yppv-kCz.d.mts} +5 -3
  92. package/dist/index.d.mts +47 -0
  93. package/dist/index.mjs +46 -20
  94. package/dist/js-CfKFwY21.mjs +19 -0
  95. package/dist/js-CqtsolD8.mjs +19 -0
  96. package/dist/js-DxwOJyF7.mjs +19 -0
  97. package/dist/js-nNB2l-OU.mjs +19 -0
  98. package/dist/js-t1rqZHU4.mjs +19 -0
  99. package/dist/ky/index.d.mts +9 -0
  100. package/dist/ky/index.mjs +9 -7
  101. package/dist/ky/js/config/index.d.mts +3 -0
  102. package/dist/ky/js/config/index.mjs +3 -18
  103. package/dist/ky/js/index.d.mts +5 -0
  104. package/dist/ky/js/index.mjs +5 -31
  105. package/dist/ky/js/parser/index.d.mts +3 -0
  106. package/dist/ky/js/parser/index.mjs +3 -79
  107. package/dist/ky/ts/config/index.d.mts +3 -0
  108. package/dist/ky/ts/config/index.mjs +3 -22
  109. package/dist/ky/ts/index.d.mts +5 -0
  110. package/dist/ky/ts/index.mjs +5 -31
  111. package/dist/ky/ts/parser/index.d.mts +3 -0
  112. package/dist/ky/ts/parser/index.mjs +3 -78
  113. package/dist/ky-tkF4RP6y.mjs +13 -0
  114. package/dist/ofetch/index.d.mts +9 -0
  115. package/dist/ofetch/index.mjs +9 -7
  116. package/dist/ofetch/js/config/index.d.mts +3 -0
  117. package/dist/ofetch/js/config/index.mjs +3 -18
  118. package/dist/ofetch/js/index.d.mts +5 -0
  119. package/dist/ofetch/js/index.mjs +5 -31
  120. package/dist/ofetch/js/parser/index.d.mts +3 -0
  121. package/dist/ofetch/js/parser/index.mjs +3 -78
  122. package/dist/ofetch/ts/config/index.d.mts +3 -0
  123. package/dist/ofetch/ts/config/index.mjs +3 -22
  124. package/dist/ofetch/ts/index.d.mts +5 -0
  125. package/dist/ofetch/ts/index.mjs +5 -31
  126. package/dist/ofetch/ts/parser/index.d.mts +3 -0
  127. package/dist/ofetch/ts/parser/index.mjs +3 -76
  128. package/dist/ofetch-D17IUjVF.mjs +13 -0
  129. package/dist/parser-8NB1Nfwt.mjs +63 -0
  130. package/dist/parser-B-nJrHKw.mjs +68 -0
  131. package/dist/parser-BGXx6lbG.mjs +66 -0
  132. package/dist/parser-BkWqv1qf.mjs +69 -0
  133. package/dist/parser-CAdkVm2b.mjs +77 -0
  134. package/dist/parser-CSJYNO0a.mjs +69 -0
  135. package/dist/parser-CaRC8JQj.mjs +67 -0
  136. package/dist/parser-GwoAS3rw.mjs +62 -0
  137. package/dist/parser-ZdK3ZwJM.mjs +69 -0
  138. package/dist/parser-aevzlGBk.mjs +72 -0
  139. package/dist/ts-4mi0Q-kd.mjs +19 -0
  140. package/dist/ts-B0VNlOAi.mjs +19 -0
  141. package/dist/ts-BLbY66M1.mjs +19 -0
  142. package/dist/ts-BrqtDsf2.mjs +19 -0
  143. package/dist/ts-DjVYemin.mjs +19 -0
  144. package/package.json +15 -15
  145. package/dist/axios/index.d.ts +0 -9
  146. package/dist/axios/js/config/index.d.ts +0 -5
  147. package/dist/axios/js/index.d.ts +0 -18
  148. package/dist/axios/ts/config/index.d.ts +0 -5
  149. package/dist/axios/ts/index.d.ts +0 -18
  150. package/dist/fetch/index.d.ts +0 -9
  151. package/dist/fetch/js/config/index.d.ts +0 -5
  152. package/dist/fetch/js/index.d.ts +0 -18
  153. package/dist/fetch/ts/config/index.d.ts +0 -5
  154. package/dist/fetch/ts/index.d.ts +0 -18
  155. package/dist/got/index.d.ts +0 -9
  156. package/dist/got/js/config/index.d.ts +0 -5
  157. package/dist/got/js/index.d.ts +0 -18
  158. package/dist/got/js/parser/index.d.ts +0 -12
  159. package/dist/got/ts/config/index.d.ts +0 -5
  160. package/dist/got/ts/index.d.ts +0 -18
  161. package/dist/got/ts/parser/index.d.ts +0 -12
  162. package/dist/index-BoRNV5uE.d.ts +0 -8
  163. package/dist/index-C-Of8dmT.d.ts +0 -8
  164. package/dist/index-DUlkpebX.d.ts +0 -8
  165. package/dist/index-doIz4HN1.d.ts +0 -8
  166. package/dist/index-ln0OpJQY.d.ts +0 -8
  167. package/dist/index.d.ts +0 -48
  168. package/dist/ky/index.d.ts +0 -9
  169. package/dist/ky/js/config/index.d.ts +0 -5
  170. package/dist/ky/js/index.d.ts +0 -18
  171. package/dist/ky/js/parser/index.d.ts +0 -12
  172. package/dist/ky/ts/config/index.d.ts +0 -5
  173. package/dist/ky/ts/index.d.ts +0 -18
  174. package/dist/ky/ts/parser/index.d.ts +0 -12
  175. package/dist/ofetch/index.d.ts +0 -9
  176. package/dist/ofetch/js/config/index.d.ts +0 -5
  177. package/dist/ofetch/js/index.d.ts +0 -18
  178. package/dist/ofetch/js/parser/index.d.ts +0 -12
  179. package/dist/ofetch/ts/config/index.d.ts +0 -5
  180. package/dist/ofetch/ts/index.d.ts +0 -18
  181. package/dist/ofetch/ts/parser/index.d.ts +0 -12
@@ -0,0 +1,3 @@
1
+ import { config$15 as config } from "../../../index.d-DlncPuTy.mjs";
2
+
3
+ export { config };
@@ -1,22 +1,3 @@
1
- // src/ofetch/ts/config/index.ts
2
- import { config as _config } from "@genapi/pipeline";
3
- function config(userConfig) {
4
- userConfig.import = userConfig.import || {};
5
- userConfig.import.http = userConfig.import.http || "ofetch";
6
- const configRead = _config(userConfig);
7
- configRead.graphs.imports.push({
8
- name: "ofetch",
9
- names: userConfig.import.http === "ofetch" ? ["FetchOptions"] : void 0,
10
- value: userConfig.import.http
11
- });
12
- if (userConfig.import.http !== "ofetch") {
13
- configRead.graphs.imports.push({
14
- names: ["FetchOptions"],
15
- value: "ofetch"
16
- });
17
- }
18
- return configRead;
19
- }
20
- export {
21
- config
22
- };
1
+ import { config$7 as config } from "../../../config-Dp9C4aUE.mjs";
2
+
3
+ export { config };
@@ -0,0 +1,5 @@
1
+ import { parser$13 as parser } from "../../index.d-CozwYURq.mjs";
2
+ import { config$15 as config } from "../../index.d-DlncPuTy.mjs";
3
+ import { compiler$16 as compiler, dest$16 as dest, generate$16 as generate, openapiPipeline$6 as openapiPipeline, original$16 as original } from "../../index.d-DgSgg69k.mjs";
4
+
5
+ export { compiler, config, openapiPipeline as default, dest, generate, original, parser };
@@ -1,31 +1,5 @@
1
- // src/ofetch/ts/index.ts
2
- import pipeline, { compiler, dest, generate, original } from "@genapi/pipeline";
3
- import { config } from "./config/index.mjs";
4
- import { parser } from "./parser/index.mjs";
5
- function openapiPipeline(userConfig) {
6
- const process = pipeline(
7
- (userConfig2) => config(userConfig2),
8
- (configRead) => original(configRead),
9
- (configRead) => parser(configRead),
10
- (configRead) => compiler(configRead),
11
- (configRead) => generate(configRead),
12
- (configRead) => dest(configRead)
13
- );
14
- return process(userConfig);
15
- }
16
- openapiPipeline.config = config;
17
- openapiPipeline.original = original;
18
- openapiPipeline.parser = parser;
19
- openapiPipeline.compiler = compiler;
20
- openapiPipeline.generate = generate;
21
- openapiPipeline.dest = dest;
22
- var ts_default = openapiPipeline;
23
- export {
24
- compiler,
25
- config,
26
- ts_default as default,
27
- dest,
28
- generate,
29
- original,
30
- parser
31
- };
1
+ import { config$7 as config } from "../../config-Dp9C4aUE.mjs";
2
+ import { parser$7 as parser } from "../../parser-BGXx6lbG.mjs";
3
+ import { compiler$7 as compiler, dest$7 as dest, generate$7 as generate, original$7 as original, ts_default$3 as ts_default } from "../../ts-B0VNlOAi.mjs";
4
+
5
+ export { compiler, config, ts_default as default, dest, generate, original, parser };
@@ -0,0 +1,3 @@
1
+ import { PathsTransformOptions$3 as PathsTransformOptions, parser$13 as parser, transformPaths$13 as transformPaths } from "../../../index.d-CozwYURq.mjs";
2
+
3
+ export { PathsTransformOptions, parser, transformPaths };
@@ -1,76 +1,3 @@
1
- // src/ofetch/ts/parser/index.ts
2
- import {
3
- literalFieldsToString,
4
- parseHeaderCommits,
5
- parseMethodMetadata,
6
- parseMethodParameters,
7
- parseOpenapiSpecification,
8
- transformBaseURL,
9
- transformDefinitions,
10
- transformParameters,
11
- transformQueryParams,
12
- transformUrlSyntax,
13
- traversePaths
14
- } from "@genapi/parser";
15
- function parser(configRead) {
16
- const source = parseOpenapiSpecification(configRead.source);
17
- const comments = parseHeaderCommits(source);
18
- const interfaces = [];
19
- const functions = [];
20
- transformBaseURL(source, {
21
- configRead
22
- });
23
- transformDefinitions(source.definitions, {
24
- interfaces
25
- });
26
- transformPaths(source.paths, {
27
- configRead,
28
- functions,
29
- interfaces
30
- });
31
- configRead.graphs.comments = comments;
32
- configRead.graphs.functions = functions;
33
- configRead.graphs.interfaces = interfaces;
34
- return configRead;
35
- }
36
- function transformPaths(paths, { configRead, functions, interfaces }) {
37
- traversePaths(paths, (config) => {
38
- const { parameters, interfaces: attachInters, options } = parseMethodParameters(config, {
39
- formData: "body",
40
- query: "params"
41
- });
42
- let { name, description, url, responseType, body } = parseMethodMetadata(config);
43
- interfaces.push(...attachInters);
44
- parameters.push({
45
- name: "options",
46
- type: "FetchOptions",
47
- required: false
48
- });
49
- options.push(["...", "options"]);
50
- options.unshift(["method", `"${config.method}"`]);
51
- if (configRead.config.baseURL)
52
- options.unshift("baseURL");
53
- const { spaceResponseType } = transformParameters(parameters, {
54
- syntax: "typescript",
55
- configRead,
56
- description,
57
- interfaces,
58
- responseType
59
- });
60
- url = transformQueryParams("query", { body, options, url });
61
- url = transformUrlSyntax(url);
62
- functions.push({
63
- export: true,
64
- name,
65
- description,
66
- parameters,
67
- body: [
68
- `return ofetch<${spaceResponseType}>(${url}, {${literalFieldsToString(options)}})`
69
- ]
70
- });
71
- });
72
- }
73
- export {
74
- parser,
75
- transformPaths
76
- };
1
+ import { parser$7 as parser, transformPaths$7 as transformPaths } from "../../../parser-BGXx6lbG.mjs";
2
+
3
+ export { parser, transformPaths };
@@ -0,0 +1,13 @@
1
+ import { __export } from "./chunk-BL35Yyzp.mjs";
2
+ import { js_default$4 as js_default } from "./js-DxwOJyF7.mjs";
3
+ import { ts_default$3 as ts_default } from "./ts-B0VNlOAi.mjs";
4
+
5
+ //#region src/ofetch/index.ts
6
+ var ofetch_exports = {};
7
+ __export(ofetch_exports, {
8
+ js: () => js_default,
9
+ ts: () => ts_default
10
+ });
11
+
12
+ //#endregion
13
+ export { ofetch_exports };
@@ -0,0 +1,63 @@
1
+ import { literalFieldsToString, parseHeaderCommits, parseMethodMetadata, parseMethodParameters, parseOpenapiSpecification, transformBaseURL, transformDefinitions, transformParameters, transformUrlSyntax, traversePaths } from "@genapi/parser";
2
+
3
+ //#region src/axios/js/parser/index.ts
4
+ function parser(configRead) {
5
+ const source = parseOpenapiSpecification(configRead.source);
6
+ const comments = parseHeaderCommits(source);
7
+ const interfaces = [];
8
+ const functions = [];
9
+ transformBaseURL(source, { configRead });
10
+ transformDefinitions(source.definitions, { interfaces });
11
+ transformPaths(source.paths, {
12
+ configRead,
13
+ functions,
14
+ interfaces
15
+ });
16
+ configRead.graphs.comments = comments;
17
+ configRead.graphs.functions = functions;
18
+ configRead.graphs.interfaces = interfaces;
19
+ return configRead;
20
+ }
21
+ function transformPaths(paths, { configRead, functions, interfaces }) {
22
+ traversePaths(paths, (config) => {
23
+ /**
24
+
25
+ * function params/function options/function use interfaces
26
+
27
+ */
28
+ const { parameters, interfaces: attachInters, options } = parseMethodParameters(config, {
29
+ body: "data",
30
+ query: "params"
31
+ });
32
+ let { name, description, url, responseType } = parseMethodMetadata(config);
33
+ options.push(["...", "config"]);
34
+ interfaces.push(...attachInters);
35
+ parameters.push({
36
+ type: "import('axios').AxiosRequestConfig",
37
+ name: "config",
38
+ required: false
39
+ });
40
+ options.unshift("url");
41
+ options.unshift(["method", `"${config.method}"`]);
42
+ if (configRead.config.baseURL) options.unshift("baseURL");
43
+ transformParameters(parameters, {
44
+ syntax: "ecmascript",
45
+ configRead,
46
+ description,
47
+ interfaces,
48
+ responseType,
49
+ generic: "import('axios').AxiosResponse<{__type__}>"
50
+ });
51
+ url = transformUrlSyntax(url);
52
+ functions.push({
53
+ export: true,
54
+ name,
55
+ description,
56
+ parameters,
57
+ body: [`const url = ${url}`, `return http.request({ ${literalFieldsToString(options)} })`]
58
+ });
59
+ });
60
+ }
61
+
62
+ //#endregion
63
+ export { parser, transformPaths };
@@ -0,0 +1,68 @@
1
+ import { literalFieldsToString, parseHeaderCommits, parseMethodMetadata, parseMethodParameters, parseOpenapiSpecification, transformBaseURL, transformBodyStringify, transformDefinitions, transformParameters, transformQueryParams, transformUrlSyntax, traversePaths } from "@genapi/parser";
2
+
3
+ //#region src/ky/ts/parser/index.ts
4
+ function parser(configRead) {
5
+ const source = parseOpenapiSpecification(configRead.source);
6
+ const comments = parseHeaderCommits(source);
7
+ const interfaces = [];
8
+ const functions = [];
9
+ transformBaseURL(source, { configRead });
10
+ transformDefinitions(source.definitions, { interfaces });
11
+ transformPaths(source.paths, {
12
+ configRead,
13
+ functions,
14
+ interfaces
15
+ });
16
+ configRead.graphs.comments = comments;
17
+ configRead.graphs.functions = functions;
18
+ configRead.graphs.interfaces = interfaces;
19
+ return configRead;
20
+ }
21
+ function transformPaths(paths, { configRead, functions, interfaces }) {
22
+ traversePaths(paths, (config) => {
23
+ /**
24
+
25
+ * function params/function options/function use interfaces
26
+
27
+ */
28
+ const { parameters, interfaces: attachInters, options } = parseMethodParameters(config);
29
+ let { name, description, url, responseType } = parseMethodMetadata(config);
30
+ interfaces.push(...attachInters);
31
+ parameters.push({
32
+ name: "config",
33
+ type: "Options",
34
+ required: false
35
+ });
36
+ options.push(["...", "config"]);
37
+ if (configRead.config.baseURL) options.unshift(["prefixUrl", "baseURL"]);
38
+ const { spaceResponseType } = transformParameters(parameters, {
39
+ syntax: "typescript",
40
+ configRead,
41
+ description,
42
+ interfaces,
43
+ responseType
44
+ });
45
+ transformBodyStringify("body", {
46
+ options,
47
+ parameters
48
+ });
49
+ transformQueryParams("query", {
50
+ optionKey: "searchParams",
51
+ options
52
+ });
53
+ url = transformUrlSyntax(url);
54
+ functions.push({
55
+ export: true,
56
+ async: true,
57
+ name,
58
+ description,
59
+ parameters,
60
+ body: [`const response = await http(${url}, {
61
+ ${literalFieldsToString(options)}
62
+ })`, `return response.json<${spaceResponseType}>()`]
63
+ });
64
+ });
65
+ }
66
+
67
+ //#endregion
68
+ export { parser as parser$9, transformPaths as transformPaths$9 };
@@ -0,0 +1,66 @@
1
+ import { literalFieldsToString, parseHeaderCommits, parseMethodMetadata, parseMethodParameters, parseOpenapiSpecification, transformBaseURL, transformDefinitions, transformParameters, transformQueryParams, transformUrlSyntax, traversePaths } from "@genapi/parser";
2
+
3
+ //#region src/ofetch/ts/parser/index.ts
4
+ function parser(configRead) {
5
+ const source = parseOpenapiSpecification(configRead.source);
6
+ const comments = parseHeaderCommits(source);
7
+ const interfaces = [];
8
+ const functions = [];
9
+ transformBaseURL(source, { configRead });
10
+ transformDefinitions(source.definitions, { interfaces });
11
+ transformPaths(source.paths, {
12
+ configRead,
13
+ functions,
14
+ interfaces
15
+ });
16
+ configRead.graphs.comments = comments;
17
+ configRead.graphs.functions = functions;
18
+ configRead.graphs.interfaces = interfaces;
19
+ return configRead;
20
+ }
21
+ function transformPaths(paths, { configRead, functions, interfaces }) {
22
+ traversePaths(paths, (config) => {
23
+ /**
24
+
25
+ * function params/function options/function use interfaces
26
+
27
+ */
28
+ const { parameters, interfaces: attachInters, options } = parseMethodParameters(config, {
29
+ formData: "body",
30
+ query: "params"
31
+ });
32
+ let { name, description, url, responseType, body } = parseMethodMetadata(config);
33
+ interfaces.push(...attachInters);
34
+ parameters.push({
35
+ name: "options",
36
+ type: "FetchOptions",
37
+ required: false
38
+ });
39
+ options.push(["...", "options"]);
40
+ options.unshift(["method", `"${config.method}"`]);
41
+ if (configRead.config.baseURL) options.unshift("baseURL");
42
+ const { spaceResponseType } = transformParameters(parameters, {
43
+ syntax: "typescript",
44
+ configRead,
45
+ description,
46
+ interfaces,
47
+ responseType
48
+ });
49
+ url = transformQueryParams("query", {
50
+ body,
51
+ options,
52
+ url
53
+ });
54
+ url = transformUrlSyntax(url);
55
+ functions.push({
56
+ export: true,
57
+ name,
58
+ description,
59
+ parameters,
60
+ body: [`return ofetch<${spaceResponseType}>(${url}, {${literalFieldsToString(options)}})`]
61
+ });
62
+ });
63
+ }
64
+
65
+ //#endregion
66
+ export { parser as parser$7, transformPaths as transformPaths$7 };
@@ -0,0 +1,69 @@
1
+ import { literalFieldsToString, parseHeaderCommits, parseMethodMetadata, parseMethodParameters, parseOpenapiSpecification, transformBaseURL, transformBodyStringify, transformDefinitions, transformParameters, transformQueryParams, transformUrlSyntax, traversePaths } from "@genapi/parser";
2
+
3
+ //#region src/got/js/parser/index.ts
4
+ function parser(configRead) {
5
+ const source = parseOpenapiSpecification(configRead.source);
6
+ const comments = parseHeaderCommits(source);
7
+ const interfaces = [];
8
+ const functions = [];
9
+ transformBaseURL(source, { configRead });
10
+ transformDefinitions(source.definitions, { interfaces });
11
+ transformPaths(source.paths, {
12
+ configRead,
13
+ functions,
14
+ interfaces
15
+ });
16
+ configRead.graphs.comments = comments;
17
+ configRead.graphs.functions = functions;
18
+ configRead.graphs.interfaces = interfaces;
19
+ return configRead;
20
+ }
21
+ function transformPaths(paths, { configRead, functions, interfaces }) {
22
+ traversePaths(paths, (config) => {
23
+ /**
24
+
25
+ * function params/function options/function use interfaces
26
+
27
+ */
28
+ const { parameters, interfaces: attachInters, options } = parseMethodParameters(config);
29
+ let { name, description, url, responseType } = parseMethodMetadata(config);
30
+ interfaces.push(...attachInters);
31
+ parameters.push({
32
+ name: "config",
33
+ type: "import('got').OptionsOfTextResponseBody",
34
+ required: false
35
+ });
36
+ options.push(["...", "config"]);
37
+ if (configRead.config.baseURL) options.unshift(["prefixUrl", "baseURL"]);
38
+ for (const parameter of parameters) if (parameter.type === "FormData") parameter.type = "any";
39
+ transformParameters(parameters, {
40
+ syntax: "ecmascript",
41
+ configRead,
42
+ description,
43
+ interfaces,
44
+ responseType
45
+ });
46
+ transformBodyStringify("body", {
47
+ options,
48
+ parameters
49
+ });
50
+ transformQueryParams("query", {
51
+ optionKey: "searchParams",
52
+ options
53
+ });
54
+ url = transformUrlSyntax(url);
55
+ functions.push({
56
+ export: true,
57
+ async: true,
58
+ name,
59
+ description,
60
+ parameters,
61
+ body: [`const response = await http(${url}, {
62
+ ${literalFieldsToString(options)}
63
+ })`, "return response.json()"]
64
+ });
65
+ });
66
+ }
67
+
68
+ //#endregion
69
+ export { parser as parser$3, transformPaths as transformPaths$3 };
@@ -0,0 +1,77 @@
1
+ import { literalFieldsToString, parseHeaderCommits, parseMethodMetadata, parseMethodParameters, parseOpenapiSpecification, transformBaseURL, transformBodyStringify, transformDefinitions, transformHeaderOptions, transformParameters, transformQueryParams, transformUrlSyntax, traversePaths } from "@genapi/parser";
2
+
3
+ //#region src/fetch/js/parser/index.ts
4
+ function parser(configRead) {
5
+ const source = parseOpenapiSpecification(configRead.source);
6
+ const comments = parseHeaderCommits(source);
7
+ const interfaces = [];
8
+ const functions = [];
9
+ transformBaseURL(source, { configRead });
10
+ transformDefinitions(source.definitions, { interfaces });
11
+ transformPaths(source.paths, {
12
+ configRead,
13
+ functions,
14
+ interfaces
15
+ });
16
+ configRead.graphs.comments = comments;
17
+ configRead.graphs.functions = functions;
18
+ configRead.graphs.interfaces = interfaces;
19
+ return configRead;
20
+ }
21
+ function transformPaths(paths, { configRead, functions, interfaces }) {
22
+ traversePaths(paths, (config) => {
23
+ /**
24
+
25
+ * function params/function options/function use interfaces
26
+
27
+ */
28
+ const { parameters, interfaces: attachInters, options } = parseMethodParameters(config, { formData: "body" });
29
+ let { name, description, url, responseType, body } = parseMethodMetadata(config);
30
+ interfaces.push(...attachInters);
31
+ parameters.push({
32
+ name: "config",
33
+ type: "RequestInit",
34
+ required: false
35
+ });
36
+ if (config.method.toLowerCase() !== "get") options.unshift(["method", `"${config.method}"`]);
37
+ transformHeaderOptions("body", {
38
+ options,
39
+ parameters
40
+ });
41
+ options.push(["...", "config"]);
42
+ transformParameters(parameters, {
43
+ syntax: "ecmascript",
44
+ configRead,
45
+ description,
46
+ interfaces,
47
+ responseType
48
+ });
49
+ transformBodyStringify("body", {
50
+ options,
51
+ parameters
52
+ });
53
+ url = transformQueryParams("query", {
54
+ body,
55
+ options,
56
+ url
57
+ });
58
+ url = transformUrlSyntax(url, { baseURL: configRead.config.baseURL });
59
+ functions.push({
60
+ export: true,
61
+ async: true,
62
+ name,
63
+ description,
64
+ parameters,
65
+ body: [
66
+ ...body,
67
+ `const response = await fetch(${url}, {
68
+ ${literalFieldsToString(options)}
69
+ })`,
70
+ "return response.json()"
71
+ ]
72
+ });
73
+ });
74
+ }
75
+
76
+ //#endregion
77
+ export { parser as parser$2, transformPaths as transformPaths$2 };
@@ -0,0 +1,69 @@
1
+ import { literalFieldsToString, parseHeaderCommits, parseMethodMetadata, parseMethodParameters, parseOpenapiSpecification, transformBaseURL, transformBodyStringify, transformDefinitions, transformParameters, transformQueryParams, transformUrlSyntax, traversePaths } from "@genapi/parser";
2
+
3
+ //#region src/ky/js/parser/index.ts
4
+ function parser(configRead) {
5
+ const source = parseOpenapiSpecification(configRead.source);
6
+ const comments = parseHeaderCommits(source);
7
+ const interfaces = [];
8
+ const functions = [];
9
+ transformBaseURL(source, { configRead });
10
+ transformDefinitions(source.definitions, { interfaces });
11
+ transformPaths(source.paths, {
12
+ configRead,
13
+ functions,
14
+ interfaces
15
+ });
16
+ configRead.graphs.comments = comments;
17
+ configRead.graphs.functions = functions;
18
+ configRead.graphs.interfaces = interfaces;
19
+ return configRead;
20
+ }
21
+ function transformPaths(paths, { configRead, functions, interfaces }) {
22
+ traversePaths(paths, (config) => {
23
+ /**
24
+
25
+ * function params/function options/function use interfaces
26
+
27
+ */
28
+ const { parameters, interfaces: attachInters, options } = parseMethodParameters(config);
29
+ let { name, description, url, responseType } = parseMethodMetadata(config);
30
+ interfaces.push(...attachInters);
31
+ parameters.push({
32
+ name: "config",
33
+ type: "import('ky').Options",
34
+ required: false
35
+ });
36
+ options.push(["...", "config"]);
37
+ if (configRead.config.baseURL) options.unshift(["prefixUrl", "baseURL"]);
38
+ transformParameters(parameters, {
39
+ syntax: "ecmascript",
40
+ configRead,
41
+ description,
42
+ interfaces,
43
+ responseType,
44
+ generic: "import('ky').KyResponse<{__type__}>"
45
+ });
46
+ transformBodyStringify("body", {
47
+ options,
48
+ parameters
49
+ });
50
+ transformQueryParams("query", {
51
+ optionKey: "searchParams",
52
+ options
53
+ });
54
+ url = transformUrlSyntax(url);
55
+ functions.push({
56
+ export: true,
57
+ async: true,
58
+ name,
59
+ description,
60
+ parameters,
61
+ body: [`const response = await http(${url}, {
62
+ ${literalFieldsToString(options)}
63
+ })`, "return response.json()"]
64
+ });
65
+ });
66
+ }
67
+
68
+ //#endregion
69
+ export { parser as parser$6, transformPaths as transformPaths$6 };
@@ -0,0 +1,67 @@
1
+ import { literalFieldsToString, parseHeaderCommits, parseMethodMetadata, parseMethodParameters, parseOpenapiSpecification, transformBaseURL, transformDefinitions, transformParameters, transformQueryParams, transformUrlSyntax, traversePaths } from "@genapi/parser";
2
+
3
+ //#region src/ofetch/js/parser/index.ts
4
+ function parser(configRead) {
5
+ const source = parseOpenapiSpecification(configRead.source);
6
+ const comments = parseHeaderCommits(source);
7
+ const interfaces = [];
8
+ const functions = [];
9
+ transformBaseURL(source, { configRead });
10
+ transformDefinitions(source.definitions, { interfaces });
11
+ transformPaths(source.paths, {
12
+ configRead,
13
+ functions,
14
+ interfaces
15
+ });
16
+ configRead.graphs.comments = comments;
17
+ configRead.graphs.functions = functions;
18
+ configRead.graphs.interfaces = interfaces;
19
+ return configRead;
20
+ }
21
+ function transformPaths(paths, { configRead, functions, interfaces }) {
22
+ traversePaths(paths, (config) => {
23
+ /**
24
+
25
+ * function params/function options/function use interfaces
26
+
27
+ */
28
+ const { parameters, interfaces: attachInters, options } = parseMethodParameters(config, {
29
+ formData: "body",
30
+ query: "params"
31
+ });
32
+ let { name, description, url, responseType, body } = parseMethodMetadata(config);
33
+ interfaces.push(...attachInters);
34
+ parameters.push({
35
+ name: "options",
36
+ type: "import('ofetch').FetchOptions",
37
+ required: false
38
+ });
39
+ options.push(["...", "options"]);
40
+ options.unshift(["method", `"${config.method}"`]);
41
+ if (configRead.config.baseURL) options.unshift("baseURL");
42
+ transformParameters(parameters, {
43
+ syntax: "ecmascript",
44
+ configRead,
45
+ description,
46
+ interfaces,
47
+ responseType
48
+ });
49
+ url = transformQueryParams("query", {
50
+ body,
51
+ options,
52
+ url
53
+ });
54
+ url = transformUrlSyntax(url, { baseURL: configRead.config.baseURL });
55
+ functions.push({
56
+ export: true,
57
+ async: true,
58
+ name,
59
+ description,
60
+ parameters,
61
+ body: [...body, `return ofetch(${url}, {${literalFieldsToString(options)}})`]
62
+ });
63
+ });
64
+ }
65
+
66
+ //#endregion
67
+ export { parser as parser$8, transformPaths as transformPaths$8 };