@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.
- package/LICENSE.md +21 -21
- package/README.md +36 -108
- package/dist/_shared/query/config.d.mts +14 -0
- package/dist/_shared/query/config.mjs +58 -0
- package/dist/_shared/query/index.d.mts +3 -0
- package/dist/_shared/query/index.mjs +4 -0
- package/dist/_shared/query/parser.d.mts +7 -0
- package/dist/_shared/query/parser.mjs +75 -0
- package/dist/_shared/schema/compiler.mjs +8 -6
- package/dist/_shared/schema/config.mjs +8 -5
- package/dist/axios/js/config/index.mjs +3 -1
- package/dist/axios/js/parser/index.mjs +3 -3
- package/dist/axios/ts/config/index.mjs +4 -2
- package/dist/axios/ts/parser/index.mjs +3 -3
- package/dist/fetch/js/parser/index.mjs +3 -3
- package/dist/fetch/schema/index.d.mts +1 -0
- package/dist/fetch/schema/parser/index.d.mts +1 -0
- package/dist/fetch/ts/parser/index.mjs +3 -3
- package/dist/got/js/config/index.mjs +3 -1
- package/dist/got/js/parser/index.mjs +3 -3
- package/dist/got/ts/config/index.mjs +4 -2
- package/dist/got/ts/parser/index.mjs +3 -3
- package/dist/index.d.mts +10 -7
- package/dist/index.mjs +11 -8
- package/dist/ky/js/config/index.mjs +3 -1
- package/dist/ky/js/parser/index.mjs +3 -3
- package/dist/ky/ts/config/index.mjs +4 -2
- package/dist/ky/ts/parser/index.mjs +3 -3
- package/dist/ofetch/js/config/index.mjs +3 -1
- package/dist/ofetch/js/parser/index.mjs +3 -3
- package/dist/ofetch/schema/index.d.mts +1 -0
- package/dist/ofetch/schema/parser/index.d.mts +1 -0
- package/dist/ofetch/ts/config/index.mjs +4 -2
- package/dist/ofetch/ts/parser/index.mjs +3 -3
- package/dist/tanstack/colada/config/index.d.mts +2 -2
- package/dist/tanstack/colada/config/index.mjs +2 -11
- package/dist/tanstack/colada/index.d.mts +1 -1
- package/dist/tanstack/colada/parser/index.mjs +2 -66
- package/dist/tanstack/react/config/index.d.mts +2 -2
- package/dist/tanstack/react/config/index.mjs +2 -11
- package/dist/tanstack/react/index.d.mts +1 -1
- package/dist/tanstack/react/parser/index.mjs +2 -70
- package/dist/tanstack/vue/config/index.d.mts +2 -2
- package/dist/tanstack/vue/config/index.mjs +2 -11
- package/dist/tanstack/vue/index.d.mts +1 -1
- package/dist/tanstack/vue/parser/index.mjs +2 -66
- package/dist/uni/js/config/index.mjs +3 -1
- package/dist/uni/js/parser/index.mjs +3 -3
- package/dist/uni/ts/config/index.mjs +4 -2
- package/dist/uni/ts/parser/index.mjs +3 -3
- package/package.json +5 -5
|
@@ -4,7 +4,7 @@ import { createParser, literalFieldsToString, parseMethodMetadata, parseMethodPa
|
|
|
4
4
|
const parser = createParser((config, { configRead, functions, interfaces }) => {
|
|
5
5
|
const { parameters, interfaces: attachInters, options } = parseMethodParameters(config);
|
|
6
6
|
let { name, description, url, responseType } = parseMethodMetadata(config);
|
|
7
|
-
interfaces.
|
|
7
|
+
attachInters.forEach((i) => interfaces.add("type", i));
|
|
8
8
|
parameters.push({
|
|
9
9
|
name: "config",
|
|
10
10
|
type: "OptionsOfTextResponseBody",
|
|
@@ -17,7 +17,7 @@ const parser = createParser((config, { configRead, functions, interfaces }) => {
|
|
|
17
17
|
syntax: "typescript",
|
|
18
18
|
configRead,
|
|
19
19
|
description,
|
|
20
|
-
interfaces,
|
|
20
|
+
interfaces: interfaces.all(),
|
|
21
21
|
responseType
|
|
22
22
|
});
|
|
23
23
|
transformBodyStringify("body", {
|
|
@@ -29,7 +29,7 @@ const parser = createParser((config, { configRead, functions, interfaces }) => {
|
|
|
29
29
|
options
|
|
30
30
|
});
|
|
31
31
|
url = transformUrlSyntax(url);
|
|
32
|
-
functions.
|
|
32
|
+
functions.add("main", {
|
|
33
33
|
export: true,
|
|
34
34
|
async: true,
|
|
35
35
|
name,
|
package/dist/index.d.mts
CHANGED
|
@@ -3,24 +3,27 @@ import { t as index_d_exports$1 } from "./fetch/index.mjs";
|
|
|
3
3
|
import { t as index_d_exports$2 } from "./got/index.mjs";
|
|
4
4
|
import { t as index_d_exports$3 } from "./ky/index.mjs";
|
|
5
5
|
import { t as index_d_exports$4 } from "./ofetch/index.mjs";
|
|
6
|
-
import openapiPipeline from "./tanstack/colada/index.mjs";
|
|
7
6
|
import { t as index_d_exports$5 } from "./tanstack/index.mjs";
|
|
8
7
|
import { t as index_d_exports$6 } from "./uni/index.mjs";
|
|
9
8
|
|
|
10
9
|
//#region src/index.d.ts
|
|
11
10
|
/**
|
|
12
11
|
* Preset pipelines by HTTP client: axios, fetch, ky, got, ofetch, tanstack (react/vue/colada), uni.
|
|
13
|
-
* Each key
|
|
12
|
+
* @description Each key exposes `.ts` and `.js` pipeline modules (e.g. use `@genapi/presets/swag-axios-ts`).
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import presets from '@genapi/presets'
|
|
16
|
+
* // presets.axios, presets.fetch, presets.ofetch, presets.tanstackQuery, presets.uni, presets.colada
|
|
17
|
+
* ```
|
|
14
18
|
*/
|
|
15
19
|
declare const _default: {
|
|
20
|
+
tanstackQuery: typeof index_d_exports$5;
|
|
21
|
+
ofetch: typeof index_d_exports$4;
|
|
16
22
|
axios: typeof index_d_exports;
|
|
17
|
-
colada: typeof openapiPipeline;
|
|
18
23
|
fetch: typeof index_d_exports$1;
|
|
24
|
+
uni: typeof index_d_exports$6;
|
|
19
25
|
got: typeof index_d_exports$2;
|
|
20
26
|
ky: typeof index_d_exports$3;
|
|
21
|
-
ofetch: typeof index_d_exports$4;
|
|
22
|
-
tanstackQuery: typeof index_d_exports$5;
|
|
23
|
-
uni: typeof index_d_exports$6;
|
|
24
27
|
};
|
|
25
28
|
//#endregion
|
|
26
|
-
export { index_d_exports as axios,
|
|
29
|
+
export { index_d_exports as axios, _default as default, index_d_exports$1 as fetch, index_d_exports$2 as got, index_d_exports$3 as ky, index_d_exports$4 as ofetch, index_d_exports$5 as tanstackQuery, index_d_exports$6 as uni };
|
package/dist/index.mjs
CHANGED
|
@@ -3,25 +3,28 @@ import { t as fetch_exports } from "./fetch/index.mjs";
|
|
|
3
3
|
import { t as got_exports } from "./got/index.mjs";
|
|
4
4
|
import { t as ky_exports } from "./ky/index.mjs";
|
|
5
5
|
import { t as ofetch_exports } from "./ofetch/index.mjs";
|
|
6
|
-
import openapiPipeline from "./tanstack/colada/index.mjs";
|
|
7
6
|
import { t as tanstack_exports } from "./tanstack/index.mjs";
|
|
8
7
|
import { t as uni_exports } from "./uni/index.mjs";
|
|
9
8
|
|
|
10
9
|
//#region src/index.ts
|
|
11
10
|
/**
|
|
12
11
|
* Preset pipelines by HTTP client: axios, fetch, ky, got, ofetch, tanstack (react/vue/colada), uni.
|
|
13
|
-
* Each key
|
|
12
|
+
* @description Each key exposes `.ts` and `.js` pipeline modules (e.g. use `@genapi/presets/swag-axios-ts`).
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import presets from '@genapi/presets'
|
|
16
|
+
* // presets.axios, presets.fetch, presets.ofetch, presets.tanstackQuery, presets.uni, presets.colada
|
|
17
|
+
* ```
|
|
14
18
|
*/
|
|
15
19
|
var src_default = {
|
|
20
|
+
tanstackQuery: tanstack_exports,
|
|
21
|
+
ofetch: ofetch_exports,
|
|
16
22
|
axios: axios_exports,
|
|
17
|
-
colada: openapiPipeline,
|
|
18
23
|
fetch: fetch_exports,
|
|
24
|
+
uni: uni_exports,
|
|
19
25
|
got: got_exports,
|
|
20
|
-
ky: ky_exports
|
|
21
|
-
ofetch: ofetch_exports,
|
|
22
|
-
tanstackQuery: tanstack_exports,
|
|
23
|
-
uni: uni_exports
|
|
26
|
+
ky: ky_exports
|
|
24
27
|
};
|
|
25
28
|
|
|
26
29
|
//#endregion
|
|
27
|
-
export { axios_exports as axios,
|
|
30
|
+
export { axios_exports as axios, src_default as default, fetch_exports as fetch, got_exports as got, ky_exports as ky, ofetch_exports as ofetch, tanstack_exports as tanstackQuery, uni_exports as uni };
|
|
@@ -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/ky/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 || "ky";
|
|
10
11
|
userConfig.output = replaceMainext(userConfig.output) || "src/api/index.js";
|
|
11
12
|
const configRead = config$1(userConfig);
|
|
12
|
-
|
|
13
|
+
const { imports } = inject();
|
|
14
|
+
imports.add("main", {
|
|
13
15
|
name: "http",
|
|
14
16
|
value: userConfig.meta.import.http
|
|
15
17
|
});
|
|
@@ -4,7 +4,7 @@ import { createParser, literalFieldsToString, parseMethodMetadata, parseMethodPa
|
|
|
4
4
|
const parser = createParser((config, { configRead, functions, interfaces }) => {
|
|
5
5
|
const { parameters, interfaces: attachInters, options } = parseMethodParameters(config);
|
|
6
6
|
let { name, description, url, responseType } = parseMethodMetadata(config);
|
|
7
|
-
interfaces.
|
|
7
|
+
attachInters.forEach((i) => interfaces.add("type", i));
|
|
8
8
|
parameters.push({
|
|
9
9
|
name: "config",
|
|
10
10
|
type: "import('ky').Options",
|
|
@@ -16,7 +16,7 @@ const parser = createParser((config, { configRead, functions, interfaces }) => {
|
|
|
16
16
|
syntax: "ecmascript",
|
|
17
17
|
configRead,
|
|
18
18
|
description,
|
|
19
|
-
interfaces,
|
|
19
|
+
interfaces: interfaces.all(),
|
|
20
20
|
responseType,
|
|
21
21
|
generic: "import('ky').KyResponse<{__type__}>"
|
|
22
22
|
});
|
|
@@ -29,7 +29,7 @@ const parser = createParser((config, { configRead, functions, interfaces }) => {
|
|
|
29
29
|
options
|
|
30
30
|
});
|
|
31
31
|
url = transformUrlSyntax(url);
|
|
32
|
-
functions.
|
|
32
|
+
functions.add("main", {
|
|
33
33
|
export: true,
|
|
34
34
|
async: true,
|
|
35
35
|
name,
|
|
@@ -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/ky/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 || "ky";
|
|
8
9
|
const configRead = config$1(userConfig);
|
|
9
|
-
|
|
10
|
+
const { imports } = inject();
|
|
11
|
+
imports.add("main", {
|
|
10
12
|
name: "http",
|
|
11
13
|
names: userConfig.meta.import.http === "ky" ? ["Options"] : void 0,
|
|
12
14
|
value: userConfig.meta.import.http
|
|
13
15
|
});
|
|
14
|
-
if (userConfig.meta.import.http !== "ky")
|
|
16
|
+
if (userConfig.meta.import.http !== "ky") imports.add("main", {
|
|
15
17
|
names: ["Options"],
|
|
16
18
|
value: "ky"
|
|
17
19
|
});
|
|
@@ -4,7 +4,7 @@ import { createParser, literalFieldsToString, parseMethodMetadata, parseMethodPa
|
|
|
4
4
|
const parser = createParser((config, { configRead, functions, interfaces }) => {
|
|
5
5
|
const { parameters, interfaces: attachInters, options } = parseMethodParameters(config);
|
|
6
6
|
let { name, description, url, responseType } = parseMethodMetadata(config);
|
|
7
|
-
interfaces.
|
|
7
|
+
attachInters.forEach((i) => interfaces.add("type", i));
|
|
8
8
|
parameters.push({
|
|
9
9
|
name: "config",
|
|
10
10
|
type: "Options",
|
|
@@ -16,7 +16,7 @@ const parser = createParser((config, { configRead, functions, interfaces }) => {
|
|
|
16
16
|
syntax: "typescript",
|
|
17
17
|
configRead,
|
|
18
18
|
description,
|
|
19
|
-
interfaces,
|
|
19
|
+
interfaces: interfaces.all(),
|
|
20
20
|
responseType
|
|
21
21
|
});
|
|
22
22
|
transformBodyStringify("body", {
|
|
@@ -28,7 +28,7 @@ const parser = createParser((config, { configRead, functions, interfaces }) => {
|
|
|
28
28
|
options
|
|
29
29
|
});
|
|
30
30
|
url = transformUrlSyntax(url);
|
|
31
|
-
functions.
|
|
31
|
+
functions.add("main", {
|
|
32
32
|
export: true,
|
|
33
33
|
async: true,
|
|
34
34
|
name,
|
|
@@ -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/ofetch/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 || "ofetch";
|
|
10
11
|
userConfig.output = replaceMainext(userConfig.output) || "src/api/index.js";
|
|
11
12
|
const configRead = config$1(userConfig);
|
|
12
|
-
|
|
13
|
+
const { imports } = inject();
|
|
14
|
+
imports.add("main", {
|
|
13
15
|
value: userConfig.meta.import.http,
|
|
14
16
|
names: ["ofetch"]
|
|
15
17
|
});
|
|
@@ -7,7 +7,7 @@ const parser = createParser((config, { configRead, functions, interfaces }) => {
|
|
|
7
7
|
query: "params"
|
|
8
8
|
});
|
|
9
9
|
let { name, description, url, responseType, body } = parseMethodMetadata(config);
|
|
10
|
-
interfaces.
|
|
10
|
+
attachInters.forEach((i) => interfaces.add("type", i));
|
|
11
11
|
parameters.push({
|
|
12
12
|
name: "options",
|
|
13
13
|
type: "import('ofetch').FetchOptions",
|
|
@@ -20,7 +20,7 @@ const parser = createParser((config, { configRead, functions, interfaces }) => {
|
|
|
20
20
|
syntax: "ecmascript",
|
|
21
21
|
configRead,
|
|
22
22
|
description,
|
|
23
|
-
interfaces,
|
|
23
|
+
interfaces: interfaces.all(),
|
|
24
24
|
responseType
|
|
25
25
|
});
|
|
26
26
|
url = transformQueryParams("query", {
|
|
@@ -29,7 +29,7 @@ const parser = createParser((config, { configRead, functions, interfaces }) => {
|
|
|
29
29
|
url
|
|
30
30
|
});
|
|
31
31
|
url = transformUrlSyntax(url, { baseURL: configRead.config.meta?.baseURL });
|
|
32
|
-
functions.
|
|
32
|
+
functions.add("main", {
|
|
33
33
|
export: true,
|
|
34
34
|
async: true,
|
|
35
35
|
name,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { schemaParser } from "../../_shared/schema/parser.mjs";
|
|
2
2
|
import { compiler } from "./compiler/index.mjs";
|
|
3
3
|
import { config } from "./config/index.mjs";
|
|
4
|
+
import "./parser/index.mjs";
|
|
4
5
|
import * as _genapi_pipeline0 from "@genapi/pipeline";
|
|
5
6
|
import { dest, generate, original } from "@genapi/pipeline";
|
|
6
7
|
import { ApiPipeline } from "@genapi/shared";
|
|
@@ -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/ofetch/ts/config/index.ts
|
|
4
5
|
function config(userConfig) {
|
|
@@ -6,11 +7,12 @@ function config(userConfig) {
|
|
|
6
7
|
userConfig.meta.import = userConfig.meta.import || {};
|
|
7
8
|
userConfig.meta.import.http = userConfig.meta.import.http || "ofetch";
|
|
8
9
|
const configRead = config$1(userConfig);
|
|
9
|
-
|
|
10
|
+
const { imports } = inject();
|
|
11
|
+
imports.add("main", {
|
|
10
12
|
names: userConfig.meta.import.http === "ofetch" ? ["FetchOptions", "ofetch"] : ["ofetch"],
|
|
11
13
|
value: userConfig.meta.import.http
|
|
12
14
|
});
|
|
13
|
-
if (userConfig.meta.import.http !== "ofetch")
|
|
15
|
+
if (userConfig.meta.import.http !== "ofetch") imports.add("main", {
|
|
14
16
|
names: ["FetchOptions"],
|
|
15
17
|
value: "ofetch"
|
|
16
18
|
});
|
|
@@ -7,7 +7,7 @@ const parser = createParser((config, { configRead, functions, interfaces }) => {
|
|
|
7
7
|
query: "params"
|
|
8
8
|
});
|
|
9
9
|
let { name, description, url, responseType, body } = parseMethodMetadata(config);
|
|
10
|
-
interfaces.
|
|
10
|
+
attachInters.forEach((i) => interfaces.add("type", i));
|
|
11
11
|
parameters.push({
|
|
12
12
|
name: "options",
|
|
13
13
|
type: "FetchOptions",
|
|
@@ -20,7 +20,7 @@ const parser = createParser((config, { configRead, functions, interfaces }) => {
|
|
|
20
20
|
syntax: "typescript",
|
|
21
21
|
configRead,
|
|
22
22
|
description,
|
|
23
|
-
interfaces,
|
|
23
|
+
interfaces: interfaces.all(),
|
|
24
24
|
responseType
|
|
25
25
|
});
|
|
26
26
|
url = transformQueryParams("query", {
|
|
@@ -29,7 +29,7 @@ const parser = createParser((config, { configRead, functions, interfaces }) => {
|
|
|
29
29
|
url
|
|
30
30
|
});
|
|
31
31
|
url = transformUrlSyntax(url);
|
|
32
|
-
functions.
|
|
32
|
+
functions.add("main", {
|
|
33
33
|
export: true,
|
|
34
34
|
name,
|
|
35
35
|
description,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _genapi_shared0 from "@genapi/shared";
|
|
2
2
|
|
|
3
3
|
//#region src/tanstack/colada/config/index.d.ts
|
|
4
|
-
declare
|
|
4
|
+
declare const config: (userConfig: _genapi_shared0.ApiPipeline.Config) => _genapi_shared0.ApiPipeline.ConfigRead;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { config };
|
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createQueryConfig } from "../../../_shared/query/config.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/tanstack/colada/config/index.ts
|
|
4
|
-
|
|
5
|
-
userConfig.meta = userConfig.meta || {};
|
|
6
|
-
userConfig.meta.import = userConfig.meta.import || {};
|
|
7
|
-
const configRead = config$1(userConfig);
|
|
8
|
-
configRead.graphs.imports.push({
|
|
9
|
-
names: ["useQuery", "useMutation"],
|
|
10
|
-
value: "@pinia/colada"
|
|
11
|
-
});
|
|
12
|
-
return configRead;
|
|
13
|
-
}
|
|
4
|
+
const config = createQueryConfig("@pinia/colada");
|
|
14
5
|
|
|
15
6
|
//#endregion
|
|
16
7
|
export { config };
|
|
@@ -7,7 +7,7 @@ import { ApiPipeline } from "@genapi/shared";
|
|
|
7
7
|
//#region src/tanstack/colada/index.d.ts
|
|
8
8
|
declare function openapiPipeline(userConfig: ApiPipeline.Config): Promise<void>;
|
|
9
9
|
declare namespace openapiPipeline {
|
|
10
|
-
var config:
|
|
10
|
+
var config: (userConfig: ApiPipeline.Config) => ApiPipeline.ConfigRead;
|
|
11
11
|
var original: typeof _genapi_pipeline0.original;
|
|
12
12
|
var parser: (configRead: ApiPipeline.ConfigRead) => ApiPipeline.ConfigRead;
|
|
13
13
|
var compiler: typeof _genapi_pipeline0.compiler;
|
|
@@ -1,71 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createQueryParser } from "../../../_shared/query/parser.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/tanstack/colada/parser/index.ts
|
|
4
|
-
|
|
5
|
-
return `use${fetcherName.charAt(0).toUpperCase()}${fetcherName.slice(1)}`;
|
|
6
|
-
}
|
|
7
|
-
const parser = createParser((config, { configRead, functions, interfaces }) => {
|
|
8
|
-
const { parameters, interfaces: attachInters, options } = parseMethodParameters(config);
|
|
9
|
-
let { name, description, url, responseType, body } = parseMethodMetadata(config);
|
|
10
|
-
interfaces.push(...attachInters);
|
|
11
|
-
const fetcherParams = [...parameters];
|
|
12
|
-
fetcherParams.push({
|
|
13
|
-
name: "config",
|
|
14
|
-
type: "RequestInit",
|
|
15
|
-
required: false
|
|
16
|
-
});
|
|
17
|
-
if (config.method.toLowerCase() !== "get") options.unshift(["method", `"${config.method}"`]);
|
|
18
|
-
transformHeaderOptions("body", {
|
|
19
|
-
options,
|
|
20
|
-
parameters
|
|
21
|
-
});
|
|
22
|
-
options.push(["...", "config"]);
|
|
23
|
-
const { spaceResponseType } = transformParameters(parameters, {
|
|
24
|
-
syntax: "typescript",
|
|
25
|
-
configRead,
|
|
26
|
-
description,
|
|
27
|
-
interfaces,
|
|
28
|
-
responseType
|
|
29
|
-
});
|
|
30
|
-
transformBodyStringify("body", {
|
|
31
|
-
options,
|
|
32
|
-
parameters
|
|
33
|
-
});
|
|
34
|
-
url = transformQueryParams("query", {
|
|
35
|
-
body,
|
|
36
|
-
options,
|
|
37
|
-
url
|
|
38
|
-
});
|
|
39
|
-
url = transformUrlSyntax(url, { baseURL: configRead.config.meta?.baseURL });
|
|
40
|
-
const fetchBody = transformFetchBody(url, options, spaceResponseType);
|
|
41
|
-
functions.push({
|
|
42
|
-
export: true,
|
|
43
|
-
async: true,
|
|
44
|
-
name,
|
|
45
|
-
description,
|
|
46
|
-
parameters: fetcherParams,
|
|
47
|
-
body: [...body, ...fetchBody]
|
|
48
|
-
});
|
|
49
|
-
const isRead = ["get", "head"].includes(config.method.toLowerCase());
|
|
50
|
-
const hook = hookName(name);
|
|
51
|
-
const paramNames = fetcherParams.map((p) => p.name).join(", ");
|
|
52
|
-
if (isRead) {
|
|
53
|
-
const keyItems = `'${name}', ${paramNames}`;
|
|
54
|
-
functions.push({
|
|
55
|
-
export: true,
|
|
56
|
-
name: hook,
|
|
57
|
-
description: [`@wraps ${name}`],
|
|
58
|
-
parameters: fetcherParams,
|
|
59
|
-
body: [`return useQuery({ key: [${keyItems}], query: () => ${name}(${paramNames}) })`]
|
|
60
|
-
});
|
|
61
|
-
} else functions.push({
|
|
62
|
-
export: true,
|
|
63
|
-
name: hook,
|
|
64
|
-
description: description ? [...Array.isArray(description) ? description : [description], `@wraps ${name}`] : [`@wraps ${name}`],
|
|
65
|
-
parameters: [],
|
|
66
|
-
body: [`return useMutation({ mutation: ${name} })`]
|
|
67
|
-
});
|
|
68
|
-
});
|
|
4
|
+
const parser = createQueryParser();
|
|
69
5
|
|
|
70
6
|
//#endregion
|
|
71
7
|
export { parser };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _genapi_shared0 from "@genapi/shared";
|
|
2
2
|
|
|
3
3
|
//#region src/tanstack/react/config/index.d.ts
|
|
4
|
-
declare
|
|
4
|
+
declare const config: (userConfig: _genapi_shared0.ApiPipeline.Config) => _genapi_shared0.ApiPipeline.ConfigRead;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { config };
|
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createQueryConfig } from "../../../_shared/query/config.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/tanstack/react/config/index.ts
|
|
4
|
-
|
|
5
|
-
userConfig.meta = userConfig.meta || {};
|
|
6
|
-
userConfig.meta.import = userConfig.meta.import || {};
|
|
7
|
-
const configRead = config$1(userConfig);
|
|
8
|
-
configRead.graphs.imports.push({
|
|
9
|
-
names: ["useQuery", "useMutation"],
|
|
10
|
-
value: "@tanstack/react-query"
|
|
11
|
-
});
|
|
12
|
-
return configRead;
|
|
13
|
-
}
|
|
4
|
+
const config = createQueryConfig("@tanstack/react-query");
|
|
14
5
|
|
|
15
6
|
//#endregion
|
|
16
7
|
export { config };
|
|
@@ -7,7 +7,7 @@ import { ApiPipeline } from "@genapi/shared";
|
|
|
7
7
|
//#region src/tanstack/react/index.d.ts
|
|
8
8
|
declare function openapiPipeline(userConfig: ApiPipeline.Config): Promise<void>;
|
|
9
9
|
declare namespace openapiPipeline {
|
|
10
|
-
var config:
|
|
10
|
+
var config: (userConfig: ApiPipeline.Config) => ApiPipeline.ConfigRead;
|
|
11
11
|
var original: typeof _genapi_pipeline0.original;
|
|
12
12
|
var parser: (configRead: ApiPipeline.ConfigRead) => ApiPipeline.ConfigRead;
|
|
13
13
|
var compiler: typeof _genapi_pipeline0.compiler;
|
|
@@ -1,75 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createQueryParser } from "../../../_shared/query/parser.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/tanstack/react/parser/index.ts
|
|
4
|
-
|
|
5
|
-
return `use${fetcherName.charAt(0).toUpperCase()}${fetcherName.slice(1)}`;
|
|
6
|
-
}
|
|
7
|
-
const parser = createParser((config, { configRead, functions, interfaces }) => {
|
|
8
|
-
const { parameters, interfaces: attachInters, options } = parseMethodParameters(config);
|
|
9
|
-
let { name, description, url, responseType, body } = parseMethodMetadata(config);
|
|
10
|
-
interfaces.push(...attachInters);
|
|
11
|
-
const fetcherParams = [...parameters];
|
|
12
|
-
fetcherParams.push({
|
|
13
|
-
name: "config",
|
|
14
|
-
type: "RequestInit",
|
|
15
|
-
required: false
|
|
16
|
-
});
|
|
17
|
-
if (config.method.toLowerCase() !== "get") options.unshift(["method", `"${config.method}"`]);
|
|
18
|
-
transformHeaderOptions("body", {
|
|
19
|
-
options,
|
|
20
|
-
parameters
|
|
21
|
-
});
|
|
22
|
-
options.push(["...", "config"]);
|
|
23
|
-
const { spaceResponseType } = transformParameters(parameters, {
|
|
24
|
-
syntax: "typescript",
|
|
25
|
-
configRead,
|
|
26
|
-
description,
|
|
27
|
-
interfaces,
|
|
28
|
-
responseType
|
|
29
|
-
});
|
|
30
|
-
transformBodyStringify("body", {
|
|
31
|
-
options,
|
|
32
|
-
parameters
|
|
33
|
-
});
|
|
34
|
-
url = transformQueryParams("query", {
|
|
35
|
-
body,
|
|
36
|
-
options,
|
|
37
|
-
url
|
|
38
|
-
});
|
|
39
|
-
url = transformUrlSyntax(url, { baseURL: configRead.config.meta?.baseURL });
|
|
40
|
-
const fetchBody = transformFetchBody(url, options, spaceResponseType);
|
|
41
|
-
functions.push({
|
|
42
|
-
export: true,
|
|
43
|
-
async: true,
|
|
44
|
-
name,
|
|
45
|
-
description,
|
|
46
|
-
parameters: fetcherParams,
|
|
47
|
-
body: [...body, ...fetchBody]
|
|
48
|
-
});
|
|
49
|
-
const isRead = ["get", "head"].includes(config.method.toLowerCase());
|
|
50
|
-
const hook = hookName(name);
|
|
51
|
-
const paramNames = fetcherParams.map((p) => p.name).join(", ");
|
|
52
|
-
if (isRead) {
|
|
53
|
-
const queryKeyItems = `'${name}', ${paramNames}`;
|
|
54
|
-
functions.push({
|
|
55
|
-
export: true,
|
|
56
|
-
name: hook,
|
|
57
|
-
description: [`@wraps ${name}`],
|
|
58
|
-
parameters: fetcherParams,
|
|
59
|
-
body: [`return useQuery({
|
|
60
|
-
queryKey: [${queryKeyItems}],
|
|
61
|
-
queryFn: () => ${name}(${paramNames}),
|
|
62
|
-
...config,
|
|
63
|
-
})`]
|
|
64
|
-
});
|
|
65
|
-
} else functions.push({
|
|
66
|
-
export: true,
|
|
67
|
-
name: hook,
|
|
68
|
-
description: [`@wraps ${name}`],
|
|
69
|
-
parameters: [],
|
|
70
|
-
body: [`return useMutation({ mutationFn: ${name} })`]
|
|
71
|
-
});
|
|
72
|
-
});
|
|
4
|
+
const parser = createQueryParser();
|
|
73
5
|
|
|
74
6
|
//#endregion
|
|
75
7
|
export { parser };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _genapi_shared0 from "@genapi/shared";
|
|
2
2
|
|
|
3
3
|
//#region src/tanstack/vue/config/index.d.ts
|
|
4
|
-
declare
|
|
4
|
+
declare const config: (userConfig: _genapi_shared0.ApiPipeline.Config) => _genapi_shared0.ApiPipeline.ConfigRead;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { config };
|
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createQueryConfig } from "../../../_shared/query/config.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/tanstack/vue/config/index.ts
|
|
4
|
-
|
|
5
|
-
userConfig.meta = userConfig.meta || {};
|
|
6
|
-
userConfig.meta.import = userConfig.meta.import || {};
|
|
7
|
-
const configRead = config$1(userConfig);
|
|
8
|
-
configRead.graphs.imports.push({
|
|
9
|
-
names: ["useQuery", "useMutation"],
|
|
10
|
-
value: "@tanstack/vue-query"
|
|
11
|
-
});
|
|
12
|
-
return configRead;
|
|
13
|
-
}
|
|
4
|
+
const config = createQueryConfig("@tanstack/vue-query");
|
|
14
5
|
|
|
15
6
|
//#endregion
|
|
16
7
|
export { config };
|
|
@@ -7,7 +7,7 @@ import { ApiPipeline } from "@genapi/shared";
|
|
|
7
7
|
//#region src/tanstack/vue/index.d.ts
|
|
8
8
|
declare function openapiPipeline(userConfig: ApiPipeline.Config): Promise<void>;
|
|
9
9
|
declare namespace openapiPipeline {
|
|
10
|
-
var config:
|
|
10
|
+
var config: (userConfig: ApiPipeline.Config) => ApiPipeline.ConfigRead;
|
|
11
11
|
var original: typeof _genapi_pipeline0.original;
|
|
12
12
|
var parser: (configRead: ApiPipeline.ConfigRead) => ApiPipeline.ConfigRead;
|
|
13
13
|
var compiler: typeof _genapi_pipeline0.compiler;
|
|
@@ -1,71 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createQueryParser } from "../../../_shared/query/parser.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/tanstack/vue/parser/index.ts
|
|
4
|
-
|
|
5
|
-
return `use${fetcherName.charAt(0).toUpperCase()}${fetcherName.slice(1)}`;
|
|
6
|
-
}
|
|
7
|
-
const parser = createParser((config, { configRead, functions, interfaces }) => {
|
|
8
|
-
const { parameters, interfaces: attachInters, options } = parseMethodParameters(config);
|
|
9
|
-
let { name, description, url, responseType, body } = parseMethodMetadata(config);
|
|
10
|
-
interfaces.push(...attachInters);
|
|
11
|
-
const fetcherParams = [...parameters];
|
|
12
|
-
fetcherParams.push({
|
|
13
|
-
name: "config",
|
|
14
|
-
type: "RequestInit",
|
|
15
|
-
required: false
|
|
16
|
-
});
|
|
17
|
-
if (config.method.toLowerCase() !== "get") options.unshift(["method", `"${config.method}"`]);
|
|
18
|
-
transformHeaderOptions("body", {
|
|
19
|
-
options,
|
|
20
|
-
parameters
|
|
21
|
-
});
|
|
22
|
-
options.push(["...", "config"]);
|
|
23
|
-
const { spaceResponseType } = transformParameters(parameters, {
|
|
24
|
-
syntax: "typescript",
|
|
25
|
-
configRead,
|
|
26
|
-
description,
|
|
27
|
-
interfaces,
|
|
28
|
-
responseType
|
|
29
|
-
});
|
|
30
|
-
transformBodyStringify("body", {
|
|
31
|
-
options,
|
|
32
|
-
parameters
|
|
33
|
-
});
|
|
34
|
-
url = transformQueryParams("query", {
|
|
35
|
-
body,
|
|
36
|
-
options,
|
|
37
|
-
url
|
|
38
|
-
});
|
|
39
|
-
url = transformUrlSyntax(url, { baseURL: configRead.config.meta?.baseURL });
|
|
40
|
-
const fetchBody = transformFetchBody(url, options, spaceResponseType);
|
|
41
|
-
functions.push({
|
|
42
|
-
export: true,
|
|
43
|
-
async: true,
|
|
44
|
-
name,
|
|
45
|
-
description,
|
|
46
|
-
parameters: fetcherParams,
|
|
47
|
-
body: [...body, ...fetchBody]
|
|
48
|
-
});
|
|
49
|
-
const isRead = ["get", "head"].includes(config.method.toLowerCase());
|
|
50
|
-
const hook = hookName(name);
|
|
51
|
-
const paramNames = fetcherParams.map((p) => p.name).join(", ");
|
|
52
|
-
if (isRead) {
|
|
53
|
-
const queryKeyItems = `'${name}', ${paramNames}`;
|
|
54
|
-
functions.push({
|
|
55
|
-
export: true,
|
|
56
|
-
name: hook,
|
|
57
|
-
description: [`@wraps ${name}`],
|
|
58
|
-
parameters: fetcherParams,
|
|
59
|
-
body: [`return useQuery({ queryKey: [${queryKeyItems}], queryFn: () => ${name}(${paramNames}) })`]
|
|
60
|
-
});
|
|
61
|
-
} else functions.push({
|
|
62
|
-
export: true,
|
|
63
|
-
name: hook,
|
|
64
|
-
description: description ? [...Array.isArray(description) ? description : [description], `@wraps ${name}`] : [`@wraps ${name}`],
|
|
65
|
-
parameters: [],
|
|
66
|
-
body: [`return useMutation({ mutationFn: ${name} })`]
|
|
67
|
-
});
|
|
68
|
-
});
|
|
4
|
+
const parser = createQueryParser();
|
|
69
5
|
|
|
70
6
|
//#endregion
|
|
71
7
|
export { parser };
|