@kubb/plugin-svelte-query 0.0.0-canary-20241104172400
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 +21 -0
- package/README.md +123 -0
- package/dist/chunk-CDRGJAED.cjs +452 -0
- package/dist/chunk-CDRGJAED.cjs.map +1 -0
- package/dist/chunk-JGITTOE5.js +445 -0
- package/dist/chunk-JGITTOE5.js.map +1 -0
- package/dist/chunk-KRGCKSGR.cjs +527 -0
- package/dist/chunk-KRGCKSGR.cjs.map +1 -0
- package/dist/chunk-R6ZVBNG7.js +519 -0
- package/dist/chunk-R6ZVBNG7.js.map +1 -0
- package/dist/components.cjs +28 -0
- package/dist/components.cjs.map +1 -0
- package/dist/components.d.cts +103 -0
- package/dist/components.d.ts +103 -0
- package/dist/components.js +3 -0
- package/dist/components.js.map +1 -0
- package/dist/generators.cjs +17 -0
- package/dist/generators.cjs.map +1 -0
- package/dist/generators.d.cts +10 -0
- package/dist/generators.d.ts +10 -0
- package/dist/generators.js +4 -0
- package/dist/generators.js.map +1 -0
- package/dist/index.cjs +127 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +120 -0
- package/dist/index.js.map +1 -0
- package/dist/types-B9W9aYra.d.cts +365 -0
- package/dist/types-B9W9aYra.d.ts +365 -0
- package/package.json +102 -0
- package/src/components/Mutation.tsx +158 -0
- package/src/components/MutationKey.tsx +54 -0
- package/src/components/Query.tsx +176 -0
- package/src/components/QueryKey.tsx +83 -0
- package/src/components/QueryOptions.tsx +133 -0
- package/src/components/index.ts +5 -0
- package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +51 -0
- package/src/generators/__snapshots__/clientGetImportPath.ts +51 -0
- package/src/generators/__snapshots__/clientPostImportPath.ts +44 -0
- package/src/generators/__snapshots__/findByTags.ts +51 -0
- package/src/generators/__snapshots__/findByTagsObject.ts +60 -0
- package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +51 -0
- package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +51 -0
- package/src/generators/__snapshots__/findByTagsWithZod.ts +51 -0
- package/src/generators/__snapshots__/postAsQuery.ts +50 -0
- package/src/generators/__snapshots__/updatePetById.ts +44 -0
- package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +44 -0
- package/src/generators/index.ts +2 -0
- package/src/generators/mutationGenerator.tsx +117 -0
- package/src/generators/queryGenerator.tsx +129 -0
- package/src/index.ts +2 -0
- package/src/plugin.ts +141 -0
- package/src/types.ts +135 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { Operation } from '@kubb/oas';
|
|
2
|
+
import { OperationSchemas } from '@kubb/plugin-oas';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
4
|
+
import { P as PluginSvelteQuery, T as Transformer } from './types-B9W9aYra.cjs';
|
|
5
|
+
import { FunctionParams } from '@kubb/react';
|
|
6
|
+
import '@kubb/core';
|
|
7
|
+
|
|
8
|
+
type Props$4 = {
|
|
9
|
+
/**
|
|
10
|
+
* Name of the function
|
|
11
|
+
*/
|
|
12
|
+
name: string;
|
|
13
|
+
typeName: string;
|
|
14
|
+
clientName: string;
|
|
15
|
+
mutationKeyName: string;
|
|
16
|
+
typeSchemas: OperationSchemas;
|
|
17
|
+
operation: Operation;
|
|
18
|
+
paramsType: PluginSvelteQuery['resolvedOptions']['paramsType'];
|
|
19
|
+
dataReturnType: PluginSvelteQuery['resolvedOptions']['client']['dataReturnType'];
|
|
20
|
+
pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType'];
|
|
21
|
+
};
|
|
22
|
+
declare function Mutation({ name, clientName, paramsType, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyName }: Props$4): ReactNode;
|
|
23
|
+
|
|
24
|
+
type Props$3 = {
|
|
25
|
+
/**
|
|
26
|
+
* Name of the function
|
|
27
|
+
*/
|
|
28
|
+
name: string;
|
|
29
|
+
queryOptionsName: string;
|
|
30
|
+
queryKeyName: string;
|
|
31
|
+
queryKeyTypeName: string;
|
|
32
|
+
typeSchemas: OperationSchemas;
|
|
33
|
+
operation: Operation;
|
|
34
|
+
paramsType: PluginSvelteQuery['resolvedOptions']['paramsType'];
|
|
35
|
+
pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType'];
|
|
36
|
+
dataReturnType: PluginSvelteQuery['resolvedOptions']['client']['dataReturnType'];
|
|
37
|
+
};
|
|
38
|
+
type GetParamsProps$3 = {
|
|
39
|
+
paramsType: PluginSvelteQuery['resolvedOptions']['paramsType'];
|
|
40
|
+
pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType'];
|
|
41
|
+
dataReturnType: PluginSvelteQuery['resolvedOptions']['client']['dataReturnType'];
|
|
42
|
+
typeSchemas: OperationSchemas;
|
|
43
|
+
};
|
|
44
|
+
declare function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, pathParamsType, dataReturnType, typeSchemas, operation, }: Props$3): ReactNode;
|
|
45
|
+
declare namespace Query {
|
|
46
|
+
var getParams: ({ paramsType, pathParamsType, dataReturnType, typeSchemas }: GetParamsProps$3) => FunctionParams;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
type Props$2 = {
|
|
50
|
+
name: string;
|
|
51
|
+
typeName: string;
|
|
52
|
+
typeSchemas: OperationSchemas;
|
|
53
|
+
operation: Operation;
|
|
54
|
+
pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType'];
|
|
55
|
+
transformer: Transformer | undefined;
|
|
56
|
+
};
|
|
57
|
+
type GetParamsProps$2 = {
|
|
58
|
+
pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType'];
|
|
59
|
+
typeSchemas: OperationSchemas;
|
|
60
|
+
};
|
|
61
|
+
declare function QueryKey({ name, typeSchemas, pathParamsType, operation, typeName, transformer }: Props$2): ReactNode;
|
|
62
|
+
declare namespace QueryKey {
|
|
63
|
+
var getParams: ({ pathParamsType, typeSchemas }: GetParamsProps$2) => FunctionParams;
|
|
64
|
+
var getTransformer: Transformer;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
type Props$1 = {
|
|
68
|
+
name: string;
|
|
69
|
+
typeName: string;
|
|
70
|
+
typeSchemas: OperationSchemas;
|
|
71
|
+
operation: Operation;
|
|
72
|
+
pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType'];
|
|
73
|
+
transformer: Transformer | undefined;
|
|
74
|
+
};
|
|
75
|
+
type GetParamsProps$1 = {
|
|
76
|
+
pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType'];
|
|
77
|
+
typeSchemas: OperationSchemas;
|
|
78
|
+
};
|
|
79
|
+
declare function MutationKey({ name, typeSchemas, pathParamsType, operation, typeName, transformer }: Props$1): ReactNode;
|
|
80
|
+
declare namespace MutationKey {
|
|
81
|
+
var getParams: ({}: GetParamsProps$1) => FunctionParams;
|
|
82
|
+
var getTransformer: Transformer;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
type Props = {
|
|
86
|
+
name: string;
|
|
87
|
+
clientName: string;
|
|
88
|
+
queryKeyName: string;
|
|
89
|
+
typeSchemas: OperationSchemas;
|
|
90
|
+
paramsType: PluginSvelteQuery['resolvedOptions']['paramsType'];
|
|
91
|
+
pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType'];
|
|
92
|
+
};
|
|
93
|
+
type GetParamsProps = {
|
|
94
|
+
paramsType: PluginSvelteQuery['resolvedOptions']['paramsType'];
|
|
95
|
+
pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType'];
|
|
96
|
+
typeSchemas: OperationSchemas;
|
|
97
|
+
};
|
|
98
|
+
declare function QueryOptions({ name, clientName, typeSchemas, paramsType, pathParamsType, queryKeyName }: Props): ReactNode;
|
|
99
|
+
declare namespace QueryOptions {
|
|
100
|
+
var getParams: ({ paramsType, pathParamsType, typeSchemas }: GetParamsProps) => FunctionParams;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export { Mutation, MutationKey, Query, QueryKey, QueryOptions };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { Operation } from '@kubb/oas';
|
|
2
|
+
import { OperationSchemas } from '@kubb/plugin-oas';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
4
|
+
import { P as PluginSvelteQuery, T as Transformer } from './types-B9W9aYra.js';
|
|
5
|
+
import { FunctionParams } from '@kubb/react';
|
|
6
|
+
import '@kubb/core';
|
|
7
|
+
|
|
8
|
+
type Props$4 = {
|
|
9
|
+
/**
|
|
10
|
+
* Name of the function
|
|
11
|
+
*/
|
|
12
|
+
name: string;
|
|
13
|
+
typeName: string;
|
|
14
|
+
clientName: string;
|
|
15
|
+
mutationKeyName: string;
|
|
16
|
+
typeSchemas: OperationSchemas;
|
|
17
|
+
operation: Operation;
|
|
18
|
+
paramsType: PluginSvelteQuery['resolvedOptions']['paramsType'];
|
|
19
|
+
dataReturnType: PluginSvelteQuery['resolvedOptions']['client']['dataReturnType'];
|
|
20
|
+
pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType'];
|
|
21
|
+
};
|
|
22
|
+
declare function Mutation({ name, clientName, paramsType, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyName }: Props$4): ReactNode;
|
|
23
|
+
|
|
24
|
+
type Props$3 = {
|
|
25
|
+
/**
|
|
26
|
+
* Name of the function
|
|
27
|
+
*/
|
|
28
|
+
name: string;
|
|
29
|
+
queryOptionsName: string;
|
|
30
|
+
queryKeyName: string;
|
|
31
|
+
queryKeyTypeName: string;
|
|
32
|
+
typeSchemas: OperationSchemas;
|
|
33
|
+
operation: Operation;
|
|
34
|
+
paramsType: PluginSvelteQuery['resolvedOptions']['paramsType'];
|
|
35
|
+
pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType'];
|
|
36
|
+
dataReturnType: PluginSvelteQuery['resolvedOptions']['client']['dataReturnType'];
|
|
37
|
+
};
|
|
38
|
+
type GetParamsProps$3 = {
|
|
39
|
+
paramsType: PluginSvelteQuery['resolvedOptions']['paramsType'];
|
|
40
|
+
pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType'];
|
|
41
|
+
dataReturnType: PluginSvelteQuery['resolvedOptions']['client']['dataReturnType'];
|
|
42
|
+
typeSchemas: OperationSchemas;
|
|
43
|
+
};
|
|
44
|
+
declare function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, pathParamsType, dataReturnType, typeSchemas, operation, }: Props$3): ReactNode;
|
|
45
|
+
declare namespace Query {
|
|
46
|
+
var getParams: ({ paramsType, pathParamsType, dataReturnType, typeSchemas }: GetParamsProps$3) => FunctionParams;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
type Props$2 = {
|
|
50
|
+
name: string;
|
|
51
|
+
typeName: string;
|
|
52
|
+
typeSchemas: OperationSchemas;
|
|
53
|
+
operation: Operation;
|
|
54
|
+
pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType'];
|
|
55
|
+
transformer: Transformer | undefined;
|
|
56
|
+
};
|
|
57
|
+
type GetParamsProps$2 = {
|
|
58
|
+
pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType'];
|
|
59
|
+
typeSchemas: OperationSchemas;
|
|
60
|
+
};
|
|
61
|
+
declare function QueryKey({ name, typeSchemas, pathParamsType, operation, typeName, transformer }: Props$2): ReactNode;
|
|
62
|
+
declare namespace QueryKey {
|
|
63
|
+
var getParams: ({ pathParamsType, typeSchemas }: GetParamsProps$2) => FunctionParams;
|
|
64
|
+
var getTransformer: Transformer;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
type Props$1 = {
|
|
68
|
+
name: string;
|
|
69
|
+
typeName: string;
|
|
70
|
+
typeSchemas: OperationSchemas;
|
|
71
|
+
operation: Operation;
|
|
72
|
+
pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType'];
|
|
73
|
+
transformer: Transformer | undefined;
|
|
74
|
+
};
|
|
75
|
+
type GetParamsProps$1 = {
|
|
76
|
+
pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType'];
|
|
77
|
+
typeSchemas: OperationSchemas;
|
|
78
|
+
};
|
|
79
|
+
declare function MutationKey({ name, typeSchemas, pathParamsType, operation, typeName, transformer }: Props$1): ReactNode;
|
|
80
|
+
declare namespace MutationKey {
|
|
81
|
+
var getParams: ({}: GetParamsProps$1) => FunctionParams;
|
|
82
|
+
var getTransformer: Transformer;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
type Props = {
|
|
86
|
+
name: string;
|
|
87
|
+
clientName: string;
|
|
88
|
+
queryKeyName: string;
|
|
89
|
+
typeSchemas: OperationSchemas;
|
|
90
|
+
paramsType: PluginSvelteQuery['resolvedOptions']['paramsType'];
|
|
91
|
+
pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType'];
|
|
92
|
+
};
|
|
93
|
+
type GetParamsProps = {
|
|
94
|
+
paramsType: PluginSvelteQuery['resolvedOptions']['paramsType'];
|
|
95
|
+
pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType'];
|
|
96
|
+
typeSchemas: OperationSchemas;
|
|
97
|
+
};
|
|
98
|
+
declare function QueryOptions({ name, clientName, typeSchemas, paramsType, pathParamsType, queryKeyName }: Props): ReactNode;
|
|
99
|
+
declare namespace QueryOptions {
|
|
100
|
+
var getParams: ({ paramsType, pathParamsType, typeSchemas }: GetParamsProps) => FunctionParams;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export { Mutation, MutationKey, Query, QueryKey, QueryOptions };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"components.js"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkCDRGJAED_cjs = require('./chunk-CDRGJAED.cjs');
|
|
4
|
+
require('./chunk-KRGCKSGR.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "mutationGenerator", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunkCDRGJAED_cjs.mutationGenerator; }
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "queryGenerator", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return chunkCDRGJAED_cjs.queryGenerator; }
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=generators.cjs.map
|
|
17
|
+
//# sourceMappingURL=generators.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"generators.cjs"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as _kubb_plugin_oas from '@kubb/plugin-oas';
|
|
2
|
+
import { P as PluginSvelteQuery } from './types-B9W9aYra.cjs';
|
|
3
|
+
import '@kubb/core';
|
|
4
|
+
import '@kubb/oas';
|
|
5
|
+
|
|
6
|
+
declare const queryGenerator: _kubb_plugin_oas.Generator<PluginSvelteQuery>;
|
|
7
|
+
|
|
8
|
+
declare const mutationGenerator: _kubb_plugin_oas.Generator<PluginSvelteQuery>;
|
|
9
|
+
|
|
10
|
+
export { mutationGenerator, queryGenerator };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as _kubb_plugin_oas from '@kubb/plugin-oas';
|
|
2
|
+
import { P as PluginSvelteQuery } from './types-B9W9aYra.js';
|
|
3
|
+
import '@kubb/core';
|
|
4
|
+
import '@kubb/oas';
|
|
5
|
+
|
|
6
|
+
declare const queryGenerator: _kubb_plugin_oas.Generator<PluginSvelteQuery>;
|
|
7
|
+
|
|
8
|
+
declare const mutationGenerator: _kubb_plugin_oas.Generator<PluginSvelteQuery>;
|
|
9
|
+
|
|
10
|
+
export { mutationGenerator, queryGenerator };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"generators.js"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkCDRGJAED_cjs = require('./chunk-CDRGJAED.cjs');
|
|
4
|
+
var chunkKRGCKSGR_cjs = require('./chunk-KRGCKSGR.cjs');
|
|
5
|
+
var path = require('path');
|
|
6
|
+
var core = require('@kubb/core');
|
|
7
|
+
var transformers = require('@kubb/core/transformers');
|
|
8
|
+
var pluginOas = require('@kubb/plugin-oas');
|
|
9
|
+
var pluginTs = require('@kubb/plugin-ts');
|
|
10
|
+
var pluginZod = require('@kubb/plugin-zod');
|
|
11
|
+
|
|
12
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
|
|
14
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
15
|
+
|
|
16
|
+
var pluginSvelteQueryName = "plugin-svelte-query";
|
|
17
|
+
var pluginSvelteQuery = core.createPlugin((options) => {
|
|
18
|
+
const {
|
|
19
|
+
output = { path: "hooks", barrelType: "named" },
|
|
20
|
+
group,
|
|
21
|
+
exclude = [],
|
|
22
|
+
include,
|
|
23
|
+
override = [],
|
|
24
|
+
parser = "client",
|
|
25
|
+
transformers: transformers$1 = {},
|
|
26
|
+
paramsType = "inline",
|
|
27
|
+
pathParamsType = "inline",
|
|
28
|
+
mutation = {},
|
|
29
|
+
query = {},
|
|
30
|
+
mutationKey = chunkKRGCKSGR_cjs.MutationKey.getTransformer,
|
|
31
|
+
queryKey = chunkKRGCKSGR_cjs.QueryKey.getTransformer,
|
|
32
|
+
generators = [chunkCDRGJAED_cjs.queryGenerator, chunkCDRGJAED_cjs.mutationGenerator].filter(Boolean)
|
|
33
|
+
} = options;
|
|
34
|
+
return {
|
|
35
|
+
name: pluginSvelteQueryName,
|
|
36
|
+
options: {
|
|
37
|
+
output,
|
|
38
|
+
client: {
|
|
39
|
+
importPath: "@kubb/plugin-client/client",
|
|
40
|
+
dataReturnType: "data",
|
|
41
|
+
pathParamsType: "inline",
|
|
42
|
+
...options.client
|
|
43
|
+
},
|
|
44
|
+
queryKey,
|
|
45
|
+
query: {
|
|
46
|
+
methods: ["get"],
|
|
47
|
+
importPath: "@tanstack/svelte-query",
|
|
48
|
+
...query
|
|
49
|
+
},
|
|
50
|
+
mutationKey,
|
|
51
|
+
mutation: {
|
|
52
|
+
methods: ["post", "put", "patch", "delete"],
|
|
53
|
+
importPath: "@tanstack/svelte-query",
|
|
54
|
+
...mutation
|
|
55
|
+
},
|
|
56
|
+
paramsType,
|
|
57
|
+
pathParamsType: paramsType === "object" ? "object" : pathParamsType,
|
|
58
|
+
parser
|
|
59
|
+
},
|
|
60
|
+
pre: [pluginOas.pluginOasName, pluginTs.pluginTsName, parser === "zod" ? pluginZod.pluginZodName : void 0].filter(Boolean),
|
|
61
|
+
resolvePath(baseName, pathMode, options2) {
|
|
62
|
+
const root = path__default.default.resolve(this.config.root, this.config.output.path);
|
|
63
|
+
const mode = pathMode ?? core.FileManager.getMode(path__default.default.resolve(root, output.path));
|
|
64
|
+
if (options2?.tag && group?.type === "tag") {
|
|
65
|
+
const groupName = group?.name ? group.name : (ctx) => `${ctx.group}Controller`;
|
|
66
|
+
return path__default.default.resolve(root, output.path, groupName({ group: transformers.camelCase(options2.tag) }), baseName);
|
|
67
|
+
}
|
|
68
|
+
if (mode === "single") {
|
|
69
|
+
return path__default.default.resolve(root, output.path);
|
|
70
|
+
}
|
|
71
|
+
return path__default.default.resolve(root, output.path, baseName);
|
|
72
|
+
},
|
|
73
|
+
resolveName(name, type) {
|
|
74
|
+
let resolvedName = transformers.camelCase(name);
|
|
75
|
+
if (type === "file" || type === "function") {
|
|
76
|
+
resolvedName = transformers.camelCase(name, {
|
|
77
|
+
isFile: type === "file"
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
if (type === "type") {
|
|
81
|
+
resolvedName = transformers.pascalCase(name);
|
|
82
|
+
}
|
|
83
|
+
if (type) {
|
|
84
|
+
return transformers$1?.name?.(resolvedName, type) || resolvedName;
|
|
85
|
+
}
|
|
86
|
+
return resolvedName;
|
|
87
|
+
},
|
|
88
|
+
async buildStart() {
|
|
89
|
+
const [swaggerPlugin] = core.PluginManager.getDependedPlugins(this.plugins, [pluginOas.pluginOasName]);
|
|
90
|
+
const oas = await swaggerPlugin.context.getOas();
|
|
91
|
+
const root = path__default.default.resolve(this.config.root, this.config.output.path);
|
|
92
|
+
const mode = core.FileManager.getMode(path__default.default.resolve(root, output.path));
|
|
93
|
+
const baseURL = await swaggerPlugin.context.getBaseURL();
|
|
94
|
+
if (baseURL) {
|
|
95
|
+
this.plugin.options.client.baseURL = baseURL;
|
|
96
|
+
}
|
|
97
|
+
const operationGenerator = new pluginOas.OperationGenerator(this.plugin.options, {
|
|
98
|
+
oas,
|
|
99
|
+
pluginManager: this.pluginManager,
|
|
100
|
+
plugin: this.plugin,
|
|
101
|
+
contentType: swaggerPlugin.context.contentType,
|
|
102
|
+
exclude,
|
|
103
|
+
include,
|
|
104
|
+
override,
|
|
105
|
+
mode
|
|
106
|
+
});
|
|
107
|
+
const files = await operationGenerator.build(...generators);
|
|
108
|
+
await this.addFile(...files);
|
|
109
|
+
const barrelFiles = await this.fileManager.getBarrelFiles({
|
|
110
|
+
type: output.barrelType ?? "named",
|
|
111
|
+
root,
|
|
112
|
+
output,
|
|
113
|
+
files: this.fileManager.files,
|
|
114
|
+
meta: {
|
|
115
|
+
pluginKey: this.plugin.key
|
|
116
|
+
},
|
|
117
|
+
logger: this.logger
|
|
118
|
+
});
|
|
119
|
+
await this.addFile(...barrelFiles);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
exports.pluginSvelteQuery = pluginSvelteQuery;
|
|
125
|
+
exports.pluginSvelteQueryName = pluginSvelteQueryName;
|
|
126
|
+
//# sourceMappingURL=index.cjs.map
|
|
127
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/plugin.ts"],"names":["createPlugin","transformers","MutationKey","QueryKey","queryGenerator","mutationGenerator","pluginOasName","pluginTsName","pluginZodName","options","path","FileManager","camelCase","pascalCase","PluginManager","OperationGenerator"],"mappings":";;;;;;;;;;;;;;;AAeO,IAAM,qBAAwB,GAAA;AAExB,IAAA,iBAAA,GAAoBA,iBAAgC,CAAA,CAAC,OAAY,KAAA;AAC5E,EAAM,MAAA;AAAA,IACJ,MAAS,GAAA,EAAE,IAAM,EAAA,OAAA,EAAS,YAAY,OAAQ,EAAA;AAAA,IAC9C,KAAA;AAAA,IACA,UAAU,EAAC;AAAA,IACX,OAAA;AAAA,IACA,WAAW,EAAC;AAAA,IACZ,MAAS,GAAA,QAAA;AAAA,kBACTC,iBAAe,EAAC;AAAA,IAChB,UAAa,GAAA,QAAA;AAAA,IACb,cAAiB,GAAA,QAAA;AAAA,IACjB,WAAW,EAAC;AAAA,IACZ,QAAQ,EAAC;AAAA,IACT,cAAcC,6BAAY,CAAA,cAAA;AAAA,IAC1B,WAAWC,0BAAS,CAAA,cAAA;AAAA,IACpB,aAAa,CAACC,gCAAA,EAAgBC,mCAAiB,CAAA,CAAE,OAAO,OAAO;AAAA,GAC7D,GAAA,OAAA;AAEJ,EAAO,OAAA;AAAA,IACL,IAAM,EAAA,qBAAA;AAAA,IACN,OAAS,EAAA;AAAA,MACP,MAAA;AAAA,MACA,MAAQ,EAAA;AAAA,QACN,UAAY,EAAA,4BAAA;AAAA,QACZ,cAAgB,EAAA,MAAA;AAAA,QAChB,cAAgB,EAAA,QAAA;AAAA,QAChB,GAAG,OAAQ,CAAA;AAAA,OACb;AAAA,MACA,QAAA;AAAA,MACA,KAAO,EAAA;AAAA,QACL,OAAA,EAAS,CAAC,KAAK,CAAA;AAAA,QACf,UAAY,EAAA,wBAAA;AAAA,QACZ,GAAG;AAAA,OACL;AAAA,MACA,WAAA;AAAA,MACA,QAAU,EAAA;AAAA,QACR,OAAS,EAAA,CAAC,MAAQ,EAAA,KAAA,EAAO,SAAS,QAAQ,CAAA;AA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AK,OAAO,OAAS,EAAA;AAAA,QACrE,GAAA;AAAA,QACA,eAAe,IAAK,CAAA,aAAA;AAAA,QACpB,QAAQ,IAAK,CAAA,MAAA;AAAA,QACb,WAAA,EAAa,cAAc,OAAQ,CAAA,WAAA;AAAA,QACnC,OAAA;AAAA,QACA,OAAA;AAAA,QACA,QAAA;AAAA,QACA;AAAA,OACD,CAAA;AAED,MAAA,MAAM,KAAQ,GAAA,MAAM,kBAAmB,CAAA,KAAA,CAAM,GAAG,UAAU,CAAA;AAC1D,MAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,KAAK,CAAA;AAE3B,MAAA,MAAM,WAAc,GAAA,MAAM,IAAK,CAAA,WAAA,CAAY,cAAe,CAAA;AAAA,QACxD,IAAA,EAAM,OAAO,UAAc,IAAA,OAAA;AAAA,QAC3B,IAAA;AAAA,QACA,MAAA;AAAA,QACA,KAAA,EAAO,KAAK,WAAY,CAAA,KAAA;AAAA,QACxB,IAAM,EAAA;AAAA,UACJ,SAAA,EAAW,KAAK,MAAO,CAAA;AAAA,SACzB;AAAA,QACA,QAAQ,IAAK,CAAA;AAAA,OACd,CAAA;AAED,MAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,WAAW,CAAA;AAAA;AACnC,GACF;AACF,CAAC","file":"index.cjs","sourcesContent":["import path from 'node:path'\n\nimport { FileManager, type Group, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\n\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas } from '@kubb/plugin-oas'\nimport { MutationKey, QueryKey } from './components'\nimport { mutationGenerator, queryGenerator } from './generators'\nimport type { PluginSvelteQuery } from './types.ts'\n\nexport const pluginSvelteQueryName = 'plugin-svelte-query' satisfies PluginSvelteQuery['name']\n\nexport const pluginSvelteQuery = createPlugin<PluginSvelteQuery>((options) => {\n const {\n output = { path: 'hooks', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n transformers = {},\n paramsType = 'inline',\n pathParamsType = 'inline',\n mutation = {},\n query = {},\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n generators = [queryGenerator, mutationGenerator].filter(Boolean),\n } = options\n\n return {\n name: pluginSvelteQueryName,\n options: {\n output,\n client: {\n importPath: '@kubb/plugin-client/client',\n dataReturnType: 'data',\n pathParamsType: 'inline',\n ...options.client,\n },\n queryKey,\n query: {\n methods: ['get'],\n importPath: '@tanstack/svelte-query',\n ...query,\n },\n mutationKey,\n mutation: {\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/svelte-query',\n ...mutation,\n },\n paramsType,\n pathParamsType: paramsType === 'object' ? 'object' : pathParamsType,\n parser,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (options?.tag && group?.type === 'tag') {\n const groupName: Group['name'] = group?.name ? group.name : (ctx) => `${ctx.group}Controller`\n\n return path.resolve(root, output.path, groupName({ group: camelCase(options.tag) }), baseName)\n }\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name)\n\n if (type === 'file' || type === 'function') {\n resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n }\n if (type === 'type') {\n resolvedName = pascalCase(name)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<PluginOas>] = PluginManager.getDependedPlugins<PluginOas>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n const baseURL = await swaggerPlugin.context.getBaseURL()\n\n if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.context.contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.addFile(...files)\n\n const barrelFiles = await this.fileManager.getBarrelFiles({\n type: output.barrelType ?? 'named',\n root,\n output,\n files: this.fileManager.files,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as _kubb_core from '@kubb/core';
|
|
2
|
+
import { O as Options, P as PluginSvelteQuery } from './types-B9W9aYra.cjs';
|
|
3
|
+
import '@kubb/oas';
|
|
4
|
+
import '@kubb/plugin-oas';
|
|
5
|
+
|
|
6
|
+
declare const pluginSvelteQueryName = "plugin-svelte-query";
|
|
7
|
+
declare const pluginSvelteQuery: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginSvelteQuery>;
|
|
8
|
+
|
|
9
|
+
export { PluginSvelteQuery, pluginSvelteQuery, pluginSvelteQueryName };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as _kubb_core from '@kubb/core';
|
|
2
|
+
import { O as Options, P as PluginSvelteQuery } from './types-B9W9aYra.js';
|
|
3
|
+
import '@kubb/oas';
|
|
4
|
+
import '@kubb/plugin-oas';
|
|
5
|
+
|
|
6
|
+
declare const pluginSvelteQueryName = "plugin-svelte-query";
|
|
7
|
+
declare const pluginSvelteQuery: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginSvelteQuery>;
|
|
8
|
+
|
|
9
|
+
export { PluginSvelteQuery, pluginSvelteQuery, pluginSvelteQueryName };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { queryGenerator, mutationGenerator } from './chunk-JGITTOE5.js';
|
|
2
|
+
import { MutationKey, QueryKey } from './chunk-R6ZVBNG7.js';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { createPlugin, FileManager, PluginManager } from '@kubb/core';
|
|
5
|
+
import { camelCase, pascalCase } from '@kubb/core/transformers';
|
|
6
|
+
import { pluginOasName, OperationGenerator } from '@kubb/plugin-oas';
|
|
7
|
+
import { pluginTsName } from '@kubb/plugin-ts';
|
|
8
|
+
import { pluginZodName } from '@kubb/plugin-zod';
|
|
9
|
+
|
|
10
|
+
var pluginSvelteQueryName = "plugin-svelte-query";
|
|
11
|
+
var pluginSvelteQuery = createPlugin((options) => {
|
|
12
|
+
const {
|
|
13
|
+
output = { path: "hooks", barrelType: "named" },
|
|
14
|
+
group,
|
|
15
|
+
exclude = [],
|
|
16
|
+
include,
|
|
17
|
+
override = [],
|
|
18
|
+
parser = "client",
|
|
19
|
+
transformers = {},
|
|
20
|
+
paramsType = "inline",
|
|
21
|
+
pathParamsType = "inline",
|
|
22
|
+
mutation = {},
|
|
23
|
+
query = {},
|
|
24
|
+
mutationKey = MutationKey.getTransformer,
|
|
25
|
+
queryKey = QueryKey.getTransformer,
|
|
26
|
+
generators = [queryGenerator, mutationGenerator].filter(Boolean)
|
|
27
|
+
} = options;
|
|
28
|
+
return {
|
|
29
|
+
name: pluginSvelteQueryName,
|
|
30
|
+
options: {
|
|
31
|
+
output,
|
|
32
|
+
client: {
|
|
33
|
+
importPath: "@kubb/plugin-client/client",
|
|
34
|
+
dataReturnType: "data",
|
|
35
|
+
pathParamsType: "inline",
|
|
36
|
+
...options.client
|
|
37
|
+
},
|
|
38
|
+
queryKey,
|
|
39
|
+
query: {
|
|
40
|
+
methods: ["get"],
|
|
41
|
+
importPath: "@tanstack/svelte-query",
|
|
42
|
+
...query
|
|
43
|
+
},
|
|
44
|
+
mutationKey,
|
|
45
|
+
mutation: {
|
|
46
|
+
methods: ["post", "put", "patch", "delete"],
|
|
47
|
+
importPath: "@tanstack/svelte-query",
|
|
48
|
+
...mutation
|
|
49
|
+
},
|
|
50
|
+
paramsType,
|
|
51
|
+
pathParamsType: paramsType === "object" ? "object" : pathParamsType,
|
|
52
|
+
parser
|
|
53
|
+
},
|
|
54
|
+
pre: [pluginOasName, pluginTsName, parser === "zod" ? pluginZodName : void 0].filter(Boolean),
|
|
55
|
+
resolvePath(baseName, pathMode, options2) {
|
|
56
|
+
const root = path.resolve(this.config.root, this.config.output.path);
|
|
57
|
+
const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path));
|
|
58
|
+
if (options2?.tag && group?.type === "tag") {
|
|
59
|
+
const groupName = group?.name ? group.name : (ctx) => `${ctx.group}Controller`;
|
|
60
|
+
return path.resolve(root, output.path, groupName({ group: camelCase(options2.tag) }), baseName);
|
|
61
|
+
}
|
|
62
|
+
if (mode === "single") {
|
|
63
|
+
return path.resolve(root, output.path);
|
|
64
|
+
}
|
|
65
|
+
return path.resolve(root, output.path, baseName);
|
|
66
|
+
},
|
|
67
|
+
resolveName(name, type) {
|
|
68
|
+
let resolvedName = camelCase(name);
|
|
69
|
+
if (type === "file" || type === "function") {
|
|
70
|
+
resolvedName = camelCase(name, {
|
|
71
|
+
isFile: type === "file"
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
if (type === "type") {
|
|
75
|
+
resolvedName = pascalCase(name);
|
|
76
|
+
}
|
|
77
|
+
if (type) {
|
|
78
|
+
return transformers?.name?.(resolvedName, type) || resolvedName;
|
|
79
|
+
}
|
|
80
|
+
return resolvedName;
|
|
81
|
+
},
|
|
82
|
+
async buildStart() {
|
|
83
|
+
const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [pluginOasName]);
|
|
84
|
+
const oas = await swaggerPlugin.context.getOas();
|
|
85
|
+
const root = path.resolve(this.config.root, this.config.output.path);
|
|
86
|
+
const mode = FileManager.getMode(path.resolve(root, output.path));
|
|
87
|
+
const baseURL = await swaggerPlugin.context.getBaseURL();
|
|
88
|
+
if (baseURL) {
|
|
89
|
+
this.plugin.options.client.baseURL = baseURL;
|
|
90
|
+
}
|
|
91
|
+
const operationGenerator = new OperationGenerator(this.plugin.options, {
|
|
92
|
+
oas,
|
|
93
|
+
pluginManager: this.pluginManager,
|
|
94
|
+
plugin: this.plugin,
|
|
95
|
+
contentType: swaggerPlugin.context.contentType,
|
|
96
|
+
exclude,
|
|
97
|
+
include,
|
|
98
|
+
override,
|
|
99
|
+
mode
|
|
100
|
+
});
|
|
101
|
+
const files = await operationGenerator.build(...generators);
|
|
102
|
+
await this.addFile(...files);
|
|
103
|
+
const barrelFiles = await this.fileManager.getBarrelFiles({
|
|
104
|
+
type: output.barrelType ?? "named",
|
|
105
|
+
root,
|
|
106
|
+
output,
|
|
107
|
+
files: this.fileManager.files,
|
|
108
|
+
meta: {
|
|
109
|
+
pluginKey: this.plugin.key
|
|
110
|
+
},
|
|
111
|
+
logger: this.logger
|
|
112
|
+
});
|
|
113
|
+
await this.addFile(...barrelFiles);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
export { pluginSvelteQuery, pluginSvelteQueryName };
|
|
119
|
+
//# sourceMappingURL=index.js.map
|
|
120
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/plugin.ts"],"names":["options"],"mappings":";;;;;;;;;AAeO,IAAM,qBAAwB,GAAA;AAExB,IAAA,iBAAA,GAAoB,YAAgC,CAAA,CAAC,OAAY,KAAA;AAC5E,EAAM,MAAA;AAAA,IACJ,MAAS,GAAA,EAAE,IAAM,EAAA,OAAA,EAAS,YAAY,OAAQ,EAA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,CAAA,GAAG,KAAK,CAAA;AAE3B,MAAA,MAAM,WAAc,GAAA,MAAM,IAAK,CAAA,WAAA,CAAY,cAAe,CAAA;AAAA,QACxD,IAAA,EAAM,OAAO,UAAc,IAAA,OAAA;AAAA,QAC3B,IAAA;AAAA,QACA,MAAA;AAAA,QACA,KAAA,EAAO,KAAK,WAAY,CAAA,KAAA;AAAA,QACxB,IAAM,EAAA;AAAA,UACJ,SAAA,EAAW,KAAK,MAAO,CAAA;AAAA,SACzB;AAAA,QACA,QAAQ,IAAK,CAAA;AAAA,OACd,CAAA;AAED,MAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,WAAW,CAAA;AAAA;AACnC,GACF;AACF,CAAC","file":"index.js","sourcesContent":["import path from 'node:path'\n\nimport { FileManager, type Group, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\n\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas } from '@kubb/plugin-oas'\nimport { MutationKey, QueryKey } from './components'\nimport { mutationGenerator, queryGenerator } from './generators'\nimport type { PluginSvelteQuery } from './types.ts'\n\nexport const pluginSvelteQueryName = 'plugin-svelte-query' satisfies PluginSvelteQuery['name']\n\nexport const pluginSvelteQuery = createPlugin<PluginSvelteQuery>((options) => {\n const {\n output = { path: 'hooks', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n transformers = {},\n paramsType = 'inline',\n pathParamsType = 'inline',\n mutation = {},\n query = {},\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n generators = [queryGenerator, mutationGenerator].filter(Boolean),\n } = options\n\n return {\n name: pluginSvelteQueryName,\n options: {\n output,\n client: {\n importPath: '@kubb/plugin-client/client',\n dataReturnType: 'data',\n pathParamsType: 'inline',\n ...options.client,\n },\n queryKey,\n query: {\n methods: ['get'],\n importPath: '@tanstack/svelte-query',\n ...query,\n },\n mutationKey,\n mutation: {\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/svelte-query',\n ...mutation,\n },\n paramsType,\n pathParamsType: paramsType === 'object' ? 'object' : pathParamsType,\n parser,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (options?.tag && group?.type === 'tag') {\n const groupName: Group['name'] = group?.name ? group.name : (ctx) => `${ctx.group}Controller`\n\n return path.resolve(root, output.path, groupName({ group: camelCase(options.tag) }), baseName)\n }\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name)\n\n if (type === 'file' || type === 'function') {\n resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n }\n if (type === 'type') {\n resolvedName = pascalCase(name)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<PluginOas>] = PluginManager.getDependedPlugins<PluginOas>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n const baseURL = await swaggerPlugin.context.getBaseURL()\n\n if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.context.contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.addFile(...files)\n\n const barrelFiles = await this.fileManager.getBarrelFiles({\n type: output.barrelType ?? 'named',\n root,\n output,\n files: this.fileManager.files,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"]}
|